COIN-OR::LEMON - Graph Library

Changeset 1878:409a31271efd in lemon-0.x


Ignore:
Timestamp:
01/05/06 13:30:09 (14 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2453
Message:

Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.

Location:
gui
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • gui/algobox.cc

    r1876 r1878  
    44enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges;
    55
    6 AlgoBox::AlgoBox(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
     6AlgoBox::AlgoBox(std::vector<std::string> tabnames)
    77{
    8   init(tabnames, nodemapnames, edgemapnames);
     8  init(tabnames);
    99}
    1010
    11 void AlgoBox::init(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
     11void AlgoBox::init(std::vector<std::string> tabnames)
    1212{
    1313  set_spacing(5);
     
    1919
    2020  pack_start(tabcbt);
    21 
    2221  build_box();
    23 
    24   update_maplist(nodemapnames, edgemapnames);
    2522
    2623  show_all_children();
     
    5350  else if(actptr>0) //so there is item in the list
    5451    {
    55       cbt.set_active(0);
     52      //cbt.set_active(0);
    5653    }
    5754}
     
    6360}
    6461
    65 void AlgoBox::update_maplist( std::vector< std::string > nml, std::vector< std::string > eml )
     62void AlgoBox::update_maplist( void * ms)
    6663{
     64  mapstorage=(MapStorage *)ms;
     65  std::vector<std::string> nml;
     66  std::vector<std::string> eml;
     67  if(mapstorage!=NULL)
     68    {
     69      mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
     70      mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed));
     71      nml=mapstorage->getNodeMapList();
     72      eml=mapstorage->getNodeMapList();
     73    }
    6774  for(int i=0;i<(int)nodemapcbts.size();i++)
    6875    {
     
    7279    {
    7380      update_cbt(eml, *(edgemapcbts[i]));
     81    }
     82}
     83
     84void AlgoBox::nodemaplist_changed(std::string newmap)
     85{
     86  for(int i=0;i<(int)nodemapcbts.size();i++)
     87    {
     88      (nodemapcbts[i])->append_text(newmap);
     89    }
     90}
     91
     92void AlgoBox::edgemaplist_changed(std::string newmap)
     93{
     94  for(int i=0;i<(int)edgemapcbts.size();i++)
     95    {
     96      (edgemapcbts[i])->append_text(newmap);
    7497    }
    7598}
     
    137160void AlgoBox::emit_tab_change()
    138161{
    139   signal_maplist_need.emit(tabcbt.get_active_text());
     162  std::string active_tab=tabcbt.get_active_text();
     163  if(active_tab!="")
     164    {
     165      signal_maplist_need.emit(active_tab);
     166    }
     167  else
     168    {
     169      std::vector<std::string> empty_vector;
     170      update_maplist(NULL);
     171    }
    140172}
  • gui/algobox.h

    r1876 r1878  
    77
    88#include <all_include.h>
     9#include <mapstorage.h>
    910#include <libgnomecanvasmm.h>
    1011#include <libgnomecanvasmm/polygon.h>
     
    2021  std::vector<Gtk::ComboBoxText *> nodemapcbts;
    2122  std::vector<Gtk::ComboBoxText *> edgemapcbts;
    22  
     23
     24  MapStorage * mapstorage;
     25
    2326public:
    2427  AlgoBox(){};
    25   AlgoBox(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
     28  AlgoBox(std::vector<std::string>);
    2629
    27   virtual void init(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
     30  virtual void init(std::vector<std::string>);
    2831
    2932  sigc::signal<void, std::string> signal_maplist_needed(); 
     
    3134
    3235  void update_tablist( std::vector< std::string > tl );
    33   void update_maplist( std::vector< std::string >, std::vector< std::string >);
     36  void update_maplist( void * );
     37
     38  void nodemaplist_changed(std::string);
     39  void edgemaplist_changed(std::string);
    3440
    3541  void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText &);
  • gui/algowin.cc

    r1876 r1878  
    2121}
    2222
    23 AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames, std::vector<std::string> nodemapnames,std::vector<std::string> edgemapnames)
     23AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
    2424{
    2525  signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
     
    3333    {
    3434    case 0:
    35       ab=new AlgoBox(tabnames, nodemapnames, edgemapnames);
     35      ab=new AlgoBox(tabnames);
    3636      set_title("Algo Win Demo");
    3737      break;
    3838    case 1:
    39       ab=new KruskalBox(tabnames, nodemapnames, edgemapnames);
     39      ab=new KruskalBox(tabnames);
    4040      set_title("Kruskal Algorithm");
    4141      break;
     
    7272}
    7373
    74 void AlgoWin::update_maplist(std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
     74void AlgoWin::update_maplist(void * mapstorage)
    7575{
    76   ab->update_maplist(nodemapnames, edgemapnames);
     76  ab->update_maplist(mapstorage);
    7777}
    7878
  • gui/algowin.h

    r1876 r1878  
    3232  void emit_tab_change(std::string);
    3333
    34   AlgoWin(int, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
     34  AlgoWin(int, std::vector<std::string>);
    3535
    3636  void update_tablist(std::vector<std::string> tabnames);
    37   void update_maplist(std::vector<std::string>, std::vector<std::string>);
     37  void update_maplist( void *);
    3838
    3939  void on_hide();
  • gui/kruskalbox.cc

    r1876 r1878  
    11#include <kruskalbox.h>
    22
    3 KruskalBox::KruskalBox(std::vector<std::string> t, std::vector<std::string> nm, std::vector<std::string> em):AlgoBox()
     3KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
    44{
    5   init(t, nm, em);
     5  init(t);
    66}
    77   
    88void KruskalBox::run()
    99{
     10 
    1011  std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl;
    1112}
  • gui/kruskalbox.h

    r1876 r1878  
    1515{
    1616public:
    17   KruskalBox(std::vector<std::string> t, std::vector<std::string> nm, std::vector<std::string> em);
     17  KruskalBox(std::vector<std::string> t);
    1818   
    1919  void run();
  • gui/main_win.cc

    r1877 r1878  
    410410void MainWin::createAlgoWin(int algoid)
    411411{
    412   AlgoWin * aw=new AlgoWin(algoid, tabnames, tabs[0]->mapstorage.getNodeMapList(),tabs[0]->mapstorage.getEdgeMapList());
     412  AlgoWin * aw=new AlgoWin(algoid, tabnames);
    413413  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
    414414  aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
     
    417417}
    418418
     419void MainWin::updateAlgoWinTabs()
     420{
     421  std::set< AlgoWin* >::iterator awsi=aws.begin();
     422  for(;awsi!=aws.end();awsi++)
     423    {
     424      (*awsi)->update_tablist(tabnames);
     425    }
     426}
     427
    419428void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
    420429{
     
    423432    {
    424433    }
    425   awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
     434  //awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
     435  awp->update_maplist(&(tabs[i]->mapstorage));
    426436}
    427437
     
    429439{
    430440  aws.erase(awp);
    431 }
    432 
    433 void MainWin::updateAlgoWinTabs()
    434 {
    435   std::set< AlgoWin* >::iterator awsi=aws.begin();
    436   for(;awsi!=aws.end();awsi++)
    437     {
    438       (*awsi)->update_tablist(tabnames);
    439     }
    440441}
    441442
  • gui/mapstorage.cc

    r1867 r1878  
    5959      // set the maps default value
    6060      nodemap_default[name] = default_value;
     61
     62      //announce changement in maps
     63      signal_node_map.emit(name);
    6164      return 0;
    6265    }
     
    127130      // set the maps default value
    128131      edgemap_default[name] = default_value;
     132
     133      //announce changement in maps
     134      signal_edge_map.emit(name);
    129135      return 0;
    130136    }
  • gui/mapstorage.h

    r1860 r1878  
    6161  typedef sigc::signal<void, bool, int> Signal_Prop;
    6262  Signal_Prop signal_prop;
     63  sigc::signal<void, std::string> signal_node_map;
     64  sigc::signal<void, std::string> signal_edge_map;
    6365
    6466public:
     
    8284
    8385  Signal_Prop signal_prop_ch();
     86
     87  sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
     88  sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
    8489
    8590  ///Adds given map to storage. A name and the map itself has to be provided.
  • gui/nbtab.cc

    r1869 r1878  
    88  //connecting signals - controller character
    99  mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
     10  mapstorage.signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap));
     11  mapstorage.signal_edge_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewEdgeMap));
    1012  show_all_children();
    1113  show();
  • gui/new_map_win.cc

    r1849 r1878  
    160160
    161161              //add it to the list of the displayable maps
    162               mytab.registerNewEdgeMap(mapname);
     162              //furthermore it is done by signals
     163              //mytab.registerNewEdgeMap(mapname);
    163164
    164165              //display it
     
    243244
    244245              //add it to the list of the displayable maps
    245               mytab.registerNewNodeMap(mapname);
     246              //furthermore it is done by signals
     247              //mytab.registerNewNodeMap(mapname);
    246248
    247249              //display it
Note: See TracChangeset for help on using the changeset viewer.