hegyi@161
|
1 |
#include <design_win.h>
|
hegyi@161
|
2 |
|
hegyi@161
|
3 |
bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
|
hegyi@161
|
4 |
{
|
hegyi@161
|
5 |
if(e->keyval==GDK_Escape)
|
hegyi@161
|
6 |
{
|
hegyi@161
|
7 |
on_hide();
|
hegyi@161
|
8 |
}
|
hegyi@161
|
9 |
return true;
|
hegyi@161
|
10 |
}
|
hegyi@161
|
11 |
|
hegyi@161
|
12 |
DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
|
hegyi@161
|
13 |
{
|
hegyi@161
|
14 |
set_title(title);
|
hegyi@161
|
15 |
|
hegyi@161
|
16 |
signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
|
hegyi@161
|
17 |
|
hegyi@161
|
18 |
Gtk::VBox * vbox=new Gtk::VBox();
|
hegyi@161
|
19 |
vbox->set_spacing(5);
|
hegyi@161
|
20 |
|
hegyi@161
|
21 |
Gtk::Label * attraction_label=new Gtk::Label("Edge elasticity: ");
|
hegyi@161
|
22 |
Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
|
hegyi@161
|
23 |
Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
|
hegyi@161
|
24 |
|
hegyi@161
|
25 |
Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
|
hegyi@161
|
26 |
Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
|
hegyi@161
|
27 |
Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
|
hegyi@161
|
28 |
|
hegyi@161
|
29 |
attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
|
hegyi@161
|
30 |
propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
|
hegyi@161
|
31 |
iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
|
hegyi@161
|
32 |
|
hegyi@161
|
33 |
close_button=new Gtk::Button("Redesign");
|
hegyi@161
|
34 |
|
hegyi@161
|
35 |
attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
|
hegyi@161
|
36 |
propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
|
hegyi@161
|
37 |
iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
|
hegyi@161
|
38 |
close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
|
hegyi@161
|
39 |
|
hegyi@161
|
40 |
table.attach(*attraction_label,0,1,0,1);
|
hegyi@161
|
41 |
table.attach(*propulsation_label,0,1,1,2);
|
hegyi@161
|
42 |
table.attach(*iteration_label,0,1,2,3);
|
hegyi@161
|
43 |
table.attach(*attraction,1,2,0,1);
|
hegyi@161
|
44 |
table.attach(*propulsation,1,2,1,2);
|
hegyi@161
|
45 |
table.attach(*iteration,1,2,2,3);
|
hegyi@161
|
46 |
table.attach(*close_button,0,2,3,4);
|
hegyi@161
|
47 |
|
hegyi@161
|
48 |
add(table);
|
hegyi@161
|
49 |
|
hegyi@161
|
50 |
show_all_children();
|
hegyi@161
|
51 |
};
|
hegyi@161
|
52 |
|
hegyi@161
|
53 |
void DesignWin::emit_attraction()
|
hegyi@161
|
54 |
{
|
hegyi@161
|
55 |
signal_attraction_ch.emit(attraction->get_value());
|
hegyi@161
|
56 |
}
|
hegyi@161
|
57 |
|
hegyi@161
|
58 |
void DesignWin::emit_propulsation()
|
hegyi@161
|
59 |
{
|
hegyi@161
|
60 |
signal_propulsation_ch.emit(propulsation->get_value());
|
hegyi@161
|
61 |
}
|
hegyi@161
|
62 |
|
hegyi@161
|
63 |
void DesignWin::emit_iteration()
|
hegyi@161
|
64 |
{
|
hegyi@161
|
65 |
signal_iteration_ch.emit((int)iteration->get_value());
|
hegyi@161
|
66 |
}
|