COIN-OR::LEMON - Graph Library

source: glemon-0.x/graph_displayer_canvas-zoom.cc @ 157:7e6ad28aeb9e

Last change on this file since 157:7e6ad28aeb9e was 157:7e6ad28aeb9e, checked in by Hegyi Péter, 18 years ago

View settings also for edges.

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