design_win.cc
changeset 1 67188bd752db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/design_win.cc	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,98 @@
     1.4 +/* -*- C++ -*-
     1.5 + *
     1.6 + * This file is a part of LEMON, a generic C++ optimization library
     1.7 + *
     1.8 + * Copyright (C) 2003-2006
     1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 + *
    1.12 + * Permission to use, modify and distribute this software is granted
    1.13 + * provided that this copyright notice appears in all copies. For
    1.14 + * precise terms see the accompanying LICENSE file.
    1.15 + *
    1.16 + * This software is provided "AS IS" with no warranty of any kind,
    1.17 + * express or implied, and with no claim as to its suitability for any
    1.18 + * purpose.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#include <design_win.h>
    1.23 +
    1.24 +bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
    1.25 +{
    1.26 +  if(e->keyval==GDK_Escape)
    1.27 +  {
    1.28 +    on_hide();
    1.29 +  }
    1.30 +  return true;
    1.31 +}
    1.32 +
    1.33 +DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
    1.34 +{
    1.35 +  set_title(title);
    1.36 +
    1.37 +  //mytab.signal_title_ch().connect(sigc::mem_fun(*this, &DesignWin::set_title));
    1.38 +
    1.39 +  signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
    1.40 +
    1.41 +  Gtk::VBox * vbox=new Gtk::VBox();
    1.42 +  vbox->set_spacing(5);
    1.43 +
    1.44 +  Gtk::Label * attraction_label=new Gtk::Label("Arc elasticity: ");
    1.45 +  Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
    1.46 +  Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
    1.47 +
    1.48 +  Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
    1.49 +  Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
    1.50 +  Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
    1.51 +
    1.52 +  attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
    1.53 +  propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
    1.54 +  iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
    1.55 +
    1.56 +  close_button=new Gtk::Button("Redesign");
    1.57 +
    1.58 +  attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
    1.59 +  propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
    1.60 +  iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
    1.61 +  close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
    1.62 +
    1.63 +  table.attach(*attraction_label,0,1,0,1);
    1.64 +  table.attach(*propulsation_label,0,1,1,2);
    1.65 +  table.attach(*iteration_label,0,1,2,3);
    1.66 +  table.attach(*attraction,1,2,0,1);
    1.67 +  table.attach(*propulsation,1,2,1,2);
    1.68 +  table.attach(*iteration,1,2,2,3);
    1.69 +  table.attach(*close_button,0,2,3,4);
    1.70 +
    1.71 +  add(table);
    1.72 +
    1.73 +  show_all_children();
    1.74 +};
    1.75 +
    1.76 +void DesignWin::emit_attraction()
    1.77 +{
    1.78 +  signal_attraction_ch.emit(attraction->get_value());
    1.79 +}
    1.80 +
    1.81 +void DesignWin::emit_propulsation()
    1.82 +{
    1.83 +  signal_propulsation_ch.emit(propulsation->get_value());
    1.84 +}
    1.85 +
    1.86 +void DesignWin::emit_iteration()
    1.87 +{
    1.88 +  signal_iteration_ch.emit((int)iteration->get_value());
    1.89 +}
    1.90 +
    1.91 +void DesignWin::set_title(std::string tabname)
    1.92 +{
    1.93 +  Gtk::Window::set_title("Design Setup - "+tabname);
    1.94 +}
    1.95 +
    1.96 +void DesignWin::set_data(double attr, double propuls, int it)
    1.97 +{
    1.98 +  attraction->set_value(attr);
    1.99 +  propulsation->set_value(propuls);
   1.100 +  iteration->set_value(it);
   1.101 +}