COIN-OR::LEMON - Graph Library

source: glemon-0.x/design_win.cc @ 172:fc1e478697d3

Last change on this file since 172:fc1e478697d3 was 172:fc1e478697d3, checked in by Hegyi Péter, 17 years ago

Currently visualized map can be saved and loaded from file.

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