# HG changeset patch # User hegyi # Date 1136807747 0 # Node ID 2bd795bb998423ff81303183c1521645d947a634 # Parent 9e5196647a5aa94b896a9f843383e48c0cb0d634 Creation of algorithm dialog is even simpler by the usage of the newly created addMapSelector function. diff -r 9e5196647a5a -r 2bd795bb9984 algobox.cc --- a/algobox.cc Fri Jan 06 23:16:51 2006 +0000 +++ b/algobox.cc Mon Jan 09 11:55:47 2006 +0000 @@ -117,39 +117,50 @@ pack_start(*label); - nodemapcbts.resize(NODE_INPUT_NUM); - for(int i=0;i<(int)nodemapcbts.size();i++) + for(int i=0;i empty_vector; - std::ostringstream o; o << "NodeInput " << i+1 << ":"; - nodemapcbts[i]=new MapSelector(empty_vector,"",o.str(),false, false); - nodemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - - pack_start(*(nodemapcbts[i])); + addMapSelector(o.str(), false); } pack_start(*(new Gtk::HSeparator())); - edgemapcbts.resize(EDGE_INPUT_NUM); - for(int i=0;i<(int)edgemapcbts.size();i++) + for(int i=0;i empty_vector; std::ostringstream o; o << "EdgeInput " << i+1 << ":"; - edgemapcbts[i]=new MapSelector(empty_vector,"",o.str(),true, false); - edgemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - - pack_start(*(edgemapcbts[i])); + addMapSelector(o.str(), true); } pack_start(*(new Gtk::HSeparator())); } +void AlgoBox::addMapSelector(std::string inputname, bool itisedge) +{ + std::vector 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; diff -r 9e5196647a5a -r 2bd795bb9984 algobox.h --- a/algobox.h Fri Jan 06 23:16:51 2006 +0000 +++ b/algobox.h Mon Jan 09 11:55:47 2006 +0000 @@ -46,5 +46,7 @@ virtual void build_box(); virtual void emit_new_map_signal(bool); + + void addMapSelector(std::string, bool); }; #endif //ALGOBOX_H diff -r 9e5196647a5a -r 2bd795bb9984 kruskalbox.cc --- a/kruskalbox.cc Fri Jan 06 23:16:51 2006 +0000 +++ b/kruskalbox.cc Mon Jan 09 11:55:47 2006 +0000 @@ -53,17 +53,8 @@ { std::vector empty_vector; - edgemapcbts.resize(MAP_NUM); - - edgemapcbts[0]=new MapSelector(empty_vector,"","Edgecosts: ",true, false); - edgemapcbts[0]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - - pack_start(*(edgemapcbts[INPUT])); - - edgemapcbts[1]=new MapSelector(empty_vector,"","Edges of tree here: ",true, false); - edgemapcbts[1]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - - pack_start(*(edgemapcbts[OUTPUT])); + addMapSelector("Edgecosts: ", true); + addMapSelector("Edges of tree here: ", true); resultlabel.set_text("Result: algorithm is not run yet."); pack_start(resultlabel);