# HG changeset patch # User hegyi # Date 1159198204 0 # Node ID 65c1b103443de169bc37b831c45c1b69e35948e9 # Parent d79a713828369331d4c4faf6722312a8b74a2c57 Node view diff -r d79a71382836 -r 65c1b103443d graph_displayer_canvas-node.cc --- a/graph_displayer_canvas-node.cc Mon Sep 25 12:08:35 2006 +0000 +++ b/graph_displayer_canvas-node.cc Mon Sep 25 15:30:04 2006 +0000 @@ -16,13 +16,20 @@ { double v=fabs((*actual_map)[i]); int w; - if(min==max) + if(autoscale) { - w=(int)(node_property_defaults[N_RADIUS]); + if(min==max) + { + w=(int)(node_property_defaults[N_RADIUS]); + } + else + { + w=(int)(radius_min+(v-min)/(max-min)*(radius_max-radius_min)); + } } else { - w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS)); + w=5+(int)(v/radius_unit); } if(w>=0) { @@ -41,7 +48,8 @@ else { //I think only new nodes use this case -// int w=(int)(*actual_map)[node]; + //that has no own value, only the default one + //int w=(int)(*actual_map)[node]; int w=(int)(node_property_defaults[N_RADIUS]); if(w>=0) { diff -r d79a71382836 -r 65c1b103443d graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Mon Sep 25 12:08:35 2006 +0000 +++ b/graph_displayer_canvas.cc Mon Sep 25 15:30:04 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(""), mytab(mainw) + edgemap_to_edit(""), autoscale(true), 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); @@ -226,3 +226,20 @@ delete edgetextmap[e]; } } + +void GraphDisplayerCanvas::setNodeView(bool autoscale_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; + propertyChange(false, N_RADIUS); +} + +void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, double& min_p, double& max_p, double& unit_p) +{ + autoscale_p=autoscale; + min_p=radius_min; + max_p=radius_max; + unit_p=radius_unit; +} diff -r d79a71382836 -r 65c1b103443d graph_displayer_canvas.h --- a/graph_displayer_canvas.h Mon Sep 25 12:08:35 2006 +0000 +++ b/graph_displayer_canvas.h Mon Sep 25 15:30:04 2006 +0000 @@ -286,6 +286,12 @@ ///Returns the actual tool in hand int getActualTool(); + ///Sets node representation settings + void setNodeView(bool, double, double, double); + + ///Gets node representation settings + void getNodeView(bool &, double&, double&, double&); + ///draws the graph ///Called when opening a file. @@ -377,6 +383,18 @@ static const int zoom_step = 5; + ///Is node radius autoscaled + bool autoscale; + + ///Minimum node radius + double radius_min; + + ///Maximum node radius + double radius_max; + + ///Node radius unit + double radius_unit; + private: ///reference to the container, in which the canvas is diff -r d79a71382836 -r 65c1b103443d main_win.cc --- a/main_win.cc Mon Sep 25 12:08:35 2006 +0000 +++ b/main_win.cc Mon Sep 25 15:30:04 2006 +0000 @@ -11,7 +11,8 @@ { set_title ("no file"); set_default_size(WIN_WIDTH,WIN_HEIGHT); - add(vbox); + //add(vbox); + add(table); // custom icons for the toolbar Glib::RefPtr p_icon_factory = Gtk::IconFactory::create(); @@ -185,16 +186,59 @@ Gtk::Widget* menubar = uim->get_widget("/MenuBar"); if (menubar){ - vbox.pack_start(*menubar, Gtk::PACK_SHRINK); + //vbox.pack_start(*menubar, Gtk::PACK_SHRINK); + table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); } Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); if (toolbar) { static_cast(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); - vbox.pack_start(*toolbar, Gtk::PACK_SHRINK); + //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET); + + 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); + + table2.attach(*auto_scale, 0,2,0,1); + + Gtk::Label * unit_label= new Gtk::Label("Unit:"); + table2.attach(*unit_label, 2,3,0,1); + + Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10); + + radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0); + radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); + table2.attach(*radius_unit, 3,4,0,1); + + Gtk::Label * min_label= new Gtk::Label("Min:"); + table2.attach(*min_label, 0,1,1,2); + + Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10); + + radius_min = new Gtk::SpinButton(*adjustment_min, 5,0); + radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); + table2.attach(*radius_min, 1,2,1,2); + + Gtk::Label * max_label= new Gtk::Label("Max:"); + table2.attach(*max_label, 2,3,1,2); + + Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 5, 200, 5, 10); + + radius_max = new Gtk::SpinButton(*adjustment_max, 5,0); + radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); + table2.attach(*radius_max, 3,4,1,2); + + //vbox.pack_start(hbox, Gtk::PACK_SHRINK); + table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK); + tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node"); tooltips.enable(); @@ -203,7 +247,8 @@ active_tool = MOVE; - vbox.pack_start(notebook); + //vbox.pack_start(notebook); + table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); show_all_children(); } @@ -316,6 +361,16 @@ active_tab=page_num; tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); set_title(tabnames[active_tab]); + bool autoscale; + double min; + double max; + double unit; + tabs[active_tab]->getNodeView(autoscale, min, max, unit); + radius_min->set_value(min); + radius_max->set_value(max); + radius_unit->set_value(unit); + auto_scale->set_active(autoscale); + } void MainWin::newFile() @@ -477,3 +532,13 @@ NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false); nmw->run(); } + + +void MainWin::nodeViewChanged() +{ + double min=radius_min->get_value(); + double max=radius_max->get_value(); + double unit=radius_unit->get_value(); + bool autoscale=auto_scale->get_active(); + tabs[active_tab]->setNodeView(autoscale, min, max, unit); +} diff -r d79a71382836 -r 65c1b103443d main_win.h --- a/main_win.h Mon Sep 25 12:08:35 2006 +0000 +++ b/main_win.h Mon Sep 25 15:30:04 2006 +0000 @@ -20,7 +20,18 @@ class MainWin : public Gtk::Window { ///Container in which the menus and the notebook is. - Gtk::VBox vbox; + //Gtk::VBox vbox; + Gtk::Table table; + Gtk::Table table2; + + ///Container in which the toolbar and the node parametrizer is. + Gtk::HBox hbox; + + ///Should nodes be autoscaled or not? + Gtk::CheckButton * auto_scale; + + ///Minimum and maximum node radius entry + Gtk::SpinButton * radius_min, * radius_max, * radius_unit; ///The notebook that has tabs (\ref NoteBookTab) with different graphs. Gtk::Notebook notebook; @@ -221,6 +232,8 @@ ///Sets the variables that have to store the actual state, and it ///updates the title of window to the actually selected \ref NoteBookTab. virtual void onChangeTab(GtkNotebookPage*, guint); + + virtual void nodeViewChanged(); }; #endif //MAIN_WIN_H diff -r d79a71382836 -r 65c1b103443d nbtab.cc --- a/nbtab.cc Mon Sep 25 12:08:35 2006 +0000 +++ b/nbtab.cc Mon Sep 25 15:30:04 2006 +0000 @@ -218,3 +218,12 @@ return signal_title; } +void NoteBookTab::setNodeView(bool autoscale, double min, double max, double unit) +{ + gd_canvas->setNodeView(autoscale, min, max, unit); +} + +void NoteBookTab::getNodeView(bool & autoscale, double& min, double& max, double& unit) +{ + gd_canvas->getNodeView(autoscale, min, max, unit); +} diff -r d79a71382836 -r 65c1b103443d nbtab.h --- a/nbtab.h Mon Sep 25 12:08:35 2006 +0000 +++ b/nbtab.h Mon Sep 25 15:30:04 2006 +0000 @@ -156,6 +156,12 @@ ///See also ///\ref mapwin. void closeMapWin(); + + ///Sets node representation settings + void setNodeView(bool, double, double, double); + + ///Gets node representation settings + void getNodeView(bool &, double&, double&, double&); }; #endif //NBTAB_H