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 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/design_win.h Thu Oct 12 12:18:20 2006 +0000
2.3 @@ -0,0 +1,43 @@
2.4 +// -*- C++ -*- //
2.5 +
2.6 +#ifndef DESWIN_H
2.7 +#define DESWIN_H
2.8 +
2.9 +#include <all_include.h>
2.10 +#include <libgnomecanvasmm.h>
2.11 +#include <libgnomecanvasmm/polygon.h>
2.12 +
2.13 +class DesignWin : public Gtk::Window
2.14 +{
2.15 +private:
2.16 + Gtk::SpinButton * attraction;
2.17 + Gtk::SpinButton * propulsation;
2.18 + Gtk::SpinButton * iteration;
2.19 + Gtk::Table table;
2.20 + Gtk::Button * close_button;
2.21 +
2.22 + sigc::signal<void, double> signal_attraction_ch;
2.23 + sigc::signal<void, double> signal_propulsation_ch;
2.24 + sigc::signal<void, int> signal_iteration_ch;
2.25 + sigc::signal<void> close_run_pr;
2.26 +
2.27 + void emit_attraction();
2.28 + void emit_propulsation();
2.29 + void emit_iteration();
2.30 + void emit_closerun(){close_run_pr.emit();};
2.31 +
2.32 +public:
2.33 + ///Close window if escape key is pressed.
2.34 + bool closeIfEscapeIsPressed(GdkEventKey* e);
2.35 +
2.36 + ///Constructor
2.37 +
2.38 + ///It builds the window.
2.39 + DesignWin(const std::string&, double, double, int);
2.40 +
2.41 + sigc::signal<void, double> signal_attraction(){return signal_attraction_ch;};
2.42 + sigc::signal<void, double> signal_propulsation(){return signal_propulsation_ch;};
2.43 + sigc::signal<void, int> signal_iteration(){return signal_iteration_ch;};
2.44 + sigc::signal<void> close_run(){return close_run_pr;};
2.45 +};
2.46 +#endif //DESWIN_H