Redesign parameters can now be saved and loaded.
1.1 --- a/design_win.cc Mon Oct 30 13:08:04 2006 +0000
1.2 +++ b/design_win.cc Mon Oct 30 14:57:48 2006 +0000
1.3 @@ -89,3 +89,10 @@
1.4 {
1.5 Gtk::Window::set_title("Design Setup - "+tabname);
1.6 }
1.7 +
1.8 +void DesignWin::set_data(double attr, double propuls, int it)
1.9 +{
1.10 + attraction->set_value(attr);
1.11 + propulsation->set_value(propuls);
1.12 + iteration->set_value(it);
1.13 +}
2.1 --- a/design_win.h Mon Oct 30 13:08:04 2006 +0000
2.2 +++ b/design_win.h Mon Oct 30 14:57:48 2006 +0000
2.3 @@ -63,5 +63,7 @@
2.4 sigc::signal<void> close_run(){return close_run_pr;};
2.5
2.6 void set_title(std::string);
2.7 +
2.8 + void set_data(double, double, int);
2.9 };
2.10 #endif //DESWIN_H
3.1 --- a/graph_displayer_canvas.cc Mon Oct 30 13:08:04 2006 +0000
3.2 +++ b/graph_displayer_canvas.cc Mon Oct 30 14:57:48 2006 +0000
3.3 @@ -25,7 +25,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), is_drawn(false), mytab(mainw)
3.8 + 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 @@ -304,7 +304,12 @@
3.13 moveNode(init.x, init.y, nodesmap[i], i);
3.14 was_redesigned=true;
3.15 }
3.16 -
3.17 +
3.18 + double attraction;
3.19 + double propulsation;
3.20 + int iterations;
3.21 +
3.22 + (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
3.23
3.24 //iteration counter
3.25 for(int l=0;l<iterations;l++)
3.26 @@ -393,25 +398,3 @@
3.27 }
3.28 }
3.29
3.30 -void GraphDisplayerCanvas::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
3.31 -{
3.32 - attraction_p=attraction;
3.33 - propulsation_p=propulsation;
3.34 - iterations_p=iterations;
3.35 -}
3.36 -
3.37 -void GraphDisplayerCanvas::set_attraction(double attraction_p)
3.38 -{
3.39 - attraction=attraction_p;
3.40 -}
3.41 -
3.42 -void GraphDisplayerCanvas::set_propulsation(double propulsation_p)
3.43 -{
3.44 - propulsation=propulsation_p;
3.45 -}
3.46 -
3.47 -void GraphDisplayerCanvas::set_iteration(int iterations_p)
3.48 -{
3.49 - iterations=iterations_p;
3.50 -}
3.51 -
4.1 --- a/graph_displayer_canvas.h Mon Oct 30 13:08:04 2006 +0000
4.2 +++ b/graph_displayer_canvas.h Mon Oct 30 14:57:48 2006 +0000
4.3 @@ -336,11 +336,6 @@
4.4
4.5 void reDesignGraph();
4.6
4.7 - void get_design_data(double &, double &, int &);
4.8 - void set_attraction(double);
4.9 - void set_propulsation(double);
4.10 - void set_iteration(int);
4.11 -
4.12 ///Show whether the graph is already drawn.
4.13 bool is_drawn;
4.14
4.15 @@ -428,15 +423,6 @@
4.16 ///Edge width
4.17 double edge_width;
4.18
4.19 - ///Iteration number during graph design
4.20 - int iterations;
4.21 -
4.22 - ///Attraction factor during graph design
4.23 - double attraction;
4.24 -
4.25 - ///Propulsation factor during graph design
4.26 - double propulsation;
4.27 -
4.28 ///Was redesign run on this graph already?
4.29 ///
4.30 ///If not, the layout will be modified randomly
5.1 --- a/gui_reader.cc Mon Oct 30 13:08:04 2006 +0000
5.2 +++ b/gui_reader.cc Mon Oct 30 14:57:48 2006 +0000
5.3 @@ -60,6 +60,20 @@
5.4 {
5.5 mapstorage->changeActiveMap(true, i, em[i]);
5.6 }
5.7 +
5.8 + double attraction;
5.9 + double propulsation;
5.10 + int iteration;
5.11 +
5.12 + x("redesign-attraction", attraction);
5.13 + x("redesign-propulsation", propulsation);
5.14 + x("redesign-iteration", iteration);
5.15 +
5.16 + mapstorage->set_attraction(attraction);
5.17 + mapstorage->set_propulsation(propulsation);
5.18 + mapstorage->set_iteration(iteration);
5.19 +
5.20 + mapstorage->redesign_data_changed();
5.21 }
5.22
5.23 GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
6.1 --- a/gui_writer.cc Mon Oct 30 13:08:04 2006 +0000
6.2 +++ b/gui_writer.cc Mon Oct 30 14:57:48 2006 +0000
6.3 @@ -51,6 +51,16 @@
6.4 em[i]=mapstorage->active_edgemaps[i];
6.5 }
6.6 x("active_edgemaps", em);
6.7 +
6.8 + double attraction;
6.9 + double propulsation;
6.10 + int iteration;
6.11 +
6.12 + mapstorage->get_design_data(attraction, propulsation, iteration);
6.13 +
6.14 + x("redesign-attraction", attraction);
6.15 + x("redesign-propulsation", propulsation);
6.16 + x("redesign-iteration", iteration);
6.17 }
6.18
6.19 GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms)
7.1 --- a/mapstorage.cc Mon Oct 30 13:08:04 2006 +0000
7.2 +++ b/mapstorage.cc Mon Oct 30 14:57:48 2006 +0000
7.3 @@ -23,7 +23,11 @@
7.4 #include <cmath>
7.5 #include <gtkmm.h>
7.6
7.7 -MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false)
7.8 +const double i_d=20;
7.9 +const double a_d=0.05;
7.10 +const double p_d=40000;
7.11 +
7.12 +MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d)
7.13 {
7.14 nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
7.15 coords.setXMap(*nodemap_storage["coordinates_x"]);
7.16 @@ -148,7 +152,7 @@
7.17 return nml;
7.18 }
7.19
7.20 -MapStorage::Signal_Prop MapStorage::signal_prop_ch()
7.21 +sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
7.22 {
7.23 return signal_prop;
7.24 }
7.25 @@ -485,6 +489,12 @@
7.26 changeActiveMap(true, i, "");
7.27 signal_map_win.emit(true, i, "");
7.28 }
7.29 +
7.30 + attraction=a_d;
7.31 + propulsation=p_d;
7.32 + iterations=i_d;
7.33 +
7.34 + signal_design_win.emit(attraction, propulsation, iterations);
7.35 }
7.36
7.37 void MapStorage::ArrowPosReadOK()
7.38 @@ -515,3 +525,30 @@
7.39 }
7.40 }
7.41 }
7.42 +
7.43 +void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
7.44 +{
7.45 + attraction_p=attraction;
7.46 + propulsation_p=propulsation;
7.47 + iterations_p=iterations;
7.48 +}
7.49 +
7.50 +void MapStorage::set_attraction(double attraction_p)
7.51 +{
7.52 + attraction=attraction_p;
7.53 +}
7.54 +
7.55 +void MapStorage::set_propulsation(double propulsation_p)
7.56 +{
7.57 + propulsation=propulsation_p;
7.58 +}
7.59 +
7.60 +void MapStorage::set_iteration(int iterations_p)
7.61 +{
7.62 + iterations=iterations_p;
7.63 +}
7.64 +
7.65 +void MapStorage::redesign_data_changed()
7.66 +{
7.67 + signal_design_win.emit(attraction, propulsation, iterations);
7.68 +}
8.1 --- a/mapstorage.h Mon Oct 30 13:08:04 2006 +0000
8.2 +++ b/mapstorage.h Mon Oct 30 14:57:48 2006 +0000
8.3 @@ -82,14 +82,13 @@
8.4 bool arrow_pos_read_ok;
8.5
8.6 protected:
8.7 - /// type of the signal emitted if the visualization of the maps might have to be updated.
8.8
8.9 + /// Signal emitted on any change made on map values
8.10 +
8.11 + /// Signal emitted if the visualization of the maps might have to be updated.
8.12 /// bool shows us whether the changed map is edge or nodemap.
8.13 /// int tells us the refreshed property
8.14 - typedef sigc::signal<void, bool, int> Signal_Prop;
8.15 -
8.16 - /// Signal emitted on any change made on map values
8.17 - Signal_Prop signal_prop;
8.18 + sigc::signal<void, bool, int> signal_prop;
8.19
8.20 /// Signal emitted in the case of nodemap addition
8.21
8.22 @@ -106,6 +105,18 @@
8.23 /// Signal emitted, when entry in \ref MapWin should be changed.
8.24 sigc::signal<void, bool, int, std::string> signal_map_win;
8.25
8.26 + /// Signal emitted, when entry in \ref DesignWin should be changed.
8.27 + sigc::signal<void, double, double, int> signal_design_win;
8.28 +
8.29 + ///Iteration number during graph design
8.30 + int iterations;
8.31 +
8.32 + ///Attraction factor during graph design
8.33 + double attraction;
8.34 +
8.35 + ///Propulsation factor during graph design
8.36 + double propulsation;
8.37 +
8.38 public:
8.39 ///Constructor of MapStorage.
8.40
8.41 @@ -152,7 +163,7 @@
8.42 std::vector<std::string> getNodeMapList();
8.43
8.44 ///returns \ref signal_prop to be able to connect functions to it
8.45 - Signal_Prop signal_prop_ch();
8.46 + sigc::signal<void, bool, int> signal_prop_ch();
8.47
8.48 ///returns \ref signal_node_map to be able to connect functions to it
8.49 sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
8.50 @@ -163,6 +174,9 @@
8.51 ///returns \ref signal_map_win to be able to connect functions to it
8.52 sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
8.53
8.54 + ///returns \ref signal_design_win to be able to connect functions to it
8.55 + sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
8.56 +
8.57 ///Adds given map to storage.
8.58
8.59 ///A name and the map itself has to be provided.
8.60 @@ -261,6 +275,13 @@
8.61 void clear();
8.62
8.63 void ArrowPosReadOK();
8.64 +
8.65 + void get_design_data(double &, double &, int &);
8.66 + void set_attraction(double);
8.67 + void set_propulsation(double);
8.68 + void set_iteration(int);
8.69 +
8.70 + void redesign_data_changed();
8.71 };
8.72
8.73 #endif //MAPSTORAGE_H
9.1 --- a/nbtab.cc Mon Oct 30 13:08:04 2006 +0000
9.2 +++ b/nbtab.cc Mon Oct 30 14:57:48 2006 +0000
9.3 @@ -235,16 +235,18 @@
9.4 {
9.5 double attraction, propulsation;
9.6 int iterations;
9.7 - gd_canvas->get_design_data(attraction, propulsation, iterations);
9.8 + mapstorage.get_design_data(attraction, propulsation, iterations);
9.9 designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this);
9.10
9.11 - designwin->signal_attraction().connect(sigc::mem_fun(*this, &NoteBookTab::attraction_ch));
9.12 - designwin->signal_propulsation().connect(sigc::mem_fun(*this, &NoteBookTab::propulsation_ch));
9.13 - designwin->signal_iteration().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::set_iteration));
9.14 + designwin->signal_attraction().connect(sigc::mem_fun(mapstorage, &MapStorage::set_attraction));
9.15 + designwin->signal_propulsation().connect(sigc::mem_fun(mapstorage, &MapStorage::set_propulsation));
9.16 + designwin->signal_iteration().connect(sigc::mem_fun(mapstorage, &MapStorage::set_iteration));
9.17 designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph));
9.18
9.19 designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
9.20
9.21 + mapst2designwin=mapstorage.signal_design_win_ch().connect(sigc::mem_fun(*designwin, &DesignWin::set_data));
9.22 +
9.23 designwin->show();
9.24 designwinexists=true;
9.25 }
9.26 @@ -262,6 +264,7 @@
9.27 if(e->type==GDK_DELETE)
9.28 {
9.29 designwinexists=false;
9.30 + mapst2designwin.disconnect();
9.31 delete designwin;
9.32 }
9.33 }
9.34 @@ -286,21 +289,6 @@
9.35 gd_canvas->reDesignGraph();
9.36 }
9.37
9.38 -void NoteBookTab::attraction_ch(double v)
9.39 -{
9.40 - gd_canvas->set_attraction(v);
9.41 -}
9.42 -
9.43 -void NoteBookTab::propulsation_ch(double v)
9.44 -{
9.45 - gd_canvas->set_propulsation(v);
9.46 -}
9.47 -
9.48 -void NoteBookTab::iteration_ch(int v)
9.49 -{
9.50 - gd_canvas->set_iteration(v);
9.51 -}
9.52 -
9.53 void NoteBookTab::active_maps_needed()
9.54 {
9.55 mapstorage.broadcastActiveMaps();
10.1 --- a/nbtab.h Mon Oct 30 13:08:04 2006 +0000
10.2 +++ b/nbtab.h Mon Oct 30 14:57:48 2006 +0000
10.3 @@ -202,15 +202,6 @@
10.4 ///Let the graph redesign, based on gravity and edge elasticity.
10.5 void reDesignGraph();
10.6
10.7 - ///Indicates that attraction factor is changed
10.8 - void attraction_ch(double);
10.9 -
10.10 - ///Indicates that propulsation factor is changed
10.11 - void propulsation_ch(double);
10.12 -
10.13 - ///Indicates that iteration number of redesign is changed
10.14 - void iteration_ch(int);
10.15 -
10.16 ///\ref MapWin calls this function when it updates the maplist in comboboxes.
10.17 void active_maps_needed();
10.18
10.19 @@ -220,6 +211,12 @@
10.20 ///If \ref MapWin is closed this connection has to be disconnected,
10.21 ///therefore we have to store it.
10.22 sigc::connection mapst2mapwin;
10.23 +
10.24 + ///Signal connection from \ref MapStorage to \ref DesignWin
10.25 +
10.26 + ///If \ref DesignWin is closed this connection has to be disconnected,
10.27 + ///therefore we have to store it.
10.28 + sigc::connection mapst2designwin;
10.29 };
10.30
10.31 #endif //NBTAB_H