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