COIN-OR::LEMON - Graph Library

source: glemon/design_win.cc @ 6:3a44a2bb6da8

Last change on this file since 6:3a44a2bb6da8 was 1:67188bd752db, checked in by Peter Hegyi <hegyi@…>, 16 years ago

SVN revision 3500 made compilable with Lemon 1.0.

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