Currently visualized map can be saved and loaded from file.
1.1 --- a/design_win.cc Tue Oct 24 07:31:31 2006 +0000
1.2 +++ b/design_win.cc Wed Oct 25 13:21:24 2006 +0000
1.3 @@ -9,10 +9,12 @@
1.4 return true;
1.5 }
1.6
1.7 -DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
1.8 +DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v, NoteBookTab & mw):mytab(mw)
1.9 {
1.10 set_title(title);
1.11
1.12 + mytab.signal_title_ch().connect(sigc::mem_fun(*this, &DesignWin::set_title));
1.13 +
1.14 signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
1.15
1.16 Gtk::VBox * vbox=new Gtk::VBox();
1.17 @@ -64,3 +66,8 @@
1.18 {
1.19 signal_iteration_ch.emit((int)iteration->get_value());
1.20 }
1.21 +
1.22 +void DesignWin::set_title(std::string tabname)
1.23 +{
1.24 + Gtk::Window::set_title("Design Setup - "+tabname);
1.25 +}
2.1 --- a/design_win.h Tue Oct 24 07:31:31 2006 +0000
2.2 +++ b/design_win.h Wed Oct 25 13:21:24 2006 +0000
2.3 @@ -3,13 +3,19 @@
2.4 #ifndef DESWIN_H
2.5 #define DESWIN_H
2.6
2.7 +class DesignWin;
2.8 +
2.9 #include <all_include.h>
2.10 +#include <nbtab.h>
2.11 #include <libgnomecanvasmm.h>
2.12 #include <libgnomecanvasmm/polygon.h>
2.13
2.14 class DesignWin : public Gtk::Window
2.15 {
2.16 private:
2.17 + ///\ref NoteBookTab to that the \ref MapWin belongs to.
2.18 + NoteBookTab & mytab;
2.19 +
2.20 Gtk::SpinButton * attraction;
2.21 Gtk::SpinButton * propulsation;
2.22 Gtk::SpinButton * iteration;
2.23 @@ -33,11 +39,13 @@
2.24 ///Constructor
2.25
2.26 ///It builds the window.
2.27 - DesignWin(const std::string&, double, double, int);
2.28 + DesignWin(const std::string&, double, double, int, NoteBookTab & mw);
2.29
2.30 sigc::signal<void, double> signal_attraction(){return signal_attraction_ch;};
2.31 sigc::signal<void, double> signal_propulsation(){return signal_propulsation_ch;};
2.32 sigc::signal<void, int> signal_iteration(){return signal_iteration_ch;};
2.33 sigc::signal<void> close_run(){return close_run_pr;};
2.34 +
2.35 + void set_title(std::string);
2.36 };
2.37 #endif //DESWIN_H
3.1 --- a/graph_displayer_canvas.cc Tue Oct 24 07:31:31 2006 +0000
3.2 +++ b/graph_displayer_canvas.cc Wed Oct 25 13:21:24 2006 +0000
3.3 @@ -7,7 +7,7 @@
3.4 nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
3.5 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
3.6 edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
3.7 - iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), mytab(mainw)
3.8 + iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), is_drawn(false), 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 @@ -63,94 +63,95 @@
3.13
3.14 void GraphDisplayerCanvas::propertyUpdate(Node node, int prop)
3.15 {
3.16 - //dummy=dummy;
3.17 -
3.18 std::string mapname=mytab.getActiveNodeMap(prop);
3.19
3.20 - if(mapname!="")
3.21 + if(is_drawn)
3.22 {
3.23 - if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) )
3.24 + if(mapname!="")
3.25 {
3.26 + if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) )
3.27 + {
3.28 + switch(prop)
3.29 + {
3.30 + case N_RADIUS:
3.31 + changeNodeRadius(mapname, node);
3.32 + break;
3.33 + case N_COLOR:
3.34 + changeNodeColor(mapname, node);
3.35 + break;
3.36 + case N_TEXT:
3.37 + changeNodeText(mapname, node);
3.38 + break;
3.39 + default:
3.40 + std::cerr<<"Error\n";
3.41 + }
3.42 + }
3.43 + }
3.44 + else //mapname==""
3.45 + {
3.46 + Node node=INVALID;
3.47 switch(prop)
3.48 {
3.49 case N_RADIUS:
3.50 - changeNodeRadius(mapname, node);
3.51 + resetNodeRadius(node);
3.52 break;
3.53 case N_COLOR:
3.54 - changeNodeColor(mapname, node);
3.55 + resetNodeColor(node);
3.56 break;
3.57 case N_TEXT:
3.58 - changeNodeText(mapname, node);
3.59 + resetNodeText(node);
3.60 break;
3.61 default:
3.62 std::cerr<<"Error\n";
3.63 }
3.64 }
3.65 }
3.66 - else //mapname==""
3.67 - {
3.68 - Node node=INVALID;
3.69 - switch(prop)
3.70 - {
3.71 - case N_RADIUS:
3.72 - resetNodeRadius(node);
3.73 - break;
3.74 - case N_COLOR:
3.75 - resetNodeColor(node);
3.76 - break;
3.77 - case N_TEXT:
3.78 - resetNodeText(node);
3.79 - break;
3.80 - default:
3.81 - std::cerr<<"Error\n";
3.82 - }
3.83 - }
3.84 -
3.85 }
3.86
3.87 void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop)
3.88 {
3.89 - //dummy=dummy;
3.90 -
3.91 std::string mapname=mytab.getActiveEdgeMap(prop);
3.92
3.93 - if(mapname!="")
3.94 + if(is_drawn)
3.95 {
3.96 - if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) )
3.97 + if(mapname!="")
3.98 + {
3.99 + if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) )
3.100 + {
3.101 + switch(prop)
3.102 + {
3.103 + case E_WIDTH:
3.104 + changeEdgeWidth(mapname, edge);
3.105 + break;
3.106 + case E_COLOR:
3.107 + changeEdgeColor(mapname, edge);
3.108 + break;
3.109 + case E_TEXT:
3.110 + changeEdgeText(mapname, edge);
3.111 + break;
3.112 + default:
3.113 + std::cerr<<"Error\n";
3.114 + }
3.115 + }
3.116 + }
3.117 + else //mapname==""
3.118 {
3.119 switch(prop)
3.120 {
3.121 case E_WIDTH:
3.122 - changeEdgeWidth(mapname, edge);
3.123 + resetEdgeWidth(edge);
3.124 break;
3.125 case E_COLOR:
3.126 - changeEdgeColor(mapname, edge);
3.127 + resetEdgeColor(edge);
3.128 break;
3.129 case E_TEXT:
3.130 - changeEdgeText(mapname, edge);
3.131 + resetEdgeText(edge);
3.132 break;
3.133 default:
3.134 std::cerr<<"Error\n";
3.135 }
3.136 }
3.137 }
3.138 - else //mapname==""
3.139 - {
3.140 - switch(prop)
3.141 - {
3.142 - case E_WIDTH:
3.143 - resetEdgeWidth(edge);
3.144 - break;
3.145 - case E_COLOR:
3.146 - resetEdgeColor(edge);
3.147 - break;
3.148 - case E_TEXT:
3.149 - resetEdgeText(edge);
3.150 - break;
3.151 - default:
3.152 - std::cerr<<"Error\n";
3.153 - }
3.154 - }
3.155 }
3.156
3.157 void GraphDisplayerCanvas::drawGraph()
3.158 @@ -207,6 +208,21 @@
3.159 nodetextmap[i]->raise_to_top();
3.160 }
3.161
3.162 + is_drawn=true;
3.163 +
3.164 + //upon drawing graph
3.165 + //properties have to
3.166 + //be set in as well
3.167 + for(int i=0;i<NODE_PROPERTY_NUM;i++)
3.168 + {
3.169 + propertyUpdate(Node(INVALID), i);
3.170 + }
3.171 +
3.172 + for(int i=0;i<EDGE_PROPERTY_NUM;i++)
3.173 + {
3.174 + propertyUpdate(Edge(INVALID), i);
3.175 + }
3.176 +
3.177 updateScrollRegion();
3.178 }
3.179
3.180 @@ -227,6 +243,8 @@
3.181 delete edgesmap[e];
3.182 delete edgetextmap[e];
3.183 }
3.184 +
3.185 + is_drawn=false;
3.186 }
3.187
3.188 void GraphDisplayerCanvas::setView(bool autoscale_p, bool zoomtrack_p, double width_p, double radius_p)
4.1 --- a/graph_displayer_canvas.h Tue Oct 24 07:31:31 2006 +0000
4.2 +++ b/graph_displayer_canvas.h Wed Oct 25 13:21:24 2006 +0000
4.3 @@ -325,6 +325,9 @@
4.4 void set_propulsation(double);
4.5 void set_iteration(int);
4.6
4.7 + ///Show whether the graph is already drawn.
4.8 + bool is_drawn;
4.9 +
4.10 private:
4.11 ///Deletes the given element.
4.12 void deleteItem(Node);
5.1 --- a/gui_reader.cc Tue Oct 24 07:31:31 2006 +0000
5.2 +++ b/gui_reader.cc Wed Oct 25 13:21:24 2006 +0000
5.3 @@ -26,6 +26,21 @@
5.4 mapstorage->arrow_pos.set(e, m[edgeid]);
5.5 }
5.6 mapstorage->ArrowPosReadOK();
5.7 +
5.8 + std::map<int, std::string> nm;
5.9 + x("active_nodemaps", nm);
5.10 +
5.11 + for(int i=0;i<NODE_PROPERTY_NUM;i++)
5.12 + {
5.13 + mapstorage->changeActiveMap(false, i, nm[i]);
5.14 + }
5.15 +
5.16 + std::map<int, std::string> em;
5.17 + x("active_edgemaps", em);
5.18 + for(int i=0;i<EDGE_PROPERTY_NUM;i++)
5.19 + {
5.20 + mapstorage->changeActiveMap(true, i, em[i]);
5.21 + }
5.22 }
5.23
5.24 GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
6.1 --- a/gui_writer.cc Tue Oct 24 07:31:31 2006 +0000
6.2 +++ b/gui_writer.cc Wed Oct 25 13:21:24 2006 +0000
6.3 @@ -19,6 +19,20 @@
6.4 m[edgeid] = mapstorage->arrow_pos[e];
6.5 }
6.6 x("arrow_pos", m);
6.7 +
6.8 + std::map<int, std::string> nm;
6.9 + for(int i=0;i<NODE_PROPERTY_NUM;i++)
6.10 + {
6.11 + nm[i]=mapstorage->active_nodemaps[i];
6.12 + }
6.13 + x("active_nodemaps", nm);
6.14 +
6.15 + std::map<int, std::string> em;
6.16 + for(int i=0;i<EDGE_PROPERTY_NUM;i++)
6.17 + {
6.18 + em[i]=mapstorage->active_edgemaps[i];
6.19 + }
6.20 + x("active_edgemaps", em);
6.21 }
6.22
6.23 GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms)
7.1 --- a/map_win.cc Tue Oct 24 07:31:31 2006 +0000
7.2 +++ b/map_win.cc Wed Oct 25 13:21:24 2006 +0000
7.3 @@ -20,6 +20,8 @@
7.4
7.5 signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
7.6
7.7 + mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title));
7.8 +
7.9 e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
7.10
7.11 table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
7.12 @@ -90,6 +92,8 @@
7.13 {
7.14 n_combo_array[i]->update_list(nml);
7.15 }
7.16 +
7.17 + mytab.active_maps_needed();
7.18 }
7.19
7.20 void MapWin::registerNewEdgeMap(std::string newmapname)
7.21 @@ -116,3 +120,20 @@
7.22 mytab.closeMapWin();
7.23 return true;
7.24 }
7.25 +
7.26 +void MapWin::changeEntry(bool isitedge, int prop, std::string mapname)
7.27 +{
7.28 + if(isitedge)
7.29 + {
7.30 + e_combo_array[prop]->set_active_text(mapname);
7.31 + }
7.32 + else
7.33 + {
7.34 + n_combo_array[prop]->set_active_text(mapname);
7.35 + }
7.36 +}
7.37 +
7.38 +void MapWin::set_title(std::string tabname)
7.39 +{
7.40 + Gtk::Window::set_title("Map Setup - "+tabname);
7.41 +}
8.1 --- a/map_win.h Tue Oct 24 07:31:31 2006 +0000
8.2 +++ b/map_win.h Wed Oct 25 13:21:24 2006 +0000
8.3 @@ -112,6 +112,10 @@
8.4 ///\param eml edge map list
8.5 ///\param nml node map list
8.6 void update(std::vector<std::string> eml, std::vector<std::string> nml);
8.7 +
8.8 + void changeEntry(bool, int, std::string);
8.9 +
8.10 + void set_title(std::string);
8.11 };
8.12
8.13 #endif //MAP_WIN_H
9.1 --- a/mapselector.cc Tue Oct 24 07:31:31 2006 +0000
9.2 +++ b/mapselector.cc Wed Oct 25 13:21:24 2006 +0000
9.3 @@ -67,14 +67,17 @@
9.4 {
9.5 int prev_act=cbt.get_active_row_number();
9.6 cbt.clear();
9.7 + cbt_content.clear();
9.8 std::vector< std::string >::iterator emsi=ml.begin();
9.9 for(;emsi!=ml.end();emsi++)
9.10 {
9.11 cbt.append_text(*emsi);
9.12 + cbt_content.push_back(*emsi);
9.13 }
9.14 if(def)
9.15 {
9.16 cbt.prepend_text("Default values");
9.17 + cbt_content.push_back("Default values");
9.18 }
9.19 if(prev_act!=-1)
9.20 {
9.21 @@ -116,12 +119,21 @@
9.22
9.23 void MapSelector::set_active_text(Glib::ustring text)
9.24 {
9.25 - cbt.set_active_text(text);
9.26 + if(text.compare(""))
9.27 + {
9.28 + cbt.set_active_text(text);
9.29 + }
9.30 + else
9.31 + {
9.32 + cbt.set_active_text("Default values");
9.33 + }
9.34 }
9.35
9.36 void MapSelector::append_text(Glib::ustring text)
9.37 {
9.38 cbt.append_text(text);
9.39 + cbt_content.push_back(text);
9.40 +
9.41 if(set_new_map)
9.42 {
9.43 set_active_text(text);
10.1 --- a/mapselector.h Tue Oct 24 07:31:31 2006 +0000
10.2 +++ b/mapselector.h Wed Oct 25 13:21:24 2006 +0000
10.3 @@ -61,6 +61,8 @@
10.4 ///Names in it are selectable.
10.5 Gtk::ComboBoxText cbt;
10.6
10.7 + std::vector<std::string> cbt_content;
10.8 +
10.9 ///New button.
10.10
10.11 ///By pressing it
11.1 --- a/mapstorage.cc Tue Oct 24 07:31:31 2006 +0000
11.2 +++ b/mapstorage.cc Wed Oct 25 13:21:24 2006 +0000
11.3 @@ -52,7 +52,6 @@
11.4
11.5 int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value)
11.6 {
11.7 - std::cout << default_value << std::endl;
11.8 if( nodemap_storage.find(name) == nodemap_storage.end() )
11.9 {
11.10 nodemap_storage[name]=nodemap;
11.11 @@ -79,6 +78,20 @@
11.12 signal_prop.emit(itisedge, prop);
11.13 }
11.14
11.15 +void MapStorage::broadcastActiveMaps()
11.16 +{
11.17 + for(int i=0;i<NODE_PROPERTY_NUM;i++)
11.18 + {
11.19 + signal_map_win.emit(false, i, active_nodemaps[i]);
11.20 + }
11.21 +
11.22 + for(int i=0;i<EDGE_PROPERTY_NUM;i++)
11.23 + {
11.24 + signal_map_win.emit(true, i, active_edgemaps[i]);
11.25 + }
11.26 +}
11.27 +
11.28 +
11.29 std::string MapStorage::getActiveEdgeMap(int prop)
11.30 {
11.31 return active_edgemaps[prop];
11.32 @@ -440,6 +453,20 @@
11.33 graph.clear();
11.34 file_name = "";
11.35 modified = false;
11.36 +
11.37 + arrow_pos_read_ok = false;
11.38 +
11.39 + for(int i=0;i<NODE_PROPERTY_NUM;i++)
11.40 + {
11.41 + changeActiveMap(false, i, "");
11.42 + signal_map_win.emit(false, i, "");
11.43 + }
11.44 +
11.45 + for(int i=0;i<EDGE_PROPERTY_NUM;i++)
11.46 + {
11.47 + changeActiveMap(true, i, "");
11.48 + signal_map_win.emit(true, i, "");
11.49 + }
11.50 }
11.51
11.52 void MapStorage::ArrowPosReadOK()
12.1 --- a/mapstorage.h Tue Oct 24 07:31:31 2006 +0000
12.2 +++ b/mapstorage.h Wed Oct 25 13:21:24 2006 +0000
12.3 @@ -85,6 +85,9 @@
12.4 ///name of the new map
12.5 sigc::signal<void, std::string> signal_edge_map;
12.6
12.7 + /// Signal emitted, when entry in \ref MapWin should be changed.
12.8 + sigc::signal<void, bool, int, std::string> signal_map_win;
12.9 +
12.10 public:
12.11 ///Constructor of MapStorage.
12.12
12.13 @@ -109,6 +112,9 @@
12.14 ///\param mapname the visible map
12.15 void changeActiveMap(bool itisedge , int prop , std::string mapname);
12.16
12.17 + ///Emits signals that let change the active maps in \ref MapWin.
12.18 + void broadcastActiveMaps();
12.19 +
12.20 /// Returns the active edgemap shown by a visualization property.
12.21
12.22 /// \param prop is the property
12.23 @@ -136,6 +142,9 @@
12.24 ///returns \ref signal_edge_map to be able to connect functions to it
12.25 sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
12.26
12.27 + ///returns \ref signal_map_win to be able to connect functions to it
12.28 + sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
12.29 +
12.30 ///Adds given map to storage.
12.31
12.32 ///A name and the map itself has to be provided.
13.1 --- a/nbtab.cc Tue Oct 24 07:31:31 2006 +0000
13.2 +++ b/nbtab.cc Wed Oct 25 13:21:24 2006 +0000
13.3 @@ -202,6 +202,7 @@
13.4 if(!mapwinexists)
13.5 {
13.6 mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
13.7 + mapst2mapwin=mapstorage.signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry));
13.8 mapwin->show();
13.9 mapwinexists=true;
13.10 }
13.11 @@ -214,7 +215,7 @@
13.12 double attraction, propulsation;
13.13 int iterations;
13.14 gd_canvas->get_design_data(attraction, propulsation, iterations);
13.15 - designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations);
13.16 + designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this);
13.17
13.18 designwin->signal_attraction().connect(sigc::mem_fun(*this, &NoteBookTab::attraction_ch));
13.19 designwin->signal_propulsation().connect(sigc::mem_fun(*this, &NoteBookTab::propulsation_ch));
13.20 @@ -230,6 +231,7 @@
13.21
13.22 void NoteBookTab::closeMapWin()
13.23 {
13.24 + mapst2mapwin.disconnect();
13.25 mapwinexists=false;
13.26 delete mapwin;
13.27 }
13.28 @@ -278,3 +280,7 @@
13.29 gd_canvas->set_iteration(v);
13.30 }
13.31
13.32 +void NoteBookTab::active_maps_needed()
13.33 +{
13.34 + mapstorage.broadcastActiveMaps();
13.35 +}
14.1 --- a/nbtab.h Tue Oct 24 07:31:31 2006 +0000
14.2 +++ b/nbtab.h Wed Oct 25 13:21:24 2006 +0000
14.3 @@ -183,13 +183,27 @@
14.4 ///Gets node representation settings
14.5 void getView(bool &, bool &, double&, double&);
14.6
14.7 + ///Let the graph redesign, based on gravity and edge elasticity.
14.8 void reDesignGraph();
14.9
14.10 + ///Indicates that attraction factor is changed
14.11 void attraction_ch(double);
14.12
14.13 + ///Indicates that propulsation factor is changed
14.14 void propulsation_ch(double);
14.15
14.16 + ///Indicates that iteration number of redesign is changed
14.17 void iteration_ch(int);
14.18 +
14.19 + ///\ref MapWin calls this function when it updates the maplist in comboboxes.
14.20 + void active_maps_needed();
14.21 +
14.22 +private:
14.23 + ///Signal connection from \ref MapStorage to \ref MapWin
14.24 +
14.25 + ///If \ref MapWin is closed this connection has to be disconnected,
14.26 + ///therefore we have to store it.
14.27 + sigc::connection mapst2mapwin;
14.28 };
14.29
14.30 #endif //NBTAB_H