[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 | |
---|
[194] | 19 | #include <map_win.h> |
---|
| 20 | #include <nbtab.h> |
---|
| 21 | #include <mapselector.h> |
---|
[6] | 22 | #include <set> |
---|
| 23 | |
---|
[30] | 24 | bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e) |
---|
[6] | 25 | { |
---|
[8] | 26 | if(e->keyval==GDK_Escape) |
---|
| 27 | { |
---|
[96] | 28 | mytab.closeMapWin(); |
---|
[95] | 29 | // hide(); |
---|
[8] | 30 | } |
---|
| 31 | return true; |
---|
| 32 | } |
---|
[6] | 33 | |
---|
[96] | 34 | MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw) |
---|
[8] | 35 | { |
---|
| 36 | set_title(title); |
---|
| 37 | set_default_size(200, 50); |
---|
[6] | 38 | |
---|
[146] | 39 | set_resizable(false); |
---|
| 40 | |
---|
[30] | 41 | signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed)); |
---|
[6] | 42 | |
---|
[172] | 43 | mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title)); |
---|
| 44 | |
---|
[81] | 45 | e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM]; |
---|
[8] | 46 | |
---|
[81] | 47 | table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false); |
---|
[28] | 48 | |
---|
| 49 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
[6] | 50 | { |
---|
[114] | 51 | e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true); |
---|
[8] | 52 | |
---|
[81] | 53 | (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); |
---|
[94] | 54 | |
---|
| 55 | e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i)); |
---|
[121] | 56 | e_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded)); |
---|
[6] | 57 | } |
---|
| 58 | |
---|
[28] | 59 | vbox.pack_start(*(new Gtk::Label("Edge properties"))); |
---|
[8] | 60 | |
---|
[28] | 61 | vbox.pack_start(*table); |
---|
| 62 | |
---|
| 63 | vbox.pack_start(*(new Gtk::HSeparator)); |
---|
| 64 | |
---|
[81] | 65 | n_combo_array=new MapSelector * [NODE_PROPERTY_NUM]; |
---|
[28] | 66 | |
---|
[81] | 67 | table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false); |
---|
[28] | 68 | |
---|
| 69 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 70 | { |
---|
[114] | 71 | n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false); |
---|
[28] | 72 | |
---|
[81] | 73 | (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); |
---|
[94] | 74 | |
---|
| 75 | n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i)); |
---|
[121] | 76 | n_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded)); |
---|
[28] | 77 | } |
---|
| 78 | |
---|
| 79 | add(vbox); |
---|
| 80 | |
---|
| 81 | vbox.pack_start(*(new Gtk::Label("Node properties"))); |
---|
| 82 | |
---|
| 83 | vbox.pack_start(*table); |
---|
[6] | 84 | |
---|
| 85 | show_all_children(); |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|
[94] | 89 | void MapWin::nodeMapChanged(std::string mapname, int prop) |
---|
| 90 | { |
---|
[96] | 91 | mytab.propertyChange(false, prop, mapname); |
---|
[94] | 92 | } |
---|
| 93 | |
---|
| 94 | void MapWin::edgeMapChanged(std::string mapname, int prop) |
---|
| 95 | { |
---|
[96] | 96 | mytab.propertyChange(true, prop, mapname); |
---|
[94] | 97 | } |
---|
| 98 | |
---|
[121] | 99 | void MapWin::newMapWinNeeded(bool itisedge) |
---|
[94] | 100 | { |
---|
[121] | 101 | mytab.popupNewMapWin(itisedge); |
---|
[94] | 102 | } |
---|
| 103 | |
---|
| 104 | void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml) |
---|
[53] | 105 | { |
---|
| 106 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 107 | { |
---|
[94] | 108 | e_combo_array[i]->update_list(eml); |
---|
[81] | 109 | } |
---|
[53] | 110 | |
---|
| 111 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 112 | { |
---|
[94] | 113 | n_combo_array[i]->update_list(nml); |
---|
[53] | 114 | } |
---|
[172] | 115 | |
---|
| 116 | mytab.active_maps_needed(); |
---|
[53] | 117 | } |
---|
| 118 | |
---|
[40] | 119 | void MapWin::registerNewEdgeMap(std::string newmapname) |
---|
[38] | 120 | { |
---|
[40] | 121 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 122 | { |
---|
| 123 | //filling in combo box with choices |
---|
[81] | 124 | e_combo_array[i]->append_text((Glib::ustring)newmapname); |
---|
[40] | 125 | } |
---|
[38] | 126 | } |
---|
| 127 | |
---|
[40] | 128 | void MapWin::registerNewNodeMap(std::string newmapname) |
---|
[38] | 129 | { |
---|
[41] | 130 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
[40] | 131 | { |
---|
| 132 | //filling in combo box with choices |
---|
[82] | 133 | n_combo_array[i]->append_text((Glib::ustring)newmapname); |
---|
[40] | 134 | } |
---|
[38] | 135 | } |
---|
[95] | 136 | |
---|
| 137 | bool MapWin::on_delete_event(GdkEventAny * event) |
---|
| 138 | { |
---|
| 139 | event=event; |
---|
[96] | 140 | mytab.closeMapWin(); |
---|
[95] | 141 | return true; |
---|
| 142 | } |
---|
[172] | 143 | |
---|
| 144 | void MapWin::changeEntry(bool isitedge, int prop, std::string mapname) |
---|
| 145 | { |
---|
| 146 | if(isitedge) |
---|
| 147 | { |
---|
| 148 | e_combo_array[prop]->set_active_text(mapname); |
---|
| 149 | } |
---|
| 150 | else |
---|
| 151 | { |
---|
| 152 | n_combo_array[prop]->set_active_text(mapname); |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | void MapWin::set_title(std::string tabname) |
---|
| 157 | { |
---|
| 158 | Gtk::Window::set_title("Map Setup - "+tabname); |
---|
| 159 | } |
---|