- '%%Title:', '%%Copyright:' and '%%CreationDate:' fields added to graphToEps-
authoralpar
Sat, 29 Jan 2005 23:22:02 +0000
changeset 1108253b66e7e41d
parent 1107 d972653c89d5
child 1109 5222b3d588c3
- '%%Title:', '%%Copyright:' and '%%CreationDate:' fields added to graphToEps-
generated output
- Some more checks in configure.ac
configure.ac
src/demo/graph_to_eps_demo.cc
src/lemon/graph_to_eps.h
     1.1 --- a/configure.ac	Sat Jan 29 15:09:41 2005 +0000
     1.2 +++ b/configure.ac	Sat Jan 29 23:22:02 2005 +0000
     1.3 @@ -25,7 +25,7 @@
     1.4  
     1.5  dnl Checks for library functions.
     1.6  AC_HEADER_STDC
     1.7 -AC_CHECK_FUNCS(gettimeofday)
     1.8 +AC_CHECK_FUNCS(gettimeofday times ctime_r)
     1.9  
    1.10  AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile src/lemon/Makefile src/test/Makefile src/benchmark/Makefile src/demo/Makefile])
    1.11  AC_OUTPUT
     2.1 --- a/src/demo/graph_to_eps_demo.cc	Sat Jan 29 15:09:41 2005 +0000
     2.2 +++ b/src/demo/graph_to_eps_demo.cc	Sat Jan 29 23:22:02 2005 +0000
     2.3 @@ -90,6 +90,8 @@
     2.4    IdMap id(g);
     2.5  
     2.6    graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
     2.7 +    title("Sample .eps figure").
     2.8 +    copyright("(C) 2004 LEMON Project").
     2.9      nodeScale(2).nodeSizes(sizes).
    2.10      nodeShapes(shapes).
    2.11      nodeColors(composeMap(colorSet,colors)).
    2.12 @@ -99,6 +101,8 @@
    2.13      run();
    2.14  
    2.15    graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
    2.16 +    title("Sample .eps figure (with arrowheads)").
    2.17 +    copyright("(C) 2004 LEMON Project").
    2.18      nodeColors(composeMap(colorSet,colors)).
    2.19      coords(coords).
    2.20      nodeScale(2).nodeSizes(sizes).
    2.21 @@ -121,6 +125,8 @@
    2.22    e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1;
    2.23  
    2.24    graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
    2.25 +    title("Sample .eps figure (parallel edges)").
    2.26 +    copyright("(C) 2004 LEMON Project").
    2.27      nodeShapes(shapes).
    2.28      coords(coords).
    2.29      nodeScale(2).nodeSizes(sizes).
    2.30 @@ -132,6 +138,8 @@
    2.31      run();
    2.32    
    2.33    graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
    2.34 +    title("Sample .eps figure (parallel edges and arrowheads)").
    2.35 +    copyright("(C) 2004 LEMON Project").
    2.36      nodeScale(2).nodeSizes(sizes).
    2.37      coords(coords).
    2.38      nodeShapes(shapes).
    2.39 @@ -144,6 +152,8 @@
    2.40      run();
    2.41  
    2.42    graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
    2.43 +    title("Sample .eps figure (fits to A4)").
    2.44 +    copyright("(C) 2004 LEMON Project").
    2.45      nodeScale(2).nodeSizes(sizes).
    2.46      coords(coords).
    2.47      nodeShapes(shapes).
     3.1 --- a/src/lemon/graph_to_eps.h	Sat Jan 29 15:09:41 2005 +0000
     3.2 +++ b/src/lemon/graph_to_eps.h	Sat Jan 29 23:22:02 2005 +0000
     3.3 @@ -17,6 +17,9 @@
     3.4  #ifndef LEMON_GRAPH_TO_EPS_H
     3.5  #define LEMON_GRAPH_TO_EPS_H
     3.6  
     3.7 +#include <sys/time.h>
     3.8 +#include <time.h>
     3.9 +
    3.10  #include<iostream>
    3.11  #include<fstream>
    3.12  #include<sstream>
    3.13 @@ -119,6 +122,9 @@
    3.14    bool _pleaseRemoveOsStream;
    3.15  
    3.16    bool _scaleToA4;
    3.17 +
    3.18 +  std::string _title;
    3.19 +  std::string _copyright;
    3.20    
    3.21    ///Constructor
    3.22  
    3.23 @@ -153,7 +159,6 @@
    3.24  ///
    3.25  ///\todo Follow PostScript's DSC.
    3.26  /// Use own dictionary.
    3.27 -///\todo Provide a way to set %%Title: and %%Copyright:. Set %%CreationDate:
    3.28  ///\todo Useful new features.
    3.29  /// - Linestyles: dotted, dashed etc.
    3.30  /// - A second color and percent value for the lines.
    3.31 @@ -449,6 +454,20 @@
    3.32    ///Use it to show the undirected edges as a pair of directed ones.
    3.33    GraphToEps<T> &bidir(bool b=true) {_undir=!b;return *this;}
    3.34  
    3.35 +  ///Sets the title.
    3.36 +
    3.37 +  ///Sets the title of the generated image,
    3.38 +  ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
    3.39 +  ///the EPS file.
    3.40 +  GraphToEps<T> &title(const std::string &t) {_title=t;return *this;}
    3.41 +  ///Sets the copyright statement.
    3.42 +
    3.43 +  ///Sets the copyright statement of the generated image,
    3.44 +  ///namely it inserts a <tt>%%Copyright:</tt> DSC field to the header of
    3.45 +  ///the EPS file.
    3.46 +  ///\todo Multiline copyright notice could be supported.
    3.47 +  GraphToEps<T> &copyright(const std::string &t) {_copyright=t;return *this;}
    3.48 +
    3.49  protected:
    3.50    bool isInsideNode(xy<double> p, double r,int t) 
    3.51    {
    3.52 @@ -476,11 +495,18 @@
    3.53      if(dontPrint) return;
    3.54      
    3.55      os << "%!PS-Adobe-2.0 EPSF-2.0\n";
    3.56 -    os << "%%Title: LEMON GraphToEps figure\n" ///\todo setTitle() is needed
    3.57 +    if(_title.size()>0) os << "%%Title: " << _title << '\n';
    3.58 +     if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
    3.59  //        << "%%Copyright: XXXX\n"
    3.60 -       << "%%Creator: LEMON GraphToEps function\n"
    3.61 -//        << "%%CreationDate: XXXXXXX\n"
    3.62 -      ;
    3.63 +    os << "%%Creator: LEMON GraphToEps function\n";
    3.64 +    
    3.65 +    {
    3.66 +      char cbuf[50];
    3.67 +      timeval tv;
    3.68 +      gettimeofday(&tv, 0);
    3.69 +      ctime_r(&tv.tv_sec,cbuf);
    3.70 +      os << "%%CreationDate: " << cbuf;
    3.71 +    }
    3.72      ///\todo: Chech whether the graph is empty.
    3.73      BoundingBox<double> bb;
    3.74      for(NodeIt n(g);n!=INVALID;++n) {
    3.75 @@ -489,12 +515,14 @@
    3.76        bb+=p+_coords[n];
    3.77        bb+=-p+_coords[n];
    3.78        }
    3.79 -    if(!_scaleToA4) os << "%%BoundingBox: "
    3.80 -		      << bb.left()*  _scale-_xBorder << ' '
    3.81 -		      << bb.bottom()*_scale-_yBorder << ' '
    3.82 -		      << bb.right()* _scale+_xBorder << ' '
    3.83 -		      << bb.top()*   _scale+_yBorder << '\n';
    3.84 -
    3.85 +    if(_scaleToA4)
    3.86 +      os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n";
    3.87 +    else os << "%%BoundingBox: "
    3.88 +	    << bb.left()*  _scale-_xBorder << ' '
    3.89 +	    << bb.bottom()*_scale-_yBorder << ' '
    3.90 +	    << bb.right()* _scale+_xBorder << ' '
    3.91 +	    << bb.top()*   _scale+_yBorder << '\n';
    3.92 +    
    3.93      os << "%%EndComments\n";
    3.94      
    3.95      //x1 y1 x2 y2 x3 y3 cr cg cb w