# HG changeset patch # User ladanyi # Date 1117801523 0 # Node ID 6a9399f56813a5ad24b4aaee5a39fc33fa0431cd # Parent 603b85626bc00bd655422290e6d4fc5a17e07c39 zooming should really work now diff -r 603b85626bc0 -r 6a9399f56813 graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Wed Jun 01 23:33:26 2005 +0000 +++ b/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); }