Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

HierarchyLayoutModule.h
Go to the documentation of this file.
1 
33 #pragma once
34 
37 #include <ogdf/layered/Hierarchy.h>
38 
39 namespace ogdf {
40 
41 
48 public:
51 
52  virtual ~HierarchyLayoutModule() { }
53 
59  void call(const HierarchyLevelsBase& levels, GraphAttributes& GA) {
60  GraphAttributes AGC(levels.hierarchy());
61 
62  // Copy over relevant nodeGraphics attributes that may be used by doCall
63  // or need to be preserved. edgeGraphics' bend points need to be cleared
64  // and are not copied over.
66  const GraphCopy& GC = dynamic_cast<const GraphCopy&>(AGC.constGraph());
67  for (node vOrig : GA.constGraph().nodes) {
68  node v = GC.copy(vOrig);
69  if (v != nullptr) {
70  AGC.height(v) = GA.height(vOrig);
71  AGC.width(v) = GA.width(vOrig);
72  AGC.shape(v) = GA.shape(vOrig);
73  }
74  }
75  }
76 
77  doCall(levels, AGC);
78  AGC.transferToOriginal(GA);
79  }
80 
81 #if 0
82 
87  void call(Hierarchy& H, GraphAttributes &AG) {
88  GraphAttributes AGC(H);
89  doCall(H,AGC);
91  HierarchyLayoutModule::addBends(AGC, H);
92  AGC.transferToOriginal(AG);
93  }
94 
101  void call(const Hierarchy& H, GraphAttributes &, GraphAttributes &AGC) {
102  doCall(H,AGC);
103  }
104 
106  static void addBends(GraphAttributes &AGC, HierarchyLevels &levels);
107 #endif
108 
109  static void dynLayerDistance(GraphAttributes& AGC, HierarchyLevelsBase& levels);
110 
111 private:
113  static void overlap(GraphAttributes& AGC, HierarchyLevelsBase& levels, node s, node t, int i,
114  int& ci, int& cj);
115 
116 protected:
118  static inline double getWidth(const GraphAttributes& GA, const HierarchyLevelsBase& levels,
119  node v) {
120  const GraphCopy& GC = levels.hierarchy();
121  return GC.isDummy(v) ? 0.0 : GA.width(v);
122  }
123 
125  static inline double getHeight(const GraphAttributes& GA, const HierarchyLevelsBase& levels,
126  node v) {
127  const GraphCopy& GC = levels.hierarchy();
128  return GC.isDummy(v) ? 0.0 : GA.height(v);
129  }
130 
139  virtual void doCall(const HierarchyLevelsBase& levels, GraphAttributes& AGC) = 0;
140 
142 };
143 
144 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::HierarchyLayoutModule::call
void call(const HierarchyLevelsBase &levels, GraphAttributes &GA)
Computes a hierarchy layout of levels in GA.
Definition: HierarchyLayoutModule.h:59
ogdf::HierarchyLayoutModule::getHeight
static double getHeight(const GraphAttributes &GA, const HierarchyLevelsBase &levels, node v)
Returns the GA height of node v or 0 if it is a dummy node in the hierarchy of levels.
Definition: HierarchyLayoutModule.h:125
ogdf::HierarchyLayoutModule
Interface of hierarchy layout algorithms.
Definition: HierarchyLayoutModule.h:47
ogdf::HierarchyLayoutModule::dynLayerDistance
static void dynLayerDistance(GraphAttributes &AGC, HierarchyLevelsBase &levels)
ogdf::GraphCopyBase::isDummy
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition: GraphCopy.h:166
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:384
ogdf::Hierarchy
Representation of proper hierarchies used by Sugiyama-layout.
Definition: Hierarchy.h:43
ogdf::HierarchyLevelsBase
Definition: CrossingMinInterfaces.h:61
ogdf::GraphAttributes::constGraph
const Graph & constGraph() const
Returns a reference to the associated graph.
Definition: GraphAttributes.h:217
ogdf::GraphAttributes::shape
Shape shape(node v) const
Returns the shape type of node v.
Definition: GraphAttributes.h:423
ogdf::Graph::nodes
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:924
OGDF_MALLOC_NEW_DELETE
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:91
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
ogdf::GraphAttributes::height
double height(node v) const
Returns the height of the bounding box of node v.
Definition: GraphAttributes.h:387
ogdf::GraphAttributes::transferToOriginal
void transferToOriginal(GraphAttributes &origAttr) const
Copies attributes of this to origAttr.
ogdf::HierarchyLayoutModule::~HierarchyLayoutModule
virtual ~HierarchyLayoutModule()
Definition: HierarchyLayoutModule.h:52
ogdf::HierarchyLayoutModule::HierarchyLayoutModule
HierarchyLayoutModule()
Initializes a hierarchy layout module.
Definition: HierarchyLayoutModule.h:50
ogdf::GraphCopy::copy
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
Definition: GraphCopy.h:457
CrossingMinInterfaces.h
Declaration of interfaces used in Sugiyama framework.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::HierarchyLayoutModule::getWidth
static double getWidth(const GraphAttributes &GA, const HierarchyLevelsBase &levels, node v)
Returns the GA width of node v or 0 if it is a dummy node in the hierarchy of levels.
Definition: HierarchyLayoutModule.h:118
Hierarchy.h
Declaration of Hierarchy class.
ogdf::HierarchyLevelsBase::hierarchy
virtual const Hierarchy & hierarchy() const =0
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::GraphAttributes::nodeGraphics
static const long nodeGraphics
Corresponds to node attributes x(node), y(node), width(node), height(node), and shape(node).
Definition: GraphAttributes.h:113
ogdf::GraphAttributes::has
bool has(long attr) const
Returns true iff all attributes in attr are available.
Definition: GraphAttributes.h:194
ogdf::GraphAttributes::width
double width(node v) const
Returns the width of the bounding box of node v.
Definition: GraphAttributes.h:351