# HG changeset patch # User alpar # Date 1138613861 0 # Node ID 92b70deed0c53ab31f3f892a0275115fee9936ba # Parent 84d87d6024af343d7d412c4eb7bb2258e14a138b Solve bug #23: Floating versus Integer Coordinates - BoundingBox values rounds to integer - The generated .eps rescales if the bounding box were too small otherwise. diff -r 84d87d6024af -r 92b70deed0c5 demo/graph_to_eps_demo.cc --- a/demo/graph_to_eps_demo.cc Mon Jan 30 09:32:52 2006 +0000 +++ b/demo/graph_to_eps_demo.cc Mon Jan 30 09:37:41 2006 +0000 @@ -79,7 +79,9 @@ IdMap 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). diff -r 84d87d6024af -r 92b70deed0c5 lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h Mon Jan 30 09:32:52 2006 +0000 +++ b/lemon/graph_to_eps.h Mon Jan 30 09:37:41 2006 +0000 @@ -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";