3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
20 #include <mapstorage.h>
21 #include <mapselector.h>
23 enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes;
24 enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges;
26 AlgoBox::AlgoBox(std::vector<std::string> tabnames)
31 void AlgoBox::init(std::vector<std::string> tabnames)
35 update_tablist(tabnames);
37 //if active tab is changed, the map names in cbt/s have to be updated
38 tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change));
46 void AlgoBox::update_cbt(std::vector< std::string > stringlist, Gtk::ComboBoxText & cbt)
48 std::string actname=cbt.get_active_text();
54 std::vector< std::string >::iterator emsi=stringlist.begin();
55 for(;emsi!=stringlist.end();emsi++)
62 cbt.append_text(*emsi);
68 cbt.set_active(prev_act);
70 else if(actptr>0) //so there is item in the list
76 void AlgoBox::update_tablist( std::vector< std::string > tl )
78 update_cbt(tl, tabcbt);
82 void AlgoBox::update_maplist(MapStorage * ms)
85 std::vector<std::string> nml;
86 std::vector<std::string> eml;
89 mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
90 mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed));
91 nml=mapstorage->getNodeMapList();
92 eml=mapstorage->getEdgeMapList();
94 for(int i=0;i<(int)nodemapcbts.size();i++)
96 (nodemapcbts[i])->update_list(nml);
97 //update_cbt(nml, *(nodemapcbts[i]));
99 for(int i=0;i<(int)edgemapcbts.size();i++)
101 (edgemapcbts[i])->update_list(eml);
102 //update_cbt(eml, *(edgemapcbts[i]));
104 signal_maplist_updated.emit();
107 void AlgoBox::nodemaplist_changed(std::string newmap)
109 for(int i=0;i<(int)nodemapcbts.size();i++)
111 (nodemapcbts[i])->append_text(newmap);
115 void AlgoBox::edgemaplist_changed(std::string newmap)
117 for(int i=0;i<(int)edgemapcbts.size();i++)
119 (edgemapcbts[i])->append_text(newmap);
125 std::cout << "Start algorithm." << std::endl;
128 void AlgoBox::build_box()
130 pack_start(*(new Gtk::HSeparator()));
132 Gtk::Label * label=new Gtk::Label("Specific part for each algorithm.");
135 pack_start(*(new Gtk::HSeparator()));
137 label=new Gtk::Label("Maps in chosen tab:");
141 for(int i=0;i<NODE_INPUT_NUM;i++)
143 std::ostringstream o;
144 o << "NodeInput " << i+1 << ":";
146 addMapSelector(o.str(), false);
149 pack_start(*(new Gtk::HSeparator()));
151 for(int i=0;i<EDGE_INPUT_NUM;i++)
154 std::ostringstream o;
155 o << "EdgeInput " << i+1 << ":";
157 addMapSelector(o.str(), true);
160 pack_start(*(new Gtk::HSeparator()));
163 void AlgoBox::addMapSelector(std::string inputname, bool itisedge)
165 std::vector<std::string> empty_vector;
167 MapSelector * msp=new MapSelector(empty_vector,"",inputname,itisedge, false);
171 edgemapcbts.resize(edgemapcbts.size()+1);
172 edgemapcbts[edgemapcbts.size()-1]=msp;
176 nodemapcbts.resize(nodemapcbts.size()+1);
177 nodemapcbts[nodemapcbts.size()-1]=msp;
180 msp->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
185 sigc::signal<void, std::string> AlgoBox::signal_maplist_needed()
187 return signal_maplist_need;
190 void AlgoBox::emit_tab_change()
192 std::string active_tab=tabcbt.get_active_text();
195 signal_maplist_need.emit(active_tab);
199 std::vector<std::string> empty_vector;
200 update_maplist(NULL);
204 void AlgoBox::emit_new_map_signal(bool itisedge)
206 signal_newmapwin_need.emit(tabcbt.get_active_text(), itisedge);