3 enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes;
4 enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges;
6 AlgoBox::AlgoBox(std::vector<std::string> tabnames)
11 void AlgoBox::init(std::vector<std::string> tabnames)
15 update_tablist(tabnames);
17 //if active tab is changed, the map names in cbt/s have to be updated
18 tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change));
26 void AlgoBox::update_cbt(std::vector< std::string > stringlist, Gtk::ComboBoxText & cbt)
28 std::string actname=cbt.get_active_text();
34 std::vector< std::string >::iterator emsi=stringlist.begin();
35 for(;emsi!=stringlist.end();emsi++)
42 cbt.append_text(*emsi);
48 cbt.set_active(prev_act);
50 else if(actptr>0) //so there is item in the list
56 void AlgoBox::update_tablist( std::vector< std::string > tl )
58 update_cbt(tl, tabcbt);
62 void AlgoBox::update_maplist(MapStorage * ms)
65 std::vector<std::string> nml;
66 std::vector<std::string> eml;
69 mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
70 mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed));
71 nml=mapstorage->getNodeMapList();
72 eml=mapstorage->getEdgeMapList();
74 for(int i=0;i<(int)nodemapcbts.size();i++)
76 (nodemapcbts[i])->update_list(nml);
77 //update_cbt(nml, *(nodemapcbts[i]));
79 for(int i=0;i<(int)edgemapcbts.size();i++)
81 (edgemapcbts[i])->update_list(eml);
82 //update_cbt(eml, *(edgemapcbts[i]));
86 void AlgoBox::nodemaplist_changed(std::string newmap)
88 for(int i=0;i<(int)nodemapcbts.size();i++)
90 (nodemapcbts[i])->append_text(newmap);
94 void AlgoBox::edgemaplist_changed(std::string newmap)
96 for(int i=0;i<(int)edgemapcbts.size();i++)
98 (edgemapcbts[i])->append_text(newmap);
104 std::cout << "Start algorithm." << std::endl;
107 void AlgoBox::build_box()
109 pack_start(*(new Gtk::HSeparator()));
111 Gtk::Label * label=new Gtk::Label("Specific part for each algorithm.");
114 pack_start(*(new Gtk::HSeparator()));
116 label=new Gtk::Label("Maps in chosen tab:");
120 for(int i=0;i<NODE_INPUT_NUM;i++)
122 std::ostringstream o;
123 o << "NodeInput " << i+1 << ":";
125 addMapSelector(o.str(), false);
128 pack_start(*(new Gtk::HSeparator()));
130 for(int i=0;i<EDGE_INPUT_NUM;i++)
133 std::ostringstream o;
134 o << "EdgeInput " << i+1 << ":";
136 addMapSelector(o.str(), true);
139 pack_start(*(new Gtk::HSeparator()));
142 void AlgoBox::addMapSelector(std::string inputname, bool itisedge)
144 std::vector<std::string> empty_vector;
146 MapSelector * msp=new MapSelector(empty_vector,"",inputname,itisedge, false);
150 edgemapcbts.resize(edgemapcbts.size()+1);
151 edgemapcbts[edgemapcbts.size()-1]=msp;
155 nodemapcbts.resize(nodemapcbts.size()+1);
156 nodemapcbts[nodemapcbts.size()-1]=msp;
159 msp->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
164 sigc::signal<void, std::string> AlgoBox::signal_maplist_needed()
166 return signal_maplist_need;
169 void AlgoBox::emit_tab_change()
171 std::string active_tab=tabcbt.get_active_text();
174 signal_maplist_need.emit(active_tab);
178 std::vector<std::string> empty_vector;
179 update_maplist(NULL);
183 void AlgoBox::emit_new_map_signal(bool itisedge)
185 signal_newmapwin_need.emit(tabcbt.get_active_text(), itisedge);