Zoom tracking of nodes is implemented and is switchable.
1 #include "graph_displayer_canvas.h"
4 void GraphDisplayerCanvas::zoomIn()
7 (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit());
10 propertyChange(false, N_RADIUS);
14 void GraphDisplayerCanvas::zoomOut()
17 (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
20 propertyChange(false, N_RADIUS);
24 void GraphDisplayerCanvas::zoomFit()
28 // get the height and width of the canvas
29 Gtk::Allocation a = get_allocation();
30 int aw = a.get_width();
31 int ah = a.get_height();
33 // get the bounding box of the graph
35 double x1, y1, x2, y2;
36 root()->get_bounds(x1, y1, x2, y2);
38 // fit the graph to the window
39 double ppu1 = (double) aw / fabs(x2 - x1);
40 double ppu2 = (double) ah / fabs(y2 - y1);
41 set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
45 propertyChange(false, N_RADIUS);
49 void GraphDisplayerCanvas::zoom100()
52 set_pixels_per_unit(1.0);
56 propertyChange(false, N_RADIUS);
60 void GraphDisplayerCanvas::updateScrollRegion()
62 // get_bounds() yields something sane only when no updates are pending
63 // and it returns a sufficient, not an exact bounding box
65 double x1, y1, x2, y2;
66 root()->get_bounds(x1, y1, x2, y2);
67 set_scroll_region(x1, y1, x2, y2);