# HG changeset patch # User alpar # Date 1107040922 0 # Node ID 253b66e7e41dc267433c0869421aa1dedfeefa2b # Parent d972653c89d56cbbfc2278761d425ebcab3fee31 - '%%Title:', '%%Copyright:' and '%%CreationDate:' fields added to graphToEps- generated output - Some more checks in configure.ac diff -r d972653c89d5 -r 253b66e7e41d configure.ac --- a/configure.ac Sat Jan 29 15:09:41 2005 +0000 +++ b/configure.ac Sat Jan 29 23:22:02 2005 +0000 @@ -25,7 +25,7 @@ dnl Checks for library functions. AC_HEADER_STDC -AC_CHECK_FUNCS(gettimeofday) +AC_CHECK_FUNCS(gettimeofday times ctime_r) AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile src/lemon/Makefile src/test/Makefile src/benchmark/Makefile src/demo/Makefile]) AC_OUTPUT diff -r d972653c89d5 -r 253b66e7e41d src/demo/graph_to_eps_demo.cc --- a/src/demo/graph_to_eps_demo.cc Sat Jan 29 15:09:41 2005 +0000 +++ b/src/demo/graph_to_eps_demo.cc Sat Jan 29 23:22:02 2005 +0000 @@ -90,6 +90,8 @@ IdMap id(g); graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords). + title("Sample .eps figure"). + copyright("(C) 2004 LEMON Project"). nodeScale(2).nodeSizes(sizes). nodeShapes(shapes). nodeColors(composeMap(colorSet,colors)). @@ -99,6 +101,8 @@ run(); graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10). + title("Sample .eps figure (with arrowheads)"). + copyright("(C) 2004 LEMON Project"). nodeColors(composeMap(colorSet,colors)). coords(coords). nodeScale(2).nodeSizes(sizes). @@ -121,6 +125,8 @@ e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1; graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10). + title("Sample .eps figure (parallel edges)"). + copyright("(C) 2004 LEMON Project"). nodeShapes(shapes). coords(coords). nodeScale(2).nodeSizes(sizes). @@ -132,6 +138,8 @@ run(); graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10). + title("Sample .eps figure (parallel edges and arrowheads)"). + copyright("(C) 2004 LEMON Project"). nodeScale(2).nodeSizes(sizes). coords(coords). nodeShapes(shapes). @@ -144,6 +152,8 @@ run(); graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4(). + title("Sample .eps figure (fits to A4)"). + copyright("(C) 2004 LEMON Project"). nodeScale(2).nodeSizes(sizes). coords(coords). nodeShapes(shapes). diff -r d972653c89d5 -r 253b66e7e41d src/lemon/graph_to_eps.h --- a/src/lemon/graph_to_eps.h Sat Jan 29 15:09:41 2005 +0000 +++ b/src/lemon/graph_to_eps.h Sat Jan 29 23:22:02 2005 +0000 @@ -17,6 +17,9 @@ #ifndef LEMON_GRAPH_TO_EPS_H #define LEMON_GRAPH_TO_EPS_H +#include +#include + #include #include #include @@ -119,6 +122,9 @@ bool _pleaseRemoveOsStream; bool _scaleToA4; + + std::string _title; + std::string _copyright; ///Constructor @@ -153,7 +159,6 @@ /// ///\todo Follow PostScript's DSC. /// Use own dictionary. -///\todo Provide a way to set %%Title: and %%Copyright:. Set %%CreationDate: ///\todo Useful new features. /// - Linestyles: dotted, dashed etc. /// - A second color and percent value for the lines. @@ -449,6 +454,20 @@ ///Use it to show the undirected edges as a pair of directed ones. GraphToEps &bidir(bool b=true) {_undir=!b;return *this;} + ///Sets the title. + + ///Sets the title of the generated image, + ///namely it inserts a %%Title: DSC field to the header of + ///the EPS file. + GraphToEps &title(const std::string &t) {_title=t;return *this;} + ///Sets the copyright statement. + + ///Sets the copyright statement of the generated image, + ///namely it inserts a %%Copyright: DSC field to the header of + ///the EPS file. + ///\todo Multiline copyright notice could be supported. + GraphToEps ©right(const std::string &t) {_copyright=t;return *this;} + protected: bool isInsideNode(xy p, double r,int t) { @@ -476,11 +495,18 @@ if(dontPrint) return; os << "%!PS-Adobe-2.0 EPSF-2.0\n"; - os << "%%Title: LEMON GraphToEps figure\n" ///\todo setTitle() is needed + if(_title.size()>0) os << "%%Title: " << _title << '\n'; + if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n'; // << "%%Copyright: XXXX\n" - << "%%Creator: LEMON GraphToEps function\n" -// << "%%CreationDate: XXXXXXX\n" - ; + os << "%%Creator: LEMON GraphToEps function\n"; + + { + char cbuf[50]; + timeval tv; + gettimeofday(&tv, 0); + ctime_r(&tv.tv_sec,cbuf); + os << "%%CreationDate: " << cbuf; + } ///\todo: Chech whether the graph is empty. BoundingBox bb; for(NodeIt n(g);n!=INVALID;++n) { @@ -489,12 +515,14 @@ bb+=p+_coords[n]; bb+=-p+_coords[n]; } - if(!_scaleToA4) os << "%%BoundingBox: " - << bb.left()* _scale-_xBorder << ' ' - << bb.bottom()*_scale-_yBorder << ' ' - << bb.right()* _scale+_xBorder << ' ' - << bb.top()* _scale+_yBorder << '\n'; - + if(_scaleToA4) + os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n"; + else os << "%%BoundingBox: " + << bb.left()* _scale-_xBorder << ' ' + << bb.bottom()*_scale-_yBorder << ' ' + << bb.right()* _scale+_xBorder << ' ' + << bb.top()* _scale+_yBorder << '\n'; + os << "%%EndComments\n"; //x1 y1 x2 y2 x3 y3 cr cg cb w