Skip to content

Commit

Permalink
talipot-ogdf/OGDFLayoutPluginBase: Use SimpleCCPacker to draw and pack
Browse files Browse the repository at this point in the history
Prefer to use SimpleCCPacker layout algorithm instead of ComponentSplitterLayout
to draw connected components with a given layout algorithm from OGDF and then
pack the drawings.
  • Loading branch information
anlambert committed Jul 17, 2024
1 parent 60fa300 commit f2f5da3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions library/talipot-ogdf/include/talipot/OGDFLayoutPluginBase.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2019-2021 The Talipot developers
* Copyright (C) 2019-2024 The Talipot developers
*
* Talipot is a fork of Tulip, created by David Auber
* and the Tulip development Team from LaBRI, University of Bordeaux
Expand All @@ -21,7 +21,7 @@
namespace ogdf {
class LayoutModule;
class GraphAttributes;
class ComponentSplitterLayout;
class SimpleCCPacker;
}

namespace tlp {
Expand All @@ -47,7 +47,7 @@ class TLP_OGDF_SCOPE OGDFLayoutPluginBase : public LayoutAlgorithm {

TalipotToOGDF *tlpToOGDF;
ogdf::LayoutModule *ogdfLayoutAlgo;
ogdf::ComponentSplitterLayout *componentSplitterLayout;
ogdf::SimpleCCPacker *simpleCCPacker;
};
}
#endif // TALIPOT_OGDF_LAYOUT_PLUGIN_BASE_H
14 changes: 5 additions & 9 deletions library/talipot-ogdf/src/OGDFLayoutPluginBase.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2019-2021 The Talipot developers
* Copyright (C) 2019-2024 The Talipot developers
*
* Talipot is a fork of Tulip, created by David Auber
* and the Tulip development Team from LaBRI, University of Bordeaux
Expand All @@ -14,7 +14,7 @@
#include <talipot/OGDFLayoutPluginBase.h>
#include <talipot/LayoutProperty.h>

#include <ogdf/packing/ComponentSplitterLayout.h>
#include <ogdf/packing/SimpleCCPacker.h>

#include <talipot/DrawingTools.h>

Expand All @@ -24,20 +24,16 @@ using namespace tlp;
OGDFLayoutPluginBase::OGDFLayoutPluginBase(const PluginContext *context,
ogdf::LayoutModule *ogdfLayoutAlgo)
: LayoutAlgorithm(context), tlpToOGDF(nullptr), ogdfLayoutAlgo(ogdfLayoutAlgo),
componentSplitterLayout(ogdfLayoutAlgo ? new ogdf::ComponentSplitterLayout : nullptr) {
simpleCCPacker(ogdfLayoutAlgo ? new ogdf::SimpleCCPacker(ogdfLayoutAlgo) : nullptr) {
// convert Tulip Graph to OGDF Graph including attributes
if (graph) {
tlpToOGDF = new TalipotToOGDF(graph, false);
}
if (ogdfLayoutAlgo) {
// ComponentSplitterLayout takes ownership of the LayoutModule instance
componentSplitterLayout->setLayoutModule(ogdfLayoutAlgo);
}
}

OGDFLayoutPluginBase::~OGDFLayoutPluginBase() {
delete tlpToOGDF;
delete componentSplitterLayout;
delete simpleCCPacker;
}

bool OGDFLayoutPluginBase::run() {
Expand Down Expand Up @@ -117,7 +113,7 @@ bool OGDFLayoutPluginBase::run() {
}

void OGDFLayoutPluginBase::callOGDFLayoutAlgorithm(ogdf::GraphAttributes &gAttributes) {
componentSplitterLayout->call(gAttributes);
simpleCCPacker->call(gAttributes);
}

void OGDFLayoutPluginBase::transposeLayoutVertically() {
Expand Down

0 comments on commit f2f5da3

Please sign in to comment.