ladanyi@1442
|
1 |
#include <map_win.h>
|
ladanyi@1442
|
2 |
#include <set>
|
ladanyi@1442
|
3 |
|
hegyi@1524
|
4 |
bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
|
ladanyi@1442
|
5 |
{
|
hegyi@1446
|
6 |
if(e->keyval==GDK_Escape)
|
hegyi@1446
|
7 |
{
|
hegyi@1446
|
8 |
hide();
|
hegyi@1446
|
9 |
}
|
hegyi@1446
|
10 |
return true;
|
hegyi@1446
|
11 |
}
|
ladanyi@1442
|
12 |
|
hegyi@1512
|
13 |
MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
|
hegyi@1446
|
14 |
{
|
hegyi@1446
|
15 |
set_title(title);
|
hegyi@1446
|
16 |
set_default_size(200, 50);
|
ladanyi@1442
|
17 |
|
hegyi@1524
|
18 |
signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
|
ladanyi@1442
|
19 |
|
hegyi@1512
|
20 |
e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
|
hegyi@1446
|
21 |
|
hegyi@1512
|
22 |
table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
|
hegyi@1512
|
23 |
|
hegyi@1512
|
24 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
ladanyi@1442
|
25 |
{
|
hegyi@1446
|
26 |
//filling in combo box with choices
|
hegyi@1446
|
27 |
std::list<Glib::ustring> listStrings;
|
hegyi@1446
|
28 |
|
hegyi@1446
|
29 |
listStrings.push_back("Default");
|
ladanyi@1442
|
30 |
|
hegyi@1525
|
31 |
std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
|
hegyi@1525
|
32 |
for(;emsi!=ms.endOfEdgeMaps();emsi++)
|
ladanyi@1442
|
33 |
{
|
hegyi@1446
|
34 |
listStrings.push_back(emsi->first);
|
ladanyi@1442
|
35 |
}
|
hegyi@1446
|
36 |
|
hegyi@1512
|
37 |
e_combo_array[i].set_popdown_strings(listStrings);
|
hegyi@1446
|
38 |
|
hegyi@1446
|
39 |
//Restrict it to these choices only:
|
hegyi@1512
|
40 |
e_combo_array[i].set_value_in_list();
|
hegyi@1446
|
41 |
|
hegyi@1512
|
42 |
//binding signal to the actual entry
|
hegyi@1512
|
43 |
e_combo_array[i].get_entry()->signal_changed().connect
|
hegyi@1446
|
44 |
(
|
hegyi@1446
|
45 |
sigc::bind
|
hegyi@1446
|
46 |
(
|
hegyi@1524
|
47 |
sigc::mem_fun(*this, &MapWin::eComboChanged),
|
hegyi@1446
|
48 |
i
|
hegyi@1446
|
49 |
)
|
hegyi@1446
|
50 |
);
|
hegyi@1446
|
51 |
|
hegyi@1446
|
52 |
//placing actual entry in the right place
|
hegyi@1446
|
53 |
|
hegyi@1446
|
54 |
label=new Gtk::Label;
|
hegyi@1512
|
55 |
label->set_text(edge_property_strings[i]);
|
hegyi@1512
|
56 |
|
hegyi@1512
|
57 |
(*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@1512
|
58 |
(*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@1446
|
59 |
|
hegyi@1446
|
60 |
|
ladanyi@1442
|
61 |
}
|
ladanyi@1442
|
62 |
|
hegyi@1512
|
63 |
vbox.pack_start(*(new Gtk::Label("Edge properties")));
|
hegyi@1446
|
64 |
|
hegyi@1512
|
65 |
vbox.pack_start(*table);
|
hegyi@1512
|
66 |
|
hegyi@1512
|
67 |
vbox.pack_start(*(new Gtk::HSeparator));
|
hegyi@1512
|
68 |
|
hegyi@1512
|
69 |
n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
|
hegyi@1512
|
70 |
|
hegyi@1512
|
71 |
table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
|
hegyi@1512
|
72 |
|
hegyi@1512
|
73 |
for(int i=0;i<NODE_PROPERTY_NUM;i++)
|
hegyi@1512
|
74 |
{
|
hegyi@1512
|
75 |
//filling in combo box with choices
|
hegyi@1512
|
76 |
std::list<Glib::ustring> listStrings;
|
hegyi@1512
|
77 |
|
hegyi@1512
|
78 |
listStrings.push_back("Default");
|
hegyi@1512
|
79 |
|
hegyi@1525
|
80 |
std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
|
hegyi@1512
|
81 |
|
hegyi@1525
|
82 |
for(;emsi!=ms.endOfNodeMaps();emsi++)
|
hegyi@1512
|
83 |
{
|
hegyi@1525
|
84 |
listStrings.push_back(emsi->first);
|
hegyi@1512
|
85 |
}
|
hegyi@1512
|
86 |
|
hegyi@1512
|
87 |
n_combo_array[i].set_popdown_strings(listStrings);
|
hegyi@1512
|
88 |
|
hegyi@1512
|
89 |
//Restrict it to these choices only:
|
hegyi@1512
|
90 |
n_combo_array[i].set_value_in_list();
|
hegyi@1512
|
91 |
|
hegyi@1512
|
92 |
//binding signal to thew actual entry
|
hegyi@1512
|
93 |
n_combo_array[i].get_entry()->signal_changed().connect
|
hegyi@1512
|
94 |
(
|
hegyi@1512
|
95 |
sigc::bind
|
hegyi@1512
|
96 |
(
|
hegyi@1524
|
97 |
sigc::mem_fun(*this, &MapWin::nComboChanged),
|
hegyi@1512
|
98 |
i
|
hegyi@1512
|
99 |
)
|
hegyi@1512
|
100 |
);
|
hegyi@1512
|
101 |
|
hegyi@1512
|
102 |
//placing actual entry in the right place
|
hegyi@1512
|
103 |
|
hegyi@1512
|
104 |
label=new Gtk::Label;
|
hegyi@1512
|
105 |
label->set_text(node_property_strings[i]);
|
hegyi@1512
|
106 |
|
hegyi@1512
|
107 |
(*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@1512
|
108 |
(*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@1512
|
109 |
|
hegyi@1512
|
110 |
|
hegyi@1512
|
111 |
}
|
hegyi@1512
|
112 |
|
hegyi@1512
|
113 |
add(vbox);
|
hegyi@1512
|
114 |
|
hegyi@1512
|
115 |
vbox.pack_start(*(new Gtk::Label("Node properties")));
|
hegyi@1512
|
116 |
|
hegyi@1512
|
117 |
vbox.pack_start(*table);
|
ladanyi@1442
|
118 |
|
ladanyi@1442
|
119 |
show_all_children();
|
ladanyi@1442
|
120 |
|
ladanyi@1442
|
121 |
}
|
ladanyi@1442
|
122 |
|
hegyi@1524
|
123 |
void MapWin::eComboChanged(int prop)
|
ladanyi@1442
|
124 |
{
|
hegyi@1589
|
125 |
|
hegyi@1512
|
126 |
Gtk::Entry* entry = e_combo_array[prop].get_entry();
|
ladanyi@1442
|
127 |
|
hegyi@1446
|
128 |
if(entry)
|
ladanyi@1442
|
129 |
{
|
hegyi@1446
|
130 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1446
|
131 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1446
|
132 |
{
|
hegyi@1525
|
133 |
if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1446
|
134 |
{
|
hegyi@1446
|
135 |
switch(prop)
|
hegyi@1446
|
136 |
{
|
hegyi@1512
|
137 |
case E_WIDTH:
|
hegyi@1512
|
138 |
gdc.changeEdgeWidth(mapname);
|
hegyi@1446
|
139 |
break;
|
hegyi@1512
|
140 |
case E_COLOR:
|
hegyi@1512
|
141 |
gdc.changeEdgeColor(mapname);
|
hegyi@1446
|
142 |
break;
|
hegyi@1512
|
143 |
case E_TEXT:
|
hegyi@1512
|
144 |
gdc.changeEdgeText(mapname);
|
hegyi@1446
|
145 |
break;
|
hegyi@1446
|
146 |
default:
|
hegyi@1446
|
147 |
std::cout<<"Error\n";
|
hegyi@1446
|
148 |
}
|
hegyi@1446
|
149 |
}
|
ladanyi@1442
|
150 |
}
|
ladanyi@1442
|
151 |
}
|
ladanyi@1442
|
152 |
};
|
hegyi@1512
|
153 |
|
hegyi@1524
|
154 |
void MapWin::nComboChanged(int prop)
|
hegyi@1512
|
155 |
{
|
hegyi@1512
|
156 |
|
hegyi@1512
|
157 |
Gtk::Entry* entry = n_combo_array[prop].get_entry();
|
hegyi@1512
|
158 |
|
hegyi@1512
|
159 |
if(entry)
|
hegyi@1512
|
160 |
{
|
hegyi@1512
|
161 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1512
|
162 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1512
|
163 |
{
|
hegyi@1525
|
164 |
if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1512
|
165 |
{
|
hegyi@1512
|
166 |
switch(prop)
|
hegyi@1512
|
167 |
{
|
hegyi@1512
|
168 |
case N_RADIUS:
|
hegyi@1512
|
169 |
gdc.changeNodeRadius(mapname);
|
hegyi@1512
|
170 |
break;
|
hegyi@1512
|
171 |
case N_COLOR:
|
hegyi@1512
|
172 |
gdc.changeNodeColor(mapname);
|
hegyi@1512
|
173 |
break;
|
hegyi@1512
|
174 |
case N_TEXT:
|
hegyi@1512
|
175 |
gdc.changeNodeText(mapname);
|
hegyi@1512
|
176 |
break;
|
hegyi@1512
|
177 |
default:
|
hegyi@1512
|
178 |
std::cout<<"Error\n";
|
hegyi@1512
|
179 |
}
|
hegyi@1512
|
180 |
}
|
hegyi@1512
|
181 |
}
|
hegyi@1512
|
182 |
}
|
hegyi@1512
|
183 |
};
|
hegyi@1512
|
184 |
|
hegyi@1524
|
185 |
void MapWin::updateNode(Graph::Node node)
|
hegyi@1512
|
186 |
{
|
hegyi@1512
|
187 |
for(int i=0;i<NODE_PROPERTY_NUM;i++)
|
hegyi@1512
|
188 |
{
|
hegyi@1512
|
189 |
Gtk::Entry* entry = n_combo_array[i].get_entry();
|
hegyi@1512
|
190 |
|
hegyi@1512
|
191 |
if(entry)
|
hegyi@1512
|
192 |
{
|
hegyi@1512
|
193 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1512
|
194 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1512
|
195 |
{
|
hegyi@1525
|
196 |
if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1512
|
197 |
{
|
hegyi@1512
|
198 |
switch(i)
|
hegyi@1512
|
199 |
{
|
hegyi@1512
|
200 |
case N_RADIUS:
|
hegyi@1525
|
201 |
gdc.changeNodeRadius(mapname, node);
|
hegyi@1512
|
202 |
break;
|
hegyi@1512
|
203 |
case N_COLOR:
|
hegyi@1512
|
204 |
gdc.changeNodeColor(mapname, node);
|
hegyi@1512
|
205 |
break;
|
hegyi@1512
|
206 |
case N_TEXT:
|
hegyi@1512
|
207 |
gdc.changeNodeText(mapname, node);
|
hegyi@1512
|
208 |
break;
|
hegyi@1512
|
209 |
default:
|
hegyi@1512
|
210 |
std::cout<<"Error\n";
|
hegyi@1512
|
211 |
}
|
hegyi@1512
|
212 |
}
|
hegyi@1512
|
213 |
}
|
hegyi@1512
|
214 |
}
|
hegyi@1512
|
215 |
}
|
hegyi@1512
|
216 |
}
|
hegyi@1512
|
217 |
|
hegyi@1524
|
218 |
void MapWin::updateEdge(Graph::Edge edge)
|
hegyi@1512
|
219 |
{
|
hegyi@1512
|
220 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@1512
|
221 |
{
|
hegyi@1512
|
222 |
|
hegyi@1512
|
223 |
Gtk::Entry* entry = e_combo_array[i].get_entry();
|
hegyi@1512
|
224 |
|
hegyi@1512
|
225 |
if(entry)
|
hegyi@1512
|
226 |
{
|
hegyi@1512
|
227 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1512
|
228 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1512
|
229 |
{
|
hegyi@1512
|
230 |
|
hegyi@1525
|
231 |
if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1512
|
232 |
{
|
hegyi@1512
|
233 |
switch(i)
|
hegyi@1512
|
234 |
{
|
hegyi@1512
|
235 |
case E_WIDTH:
|
hegyi@1525
|
236 |
gdc.changeEdgeWidth(mapname, edge);
|
hegyi@1512
|
237 |
break;
|
hegyi@1512
|
238 |
case E_COLOR:
|
hegyi@1512
|
239 |
gdc.changeEdgeColor(mapname, edge);
|
hegyi@1512
|
240 |
break;
|
hegyi@1512
|
241 |
case E_TEXT:
|
hegyi@1512
|
242 |
gdc.changeEdgeText(mapname, edge);
|
hegyi@1512
|
243 |
break;
|
hegyi@1512
|
244 |
default:
|
hegyi@1512
|
245 |
std::cout<<"Error\n";
|
hegyi@1512
|
246 |
}
|
hegyi@1512
|
247 |
}
|
hegyi@1512
|
248 |
}
|
hegyi@1512
|
249 |
}
|
hegyi@1512
|
250 |
}
|
hegyi@1512
|
251 |
}
|
hegyi@1586
|
252 |
|
hegyi@1589
|
253 |
void MapWin::registerNewEdgeMap(std::string newmapname)
|
hegyi@1586
|
254 |
{
|
hegyi@1589
|
255 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@1589
|
256 |
{
|
hegyi@1589
|
257 |
//filling in combo box with choices
|
hegyi@1589
|
258 |
std::list<Glib::ustring> listStrings=e_combo_array[i].get_popdown_strings();
|
hegyi@1589
|
259 |
listStrings.push_back(newmapname);
|
hegyi@1589
|
260 |
e_combo_array[i].set_popdown_strings(listStrings);
|
hegyi@1589
|
261 |
}
|
hegyi@1589
|
262 |
Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry();
|
hegyi@1589
|
263 |
entry->set_text((Glib::ustring)newmapname);
|
hegyi@1586
|
264 |
}
|
hegyi@1586
|
265 |
|
hegyi@1589
|
266 |
void MapWin::registerNewNodeMap(std::string newmapname)
|
hegyi@1586
|
267 |
{
|
hegyi@1589
|
268 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@1589
|
269 |
{
|
hegyi@1589
|
270 |
//filling in combo box with choices
|
hegyi@1589
|
271 |
std::list<Glib::ustring> listStrings=n_combo_array[i].get_popdown_strings();
|
hegyi@1589
|
272 |
listStrings.push_back(newmapname);
|
hegyi@1589
|
273 |
n_combo_array[i].set_popdown_strings(listStrings);
|
hegyi@1589
|
274 |
}
|
hegyi@1586
|
275 |
}
|