COIN-OR::LEMON - Graph Library

source: glemon/algowin.cc @ 1:67188bd752db

Last change on this file since 1:67188bd752db was 1:67188bd752db, checked in by Peter Hegyi <hegyi@…>, 16 years ago

SVN revision 3500 made compilable with Lemon 1.0.

File size: 2.8 KB
Line 
1/* -*- C++ -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library
4 *
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
12 *
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
15 * purpose.
16 *
17 */
18
19#include <algowin.h>
20#include <algobox.h>
21#include <kruskalbox.h>
22#include <dijkstrabox.h>
23
24sigc::signal<void, AlgoWin *> AlgoWin::signal_closing()
25{
26  return signal_closed;
27}
28
29sigc::signal<void, AlgoWin *, std::string> AlgoWin::signal_maplist_needed()
30{
31  return signal_maplist_need;
32}
33
34bool AlgoWin::closeIfEscapeIsPressed(GdkEventKey* e)
35{
36  if(e->keyval==GDK_Escape)
37  {
38    on_hide();
39  }
40  return true;
41}
42
43AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
44{
45  signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
46
47  Gtk::VBox * vbox=new Gtk::VBox();
48  vbox->set_spacing(5);
49
50  Gtk::Label * label=new Gtk::Label("Select digraph:");
51
52  switch(algoid)
53    {
54    case 0:
55      ab=new AlgoBox(tabnames);
56      set_title("Algo Win Demo");
57      break;
58    case 1:
59      ab=new KruskalBox(tabnames);
60      set_title("Kruskal Algorithm");
61      break;
62    case 2:
63      ab=new DijkstraBox(tabnames);
64      set_title("Dijkstra Algorithm");
65      break;
66    case 3:
67      ab=new SuurballeBox(tabnames);
68      set_title("Suurballe Algorithm");
69      break;
70    default:
71      break;
72    }
73  ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
74  ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal));
75
76  runbutton=new Gtk::Button("Run");
77  runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
78  runbutton->signal_activate().connect(sigc::mem_fun(*ab,&AlgoBox::run));
79
80  closebutton=new Gtk::Button("Close");
81  closebutton->signal_released().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
82  closebutton->signal_activate().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
83     
84  Gtk::HBox * hbox=new Gtk::HBox();
85
86  hbox->pack_start(*runbutton);
87  hbox->pack_start(*closebutton);
88
89  vbox->pack_start(*label);
90  vbox->pack_start(*ab);
91  vbox->pack_start(*hbox);
92     
93  add(*vbox);
94
95  show_all_children();
96};
97
98void AlgoWin::update_tablist(std::vector<std::string> tabnames)
99{
100  ab->update_tablist(tabnames);
101}
102
103void AlgoWin::update_maplist(MapStorage * mapstorage)
104{
105  ab->update_maplist(mapstorage);
106}
107
108void AlgoWin::on_hide()
109{
110  signal_closed.emit(this);
111  Gtk::Window::on_hide();
112}
113
114void AlgoWin::emit_tab_change(std::string newtab)
115{
116  signal_maplist_need.emit(this, newtab);
117}
Note: See TracBrowser for help on using the repository browser.