COIN-OR::LEMON - Graph Library

Changeset 87:b44281e4cca7 in glemon-0.x


Ignore:
Timestamp:
11/04/05 20:07:15 (18 years ago)
Author:
Akos Ladanyi
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2309
Message:

improved zooming

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-event.cc

    r72 r87  
    309309      active_item=NULL;
    310310      active_node=INVALID;
    311 
    312311      break;
    313312    default:
  • graph_displayer_canvas-zoom.cc

    r59 r87  
    1717void GraphDisplayerCanvas::zoomFit()
    1818{
     19  updateScrollRegion();
     20
    1921  // get the height and width of the canvas
    2022  Gtk::Allocation a = get_allocation();
    2123  int aw = a.get_width();
    2224  int ah = a.get_height();
    23   // add some space
    24   aw -= 5; if (aw < 0) aw = 0;
    25   ah -= 5; if (ah < 0) ah = 0;
    2625
    2726  // get the bounding box of the graph
    28   double wx1, wy1, wx2, wy2;
    29   Gnome::Canvas::Item* pCanvasItem = root();
    30   pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
     27  update_now();
     28  double x1, y1, x2, y2;
     29  root()->get_bounds(x1, y1, x2, y2);
    3130
    3231  // fit the graph to the window
    33   double ppu1 = (double) aw / fabs(wx2 - wx1);
    34   double ppu2 = (double) ah / fabs(wy2 - wy1);
     32  double ppu1 = (double) aw / fabs(x2 - x1);
     33  double ppu2 = (double) ah / fabs(y2 - y1);
    3534  set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
    3635}
     
    3837void GraphDisplayerCanvas::zoom100()
    3938{
     39  updateScrollRegion();
    4040  set_pixels_per_unit(1.0);
    4141}
     
    4343void GraphDisplayerCanvas::updateScrollRegion()
    4444{
    45   double wx1, wy1, wx2, wy2;
    46   Gnome::Canvas::Item* pCanvasItem = root();
    47   pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
    48   set_scroll_region(wx1, wy1, wx2, wy2);
     45  // get_bounds() yields something sane only when no updates are pending
     46  // and it returns a sufficient, not an exact bounding box
     47  update_now();
     48  double x1, y1, x2, y2;
     49  root()->get_bounds(x1, y1, x2, y2);
     50  set_scroll_region(x1, y1, x2, y2);
    4951}
  • main_win.cc

    r82 r87  
    128128  add_accel_group(uim->get_accel_group());
    129129
    130   /*
    131       "      <menuitem action='ViewZoomFit' />"
    132       "    <toolitem action='ViewZoomFit' />"
    133    */
    134 
    135130  try
    136131  {
     
    151146      "      <menuitem action='ViewZoomOut' />"
    152147      "      <menuitem action='ViewZoom100' />"
     148      "      <menuitem action='ViewZoomFit' />"
    153149      "    </menu>"
    154150      "    <menu action='ShowMenu'>"
     
    165161      "    <toolitem action='ViewZoomOut' />"
    166162      "    <toolitem action='ViewZoom100' />"
     163      "    <toolitem action='ViewZoomFit' />"
    167164      "    <separator />"
    168165      "    <toolitem action='MoveItem' />"
     
    198195
    199196  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
     197  pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN);
    200198  pScrolledWindow->add(gd_canvas);
    201199  vbox.pack_start(*pScrolledWindow);
Note: See TracChangeset for help on using the changeset viewer.