# HG changeset patch # User hegyi # Date 1159453960 0 # Node ID c5cdf6690cdfde60839e99fd697dc31ebad7b597 # Parent 74065e83844d9995799c809d299dbabf00a5cc66 Zoom tracking of nodes is implemented and is switchable. diff -r 74065e83844d -r c5cdf6690cdf graph_displayer_canvas-node.cc --- a/graph_displayer_canvas-node.cc Thu Sep 28 09:26:48 2006 +0000 +++ b/graph_displayer_canvas-node.cc Thu Sep 28 14:32:40 2006 +0000 @@ -38,6 +38,12 @@ w=5; } + if(zoomtrack) + { + double actual_ppu=get_pixels_per_unit(); + w=(int)(w/actual_ppu*fixed_zoom_factor); + } + if(w>=0) { double x1, y1, x2, y2; @@ -95,6 +101,11 @@ { w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS)); } + if(zoomtrack) + { + double actual_ppu=get_pixels_per_unit(); + w=(int)(w/actual_ppu*fixed_zoom_factor); + } if(w>=0) { double x1, y1, x2, y2; diff -r 74065e83844d -r c5cdf6690cdf graph_displayer_canvas-zoom.cc --- a/graph_displayer_canvas-zoom.cc Thu Sep 28 09:26:48 2006 +0000 +++ b/graph_displayer_canvas-zoom.cc Thu Sep 28 14:32:40 2006 +0000 @@ -5,12 +5,20 @@ { set_pixels_per_unit( (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit()); + if(zoomtrack) + { + propertyChange(false, N_RADIUS); + } } void GraphDisplayerCanvas::zoomOut() { set_pixels_per_unit( (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit()); + if(zoomtrack) + { + propertyChange(false, N_RADIUS); + } } void GraphDisplayerCanvas::zoomFit() @@ -31,12 +39,22 @@ double ppu1 = (double) aw / fabs(x2 - x1); double ppu2 = (double) ah / fabs(y2 - y1); set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2); + + if(zoomtrack) + { + propertyChange(false, N_RADIUS); + } } void GraphDisplayerCanvas::zoom100() { updateScrollRegion(); set_pixels_per_unit(1.0); + + if(zoomtrack) + { + propertyChange(false, N_RADIUS); + } } void GraphDisplayerCanvas::updateScrollRegion() diff -r 74065e83844d -r c5cdf6690cdf graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Thu Sep 28 09:26:48 2006 +0000 +++ b/graph_displayer_canvas.cc Thu Sep 28 14:32:40 2006 +0000 @@ -5,7 +5,7 @@ nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph), nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0), isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""), - edgemap_to_edit(""), autoscale(true), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw) + edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw) { //base event handler is move tool actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); @@ -227,18 +227,27 @@ } } -void GraphDisplayerCanvas::setNodeView(bool autoscale_p, double min_p, double max_p, double unit_p) +void GraphDisplayerCanvas::setNodeView(bool autoscale_p, bool zoomtrack_p, double min_p, double max_p, double unit_p) { autoscale=autoscale_p; radius_min=min_p; radius_max=max_p; radius_unit=unit_p; + + if((!zoomtrack) && zoomtrack_p) + { + fixed_zoom_factor=get_pixels_per_unit(); + } + + zoomtrack=zoomtrack_p; + propertyChange(false, N_RADIUS); } -void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, double& min_p, double& max_p, double& unit_p) +void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, bool & zoomtrack_p, double& min_p, double& max_p, double& unit_p) { autoscale_p=autoscale; + zoomtrack_p=zoomtrack; min_p=radius_min; max_p=radius_max; unit_p=radius_unit; diff -r 74065e83844d -r c5cdf6690cdf graph_displayer_canvas.h --- a/graph_displayer_canvas.h Thu Sep 28 09:26:48 2006 +0000 +++ b/graph_displayer_canvas.h Thu Sep 28 14:32:40 2006 +0000 @@ -287,10 +287,10 @@ int getActualTool(); ///Sets node representation settings - void setNodeView(bool, double, double, double); + void setNodeView(bool, bool, double, double, double); ///Gets node representation settings - void getNodeView(bool &, double&, double&, double&); + void getNodeView(bool &, bool &, double&, double&, double&); ///draws the graph @@ -386,6 +386,12 @@ ///Is node radius autoscaled bool autoscale; + ///Should we track zoomfactor changes + bool zoomtrack; + + ///to store the zoom factor when it was "fixed" + double fixed_zoom_factor; + ///Minimum node radius double radius_min; diff -r 74065e83844d -r c5cdf6690cdf main_win.cc --- a/main_win.cc Thu Sep 28 09:26:48 2006 +0000 +++ b/main_win.cc Thu Sep 28 14:32:40 2006 +0000 @@ -199,16 +199,15 @@ table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); } - - auto_scale= new Gtk::CheckButton("Autoscale"); - auto_scale->set_active(false); - auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); - + table2.set_row_spacings(10); table2.set_col_spacings(5); + auto_scale = new Gtk::CheckButton("Autoscale"); + auto_scale->set_active(false); + auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); table2.attach(*auto_scale, 0,2,0,1); - + Gtk::Label * unit_label= new Gtk::Label("Unit:"); // table2.attach(*unit_label, 2,3,0,1); @@ -236,6 +235,12 @@ radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); table2.attach(*radius_max, 3,4,1,2); + zoom_track = new Gtk::CheckButton("Zoom tracking"); + zoom_track->set_active(false); + zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); + table2.attach(*zoom_track, 2,4,0,1); + + //vbox.pack_start(hbox, Gtk::PACK_SHRINK); table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK); @@ -362,13 +367,15 @@ tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); set_title(tabnames[active_tab]); bool autoscale; + bool zoomtrack; double min; double max; double unit; - tabs[active_tab]->getNodeView(autoscale, min, max, unit); + tabs[active_tab]->getNodeView(autoscale, zoomtrack, min, max, unit); radius_min->set_value(min); radius_max->set_value(max); radius_unit->set_value(unit); + zoom_track->set_active(zoomtrack); auto_scale->set_active(autoscale); } @@ -539,6 +546,7 @@ double min=radius_min->get_value(); double max=radius_max->get_value(); double unit=radius_unit->get_value(); + bool zoomtrack=zoom_track->get_active(); bool autoscale=auto_scale->get_active(); - tabs[active_tab]->setNodeView(autoscale, min, max, unit); + tabs[active_tab]->setNodeView(autoscale, zoomtrack, min, max, unit); } diff -r 74065e83844d -r c5cdf6690cdf main_win.h --- a/main_win.h Thu Sep 28 09:26:48 2006 +0000 +++ b/main_win.h Thu Sep 28 14:32:40 2006 +0000 @@ -30,6 +30,9 @@ ///Should nodes be autoscaled or not? Gtk::CheckButton * auto_scale; + ///Should node size track zoom factor? + Gtk::CheckButton * zoom_track; + ///Minimum and maximum node radius entry Gtk::SpinButton * radius_min, * radius_max, * radius_unit; diff -r 74065e83844d -r c5cdf6690cdf nbtab.cc --- a/nbtab.cc Thu Sep 28 09:26:48 2006 +0000 +++ b/nbtab.cc Thu Sep 28 14:32:40 2006 +0000 @@ -218,12 +218,12 @@ return signal_title; } -void NoteBookTab::setNodeView(bool autoscale, double min, double max, double unit) +void NoteBookTab::setNodeView(bool autoscale, bool zoomtrack, double min, double max, double unit) { - gd_canvas->setNodeView(autoscale, min, max, unit); + gd_canvas->setNodeView(autoscale, zoomtrack, min, max, unit); } -void NoteBookTab::getNodeView(bool & autoscale, double& min, double& max, double& unit) +void NoteBookTab::getNodeView(bool & autoscale, bool & zoomtrack, double& min, double& max, double& unit) { - gd_canvas->getNodeView(autoscale, min, max, unit); + gd_canvas->getNodeView(autoscale, zoomtrack, min, max, unit); } diff -r 74065e83844d -r c5cdf6690cdf nbtab.h --- a/nbtab.h Thu Sep 28 09:26:48 2006 +0000 +++ b/nbtab.h Thu Sep 28 14:32:40 2006 +0000 @@ -158,10 +158,10 @@ void closeMapWin(); ///Sets node representation settings - void setNodeView(bool, double, double, double); + void setNodeView(bool, bool, double, double, double); ///Gets node representation settings - void getNodeView(bool &, double&, double&, double&); + void getNodeView(bool &, bool &, double&, double&, double&); }; #endif //NBTAB_H