COIN-OR::LEMON - Graph Library

Changeset 7:6a9399f56813 in glemon-0.x


Ignore:
Timestamp:
06/03/05 14:25:23 (19 years ago)
Author:
Akos Ladanyi
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@1923
Message:

zooming should really work now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas.cc

    r6 r7  
    191191      isbutton=false;
    192192      active_item=NULL;
     193      updateScrollRegion();
    193194      break;
    194195    case GDK_MOTION_NOTIFY:
     
    284285  aw -= 5; if (aw < 0) aw = 0;
    285286  ah -= 5; if (ah < 0) ah = 0;
    286   //std::cout << "aw=" << aw << " ah=" << ah << std::endl;
    287287
    288288  // get the bounding box of the graph
    289   set_pixels_per_unit(1.0); // I don't really understand why this is necessary
    290289  double wx1, wy1, wx2, wy2;
    291   double cx1, cy1, cx2, cy2;
    292290  Gnome::Canvas::Item* pCanvasItem = root();
    293291  pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
    294   //std::cout << "root bounds: " << wx1 << " " << wy1 << " " << wx2 << " " << wy2 << std::endl;
    295   w2c(wx1, wy1, cx1, cy1);
    296   w2c(wx2, wy2, cx2, cy2);
    297   //std::cout << "root bounds (c): " << cx1 << " " << cy1 << " " << cx2 << " " << cy2 << std::endl;
    298   //std::cout << "cx2 - cx1=" << fabs(cx2 - cx1) << " cy2 - cy1=" << fabs(cy2 - cy1) << std::endl;
    299292
    300293  // fit the graph to the window
    301   double ppu1 = (double) aw / fabs(cx2 - cx1);
    302   double ppu2 = (double) ah / fabs(cy2 - cy1);
    303   //std::cout << "ppu1=" << ppu1 << " ppu2=" << ppu2 << std::endl;
    304   (ppu1 < ppu2) ? set_pixels_per_unit(ppu1) : set_pixels_per_unit(ppu2);
     294  double ppu1 = (double) aw / fabs(wx2 - wx1);
     295  double ppu2 = (double) ah / fabs(wy2 - wy1);
     296  set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
    305297}
    306298
     
    313305{
    314306  double wx1, wy1, wx2, wy2;
    315   int cx1, cy1, cx2, cy2;
    316307  Gnome::Canvas::Item* pCanvasItem = root();
    317308  pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
    318   w2c(wx1, wy1, cx1, cy1);
    319   w2c(wx2, wy2, cx2, cy2);
    320   set_scroll_region(cx1, cy1, cx2, cy2);
    321 }
     309  set_scroll_region(wx1, wy1, wx2, wy2);
     310}
Note: See TracChangeset for help on using the changeset viewer.