COIN-OR::LEMON - Graph Library

Changeset 1108:253b66e7e41d in lemon-0.x


Ignore:
Timestamp:
01/30/05 00:22:02 (15 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1507
Message:
  • '%%Title:', '%%Copyright:' and '%%CreationDate:' fields added to graphToEps-

generated output

  • Some more checks in configure.ac
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r939 r1108  
    2626dnl Checks for library functions.
    2727AC_HEADER_STDC
    28 AC_CHECK_FUNCS(gettimeofday)
     28AC_CHECK_FUNCS(gettimeofday times ctime_r)
    2929
    3030AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile src/lemon/Makefile src/test/Makefile src/benchmark/Makefile src/demo/Makefile])
  • src/demo/graph_to_eps_demo.cc

    r1103 r1108  
    9191
    9292  graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
     93    title("Sample .eps figure").
     94    copyright("(C) 2004 LEMON Project").
    9395    nodeScale(2).nodeSizes(sizes).
    9496    nodeShapes(shapes).
     
    100102
    101103  graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
     104    title("Sample .eps figure (with arrowheads)").
     105    copyright("(C) 2004 LEMON Project").
    102106    nodeColors(composeMap(colorSet,colors)).
    103107    coords(coords).
     
    122126
    123127  graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
     128    title("Sample .eps figure (parallel edges)").
     129    copyright("(C) 2004 LEMON Project").
    124130    nodeShapes(shapes).
    125131    coords(coords).
     
    133139 
    134140  graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
     141    title("Sample .eps figure (parallel edges and arrowheads)").
     142    copyright("(C) 2004 LEMON Project").
    135143    nodeScale(2).nodeSizes(sizes).
    136144    coords(coords).
     
    145153
    146154  graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
     155    title("Sample .eps figure (fits to A4)").
     156    copyright("(C) 2004 LEMON Project").
    147157    nodeScale(2).nodeSizes(sizes).
    148158    coords(coords).
  • src/lemon/graph_to_eps.h

    r1107 r1108  
    1717#ifndef LEMON_GRAPH_TO_EPS_H
    1818#define LEMON_GRAPH_TO_EPS_H
     19
     20#include <sys/time.h>
     21#include <time.h>
    1922
    2023#include<iostream>
     
    120123
    121124  bool _scaleToA4;
     125
     126  std::string _title;
     127  std::string _copyright;
    122128 
    123129  ///Constructor
     
    154160///\todo Follow PostScript's DSC.
    155161/// Use own dictionary.
    156 ///\todo Provide a way to set %%Title: and %%Copyright:. Set %%CreationDate:
    157162///\todo Useful new features.
    158163/// - Linestyles: dotted, dashed etc.
     
    450455  GraphToEps<T> &bidir(bool b=true) {_undir=!b;return *this;}
    451456
     457  ///Sets the title.
     458
     459  ///Sets the title of the generated image,
     460  ///namely it inserts a <tt>%%Title:</tt> DSC field to the header of
     461  ///the EPS file.
     462  GraphToEps<T> &title(const std::string &t) {_title=t;return *this;}
     463  ///Sets the copyright statement.
     464
     465  ///Sets the copyright statement of the generated image,
     466  ///namely it inserts a <tt>%%Copyright:</tt> DSC field to the header of
     467  ///the EPS file.
     468  ///\todo Multiline copyright notice could be supported.
     469  GraphToEps<T> &copyright(const std::string &t) {_copyright=t;return *this;}
     470
    452471protected:
    453472  bool isInsideNode(xy<double> p, double r,int t)
     
    477496   
    478497    os << "%!PS-Adobe-2.0 EPSF-2.0\n";
    479     os << "%%Title: LEMON GraphToEps figure\n" ///\todo setTitle() is needed
     498    if(_title.size()>0) os << "%%Title: " << _title << '\n';
     499     if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
    480500//        << "%%Copyright: XXXX\n"
    481        << "%%Creator: LEMON GraphToEps function\n"
    482 //        << "%%CreationDate: XXXXXXX\n"
    483       ;
     501    os << "%%Creator: LEMON GraphToEps function\n";
     502   
     503    {
     504      char cbuf[50];
     505      timeval tv;
     506      gettimeofday(&tv, 0);
     507      ctime_r(&tv.tv_sec,cbuf);
     508      os << "%%CreationDate: " << cbuf;
     509    }
    484510    ///\todo: Chech whether the graph is empty.
    485511    BoundingBox<double> bb;
     
    490516      bb+=-p+_coords[n];
    491517      }
    492     if(!_scaleToA4) os << "%%BoundingBox: "
    493                       << bb.left()*  _scale-_xBorder << ' '
    494                       << bb.bottom()*_scale-_yBorder << ' '
    495                       << bb.right()* _scale+_xBorder << ' '
    496                       << bb.top()*   _scale+_yBorder << '\n';
    497 
     518    if(_scaleToA4)
     519      os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n";
     520    else os << "%%BoundingBox: "
     521            << bb.left()*  _scale-_xBorder << ' '
     522            << bb.bottom()*_scale-_yBorder << ' '
     523            << bb.right()* _scale+_xBorder << ' '
     524            << bb.top()*   _scale+_yBorder << '\n';
     525   
    498526    os << "%%EndComments\n";
    499527   
Note: See TracChangeset for help on using the changeset viewer.