lemon/graph_to_eps.h
changeset 571 d5c39e9d1a4e
parent 515 b9b3473327e3
child 584 33c6b6e755cd
equal deleted inserted replaced
24:1cd488171511 25:d712b2b79af8
    62 
    62 
    63 ///Default traits class of GraphToEps
    63 ///Default traits class of GraphToEps
    64 
    64 
    65 ///Default traits class of \ref GraphToEps.
    65 ///Default traits class of \ref GraphToEps.
    66 ///
    66 ///
    67 ///\c G is the type of the underlying graph.
    67 ///\param GR is the type of the underlying graph.
    68 template<class G>
    68 template<class GR>
    69 struct DefaultGraphToEpsTraits
    69 struct DefaultGraphToEpsTraits
    70 {
    70 {
    71   typedef G Graph;
    71   typedef GR Graph;
    72   typedef typename Graph::Node Node;
    72   typedef typename Graph::Node Node;
    73   typedef typename Graph::NodeIt NodeIt;
    73   typedef typename Graph::NodeIt NodeIt;
    74   typedef typename Graph::Arc Arc;
    74   typedef typename Graph::Arc Arc;
    75   typedef typename Graph::ArcIt ArcIt;
    75   typedef typename Graph::ArcIt ArcIt;
    76   typedef typename Graph::InArcIt InArcIt;
    76   typedef typename Graph::InArcIt InArcIt;
   137 
   137 
   138   bool _preScale;
   138   bool _preScale;
   139   ///Constructor
   139   ///Constructor
   140 
   140 
   141   ///Constructor
   141   ///Constructor
   142   ///\param _g  Reference to the graph to be printed.
   142   ///\param gr  Reference to the graph to be printed.
   143   ///\param _os Reference to the output stream.
   143   ///\param ost Reference to the output stream.
   144   ///\param _os Reference to the output stream.
       
   145   ///By default it is <tt>std::cout</tt>.
   144   ///By default it is <tt>std::cout</tt>.
   146   ///\param _pros If it is \c true, then the \c ostream referenced by \c _os
   145   ///\param pros If it is \c true, then the \c ostream referenced by \c os
   147   ///will be explicitly deallocated by the destructor.
   146   ///will be explicitly deallocated by the destructor.
   148   DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,
   147   DefaultGraphToEpsTraits(const GR &gr, std::ostream& ost = std::cout,
   149                           bool _pros=false) :
   148                           bool pros = false) :
   150     g(_g), os(_os),
   149     g(gr), os(ost),
   151     _coords(dim2::Point<double>(1,1)), _nodeSizes(1), _nodeShapes(0),
   150     _coords(dim2::Point<double>(1,1)), _nodeSizes(1), _nodeShapes(0),
   152     _nodeColors(WHITE), _arcColors(BLACK),
   151     _nodeColors(WHITE), _arcColors(BLACK),
   153     _arcWidths(1.0), _arcWidthScale(0.003),
   152     _arcWidths(1.0), _arcWidthScale(0.003),
   154     _nodeScale(.01), _xBorder(10), _yBorder(10), _scale(1.0),
   153     _nodeScale(.01), _xBorder(10), _yBorder(10), _scale(1.0),
   155     _nodeBorderQuotient(.1),
   154     _nodeBorderQuotient(.1),
   156     _drawArrows(false), _arrowLength(1), _arrowWidth(0.3),
   155     _drawArrows(false), _arrowLength(1), _arrowWidth(0.3),
   157     _showNodes(true), _showArcs(true),
   156     _showNodes(true), _showArcs(true),
   158     _enableParallel(false), _parArcDist(1),
   157     _enableParallel(false), _parArcDist(1),
   159     _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
   158     _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
   160     _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
   159     _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
   161     _undirected(lemon::UndirectedTagIndicator<G>::value),
   160     _undirected(lemon::UndirectedTagIndicator<GR>::value),
   162     _pleaseRemoveOsStream(_pros), _scaleToA4(false),
   161     _pleaseRemoveOsStream(pros), _scaleToA4(false),
   163     _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK),
   162     _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK),
   164     _autoNodeScale(false),
   163     _autoNodeScale(false),
   165     _autoArcWidthScale(false),
   164     _autoArcWidthScale(false),
   166     _absoluteNodeSizes(false),
   165     _absoluteNodeSizes(false),
   167     _absoluteArcWidths(false),
   166     _absoluteArcWidths(false),
  1132 ///For more detailed examples see the \ref graph_to_eps_demo.cc demo file.
  1131 ///For more detailed examples see the \ref graph_to_eps_demo.cc demo file.
  1133 ///
  1132 ///
  1134 ///\warning Don't forget to put the \ref GraphToEps::run() "run()"
  1133 ///\warning Don't forget to put the \ref GraphToEps::run() "run()"
  1135 ///to the end of the parameter list.
  1134 ///to the end of the parameter list.
  1136 ///\sa GraphToEps
  1135 ///\sa GraphToEps
  1137 ///\sa graphToEps(G &g, const char *file_name)
  1136 ///\sa graphToEps(GR &g, const char *file_name)
  1138 template<class G>
  1137 template<class GR>
  1139 GraphToEps<DefaultGraphToEpsTraits<G> >
  1138 GraphToEps<DefaultGraphToEpsTraits<GR> >
  1140 graphToEps(G &g, std::ostream& os=std::cout)
  1139 graphToEps(GR &g, std::ostream& os=std::cout)
  1141 {
  1140 {
  1142   return
  1141   return
  1143     GraphToEps<DefaultGraphToEpsTraits<G> >(DefaultGraphToEpsTraits<G>(g,os));
  1142     GraphToEps<DefaultGraphToEpsTraits<GR> >(DefaultGraphToEpsTraits<GR>(g,os));
  1144 }
  1143 }
  1145 
  1144 
  1146 ///Generates an EPS file from a graph
  1145 ///Generates an EPS file from a graph
  1147 
  1146 
  1148 ///\ingroup eps_io
  1147 ///\ingroup eps_io
  1149 ///This function does the same as
  1148 ///This function does the same as
  1150 ///\ref graphToEps(G &g,std::ostream& os)
  1149 ///\ref graphToEps(GR &g,std::ostream& os)
  1151 ///but it writes its output into the file \c file_name
  1150 ///but it writes its output into the file \c file_name
  1152 ///instead of a stream.
  1151 ///instead of a stream.
  1153 ///\sa graphToEps(G &g, std::ostream& os)
  1152 ///\sa graphToEps(GR &g, std::ostream& os)
  1154 template<class G>
  1153 template<class GR>
  1155 GraphToEps<DefaultGraphToEpsTraits<G> >
  1154 GraphToEps<DefaultGraphToEpsTraits<GR> >
  1156 graphToEps(G &g,const char *file_name)
  1155 graphToEps(GR &g,const char *file_name)
  1157 {
  1156 {
  1158   std::ostream* os = new std::ofstream(file_name);
  1157   std::ostream* os = new std::ofstream(file_name);
  1159   if (!(*os)) {
  1158   if (!(*os)) {
  1160     delete os;
  1159     delete os;
  1161     throw IoError("Cannot write file", file_name);
  1160     throw IoError("Cannot write file", file_name);
  1162   }
  1161   }
  1163   return GraphToEps<DefaultGraphToEpsTraits<G> >
  1162   return GraphToEps<DefaultGraphToEpsTraits<GR> >
  1164     (DefaultGraphToEpsTraits<G>(g,*os,true));
  1163     (DefaultGraphToEpsTraits<GR>(g,*os,true));
  1165 }
  1164 }
  1166 
  1165 
  1167 ///Generates an EPS file from a graph
  1166 ///Generates an EPS file from a graph
  1168 
  1167 
  1169 ///\ingroup eps_io
  1168 ///\ingroup eps_io
  1170 ///This function does the same as
  1169 ///This function does the same as
  1171 ///\ref graphToEps(G &g,std::ostream& os)
  1170 ///\ref graphToEps(GR &g,std::ostream& os)
  1172 ///but it writes its output into the file \c file_name
  1171 ///but it writes its output into the file \c file_name
  1173 ///instead of a stream.
  1172 ///instead of a stream.
  1174 ///\sa graphToEps(G &g, std::ostream& os)
  1173 ///\sa graphToEps(GR &g, std::ostream& os)
  1175 template<class G>
  1174 template<class GR>
  1176 GraphToEps<DefaultGraphToEpsTraits<G> >
  1175 GraphToEps<DefaultGraphToEpsTraits<GR> >
  1177 graphToEps(G &g,const std::string& file_name)
  1176 graphToEps(GR &g,const std::string& file_name)
  1178 {
  1177 {
  1179   std::ostream* os = new std::ofstream(file_name.c_str());
  1178   std::ostream* os = new std::ofstream(file_name.c_str());
  1180   if (!(*os)) {
  1179   if (!(*os)) {
  1181     delete os;
  1180     delete os;
  1182     throw IoError("Cannot write file", file_name);
  1181     throw IoError("Cannot write file", file_name);
  1183   }
  1182   }
  1184   return GraphToEps<DefaultGraphToEpsTraits<G> >
  1183   return GraphToEps<DefaultGraphToEpsTraits<GR> >
  1185     (DefaultGraphToEpsTraits<G>(g,*os,true));
  1184     (DefaultGraphToEpsTraits<GR>(g,*os,true));
  1186 }
  1185 }
  1187 
  1186 
  1188 } //END OF NAMESPACE LEMON
  1187 } //END OF NAMESPACE LEMON
  1189 
  1188 
  1190 #endif // LEMON_GRAPH_TO_EPS_H
  1189 #endif // LEMON_GRAPH_TO_EPS_H