Open
Graph Drawing
Framework

 v.2012.05
 

PlanRepUML.h
Go to the documentation of this file.
00001 /*
00002  * $Revision: 2299 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 
00007  ***************************************************************/
00008  
00043 #ifdef _MSC_VER
00044 #pragma once
00045 #endif
00046 
00047 #ifndef OGDF_PLAN_REP_UML_H
00048 #define OGDF_PLAN_REP_UML_H
00049 
00050 
00051 
00052 #include <ogdf/planarity/PlanRep.h>
00053 #include <ogdf/basic/UMLGraph.h>
00054 
00055 #include <ogdf/planarity/EdgeTypePatterns.h> 
00056 #include <ogdf/planarity/NodeTypePatterns.h>
00057 
00058 
00059 
00060 namespace ogdf {
00061 
00062     class OGDF_EXPORT Layout;
00063     class OGDF_EXPORT GridLayoutMapped;
00064     class OGDF_EXPORT OrthoRep;
00065 
00066  
00067 //---------------------------------------------------------
00068 // PlanRepUML
00069 // Planarized representation (of a connected component)
00070 // of a UMLGraph; allows special handling of hierarchies 
00071 // in the graph
00072 //---------------------------------------------------------
00073 class OGDF_EXPORT PlanRepUML : public PlanRep {
00074 public:
00075 
00076     // construction
00077     PlanRepUML(const UMLGraph &umlGraph);
00078     PlanRepUML(const GraphAttributes &GA);
00079 
00080     // deconstruction
00081     ~PlanRepUML() {}
00082 
00083     void initCC(int i); 
00084 
00085     // Returns true if an edge splits a face into two subfaces to 
00086     // guarantee generalizations to be on opposite sides of a node. 
00087     bool faceSplitter(edge e) const{
00088         return m_faceSplitter[e];
00089     }
00090 
00091     // Removes all face splitting edges.
00092     void removeFaceSplitter(){
00093         edge e;
00094         forall_edges(e,(*this))
00095             if (m_faceSplitter[e])
00096                 delEdge(e);
00097     }
00098 
00099     //-------------------
00100     //incremental drawing
00101     //-------------------
00102     //initialize incremental stuff, e.g. insert inremental mergers
00103     void setupIncremental(int indexCC, CombinatorialEmbedding &E);
00104     //Return the list of inserted incremental mergers
00105     const SList<node>&  incrementalMergers(int indexCC) const {return m_incMergers[indexCC];};
00106     
00107 
00108     //**********************************************************
00109     //set generic types
00110   
00111     //the edges that are embedded next to outgoing generalizations if alignment set
00112     //attention: this information is NOT updated during graph changes and only
00113     //to be used during the embedding phase
00114     bool alignUpward(adjEntry ae) {return m_alignUpward[ae];}
00115     void alignUpward(adjEntry ae, bool b) {m_alignUpward[ae] = b;}
00116 
00117     
00118     //*************************************************************************
00119 
00120 
00121     const UMLGraph &getUMLGraph() const {
00122         return *m_pUmlGraph;
00123     }
00124 
00125     //*************************************************************************
00126     //structural alterations
00127 
00128     // inserts a generalization merge node for all incoming
00129     // generalizations of v and returns it
00130     //conserving embedding
00131     node insertGenMerger(node v, const SList<edge> &inGens,
00132                                  CombinatorialEmbedding &E);
00133 
00134     // Expands nodes with degree > 4 and merge nodes for generalizations
00135     void expand(bool lowDegreeExpand = false);
00136 
00137     //expands nodes with degree <= 4 and aligns opposite edges at degree 2 nodes
00138     void expandLowDegreeVertices(OrthoRep &OR, bool alignSmallDegree = false);
00139 
00140     void collapseVertices(const OrthoRep &OR, Layout &drawing);
00141 
00142     //*************************************************************************
00143 
00144 
00145     //
00146     // extension of methods defined by GraphCopy/PlanRep
00147     //
00148 
00149     // splits edge e
00150     virtual edge split(edge e) {
00151         
00152         edge eNew = PlanRep::split(e);
00153         
00154         //check this
00155         if (m_alignUpward[e->adjSource()]) m_alignUpward[eNew->adjSource()] = true;
00156         if (m_alignUpward[e->adjTarget()]) m_alignUpward[eNew->adjTarget()] = true;
00157         
00158         return eNew;
00159     }
00160 
00161 
00162     // writes attributed graph in GML format to file fileName
00163     // For Debugging only
00164     void writeGML(const char *fileName, const Layout &drawing);
00165     void writeGML(const char *fileName);
00166     void writeGML(const char *fileName, GraphAttributes &AG);
00167 
00168     // writes attributed graph in GML format to output stream os
00169     // For Debugging only
00170     void writeGML(ostream &os, const Layout &drawing);
00171     void writeGML(const char *fileName, const OrthoRep &OR, const Layout &drawing);
00172     void writeGML(ostream &os, const OrthoRep &OR, const Layout &drawing);
00173     void writeGML(const char *fileName, const OrthoRep &OR, const GridLayoutMapped &drawing);
00174     void writeGML(ostream &os, const OrthoRep &OR, const GridLayoutMapped &drawing);
00175 
00176         
00177 protected:
00178     //insert mergers of generalizations in copy
00179     void prepareIncrementalMergers(int indexCC, CombinatorialEmbedding &E);
00180 
00181    
00182 protected:
00183     //still some AdjEntry type: used by alignment procedures
00184     //attention: this information is NOT updated during graph changes and only
00185     //to be used during the embedding phase
00186     AdjEntryArray<bool> m_alignUpward;
00187 
00188 private:
00189     const UMLGraph *m_pUmlGraph;
00190     
00191     EdgeArray<bool>     m_faceSplitter;
00192 
00193     SListPure<edge>       m_mergeEdges;
00194     Array< SList<node> >  m_incMergers; //stores all incremental mergers in CC
00195 };
00196 
00197 
00198 } // end namespace ogdf
00199 
00200 #endif