#include 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) { init(tabnames); } void AlgoBox::init(std::vector tabnames) { set_spacing(5); update_tablist(tabnames); //if active tab is changed, the map names in cbt/s have to be updated tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change)); pack_start(tabcbt); build_box(); show_all_children(); }; void AlgoBox::update_cbt(std::vector< std::string > stringlist, Gtk::ComboBoxText & cbt) { std::string actname=cbt.get_active_text(); int prev_act=-1; cbt.clear(); int actptr=0; std::vector< std::string >::iterator emsi=stringlist.begin(); for(;emsi!=stringlist.end();emsi++) { if(actname==*emsi) { prev_act=actptr; } cbt.append_text(*emsi); actptr++; } if(prev_act!=-1) { cbt.set_active(prev_act); } else if(actptr>0) //so there is item in the list { //cbt.set_active(0); } } void AlgoBox::update_tablist( std::vector< std::string > tl ) { update_cbt(tl, tabcbt); emit_tab_change(); } void AlgoBox::update_maplist(MapStorage * ms) { 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->getEdgeMapList(); } for(int i=0;i<(int)nodemapcbts.size();i++) { (nodemapcbts[i])->update_list(nml); //update_cbt(nml, *(nodemapcbts[i])); } for(int i=0;i<(int)edgemapcbts.size();i++) { (edgemapcbts[i])->update_list(eml); //update_cbt(eml, *(edgemapcbts[i])); } } 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; } void AlgoBox::build_box() { pack_start(*(new Gtk::HSeparator())); Gtk::Label * label=new Gtk::Label("Specific part for each algorithm."); pack_start(*label); pack_start(*(new Gtk::HSeparator())); label=new Gtk::Label("Maps in chosen tab:"); pack_start(*label); for(int i=0;i empty_vector; MapSelector * msp=new MapSelector(empty_vector,"",inputname,itisedge, false); if(itisedge) { edgemapcbts.resize(edgemapcbts.size()+1); edgemapcbts[edgemapcbts.size()-1]=msp; } else { nodemapcbts.resize(nodemapcbts.size()+1); nodemapcbts[nodemapcbts.size()-1]=msp; } msp->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); pack_start(*msp); } sigc::signal AlgoBox::signal_maplist_needed() { return signal_maplist_need; } void AlgoBox::emit_tab_change() { 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); } } void AlgoBox::emit_new_map_signal(bool itisedge) { signal_newmapwin_need.emit(tabcbt.get_active_text(), itisedge); }