[Lemon-commits] [lemon_svn] alpar: r1507 - in hugo/trunk: . src/demo src/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:45:56 CET 2006


Author: alpar
Date: Sun Jan 30 00:22:02 2005
New Revision: 1507

Modified:
   hugo/trunk/configure.ac
   hugo/trunk/src/demo/graph_to_eps_demo.cc
   hugo/trunk/src/lemon/graph_to_eps.h

Log:
- '%%Title:', '%%Copyright:' and '%%CreationDate:' fields added to graphToEps-
   generated output
- Some more checks in configure.ac

Modified: hugo/trunk/configure.ac
==============================================================================
--- hugo/trunk/configure.ac	(original)
+++ hugo/trunk/configure.ac	Sun Jan 30 00:22:02 2005
@@ -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

Modified: hugo/trunk/src/demo/graph_to_eps_demo.cc
==============================================================================
--- hugo/trunk/src/demo/graph_to_eps_demo.cc	(original)
+++ hugo/trunk/src/demo/graph_to_eps_demo.cc	Sun Jan 30 00:22:02 2005
@@ -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).

Modified: hugo/trunk/src/lemon/graph_to_eps.h
==============================================================================
--- hugo/trunk/src/lemon/graph_to_eps.h	(original)
+++ hugo/trunk/src/lemon/graph_to_eps.h	Sun Jan 30 00:22:02 2005
@@ -17,6 +17,9 @@
 #ifndef LEMON_GRAPH_TO_EPS_H
 #define LEMON_GRAPH_TO_EPS_H
 
+#include <sys/time.h>
+#include <time.h>
+
 #include<iostream>
 #include<fstream>
 #include<sstream>
@@ -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<T> &bidir(bool b=true) {_undir=!b;return *this;}
 
+  ///Sets the title.
+
+  ///Sets the title of the generated image,
+  ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
+  ///the EPS file.
+  GraphToEps<T> &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 <tt>%%Copyright:</tt> DSC field to the header of
+  ///the EPS file.
+  ///\todo Multiline copyright notice could be supported.
+  GraphToEps<T> &copyright(const std::string &t) {_copyright=t;return *this;}
+
 protected:
   bool isInsideNode(xy<double> 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<double> 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



More information about the Lemon-commits mailing list