COIN-OR::LEMON - Graph Library

Changeset 1876:5ad84ad1b68f in lemon-0.x for gui


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

Communication with algorithm window is developed.

Location:
gui
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • gui/Makefile.am

    r1862 r1876  
    88glemon_SOURCES = \
    99        all_include.h \
     10        algobox.cc \
     11        algobox.h \
     12        algowin.cc \
     13        algowin.h \
    1014        gdc-broken_edge.cc \
    1115        graph_displayer_canvas.cc \
     
    1620        graph_displayer_canvas-zoom.cc \
    1721        graph-displayer.cc \
     22        kruskalbox.cc \
     23        kruskalbox.h \
    1824        main_win.cc \
    1925        main_win.h \
  • gui/algobox.h

    r1871 r1876  
    1212class AlgoBox : public Gtk::VBox
    1313{
     14  sigc::signal<void, std::string> signal_maplist_need; 
    1415 
     16  Gtk::ComboBoxText tabcbt;
     17
     18protected:
    1519  Gtk::Label * label;
    16   Gtk::ComboBoxText cbt;
     20  std::vector<Gtk::ComboBoxText *> nodemapcbts;
     21  std::vector<Gtk::ComboBoxText *> edgemapcbts;
    1722 
    18  public:
    19   AlgoBox(std::vector<std::string> tabnames)
    20     {
    21       update_tablist(tabnames);
     23public:
     24  AlgoBox(){};
     25  AlgoBox(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
    2226
    23       label=new Gtk::Label("Haliho");
    24      
    25       pack_start(*label);
    26       pack_start(cbt);
     27  virtual void init(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
    2728
    28       show_all_children();
    29     };
     29  sigc::signal<void, std::string> signal_maplist_needed(); 
     30  void emit_tab_change();
    3031
    31   void update_tablist( std::vector< std::string > tl )
    32     {
    33       std::string actname=cbt.get_active_text();
    34       int prev_act=-1;
     32  void update_tablist( std::vector< std::string > tl );
     33  void update_maplist( std::vector< std::string >, std::vector< std::string >);
    3534
    36       cbt.clear();
    37       int actptr=0;
    38 
    39       std::vector< std::string >::iterator emsi=tl.begin();
    40       for(;emsi!=tl.end();emsi++)
    41         {
    42           if(actname==*emsi)
    43             {
    44               prev_act=actptr;
    45             }
    46 
    47           cbt.append_text(*emsi);
    48           actptr++;
    49         }
    50 
    51       if(prev_act!=-1)
    52         {
    53           cbt.set_active(prev_act);
    54         }
    55       else if(actptr>0) //so there is item in the list
    56         {
    57           cbt.set_active(0);
    58         }
    59     }
    60 
     35  void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText &);
     36 
     37  virtual void run();
     38 
     39  virtual void build_box();
    6140};
    6241#endif //ALGOBOX_H
  • gui/algowin.h

    r1871 r1876  
    1111#include <libgnomecanvasmm/polygon.h>
    1212
    13 enum {GENERAL, ALGO_NUM}; // algorithm IDs;
     13enum {GENERAL, KRUSKAL, ALGO_NUM}; // algorithm IDs;
    1414
    15 class AlgoWin : public Gtk::Dialog
     15class AlgoWin : public Gtk::Window
    1616{
    1717private:
    1818  AlgoBox * ab;
     19  Gtk::Button * runbutton;
     20  Gtk::Button * closebutton;
    1921
    2022protected:
    2123  sigc::signal<void, AlgoWin *> signal_closed; 
     24  sigc::signal<void, AlgoWin *, std::string> signal_maplist_need; 
    2225
    2326public:
    24   sigc::signal<void, AlgoWin *> signal_closing()
    25   {
    26     return signal_closed;
    27   }
     27  bool closeIfEscapeIsPressed(GdkEventKey* e);
    2828
    29   AlgoWin(int algoid, std::vector<std::string> tabnames)
    30     {
    31       Gtk::VBox * vbox=get_vbox();
    32      
    33       ab=new AlgoBox(tabnames);
    34      
    35       vbox->pack_start(*ab);
    36      
    37       add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
    38      
    39       show_all_children();
    40     };
     29  sigc::signal<void, AlgoWin *> signal_closing();
     30  sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
    4131
    42   void update_tablist(std::vector<std::string> tabnames)
    43   {
    44     ab->update_tablist(tabnames);
    45   }
     32  void emit_tab_change(std::string);
    4633
    47   void on_hide()
    48   {
    49     signal_closed.emit(this);
    50     Gtk::Dialog::on_hide();
    51   }
     34  AlgoWin(int, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
     35
     36  void update_tablist(std::vector<std::string> tabnames);
     37  void update_maplist(std::vector<std::string>, std::vector<std::string>);
     38
     39  void on_hide();
    5240};
    5341#endif //ALGOWIN_H
  • gui/main_win.cc

    r1872 r1876  
    105105  ag->add( Gtk::Action::create("AlgoGeneral", "_General"),
    106106           sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) );
     107  ag->add( Gtk::Action::create("AlgoKruskal", "_Kruskal"),
     108           sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) );
    107109
    108110  Gtk::RadioAction::Group tool_group;
     
    154156      "    <menu action='AlgoMenu'>"
    155157      "      <menuitem action='AlgoGeneral'/>"
     158      "      <menuitem action='AlgoKruskal'/>"
    156159      "    </menu>"
    157160      "  </menubar>"
     
    225228  set_title(tabnames[active_tab] + " - " + prog_name);
    226229  notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
    227   updateAlgoWins();
     230  updateAlgoWinTabs();
    228231}
    229232
     
    247250  notebook.set_current_page(size);
    248251  set_tabtitle("unsaved file");
    249   updateAlgoWins();
     252  updateAlgoWinTabs();
    250253}
    251254
     
    307310        }
    308311
    309       updateAlgoWins();
     312      updateAlgoWinTabs();
    310313    }
    311314}
     
    405408void MainWin::createAlgoWin(int algoid)
    406409{
    407   AlgoWin * aw=new AlgoWin(algoid, tabnames);
     410  AlgoWin * aw=new AlgoWin(algoid, tabnames, tabs[0]->mapstorage.getNodeMapList(),tabs[0]->mapstorage.getEdgeMapList());
    408411  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
     412  aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
    409413  aws.insert(aw);
    410414  aw->show();
    411415}
    412416
     417void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
     418{
     419  int i=0;
     420  for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
     421    {
     422    }
     423  awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
     424}
     425
    413426void MainWin::deRegisterAlgoWin(AlgoWin * awp)
    414427{
     
    416429}
    417430
    418 void MainWin::updateAlgoWins()
     431void MainWin::updateAlgoWinTabs()
    419432{
    420433  std::set< AlgoWin* >::iterator awsi=aws.begin();
  • gui/main_win.h

    r1872 r1876  
    7474  virtual void createAlgoWin(int);
    7575  virtual void deRegisterAlgoWin(AlgoWin *);
    76   virtual void updateAlgoWins();
     76  virtual void updateAlgoWinTabs();
     77  virtual void updateAlgoWinMaps(AlgoWin *, std::string);
    7778
    7879  virtual void changeEditorialTool(int);
Note: See TracChangeset for help on using the changeset viewer.