# HG changeset patch # User hegyi # Date 1161782484 0 # Node ID fc1e478697d35ee4747765a62239357fe5f5aff8 # Parent ffab98e94909a7d400f9ca12dce90d844219d5e2 Currently visualized map can be saved and loaded from file. diff -r ffab98e94909 -r fc1e478697d3 design_win.cc --- a/design_win.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/design_win.cc Wed Oct 25 13:21:24 2006 +0000 @@ -9,10 +9,12 @@ return true; } -DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v) +DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v, NoteBookTab & mw):mytab(mw) { set_title(title); + mytab.signal_title_ch().connect(sigc::mem_fun(*this, &DesignWin::set_title)); + signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed)); Gtk::VBox * vbox=new Gtk::VBox(); @@ -64,3 +66,8 @@ { signal_iteration_ch.emit((int)iteration->get_value()); } + +void DesignWin::set_title(std::string tabname) +{ + Gtk::Window::set_title("Design Setup - "+tabname); +} diff -r ffab98e94909 -r fc1e478697d3 design_win.h --- a/design_win.h Tue Oct 24 07:31:31 2006 +0000 +++ b/design_win.h Wed Oct 25 13:21:24 2006 +0000 @@ -3,13 +3,19 @@ #ifndef DESWIN_H #define DESWIN_H +class DesignWin; + #include +#include #include #include class DesignWin : public Gtk::Window { private: + ///\ref NoteBookTab to that the \ref MapWin belongs to. + NoteBookTab & mytab; + Gtk::SpinButton * attraction; Gtk::SpinButton * propulsation; Gtk::SpinButton * iteration; @@ -33,11 +39,13 @@ ///Constructor ///It builds the window. - DesignWin(const std::string&, double, double, int); + DesignWin(const std::string&, double, double, int, NoteBookTab & mw); sigc::signal signal_attraction(){return signal_attraction_ch;}; sigc::signal signal_propulsation(){return signal_propulsation_ch;}; sigc::signal signal_iteration(){return signal_iteration_ch;}; sigc::signal close_run(){return close_run_pr;}; + + void set_title(std::string); }; #endif //DESWIN_H diff -r ffab98e94909 -r fc1e478697d3 graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/graph_displayer_canvas.cc Wed Oct 25 13:21:24 2006 +0000 @@ -7,7 +7,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), mytab(mainw) + iterations(20), attraction(0.05), propulsation(40000), 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); @@ -63,94 +63,95 @@ void GraphDisplayerCanvas::propertyUpdate(Node node, int prop) { - //dummy=dummy; - std::string mapname=mytab.getActiveNodeMap(prop); - if(mapname!="") + if(is_drawn) { - if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) ) + if(mapname!="") { + if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) ) + { + switch(prop) + { + case N_RADIUS: + changeNodeRadius(mapname, node); + break; + case N_COLOR: + changeNodeColor(mapname, node); + break; + case N_TEXT: + changeNodeText(mapname, node); + break; + default: + std::cerr<<"Error\n"; + } + } + } + else //mapname=="" + { + Node node=INVALID; switch(prop) { case N_RADIUS: - changeNodeRadius(mapname, node); + resetNodeRadius(node); break; case N_COLOR: - changeNodeColor(mapname, node); + resetNodeColor(node); break; case N_TEXT: - changeNodeText(mapname, node); + resetNodeText(node); break; default: std::cerr<<"Error\n"; } } } - else //mapname=="" - { - Node node=INVALID; - switch(prop) - { - case N_RADIUS: - resetNodeRadius(node); - break; - case N_COLOR: - resetNodeColor(node); - break; - case N_TEXT: - resetNodeText(node); - break; - default: - std::cerr<<"Error\n"; - } - } - } void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop) { - //dummy=dummy; - std::string mapname=mytab.getActiveEdgeMap(prop); - if(mapname!="") + if(is_drawn) { - if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) ) + if(mapname!="") + { + if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) ) + { + switch(prop) + { + case E_WIDTH: + changeEdgeWidth(mapname, edge); + break; + case E_COLOR: + changeEdgeColor(mapname, edge); + break; + case E_TEXT: + changeEdgeText(mapname, edge); + break; + default: + std::cerr<<"Error\n"; + } + } + } + else //mapname=="" { switch(prop) { case E_WIDTH: - changeEdgeWidth(mapname, edge); + resetEdgeWidth(edge); break; case E_COLOR: - changeEdgeColor(mapname, edge); + resetEdgeColor(edge); break; case E_TEXT: - changeEdgeText(mapname, edge); + resetEdgeText(edge); break; default: std::cerr<<"Error\n"; } } } - else //mapname=="" - { - switch(prop) - { - case E_WIDTH: - resetEdgeWidth(edge); - break; - case E_COLOR: - resetEdgeColor(edge); - break; - case E_TEXT: - resetEdgeText(edge); - break; - default: - std::cerr<<"Error\n"; - } - } } void GraphDisplayerCanvas::drawGraph() @@ -207,6 +208,21 @@ nodetextmap[i]->raise_to_top(); } + is_drawn=true; + + //upon drawing graph + //properties have to + //be set in as well + for(int i=0;iarrow_pos.set(e, m[edgeid]); } mapstorage->ArrowPosReadOK(); + + std::map nm; + x("active_nodemaps", nm); + + for(int i=0;ichangeActiveMap(false, i, nm[i]); + } + + std::map em; + x("active_edgemaps", em); + for(int i=0;ichangeActiveMap(true, i, em[i]); + } } GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms) diff -r ffab98e94909 -r fc1e478697d3 gui_writer.cc --- a/gui_writer.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/gui_writer.cc Wed Oct 25 13:21:24 2006 +0000 @@ -19,6 +19,20 @@ m[edgeid] = mapstorage->arrow_pos[e]; } x("arrow_pos", m); + + std::map nm; + for(int i=0;iactive_nodemaps[i]; + } + x("active_nodemaps", nm); + + std::map em; + for(int i=0;iactive_edgemaps[i]; + } + x("active_edgemaps", em); } GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms) diff -r ffab98e94909 -r fc1e478697d3 map_win.cc --- a/map_win.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/map_win.cc Wed Oct 25 13:21:24 2006 +0000 @@ -20,6 +20,8 @@ signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed)); + mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title)); + e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM]; table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false); @@ -90,6 +92,8 @@ { n_combo_array[i]->update_list(nml); } + + mytab.active_maps_needed(); } void MapWin::registerNewEdgeMap(std::string newmapname) @@ -116,3 +120,20 @@ mytab.closeMapWin(); return true; } + +void MapWin::changeEntry(bool isitedge, int prop, std::string mapname) +{ + if(isitedge) + { + e_combo_array[prop]->set_active_text(mapname); + } + else + { + n_combo_array[prop]->set_active_text(mapname); + } +} + +void MapWin::set_title(std::string tabname) +{ + Gtk::Window::set_title("Map Setup - "+tabname); +} diff -r ffab98e94909 -r fc1e478697d3 map_win.h --- a/map_win.h Tue Oct 24 07:31:31 2006 +0000 +++ b/map_win.h Wed Oct 25 13:21:24 2006 +0000 @@ -112,6 +112,10 @@ ///\param eml edge map list ///\param nml node map list void update(std::vector eml, std::vector nml); + + void changeEntry(bool, int, std::string); + + void set_title(std::string); }; #endif //MAP_WIN_H diff -r ffab98e94909 -r fc1e478697d3 mapselector.cc --- a/mapselector.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/mapselector.cc Wed Oct 25 13:21:24 2006 +0000 @@ -67,14 +67,17 @@ { int prev_act=cbt.get_active_row_number(); cbt.clear(); + cbt_content.clear(); std::vector< std::string >::iterator emsi=ml.begin(); for(;emsi!=ml.end();emsi++) { cbt.append_text(*emsi); + cbt_content.push_back(*emsi); } if(def) { cbt.prepend_text("Default values"); + cbt_content.push_back("Default values"); } if(prev_act!=-1) { @@ -116,12 +119,21 @@ void MapSelector::set_active_text(Glib::ustring text) { - cbt.set_active_text(text); + if(text.compare("")) + { + cbt.set_active_text(text); + } + else + { + cbt.set_active_text("Default values"); + } } void MapSelector::append_text(Glib::ustring text) { cbt.append_text(text); + cbt_content.push_back(text); + if(set_new_map) { set_active_text(text); diff -r ffab98e94909 -r fc1e478697d3 mapselector.h --- a/mapselector.h Tue Oct 24 07:31:31 2006 +0000 +++ b/mapselector.h Wed Oct 25 13:21:24 2006 +0000 @@ -61,6 +61,8 @@ ///Names in it are selectable. Gtk::ComboBoxText cbt; + std::vector cbt_content; + ///New button. ///By pressing it diff -r ffab98e94909 -r fc1e478697d3 mapstorage.cc --- a/mapstorage.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/mapstorage.cc Wed Oct 25 13:21:24 2006 +0000 @@ -52,7 +52,6 @@ int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap *nodemap, double default_value) { - std::cout << default_value << std::endl; if( nodemap_storage.find(name) == nodemap_storage.end() ) { nodemap_storage[name]=nodemap; @@ -79,6 +78,20 @@ signal_prop.emit(itisedge, prop); } +void MapStorage::broadcastActiveMaps() +{ + for(int i=0;i signal_edge_map; + /// Signal emitted, when entry in \ref MapWin should be changed. + sigc::signal signal_map_win; + public: ///Constructor of MapStorage. @@ -109,6 +112,9 @@ ///\param mapname the visible map void changeActiveMap(bool itisedge , int prop , std::string mapname); + ///Emits signals that let change the active maps in \ref MapWin. + void broadcastActiveMaps(); + /// Returns the active edgemap shown by a visualization property. /// \param prop is the property @@ -136,6 +142,9 @@ ///returns \ref signal_edge_map to be able to connect functions to it sigc::signal signal_edge_map_ch(){return signal_edge_map;}; + ///returns \ref signal_map_win to be able to connect functions to it + sigc::signal signal_map_win_ch(){return signal_map_win;}; + ///Adds given map to storage. ///A name and the map itself has to be provided. diff -r ffab98e94909 -r fc1e478697d3 nbtab.cc --- a/nbtab.cc Tue Oct 24 07:31:31 2006 +0000 +++ b/nbtab.cc Wed Oct 25 13:21:24 2006 +0000 @@ -202,6 +202,7 @@ if(!mapwinexists) { mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); + mapst2mapwin=mapstorage.signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry)); mapwin->show(); mapwinexists=true; } @@ -214,7 +215,7 @@ double attraction, propulsation; int iterations; gd_canvas->get_design_data(attraction, propulsation, iterations); - designwin=new DesignWin("Design Setup - "+name, 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)); @@ -230,6 +231,7 @@ void NoteBookTab::closeMapWin() { + mapst2mapwin.disconnect(); mapwinexists=false; delete mapwin; } @@ -278,3 +280,7 @@ gd_canvas->set_iteration(v); } +void NoteBookTab::active_maps_needed() +{ + mapstorage.broadcastActiveMaps(); +} diff -r ffab98e94909 -r fc1e478697d3 nbtab.h --- a/nbtab.h Tue Oct 24 07:31:31 2006 +0000 +++ b/nbtab.h Wed Oct 25 13:21:24 2006 +0000 @@ -183,13 +183,27 @@ ///Gets node representation settings void getView(bool &, bool &, double&, double&); + ///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(); + +private: + ///Signal connection from \ref MapStorage to \ref MapWin + + ///If \ref MapWin is closed this connection has to be disconnected, + ///therefore we have to store it. + sigc::connection mapst2mapwin; }; #endif //NBTAB_H