1.1 --- a/gui/graph_displayer_canvas.cc Thu Jun 02 14:43:45 2005 +0000
1.2 +++ b/gui/graph_displayer_canvas.cc Fri Jun 03 12:25:23 2005 +0000
1.3 @@ -190,6 +190,7 @@
1.4 case GDK_BUTTON_RELEASE:
1.5 isbutton=false;
1.6 active_item=NULL;
1.7 + updateScrollRegion();
1.8 break;
1.9 case GDK_MOTION_NOTIFY:
1.10 //we only have to do sg. if the mouse button is pressed
1.11 @@ -283,25 +284,16 @@
1.12 // add some space
1.13 aw -= 5; if (aw < 0) aw = 0;
1.14 ah -= 5; if (ah < 0) ah = 0;
1.15 - //std::cout << "aw=" << aw << " ah=" << ah << std::endl;
1.16
1.17 // get the bounding box of the graph
1.18 - set_pixels_per_unit(1.0); // I don't really understand why this is necessary
1.19 double wx1, wy1, wx2, wy2;
1.20 - double cx1, cy1, cx2, cy2;
1.21 Gnome::Canvas::Item* pCanvasItem = root();
1.22 pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
1.23 - //std::cout << "root bounds: " << wx1 << " " << wy1 << " " << wx2 << " " << wy2 << std::endl;
1.24 - w2c(wx1, wy1, cx1, cy1);
1.25 - w2c(wx2, wy2, cx2, cy2);
1.26 - //std::cout << "root bounds (c): " << cx1 << " " << cy1 << " " << cx2 << " " << cy2 << std::endl;
1.27 - //std::cout << "cx2 - cx1=" << fabs(cx2 - cx1) << " cy2 - cy1=" << fabs(cy2 - cy1) << std::endl;
1.28
1.29 // fit the graph to the window
1.30 - double ppu1 = (double) aw / fabs(cx2 - cx1);
1.31 - double ppu2 = (double) ah / fabs(cy2 - cy1);
1.32 - //std::cout << "ppu1=" << ppu1 << " ppu2=" << ppu2 << std::endl;
1.33 - (ppu1 < ppu2) ? set_pixels_per_unit(ppu1) : set_pixels_per_unit(ppu2);
1.34 + double ppu1 = (double) aw / fabs(wx2 - wx1);
1.35 + double ppu2 = (double) ah / fabs(wy2 - wy1);
1.36 + set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
1.37 }
1.38
1.39 void GraphDisplayerCanvas::zoom100()
1.40 @@ -312,10 +304,7 @@
1.41 void GraphDisplayerCanvas::updateScrollRegion()
1.42 {
1.43 double wx1, wy1, wx2, wy2;
1.44 - int cx1, cy1, cx2, cy2;
1.45 Gnome::Canvas::Item* pCanvasItem = root();
1.46 pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
1.47 - w2c(wx1, wy1, cx1, cy1);
1.48 - w2c(wx2, wy2, cx2, cy2);
1.49 - set_scroll_region(cx1, cy1, cx2, cy2);
1.50 + set_scroll_region(wx1, wy1, wx2, wy2);
1.51 }