Open
Graph Drawing
Framework

 v.2012.05
 

PlanRepInc.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  
00048 #ifdef _MSC_VER
00049 #pragma once
00050 #endif
00051 
00052 
00053 #ifndef OGDF_PLAN_REP_INC_H
00054 #define OGDF_PLAN_REP_INC_H
00055 
00056 
00057 
00058 #include <ogdf/planarity/PlanRep.h>
00059 #include <ogdf/planarity/PlanRepUML.h>
00060 #include <ogdf/basic/UMLGraph.h>
00061 #include <ogdf/basic/GraphAttributes.h>
00062 #include <ogdf/basic/GraphObserver.h>
00063 #include <ogdf/basic/Array2D.h>
00064 
00065 
00066 namespace ogdf {
00067 
00068 
00069 //===============================================
00070 //main function(s):
00071 //
00072 //      this class is only an adaption of PlanRep
00073 //      for the special incremental drawing case
00074 //      As incremental layout only makes sense with
00075 //      a given layout, this PlanRepInc copes with
00076 //      layout information and embedding
00077 //===============================================
00078 
00079 class OGDF_EXPORT PlanRepInc : public PlanRepUML, public GraphObserver
00080 {   
00081 public:
00082     //construction
00083     //constructor for interactive updates (parts added step by step)
00084     PlanRepInc(const UMLGraph& UG);
00085     //constructor for incremental updates (whole graph already given)
00086     //part to stay fixed has fixed value set to true
00087     PlanRepInc(const UMLGraph& UG, const NodeArray<bool> &fixed);
00088 
00089     //init a CC only with active elements
00090     void initActiveCC(int i);
00091     //but with at least one active node, makes a node active if necessary
00092     //and returns it. returns 0 otherwise
00093     node initMinActiveCC(int i); 
00094 
00095     //in the case that the underlying incremental structure
00096     //changes, we update this copy
00097     virtual void nodeDeleted(node v);
00098     virtual void nodeAdded(node v);
00099     virtual void edgeDeleted(edge e);
00100     virtual void edgeAdded(edge e);
00101     virtual void reInit(); 
00102     virtual void cleared();//Graph cleared
00103 
00104     //sets activity status to true and updates the structures
00105     //node activation activates all adjacent edges
00106     void activateNode(node v);
00107     //TODO: auch deaktivieren
00108     //void activateNode(node v, bool b);
00109     void activateEdge(edge e);
00110 
00111     //handles copies of original CCs that are split into 
00112     //unconnected parts of active nodes by connecting them
00113     //tree-like adding necessary edges at "external" nodes 
00114     //of the partial CCs. Note that this only makes sense
00115     //when the CC parts are already correctly embedded
00116     bool makeTreeConnected(adjEntry adjExternal);
00117     //delete an edge again
00118     void deleteTreeConnection(int i, int j);
00119     void deleteTreeConnection(int i, int j, CombinatorialEmbedding &E);
00120     //sets a list of adjentries on "external" faces of 
00121     //unconnected active parts of the current CC
00122     void getExtAdjs(List<adjEntry> &extAdjs);
00123     adjEntry getExtAdj(GraphCopy &GC, CombinatorialEmbedding &E);
00124 
00125     //component number
00126     int& componentNumber(node v) {return m_component[v];}
00127 
00128     bool& treeEdge(edge e) {return m_treeEdge[e];}
00129     //only valid if m_eTreeArray initialized, should be replaced later
00130     const edge  treeEdge(int i, int j) const 
00131         {
00132             if (m_treeInit) return m_eTreeArray(i, j);
00133             else return 0;
00134         }
00135     bool treeInit() {return m_treeInit;}
00136 
00137     //
00138     // extension of methods defined by GraphCopy/PlanRep
00139     //
00140 
00141     // splits edge e, can be removed when edge status in edgetype
00142     // m_treedge can be removed afterwards
00143     virtual edge split(edge e) {
00144         
00145         edge eNew = PlanRepUML::split(e);
00146         if (m_treeEdge[e]) m_treeEdge[eNew] = true;
00147 
00148         return eNew;
00149 
00150     }//split
00151 
00152     //debug output
00153 #ifdef OGDF_DEBUG
00154     void writeGML(const char *fileName)
00155     {
00156         const GraphAttributes &AG = getUMLGraph();
00157         ofstream os(fileName);
00158         PlanRepInc::writeGML(os, AG);//getUMLGraph());//l);
00159     }
00160     void writeGML(const char *fileName, const Layout &drawing)
00161     {
00162         ofstream os(fileName);
00163         writeGML(os, drawing);
00164     }
00165 
00166     void writeGML(ostream &os, const GraphAttributes &AG);
00167     void writeGML(ostream &os, const Layout &drawing, bool colorEmbed = true);
00168     void writeGML(const char *fileName, GraphAttributes &AG, bool colorEmbed = true);
00169 
00170     //outputs a drawing if genus != 0
00171     int genusLayout(Layout &drawing) const;
00172 #endif
00173 
00174 protected: 
00175     void initMembers(const UMLGraph &UG);
00176     //initialize CC with active nodes (minNode ? at least one node)
00177     node initActiveCCGen(int i, bool minNode);
00178 
00179 private:
00180     NodeArray<bool> m_activeNodes; //stores the status of the nodes
00181     EdgeArray<bool> m_treeEdge; //edge inserted for connnectivity
00182     NodeArray<int> m_component; //number of partial component in current CC
00183                                 //used for treeConnection
00184     Array2D<edge> m_eTreeArray;    //used for treeConnection
00185     bool m_treeInit;           //check if the tree edge Array2D was initialized
00186 };//PlanrepInc
00187 
00188 
00189 }//namespace ogdf
00190 
00191 #endif