src/lemon/graph_to_eps.h
changeset 1252 4fee8e9d9014
parent 1202 da44ee225dad
child 1287 984723507b86
equal deleted inserted replaced
13:65f445798a01 14:24a10543d446
    24 #include<fstream>
    24 #include<fstream>
    25 #include<sstream>
    25 #include<sstream>
    26 #include<algorithm>
    26 #include<algorithm>
    27 #include<vector>
    27 #include<vector>
    28 
    28 
       
    29 #include<lemon/invalid.h>
    29 #include<lemon/xy.h>
    30 #include<lemon/xy.h>
    30 #include<lemon/maps.h>
    31 #include<lemon/maps.h>
    31 #include<lemon/bezier.h>
    32 #include<lemon/bezier.h>
    32 
    33 
    33 ///\ingroup misc
    34 ///\ingroup misc
   189   ConstMap<typename Graph::Node,Color > _nodeColors;
   190   ConstMap<typename Graph::Node,Color > _nodeColors;
   190   ConstMap<typename Graph::Edge,Color > _edgeColors;
   191   ConstMap<typename Graph::Edge,Color > _edgeColors;
   191 
   192 
   192   ConstMap<typename Graph::Edge,double > _edgeWidths;
   193   ConstMap<typename Graph::Edge,double > _edgeWidths;
   193 
   194 
   194   static const double A4HEIGHT = 841.8897637795276;
       
   195   static const double A4WIDTH  = 595.275590551181;
       
   196   static const double A4BORDER = 15;
       
   197 
       
   198   
       
   199   double _edgeWidthScale;
   195   double _edgeWidthScale;
   200   
   196   
   201   double _nodeScale;
   197   double _nodeScale;
   202   double _xBorder, _yBorder;
   198   double _xBorder, _yBorder;
   203   double _scale;
   199   double _scale;
   269 ///\todo Useful new features.
   265 ///\todo Useful new features.
   270 /// - Linestyles: dotted, dashed etc.
   266 /// - Linestyles: dotted, dashed etc.
   271 /// - A second color and percent value for the lines.
   267 /// - A second color and percent value for the lines.
   272 template<class T> class GraphToEps : public T 
   268 template<class T> class GraphToEps : public T 
   273 {
   269 {
       
   270   // Can't believe it is required by the C++ standard
       
   271   using T::g;
       
   272   using T::os;
       
   273 
       
   274   using T::_coords;
       
   275   using T::_nodeSizes;
       
   276   using T::_nodeShapes;
       
   277   using T::_nodeColors;
       
   278   using T::_edgeColors;
       
   279   using T::_edgeWidths;
       
   280 
       
   281   using T::_edgeWidthScale;
       
   282   using T::_nodeScale;
       
   283   using T::_xBorder;
       
   284   using T::_yBorder;
       
   285   using T::_scale;
       
   286   using T::_nodeBorderQuotient;
       
   287   
       
   288   using T::_drawArrows;
       
   289   using T::_arrowLength;
       
   290   using T::_arrowWidth;
       
   291   
       
   292   using T::_showNodes;
       
   293   using T::_showEdges;
       
   294 
       
   295   using T::_enableParallel;
       
   296   using T::_parEdgeDist;
       
   297 
       
   298   using T::_showNodeText;
       
   299   using T::_nodeTexts;  
       
   300   using T::_nodeTextSize;
       
   301 
       
   302   using T::_showNodePsText;
       
   303   using T::_nodePsTexts;  
       
   304   using T::_nodePsTextsPreamble;
       
   305   
       
   306   using T::_undir;
       
   307   using T::_pleaseRemoveOsStream;
       
   308 
       
   309   using T::_scaleToA4;
       
   310 
       
   311   using T::_title;
       
   312   using T::_copyright;
       
   313 
       
   314   using T::NodeTextColorType;
       
   315   using T::CUST_COL;
       
   316   using T::DIST_COL;
       
   317   using T::DIST_BW;
       
   318   using T::_nodeTextColorType;
       
   319   using T::_nodeTextColors;
       
   320   // dradnats ++C eht yb deriuqer si ti eveileb t'naC
       
   321 
   274   typedef typename T::Graph Graph;
   322   typedef typename T::Graph Graph;
   275   typedef typename Graph::Node Node;
   323   typedef typename Graph::Node Node;
   276   typedef typename Graph::NodeIt NodeIt;
   324   typedef typename Graph::NodeIt NodeIt;
   277   typedef typename Graph::Edge Edge;
   325   typedef typename Graph::Edge Edge;
   278   typedef typename Graph::EdgeIt EdgeIt;
   326   typedef typename Graph::EdgeIt EdgeIt;
   279   typedef typename Graph::InEdgeIt InEdgeIt;
   327   typedef typename Graph::InEdgeIt InEdgeIt;
   280   typedef typename Graph::OutEdgeIt OutEdgeIt;
   328   typedef typename Graph::OutEdgeIt OutEdgeIt;
   281 
   329 
   282   static const int INTERPOL_PREC=20;
   330   static const int INTERPOL_PREC=20;
       
   331   static const double A4HEIGHT = 841.8897637795276;
       
   332   static const double A4WIDTH  = 595.275590551181;
       
   333   static const double A4BORDER = 15;
   283 
   334 
   284   bool dontPrint;
   335   bool dontPrint;
   285 
   336 
   286 public:
   337 public:
   287   ///Node shapes
   338   ///Node shapes
   321 		    (aa==ba && ai==g.source(a) && bi==g.target(b))));
   372 		    (aa==ba && ai==g.source(a) && bi==g.target(b))));
   322     }
   373     }
   323   };
   374   };
   324   bool isParallel(Edge e,Edge f) const
   375   bool isParallel(Edge e,Edge f) const
   325   {
   376   {
   326     return (g.source(e)==g.source(f)&&g.target(e)==g.target(f))||
   377     return (g.source(e)==g.source(f)&&
   327       (g.source(e)==g.target(f)&&g.target(e)==g.source(f));
   378 	    g.target(e)==g.target(f)) ||
       
   379       (g.source(e)==g.target(f)&&
       
   380        g.target(e)==g.source(f));
   328   }
   381   }
   329   template<class TT>
   382   template<class TT>
   330   static std::string psOut(const xy<TT> &p) 
   383   static std::string psOut(const xy<TT> &p) 
   331     {
   384     {
   332       std::ostringstream os;	
   385       std::ostringstream os;	
   581   
   634   
   582   ///Gives a preamble block for node Postscript block.
   635   ///Gives a preamble block for node Postscript block.
   583   ///
   636   ///
   584   ///\sa nodePsTexts()
   637   ///\sa nodePsTexts()
   585   GraphToEps<T> & nodePsTextsPreamble(const char *str) {
   638   GraphToEps<T> & nodePsTextsPreamble(const char *str) {
   586     _nodePsTextsPreamble=s ;return *this;
   639     _nodePsTextsPreamble=str ;return *this;
   587   }
   640   }
   588   ///Sets whether the the graph is undirected
   641   ///Sets whether the the graph is undirected
   589 
   642 
   590   ///Sets whether the the graph is undirected
   643   ///Sets whether the the graph is undirected
   591   ///
   644   ///