1.1 --- a/graph_displayer_canvas-node.cc Mon Sep 25 12:08:35 2006 +0000
1.2 +++ b/graph_displayer_canvas-node.cc Mon Sep 25 15:30:04 2006 +0000
1.3 @@ -16,13 +16,20 @@
1.4 {
1.5 double v=fabs((*actual_map)[i]);
1.6 int w;
1.7 - if(min==max)
1.8 + if(autoscale)
1.9 {
1.10 - w=(int)(node_property_defaults[N_RADIUS]);
1.11 + if(min==max)
1.12 + {
1.13 + w=(int)(node_property_defaults[N_RADIUS]);
1.14 + }
1.15 + else
1.16 + {
1.17 + w=(int)(radius_min+(v-min)/(max-min)*(radius_max-radius_min));
1.18 + }
1.19 }
1.20 else
1.21 {
1.22 - w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
1.23 + w=5+(int)(v/radius_unit);
1.24 }
1.25 if(w>=0)
1.26 {
1.27 @@ -41,7 +48,8 @@
1.28 else
1.29 {
1.30 //I think only new nodes use this case
1.31 -// int w=(int)(*actual_map)[node];
1.32 + //that has no own value, only the default one
1.33 + //int w=(int)(*actual_map)[node];
1.34 int w=(int)(node_property_defaults[N_RADIUS]);
1.35 if(w>=0)
1.36 {
2.1 --- a/graph_displayer_canvas.cc Mon Sep 25 12:08:35 2006 +0000
2.2 +++ b/graph_displayer_canvas.cc Mon Sep 25 15:30:04 2006 +0000
2.3 @@ -5,7 +5,7 @@
2.4 nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
2.5 nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
2.6 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
2.7 - edgemap_to_edit(""), mytab(mainw)
2.8 + edgemap_to_edit(""), autoscale(true), radius_min(10), radius_max(40), radius_unit(1), mytab(mainw)
2.9 {
2.10 //base event handler is move tool
2.11 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
2.12 @@ -226,3 +226,20 @@
2.13 delete edgetextmap[e];
2.14 }
2.15 }
2.16 +
2.17 +void GraphDisplayerCanvas::setNodeView(bool autoscale_p, double min_p, double max_p, double unit_p)
2.18 +{
2.19 + autoscale=autoscale_p;
2.20 + radius_min=min_p;
2.21 + radius_max=max_p;
2.22 + radius_unit=unit_p;
2.23 + propertyChange(false, N_RADIUS);
2.24 +}
2.25 +
2.26 +void GraphDisplayerCanvas::getNodeView(bool & autoscale_p, double& min_p, double& max_p, double& unit_p)
2.27 +{
2.28 + autoscale_p=autoscale;
2.29 + min_p=radius_min;
2.30 + max_p=radius_max;
2.31 + unit_p=radius_unit;
2.32 +}
3.1 --- a/graph_displayer_canvas.h Mon Sep 25 12:08:35 2006 +0000
3.2 +++ b/graph_displayer_canvas.h Mon Sep 25 15:30:04 2006 +0000
3.3 @@ -286,6 +286,12 @@
3.4 ///Returns the actual tool in hand
3.5 int getActualTool();
3.6
3.7 + ///Sets node representation settings
3.8 + void setNodeView(bool, double, double, double);
3.9 +
3.10 + ///Gets node representation settings
3.11 + void getNodeView(bool &, double&, double&, double&);
3.12 +
3.13 ///draws the graph
3.14
3.15 ///Called when opening a file.
3.16 @@ -377,6 +383,18 @@
3.17
3.18 static const int zoom_step = 5;
3.19
3.20 + ///Is node radius autoscaled
3.21 + bool autoscale;
3.22 +
3.23 + ///Minimum node radius
3.24 + double radius_min;
3.25 +
3.26 + ///Maximum node radius
3.27 + double radius_max;
3.28 +
3.29 + ///Node radius unit
3.30 + double radius_unit;
3.31 +
3.32 private:
3.33
3.34 ///reference to the container, in which the canvas is
4.1 --- a/main_win.cc Mon Sep 25 12:08:35 2006 +0000
4.2 +++ b/main_win.cc Mon Sep 25 15:30:04 2006 +0000
4.3 @@ -11,7 +11,8 @@
4.4 {
4.5 set_title ("no file");
4.6 set_default_size(WIN_WIDTH,WIN_HEIGHT);
4.7 - add(vbox);
4.8 + //add(vbox);
4.9 + add(table);
4.10
4.11 // custom icons for the toolbar
4.12 Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
4.13 @@ -185,16 +186,59 @@
4.14
4.15 Gtk::Widget* menubar = uim->get_widget("/MenuBar");
4.16 if (menubar){
4.17 - vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
4.18 + //vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
4.19 + table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
4.20 }
4.21
4.22 Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
4.23 if (toolbar)
4.24 {
4.25 static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
4.26 - vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
4.27 + //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET);
4.28 +
4.29 + table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
4.30 +
4.31 }
4.32
4.33 + auto_scale= new Gtk::CheckButton("Autoscale");
4.34 + auto_scale->set_active(false);
4.35 + auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
4.36 +
4.37 + table2.set_row_spacings(10);
4.38 + table2.set_col_spacings(5);
4.39 +
4.40 + table2.attach(*auto_scale, 0,2,0,1);
4.41 +
4.42 + Gtk::Label * unit_label= new Gtk::Label("Unit:");
4.43 + table2.attach(*unit_label, 2,3,0,1);
4.44 +
4.45 + Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10);
4.46 +
4.47 + radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0);
4.48 + radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
4.49 + table2.attach(*radius_unit, 3,4,0,1);
4.50 +
4.51 + Gtk::Label * min_label= new Gtk::Label("Min:");
4.52 + table2.attach(*min_label, 0,1,1,2);
4.53 +
4.54 + Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10);
4.55 +
4.56 + radius_min = new Gtk::SpinButton(*adjustment_min, 5,0);
4.57 + radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
4.58 + table2.attach(*radius_min, 1,2,1,2);
4.59 +
4.60 + Gtk::Label * max_label= new Gtk::Label("Max:");
4.61 + table2.attach(*max_label, 2,3,1,2);
4.62 +
4.63 + Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 5, 200, 5, 10);
4.64 +
4.65 + radius_max = new Gtk::SpinButton(*adjustment_max, 5,0);
4.66 + radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
4.67 + table2.attach(*radius_max, 3,4,1,2);
4.68 +
4.69 + //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
4.70 + table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
4.71 +
4.72 tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
4.73 tooltips.enable();
4.74
4.75 @@ -203,7 +247,8 @@
4.76
4.77 active_tool = MOVE;
4.78
4.79 - vbox.pack_start(notebook);
4.80 + //vbox.pack_start(notebook);
4.81 + table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
4.82
4.83 show_all_children();
4.84 }
4.85 @@ -316,6 +361,16 @@
4.86 active_tab=page_num;
4.87 tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
4.88 set_title(tabnames[active_tab]);
4.89 + bool autoscale;
4.90 + double min;
4.91 + double max;
4.92 + double unit;
4.93 + tabs[active_tab]->getNodeView(autoscale, min, max, unit);
4.94 + radius_min->set_value(min);
4.95 + radius_max->set_value(max);
4.96 + radius_unit->set_value(unit);
4.97 + auto_scale->set_active(autoscale);
4.98 +
4.99 }
4.100
4.101 void MainWin::newFile()
4.102 @@ -477,3 +532,13 @@
4.103 NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false);
4.104 nmw->run();
4.105 }
4.106 +
4.107 +
4.108 +void MainWin::nodeViewChanged()
4.109 +{
4.110 + double min=radius_min->get_value();
4.111 + double max=radius_max->get_value();
4.112 + double unit=radius_unit->get_value();
4.113 + bool autoscale=auto_scale->get_active();
4.114 + tabs[active_tab]->setNodeView(autoscale, min, max, unit);
4.115 +}
5.1 --- a/main_win.h Mon Sep 25 12:08:35 2006 +0000
5.2 +++ b/main_win.h Mon Sep 25 15:30:04 2006 +0000
5.3 @@ -20,7 +20,18 @@
5.4 class MainWin : public Gtk::Window
5.5 {
5.6 ///Container in which the menus and the notebook is.
5.7 - Gtk::VBox vbox;
5.8 + //Gtk::VBox vbox;
5.9 + Gtk::Table table;
5.10 + Gtk::Table table2;
5.11 +
5.12 + ///Container in which the toolbar and the node parametrizer is.
5.13 + Gtk::HBox hbox;
5.14 +
5.15 + ///Should nodes be autoscaled or not?
5.16 + Gtk::CheckButton * auto_scale;
5.17 +
5.18 + ///Minimum and maximum node radius entry
5.19 + Gtk::SpinButton * radius_min, * radius_max, * radius_unit;
5.20
5.21 ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
5.22 Gtk::Notebook notebook;
5.23 @@ -221,6 +232,8 @@
5.24 ///Sets the variables that have to store the actual state, and it
5.25 ///updates the title of window to the actually selected \ref NoteBookTab.
5.26 virtual void onChangeTab(GtkNotebookPage*, guint);
5.27 +
5.28 + virtual void nodeViewChanged();
5.29 };
5.30
5.31 #endif //MAIN_WIN_H
6.1 --- a/nbtab.cc Mon Sep 25 12:08:35 2006 +0000
6.2 +++ b/nbtab.cc Mon Sep 25 15:30:04 2006 +0000
6.3 @@ -218,3 +218,12 @@
6.4 return signal_title;
6.5 }
6.6
6.7 +void NoteBookTab::setNodeView(bool autoscale, double min, double max, double unit)
6.8 +{
6.9 + gd_canvas->setNodeView(autoscale, min, max, unit);
6.10 +}
6.11 +
6.12 +void NoteBookTab::getNodeView(bool & autoscale, double& min, double& max, double& unit)
6.13 +{
6.14 + gd_canvas->getNodeView(autoscale, min, max, unit);
6.15 +}
7.1 --- a/nbtab.h Mon Sep 25 12:08:35 2006 +0000
7.2 +++ b/nbtab.h Mon Sep 25 15:30:04 2006 +0000
7.3 @@ -156,6 +156,12 @@
7.4 ///See also
7.5 ///\ref mapwin.
7.6 void closeMapWin();
7.7 +
7.8 + ///Sets node representation settings
7.9 + void setNodeView(bool, double, double, double);
7.10 +
7.11 + ///Gets node representation settings
7.12 + void getNodeView(bool &, double&, double&, double&);
7.13 };
7.14
7.15 #endif //NBTAB_H