Suurballe algorithm is implemented in glemon.
1 #include <design_win.h>
3 bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
5 if(e->keyval==GDK_Escape)
12 DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
16 signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
18 Gtk::VBox * vbox=new Gtk::VBox();
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: ");
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);
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);
33 close_button=new Gtk::Button("Redesign");
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));
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);
53 void DesignWin::emit_attraction()
55 signal_attraction_ch.emit(attraction->get_value());
58 void DesignWin::emit_propulsation()
60 signal_propulsation_ch.emit(propulsation->get_value());
63 void DesignWin::emit_iteration()
65 signal_iteration_ch.emit((int)iteration->get_value());