[Lemon-commits] [lemon_svn] alpar: r2505 - in hugo/trunk: demo lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:53:09 CET 2006
Author: alpar
Date: Mon Jan 30 10:37:41 2006
New Revision: 2505
Modified:
hugo/trunk/demo/graph_to_eps_demo.cc
hugo/trunk/lemon/graph_to_eps.h
Log:
Solve bug #23: Floating versus Integer Coordinates
- BoundingBox values rounds to integer
- The generated .eps rescales if the bounding box were too small otherwise.
Modified: hugo/trunk/demo/graph_to_eps_demo.cc
==============================================================================
--- hugo/trunk/demo/graph_to_eps_demo.cc (original)
+++ hugo/trunk/demo/graph_to_eps_demo.cc Mon Jan 30 10:37:41 2006
@@ -79,7 +79,9 @@
IdMap<ListGraph,Node> id(g);
cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
+ graphToEps(g,"graph_to_eps_demo_out.eps").
+ //scale(10).
+ coords(coords).
title("Sample .eps figure").
copyright("(C) 2006 LEMON Project").
nodeScale(2).nodeSizes(sizes).
@@ -92,7 +94,8 @@
cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
+ graphToEps(g,"graph_to_eps_demo_out_arr.eps").
+ //scale(10).
title("Sample .eps figure (with arrowheads)").
copyright("(C) 2006 LEMON Project").
nodeColors(composeMap(colorSet,colors)).
@@ -117,7 +120,8 @@
e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1;
cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
+ graphToEps(g,"graph_to_eps_demo_out_par.eps").
+ //scale(10).
title("Sample .eps figure (parallel edges)").
copyright("(C) 2006 LEMON Project").
nodeShapes(shapes).
@@ -131,7 +135,8 @@
run();
cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
+ graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").
+ //scale(10).
title("Sample .eps figure (parallel edges and arrowheads)").
copyright("(C) 2006 LEMON Project").
nodeScale(2).nodeSizes(sizes).
@@ -172,7 +177,8 @@
}
cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
- graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60).
+ graphToEps(h,"graph_to_eps_demo_out_colors.eps").
+ //scale(60).
title("Sample .eps figure (ColorSet demo)").
copyright("(C) 2006 LEMON Project").
coords(hcoords).
Modified: hugo/trunk/lemon/graph_to_eps.h
==============================================================================
--- hugo/trunk/lemon/graph_to_eps.h (original)
+++ hugo/trunk/lemon/graph_to_eps.h Mon Jan 30 10:37:41 2006
@@ -851,11 +851,17 @@
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';
+ else {
+ //Rescale so that BoundingBox won't be neither to big nor too small.
+ while(bb.height()*_scale>1000||bb.width()*_scale>1000) _scale/=10;
+ while(bb.height()*_scale<100||bb.width()*_scale<100) _scale*=10;
+
+ os << "%%BoundingBox: "
+ << int(floor(bb.left() * _scale - _xBorder)) << ' '
+ << int(floor(bb.bottom() * _scale - _yBorder)) << ' '
+ << int(ceil(bb.right() * _scale + _xBorder)) << ' '
+ << int(ceil(bb.top() * _scale + _yBorder)) << '\n';
+ }
os << "%%EndComments\n";
More information about the Lemon-commits
mailing list