COIN-OR::LEMON - Graph Library

Changeset 114:0ace7edbb06f in glemon-0.x for kruskalbox.cc


Ignore:
Timestamp:
01/06/06 17:07:08 (14 years ago)
Author:
Hegyi Péter
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2459
Message:

In algorithm window maps can be selected and reated through MapSelector? widget.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kruskalbox.cc

    r111 r114  
    1010void KruskalBox::run()
    1111{
    12   Graph g=mapstorage->graph;
    13   Graph::EdgeMap<double> * inputmap=
    14     ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
    15   Graph::EdgeMap<bool> outputmap(g);
    16   double res=kruskal(g, *inputmap, outputmap);
     12  if(
     13     tabcbt.get_active_text()!="" &&
     14     (edgemapcbts[INPUT])->get_active_text()!="" &&
     15     (edgemapcbts[OUTPUT])->get_active_text()!=""
     16     )
     17    {
    1718
    18   for (EdgeIt i(g); i!=INVALID; ++i)
    19   {
    20     if(outputmap[i])
    21       {
    22         (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
    23                                          get_active_text()]))[i]=1;
    24       }
    25     else
    26       {
    27         (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
    28                                          get_active_text()]))[i]=0;
    29       }
    30   }
     19      Graph g=mapstorage->graph;
     20      Graph::EdgeMap<double> * inputmap=
     21        ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
     22      Graph::EdgeMap<bool> outputmap(g);
     23      double res=kruskal(g, *inputmap, outputmap);
    3124
    32   std::ostringstream o;
    33   o << "Result: " << res;
    34   resultlabel.set_text(o.str());
     25      for (EdgeIt i(g); i!=INVALID; ++i)
     26        {
     27          if(outputmap[i])
     28            {
     29              (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
     30                                               get_active_text()]))[i]=1;
     31            }
     32          else
     33            {
     34              (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
     35                                               get_active_text()]))[i]=0;
     36            }
     37        }
    3538
    36   mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
    37   //   mapstorage->changeActiveMap(true, E_COLOR,
    38   //                          (edgemapcbts[OUTPUT])->get_active_text());
    39   //   mapstorage->changeActiveMap(true, E_TEXT,
    40   //                          (edgemapcbts[INPUT])->get_active_text());
     39      std::ostringstream o;
     40      o << "Result: " << res;
     41      resultlabel.set_text(o.str());
     42
     43      mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
     44      //   mapstorage->changeActiveMap(true, E_COLOR,
     45      //                              (edgemapcbts[OUTPUT])->get_active_text());
     46      //   mapstorage->changeActiveMap(true, E_TEXT,
     47      //                              (edgemapcbts[INPUT])->get_active_text());
    4148 
     49    }
    4250}
    4351   
    4452void KruskalBox::build_box()
    4553{
     54  std::vector<std::string> empty_vector;
     55
    4656  edgemapcbts.resize(MAP_NUM);
    47   Gtk::HBox * hbox;
    4857
    49   hbox=new Gtk::HBox();
     58  edgemapcbts[0]=new MapSelector(empty_vector,"","Edgecosts: ",true, false);
     59  edgemapcbts[0]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    5060
    51   label=new Gtk::Label("Edgecosts: ");
     61  pack_start(*(edgemapcbts[INPUT]));
    5262
    53   edgemapcbts[0]=new Gtk::ComboBoxText();
     63  edgemapcbts[1]=new MapSelector(empty_vector,"","Edges of tree here: ",true, false);
     64  edgemapcbts[1]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
    5465
    55   hbox->pack_start(*label);
    56   hbox->pack_start(*(edgemapcbts[INPUT]));
    57   pack_start(*hbox);
    58 
    59   hbox=new Gtk::HBox();
    60 
    61   label=new Gtk::Label("Edges of tree here: ");
    62 
    63   edgemapcbts[1]=new Gtk::ComboBoxText();
    64 
    65   hbox->pack_start(*label);
    66   hbox->pack_start(*(edgemapcbts[OUTPUT]));
    67   pack_start(*hbox);
     66  pack_start(*(edgemapcbts[OUTPUT]));
    6867
    6968  resultlabel.set_text("Result: algorithm is not run yet.");
Note: See TracChangeset for help on using the changeset viewer.