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