Zoom tracking of nodes is implemented and is switchable.
1.1 --- a/graph_displayer_canvas-node.cc Thu Sep 28 09:26:48 2006 +0000
1.2 +++ b/graph_displayer_canvas-node.cc Thu Sep 28 14:32:40 2006 +0000
1.3 @@ -38,6 +38,12 @@
1.4 w=5;
1.5 }
1.6
1.7 + if(zoomtrack)
1.8 + {
1.9 + double actual_ppu=get_pixels_per_unit();
1.10 + w=(int)(w/actual_ppu*fixed_zoom_factor);
1.11 + }
1.12 +
1.13 if(w>=0)
1.14 {
1.15 double x1, y1, x2, y2;
1.16 @@ -95,6 +101,11 @@
1.17 {
1.18 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
1.19 }
1.20 + if(zoomtrack)
1.21 + {
1.22 + double actual_ppu=get_pixels_per_unit();
1.23 + w=(int)(w/actual_ppu*fixed_zoom_factor);
1.24 + }
1.25 if(w>=0)
1.26 {
1.27 double x1, y1, x2, y2;
2.1 --- a/graph_displayer_canvas-zoom.cc Thu Sep 28 09:26:48 2006 +0000
2.2 +++ b/graph_displayer_canvas-zoom.cc Thu Sep 28 14:32:40 2006 +0000
2.3 @@ -5,12 +5,20 @@
2.4 {
2.5 set_pixels_per_unit(
2.6 (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit());
2.7 + if(zoomtrack)
2.8 + {
2.9 + propertyChange(false, N_RADIUS);
2.10 + }
2.11 }
2.12
2.13 void GraphDisplayerCanvas::zoomOut()
2.14 {
2.15 set_pixels_per_unit(
2.16 (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
2.17 + if(zoomtrack)
2.18 + {
2.19 + propertyChange(false, N_RADIUS);
2.20 + }
2.21 }
2.22
2.23 void GraphDisplayerCanvas::zoomFit()
2.24 @@ -31,12 +39,22 @@
2.25 double ppu1 = (double) aw / fabs(x2 - x1);
2.26 double ppu2 = (double) ah / fabs(y2 - y1);
2.27 set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
2.28 +
2.29 + if(zoomtrack)
2.30 + {
2.31 + propertyChange(false, N_RADIUS);
2.32 + }
2.33 }
2.34
2.35 void GraphDisplayerCanvas::zoom100()
2.36 {
2.37 updateScrollRegion();
2.38 set_pixels_per_unit(1.0);
2.39 +
2.40 + if(zoomtrack)
2.41 + {
2.42 + propertyChange(false, N_RADIUS);
2.43 + }
2.44 }
2.45
2.46 void GraphDisplayerCanvas::updateScrollRegion()
3.1 --- a/graph_displayer_canvas.cc Thu Sep 28 09:26:48 2006 +0000
3.2 +++ b/graph_displayer_canvas.cc Thu Sep 28 14:32:40 2006 +0000
3.3 @@ -5,7 +5,7 @@
3.4 nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
3.5 nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
3.6 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
3.7 - edgemap_to_edit(""), autoscale(true), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
3.8 + edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
3.9 {
3.10 //base event handler is move tool
3.11 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
3.12 @@ -227,18 +227,27 @@
3.13 }
3.14 }
3.15
3.16 -void GraphDisplayerCanvas::setNodeView(bool autoscale_p, double min_p, double max_p, double unit_p)
3.17 +void GraphDisplayerCanvas::setNodeView(bool autoscale_p, bool zoomtrack_p, double min_p, double max_p, double unit_p)
3.18 {
3.19 autoscale=autoscale_p;
3.20 radius_min=min_p;
3.21 radius_max=max_p;
3.22 radius_unit=unit_p;
3.23 +
3.24 + if((!zoomtrack) && zoomtrack_p)
3.25 + {
3.26 + fixed_zoom_factor=get_pixels_per_unit();
3.27 + }
3.28 +
3.29 + zoomtrack=zoomtrack_p;
3.30 +
3.31 propertyChange(false, N_RADIUS);
3.32 }
3.33
3.34 -void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, double& min_p, double& max_p, double& unit_p)
3.35 +void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, bool & zoomtrack_p, double& min_p, double& max_p, double& unit_p)
3.36 {
3.37 autoscale_p=autoscale;
3.38 + zoomtrack_p=zoomtrack;
3.39 min_p=radius_min;
3.40 max_p=radius_max;
3.41 unit_p=radius_unit;
4.1 --- a/graph_displayer_canvas.h Thu Sep 28 09:26:48 2006 +0000
4.2 +++ b/graph_displayer_canvas.h Thu Sep 28 14:32:40 2006 +0000
4.3 @@ -287,10 +287,10 @@
4.4 int getActualTool();
4.5
4.6 ///Sets node representation settings
4.7 - void setNodeView(bool, double, double, double);
4.8 + void setNodeView(bool, bool, double, double, double);
4.9
4.10 ///Gets node representation settings
4.11 - void getNodeView(bool &, double&, double&, double&);
4.12 + void getNodeView(bool &, bool &, double&, double&, double&);
4.13
4.14 ///draws the graph
4.15
4.16 @@ -386,6 +386,12 @@
4.17 ///Is node radius autoscaled
4.18 bool autoscale;
4.19
4.20 + ///Should we track zoomfactor changes
4.21 + bool zoomtrack;
4.22 +
4.23 + ///to store the zoom factor when it was "fixed"
4.24 + double fixed_zoom_factor;
4.25 +
4.26 ///Minimum node radius
4.27 double radius_min;
4.28
5.1 --- a/main_win.cc Thu Sep 28 09:26:48 2006 +0000
5.2 +++ b/main_win.cc Thu Sep 28 14:32:40 2006 +0000
5.3 @@ -199,16 +199,15 @@
5.4 table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
5.5
5.6 }
5.7 -
5.8 - auto_scale= new Gtk::CheckButton("Autoscale");
5.9 - auto_scale->set_active(false);
5.10 - auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
5.11 -
5.12 +
5.13 table2.set_row_spacings(10);
5.14 table2.set_col_spacings(5);
5.15
5.16 + auto_scale = new Gtk::CheckButton("Autoscale");
5.17 + auto_scale->set_active(false);
5.18 + auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
5.19 table2.attach(*auto_scale, 0,2,0,1);
5.20 -
5.21 +
5.22 Gtk::Label * unit_label= new Gtk::Label("Unit:");
5.23 // table2.attach(*unit_label, 2,3,0,1);
5.24
5.25 @@ -236,6 +235,12 @@
5.26 radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
5.27 table2.attach(*radius_max, 3,4,1,2);
5.28
5.29 + zoom_track = new Gtk::CheckButton("Zoom tracking");
5.30 + zoom_track->set_active(false);
5.31 + zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
5.32 + table2.attach(*zoom_track, 2,4,0,1);
5.33 +
5.34 +
5.35 //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
5.36 table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
5.37
5.38 @@ -362,13 +367,15 @@
5.39 tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
5.40 set_title(tabnames[active_tab]);
5.41 bool autoscale;
5.42 + bool zoomtrack;
5.43 double min;
5.44 double max;
5.45 double unit;
5.46 - tabs[active_tab]->getNodeView(autoscale, min, max, unit);
5.47 + tabs[active_tab]->getNodeView(autoscale, zoomtrack, min, max, unit);
5.48 radius_min->set_value(min);
5.49 radius_max->set_value(max);
5.50 radius_unit->set_value(unit);
5.51 + zoom_track->set_active(zoomtrack);
5.52 auto_scale->set_active(autoscale);
5.53
5.54 }
5.55 @@ -539,6 +546,7 @@
5.56 double min=radius_min->get_value();
5.57 double max=radius_max->get_value();
5.58 double unit=radius_unit->get_value();
5.59 + bool zoomtrack=zoom_track->get_active();
5.60 bool autoscale=auto_scale->get_active();
5.61 - tabs[active_tab]->setNodeView(autoscale, min, max, unit);
5.62 + tabs[active_tab]->setNodeView(autoscale, zoomtrack, min, max, unit);
5.63 }
6.1 --- a/main_win.h Thu Sep 28 09:26:48 2006 +0000
6.2 +++ b/main_win.h Thu Sep 28 14:32:40 2006 +0000
6.3 @@ -30,6 +30,9 @@
6.4 ///Should nodes be autoscaled or not?
6.5 Gtk::CheckButton * auto_scale;
6.6
6.7 + ///Should node size track zoom factor?
6.8 + Gtk::CheckButton * zoom_track;
6.9 +
6.10 ///Minimum and maximum node radius entry
6.11 Gtk::SpinButton * radius_min, * radius_max, * radius_unit;
6.12
7.1 --- a/nbtab.cc Thu Sep 28 09:26:48 2006 +0000
7.2 +++ b/nbtab.cc Thu Sep 28 14:32:40 2006 +0000
7.3 @@ -218,12 +218,12 @@
7.4 return signal_title;
7.5 }
7.6
7.7 -void NoteBookTab::setNodeView(bool autoscale, double min, double max, double unit)
7.8 +void NoteBookTab::setNodeView(bool autoscale, bool zoomtrack, double min, double max, double unit)
7.9 {
7.10 - gd_canvas->setNodeView(autoscale, min, max, unit);
7.11 + gd_canvas->setNodeView(autoscale, zoomtrack, min, max, unit);
7.12 }
7.13
7.14 -void NoteBookTab::getNodeView(bool & autoscale, double& min, double& max, double& unit)
7.15 +void NoteBookTab::getNodeView(bool & autoscale, bool & zoomtrack, double& min, double& max, double& unit)
7.16 {
7.17 - gd_canvas->getNodeView(autoscale, min, max, unit);
7.18 + gd_canvas->getNodeView(autoscale, zoomtrack, min, max, unit);
7.19 }
8.1 --- a/nbtab.h Thu Sep 28 09:26:48 2006 +0000
8.2 +++ b/nbtab.h Thu Sep 28 14:32:40 2006 +0000
8.3 @@ -158,10 +158,10 @@
8.4 void closeMapWin();
8.5
8.6 ///Sets node representation settings
8.7 - void setNodeView(bool, double, double, double);
8.8 + void setNodeView(bool, bool, double, double, double);
8.9
8.10 ///Gets node representation settings
8.11 - void getNodeView(bool &, double&, double&, double&);
8.12 + void getNodeView(bool &, bool &, double&, double&, double&);
8.13 };
8.14
8.15 #endif //NBTAB_H