COIN-OR::LEMON - Graph Library

source: glemon-0.x/algowin.cc @ 108:bf355fd6563e

gui
Last change on this file since 108:bf355fd6563e was 108:bf355fd6563e, checked in by Hegyi Péter, 14 years ago

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.

File size: 1.9 KB
Line 
1#include <algowin.h>
2#include <kruskalbox.h>
3
4sigc::signal<void, AlgoWin *> AlgoWin::signal_closing()
5{
6  return signal_closed;
7}
8
9sigc::signal<void, AlgoWin *, std::string> AlgoWin::signal_maplist_needed()
10{
11  return signal_maplist_need;
12}
13
14bool AlgoWin::closeIfEscapeIsPressed(GdkEventKey* e)
15{
16  if(e->keyval==GDK_Escape)
17  {
18    on_hide();
19  }
20  return true;
21}
22
23AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
24{
25  signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
26
27  Gtk::VBox * vbox=new Gtk::VBox();
28  vbox->set_spacing(5);
29
30  Gtk::Label * label=new Gtk::Label("Select graph:");
31
32  switch(algoid)
33    {
34    case 0:
35      ab=new AlgoBox(tabnames);
36      set_title("Algo Win Demo");
37      break;
38    case 1:
39      ab=new KruskalBox(tabnames);
40      set_title("Kruskal Algorithm");
41      break;
42    default:
43      break;
44    }
45  ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
46
47  runbutton=new Gtk::Button("Run");
48  runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
49  runbutton->signal_activate().connect(sigc::mem_fun(*ab,&AlgoBox::run));
50
51  closebutton=new Gtk::Button("Close");
52  closebutton->signal_released().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
53  closebutton->signal_activate().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
54     
55  Gtk::HBox * hbox=new Gtk::HBox();
56
57  hbox->pack_start(*runbutton);
58  hbox->pack_start(*closebutton);
59
60  vbox->pack_start(*label);
61  vbox->pack_start(*ab);
62  vbox->pack_start(*hbox);
63     
64  add(*vbox);
65
66  show_all_children();
67};
68
69void AlgoWin::update_tablist(std::vector<std::string> tabnames)
70{
71  ab->update_tablist(tabnames);
72}
73
74void AlgoWin::update_maplist(void * mapstorage)
75{
76  ab->update_maplist(mapstorage);
77}
78
79void AlgoWin::on_hide()
80{
81  signal_closed.emit(this);
82  Gtk::Window::on_hide();
83}
84
85void AlgoWin::emit_tab_change(std::string newtab)
86{
87  signal_maplist_need.emit(this, newtab);
88}
Note: See TracBrowser for help on using the repository browser.