lemon/graph_to_eps.h
changeset 131 3125084667a3
parent 130 88c4f7943b75
child 132 50ff949140fa
equal deleted inserted replaced
1:3ec2380c9941 2:5ca504ee6989
    47 ///
    47 ///
    48 ///\author Alpar Juttner
    48 ///\author Alpar Juttner
    49 
    49 
    50 namespace lemon {
    50 namespace lemon {
    51 
    51 
    52 template<class MT>
    52   namespace _graph_to_eps_bits {
    53 class _NegY {
    53     template<class MT>
    54 public:
    54     class _NegY {
    55   typedef typename MT::Key Key;
    55     public:
    56   typedef typename MT::Value Value;
    56       typedef typename MT::Key Key;
    57   const MT &map;
    57       typedef typename MT::Value Value;
    58   int yscale;
    58       const MT &map;
    59   _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {}
    59       int yscale;
    60   Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);}
    60       _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {}
    61 };
    61       Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);}
    62 
    62     };
       
    63   }
       
    64   
    63 ///Default traits class of \ref GraphToEps
    65 ///Default traits class of \ref GraphToEps
    64 
    66 
    65 ///Default traits class of \ref GraphToEps
    67 ///Default traits class of \ref GraphToEps
    66 ///
    68 ///
    67 ///\c G is the type of the underlying graph.
    69 ///\c G is the type of the underlying graph.
   156     _drawArrows(false), _arrowLength(1), _arrowWidth(0.3),
   158     _drawArrows(false), _arrowLength(1), _arrowWidth(0.3),
   157     _showNodes(true), _showArcs(true),
   159     _showNodes(true), _showArcs(true),
   158     _enableParallel(false), _parArcDist(1),
   160     _enableParallel(false), _parArcDist(1),
   159     _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
   161     _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
   160     _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
   162     _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
   161     _undirected(false),
   163     _undirected(lemon::UndirectedTagIndicator<G>::value),
   162     _pleaseRemoveOsStream(_pros), _scaleToA4(false),
   164     _pleaseRemoveOsStream(_pros), _scaleToA4(false),
   163     _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK),
   165     _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK),
   164     _autoNodeScale(false),
   166     _autoNodeScale(false),
   165     _autoArcWidthScale(false),
   167     _autoArcWidthScale(false),
   166     _absoluteNodeSizes(false),
   168     _absoluteNodeSizes(false),
   666 
   668 
   667   ///Sets whether the the graph is directed
   669   ///Sets whether the the graph is directed
   668 
   670 
   669   ///Sets whether the the graph is directed.
   671   ///Sets whether the the graph is directed.
   670   ///Use it to show the edges as a pair of directed ones.
   672   ///Use it to show the edges as a pair of directed ones.
   671   GraphToEps<T> &bidir(bool b=true) {_undirected=!b;return *this;}
   673   GraphToEps<T> &directed(bool b=true) {_undirected=!b;return *this;}
   672 
   674 
   673   ///Sets the title.
   675   ///Sets the title.
   674 
   676 
   675   ///Sets the title of the generated image,
   677   ///Sets the title of the generated image,
   676   ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
   678   ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
   712   void run() {
   714   void run() {
   713     ///\todo better 'epsilon' would be nice here.
   715     ///\todo better 'epsilon' would be nice here.
   714     const double EPSILON=1e-9;
   716     const double EPSILON=1e-9;
   715     if(dontPrint) return;
   717     if(dontPrint) return;
   716     
   718     
   717     _NegY<typename T::CoordsMapType> mycoords(_coords,_negY);
   719     _graph_to_eps_bits::_NegY<typename T::CoordsMapType>
       
   720       mycoords(_coords,_negY);
   718 
   721 
   719     os << "%!PS-Adobe-2.0 EPSF-2.0\n";
   722     os << "%!PS-Adobe-2.0 EPSF-2.0\n";
   720     if(_title.size()>0) os << "%%Title: " << _title << '\n';
   723     if(_title.size()>0) os << "%%Title: " << _title << '\n';
   721      if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
   724      if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
   722 //        << "%%Copyright: XXXX\n"
   725 //        << "%%Copyright: XXXX\n"