[1606] | 1 | #include "graph_displayer_canvas.h" |
---|
| 2 | #include "broken_edge.h" |
---|
[1510] | 3 | #include <math.h> |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | bool GraphDisplayerCanvas::on_expose_event(GdkEventExpose *event) |
---|
| 7 | { |
---|
| 8 | Gnome::Canvas::CanvasAA::on_expose_event(event); |
---|
| 9 | //usleep(10000); |
---|
| 10 | //rezoom(); |
---|
| 11 | return true; |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | void GraphDisplayerCanvas::changeEditorialTool(int newtool) |
---|
| 15 | { |
---|
[1562] | 16 | if(actual_tool!=newtool) |
---|
| 17 | { |
---|
[1510] | 18 | |
---|
[1562] | 19 | actual_handler.disconnect(); |
---|
[1510] | 20 | |
---|
[1562] | 21 | switch(actual_tool) |
---|
| 22 | { |
---|
| 23 | case CREATE_EDGE: |
---|
| 24 | { |
---|
| 25 | GdkEvent * generated=new GdkEvent(); |
---|
| 26 | generated->type=GDK_BUTTON_RELEASE; |
---|
| 27 | generated->button.button=3; |
---|
| 28 | createEdgeEventHandler(generated); |
---|
| 29 | break; |
---|
| 30 | } |
---|
| 31 | case EDGE_MAP_EDIT: |
---|
[1579] | 32 | //has to do the same thing as in the case of NODE_MAP_EDIT |
---|
| 33 | case NODE_MAP_EDIT: |
---|
| 34 | { |
---|
| 35 | GdkEvent * generated=new GdkEvent(); |
---|
| 36 | generated->type=GDK_KEY_PRESS; |
---|
| 37 | ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; |
---|
| 38 | entryWidgetChangeHandler(generated); |
---|
| 39 | entrywidget.hide(); |
---|
| 40 | break; |
---|
| 41 | } |
---|
[1562] | 42 | default: |
---|
| 43 | break; |
---|
| 44 | } |
---|
[1510] | 45 | |
---|
[1562] | 46 | active_item=NULL; |
---|
| 47 | target_item=NULL; |
---|
| 48 | active_edge=INVALID; |
---|
| 49 | active_node=INVALID; |
---|
[1551] | 50 | |
---|
[1510] | 51 | |
---|
[1562] | 52 | actual_tool=newtool; |
---|
| 53 | |
---|
| 54 | switch(newtool) |
---|
| 55 | { |
---|
| 56 | case MOVE: |
---|
| 57 | actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); |
---|
| 58 | break; |
---|
[1510] | 59 | |
---|
[1562] | 60 | case CREATE_NODE: |
---|
| 61 | actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false); |
---|
| 62 | break; |
---|
[1510] | 63 | |
---|
[1562] | 64 | case CREATE_EDGE: |
---|
| 65 | actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false); |
---|
| 66 | break; |
---|
[1510] | 67 | |
---|
[1562] | 68 | case ERASER: |
---|
| 69 | actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false); |
---|
| 70 | break; |
---|
[1550] | 71 | |
---|
[1562] | 72 | case EDGE_MAP_EDIT: |
---|
| 73 | grab_focus(); |
---|
| 74 | actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false); |
---|
| 75 | break; |
---|
[1550] | 76 | |
---|
[1562] | 77 | case NODE_MAP_EDIT: |
---|
| 78 | actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false); |
---|
| 79 | break; |
---|
| 80 | |
---|
| 81 | default: |
---|
| 82 | break; |
---|
| 83 | } |
---|
[1510] | 84 | } |
---|
| 85 | } |
---|
| 86 | |
---|
[1524] | 87 | int GraphDisplayerCanvas::getActualTool() |
---|
[1510] | 88 | { |
---|
| 89 | return actual_tool; |
---|
| 90 | } |
---|
| 91 | |
---|
[1524] | 92 | bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e) |
---|
[1510] | 93 | { |
---|
| 94 | switch(e->type) |
---|
| 95 | { |
---|
| 96 | case GDK_BUTTON_PRESS: |
---|
| 97 | //we mark the location of the event to be able to calculate parameters of dragging |
---|
[1525] | 98 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 99 | |
---|
| 100 | active_item=(get_item_at(clicked_x, clicked_y)); |
---|
[1510] | 101 | active_node=INVALID; |
---|
[1606] | 102 | for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1510] | 103 | { |
---|
| 104 | if(nodesmap[i]==active_item) |
---|
| 105 | { |
---|
| 106 | active_node=i; |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | switch(e->button.button) |
---|
| 110 | { |
---|
| 111 | case 3: |
---|
| 112 | isbutton=3; |
---|
| 113 | break; |
---|
| 114 | default: |
---|
| 115 | isbutton=1; |
---|
| 116 | break; |
---|
| 117 | } |
---|
| 118 | break; |
---|
| 119 | case GDK_BUTTON_RELEASE: |
---|
| 120 | isbutton=0; |
---|
| 121 | active_item=NULL; |
---|
| 122 | active_node=INVALID; |
---|
| 123 | break; |
---|
| 124 | case GDK_MOTION_NOTIFY: |
---|
| 125 | //we only have to do sg. if the mouse button is pressed AND the click was on a node that was found in the set of nodes |
---|
| 126 | if(active_node!=INVALID) |
---|
| 127 | { |
---|
[1606] | 128 | mapstorage.modified = true; |
---|
| 129 | mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y)); |
---|
[1510] | 130 | //new coordinates will be the old values, |
---|
| 131 | //because the item will be moved to the |
---|
| 132 | //new coordinate therefore the new movement |
---|
| 133 | //has to be calculated from here |
---|
| 134 | |
---|
[1525] | 135 | double new_x, new_y; |
---|
| 136 | |
---|
| 137 | window_to_world (e->motion.x, e->motion.y, new_x, new_y); |
---|
| 138 | |
---|
| 139 | double dx=new_x-clicked_x; |
---|
| 140 | double dy=new_y-clicked_y; |
---|
[1510] | 141 | |
---|
[1512] | 142 | //repositioning node and its text |
---|
[1510] | 143 | active_item->move(dx, dy); |
---|
[1512] | 144 | nodetextmap[active_node]->move(dx, dy); |
---|
[1510] | 145 | |
---|
[1525] | 146 | clicked_x=new_x; |
---|
| 147 | clicked_y=new_y; |
---|
[1510] | 148 | |
---|
| 149 | //all the edges connected to the moved point has to be redrawn |
---|
| 150 | EdgeIt ei; |
---|
| 151 | |
---|
[1606] | 152 | mapstorage.graph.firstOut(ei,active_node); |
---|
[1510] | 153 | |
---|
[1606] | 154 | for(;ei!=INVALID;mapstorage.graph.nextOut(ei)) |
---|
[1510] | 155 | { |
---|
| 156 | Gnome::Canvas::Points coos; |
---|
| 157 | double x1, x2, y1, y2; |
---|
| 158 | |
---|
[1606] | 159 | nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2); |
---|
[1510] | 160 | coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); |
---|
| 161 | |
---|
[1606] | 162 | nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2); |
---|
[1510] | 163 | coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); |
---|
| 164 | |
---|
| 165 | if(isbutton==3) |
---|
| 166 | { |
---|
[1524] | 167 | edgesmap[ei]->setPoints(coos); |
---|
[1510] | 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
[1524] | 171 | edgesmap[ei]->setPoints(coos,true); |
---|
[1510] | 172 | } |
---|
| 173 | |
---|
[1512] | 174 | //reposition of edgetext |
---|
[1524] | 175 | xy<double> text_pos=edgesmap[ei]->getArrowPos(); |
---|
[1510] | 176 | text_pos+=(xy<double>(10,10)); |
---|
| 177 | edgetextmap[ei]->property_x().set_value(text_pos.x); |
---|
| 178 | edgetextmap[ei]->property_y().set_value(text_pos.y); |
---|
| 179 | } |
---|
| 180 | |
---|
[1606] | 181 | mapstorage.graph.firstIn(ei,active_node); |
---|
| 182 | for(;ei!=INVALID;mapstorage.graph.nextIn(ei)) |
---|
[1510] | 183 | { |
---|
| 184 | Gnome::Canvas::Points coos; |
---|
| 185 | double x1, x2, y1, y2; |
---|
| 186 | |
---|
[1606] | 187 | nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2); |
---|
[1510] | 188 | coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); |
---|
| 189 | |
---|
[1606] | 190 | nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2); |
---|
[1510] | 191 | coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); |
---|
| 192 | |
---|
| 193 | if(isbutton==3) |
---|
| 194 | { |
---|
[1524] | 195 | edgesmap[ei]->setPoints(coos); |
---|
[1510] | 196 | } |
---|
| 197 | else |
---|
| 198 | { |
---|
[1524] | 199 | edgesmap[ei]->setPoints(coos,true); |
---|
[1510] | 200 | } |
---|
| 201 | |
---|
[1524] | 202 | xy<double> text_pos=edgesmap[ei]->getArrowPos(); |
---|
[1510] | 203 | text_pos+=(xy<double>(10,10)); |
---|
| 204 | edgetextmap[ei]->property_x().set_value(text_pos.x); |
---|
| 205 | edgetextmap[ei]->property_y().set_value(text_pos.y); |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | default: break; |
---|
| 209 | } |
---|
| 210 | |
---|
[1525] | 211 | return false; |
---|
[1510] | 212 | } |
---|
| 213 | |
---|
[1524] | 214 | bool GraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e) |
---|
[1510] | 215 | { |
---|
| 216 | switch(e->type) |
---|
| 217 | { |
---|
| 218 | |
---|
| 219 | //draw the new node in red at the clicked place |
---|
[1525] | 220 | case GDK_2BUTTON_PRESS: |
---|
[1599] | 221 | //std::cout << "double click" << std::endl; |
---|
[1525] | 222 | break; |
---|
[1510] | 223 | case GDK_BUTTON_PRESS: |
---|
[1606] | 224 | mapstorage.modified = true; |
---|
| 225 | |
---|
[1510] | 226 | isbutton=1; |
---|
| 227 | |
---|
[1606] | 228 | active_node=NodeIt(mapstorage.graph,mapstorage.graph.addNode()); |
---|
[1510] | 229 | |
---|
| 230 | //initiating values corresponding to new node in maps |
---|
| 231 | |
---|
| 232 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 233 | |
---|
[1606] | 234 | mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y)); |
---|
| 235 | (*mapstorage.nodemap_storage["id"])[active_node] = |
---|
| 236 | mapstorage.graph.id(active_node); |
---|
| 237 | |
---|
| 238 | nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, |
---|
| 239 | clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20); |
---|
[1510] | 240 | active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]); |
---|
| 241 | *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red"); |
---|
| 242 | *(nodesmap[active_node]) << Gnome::Canvas::Properties::outline_color("black"); |
---|
| 243 | (nodesmap[active_node])->show(); |
---|
[1512] | 244 | |
---|
[1606] | 245 | nodetextmap[active_node]=new Gnome::Canvas::Text(displayed_graph, |
---|
| 246 | clicked_x+node_property_defaults[N_RADIUS]+5, |
---|
| 247 | clicked_y+node_property_defaults[N_RADIUS]+5, ""); |
---|
[1512] | 248 | nodetextmap[active_node]->property_fill_color().set_value("darkblue"); |
---|
| 249 | |
---|
[1606] | 250 | mapwin.updateNode(active_node); |
---|
[1512] | 251 | |
---|
[1510] | 252 | break; |
---|
| 253 | |
---|
| 254 | //move the new node |
---|
| 255 | case GDK_MOTION_NOTIFY: |
---|
| 256 | { |
---|
| 257 | GdkEvent * generated=new GdkEvent(); |
---|
[1525] | 258 | generated->motion.x=e->motion.x; |
---|
| 259 | generated->motion.y=e->motion.y; |
---|
[1510] | 260 | generated->type=GDK_MOTION_NOTIFY; |
---|
[1524] | 261 | moveEventHandler(generated); |
---|
[1510] | 262 | break; |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | //finalize the new node |
---|
| 266 | case GDK_BUTTON_RELEASE: |
---|
[1579] | 267 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 268 | |
---|
| 269 | active_item->lower_to_bottom(); |
---|
| 270 | |
---|
| 271 | target_item=NULL; |
---|
| 272 | target_item=get_item_at(clicked_x, clicked_y); |
---|
| 273 | |
---|
| 274 | active_item->raise_to_top(); |
---|
| 275 | |
---|
[1510] | 276 | isbutton=0; |
---|
[1579] | 277 | if(target_item==active_item) |
---|
[1525] | 278 | { |
---|
| 279 | //Its appropriate color is given by update. |
---|
[1579] | 280 | *active_item << Gnome::Canvas::Properties::fill_color("blue"); |
---|
[1525] | 281 | } |
---|
| 282 | else |
---|
| 283 | { |
---|
| 284 | //In this case the given color has to be overwritten, because the noe covers an other item. |
---|
| 285 | *active_item << Gnome::Canvas::Properties::fill_color("lightblue"); |
---|
| 286 | } |
---|
| 287 | target_item=NULL; |
---|
[1510] | 288 | active_item=NULL; |
---|
| 289 | active_node=INVALID; |
---|
| 290 | break; |
---|
| 291 | default: |
---|
| 292 | break; |
---|
| 293 | } |
---|
| 294 | return false; |
---|
| 295 | } |
---|
| 296 | |
---|
[1524] | 297 | bool GraphDisplayerCanvas::createEdgeEventHandler(GdkEvent* e) |
---|
[1510] | 298 | { |
---|
| 299 | switch(e->type) |
---|
| 300 | { |
---|
| 301 | case GDK_BUTTON_PRESS: |
---|
| 302 | //in edge creation right button has special meaning |
---|
| 303 | if(e->button.button!=3) |
---|
| 304 | { |
---|
| 305 | //there is not yet selected node |
---|
| 306 | if(active_node==INVALID) |
---|
| 307 | { |
---|
| 308 | //we mark the location of the event to be able to calculate parameters of dragging |
---|
[1525] | 309 | |
---|
| 310 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 311 | |
---|
| 312 | active_item=(get_item_at(clicked_x, clicked_y)); |
---|
[1510] | 313 | active_node=INVALID; |
---|
[1606] | 314 | for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1510] | 315 | { |
---|
| 316 | if(nodesmap[i]==active_item) |
---|
| 317 | { |
---|
| 318 | active_node=i; |
---|
| 319 | } |
---|
| 320 | } |
---|
| 321 | //the clicked item is really a node |
---|
| 322 | if(active_node!=INVALID) |
---|
| 323 | { |
---|
| 324 | *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red"); |
---|
| 325 | isbutton=1; |
---|
| 326 | } |
---|
| 327 | //clicked item was not a node. It could be e.g. edge. |
---|
| 328 | else |
---|
| 329 | { |
---|
| 330 | active_item=NULL; |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | //we only have to do sg. if the mouse button |
---|
| 334 | // is pressed already once AND the click was |
---|
| 335 | // on a node that was found in the set of |
---|
| 336 | //nodes, and now we only search for the second |
---|
| 337 | //node |
---|
| 338 | else |
---|
| 339 | { |
---|
[1525] | 340 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 341 | target_item=(get_item_at(clicked_x, clicked_y)); |
---|
[1510] | 342 | Graph::NodeIt target_node=INVALID; |
---|
[1606] | 343 | for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1510] | 344 | { |
---|
| 345 | if(nodesmap[i]==target_item) |
---|
| 346 | { |
---|
| 347 | target_node=i; |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | //the clicked item is a node, the edge can be drawn |
---|
| 351 | if(target_node!=INVALID) |
---|
| 352 | { |
---|
[1512] | 353 | if(target_node!=active_node) |
---|
| 354 | { |
---|
[1606] | 355 | mapstorage.modified = true; |
---|
| 356 | |
---|
[1512] | 357 | *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red"); |
---|
[1510] | 358 | |
---|
[1512] | 359 | //creating new edge |
---|
[1606] | 360 | active_edge=EdgeIt(mapstorage.graph,mapstorage.graph.addEdge(active_node, target_node)); |
---|
[1510] | 361 | |
---|
[1512] | 362 | //initiating values corresponding to new edge in maps |
---|
[1524] | 363 | mapstorage.initMapsForEdge(active_edge); |
---|
[1606] | 364 | (*mapstorage.edgemap_storage["id"])[active_edge] = mapstorage.graph.id(active_edge); |
---|
[1510] | 365 | |
---|
[1512] | 366 | //calculating coordinates of new edge |
---|
| 367 | Gnome::Canvas::Points coos; |
---|
| 368 | double x1, x2, y1, y2; |
---|
[1510] | 369 | |
---|
[1512] | 370 | active_item->get_bounds(x1, y1, x2, y2); |
---|
| 371 | coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); |
---|
[1510] | 372 | |
---|
[1512] | 373 | target_item->get_bounds(x1, y1, x2, y2); |
---|
| 374 | coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); |
---|
[1510] | 375 | |
---|
[1512] | 376 | //drawing new edge |
---|
| 377 | edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this); |
---|
| 378 | *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green"); |
---|
| 379 | edgesmap[active_edge]->property_width_pixels().set_value(10); |
---|
[1510] | 380 | |
---|
[1512] | 381 | //redraw nodes to blank terminations of the new edge |
---|
| 382 | target_item->raise_to_top(); |
---|
| 383 | active_item->raise_to_top(); |
---|
[1510] | 384 | |
---|
[1512] | 385 | //initializing edge-text as well, to empty string |
---|
[1524] | 386 | xy<double> text_pos=edgesmap[active_edge]->getArrowPos(); |
---|
[1512] | 387 | text_pos+=(xy<double>(10,10)); |
---|
[1510] | 388 | |
---|
[1512] | 389 | edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); |
---|
| 390 | edgetextmap[active_edge]->property_fill_color().set_value("darkgreen"); |
---|
| 391 | |
---|
| 392 | //updating its properties |
---|
[1606] | 393 | mapwin.updateEdge(active_edge); |
---|
[1512] | 394 | } |
---|
| 395 | else |
---|
| 396 | { |
---|
| 397 | target_node=INVALID; |
---|
[1599] | 398 | std::cerr << "Loop edge is not yet implemented!" << std::endl; |
---|
[1512] | 399 | } |
---|
[1510] | 400 | } |
---|
| 401 | //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore. |
---|
| 402 | else |
---|
| 403 | { |
---|
| 404 | target_item=NULL; |
---|
| 405 | } |
---|
| 406 | } |
---|
| 407 | } |
---|
| 408 | break; |
---|
| 409 | case GDK_BUTTON_RELEASE: |
---|
| 410 | isbutton=0; |
---|
| 411 | //we clear settings in two cases |
---|
| 412 | //1: the edge is ready (target_item has valid value) |
---|
| 413 | //2: the edge creation is cancelled with right button |
---|
| 414 | if((target_item)||(e->button.button==3)) |
---|
| 415 | { |
---|
| 416 | if(active_item) |
---|
| 417 | { |
---|
| 418 | *active_item << Gnome::Canvas::Properties::fill_color("blue"); |
---|
| 419 | active_item=NULL; |
---|
| 420 | } |
---|
| 421 | if(target_item) |
---|
| 422 | { |
---|
| 423 | *target_item << Gnome::Canvas::Properties::fill_color("blue"); |
---|
| 424 | target_item=NULL; |
---|
| 425 | } |
---|
| 426 | active_node=INVALID; |
---|
| 427 | active_edge=INVALID; |
---|
| 428 | } |
---|
| 429 | break; |
---|
| 430 | default: |
---|
| 431 | break; |
---|
| 432 | } |
---|
| 433 | return false; |
---|
| 434 | } |
---|
| 435 | |
---|
[1524] | 436 | bool GraphDisplayerCanvas::eraserEventHandler(GdkEvent* e) |
---|
[1510] | 437 | { |
---|
| 438 | switch(e->type) |
---|
| 439 | { |
---|
| 440 | case GDK_BUTTON_PRESS: |
---|
[1594] | 441 | //finding the clicked items |
---|
[1525] | 442 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 443 | active_item=(get_item_at(clicked_x, clicked_y)); |
---|
[1510] | 444 | active_node=INVALID; |
---|
| 445 | active_edge=INVALID; |
---|
[1594] | 446 | //was it a node? |
---|
[1606] | 447 | for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1510] | 448 | { |
---|
| 449 | if(nodesmap[i]==active_item) |
---|
| 450 | { |
---|
| 451 | active_node=i; |
---|
| 452 | } |
---|
| 453 | } |
---|
[1594] | 454 | //or was it an edge? |
---|
[1510] | 455 | if(active_node==INVALID) |
---|
| 456 | { |
---|
[1606] | 457 | for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1510] | 458 | { |
---|
| 459 | if(edgesmap[i]==active_item) |
---|
| 460 | { |
---|
| 461 | active_edge=i; |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | } |
---|
[1594] | 465 | |
---|
| 466 | //recolor activated item |
---|
[1525] | 467 | if(active_item) |
---|
| 468 | { |
---|
| 469 | *active_item << Gnome::Canvas::Properties::fill_color("red"); |
---|
| 470 | } |
---|
[1510] | 471 | break; |
---|
| 472 | |
---|
| 473 | case GDK_BUTTON_RELEASE: |
---|
[1525] | 474 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 475 | if(active_item) |
---|
[1510] | 476 | { |
---|
[1594] | 477 | //the cursor was not moved since pressing it |
---|
[1525] | 478 | if( active_item == ( get_item_at (clicked_x, clicked_y) ) ) |
---|
[1510] | 479 | { |
---|
[1594] | 480 | //a node was found |
---|
[1525] | 481 | if(active_node!=INVALID) |
---|
| 482 | { |
---|
[1606] | 483 | mapstorage.modified = true; |
---|
[1510] | 484 | |
---|
[1525] | 485 | //collecting edges to delete |
---|
| 486 | EdgeIt e; |
---|
| 487 | std::set<Graph::Edge> edges_to_delete; |
---|
[1510] | 488 | |
---|
[1606] | 489 | mapstorage.graph.firstOut(e,active_node); |
---|
| 490 | for(;e!=INVALID;mapstorage.graph.nextOut(e)) |
---|
[1525] | 491 | { |
---|
| 492 | edges_to_delete.insert(e); |
---|
| 493 | } |
---|
| 494 | |
---|
[1606] | 495 | mapstorage.graph.firstIn(e,active_node); |
---|
| 496 | for(;e!=INVALID;mapstorage.graph.nextIn(e)) |
---|
[1525] | 497 | { |
---|
| 498 | edges_to_delete.insert(e); |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | //deleting collected edges |
---|
| 502 | for(std::set<Graph::Edge>::iterator edge_set_it=edges_to_delete.begin();edge_set_it!=edges_to_delete.end();edge_set_it++) |
---|
| 503 | { |
---|
| 504 | deleteItem(*edge_set_it); |
---|
| 505 | } |
---|
| 506 | deleteItem(active_node); |
---|
| 507 | } |
---|
| 508 | //a simple edge was chosen |
---|
| 509 | else |
---|
[1510] | 510 | { |
---|
[1525] | 511 | deleteItem(active_edge); |
---|
[1510] | 512 | } |
---|
| 513 | } |
---|
[1525] | 514 | //pointer was moved, deletion is cancelled |
---|
[1510] | 515 | else |
---|
| 516 | { |
---|
[1525] | 517 | if(active_node!=INVALID) |
---|
| 518 | { |
---|
| 519 | *active_item << Gnome::Canvas::Properties::fill_color("blue"); |
---|
| 520 | } |
---|
| 521 | else |
---|
| 522 | { |
---|
| 523 | *active_item << Gnome::Canvas::Properties::fill_color("green"); |
---|
| 524 | } |
---|
[1510] | 525 | } |
---|
| 526 | } |
---|
| 527 | //reseting datas |
---|
| 528 | active_item=NULL; |
---|
| 529 | active_edge=INVALID; |
---|
| 530 | active_node=INVALID; |
---|
| 531 | break; |
---|
| 532 | |
---|
| 533 | case GDK_MOTION_NOTIFY: |
---|
| 534 | break; |
---|
| 535 | |
---|
| 536 | default: |
---|
| 537 | break; |
---|
| 538 | } |
---|
[1525] | 539 | return false; |
---|
[1510] | 540 | } |
---|
| 541 | |
---|
[1550] | 542 | bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e) |
---|
| 543 | { |
---|
[1599] | 544 | if(actual_tool==EDGE_MAP_EDIT) |
---|
[1550] | 545 | { |
---|
[1599] | 546 | switch(e->type) |
---|
| 547 | { |
---|
| 548 | case GDK_KEY_PRESS: |
---|
| 549 | //for Escape or Enter hide the displayed widget |
---|
| 550 | { |
---|
| 551 | nodeMapEditEventHandler(e); |
---|
| 552 | break; |
---|
| 553 | } |
---|
| 554 | case GDK_BUTTON_PRESS: |
---|
| 555 | //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. |
---|
| 556 | { |
---|
| 557 | //for determine, whether it was an edge |
---|
| 558 | Graph::EdgeIt clicked_edge=INVALID; |
---|
[1594] | 559 | |
---|
[1599] | 560 | //find the activated item between texts |
---|
| 561 | active_item=(get_item_at(e->button.x, e->button.y)); |
---|
[1606] | 562 | for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1562] | 563 | { |
---|
[1599] | 564 | if(edgetextmap[i]==active_item) |
---|
| 565 | { |
---|
| 566 | clicked_edge=i; |
---|
| 567 | } |
---|
[1562] | 568 | } |
---|
[1599] | 569 | |
---|
| 570 | //if it was not between texts, search for it between edges |
---|
| 571 | if(clicked_edge==INVALID) |
---|
[1562] | 572 | { |
---|
[1599] | 573 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 574 | active_item=(get_item_at(clicked_x, clicked_y)); |
---|
| 575 | |
---|
[1606] | 576 | for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1599] | 577 | { |
---|
| 578 | //at the same time only one can be active |
---|
| 579 | if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item)) |
---|
| 580 | { |
---|
| 581 | clicked_edge=i; |
---|
| 582 | } |
---|
| 583 | } |
---|
| 584 | } |
---|
| 585 | //if it was really an edge... |
---|
| 586 | if(clicked_edge!=INVALID) |
---|
| 587 | { |
---|
| 588 | //If there is already edited edge, it has to be saved first |
---|
| 589 | if(entrywidget.is_visible()) |
---|
| 590 | { |
---|
| 591 | GdkEvent * generated=new GdkEvent(); |
---|
| 592 | generated->type=GDK_KEY_PRESS; |
---|
| 593 | ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; |
---|
| 594 | entryWidgetChangeHandler(generated); |
---|
| 595 | } |
---|
| 596 | //If the previous value could be saved, we can go further, otherwise not |
---|
| 597 | if(!entrywidget.is_visible()) |
---|
| 598 | { |
---|
| 599 | //and there is activated map |
---|
| 600 | if(edgetextmap[clicked_edge]->property_text().get_value()!="") |
---|
| 601 | { |
---|
| 602 | //activate the general variable for it |
---|
| 603 | active_edge=clicked_edge; |
---|
| 604 | //delete visible widget if there is |
---|
| 605 | if(canvasentrywidget) |
---|
| 606 | { |
---|
| 607 | delete(canvasentrywidget); |
---|
| 608 | } |
---|
| 609 | |
---|
| 610 | //initialize the entry |
---|
| 611 | entrywidget.show(); |
---|
| 612 | |
---|
| 613 | //fill in the correct value |
---|
| 614 | entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value()); |
---|
| 615 | |
---|
| 616 | //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc |
---|
| 617 | xy<double> entry_coos; |
---|
| 618 | entry_coos.x=(edgetextmap[active_edge])->property_x().get_value(); |
---|
| 619 | entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2; |
---|
| 620 | entry_coos.y=(edgetextmap[active_edge])->property_y().get_value(); |
---|
| 621 | entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2; |
---|
| 622 | canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); |
---|
| 623 | canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4); |
---|
| 624 | canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5); |
---|
| 625 | } |
---|
| 626 | } |
---|
| 627 | } |
---|
| 628 | //if it was not an edge... |
---|
| 629 | else |
---|
| 630 | { |
---|
| 631 | //In this case the click did not happen on an edge |
---|
| 632 | //if there is visible entry we save the value in it |
---|
| 633 | //we pretend like an Enter was presse din the Entry widget |
---|
[1594] | 634 | GdkEvent * generated=new GdkEvent(); |
---|
| 635 | generated->type=GDK_KEY_PRESS; |
---|
| 636 | ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; |
---|
| 637 | entryWidgetChangeHandler(generated); |
---|
| 638 | } |
---|
[1599] | 639 | break; |
---|
[1562] | 640 | } |
---|
[1599] | 641 | default: |
---|
| 642 | break; |
---|
| 643 | } |
---|
[1550] | 644 | } |
---|
| 645 | return false; |
---|
| 646 | } |
---|
| 647 | |
---|
| 648 | bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e) |
---|
| 649 | { |
---|
[1599] | 650 | if(actual_tool==NODE_MAP_EDIT) |
---|
[1579] | 651 | { |
---|
[1599] | 652 | switch(e->type) |
---|
| 653 | { |
---|
| 654 | case GDK_KEY_PRESS: |
---|
| 655 | //for Escape or Enter hide the displayed widget |
---|
[1579] | 656 | { |
---|
[1599] | 657 | switch(((GdkEventKey*)e)->keyval) |
---|
| 658 | { |
---|
| 659 | case GDK_Escape: |
---|
| 660 | entrywidget.hide(); |
---|
| 661 | break; |
---|
| 662 | case GDK_Return: |
---|
| 663 | case GDK_KP_Enter: |
---|
| 664 | entrywidget.hide(); |
---|
| 665 | break; |
---|
| 666 | default: |
---|
| 667 | break; |
---|
| 668 | } |
---|
| 669 | |
---|
[1579] | 670 | break; |
---|
| 671 | } |
---|
[1599] | 672 | case GDK_BUTTON_PRESS: |
---|
| 673 | //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. |
---|
| 674 | { |
---|
| 675 | //for determine, whether it was a node |
---|
| 676 | Graph::NodeIt clicked_node=INVALID; |
---|
[1594] | 677 | |
---|
[1599] | 678 | //find the activated item between texts |
---|
| 679 | active_item=(get_item_at(e->button.x, e->button.y)); |
---|
[1606] | 680 | for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1579] | 681 | { |
---|
[1599] | 682 | //at the same time only one can be active |
---|
| 683 | if(nodetextmap[i]==active_item) |
---|
| 684 | { |
---|
| 685 | clicked_node=i; |
---|
| 686 | } |
---|
[1579] | 687 | } |
---|
[1594] | 688 | |
---|
[1599] | 689 | //if there was not, search for it between nodes |
---|
| 690 | if(clicked_node==INVALID) |
---|
[1579] | 691 | { |
---|
[1599] | 692 | window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); |
---|
| 693 | active_item=(get_item_at(clicked_x, clicked_y)); |
---|
| 694 | |
---|
[1606] | 695 | for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1599] | 696 | { |
---|
| 697 | //at the same time only one can be active |
---|
| 698 | if(nodesmap[i]==active_item) |
---|
| 699 | { |
---|
| 700 | clicked_node=i; |
---|
| 701 | } |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | //if it was really an edge... |
---|
| 705 | if(clicked_node!=INVALID) |
---|
| 706 | { |
---|
| 707 | //If there is already edited edge, it has to be saved first |
---|
| 708 | if(entrywidget.is_visible()) |
---|
| 709 | { |
---|
| 710 | GdkEvent * generated=new GdkEvent(); |
---|
| 711 | generated->type=GDK_KEY_PRESS; |
---|
| 712 | ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; |
---|
| 713 | entryWidgetChangeHandler(generated); |
---|
| 714 | } |
---|
| 715 | //If the previous value could be saved, we can go further, otherwise not |
---|
| 716 | if(!entrywidget.is_visible()) |
---|
| 717 | { |
---|
| 718 | //and there is activated map |
---|
| 719 | if(nodetextmap[clicked_node]->property_text().get_value()!="") |
---|
| 720 | { |
---|
| 721 | //activate the general variable for it |
---|
| 722 | active_node=clicked_node; |
---|
| 723 | //delete visible widget if there is |
---|
| 724 | if(canvasentrywidget) |
---|
| 725 | { |
---|
| 726 | delete(canvasentrywidget); |
---|
| 727 | } |
---|
| 728 | |
---|
| 729 | //initialize the entry |
---|
| 730 | entrywidget.show(); |
---|
| 731 | |
---|
| 732 | //fill in the correct value |
---|
| 733 | entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); |
---|
| 734 | |
---|
| 735 | //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc |
---|
| 736 | xy<double> entry_coos; |
---|
| 737 | entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); |
---|
| 738 | entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2; |
---|
| 739 | entry_coos.y=(nodetextmap[active_node])->property_y().get_value(); |
---|
| 740 | entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2; |
---|
| 741 | canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); |
---|
| 742 | canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*4); |
---|
| 743 | canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5); |
---|
| 744 | } |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | //if it was not an edge... |
---|
| 748 | else |
---|
| 749 | { |
---|
| 750 | //In this case the click did not happen on an edge |
---|
| 751 | //if there is visible entry we save the value in it |
---|
| 752 | //we pretend like an Enter was presse din the Entry widget |
---|
[1579] | 753 | GdkEvent * generated=new GdkEvent(); |
---|
| 754 | generated->type=GDK_KEY_PRESS; |
---|
| 755 | ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; |
---|
| 756 | entryWidgetChangeHandler(generated); |
---|
| 757 | } |
---|
[1599] | 758 | break; |
---|
[1579] | 759 | } |
---|
[1599] | 760 | default: |
---|
| 761 | break; |
---|
| 762 | } |
---|
[1579] | 763 | } |
---|
| 764 | return false; |
---|
[1550] | 765 | } |
---|
| 766 | |
---|
[1562] | 767 | bool GraphDisplayerCanvas::entryWidgetChangeHandler(GdkEvent* e) |
---|
| 768 | { |
---|
[1579] | 769 | if(entrywidget.is_visible()) |
---|
| 770 | { |
---|
| 771 | if(e->type==GDK_KEY_PRESS) |
---|
| 772 | { |
---|
| 773 | switch(((GdkEventKey*)e)->keyval) |
---|
| 774 | { |
---|
| 775 | case GDK_Escape: |
---|
| 776 | entrywidget.hide(); |
---|
| 777 | break; |
---|
| 778 | case GDK_KP_Enter: |
---|
| 779 | case GDK_Return: |
---|
| 780 | { |
---|
[1594] | 781 | //these variables check whether the text in the entry is valid |
---|
[1592] | 782 | bool valid_double=true; |
---|
| 783 | int point_num=0; |
---|
[1594] | 784 | |
---|
| 785 | //getting the value from the entry and converting it to double |
---|
[1592] | 786 | Glib::ustring mapvalue_str = entrywidget.get_text(); |
---|
[1579] | 787 | |
---|
[1592] | 788 | char * mapvalue_ch=new char [mapvalue_str.length()]; |
---|
| 789 | for(int i=0;i<(int)(mapvalue_str.length());i++) |
---|
[1579] | 790 | { |
---|
[1592] | 791 | if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.')) |
---|
[1579] | 792 | { |
---|
[1592] | 793 | valid_double=false; |
---|
[1579] | 794 | } |
---|
| 795 | else |
---|
| 796 | { |
---|
[1592] | 797 | if(mapvalue_str[i]=='.') |
---|
| 798 | { |
---|
| 799 | point_num++; |
---|
| 800 | } |
---|
[1579] | 801 | } |
---|
[1592] | 802 | mapvalue_ch[i]=mapvalue_str[i]; |
---|
[1579] | 803 | } |
---|
[1596] | 804 | |
---|
[1594] | 805 | //if the text in the entry was correct |
---|
[1592] | 806 | if((point_num<=1)&&(valid_double)) |
---|
[1579] | 807 | { |
---|
[1596] | 808 | double mapvalue_d=atof(mapvalue_ch); |
---|
| 809 | |
---|
| 810 | //reconvert the double to string for the correct format |
---|
| 811 | std::ostringstream ostr; |
---|
| 812 | ostr << mapvalue_d; |
---|
| 813 | |
---|
[1594] | 814 | //save the value to the correct place |
---|
[1579] | 815 | switch(actual_tool) |
---|
| 816 | { |
---|
| 817 | case EDGE_MAP_EDIT: |
---|
[1596] | 818 | edgetextmap[active_edge]->property_text().set_value(ostr.str()); |
---|
[1592] | 819 | (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d; |
---|
[1606] | 820 | mapwin.updateEdge(active_edge); |
---|
[1579] | 821 | break; |
---|
| 822 | case NODE_MAP_EDIT: |
---|
[1596] | 823 | nodetextmap[active_node]->property_text().set_value(ostr.str()); |
---|
[1592] | 824 | (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d; |
---|
[1606] | 825 | mapwin.updateNode(active_node); |
---|
[1579] | 826 | break; |
---|
| 827 | default: |
---|
| 828 | break; |
---|
| 829 | } |
---|
| 830 | entrywidget.hide(); |
---|
| 831 | } |
---|
[1594] | 832 | //the text in the entry was not correct for a double |
---|
[1579] | 833 | else |
---|
| 834 | { |
---|
[1599] | 835 | std::cerr << "ERROR: only handling of double values is implemented yet!" << std::endl; |
---|
[1579] | 836 | } |
---|
| 837 | |
---|
| 838 | break; |
---|
| 839 | } |
---|
| 840 | default: |
---|
| 841 | break; |
---|
| 842 | } |
---|
| 843 | } |
---|
| 844 | } |
---|
[1562] | 845 | return false; |
---|
| 846 | } |
---|
| 847 | |
---|
[1524] | 848 | void GraphDisplayerCanvas::deleteItem(NodeIt node_to_delete) |
---|
[1510] | 849 | { |
---|
[1512] | 850 | delete(nodetextmap[node_to_delete]); |
---|
[1510] | 851 | delete(nodesmap[node_to_delete]); |
---|
[1606] | 852 | mapstorage.graph.erase(node_to_delete); |
---|
[1510] | 853 | } |
---|
| 854 | |
---|
[1524] | 855 | void GraphDisplayerCanvas::deleteItem(EdgeIt edge_to_delete) |
---|
[1510] | 856 | { |
---|
[1512] | 857 | delete(edgetextmap[edge_to_delete]); |
---|
[1510] | 858 | delete(edgesmap[edge_to_delete]); |
---|
[1606] | 859 | mapstorage.graph.erase(edge_to_delete); |
---|
[1510] | 860 | } |
---|
| 861 | |
---|
[1524] | 862 | void GraphDisplayerCanvas::deleteItem(Graph::Edge edge_to_delete) |
---|
[1510] | 863 | { |
---|
[1512] | 864 | delete(edgetextmap[edge_to_delete]); |
---|
[1510] | 865 | delete(edgesmap[edge_to_delete]); |
---|
[1606] | 866 | mapstorage.graph.erase(edge_to_delete); |
---|
[1510] | 867 | } |
---|
| 868 | |
---|
[1524] | 869 | void GraphDisplayerCanvas::textReposition(xy<double> new_place) |
---|
[1510] | 870 | { |
---|
| 871 | new_place+=(xy<double>(10,10)); |
---|
[1579] | 872 | edgetextmap[forming_edge]->property_x().set_value(new_place.x); |
---|
| 873 | edgetextmap[forming_edge]->property_y().set_value(new_place.y); |
---|
[1510] | 874 | } |
---|
| 875 | |
---|
[1524] | 876 | void GraphDisplayerCanvas::toggleEdgeActivity(BrokenEdge* active_bre, bool on) |
---|
[1510] | 877 | { |
---|
| 878 | if(on) |
---|
| 879 | { |
---|
[1579] | 880 | if(forming_edge!=INVALID) |
---|
[1510] | 881 | { |
---|
[1599] | 882 | std::cerr << "ERROR!!!! Valid edge found!" << std::endl; |
---|
[1510] | 883 | } |
---|
| 884 | else |
---|
| 885 | { |
---|
[1606] | 886 | for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) |
---|
[1510] | 887 | { |
---|
| 888 | if(edgesmap[i]==active_bre) |
---|
| 889 | { |
---|
[1579] | 890 | forming_edge=i; |
---|
[1510] | 891 | } |
---|
| 892 | } |
---|
| 893 | } |
---|
| 894 | } |
---|
| 895 | else |
---|
| 896 | { |
---|
[1579] | 897 | if(forming_edge!=INVALID) |
---|
[1510] | 898 | { |
---|
[1579] | 899 | forming_edge=INVALID; |
---|
[1510] | 900 | } |
---|
| 901 | else |
---|
| 902 | { |
---|
[1599] | 903 | std::cerr << "ERROR!!!! Invalid edge found!" << std::endl; |
---|
[1510] | 904 | } |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | } |
---|
[1550] | 908 | |
---|
[1597] | 909 | int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname) |
---|
[1585] | 910 | { |
---|
[1594] | 911 | //create the new map |
---|
[1606] | 912 | Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mapstorage.graph, default_value); |
---|
[1597] | 913 | |
---|
| 914 | //if addition was not successful addEdgeMap returns one. |
---|
| 915 | //cause can be that there is already a map named like the new one |
---|
| 916 | if(mapstorage.addEdgeMap(mapname,emptr)) |
---|
| 917 | { |
---|
| 918 | return 1; |
---|
| 919 | } |
---|
| 920 | |
---|
[1594] | 921 | |
---|
| 922 | //add it to the list of the displayable maps |
---|
[1606] | 923 | mapwin.registerNewEdgeMap(mapname); |
---|
[1594] | 924 | |
---|
| 925 | //display it |
---|
[1592] | 926 | changeEdgeText(mapname); |
---|
[1597] | 927 | |
---|
| 928 | return 0; |
---|
[1585] | 929 | } |
---|
| 930 | |
---|
[1597] | 931 | int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname) |
---|
[1585] | 932 | { |
---|
[1594] | 933 | //create the new map |
---|
[1606] | 934 | Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mapstorage.graph,default_value); |
---|
[1597] | 935 | |
---|
| 936 | //if addition was not successful addNodeMap returns one. |
---|
| 937 | //cause can be that there is already a map named like the new one |
---|
| 938 | if(mapstorage.addNodeMap(mapname,emptr)) |
---|
| 939 | { |
---|
| 940 | return 1; |
---|
| 941 | } |
---|
[1594] | 942 | |
---|
| 943 | //add it to the list of the displayable maps |
---|
[1606] | 944 | mapwin.registerNewNodeMap(mapname); |
---|
[1594] | 945 | |
---|
| 946 | //display it |
---|
[1592] | 947 | changeNodeText(mapname); |
---|
[1597] | 948 | |
---|
| 949 | return 0; |
---|
[1585] | 950 | } |
---|
| 951 | |
---|