# HG changeset patch # User hegyi # Date 1162220268 0 # Node ID 40f3006fba2ecf525f830ef87903a231ea1622d9 # Parent 9fc3d5170b245f1d5dbb1f6643b4604cd0bfe9b5 Redesign parameters can now be saved and loaded. diff -r 9fc3d5170b24 -r 40f3006fba2e design_win.cc --- a/design_win.cc Mon Oct 30 13:08:04 2006 +0000 +++ b/design_win.cc Mon Oct 30 14:57:48 2006 +0000 @@ -89,3 +89,10 @@ { Gtk::Window::set_title("Design Setup - "+tabname); } + +void DesignWin::set_data(double attr, double propuls, int it) +{ + attraction->set_value(attr); + propulsation->set_value(propuls); + iteration->set_value(it); +} diff -r 9fc3d5170b24 -r 40f3006fba2e design_win.h --- a/design_win.h Mon Oct 30 13:08:04 2006 +0000 +++ b/design_win.h Mon Oct 30 14:57:48 2006 +0000 @@ -63,5 +63,7 @@ sigc::signal close_run(){return close_run_pr;}; void set_title(std::string); + + void set_data(double, double, int); }; #endif //DESWIN_H diff -r 9fc3d5170b24 -r 40f3006fba2e graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Mon Oct 30 13:08:04 2006 +0000 +++ b/graph_displayer_canvas.cc Mon Oct 30 14:57:48 2006 +0000 @@ -25,7 +25,7 @@ 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), zoomtrack(false), radius_size(20), edge_width(10), - iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), is_drawn(false), mytab(mainw) + was_redesigned(false), is_drawn(false), mytab(mainw) { //base event handler is move tool actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); @@ -304,7 +304,12 @@ moveNode(init.x, init.y, nodesmap[i], i); was_redesigned=true; } - + + double attraction; + double propulsation; + int iterations; + + (mytab.mapstorage).get_design_data(attraction, propulsation, iterations); //iteration counter for(int l=0;lchangeActiveMap(true, i, em[i]); } + + double attraction; + double propulsation; + int iteration; + + x("redesign-attraction", attraction); + x("redesign-propulsation", propulsation); + x("redesign-iteration", iteration); + + mapstorage->set_attraction(attraction); + mapstorage->set_propulsation(propulsation); + mapstorage->set_iteration(iteration); + + mapstorage->redesign_data_changed(); } GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms) diff -r 9fc3d5170b24 -r 40f3006fba2e gui_writer.cc --- a/gui_writer.cc Mon Oct 30 13:08:04 2006 +0000 +++ b/gui_writer.cc Mon Oct 30 14:57:48 2006 +0000 @@ -51,6 +51,16 @@ em[i]=mapstorage->active_edgemaps[i]; } x("active_edgemaps", em); + + double attraction; + double propulsation; + int iteration; + + mapstorage->get_design_data(attraction, propulsation, iteration); + + x("redesign-attraction", attraction); + x("redesign-propulsation", propulsation); + x("redesign-iteration", iteration); } GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms) diff -r 9fc3d5170b24 -r 40f3006fba2e mapstorage.cc --- a/mapstorage.cc Mon Oct 30 13:08:04 2006 +0000 +++ b/mapstorage.cc Mon Oct 30 14:57:48 2006 +0000 @@ -23,7 +23,11 @@ #include #include -MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false) +const double i_d=20; +const double a_d=0.05; +const double p_d=40000; + +MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d) { nodemap_storage["coordinates_x"] = new Graph::NodeMap(graph); coords.setXMap(*nodemap_storage["coordinates_x"]); @@ -148,7 +152,7 @@ return nml; } -MapStorage::Signal_Prop MapStorage::signal_prop_ch() +sigc::signal MapStorage::signal_prop_ch() { return signal_prop; } @@ -485,6 +489,12 @@ changeActiveMap(true, i, ""); signal_map_win.emit(true, i, ""); } + + attraction=a_d; + propulsation=p_d; + iterations=i_d; + + signal_design_win.emit(attraction, propulsation, iterations); } void MapStorage::ArrowPosReadOK() @@ -515,3 +525,30 @@ } } } + +void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p) +{ + attraction_p=attraction; + propulsation_p=propulsation; + iterations_p=iterations; +} + +void MapStorage::set_attraction(double attraction_p) +{ + attraction=attraction_p; +} + +void MapStorage::set_propulsation(double propulsation_p) +{ + propulsation=propulsation_p; +} + +void MapStorage::set_iteration(int iterations_p) +{ + iterations=iterations_p; +} + +void MapStorage::redesign_data_changed() +{ + signal_design_win.emit(attraction, propulsation, iterations); +} diff -r 9fc3d5170b24 -r 40f3006fba2e mapstorage.h --- a/mapstorage.h Mon Oct 30 13:08:04 2006 +0000 +++ b/mapstorage.h Mon Oct 30 14:57:48 2006 +0000 @@ -82,14 +82,13 @@ bool arrow_pos_read_ok; protected: - /// type of the signal emitted if the visualization of the maps might have to be updated. + /// Signal emitted on any change made on map values + + /// Signal emitted if the visualization of the maps might have to be updated. /// bool shows us whether the changed map is edge or nodemap. /// int tells us the refreshed property - typedef sigc::signal Signal_Prop; - - /// Signal emitted on any change made on map values - Signal_Prop signal_prop; + sigc::signal signal_prop; /// Signal emitted in the case of nodemap addition @@ -106,6 +105,18 @@ /// Signal emitted, when entry in \ref MapWin should be changed. sigc::signal signal_map_win; + /// Signal emitted, when entry in \ref DesignWin should be changed. + sigc::signal signal_design_win; + + ///Iteration number during graph design + int iterations; + + ///Attraction factor during graph design + double attraction; + + ///Propulsation factor during graph design + double propulsation; + public: ///Constructor of MapStorage. @@ -152,7 +163,7 @@ std::vector getNodeMapList(); ///returns \ref signal_prop to be able to connect functions to it - Signal_Prop signal_prop_ch(); + sigc::signal signal_prop_ch(); ///returns \ref signal_node_map to be able to connect functions to it sigc::signal signal_node_map_ch(){return signal_node_map;}; @@ -163,6 +174,9 @@ ///returns \ref signal_map_win to be able to connect functions to it sigc::signal signal_map_win_ch(){return signal_map_win;}; + ///returns \ref signal_design_win to be able to connect functions to it + sigc::signal signal_design_win_ch(){return signal_design_win;}; + ///Adds given map to storage. ///A name and the map itself has to be provided. @@ -261,6 +275,13 @@ void clear(); void ArrowPosReadOK(); + + void get_design_data(double &, double &, int &); + void set_attraction(double); + void set_propulsation(double); + void set_iteration(int); + + void redesign_data_changed(); }; #endif //MAPSTORAGE_H diff -r 9fc3d5170b24 -r 40f3006fba2e nbtab.cc --- a/nbtab.cc Mon Oct 30 13:08:04 2006 +0000 +++ b/nbtab.cc Mon Oct 30 14:57:48 2006 +0000 @@ -235,16 +235,18 @@ { double attraction, propulsation; int iterations; - gd_canvas->get_design_data(attraction, propulsation, iterations); + mapstorage.get_design_data(attraction, propulsation, iterations); designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this); - designwin->signal_attraction().connect(sigc::mem_fun(*this, &NoteBookTab::attraction_ch)); - designwin->signal_propulsation().connect(sigc::mem_fun(*this, &NoteBookTab::propulsation_ch)); - designwin->signal_iteration().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::set_iteration)); + designwin->signal_attraction().connect(sigc::mem_fun(mapstorage, &MapStorage::set_attraction)); + designwin->signal_propulsation().connect(sigc::mem_fun(mapstorage, &MapStorage::set_propulsation)); + designwin->signal_iteration().connect(sigc::mem_fun(mapstorage, &MapStorage::set_iteration)); designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph)); designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin)); + mapst2designwin=mapstorage.signal_design_win_ch().connect(sigc::mem_fun(*designwin, &DesignWin::set_data)); + designwin->show(); designwinexists=true; } @@ -262,6 +264,7 @@ if(e->type==GDK_DELETE) { designwinexists=false; + mapst2designwin.disconnect(); delete designwin; } } @@ -286,21 +289,6 @@ gd_canvas->reDesignGraph(); } -void NoteBookTab::attraction_ch(double v) -{ - gd_canvas->set_attraction(v); -} - -void NoteBookTab::propulsation_ch(double v) -{ - gd_canvas->set_propulsation(v); -} - -void NoteBookTab::iteration_ch(int v) -{ - gd_canvas->set_iteration(v); -} - void NoteBookTab::active_maps_needed() { mapstorage.broadcastActiveMaps(); diff -r 9fc3d5170b24 -r 40f3006fba2e nbtab.h --- a/nbtab.h Mon Oct 30 13:08:04 2006 +0000 +++ b/nbtab.h Mon Oct 30 14:57:48 2006 +0000 @@ -202,15 +202,6 @@ ///Let the graph redesign, based on gravity and edge elasticity. void reDesignGraph(); - ///Indicates that attraction factor is changed - void attraction_ch(double); - - ///Indicates that propulsation factor is changed - void propulsation_ch(double); - - ///Indicates that iteration number of redesign is changed - void iteration_ch(int); - ///\ref MapWin calls this function when it updates the maplist in comboboxes. void active_maps_needed(); @@ -220,6 +211,12 @@ ///If \ref MapWin is closed this connection has to be disconnected, ///therefore we have to store it. sigc::connection mapst2mapwin; + + ///Signal connection from \ref MapStorage to \ref DesignWin + + ///If \ref DesignWin is closed this connection has to be disconnected, + ///therefore we have to store it. + sigc::connection mapst2designwin; }; #endif //NBTAB_H