algowin.cc
author alpar
Mon, 30 Oct 2006 12:16:25 +0000
changeset 174 95872af46fc4
parent 165 2cd447b0bd3a
child 194 6b2b718420eb
permissions -rw-r--r--
Add copyright headers
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@106
    19
#include <algowin.h>
hegyi@106
    20
#include <kruskalbox.h>
hegyi@162
    21
#include <dijkstrabox.h>
hegyi@106
    22
hegyi@106
    23
sigc::signal<void, AlgoWin *> AlgoWin::signal_closing()
hegyi@106
    24
{
hegyi@106
    25
  return signal_closed;
hegyi@106
    26
}
hegyi@106
    27
hegyi@106
    28
sigc::signal<void, AlgoWin *, std::string> AlgoWin::signal_maplist_needed()
hegyi@106
    29
{
hegyi@106
    30
  return signal_maplist_need;
hegyi@106
    31
}
hegyi@106
    32
hegyi@106
    33
bool AlgoWin::closeIfEscapeIsPressed(GdkEventKey* e)
hegyi@106
    34
{
hegyi@106
    35
  if(e->keyval==GDK_Escape)
hegyi@106
    36
  {
hegyi@106
    37
    on_hide();
hegyi@106
    38
  }
hegyi@106
    39
  return true;
hegyi@106
    40
}
hegyi@106
    41
hegyi@108
    42
AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
hegyi@106
    43
{
hegyi@106
    44
  signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
hegyi@106
    45
hegyi@106
    46
  Gtk::VBox * vbox=new Gtk::VBox();
hegyi@106
    47
  vbox->set_spacing(5);
hegyi@106
    48
hegyi@106
    49
  Gtk::Label * label=new Gtk::Label("Select graph:");
hegyi@106
    50
hegyi@106
    51
  switch(algoid)
hegyi@106
    52
    {
hegyi@106
    53
    case 0:
hegyi@108
    54
      ab=new AlgoBox(tabnames);
hegyi@106
    55
      set_title("Algo Win Demo");
hegyi@106
    56
      break;
hegyi@106
    57
    case 1:
hegyi@108
    58
      ab=new KruskalBox(tabnames);
hegyi@106
    59
      set_title("Kruskal Algorithm");
hegyi@106
    60
      break;
hegyi@162
    61
    case 2:
hegyi@162
    62
      ab=new DijkstraBox(tabnames);
hegyi@162
    63
      set_title("Dijkstra Algorithm");
hegyi@162
    64
      break;
hegyi@165
    65
    case 3:
hegyi@165
    66
      ab=new SuurballeBox(tabnames);
hegyi@165
    67
      set_title("Suurballe Algorithm");
hegyi@165
    68
      break;
hegyi@106
    69
    default:
hegyi@106
    70
      break;
hegyi@106
    71
    }
hegyi@106
    72
  ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
hegyi@114
    73
  ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal));
hegyi@106
    74
hegyi@106
    75
  runbutton=new Gtk::Button("Run");
hegyi@106
    76
  runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
hegyi@106
    77
  runbutton->signal_activate().connect(sigc::mem_fun(*ab,&AlgoBox::run));
hegyi@106
    78
hegyi@106
    79
  closebutton=new Gtk::Button("Close");
hegyi@106
    80
  closebutton->signal_released().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
hegyi@106
    81
  closebutton->signal_activate().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
hegyi@106
    82
      
hegyi@106
    83
  Gtk::HBox * hbox=new Gtk::HBox();
hegyi@106
    84
hegyi@106
    85
  hbox->pack_start(*runbutton);
hegyi@106
    86
  hbox->pack_start(*closebutton);
hegyi@106
    87
hegyi@106
    88
  vbox->pack_start(*label);
hegyi@106
    89
  vbox->pack_start(*ab);
hegyi@106
    90
  vbox->pack_start(*hbox);
hegyi@106
    91
      
hegyi@106
    92
  add(*vbox);
hegyi@106
    93
hegyi@106
    94
  show_all_children();
hegyi@106
    95
};
hegyi@106
    96
hegyi@106
    97
void AlgoWin::update_tablist(std::vector<std::string> tabnames)
hegyi@106
    98
{
hegyi@106
    99
  ab->update_tablist(tabnames);
hegyi@106
   100
}
hegyi@106
   101
hegyi@109
   102
void AlgoWin::update_maplist(MapStorage * mapstorage)
hegyi@106
   103
{
hegyi@108
   104
  ab->update_maplist(mapstorage);
hegyi@106
   105
}
hegyi@106
   106
hegyi@106
   107
void AlgoWin::on_hide()
hegyi@106
   108
{
hegyi@106
   109
  signal_closed.emit(this);
hegyi@106
   110
  Gtk::Window::on_hide();
hegyi@106
   111
}
hegyi@106
   112
hegyi@106
   113
void AlgoWin::emit_tab_change(std::string newtab)
hegyi@106
   114
{
hegyi@106
   115
  signal_maplist_need.emit(this, newtab);
hegyi@106
   116
}