1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/algowin.cc Mon Jul 07 08:10:39 2008 -0500
1.3 @@ -0,0 +1,117 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2006
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#include <algowin.h>
1.23 +#include <algobox.h>
1.24 +#include <kruskalbox.h>
1.25 +#include <dijkstrabox.h>
1.26 +
1.27 +sigc::signal<void, AlgoWin *> AlgoWin::signal_closing()
1.28 +{
1.29 + return signal_closed;
1.30 +}
1.31 +
1.32 +sigc::signal<void, AlgoWin *, std::string> AlgoWin::signal_maplist_needed()
1.33 +{
1.34 + return signal_maplist_need;
1.35 +}
1.36 +
1.37 +bool AlgoWin::closeIfEscapeIsPressed(GdkEventKey* e)
1.38 +{
1.39 + if(e->keyval==GDK_Escape)
1.40 + {
1.41 + on_hide();
1.42 + }
1.43 + return true;
1.44 +}
1.45 +
1.46 +AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
1.47 +{
1.48 + signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
1.49 +
1.50 + Gtk::VBox * vbox=new Gtk::VBox();
1.51 + vbox->set_spacing(5);
1.52 +
1.53 + Gtk::Label * label=new Gtk::Label("Select digraph:");
1.54 +
1.55 + switch(algoid)
1.56 + {
1.57 + case 0:
1.58 + ab=new AlgoBox(tabnames);
1.59 + set_title("Algo Win Demo");
1.60 + break;
1.61 + case 1:
1.62 + ab=new KruskalBox(tabnames);
1.63 + set_title("Kruskal Algorithm");
1.64 + break;
1.65 + case 2:
1.66 + ab=new DijkstraBox(tabnames);
1.67 + set_title("Dijkstra Algorithm");
1.68 + break;
1.69 + case 3:
1.70 + ab=new SuurballeBox(tabnames);
1.71 + set_title("Suurballe Algorithm");
1.72 + break;
1.73 + default:
1.74 + break;
1.75 + }
1.76 + ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
1.77 + ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal));
1.78 +
1.79 + runbutton=new Gtk::Button("Run");
1.80 + runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
1.81 + runbutton->signal_activate().connect(sigc::mem_fun(*ab,&AlgoBox::run));
1.82 +
1.83 + closebutton=new Gtk::Button("Close");
1.84 + closebutton->signal_released().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
1.85 + closebutton->signal_activate().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
1.86 +
1.87 + Gtk::HBox * hbox=new Gtk::HBox();
1.88 +
1.89 + hbox->pack_start(*runbutton);
1.90 + hbox->pack_start(*closebutton);
1.91 +
1.92 + vbox->pack_start(*label);
1.93 + vbox->pack_start(*ab);
1.94 + vbox->pack_start(*hbox);
1.95 +
1.96 + add(*vbox);
1.97 +
1.98 + show_all_children();
1.99 +};
1.100 +
1.101 +void AlgoWin::update_tablist(std::vector<std::string> tabnames)
1.102 +{
1.103 + ab->update_tablist(tabnames);
1.104 +}
1.105 +
1.106 +void AlgoWin::update_maplist(MapStorage * mapstorage)
1.107 +{
1.108 + ab->update_maplist(mapstorage);
1.109 +}
1.110 +
1.111 +void AlgoWin::on_hide()
1.112 +{
1.113 + signal_closed.emit(this);
1.114 + Gtk::Window::on_hide();
1.115 +}
1.116 +
1.117 +void AlgoWin::emit_tab_change(std::string newtab)
1.118 +{
1.119 + signal_maplist_need.emit(this, newtab);
1.120 +}