Changeset 1103:f196dc4f1b31 in lemon-0.x
- Timestamp:
- 01/28/05 10:09:59 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1502
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/demo/graph_to_eps_demo.cc
r1091 r1103 141 141 nodeTexts(id).nodeTextSize(3). 142 142 enableParallel().parEdgeDist(1). 143 // hideNodes().144 143 drawArrows().arrowWidth(1).arrowLength(1). 145 run();; 144 run(); 145 146 graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4(). 147 nodeScale(2).nodeSizes(sizes). 148 coords(coords). 149 nodeShapes(shapes). 150 nodeColors(composeMap(colorSet,colors)). 151 edgeColors(composeMap(colorSet,ecolors)). 152 edgeWidthScale(.3).edgeWidths(widths). 153 nodeTexts(id).nodeTextSize(3). 154 enableParallel().parEdgeDist(1). 155 drawArrows().arrowWidth(1).arrowLength(1). 156 run(); 157 146 158 } -
src/lemon/graph_to_eps.h
r1091 r1103 87 87 88 88 ConstMap<typename Graph::Edge,double > _edgeWidths; 89 90 static const double A4HEIGHT = 841.8897637795276; 91 static const double A4WIDTH = 595.275590551181; 92 static const double A4BORDER = 15; 93 89 94 90 95 double _edgeWidthScale; … … 113 118 bool _undir; 114 119 bool _pleaseRemoveOsStream; 120 121 bool _scaleToA4; 122 115 123 ///Constructor 116 124 … … 136 144 _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0), 137 145 _undir(false), 138 _pleaseRemoveOsStream(_pros) {}146 _pleaseRemoveOsStream(_pros), _scaleToA4(false) {} 139 147 }; 140 148 … … 144 152 ///\todo Is 'helper class' a good name for this? 145 153 /// 154 ///\todo Follow PostScript's DSC. 155 ///\todo Use own dictionary. 146 156 template<class T> class GraphToEps : public T 147 157 { … … 202 212 203 213 ///Sets the map of the node coordinates. 204 ///\param x must be a node map with xy<double> or xy<int>values.214 ///\param x must be a node map with xy<double> or \ref xy "xy<int>" values. 205 215 template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) { 206 216 dontPrint=true; … … 359 369 /// 360 370 GraphToEps<T> &arrowWidth(double d) {_arrowWidth*=d;return *this;} 371 372 ///Scales the drawing to fit to A4 page 373 374 ///Scales the drawing to fit to A4 page 375 /// 376 GraphToEps<T> &scaleToA4() {_scaleToA4=true;return *this;} 361 377 362 378 ///Enables parallel edges … … 442 458 bb+=-p+_coords[n]; 443 459 } 444 os << "%%BoundingBox: "445 << bb.left()* _scale-_xBorder << ' '446 << bb.bottom()*_scale-_yBorder << ' '447 << bb.right()* _scale+_xBorder << ' '448 << bb.top()* _scale+_yBorder << '\n';460 if(!_scaleToA4) os << "%%BoundingBox: " 461 << bb.left()* _scale-_xBorder << ' ' 462 << bb.bottom()*_scale-_yBorder << ' ' 463 << bb.right()* _scale+_xBorder << ' ' 464 << bb.top()* _scale+_yBorder << '\n'; 449 465 //x1 y1 x2 y2 x3 y3 cr cg cb w 450 466 os << "/lb { setlinewidth setrgbcolor newpath moveto\n" … … 497 513 498 514 os << "\ngsave\n"; 499 if(_scale!=1.0) os << _scale << " dup scale\n"; 515 if(_scaleToA4) 516 if(bb.height()>bb.width()) { 517 double sc= min((A4HEIGHT-2*A4BORDER)/bb.height(), 518 (A4WIDTH-2*A4BORDER)/bb.width()); 519 os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' ' 520 << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n" 521 << sc << " dup scale\n" 522 << -bb.left() << ' ' << -bb.bottom() << " translate\n"; 523 } 524 else { 525 //\todo Verify centering 526 double sc= min((A4HEIGHT-2*A4BORDER)/bb.width(), 527 (A4WIDTH-2*A4BORDER)/bb.height()); 528 os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' ' 529 << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER << " translate\n" 530 << sc << " dup scale\n90 rotate\n" 531 << -bb.left() << ' ' << -bb.top() << " translate\n"; 532 } 533 else if(_scale!=1.0) os << _scale << " dup scale\n"; 500 534 501 535 if(_showEdges) { … … 659 693 } 660 694 661 os << "grestore\n ";695 os << "grestore\nshowpage\n"; 662 696 663 697 //CleanUp: … … 698 732 ///Generates an EPS file from a graph 699 733 700 // \ingroup misc734 ///\ingroup misc 701 735 ///This function does the same as 702 736 ///\ref graphToEps(G &g,std::ostream& os)
Note: See TracChangeset
for help on using the changeset viewer.