ladanyi@1606: #include "graph_displayer_canvas.h" ladanyi@1606: #include "broken_edge.h" alpar@1632: #include hegyi@1510: hegyi@1510: void GraphDisplayerCanvas::zoomIn() hegyi@1510: { hegyi@1510: set_pixels_per_unit( hegyi@1510: (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit()); hegyi@1510: } hegyi@1510: hegyi@1510: void GraphDisplayerCanvas::zoomOut() hegyi@1510: { hegyi@1510: set_pixels_per_unit( hegyi@1510: (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit()); hegyi@1510: } hegyi@1510: hegyi@1510: void GraphDisplayerCanvas::zoomFit() hegyi@1510: { hegyi@1510: // get the height and width of the canvas hegyi@1510: Gtk::Allocation a = get_allocation(); hegyi@1510: int aw = a.get_width(); hegyi@1510: int ah = a.get_height(); hegyi@1510: // add some space hegyi@1510: aw -= 5; if (aw < 0) aw = 0; hegyi@1510: ah -= 5; if (ah < 0) ah = 0; hegyi@1510: hegyi@1510: // get the bounding box of the graph hegyi@1510: double wx1, wy1, wx2, wy2; hegyi@1510: Gnome::Canvas::Item* pCanvasItem = root(); hegyi@1510: pCanvasItem->get_bounds(wx1, wy1, wx2, wy2); hegyi@1510: hegyi@1510: // fit the graph to the window hegyi@1510: double ppu1 = (double) aw / fabs(wx2 - wx1); hegyi@1510: double ppu2 = (double) ah / fabs(wy2 - wy1); hegyi@1510: set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2); hegyi@1510: } hegyi@1510: hegyi@1510: void GraphDisplayerCanvas::zoom100() hegyi@1510: { hegyi@1510: set_pixels_per_unit(1.0); hegyi@1510: } hegyi@1510: hegyi@1510: void GraphDisplayerCanvas::updateScrollRegion() hegyi@1510: { hegyi@1510: double wx1, wy1, wx2, wy2; hegyi@1510: Gnome::Canvas::Item* pCanvasItem = root(); hegyi@1510: pCanvasItem->get_bounds(wx1, wy1, wx2, wy2); hegyi@1510: set_scroll_region(wx1, wy1, wx2, wy2); hegyi@1510: }