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