# HG changeset patch # User ladanyi # Date 1117801523 0 # Node ID 5fcd697859599191857a480f476716e1416e6f28 # Parent 70781827eb2fb15cebb6f8fa57c50a133ccab50a zooming should really work now diff -r 70781827eb2f -r 5fcd69785959 gui/graph_displayer_canvas.cc --- a/gui/graph_displayer_canvas.cc Thu Jun 02 14:43:45 2005 +0000 +++ b/gui/graph_displayer_canvas.cc Fri Jun 03 12:25:23 2005 +0000 @@ -190,6 +190,7 @@ case GDK_BUTTON_RELEASE: isbutton=false; active_item=NULL; + updateScrollRegion(); break; case GDK_MOTION_NOTIFY: //we only have to do sg. if the mouse button is pressed @@ -283,25 +284,16 @@ // add some space aw -= 5; if (aw < 0) aw = 0; ah -= 5; if (ah < 0) ah = 0; - //std::cout << "aw=" << aw << " ah=" << ah << std::endl; // get the bounding box of the graph - set_pixels_per_unit(1.0); // I don't really understand why this is necessary double wx1, wy1, wx2, wy2; - double cx1, cy1, cx2, cy2; Gnome::Canvas::Item* pCanvasItem = root(); pCanvasItem->get_bounds(wx1, wy1, wx2, wy2); - //std::cout << "root bounds: " << wx1 << " " << wy1 << " " << wx2 << " " << wy2 << std::endl; - w2c(wx1, wy1, cx1, cy1); - w2c(wx2, wy2, cx2, cy2); - //std::cout << "root bounds (c): " << cx1 << " " << cy1 << " " << cx2 << " " << cy2 << std::endl; - //std::cout << "cx2 - cx1=" << fabs(cx2 - cx1) << " cy2 - cy1=" << fabs(cy2 - cy1) << std::endl; // fit the graph to the window - double ppu1 = (double) aw / fabs(cx2 - cx1); - double ppu2 = (double) ah / fabs(cy2 - cy1); - //std::cout << "ppu1=" << ppu1 << " ppu2=" << ppu2 << std::endl; - (ppu1 < ppu2) ? set_pixels_per_unit(ppu1) : set_pixels_per_unit(ppu2); + double ppu1 = (double) aw / fabs(wx2 - wx1); + double ppu2 = (double) ah / fabs(wy2 - wy1); + set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2); } void GraphDisplayerCanvas::zoom100() @@ -312,10 +304,7 @@ void GraphDisplayerCanvas::updateScrollRegion() { double wx1, wy1, wx2, wy2; - int cx1, cy1, cx2, cy2; Gnome::Canvas::Item* pCanvasItem = root(); pCanvasItem->get_bounds(wx1, wy1, wx2, wy2); - w2c(wx1, wy1, cx1, cy1); - w2c(wx2, wy2, cx2, cy2); - set_scroll_region(cx1, cy1, cx2, cy2); + set_scroll_region(wx1, wy1, wx2, wy2); }