COIN-OR::LEMON - Graph Library

Changeset 1108:253b66e7e41d in lemon-0.x for src/lemon


Ignore:
Timestamp:
01/30/05 00:22:02 (19 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.