COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/graph_displayer_canvas-zoom.cc @ 1862:d47ebd34e581

Last change on this file since 1862:d47ebd34e581 was 1819:fd82adfbe905, checked in by Hegyi Péter, 16 years ago

Reorganizing.

  • Property exe set to *
File size: 1.2 KB
RevLine 
[1606]1#include "graph_displayer_canvas.h"
[1632]2#include <cmath>
[1510]3
4void GraphDisplayerCanvas::zoomIn()
5{
6  set_pixels_per_unit(
7      (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit());
8}
9
10void GraphDisplayerCanvas::zoomOut()
11{
12  set_pixels_per_unit(
13      (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
14}
15
16void GraphDisplayerCanvas::zoomFit()
17{
[1777]18  updateScrollRegion();
19
[1510]20  // get the height and width of the canvas
21  Gtk::Allocation a = get_allocation();
22  int aw = a.get_width();
23  int ah = a.get_height();
24
25  // get the bounding box of the graph
[1777]26  update_now();
27  double x1, y1, x2, y2;
28  root()->get_bounds(x1, y1, x2, y2);
[1510]29
30  // fit the graph to the window
[1777]31  double ppu1 = (double) aw / fabs(x2 - x1);
32  double ppu2 = (double) ah / fabs(y2 - y1);
[1510]33  set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
34}
35
36void GraphDisplayerCanvas::zoom100()
37{
[1777]38  updateScrollRegion();
[1510]39  set_pixels_per_unit(1.0);
40}
41
42void GraphDisplayerCanvas::updateScrollRegion()
43{
[1777]44  // get_bounds() yields something sane only when no updates are pending
45  // and it returns a sufficient, not an exact bounding box
46  update_now();
47  double x1, y1, x2, y2;
48  root()->get_bounds(x1, y1, x2, y2);
49  set_scroll_region(x1, y1, x2, y2);
[1510]50}
Note: See TracBrowser for help on using the repository browser.