COIN-OR::LEMON - Graph Library

Changeset 1930:92b70deed0c5 in lemon-0.x


Ignore:
Timestamp:
01/30/06 10:37:41 (18 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2505
Message:

Solve bug #23: Floating versus Integer Coordinates

  • BoundingBox? values rounds to integer
  • The generated .eps rescales if the bounding box were too small otherwise.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • demo/graph_to_eps_demo.cc

    r1875 r1930  
    8080
    8181  cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
    82   graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
     82  graphToEps(g,"graph_to_eps_demo_out.eps").
     83    //scale(10).
     84    coords(coords).
    8385    title("Sample .eps figure").
    8486    copyright("(C) 2006 LEMON Project").
     
    9395
    9496  cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
    95   graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
     97  graphToEps(g,"graph_to_eps_demo_out_arr.eps").
     98    //scale(10).
    9699    title("Sample .eps figure (with arrowheads)").
    97100    copyright("(C) 2006 LEMON Project").
     
    118121
    119122  cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
    120   graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
     123  graphToEps(g,"graph_to_eps_demo_out_par.eps").
     124    //scale(10).
    121125    title("Sample .eps figure (parallel edges)").
    122126    copyright("(C) 2006 LEMON Project").
     
    132136 
    133137  cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl;
    134   graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
     138  graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").
     139    //scale(10).
    135140    title("Sample .eps figure (parallel edges and arrowheads)").
    136141    copyright("(C) 2006 LEMON Project").
     
    173178 
    174179  cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
    175   graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60).
     180  graphToEps(h,"graph_to_eps_demo_out_colors.eps").
     181    //scale(60).
    176182    title("Sample .eps figure (ColorSet demo)").
    177183    copyright("(C) 2006 LEMON Project").
  • lemon/graph_to_eps.h

    r1910 r1930  
    852852    if(_scaleToA4)
    853853      os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n";
    854     else os << "%%BoundingBox: "
    855             << bb.left()   * _scale - _xBorder << ' '
    856             << bb.bottom() * _scale - _yBorder << ' '
    857             << bb.right()  * _scale + _xBorder << ' '
    858             << bb.top()    * _scale + _yBorder << '\n';
     854    else {
     855      //Rescale so that BoundingBox won't be neither to big nor too small.
     856      while(bb.height()*_scale>1000||bb.width()*_scale>1000) _scale/=10;
     857      while(bb.height()*_scale<100||bb.width()*_scale<100) _scale*=10;
     858   
     859      os << "%%BoundingBox: "
     860         << int(floor(bb.left()   * _scale - _xBorder)) << ' '
     861         << int(floor(bb.bottom() * _scale - _yBorder)) << ' '
     862         << int(ceil(bb.right()  * _scale + _xBorder)) << ' '
     863         << int(ceil(bb.top()    * _scale + _yBorder)) << '\n';
     864    }
    859865   
    860866    os << "%%EndComments\n";
Note: See TracChangeset for help on using the changeset viewer.