design_win.cc
author hegyi
Wed, 28 Feb 2007 18:20:28 +0000
changeset 194 6b2b718420eb
parent 177 40f3006fba2e
child 196 c220f9de6545
permissions -rw-r--r--
Header reorganising
     1 /* -*- C++ -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     4  *
     5  * Copyright (C) 2003-2006
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #include <nbtab.h>
    20 #include <design_win.h>
    21 
    22 bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
    23 {
    24   if(e->keyval==GDK_Escape)
    25   {
    26     on_hide();
    27   }
    28   return true;
    29 }
    30 
    31 DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v, NoteBookTab & mw):mytab(mw)
    32 {
    33   set_title(title);
    34 
    35   mytab.signal_title_ch().connect(sigc::mem_fun(*this, &DesignWin::set_title));
    36 
    37   signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
    38 
    39   Gtk::VBox * vbox=new Gtk::VBox();
    40   vbox->set_spacing(5);
    41 
    42   Gtk::Label * attraction_label=new Gtk::Label("Edge elasticity: ");
    43   Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
    44   Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
    45 
    46   Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
    47   Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
    48   Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
    49 
    50   attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
    51   propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
    52   iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
    53 
    54   close_button=new Gtk::Button("Redesign");
    55 
    56   attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
    57   propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
    58   iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
    59   close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
    60 
    61   table.attach(*attraction_label,0,1,0,1);
    62   table.attach(*propulsation_label,0,1,1,2);
    63   table.attach(*iteration_label,0,1,2,3);
    64   table.attach(*attraction,1,2,0,1);
    65   table.attach(*propulsation,1,2,1,2);
    66   table.attach(*iteration,1,2,2,3);
    67   table.attach(*close_button,0,2,3,4);
    68 
    69   add(table);
    70 
    71   show_all_children();
    72 };
    73 
    74 void DesignWin::emit_attraction()
    75 {
    76   signal_attraction_ch.emit(attraction->get_value());
    77 }
    78 
    79 void DesignWin::emit_propulsation()
    80 {
    81   signal_propulsation_ch.emit(propulsation->get_value());
    82 }
    83 
    84 void DesignWin::emit_iteration()
    85 {
    86   signal_iteration_ch.emit((int)iteration->get_value());
    87 }
    88 
    89 void DesignWin::set_title(std::string tabname)
    90 {
    91   Gtk::Window::set_title("Design Setup - "+tabname);
    92 }
    93 
    94 void DesignWin::set_data(double attr, double propuls, int it)
    95 {
    96   attraction->set_value(attr);
    97   propulsation->set_value(propuls);
    98   iteration->set_value(it);
    99 }