design_win.cc
changeset 161 aef1fbfd9d60
child 172 fc1e478697d3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/design_win.cc	Thu Oct 12 12:18:20 2006 +0000
     1.3 @@ -0,0 +1,66 @@
     1.4 +#include <design_win.h>
     1.5 +
     1.6 +bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
     1.7 +{
     1.8 +  if(e->keyval==GDK_Escape)
     1.9 +  {
    1.10 +    on_hide();
    1.11 +  }
    1.12 +  return true;
    1.13 +}
    1.14 +
    1.15 +DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
    1.16 +{
    1.17 +  set_title(title);
    1.18 +
    1.19 +  signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
    1.20 +
    1.21 +  Gtk::VBox * vbox=new Gtk::VBox();
    1.22 +  vbox->set_spacing(5);
    1.23 +
    1.24 +  Gtk::Label * attraction_label=new Gtk::Label("Edge elasticity: ");
    1.25 +  Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
    1.26 +  Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
    1.27 +
    1.28 +  Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
    1.29 +  Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
    1.30 +  Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
    1.31 +
    1.32 +  attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
    1.33 +  propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
    1.34 +  iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
    1.35 +
    1.36 +  close_button=new Gtk::Button("Redesign");
    1.37 +
    1.38 +  attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
    1.39 +  propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
    1.40 +  iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
    1.41 +  close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
    1.42 +
    1.43 +  table.attach(*attraction_label,0,1,0,1);
    1.44 +  table.attach(*propulsation_label,0,1,1,2);
    1.45 +  table.attach(*iteration_label,0,1,2,3);
    1.46 +  table.attach(*attraction,1,2,0,1);
    1.47 +  table.attach(*propulsation,1,2,1,2);
    1.48 +  table.attach(*iteration,1,2,2,3);
    1.49 +  table.attach(*close_button,0,2,3,4);
    1.50 +
    1.51 +  add(table);
    1.52 +
    1.53 +  show_all_children();
    1.54 +};
    1.55 +
    1.56 +void DesignWin::emit_attraction()
    1.57 +{
    1.58 +  signal_attraction_ch.emit(attraction->get_value());
    1.59 +}
    1.60 +
    1.61 +void DesignWin::emit_propulsation()
    1.62 +{
    1.63 +  signal_propulsation_ch.emit(propulsation->get_value());
    1.64 +}
    1.65 +
    1.66 +void DesignWin::emit_iteration()
    1.67 +{
    1.68 +  signal_iteration_ch.emit((int)iteration->get_value());
    1.69 +}