# HG changeset patch # User hegyi # Date 1136464209 0 # Node ID 409a31271efd209a88dd96ae37421bc1ac73f794 # Parent bed340c4f960189fb278aa2ccb3f7e8e7eea259e Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox. diff -r bed340c4f960 -r 409a31271efd gui/algobox.cc --- a/gui/algobox.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/algobox.cc Thu Jan 05 12:30:09 2006 +0000 @@ -3,12 +3,12 @@ enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes; enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges; -AlgoBox::AlgoBox(std::vector tabnames, std::vector nodemapnames, std::vector edgemapnames) +AlgoBox::AlgoBox(std::vector tabnames) { - init(tabnames, nodemapnames, edgemapnames); + init(tabnames); } -void AlgoBox::init(std::vector tabnames, std::vector nodemapnames, std::vector edgemapnames) +void AlgoBox::init(std::vector tabnames) { set_spacing(5); @@ -18,11 +18,8 @@ tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change)); pack_start(tabcbt); - build_box(); - update_maplist(nodemapnames, edgemapnames); - show_all_children(); }; @@ -52,7 +49,7 @@ } else if(actptr>0) //so there is item in the list { - cbt.set_active(0); + //cbt.set_active(0); } } @@ -62,8 +59,18 @@ emit_tab_change(); } -void AlgoBox::update_maplist( std::vector< std::string > nml, std::vector< std::string > eml ) +void AlgoBox::update_maplist( void * ms) { + mapstorage=(MapStorage *)ms; + std::vector nml; + std::vector eml; + if(mapstorage!=NULL) + { + mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed)); + mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed)); + nml=mapstorage->getNodeMapList(); + eml=mapstorage->getNodeMapList(); + } for(int i=0;i<(int)nodemapcbts.size();i++) { update_cbt(nml, *(nodemapcbts[i])); @@ -74,6 +81,22 @@ } } +void AlgoBox::nodemaplist_changed(std::string newmap) +{ + for(int i=0;i<(int)nodemapcbts.size();i++) + { + (nodemapcbts[i])->append_text(newmap); + } +} + +void AlgoBox::edgemaplist_changed(std::string newmap) +{ + for(int i=0;i<(int)edgemapcbts.size();i++) + { + (edgemapcbts[i])->append_text(newmap); + } +} + void AlgoBox::run() { std::cout << "Start algorithm." << std::endl; @@ -136,5 +159,14 @@ void AlgoBox::emit_tab_change() { - signal_maplist_need.emit(tabcbt.get_active_text()); + std::string active_tab=tabcbt.get_active_text(); + if(active_tab!="") + { + signal_maplist_need.emit(active_tab); + } + else + { + std::vector empty_vector; + update_maplist(NULL); + } } diff -r bed340c4f960 -r 409a31271efd gui/algobox.h --- a/gui/algobox.h Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/algobox.h Thu Jan 05 12:30:09 2006 +0000 @@ -6,6 +6,7 @@ class AlgoBox; #include +#include #include #include @@ -19,18 +20,23 @@ Gtk::Label * label; std::vector nodemapcbts; std::vector edgemapcbts; - + + MapStorage * mapstorage; + public: AlgoBox(){}; - AlgoBox(std::vector, std::vector, std::vector); + AlgoBox(std::vector); - virtual void init(std::vector, std::vector, std::vector); + virtual void init(std::vector); sigc::signal signal_maplist_needed(); void emit_tab_change(); void update_tablist( std::vector< std::string > tl ); - void update_maplist( std::vector< std::string >, std::vector< std::string >); + void update_maplist( void * ); + + void nodemaplist_changed(std::string); + void edgemaplist_changed(std::string); void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText &); diff -r bed340c4f960 -r 409a31271efd gui/algowin.cc --- a/gui/algowin.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/algowin.cc Thu Jan 05 12:30:09 2006 +0000 @@ -20,7 +20,7 @@ return true; } -AlgoWin::AlgoWin(int algoid, std::vector tabnames, std::vector nodemapnames,std::vector edgemapnames) +AlgoWin::AlgoWin(int algoid, std::vector tabnames) { signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed)); @@ -32,11 +32,11 @@ switch(algoid) { case 0: - ab=new AlgoBox(tabnames, nodemapnames, edgemapnames); + ab=new AlgoBox(tabnames); set_title("Algo Win Demo"); break; case 1: - ab=new KruskalBox(tabnames, nodemapnames, edgemapnames); + ab=new KruskalBox(tabnames); set_title("Kruskal Algorithm"); break; default: @@ -71,9 +71,9 @@ ab->update_tablist(tabnames); } -void AlgoWin::update_maplist(std::vector nodemapnames, std::vector edgemapnames) +void AlgoWin::update_maplist(void * mapstorage) { - ab->update_maplist(nodemapnames, edgemapnames); + ab->update_maplist(mapstorage); } void AlgoWin::on_hide() diff -r bed340c4f960 -r 409a31271efd gui/algowin.h --- a/gui/algowin.h Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/algowin.h Thu Jan 05 12:30:09 2006 +0000 @@ -31,10 +31,10 @@ void emit_tab_change(std::string); - AlgoWin(int, std::vector, std::vector, std::vector); + AlgoWin(int, std::vector); void update_tablist(std::vector tabnames); - void update_maplist(std::vector, std::vector); + void update_maplist( void *); void on_hide(); }; diff -r bed340c4f960 -r 409a31271efd gui/kruskalbox.cc --- a/gui/kruskalbox.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/kruskalbox.cc Thu Jan 05 12:30:09 2006 +0000 @@ -1,12 +1,13 @@ #include -KruskalBox::KruskalBox(std::vector t, std::vector nm, std::vector em):AlgoBox() +KruskalBox::KruskalBox(std::vector t):AlgoBox() { - init(t, nm, em); + init(t); } void KruskalBox::run() { + std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl; } diff -r bed340c4f960 -r 409a31271efd gui/kruskalbox.h --- a/gui/kruskalbox.h Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/kruskalbox.h Thu Jan 05 12:30:09 2006 +0000 @@ -14,7 +14,7 @@ class KruskalBox : public AlgoBox { public: - KruskalBox(std::vector t, std::vector nm, std::vector em); + KruskalBox(std::vector t); void run(); diff -r bed340c4f960 -r 409a31271efd gui/main_win.cc --- a/gui/main_win.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/main_win.cc Thu Jan 05 12:30:09 2006 +0000 @@ -409,27 +409,13 @@ void MainWin::createAlgoWin(int algoid) { - AlgoWin * aw=new AlgoWin(algoid, tabnames, tabs[0]->mapstorage.getNodeMapList(),tabs[0]->mapstorage.getEdgeMapList()); + AlgoWin * aw=new AlgoWin(algoid, tabnames); aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps)); aws.insert(aw); aw->show(); } -void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname) -{ - int i=0; - for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++) - { - } - awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList()); -} - -void MainWin::deRegisterAlgoWin(AlgoWin * awp) -{ - aws.erase(awp); -} - void MainWin::updateAlgoWinTabs() { std::set< AlgoWin* >::iterator awsi=aws.begin(); @@ -439,6 +425,21 @@ } } +void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname) +{ + int i=0; + for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++) + { + } + //awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList()); + awp->update_maplist(&(tabs[i]->mapstorage)); +} + +void MainWin::deRegisterAlgoWin(AlgoWin * awp) +{ + aws.erase(awp); +} + void MainWin::changeEditorialTool(int tool) { active_tool=tool; diff -r bed340c4f960 -r 409a31271efd gui/mapstorage.cc --- a/gui/mapstorage.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/mapstorage.cc Thu Jan 05 12:30:09 2006 +0000 @@ -58,6 +58,9 @@ nodemap_storage[name]=nodemap; // set the maps default value nodemap_default[name] = default_value; + + //announce changement in maps + signal_node_map.emit(name); return 0; } return 1; @@ -126,6 +129,9 @@ edgemap_storage[name]=edgemap; // set the maps default value edgemap_default[name] = default_value; + + //announce changement in maps + signal_edge_map.emit(name); return 0; } return 1; diff -r bed340c4f960 -r 409a31271efd gui/mapstorage.h --- a/gui/mapstorage.h Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/mapstorage.h Thu Jan 05 12:30:09 2006 +0000 @@ -60,6 +60,8 @@ protected: typedef sigc::signal Signal_Prop; Signal_Prop signal_prop; + sigc::signal signal_node_map; + sigc::signal signal_edge_map; public: ///Constructor of MapStorage. Expects the Graph of @@ -82,6 +84,9 @@ Signal_Prop signal_prop_ch(); + sigc::signal signal_node_map_ch(){return signal_node_map;}; + sigc::signal signal_edge_map_ch(){return signal_edge_map;}; + ///Adds given map to storage. A name and the map itself has to be provided. ///\param name is the name of map ///\nodemap is the pointer of the given nodemap diff -r bed340c4f960 -r 409a31271efd gui/nbtab.cc --- a/gui/nbtab.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/nbtab.cc Thu Jan 05 12:30:09 2006 +0000 @@ -7,6 +7,8 @@ //connecting signals - controller character mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange)); + mapstorage.signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap)); + mapstorage.signal_edge_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewEdgeMap)); show_all_children(); show(); } diff -r bed340c4f960 -r 409a31271efd gui/new_map_win.cc --- a/gui/new_map_win.cc Thu Jan 05 01:54:24 2006 +0000 +++ b/gui/new_map_win.cc Thu Jan 05 12:30:09 2006 +0000 @@ -159,7 +159,8 @@ } //add it to the list of the displayable maps - mytab.registerNewEdgeMap(mapname); + //furthermore it is done by signals + //mytab.registerNewEdgeMap(mapname); //display it //gdc.changeEdgeText(mapname); @@ -242,7 +243,8 @@ } //add it to the list of the displayable maps - mytab.registerNewNodeMap(mapname); + //furthermore it is done by signals + //mytab.registerNewNodeMap(mapname); //display it //gdc.changeNodeText(mapname);