1.1 --- a/lemon/graph_to_eps.h Mon Jan 12 23:11:39 2009 +0100
1.2 +++ b/lemon/graph_to_eps.h Thu Nov 05 15:48:01 2009 +0100
1.3 @@ -29,9 +29,7 @@
1.4 #include<sys/time.h>
1.5 #include<ctime>
1.6 #else
1.7 -#define WIN32_LEAN_AND_MEAN
1.8 -#define NOMINMAX
1.9 -#include<windows.h>
1.10 +#include<lemon/bits/windows.h>
1.11 #endif
1.12
1.13 #include<lemon/math.h>
1.14 @@ -66,11 +64,12 @@
1.15
1.16 ///Default traits class of \ref GraphToEps.
1.17 ///
1.18 -///\c G is the type of the underlying graph.
1.19 -template<class G>
1.20 +///\param GR is the type of the underlying graph.
1.21 +template<class GR>
1.22 struct DefaultGraphToEpsTraits
1.23 {
1.24 - typedef G Graph;
1.25 + typedef GR Graph;
1.26 + typedef GR Digraph;
1.27 typedef typename Graph::Node Node;
1.28 typedef typename Graph::NodeIt NodeIt;
1.29 typedef typename Graph::Arc Arc;
1.30 @@ -141,15 +140,14 @@
1.31 ///Constructor
1.32
1.33 ///Constructor
1.34 - ///\param _g Reference to the graph to be printed.
1.35 - ///\param _os Reference to the output stream.
1.36 - ///\param _os Reference to the output stream.
1.37 + ///\param gr Reference to the graph to be printed.
1.38 + ///\param ost Reference to the output stream.
1.39 ///By default it is <tt>std::cout</tt>.
1.40 - ///\param _pros If it is \c true, then the \c ostream referenced by \c _os
1.41 + ///\param pros If it is \c true, then the \c ostream referenced by \c os
1.42 ///will be explicitly deallocated by the destructor.
1.43 - DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,
1.44 - bool _pros=false) :
1.45 - g(_g), os(_os),
1.46 + DefaultGraphToEpsTraits(const GR &gr, std::ostream& ost = std::cout,
1.47 + bool pros = false) :
1.48 + g(gr), os(ost),
1.49 _coords(dim2::Point<double>(1,1)), _nodeSizes(1), _nodeShapes(0),
1.50 _nodeColors(WHITE), _arcColors(BLACK),
1.51 _arcWidths(1.0), _arcWidthScale(0.003),
1.52 @@ -160,8 +158,8 @@
1.53 _enableParallel(false), _parArcDist(1),
1.54 _showNodeText(false), _nodeTexts(false), _nodeTextSize(1),
1.55 _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0),
1.56 - _undirected(lemon::UndirectedTagIndicator<G>::value),
1.57 - _pleaseRemoveOsStream(_pros), _scaleToA4(false),
1.58 + _undirected(lemon::UndirectedTagIndicator<GR>::value),
1.59 + _pleaseRemoveOsStream(pros), _scaleToA4(false),
1.60 _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK),
1.61 _autoNodeScale(false),
1.62 _autoArcWidthScale(false),
1.63 @@ -244,6 +242,7 @@
1.64 // dradnats ++C eht yb deriuqer si ti eveileb t'naC
1.65
1.66 typedef typename T::Graph Graph;
1.67 + typedef typename T::Digraph Digraph;
1.68 typedef typename Graph::Node Node;
1.69 typedef typename Graph::NodeIt NodeIt;
1.70 typedef typename Graph::Arc Arc;
1.71 @@ -271,22 +270,18 @@
1.72 /// = 1
1.73 ///\image html nodeshape_1.png
1.74 ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
1.75 - ///
1.76 SQUARE=1,
1.77 /// = 2
1.78 ///\image html nodeshape_2.png
1.79 ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
1.80 - ///
1.81 DIAMOND=2,
1.82 /// = 3
1.83 ///\image html nodeshape_3.png
1.84 - ///\image latex nodeshape_2.eps "MALE shape (4)" width=2cm
1.85 - ///
1.86 + ///\image latex nodeshape_3.eps "MALE shape (3)" width=2cm
1.87 MALE=3,
1.88 /// = 4
1.89 ///\image html nodeshape_4.png
1.90 - ///\image latex nodeshape_2.eps "FEMALE shape (4)" width=2cm
1.91 - ///
1.92 + ///\image latex nodeshape_4.eps "FEMALE shape (4)" width=2cm
1.93 FEMALE=4
1.94 };
1.95
1.96 @@ -679,29 +674,19 @@
1.97 os << "%%Creator: LEMON, graphToEps()\n";
1.98
1.99 {
1.100 + os << "%%CreationDate: ";
1.101 #ifndef WIN32
1.102 timeval tv;
1.103 gettimeofday(&tv, 0);
1.104
1.105 char cbuf[26];
1.106 ctime_r(&tv.tv_sec,cbuf);
1.107 - os << "%%CreationDate: " << cbuf;
1.108 + os << cbuf;
1.109 #else
1.110 - SYSTEMTIME time;
1.111 - char buf1[11], buf2[9], buf3[5];
1.112 -
1.113 - GetSystemTime(&time);
1.114 - if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
1.115 - "ddd MMM dd", buf1, 11) &&
1.116 - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
1.117 - "HH':'mm':'ss", buf2, 9) &&
1.118 - GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
1.119 - "yyyy", buf3, 5)) {
1.120 - os << "%%CreationDate: " << buf1 << ' '
1.121 - << buf2 << ' ' << buf3 << std::endl;
1.122 - }
1.123 + os << bits::getWinFormattedDate();
1.124 #endif
1.125 }
1.126 + os << std::endl;
1.127
1.128 if (_autoArcWidthScale) {
1.129 double max_w=0;
1.130 @@ -1146,55 +1131,55 @@
1.131 ///\warning Don't forget to put the \ref GraphToEps::run() "run()"
1.132 ///to the end of the parameter list.
1.133 ///\sa GraphToEps
1.134 -///\sa graphToEps(G &g, const char *file_name)
1.135 -template<class G>
1.136 -GraphToEps<DefaultGraphToEpsTraits<G> >
1.137 -graphToEps(G &g, std::ostream& os=std::cout)
1.138 +///\sa graphToEps(GR &g, const char *file_name)
1.139 +template<class GR>
1.140 +GraphToEps<DefaultGraphToEpsTraits<GR> >
1.141 +graphToEps(GR &g, std::ostream& os=std::cout)
1.142 {
1.143 return
1.144 - GraphToEps<DefaultGraphToEpsTraits<G> >(DefaultGraphToEpsTraits<G>(g,os));
1.145 + GraphToEps<DefaultGraphToEpsTraits<GR> >(DefaultGraphToEpsTraits<GR>(g,os));
1.146 }
1.147
1.148 ///Generates an EPS file from a graph
1.149
1.150 ///\ingroup eps_io
1.151 ///This function does the same as
1.152 -///\ref graphToEps(G &g,std::ostream& os)
1.153 +///\ref graphToEps(GR &g,std::ostream& os)
1.154 ///but it writes its output into the file \c file_name
1.155 ///instead of a stream.
1.156 -///\sa graphToEps(G &g, std::ostream& os)
1.157 -template<class G>
1.158 -GraphToEps<DefaultGraphToEpsTraits<G> >
1.159 -graphToEps(G &g,const char *file_name)
1.160 +///\sa graphToEps(GR &g, std::ostream& os)
1.161 +template<class GR>
1.162 +GraphToEps<DefaultGraphToEpsTraits<GR> >
1.163 +graphToEps(GR &g,const char *file_name)
1.164 {
1.165 std::ostream* os = new std::ofstream(file_name);
1.166 if (!(*os)) {
1.167 delete os;
1.168 throw IoError("Cannot write file", file_name);
1.169 }
1.170 - return GraphToEps<DefaultGraphToEpsTraits<G> >
1.171 - (DefaultGraphToEpsTraits<G>(g,*os,true));
1.172 + return GraphToEps<DefaultGraphToEpsTraits<GR> >
1.173 + (DefaultGraphToEpsTraits<GR>(g,*os,true));
1.174 }
1.175
1.176 ///Generates an EPS file from a graph
1.177
1.178 ///\ingroup eps_io
1.179 ///This function does the same as
1.180 -///\ref graphToEps(G &g,std::ostream& os)
1.181 +///\ref graphToEps(GR &g,std::ostream& os)
1.182 ///but it writes its output into the file \c file_name
1.183 ///instead of a stream.
1.184 -///\sa graphToEps(G &g, std::ostream& os)
1.185 -template<class G>
1.186 -GraphToEps<DefaultGraphToEpsTraits<G> >
1.187 -graphToEps(G &g,const std::string& file_name)
1.188 +///\sa graphToEps(GR &g, std::ostream& os)
1.189 +template<class GR>
1.190 +GraphToEps<DefaultGraphToEpsTraits<GR> >
1.191 +graphToEps(GR &g,const std::string& file_name)
1.192 {
1.193 std::ostream* os = new std::ofstream(file_name.c_str());
1.194 if (!(*os)) {
1.195 delete os;
1.196 throw IoError("Cannot write file", file_name);
1.197 }
1.198 - return GraphToEps<DefaultGraphToEpsTraits<G> >
1.199 - (DefaultGraphToEpsTraits<G>(g,*os,true));
1.200 + return GraphToEps<DefaultGraphToEpsTraits<GR> >
1.201 + (DefaultGraphToEpsTraits<GR>(g,*os,true));
1.202 }
1.203
1.204 } //END OF NAMESPACE LEMON