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