hegyi@42
|
1 |
#include <new_map_win.h>
|
hegyi@42
|
2 |
|
hegyi@42
|
3 |
bool NewMapWin::closeIfEscapeIsPressed(GdkEventKey* e)
|
hegyi@42
|
4 |
{
|
hegyi@42
|
5 |
if(e->keyval==GDK_Escape)
|
hegyi@42
|
6 |
{
|
hegyi@42
|
7 |
hide();
|
hegyi@42
|
8 |
}
|
hegyi@42
|
9 |
return true;
|
hegyi@42
|
10 |
}
|
hegyi@42
|
11 |
|
hegyi@96
|
12 |
NewMapWin::NewMapWin(const std::string& title, NoteBookTab & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mytab(mw),node("Create NodeMap"),edge("Create EdgeMap")
|
hegyi@42
|
13 |
{
|
hegyi@42
|
14 |
set_default_size(200, 50);
|
hegyi@42
|
15 |
|
hegyi@42
|
16 |
signal_key_press_event().connect(sigc::mem_fun(*this, &NewMapWin::closeIfEscapeIsPressed));
|
hegyi@42
|
17 |
|
hegyi@90
|
18 |
Gtk::VBox * vbox=get_vbox();
|
hegyi@42
|
19 |
|
hegyi@42
|
20 |
//entries
|
hegyi@42
|
21 |
table=new Gtk::Table(3, 2, false);
|
hegyi@42
|
22 |
|
hegyi@42
|
23 |
label=new Gtk::Label;
|
hegyi@42
|
24 |
label->set_text("Name of new map:");
|
hegyi@42
|
25 |
name.set_text("");
|
hegyi@42
|
26 |
|
hegyi@42
|
27 |
(*table).attach(*label,0,1,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@42
|
28 |
(*table).attach(name,1,2,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@42
|
29 |
|
hegyi@42
|
30 |
label=new Gtk::Label;
|
hegyi@42
|
31 |
label->set_text("Default value in the map:");
|
hegyi@42
|
32 |
default_value.set_text("0");
|
hegyi@42
|
33 |
|
hegyi@42
|
34 |
(*table).attach(*label,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@42
|
35 |
(*table).attach(default_value,1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@42
|
36 |
|
hegyi@42
|
37 |
//node vs. edge map selector
|
hegyi@42
|
38 |
Gtk::RadioButton::Group group = node.get_group();
|
hegyi@42
|
39 |
edge.set_group(group);
|
hegyi@90
|
40 |
|
hegyi@90
|
41 |
if(edgenode)
|
hegyi@90
|
42 |
{
|
hegyi@90
|
43 |
(*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@90
|
44 |
(*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
|
hegyi@90
|
45 |
}
|
hegyi@90
|
46 |
else
|
hegyi@90
|
47 |
{
|
hegyi@90
|
48 |
if(itisedge)
|
hegyi@90
|
49 |
{
|
hegyi@90
|
50 |
edge.set_active();
|
hegyi@90
|
51 |
}
|
hegyi@90
|
52 |
else
|
hegyi@90
|
53 |
{
|
hegyi@90
|
54 |
node.set_active();
|
hegyi@90
|
55 |
}
|
hegyi@90
|
56 |
}
|
hegyi@42
|
57 |
|
hegyi@90
|
58 |
vbox->pack_start(*table);
|
hegyi@42
|
59 |
|
hegyi@42
|
60 |
//OK button
|
hegyi@90
|
61 |
add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
hegyi@42
|
62 |
|
hegyi@42
|
63 |
show_all_children();
|
hegyi@42
|
64 |
|
hegyi@42
|
65 |
}
|
hegyi@42
|
66 |
|
hegyi@90
|
67 |
void NewMapWin::on_response(int response_id)
|
hegyi@85
|
68 |
{
|
hegyi@90
|
69 |
if(response_id==Gtk::RESPONSE_OK)
|
hegyi@85
|
70 |
{
|
hegyi@90
|
71 |
double def_val=0;
|
hegyi@85
|
72 |
|
hegyi@90
|
73 |
//get and formulate text
|
hegyi@90
|
74 |
std::string def_val_str=default_value.get_text();
|
hegyi@90
|
75 |
std::string polishform=string2Polishform(def_val_str,edge.get_active());
|
hegyi@42
|
76 |
|
hegyi@90
|
77 |
//get name of text
|
hegyi@90
|
78 |
std::string mapname=name.get_text();
|
hegyi@42
|
79 |
|
hegyi@90
|
80 |
if(!mapname.empty()&&!polishform.empty())
|
hegyi@90
|
81 |
{
|
hegyi@90
|
82 |
int abortion=0;
|
hegyi@90
|
83 |
if(edge.get_active())
|
hegyi@90
|
84 |
{
|
hegyi@90
|
85 |
//create the new map
|
hegyi@96
|
86 |
Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mytab.mapstorage.graph);
|
hegyi@42
|
87 |
|
hegyi@90
|
88 |
std::stack<double> polishstack;
|
hegyi@88
|
89 |
|
hegyi@96
|
90 |
for(EdgeIt k(mytab.mapstorage.graph); k!=INVALID; ++k)
|
hegyi@88
|
91 |
{
|
hegyi@90
|
92 |
for(int i=0;i<(int)polishform.size();i++)
|
hegyi@88
|
93 |
{
|
hegyi@90
|
94 |
double op1, op2;
|
hegyi@90
|
95 |
bool operation=true;
|
hegyi@88
|
96 |
switch(polishform[i])
|
hegyi@88
|
97 |
{
|
hegyi@88
|
98 |
case '+':
|
hegyi@88
|
99 |
case '-':
|
hegyi@88
|
100 |
case '/':
|
hegyi@88
|
101 |
case '*':
|
hegyi@90
|
102 |
op1=polishstack.top();
|
hegyi@90
|
103 |
polishstack.pop();
|
hegyi@90
|
104 |
op2=polishstack.top();
|
hegyi@90
|
105 |
polishstack.pop();
|
hegyi@88
|
106 |
break;
|
hegyi@88
|
107 |
default:
|
hegyi@90
|
108 |
//substitute variable
|
hegyi@96
|
109 |
std::map< std::string,Graph::EdgeMap<double> * > ems=mytab.mapstorage.edgemap_storage;
|
hegyi@90
|
110 |
bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
|
hegyi@90
|
111 |
if(itisvar)
|
hegyi@90
|
112 |
{
|
hegyi@96
|
113 |
polishstack.push( (*(mytab.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
|
hegyi@90
|
114 |
}
|
hegyi@90
|
115 |
else
|
hegyi@90
|
116 |
{
|
hegyi@114
|
117 |
polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
|
hegyi@90
|
118 |
}
|
hegyi@90
|
119 |
operation=false;
|
hegyi@88
|
120 |
break;
|
hegyi@88
|
121 |
}
|
hegyi@90
|
122 |
if(operation)
|
hegyi@90
|
123 |
{
|
hegyi@90
|
124 |
double res;
|
hegyi@90
|
125 |
switch(polishform[i])
|
hegyi@90
|
126 |
{
|
hegyi@90
|
127 |
case '+':
|
hegyi@90
|
128 |
res=op1+op2;
|
hegyi@90
|
129 |
break;
|
hegyi@90
|
130 |
case '-':
|
hegyi@90
|
131 |
res=op2-op1;
|
hegyi@90
|
132 |
break;
|
hegyi@90
|
133 |
case '/':
|
hegyi@90
|
134 |
res=op2/op1;
|
hegyi@90
|
135 |
break;
|
hegyi@90
|
136 |
case '*':
|
hegyi@90
|
137 |
res=op1*op2;
|
hegyi@90
|
138 |
break;
|
hegyi@90
|
139 |
default:
|
hegyi@90
|
140 |
std::cout << "How could we get here?" << std::endl;
|
hegyi@90
|
141 |
break;
|
hegyi@90
|
142 |
}
|
hegyi@90
|
143 |
polishstack.push(res);
|
hegyi@90
|
144 |
}
|
hegyi@88
|
145 |
}
|
hegyi@90
|
146 |
(*emptr)[k]=polishstack.top();
|
hegyi@88
|
147 |
}
|
hegyi@90
|
148 |
|
hegyi@90
|
149 |
//if addition was not successful addEdgeMap returns one.
|
hegyi@90
|
150 |
//cause can be that there is already a map named like the new one
|
hegyi@96
|
151 |
if(mytab.mapstorage.addEdgeMap(mapname, emptr, def_val))
|
hegyi@90
|
152 |
{
|
hegyi@90
|
153 |
abortion=1;
|
hegyi@90
|
154 |
}
|
hegyi@90
|
155 |
|
hegyi@90
|
156 |
//add it to the list of the displayable maps
|
hegyi@108
|
157 |
//furthermore it is done by signals
|
hegyi@108
|
158 |
//mytab.registerNewEdgeMap(mapname);
|
hegyi@90
|
159 |
|
hegyi@90
|
160 |
//display it
|
hegyi@94
|
161 |
//gdc.changeEdgeText(mapname);
|
hegyi@109
|
162 |
|
hegyi@109
|
163 |
//delete emptr;
|
hegyi@88
|
164 |
}
|
hegyi@90
|
165 |
else //!edge.get_active()
|
hegyi@90
|
166 |
{
|
hegyi@90
|
167 |
//create the new map
|
hegyi@96
|
168 |
Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mytab.mapstorage.graph);
|
hegyi@88
|
169 |
|
hegyi@90
|
170 |
std::stack<double> polishstack;
|
hegyi@88
|
171 |
|
hegyi@96
|
172 |
for(NodeIt k(mytab.mapstorage.graph); k!=INVALID; ++k)
|
hegyi@88
|
173 |
{
|
hegyi@90
|
174 |
for(int i=0;i<(int)polishform.size();i++)
|
hegyi@88
|
175 |
{
|
hegyi@90
|
176 |
double op1, op2;
|
hegyi@90
|
177 |
bool operation=true;
|
hegyi@88
|
178 |
switch(polishform[i])
|
hegyi@88
|
179 |
{
|
hegyi@88
|
180 |
case '+':
|
hegyi@88
|
181 |
case '-':
|
hegyi@88
|
182 |
case '/':
|
hegyi@88
|
183 |
case '*':
|
hegyi@90
|
184 |
op1=polishstack.top();
|
hegyi@90
|
185 |
polishstack.pop();
|
hegyi@90
|
186 |
op2=polishstack.top();
|
hegyi@90
|
187 |
polishstack.pop();
|
hegyi@88
|
188 |
break;
|
hegyi@88
|
189 |
default:
|
hegyi@96
|
190 |
std::map< std::string,Graph::NodeMap<double> * > nms=mytab.mapstorage.nodemap_storage;
|
hegyi@90
|
191 |
bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
|
hegyi@90
|
192 |
if(itisvar)
|
hegyi@90
|
193 |
{
|
hegyi@96
|
194 |
polishstack.push( (*(mytab.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
|
hegyi@90
|
195 |
}
|
hegyi@90
|
196 |
else
|
hegyi@90
|
197 |
{
|
hegyi@114
|
198 |
polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
|
hegyi@90
|
199 |
}
|
hegyi@90
|
200 |
operation=false;
|
hegyi@88
|
201 |
break;
|
hegyi@88
|
202 |
}
|
hegyi@90
|
203 |
if(operation)
|
hegyi@90
|
204 |
{
|
hegyi@90
|
205 |
double res;
|
hegyi@90
|
206 |
switch(polishform[i])
|
hegyi@90
|
207 |
{
|
hegyi@90
|
208 |
case '+':
|
hegyi@90
|
209 |
res=op1+op2;
|
hegyi@90
|
210 |
break;
|
hegyi@90
|
211 |
case '-':
|
hegyi@90
|
212 |
res=op2-op1;
|
hegyi@90
|
213 |
break;
|
hegyi@90
|
214 |
case '/':
|
hegyi@90
|
215 |
res=op2/op1;
|
hegyi@90
|
216 |
break;
|
hegyi@90
|
217 |
case '*':
|
hegyi@90
|
218 |
res=op1*op2;
|
hegyi@90
|
219 |
break;
|
hegyi@90
|
220 |
default:
|
hegyi@90
|
221 |
std::cout << "How could we get here?" << std::endl;
|
hegyi@90
|
222 |
break;
|
hegyi@90
|
223 |
}
|
hegyi@90
|
224 |
polishstack.push(res);
|
hegyi@90
|
225 |
}
|
hegyi@88
|
226 |
}
|
hegyi@90
|
227 |
(*emptr)[k]=polishstack.top();
|
hegyi@88
|
228 |
}
|
hegyi@90
|
229 |
|
hegyi@90
|
230 |
//if addition was not successful addNodeMap returns one.
|
hegyi@90
|
231 |
//cause can be that there is already a map named like the new one
|
hegyi@96
|
232 |
if(mytab.mapstorage.addNodeMap(mapname,emptr, def_val))
|
hegyi@90
|
233 |
{
|
hegyi@90
|
234 |
abortion=1;
|
hegyi@90
|
235 |
}
|
hegyi@90
|
236 |
|
hegyi@90
|
237 |
//add it to the list of the displayable maps
|
hegyi@108
|
238 |
//furthermore it is done by signals
|
hegyi@108
|
239 |
//mytab.registerNewNodeMap(mapname);
|
hegyi@90
|
240 |
|
hegyi@90
|
241 |
//display it
|
hegyi@90
|
242 |
//gdc.changeNodeText(mapname);
|
hegyi@109
|
243 |
|
hegyi@109
|
244 |
//delete emptr;
|
hegyi@88
|
245 |
}
|
hegyi@90
|
246 |
if(!abortion)
|
hegyi@88
|
247 |
{
|
hegyi@90
|
248 |
name.set_text("");
|
hegyi@90
|
249 |
default_value.set_text("0");
|
hegyi@90
|
250 |
edge.show();
|
hegyi@90
|
251 |
node.show();
|
hegyi@90
|
252 |
hide();
|
hegyi@88
|
253 |
}
|
hegyi@46
|
254 |
}
|
hegyi@42
|
255 |
}
|
hegyi@42
|
256 |
}
|
hegyi@42
|
257 |
|
hegyi@90
|
258 |
|
hegyi@88
|
259 |
std::string NewMapWin::string2Polishform(std::string rawcommand, bool itisedge)
|
hegyi@88
|
260 |
{
|
hegyi@88
|
261 |
bool valid_entry=true;
|
hegyi@88
|
262 |
|
hegyi@88
|
263 |
std::map<std::string, int> str2i;
|
hegyi@88
|
264 |
|
hegyi@88
|
265 |
std::string command;
|
hegyi@88
|
266 |
|
hegyi@88
|
267 |
std::string variable;
|
hegyi@88
|
268 |
|
hegyi@88
|
269 |
char index='a';
|
hegyi@88
|
270 |
|
hegyi@88
|
271 |
for(int i=0;(valid_entry&&(i<(int)rawcommand.size()));i++)
|
hegyi@88
|
272 |
{
|
hegyi@88
|
273 |
switch(rawcommand[i])
|
hegyi@88
|
274 |
{
|
hegyi@88
|
275 |
case '+':
|
hegyi@88
|
276 |
case '-':
|
hegyi@88
|
277 |
case '*':
|
hegyi@88
|
278 |
case '/':
|
hegyi@88
|
279 |
case ')':
|
hegyi@88
|
280 |
case '(':
|
hegyi@88
|
281 |
if(!variable.empty())
|
hegyi@88
|
282 |
{
|
hegyi@88
|
283 |
valid_entry=validVariable(variable, itisedge);
|
hegyi@88
|
284 |
ch2var[index]=variable;
|
hegyi@88
|
285 |
command+=index;
|
hegyi@88
|
286 |
index++;
|
hegyi@88
|
287 |
variable.erase(0,variable.size());
|
hegyi@88
|
288 |
}
|
hegyi@88
|
289 |
command+=rawcommand[i];
|
hegyi@88
|
290 |
break;
|
hegyi@88
|
291 |
default:
|
hegyi@88
|
292 |
variable+=rawcommand[i];
|
hegyi@88
|
293 |
break;
|
hegyi@88
|
294 |
}
|
hegyi@88
|
295 |
}
|
hegyi@88
|
296 |
|
hegyi@88
|
297 |
if(!variable.empty()&&valid_entry)
|
hegyi@88
|
298 |
{
|
hegyi@88
|
299 |
valid_entry=validVariable(variable, itisedge);
|
hegyi@88
|
300 |
ch2var[index]=variable;
|
hegyi@88
|
301 |
command+=index;
|
hegyi@88
|
302 |
index++;
|
hegyi@88
|
303 |
variable.erase(0,variable.size());
|
hegyi@88
|
304 |
}
|
hegyi@88
|
305 |
|
hegyi@88
|
306 |
if(valid_entry)
|
hegyi@88
|
307 |
{
|
hegyi@88
|
308 |
unsigned int pr=10000;
|
hegyi@88
|
309 |
bool prevmult=false;
|
hegyi@89
|
310 |
unsigned int prev_change=pr;
|
hegyi@89
|
311 |
unsigned int prev_br=pr;
|
hegyi@88
|
312 |
int counter=0;
|
hegyi@88
|
313 |
std::string comm_nobr="";
|
hegyi@88
|
314 |
std::vector<unsigned int> p;
|
hegyi@88
|
315 |
p.resize(counter+1);
|
hegyi@88
|
316 |
|
hegyi@88
|
317 |
//limits
|
hegyi@88
|
318 |
//6 brackets embedded
|
hegyi@88
|
319 |
//100 operation in a row from the same priority
|
hegyi@88
|
320 |
|
hegyi@88
|
321 |
for(int i=0;i<(int)command.size();i++)
|
hegyi@88
|
322 |
{
|
hegyi@88
|
323 |
bool put_in_string=true;
|
hegyi@88
|
324 |
switch(command[i])
|
hegyi@88
|
325 |
{
|
hegyi@88
|
326 |
case '(':
|
hegyi@88
|
327 |
pr=prev_br+10000;
|
hegyi@88
|
328 |
prev_br=pr;
|
hegyi@88
|
329 |
prevmult=false;
|
hegyi@88
|
330 |
put_in_string=false;
|
hegyi@88
|
331 |
break;
|
hegyi@88
|
332 |
case ')':
|
hegyi@88
|
333 |
pr=prev_br-10000;
|
hegyi@88
|
334 |
prev_br=pr;
|
hegyi@88
|
335 |
prevmult=false;
|
hegyi@88
|
336 |
put_in_string=false;
|
hegyi@88
|
337 |
break;
|
hegyi@88
|
338 |
case '+':
|
hegyi@88
|
339 |
case '-':
|
hegyi@88
|
340 |
if(prevmult)
|
hegyi@88
|
341 |
{
|
hegyi@88
|
342 |
pr=prev_change;
|
hegyi@88
|
343 |
}
|
hegyi@88
|
344 |
p[counter]=pr;
|
hegyi@88
|
345 |
pr-=100;
|
hegyi@88
|
346 |
|
hegyi@88
|
347 |
prevmult=false;
|
hegyi@88
|
348 |
break;
|
hegyi@88
|
349 |
case '/':
|
hegyi@88
|
350 |
case '*':
|
hegyi@88
|
351 |
if(!prevmult)
|
hegyi@88
|
352 |
{
|
hegyi@88
|
353 |
prev_change=pr;
|
hegyi@88
|
354 |
pr+=200;
|
hegyi@88
|
355 |
pr-=1;
|
hegyi@88
|
356 |
}
|
hegyi@88
|
357 |
p[counter]=pr;
|
hegyi@88
|
358 |
pr-=1;
|
hegyi@88
|
359 |
prevmult=true;
|
hegyi@88
|
360 |
break;
|
hegyi@88
|
361 |
default:
|
hegyi@88
|
362 |
p[counter]=65000;
|
hegyi@88
|
363 |
break;
|
hegyi@88
|
364 |
}
|
hegyi@88
|
365 |
if(put_in_string)
|
hegyi@88
|
366 |
{
|
hegyi@88
|
367 |
counter++;
|
hegyi@88
|
368 |
p.resize(counter+1);
|
hegyi@88
|
369 |
comm_nobr=comm_nobr+command[i];
|
hegyi@88
|
370 |
}
|
hegyi@88
|
371 |
}
|
hegyi@88
|
372 |
|
hegyi@88
|
373 |
tree_node * root=weightedString2Tree(comm_nobr, p, 0);
|
hegyi@88
|
374 |
|
hegyi@88
|
375 |
std::string polishform=postOrder(root);
|
hegyi@88
|
376 |
|
hegyi@88
|
377 |
return polishform;
|
hegyi@88
|
378 |
}
|
hegyi@88
|
379 |
return "";
|
hegyi@88
|
380 |
}
|
hegyi@88
|
381 |
|
hegyi@88
|
382 |
NewMapWin::tree_node * NewMapWin::weightedString2Tree(std::string to_tree, std::vector<unsigned int> & p, int offset)
|
hegyi@88
|
383 |
{
|
hegyi@89
|
384 |
unsigned int min=p[offset];
|
hegyi@88
|
385 |
int minplace=0;
|
hegyi@88
|
386 |
for(int i=0;i<(int)to_tree.size();i++)
|
hegyi@88
|
387 |
{
|
hegyi@88
|
388 |
if(min>p[offset+i])
|
hegyi@88
|
389 |
{
|
hegyi@88
|
390 |
min=p[offset+i];
|
hegyi@88
|
391 |
minplace=i;
|
hegyi@88
|
392 |
}
|
hegyi@88
|
393 |
}
|
hegyi@88
|
394 |
tree_node * act_node=new tree_node;
|
hegyi@88
|
395 |
act_node->ch=to_tree[minplace];
|
hegyi@88
|
396 |
if(to_tree.size()>=3)
|
hegyi@88
|
397 |
{
|
hegyi@88
|
398 |
act_node->left_child=weightedString2Tree(to_tree.substr(0,minplace), p, offset);
|
hegyi@88
|
399 |
act_node->right_child=weightedString2Tree(to_tree.substr(minplace+1,to_tree.size()-minplace-1), p, offset+minplace+1);
|
hegyi@88
|
400 |
}
|
hegyi@88
|
401 |
else
|
hegyi@88
|
402 |
{
|
hegyi@88
|
403 |
act_node->left_child=NULL;
|
hegyi@88
|
404 |
act_node->right_child=NULL;
|
hegyi@88
|
405 |
}
|
hegyi@88
|
406 |
return act_node;
|
hegyi@88
|
407 |
}
|
hegyi@88
|
408 |
|
hegyi@88
|
409 |
std::string NewMapWin::postOrder(tree_node * subtree)
|
hegyi@88
|
410 |
{
|
hegyi@88
|
411 |
std::string subtree_to_string;
|
hegyi@88
|
412 |
if(subtree->left_child)
|
hegyi@88
|
413 |
{
|
hegyi@88
|
414 |
subtree_to_string=postOrder(subtree->left_child);
|
hegyi@88
|
415 |
}
|
hegyi@88
|
416 |
if(subtree->right_child)
|
hegyi@88
|
417 |
{
|
hegyi@88
|
418 |
subtree_to_string=subtree_to_string+postOrder(subtree->right_child);
|
hegyi@88
|
419 |
}
|
hegyi@88
|
420 |
subtree_to_string=subtree_to_string+subtree->ch;
|
hegyi@88
|
421 |
return subtree_to_string;
|
hegyi@88
|
422 |
}
|
hegyi@88
|
423 |
|
hegyi@88
|
424 |
bool NewMapWin::validVariable(std::string variable, bool itisedge)
|
hegyi@88
|
425 |
{
|
hegyi@88
|
426 |
bool cancel;
|
hegyi@88
|
427 |
//is it mapname?
|
hegyi@88
|
428 |
if(itisedge)
|
hegyi@88
|
429 |
{
|
hegyi@96
|
430 |
cancel=(mytab.mapstorage.edgemap_storage.find(variable)==mytab.mapstorage.edgemap_storage.end());
|
hegyi@88
|
431 |
}
|
hegyi@88
|
432 |
else
|
hegyi@88
|
433 |
{
|
hegyi@96
|
434 |
cancel=(mytab.mapstorage.nodemap_storage.find(variable)==mytab.mapstorage.nodemap_storage.end());
|
hegyi@88
|
435 |
}
|
hegyi@88
|
436 |
//maybe it is number
|
hegyi@88
|
437 |
int point_num=0;
|
hegyi@88
|
438 |
if(cancel)
|
hegyi@88
|
439 |
{
|
hegyi@88
|
440 |
cancel=false;
|
hegyi@88
|
441 |
for(int j=0;(!cancel)&&(j<(int)variable.size());j++)
|
hegyi@88
|
442 |
{
|
hegyi@88
|
443 |
if(((variable[j]<'0')||(variable[j]>'9'))&&(variable[j]!='.'))
|
hegyi@88
|
444 |
{
|
hegyi@88
|
445 |
cancel=true;
|
hegyi@88
|
446 |
}
|
hegyi@88
|
447 |
else
|
hegyi@88
|
448 |
{
|
hegyi@88
|
449 |
if(variable[j]=='.')
|
hegyi@88
|
450 |
{
|
hegyi@88
|
451 |
point_num++;
|
hegyi@88
|
452 |
if(point_num>1)
|
hegyi@88
|
453 |
{
|
hegyi@88
|
454 |
cancel=true;
|
hegyi@88
|
455 |
}
|
hegyi@88
|
456 |
}
|
hegyi@88
|
457 |
}
|
hegyi@88
|
458 |
}
|
hegyi@88
|
459 |
}
|
hegyi@88
|
460 |
if(cancel)
|
hegyi@88
|
461 |
{
|
hegyi@88
|
462 |
return false;
|
hegyi@88
|
463 |
}
|
hegyi@88
|
464 |
return true;
|
hegyi@88
|
465 |
}
|