1.1 --- a/src/lemon/graph_to_eps.h Sat Jan 29 15:09:41 2005 +0000
1.2 +++ b/src/lemon/graph_to_eps.h Sat Jan 29 23:22:02 2005 +0000
1.3 @@ -17,6 +17,9 @@
1.4 #ifndef LEMON_GRAPH_TO_EPS_H
1.5 #define LEMON_GRAPH_TO_EPS_H
1.6
1.7 +#include <sys/time.h>
1.8 +#include <time.h>
1.9 +
1.10 #include<iostream>
1.11 #include<fstream>
1.12 #include<sstream>
1.13 @@ -119,6 +122,9 @@
1.14 bool _pleaseRemoveOsStream;
1.15
1.16 bool _scaleToA4;
1.17 +
1.18 + std::string _title;
1.19 + std::string _copyright;
1.20
1.21 ///Constructor
1.22
1.23 @@ -153,7 +159,6 @@
1.24 ///
1.25 ///\todo Follow PostScript's DSC.
1.26 /// Use own dictionary.
1.27 -///\todo Provide a way to set %%Title: and %%Copyright:. Set %%CreationDate:
1.28 ///\todo Useful new features.
1.29 /// - Linestyles: dotted, dashed etc.
1.30 /// - A second color and percent value for the lines.
1.31 @@ -449,6 +454,20 @@
1.32 ///Use it to show the undirected edges as a pair of directed ones.
1.33 GraphToEps<T> &bidir(bool b=true) {_undir=!b;return *this;}
1.34
1.35 + ///Sets the title.
1.36 +
1.37 + ///Sets the title of the generated image,
1.38 + ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
1.39 + ///the EPS file.
1.40 + GraphToEps<T> &title(const std::string &t) {_title=t;return *this;}
1.41 + ///Sets the copyright statement.
1.42 +
1.43 + ///Sets the copyright statement of the generated image,
1.44 + ///namely it inserts a <tt>%%Copyright:</tt> DSC field to the header of
1.45 + ///the EPS file.
1.46 + ///\todo Multiline copyright notice could be supported.
1.47 + GraphToEps<T> ©right(const std::string &t) {_copyright=t;return *this;}
1.48 +
1.49 protected:
1.50 bool isInsideNode(xy<double> p, double r,int t)
1.51 {
1.52 @@ -476,11 +495,18 @@
1.53 if(dontPrint) return;
1.54
1.55 os << "%!PS-Adobe-2.0 EPSF-2.0\n";
1.56 - os << "%%Title: LEMON GraphToEps figure\n" ///\todo setTitle() is needed
1.57 + if(_title.size()>0) os << "%%Title: " << _title << '\n';
1.58 + if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
1.59 // << "%%Copyright: XXXX\n"
1.60 - << "%%Creator: LEMON GraphToEps function\n"
1.61 -// << "%%CreationDate: XXXXXXX\n"
1.62 - ;
1.63 + os << "%%Creator: LEMON GraphToEps function\n";
1.64 +
1.65 + {
1.66 + char cbuf[50];
1.67 + timeval tv;
1.68 + gettimeofday(&tv, 0);
1.69 + ctime_r(&tv.tv_sec,cbuf);
1.70 + os << "%%CreationDate: " << cbuf;
1.71 + }
1.72 ///\todo: Chech whether the graph is empty.
1.73 BoundingBox<double> bb;
1.74 for(NodeIt n(g);n!=INVALID;++n) {
1.75 @@ -489,12 +515,14 @@
1.76 bb+=p+_coords[n];
1.77 bb+=-p+_coords[n];
1.78 }
1.79 - if(!_scaleToA4) os << "%%BoundingBox: "
1.80 - << bb.left()* _scale-_xBorder << ' '
1.81 - << bb.bottom()*_scale-_yBorder << ' '
1.82 - << bb.right()* _scale+_xBorder << ' '
1.83 - << bb.top()* _scale+_yBorder << '\n';
1.84 -
1.85 + if(_scaleToA4)
1.86 + os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n";
1.87 + else os << "%%BoundingBox: "
1.88 + << bb.left()* _scale-_xBorder << ' '
1.89 + << bb.bottom()*_scale-_yBorder << ' '
1.90 + << bb.right()* _scale+_xBorder << ' '
1.91 + << bb.top()* _scale+_yBorder << '\n';
1.92 +
1.93 os << "%%EndComments\n";
1.94
1.95 //x1 y1 x2 y2 x3 y3 cr cg cb w