Creation of algorithm dialog is even simpler by the usage of the newly created addMapSelector function. gui
authorhegyi
Mon, 09 Jan 2006 11:55:47 +0000
branchgui
changeset 1162bd795bb9984
parent 115 9e5196647a5a
child 117 004b239908e6
Creation of algorithm dialog is even simpler by the usage of the newly created addMapSelector function.
algobox.cc
algobox.h
kruskalbox.cc
     1.1 --- a/algobox.cc	Fri Jan 06 23:16:51 2006 +0000
     1.2 +++ b/algobox.cc	Mon Jan 09 11:55:47 2006 +0000
     1.3 @@ -117,39 +117,50 @@
     1.4        
     1.5    pack_start(*label);
     1.6  
     1.7 -  nodemapcbts.resize(NODE_INPUT_NUM);
     1.8 -  for(int i=0;i<(int)nodemapcbts.size();i++)
     1.9 +  for(int i=0;i<NODE_INPUT_NUM;i++)
    1.10      {
    1.11 -      std::vector<std::string> empty_vector;
    1.12 -
    1.13        std::ostringstream o;
    1.14        o << "NodeInput " << i+1 << ":";
    1.15  
    1.16 -      nodemapcbts[i]=new MapSelector(empty_vector,"",o.str(),false, false);
    1.17 -      nodemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    1.18 -
    1.19 -      pack_start(*(nodemapcbts[i]));
    1.20 +      addMapSelector(o.str(), false);
    1.21      }
    1.22  
    1.23    pack_start(*(new Gtk::HSeparator()));
    1.24  
    1.25 -  edgemapcbts.resize(EDGE_INPUT_NUM);
    1.26 -  for(int i=0;i<(int)edgemapcbts.size();i++)
    1.27 +  for(int i=0;i<EDGE_INPUT_NUM;i++)
    1.28      {
    1.29 -      std::vector<std::string> empty_vector;
    1.30  
    1.31        std::ostringstream o;
    1.32        o << "EdgeInput " << i+1 << ":";
    1.33  
    1.34 -      edgemapcbts[i]=new MapSelector(empty_vector,"",o.str(),true, false);
    1.35 -      edgemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    1.36 -
    1.37 -      pack_start(*(edgemapcbts[i]));
    1.38 +      addMapSelector(o.str(), true);
    1.39      }
    1.40  
    1.41    pack_start(*(new Gtk::HSeparator()));
    1.42  }
    1.43  
    1.44 +void AlgoBox::addMapSelector(std::string inputname, bool itisedge)
    1.45 +{
    1.46 +  std::vector<std::string> empty_vector;
    1.47 +
    1.48 +  MapSelector * msp=new MapSelector(empty_vector,"",inputname,itisedge, false);
    1.49 +
    1.50 +  if(itisedge)
    1.51 +    {
    1.52 +      edgemapcbts.resize(edgemapcbts.size()+1);
    1.53 +      edgemapcbts[edgemapcbts.size()-1]=msp;
    1.54 +    }
    1.55 +  else
    1.56 +    {
    1.57 +      nodemapcbts.resize(nodemapcbts.size()+1);
    1.58 +      nodemapcbts[nodemapcbts.size()-1]=msp;
    1.59 +    }
    1.60 +
    1.61 +  msp->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    1.62 +
    1.63 +  pack_start(*msp);
    1.64 +}
    1.65 +
    1.66  sigc::signal<void, std::string> AlgoBox::signal_maplist_needed()
    1.67  {
    1.68    return signal_maplist_need;
     2.1 --- a/algobox.h	Fri Jan 06 23:16:51 2006 +0000
     2.2 +++ b/algobox.h	Mon Jan 09 11:55:47 2006 +0000
     2.3 @@ -46,5 +46,7 @@
     2.4    virtual void build_box();
     2.5  
     2.6    virtual void emit_new_map_signal(bool);
     2.7 +
     2.8 +  void addMapSelector(std::string, bool);
     2.9  };
    2.10  #endif //ALGOBOX_H
     3.1 --- a/kruskalbox.cc	Fri Jan 06 23:16:51 2006 +0000
     3.2 +++ b/kruskalbox.cc	Mon Jan 09 11:55:47 2006 +0000
     3.3 @@ -53,17 +53,8 @@
     3.4  {
     3.5    std::vector<std::string> empty_vector;
     3.6  
     3.7 -  edgemapcbts.resize(MAP_NUM);
     3.8 -
     3.9 -  edgemapcbts[0]=new MapSelector(empty_vector,"","Edgecosts: ",true, false);
    3.10 -  edgemapcbts[0]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    3.11 -
    3.12 -  pack_start(*(edgemapcbts[INPUT]));
    3.13 -
    3.14 -  edgemapcbts[1]=new MapSelector(empty_vector,"","Edges of tree here: ",true, false);
    3.15 -  edgemapcbts[1]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    3.16 -
    3.17 -  pack_start(*(edgemapcbts[OUTPUT]));
    3.18 +  addMapSelector("Edgecosts: ", true);
    3.19 +  addMapSelector("Edges of tree here: ", true);
    3.20  
    3.21    resultlabel.set_text("Result: algorithm is not run yet.");
    3.22    pack_start(resultlabel);