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