Use hg changeset hash instead of svn revision.
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 arcs;
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> n_nml;
86 std::vector<std::string> s_nml;
87 std::vector<std::string> n_eml;
88 std::vector<std::string> s_eml;
91 mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
92 mapstorage->signal_arc_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::arcmaplist_changed));
93 n_nml=mapstorage->getNodeMapList(NUM);
94 s_nml=mapstorage->getNodeMapList(STR);
95 n_eml=mapstorage->getArcMapList(NUM);
96 s_eml=mapstorage->getArcMapList(STR);
98 for(int i=0;i<(int)nodemapcbts.size();i++)
100 (nodemapcbts[i])->update_list(n_nml, s_nml);
101 //update_cbt(nml, *(nodemapcbts[i]));
103 for(int i=0;i<(int)arcmapcbts.size();i++)
105 (arcmapcbts[i])->update_list(n_eml, s_eml);
106 //update_cbt(eml, *(arcmapcbts[i]));
108 signal_maplist_updated.emit();
111 void AlgoBox::nodemaplist_changed(std::string newmap, MapValue::Type type)
113 for(int i=0;i<(int)nodemapcbts.size();i++)
115 (nodemapcbts[i])->append_text(newmap, type);
119 void AlgoBox::arcmaplist_changed(std::string newmap, MapValue::Type type)
121 for(int i=0;i<(int)arcmapcbts.size();i++)
123 (arcmapcbts[i])->append_text(newmap, type);
129 std::cout << "Start algorithm." << std::endl;
132 void AlgoBox::build_box()
134 pack_start(*(new Gtk::HSeparator()));
136 Gtk::Label * label=new Gtk::Label("Specific part for each algorithm.");
139 pack_start(*(new Gtk::HSeparator()));
141 label=new Gtk::Label("Maps in chosen tab:");
145 for(int i=0;i<NODE_INPUT_NUM;i++)
147 std::ostringstream o;
148 o << "NodeInput " << i+1 << ":";
150 addMapSelector(o.str(), false);
153 pack_start(*(new Gtk::HSeparator()));
155 for(int i=0;i<EDGE_INPUT_NUM;i++)
158 std::ostringstream o;
159 o << "ArcInput " << i+1 << ":";
161 addMapSelector(o.str(), true);
164 pack_start(*(new Gtk::HSeparator()));
167 void AlgoBox::addMapSelector(std::string inputname, bool itisarc, MapType type)
169 std::vector<std::string> empty_vector;
171 MapSelector * msp=new MapSelector(empty_vector,empty_vector,"",inputname,itisarc, false, type);
175 arcmapcbts.resize(arcmapcbts.size()+1);
176 arcmapcbts[arcmapcbts.size()-1]=msp;
180 nodemapcbts.resize(nodemapcbts.size()+1);
181 nodemapcbts[nodemapcbts.size()-1]=msp;
184 msp->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
189 sigc::signal<void, std::string> AlgoBox::signal_maplist_needed()
191 return signal_maplist_need;
194 void AlgoBox::emit_tab_change()
196 std::string active_tab=tabcbt.get_active_text();
199 signal_maplist_need.emit(active_tab);
203 std::vector<std::string> empty_vector;
204 update_maplist(NULL);
208 void AlgoBox::emit_new_map_signal(bool itisarc)
210 signal_newmapwin_need.emit(tabcbt.get_active_text(), itisarc);