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
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@194
    19
#include <nbtab.h>
hegyi@161
    20
#include <design_win.h>
hegyi@161
    21
hegyi@161
    22
bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
hegyi@161
    23
{
hegyi@161
    24
  if(e->keyval==GDK_Escape)
hegyi@161
    25
  {
hegyi@161
    26
    on_hide();
hegyi@161
    27
  }
hegyi@161
    28
  return true;
hegyi@161
    29
}
hegyi@161
    30
hegyi@172
    31
DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v, NoteBookTab & mw):mytab(mw)
hegyi@161
    32
{
hegyi@161
    33
  set_title(title);
hegyi@161
    34
hegyi@172
    35
  mytab.signal_title_ch().connect(sigc::mem_fun(*this, &DesignWin::set_title));
hegyi@172
    36
hegyi@161
    37
  signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
hegyi@161
    38
hegyi@161
    39
  Gtk::VBox * vbox=new Gtk::VBox();
hegyi@161
    40
  vbox->set_spacing(5);
hegyi@161
    41
hegyi@161
    42
  Gtk::Label * attraction_label=new Gtk::Label("Edge elasticity: ");
hegyi@161
    43
  Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
hegyi@161
    44
  Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
hegyi@161
    45
hegyi@161
    46
  Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
hegyi@161
    47
  Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
hegyi@161
    48
  Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
hegyi@161
    49
hegyi@161
    50
  attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
hegyi@161
    51
  propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
hegyi@161
    52
  iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
hegyi@161
    53
hegyi@161
    54
  close_button=new Gtk::Button("Redesign");
hegyi@161
    55
hegyi@161
    56
  attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
hegyi@161
    57
  propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
hegyi@161
    58
  iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
hegyi@161
    59
  close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
hegyi@161
    60
hegyi@161
    61
  table.attach(*attraction_label,0,1,0,1);
hegyi@161
    62
  table.attach(*propulsation_label,0,1,1,2);
hegyi@161
    63
  table.attach(*iteration_label,0,1,2,3);
hegyi@161
    64
  table.attach(*attraction,1,2,0,1);
hegyi@161
    65
  table.attach(*propulsation,1,2,1,2);
hegyi@161
    66
  table.attach(*iteration,1,2,2,3);
hegyi@161
    67
  table.attach(*close_button,0,2,3,4);
hegyi@161
    68
hegyi@161
    69
  add(table);
hegyi@161
    70
hegyi@161
    71
  show_all_children();
hegyi@161
    72
};
hegyi@161
    73
hegyi@161
    74
void DesignWin::emit_attraction()
hegyi@161
    75
{
hegyi@161
    76
  signal_attraction_ch.emit(attraction->get_value());
hegyi@161
    77
}
hegyi@161
    78
hegyi@161
    79
void DesignWin::emit_propulsation()
hegyi@161
    80
{
hegyi@161
    81
  signal_propulsation_ch.emit(propulsation->get_value());
hegyi@161
    82
}
hegyi@161
    83
hegyi@161
    84
void DesignWin::emit_iteration()
hegyi@161
    85
{
hegyi@161
    86
  signal_iteration_ch.emit((int)iteration->get_value());
hegyi@161
    87
}
hegyi@172
    88
hegyi@172
    89
void DesignWin::set_title(std::string tabname)
hegyi@172
    90
{
hegyi@172
    91
  Gtk::Window::set_title("Design Setup - "+tabname);
hegyi@172
    92
}
hegyi@177
    93
hegyi@177
    94
void DesignWin::set_data(double attr, double propuls, int it)
hegyi@177
    95
{
hegyi@177
    96
  attraction->set_value(attr);
hegyi@177
    97
  propulsation->set_value(propuls);
hegyi@177
    98
  iteration->set_value(it);
hegyi@177
    99
}