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@1512
|
125 |
Gtk::Entry* entry = e_combo_array[prop].get_entry();
|
ladanyi@1442
|
126 |
|
hegyi@1446
|
127 |
if(entry)
|
ladanyi@1442
|
128 |
{
|
hegyi@1446
|
129 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1446
|
130 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1446
|
131 |
{
|
hegyi@1525
|
132 |
if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1446
|
133 |
{
|
hegyi@1446
|
134 |
switch(prop)
|
hegyi@1446
|
135 |
{
|
hegyi@1512
|
136 |
case E_WIDTH:
|
hegyi@1512
|
137 |
gdc.changeEdgeWidth(mapname);
|
hegyi@1446
|
138 |
break;
|
hegyi@1512
|
139 |
case E_COLOR:
|
hegyi@1512
|
140 |
gdc.changeEdgeColor(mapname);
|
hegyi@1446
|
141 |
break;
|
hegyi@1512
|
142 |
case E_TEXT:
|
hegyi@1512
|
143 |
gdc.changeEdgeText(mapname);
|
hegyi@1446
|
144 |
break;
|
hegyi@1446
|
145 |
default:
|
hegyi@1446
|
146 |
std::cout<<"Error\n";
|
hegyi@1446
|
147 |
}
|
hegyi@1446
|
148 |
}
|
ladanyi@1442
|
149 |
}
|
ladanyi@1442
|
150 |
}
|
ladanyi@1442
|
151 |
};
|
hegyi@1512
|
152 |
|
hegyi@1524
|
153 |
void MapWin::nComboChanged(int prop)
|
hegyi@1512
|
154 |
{
|
hegyi@1512
|
155 |
|
hegyi@1512
|
156 |
Gtk::Entry* entry = n_combo_array[prop].get_entry();
|
hegyi@1512
|
157 |
|
hegyi@1512
|
158 |
if(entry)
|
hegyi@1512
|
159 |
{
|
hegyi@1512
|
160 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1512
|
161 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1512
|
162 |
{
|
hegyi@1525
|
163 |
if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1512
|
164 |
{
|
hegyi@1512
|
165 |
switch(prop)
|
hegyi@1512
|
166 |
{
|
hegyi@1512
|
167 |
case N_RADIUS:
|
hegyi@1512
|
168 |
gdc.changeNodeRadius(mapname);
|
hegyi@1512
|
169 |
break;
|
hegyi@1512
|
170 |
case N_COLOR:
|
hegyi@1512
|
171 |
gdc.changeNodeColor(mapname);
|
hegyi@1512
|
172 |
break;
|
hegyi@1512
|
173 |
case N_TEXT:
|
hegyi@1512
|
174 |
gdc.changeNodeText(mapname);
|
hegyi@1512
|
175 |
break;
|
hegyi@1512
|
176 |
default:
|
hegyi@1512
|
177 |
std::cout<<"Error\n";
|
hegyi@1512
|
178 |
}
|
hegyi@1512
|
179 |
}
|
hegyi@1512
|
180 |
}
|
hegyi@1512
|
181 |
}
|
hegyi@1512
|
182 |
};
|
hegyi@1512
|
183 |
|
hegyi@1524
|
184 |
void MapWin::updateNode(Graph::Node node)
|
hegyi@1512
|
185 |
{
|
hegyi@1512
|
186 |
for(int i=0;i<NODE_PROPERTY_NUM;i++)
|
hegyi@1512
|
187 |
{
|
hegyi@1512
|
188 |
Gtk::Entry* entry = n_combo_array[i].get_entry();
|
hegyi@1512
|
189 |
|
hegyi@1512
|
190 |
if(entry)
|
hegyi@1512
|
191 |
{
|
hegyi@1512
|
192 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1512
|
193 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1512
|
194 |
{
|
hegyi@1525
|
195 |
if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1512
|
196 |
{
|
hegyi@1512
|
197 |
switch(i)
|
hegyi@1512
|
198 |
{
|
hegyi@1512
|
199 |
case N_RADIUS:
|
hegyi@1525
|
200 |
gdc.changeNodeRadius(mapname, node);
|
hegyi@1512
|
201 |
break;
|
hegyi@1512
|
202 |
case N_COLOR:
|
hegyi@1512
|
203 |
gdc.changeNodeColor(mapname, node);
|
hegyi@1512
|
204 |
break;
|
hegyi@1512
|
205 |
case N_TEXT:
|
hegyi@1512
|
206 |
gdc.changeNodeText(mapname, node);
|
hegyi@1512
|
207 |
break;
|
hegyi@1512
|
208 |
default:
|
hegyi@1512
|
209 |
std::cout<<"Error\n";
|
hegyi@1512
|
210 |
}
|
hegyi@1512
|
211 |
}
|
hegyi@1512
|
212 |
}
|
hegyi@1512
|
213 |
}
|
hegyi@1512
|
214 |
}
|
hegyi@1512
|
215 |
}
|
hegyi@1512
|
216 |
|
hegyi@1524
|
217 |
void MapWin::updateEdge(Graph::Edge edge)
|
hegyi@1512
|
218 |
{
|
hegyi@1512
|
219 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@1512
|
220 |
{
|
hegyi@1512
|
221 |
|
hegyi@1512
|
222 |
Gtk::Entry* entry = e_combo_array[i].get_entry();
|
hegyi@1512
|
223 |
|
hegyi@1512
|
224 |
if(entry)
|
hegyi@1512
|
225 |
{
|
hegyi@1512
|
226 |
Glib::ustring mapname = entry->get_text();
|
hegyi@1512
|
227 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1512
|
228 |
{
|
hegyi@1512
|
229 |
|
hegyi@1525
|
230 |
if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
|
hegyi@1512
|
231 |
{
|
hegyi@1512
|
232 |
switch(i)
|
hegyi@1512
|
233 |
{
|
hegyi@1512
|
234 |
case E_WIDTH:
|
hegyi@1525
|
235 |
gdc.changeEdgeWidth(mapname, edge);
|
hegyi@1512
|
236 |
break;
|
hegyi@1512
|
237 |
case E_COLOR:
|
hegyi@1512
|
238 |
gdc.changeEdgeColor(mapname, edge);
|
hegyi@1512
|
239 |
break;
|
hegyi@1512
|
240 |
case E_TEXT:
|
hegyi@1512
|
241 |
gdc.changeEdgeText(mapname, edge);
|
hegyi@1512
|
242 |
break;
|
hegyi@1512
|
243 |
default:
|
hegyi@1512
|
244 |
std::cout<<"Error\n";
|
hegyi@1512
|
245 |
}
|
hegyi@1512
|
246 |
}
|
hegyi@1512
|
247 |
}
|
hegyi@1512
|
248 |
}
|
hegyi@1512
|
249 |
}
|
hegyi@1512
|
250 |
}
|