Open
Graph Drawing
Framework

 v.2012.07
 

PlanarizationLayout.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2583 $
3  *
4  * last checkin:
5  * $Author: gutwenger $
6  * $Date: 2012-07-12 01:02:21 +0200 (Do, 12. Jul 2012) $
7  ***************************************************************/
8 
44 #ifdef _MSC_VER
45 #pragma once
46 #endif
47 
48 #ifndef OGDF_UML_PLANARIZATION_LAYOUT_H
49 #define OGDF_UML_PLANARIZATION_LAYOUT_H
50 
51 
52 
60 #include <ogdf/basic/HashArray.h>
61 
62 
63 
64 namespace ogdf {
65 
66 
142 {
143 public:
146 
147  // destructor
148  virtual ~PlanarizationLayout() { }
149 
160  void call(GraphAttributes &GA) {
161  doSimpleCall(&GA);
162  }
163 
169  virtual void call(UMLGraph &umlGraph);
170 
172  void simpleCall(UMLGraph &umlGraph) {
173  //this simple call method does not care about any special treatments
174  //of subgraphs, layout informations etc., therefore we save the
175  //option status and set them back later on
176  //cliques are only handled for UMLGraphs, so it is save to
177  //only set this value here and not in the GraphAtrtibutes interface method.
178  bool l_saveCliqueHandling = m_processCliques;
179  m_processCliques = false;
180 
181  //---------------------------------------------------
182  // preprocessing: insert a merger for generalizations
183 
184  preProcess(umlGraph);
185  umlGraph.insertGenMergers();
186 
187  doSimpleCall(&umlGraph);
188 
189  umlGraph.undoGenMergers();
190 
191  umlGraph.removeUnnecessaryBendsHV();
192 
193  postProcess(umlGraph);
194 
195  m_processCliques = l_saveCliqueHandling;
196  }
197 
198  void simpleCall(GraphAttributes & GA)
199  {
200  doSimpleCall(&GA);
202  }
203 
205  virtual void callSimDraw(UMLGraph &umlGraph);
206 
214  virtual void callFixEmbed(UMLGraph &umlGraph);
215 
216  //call with information about objects that should be
217  //fixed as much as possible in the old/new drawing
218  //for incremental drawing: takes a fixed part of the input
219  //graph (indicated by fixedNodes(Edges)==true), embeds it using
220  //the input layout, then inserts the remaining part into this embedding
221  virtual void callIncremental(UMLGraph &umlgraph,
222  NodeArray<bool> &fixedNodes, const EdgeArray<bool> &fixedEdges);
223 
224 
236  double pageRatio() const {
237  return m_pageRatio;
238  }
239 
241  void pageRatio(double ratio) {
242  m_pageRatio = ratio;
243  }
244 
254  bool preprocessCliques() const {
255  return m_processCliques;
256  }
257 
259  void preprocessCliques(bool b) {
260  m_processCliques = b;
261  }
262 
269  int minCliqueSize() const {
270  return m_cliqueSize;
271  }
272 
274  void minCliqueSize(int i) {
275  m_cliqueSize = max(i, 3);
276  }
277 
278  //set the option field for the planar layouter
279  void setLayouterOptions(int ops)
280  {m_planarLayouter.get().setOptions(ops);}
281 
282  //draw hierarchy nodes corresponding to their level
283  void alignSons(bool b)
284  {
285  int opts = m_planarLayouter.get().getOptions();
286 
287  if (b) m_planarLayouter.get().setOptions(opts | umlOpAlign);
288  else m_planarLayouter.get().setOptions(opts & ~umlOpAlign);
289  }
290 
291 
304  m_subgraph.set(pSubgraph);
305  }
306 
315  void setInserter(EdgeInsertionModule *pInserter) {
316  m_inserter.set(pInserter);
317  }
318 
326  void setEmbedder(EmbedderModule *pEmbedder) {
327  m_embedder.set(pEmbedder);
328  }
329 
340  void setPlanarLayouter(LayoutPlanRepModule *pPlanarLayouter) {
341  m_planarLayouter.set(pPlanarLayouter);
342  }
343 
351  void setPacker(CCLayoutPackModule *pPacker) {
352  m_packer.set(pPacker);
353  }
354 
360 
361  int numberOfCrossings() const {
362  return m_nCrossings;
363  }
364 
366  void assureDrawability(UMLGraph& umlGraph);
367 
369 
370 protected:
371  void doSimpleCall(GraphAttributes *pGA);
372 
373  //sorts the additional nodes for piecewise insertion
374  void sortIncrementalNodes(List<node> &addNodes, const NodeArray<bool> &fixedNodes);
375  void getFixationDistance(node startNode, HashArray<int, int> &distance,
376  const NodeArray<bool> &fixedNodes);
377  //reembeds already planarized PG in case of errors
378  void reembed(PlanRepUML &PG, int ccNumber, bool l_align = false,
379  bool l_gensExist = false);
380 
381  virtual void preProcess(UMLGraph &UG);
382  virtual void postProcess(UMLGraph& UG); //redo changes at original
383 
384  //collect and store nodes around center in correct order
385  void fillAdjNodes(List<node>& adjNodes, PlanRepUML& PG, node centerNode,
386  NodeArray<bool>& isClique, Layout& drawing);
387 
388  void arrangeCCs(PlanRep &PG, GraphAttributes &GA, Array<DPoint> &boundingBox);
389 
390 private:
393 
396 
399 
402 
405 
406  double m_pageRatio;
411 
412  // temporary changes to avoid errors
413  List<edge> m_fakedGens; // made to associations
415 
416  face findBestExternalFace(
417  const PlanRep &PG,
418  const CombinatorialEmbedding &E);
419 };
420 
421 
422 //--------------------------------------------------------
423 //incremental part
424 
427 {
429 
430 public:
432 
433  int compare(const node &v1, const node &v2) const {
434  if ((*m_indToDeg)[v1->index()] < (*m_indToDeg)[v2->index()])
435  return 1;
436  else if ((*m_indToDeg)[v1->index()] > (*m_indToDeg)[v2->index()])
437  return -1;
438  else
439  return 0;
440  }
441 
443 };
444 
445 
446 } // end namespace ogdf
447 
448 
449 #endif