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.
1.1 --- a/gui/algobox.cc Thu Jan 05 01:54:24 2006 +0000
1.2 +++ b/gui/algobox.cc Thu Jan 05 12:30:09 2006 +0000
1.3 @@ -3,12 +3,12 @@
1.4 enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes;
1.5 enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges;
1.6
1.7 -AlgoBox::AlgoBox(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
1.8 +AlgoBox::AlgoBox(std::vector<std::string> tabnames)
1.9 {
1.10 - init(tabnames, nodemapnames, edgemapnames);
1.11 + init(tabnames);
1.12 }
1.13
1.14 -void AlgoBox::init(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
1.15 +void AlgoBox::init(std::vector<std::string> tabnames)
1.16 {
1.17 set_spacing(5);
1.18
1.19 @@ -18,11 +18,8 @@
1.20 tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change));
1.21
1.22 pack_start(tabcbt);
1.23 -
1.24 build_box();
1.25
1.26 - update_maplist(nodemapnames, edgemapnames);
1.27 -
1.28 show_all_children();
1.29 };
1.30
1.31 @@ -52,7 +49,7 @@
1.32 }
1.33 else if(actptr>0) //so there is item in the list
1.34 {
1.35 - cbt.set_active(0);
1.36 + //cbt.set_active(0);
1.37 }
1.38 }
1.39
1.40 @@ -62,8 +59,18 @@
1.41 emit_tab_change();
1.42 }
1.43
1.44 -void AlgoBox::update_maplist( std::vector< std::string > nml, std::vector< std::string > eml )
1.45 +void AlgoBox::update_maplist( void * ms)
1.46 {
1.47 + mapstorage=(MapStorage *)ms;
1.48 + std::vector<std::string> nml;
1.49 + std::vector<std::string> eml;
1.50 + if(mapstorage!=NULL)
1.51 + {
1.52 + mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
1.53 + mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed));
1.54 + nml=mapstorage->getNodeMapList();
1.55 + eml=mapstorage->getNodeMapList();
1.56 + }
1.57 for(int i=0;i<(int)nodemapcbts.size();i++)
1.58 {
1.59 update_cbt(nml, *(nodemapcbts[i]));
1.60 @@ -74,6 +81,22 @@
1.61 }
1.62 }
1.63
1.64 +void AlgoBox::nodemaplist_changed(std::string newmap)
1.65 +{
1.66 + for(int i=0;i<(int)nodemapcbts.size();i++)
1.67 + {
1.68 + (nodemapcbts[i])->append_text(newmap);
1.69 + }
1.70 +}
1.71 +
1.72 +void AlgoBox::edgemaplist_changed(std::string newmap)
1.73 +{
1.74 + for(int i=0;i<(int)edgemapcbts.size();i++)
1.75 + {
1.76 + (edgemapcbts[i])->append_text(newmap);
1.77 + }
1.78 +}
1.79 +
1.80 void AlgoBox::run()
1.81 {
1.82 std::cout << "Start algorithm." << std::endl;
1.83 @@ -136,5 +159,14 @@
1.84
1.85 void AlgoBox::emit_tab_change()
1.86 {
1.87 - signal_maplist_need.emit(tabcbt.get_active_text());
1.88 + std::string active_tab=tabcbt.get_active_text();
1.89 + if(active_tab!="")
1.90 + {
1.91 + signal_maplist_need.emit(active_tab);
1.92 + }
1.93 + else
1.94 + {
1.95 + std::vector<std::string> empty_vector;
1.96 + update_maplist(NULL);
1.97 + }
1.98 }
2.1 --- a/gui/algobox.h Thu Jan 05 01:54:24 2006 +0000
2.2 +++ b/gui/algobox.h Thu Jan 05 12:30:09 2006 +0000
2.3 @@ -6,6 +6,7 @@
2.4 class AlgoBox;
2.5
2.6 #include <all_include.h>
2.7 +#include <mapstorage.h>
2.8 #include <libgnomecanvasmm.h>
2.9 #include <libgnomecanvasmm/polygon.h>
2.10
2.11 @@ -19,18 +20,23 @@
2.12 Gtk::Label * label;
2.13 std::vector<Gtk::ComboBoxText *> nodemapcbts;
2.14 std::vector<Gtk::ComboBoxText *> edgemapcbts;
2.15 -
2.16 +
2.17 + MapStorage * mapstorage;
2.18 +
2.19 public:
2.20 AlgoBox(){};
2.21 - AlgoBox(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
2.22 + AlgoBox(std::vector<std::string>);
2.23
2.24 - virtual void init(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
2.25 + virtual void init(std::vector<std::string>);
2.26
2.27 sigc::signal<void, std::string> signal_maplist_needed();
2.28 void emit_tab_change();
2.29
2.30 void update_tablist( std::vector< std::string > tl );
2.31 - void update_maplist( std::vector< std::string >, std::vector< std::string >);
2.32 + void update_maplist( void * );
2.33 +
2.34 + void nodemaplist_changed(std::string);
2.35 + void edgemaplist_changed(std::string);
2.36
2.37 void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText &);
2.38
3.1 --- a/gui/algowin.cc Thu Jan 05 01:54:24 2006 +0000
3.2 +++ b/gui/algowin.cc Thu Jan 05 12:30:09 2006 +0000
3.3 @@ -20,7 +20,7 @@
3.4 return true;
3.5 }
3.6
3.7 -AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames, std::vector<std::string> nodemapnames,std::vector<std::string> edgemapnames)
3.8 +AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
3.9 {
3.10 signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
3.11
3.12 @@ -32,11 +32,11 @@
3.13 switch(algoid)
3.14 {
3.15 case 0:
3.16 - ab=new AlgoBox(tabnames, nodemapnames, edgemapnames);
3.17 + ab=new AlgoBox(tabnames);
3.18 set_title("Algo Win Demo");
3.19 break;
3.20 case 1:
3.21 - ab=new KruskalBox(tabnames, nodemapnames, edgemapnames);
3.22 + ab=new KruskalBox(tabnames);
3.23 set_title("Kruskal Algorithm");
3.24 break;
3.25 default:
3.26 @@ -71,9 +71,9 @@
3.27 ab->update_tablist(tabnames);
3.28 }
3.29
3.30 -void AlgoWin::update_maplist(std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
3.31 +void AlgoWin::update_maplist(void * mapstorage)
3.32 {
3.33 - ab->update_maplist(nodemapnames, edgemapnames);
3.34 + ab->update_maplist(mapstorage);
3.35 }
3.36
3.37 void AlgoWin::on_hide()
4.1 --- a/gui/algowin.h Thu Jan 05 01:54:24 2006 +0000
4.2 +++ b/gui/algowin.h Thu Jan 05 12:30:09 2006 +0000
4.3 @@ -31,10 +31,10 @@
4.4
4.5 void emit_tab_change(std::string);
4.6
4.7 - AlgoWin(int, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
4.8 + AlgoWin(int, std::vector<std::string>);
4.9
4.10 void update_tablist(std::vector<std::string> tabnames);
4.11 - void update_maplist(std::vector<std::string>, std::vector<std::string>);
4.12 + void update_maplist( void *);
4.13
4.14 void on_hide();
4.15 };
5.1 --- a/gui/kruskalbox.cc Thu Jan 05 01:54:24 2006 +0000
5.2 +++ b/gui/kruskalbox.cc Thu Jan 05 12:30:09 2006 +0000
5.3 @@ -1,12 +1,13 @@
5.4 #include <kruskalbox.h>
5.5
5.6 -KruskalBox::KruskalBox(std::vector<std::string> t, std::vector<std::string> nm, std::vector<std::string> em):AlgoBox()
5.7 +KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
5.8 {
5.9 - init(t, nm, em);
5.10 + init(t);
5.11 }
5.12
5.13 void KruskalBox::run()
5.14 {
5.15 +
5.16 std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl;
5.17 }
5.18
6.1 --- a/gui/kruskalbox.h Thu Jan 05 01:54:24 2006 +0000
6.2 +++ b/gui/kruskalbox.h Thu Jan 05 12:30:09 2006 +0000
6.3 @@ -14,7 +14,7 @@
6.4 class KruskalBox : public AlgoBox
6.5 {
6.6 public:
6.7 - KruskalBox(std::vector<std::string> t, std::vector<std::string> nm, std::vector<std::string> em);
6.8 + KruskalBox(std::vector<std::string> t);
6.9
6.10 void run();
6.11
7.1 --- a/gui/main_win.cc Thu Jan 05 01:54:24 2006 +0000
7.2 +++ b/gui/main_win.cc Thu Jan 05 12:30:09 2006 +0000
7.3 @@ -409,27 +409,13 @@
7.4
7.5 void MainWin::createAlgoWin(int algoid)
7.6 {
7.7 - AlgoWin * aw=new AlgoWin(algoid, tabnames, tabs[0]->mapstorage.getNodeMapList(),tabs[0]->mapstorage.getEdgeMapList());
7.8 + AlgoWin * aw=new AlgoWin(algoid, tabnames);
7.9 aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
7.10 aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
7.11 aws.insert(aw);
7.12 aw->show();
7.13 }
7.14
7.15 -void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
7.16 -{
7.17 - int i=0;
7.18 - for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
7.19 - {
7.20 - }
7.21 - awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
7.22 -}
7.23 -
7.24 -void MainWin::deRegisterAlgoWin(AlgoWin * awp)
7.25 -{
7.26 - aws.erase(awp);
7.27 -}
7.28 -
7.29 void MainWin::updateAlgoWinTabs()
7.30 {
7.31 std::set< AlgoWin* >::iterator awsi=aws.begin();
7.32 @@ -439,6 +425,21 @@
7.33 }
7.34 }
7.35
7.36 +void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
7.37 +{
7.38 + int i=0;
7.39 + for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
7.40 + {
7.41 + }
7.42 + //awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
7.43 + awp->update_maplist(&(tabs[i]->mapstorage));
7.44 +}
7.45 +
7.46 +void MainWin::deRegisterAlgoWin(AlgoWin * awp)
7.47 +{
7.48 + aws.erase(awp);
7.49 +}
7.50 +
7.51 void MainWin::changeEditorialTool(int tool)
7.52 {
7.53 active_tool=tool;
8.1 --- a/gui/mapstorage.cc Thu Jan 05 01:54:24 2006 +0000
8.2 +++ b/gui/mapstorage.cc Thu Jan 05 12:30:09 2006 +0000
8.3 @@ -58,6 +58,9 @@
8.4 nodemap_storage[name]=nodemap;
8.5 // set the maps default value
8.6 nodemap_default[name] = default_value;
8.7 +
8.8 + //announce changement in maps
8.9 + signal_node_map.emit(name);
8.10 return 0;
8.11 }
8.12 return 1;
8.13 @@ -126,6 +129,9 @@
8.14 edgemap_storage[name]=edgemap;
8.15 // set the maps default value
8.16 edgemap_default[name] = default_value;
8.17 +
8.18 + //announce changement in maps
8.19 + signal_edge_map.emit(name);
8.20 return 0;
8.21 }
8.22 return 1;
9.1 --- a/gui/mapstorage.h Thu Jan 05 01:54:24 2006 +0000
9.2 +++ b/gui/mapstorage.h Thu Jan 05 12:30:09 2006 +0000
9.3 @@ -60,6 +60,8 @@
9.4 protected:
9.5 typedef sigc::signal<void, bool, int> Signal_Prop;
9.6 Signal_Prop signal_prop;
9.7 + sigc::signal<void, std::string> signal_node_map;
9.8 + sigc::signal<void, std::string> signal_edge_map;
9.9
9.10 public:
9.11 ///Constructor of MapStorage. Expects the Graph of
9.12 @@ -82,6 +84,9 @@
9.13
9.14 Signal_Prop signal_prop_ch();
9.15
9.16 + sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
9.17 + sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
9.18 +
9.19 ///Adds given map to storage. A name and the map itself has to be provided.
9.20 ///\param name is the name of map
9.21 ///\nodemap is the pointer of the given nodemap
10.1 --- a/gui/nbtab.cc Thu Jan 05 01:54:24 2006 +0000
10.2 +++ b/gui/nbtab.cc Thu Jan 05 12:30:09 2006 +0000
10.3 @@ -7,6 +7,8 @@
10.4
10.5 //connecting signals - controller character
10.6 mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
10.7 + mapstorage.signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap));
10.8 + mapstorage.signal_edge_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewEdgeMap));
10.9 show_all_children();
10.10 show();
10.11 }
11.1 --- a/gui/new_map_win.cc Thu Jan 05 01:54:24 2006 +0000
11.2 +++ b/gui/new_map_win.cc Thu Jan 05 12:30:09 2006 +0000
11.3 @@ -159,7 +159,8 @@
11.4 }
11.5
11.6 //add it to the list of the displayable maps
11.7 - mytab.registerNewEdgeMap(mapname);
11.8 + //furthermore it is done by signals
11.9 + //mytab.registerNewEdgeMap(mapname);
11.10
11.11 //display it
11.12 //gdc.changeEdgeText(mapname);
11.13 @@ -242,7 +243,8 @@
11.14 }
11.15
11.16 //add it to the list of the displayable maps
11.17 - mytab.registerNewNodeMap(mapname);
11.18 + //furthermore it is done by signals
11.19 + //mytab.registerNewNodeMap(mapname);
11.20
11.21 //display it
11.22 //gdc.changeNodeText(mapname);