In algorithm window maps can be selected and reated through MapSelector widget.
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 nodemapcbts.resize(NODE_INPUT_NUM);
121 for(int i=0;i<(int)nodemapcbts.size();i++)
123 std::vector<std::string> empty_vector;
125 std::ostringstream o;
126 o << "NodeInput " << i+1 << ":";
128 nodemapcbts[i]=new MapSelector(empty_vector,"",o.str(),false, false);
129 nodemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
131 pack_start(*(nodemapcbts[i]));
134 pack_start(*(new Gtk::HSeparator()));
136 edgemapcbts.resize(EDGE_INPUT_NUM);
137 for(int i=0;i<(int)edgemapcbts.size();i++)
139 std::vector<std::string> empty_vector;
141 std::ostringstream o;
142 o << "EdgeInput " << i+1 << ":";
144 edgemapcbts[i]=new MapSelector(empty_vector,"",o.str(),true, false);
145 edgemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
147 pack_start(*(edgemapcbts[i]));
150 pack_start(*(new Gtk::HSeparator()));
153 sigc::signal<void, std::string> AlgoBox::signal_maplist_needed()
155 return signal_maplist_need;
158 void AlgoBox::emit_tab_change()
160 std::string active_tab=tabcbt.get_active_text();
163 signal_maplist_need.emit(active_tab);
167 std::vector<std::string> empty_vector;
168 update_maplist(NULL);
172 void AlgoBox::emit_new_map_signal(bool itisedge)
174 signal_newmapwin_need.emit(tabcbt.get_active_text(), itisedge);