1.1 --- a/graph_displayer_canvas-event.cc Wed May 02 20:33:58 2007 +0000
1.2 +++ b/graph_displayer_canvas-event.cc Wed Jan 02 21:03:09 2008 +0000
1.3 @@ -33,63 +33,63 @@
1.4 void GraphDisplayerCanvas::changeEditorialTool(int newtool)
1.5 {
1.6 if(actual_tool!=newtool)
1.7 + {
1.8 +
1.9 + actual_handler.disconnect();
1.10 +
1.11 + switch(actual_tool)
1.12 {
1.13 + case CREATE_EDGE:
1.14 + {
1.15 + GdkEvent * generated=new GdkEvent();
1.16 + generated->type=GDK_BUTTON_RELEASE;
1.17 + generated->button.button=3;
1.18 + createEdgeEventHandler(generated);
1.19 + break;
1.20 + }
1.21 + case MAP_EDIT:
1.22 + {
1.23 + break;
1.24 + }
1.25 + default:
1.26 + break;
1.27 + }
1.28
1.29 - actual_handler.disconnect();
1.30 + active_item=NULL;
1.31 + target_item=NULL;
1.32 + active_edge=INVALID;
1.33 + active_node=INVALID;
1.34
1.35 - switch(actual_tool)
1.36 - {
1.37 - case CREATE_EDGE:
1.38 - {
1.39 - GdkEvent * generated=new GdkEvent();
1.40 - generated->type=GDK_BUTTON_RELEASE;
1.41 - generated->button.button=3;
1.42 - createEdgeEventHandler(generated);
1.43 - break;
1.44 - }
1.45 - case MAP_EDIT:
1.46 - {
1.47 - break;
1.48 - }
1.49 - default:
1.50 - break;
1.51 - }
1.52
1.53 - active_item=NULL;
1.54 - target_item=NULL;
1.55 - active_edge=INVALID;
1.56 - active_node=INVALID;
1.57 + actual_tool=newtool;
1.58
1.59 + switch(newtool)
1.60 + {
1.61 + case MOVE:
1.62 + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
1.63 + break;
1.64
1.65 - actual_tool=newtool;
1.66 -
1.67 - switch(newtool)
1.68 - {
1.69 - case MOVE:
1.70 - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
1.71 - break;
1.72 + case CREATE_NODE:
1.73 + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
1.74 + break;
1.75
1.76 - case CREATE_NODE:
1.77 - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
1.78 - break;
1.79 + case CREATE_EDGE:
1.80 + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
1.81 + break;
1.82
1.83 - case CREATE_EDGE:
1.84 - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
1.85 - break;
1.86 + case ERASER:
1.87 + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
1.88 + break;
1.89
1.90 - case ERASER:
1.91 - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
1.92 - break;
1.93 + case MAP_EDIT:
1.94 + grab_focus();
1.95 + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
1.96 + break;
1.97
1.98 - case MAP_EDIT:
1.99 - grab_focus();
1.100 - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
1.101 - break;
1.102 -
1.103 - default:
1.104 - break;
1.105 - }
1.106 + default:
1.107 + break;
1.108 }
1.109 + }
1.110 }
1.111
1.112 int GraphDisplayerCanvas::getActualTool()
1.113 @@ -138,30 +138,32 @@
1.114
1.115 bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e)
1.116 {
1.117 + MapStorage& ms = *mytab.mapstorage;
1.118 +
1.119 static Gnome::Canvas::Text *coord_text = 0;
1.120 switch(e->type)
1.121 - {
1.122 + {
1.123 case GDK_BUTTON_PRESS:
1.124 //we mark the location of the event to be able to calculate parameters of dragging
1.125 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.126 -
1.127 +
1.128 active_item=(get_item_at(clicked_x, clicked_y));
1.129 active_node=INVALID;
1.130 - for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.131 - {
1.132 - if(nodesmap[i]==active_item)
1.133 - {
1.134 - active_node=i;
1.135 - }
1.136 - }
1.137 + for (NodeIt i(ms.graph); i!=INVALID; ++i)
1.138 + {
1.139 + if(nodesmap[i]==active_item)
1.140 + {
1.141 + active_node=i;
1.142 + }
1.143 + }
1.144 isbutton=e->button.button;
1.145 break;
1.146 case GDK_BUTTON_RELEASE:
1.147 if (coord_text)
1.148 - {
1.149 - delete coord_text;
1.150 - coord_text = 0;
1.151 - }
1.152 + {
1.153 + delete coord_text;
1.154 + coord_text = 0;
1.155 + }
1.156 isbutton=0;
1.157 active_item=NULL;
1.158 active_node=INVALID;
1.159 @@ -169,65 +171,65 @@
1.160 case GDK_MOTION_NOTIFY:
1.161 //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
1.162 if(active_node!=INVALID)
1.163 - {
1.164 - (mytab.mapstorage)->modified = true;
1.165 -
1.166 - //new coordinates will be the old values,
1.167 - //because the item will be moved to the
1.168 - //new coordinate therefore the new movement
1.169 - //has to be calculated from here
1.170 -
1.171 - double new_x, new_y;
1.172 -
1.173 - window_to_world (e->motion.x, e->motion.y, new_x, new_y);
1.174 -
1.175 - double dx=new_x-clicked_x;
1.176 - double dy=new_y-clicked_y;
1.177 -
1.178 - moveNode(dx, dy);
1.179 + {
1.180 + ms.setModified();
1.181
1.182 - clicked_x=new_x;
1.183 - clicked_y=new_y;
1.184 + //new coordinates will be the old values,
1.185 + //because the item will be moved to the
1.186 + //new coordinate therefore the new movement
1.187 + //has to be calculated from here
1.188
1.189 - // reposition the coordinates text
1.190 - std::ostringstream ostr;
1.191 - ostr << "(" <<
1.192 - (mytab.mapstorage)->coords[active_node].x << ", " <<
1.193 - (mytab.mapstorage)->coords[active_node].y << ")";
1.194 - double radius =
1.195 - (nodesmap[active_node]->property_x2().get_value() -
1.196 - nodesmap[active_node]->property_x1().get_value()) / 2.0;
1.197 - if (coord_text)
1.198 - {
1.199 - coord_text->property_text().set_value(ostr.str());
1.200 - coord_text->property_x().set_value((mytab.mapstorage)->coords[active_node].x +
1.201 - radius);
1.202 - coord_text->property_y().set_value((mytab.mapstorage)->coords[active_node].y -
1.203 - radius);
1.204 - }
1.205 - else
1.206 - {
1.207 - coord_text = new Gnome::Canvas::Text(
1.208 - displayed_graph,
1.209 - (mytab.mapstorage)->coords[active_node].x + radius,
1.210 - (mytab.mapstorage)->coords[active_node].y - radius,
1.211 - ostr.str());
1.212 - coord_text->property_fill_color().set_value("black");
1.213 - coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
1.214 - }
1.215 + double new_x, new_y;
1.216
1.217 + window_to_world (e->motion.x, e->motion.y, new_x, new_y);
1.218
1.219 - }
1.220 + double dx=new_x-clicked_x;
1.221 + double dy=new_y-clicked_y;
1.222 +
1.223 + moveNode(dx, dy);
1.224 +
1.225 + clicked_x=new_x;
1.226 + clicked_y=new_y;
1.227 +
1.228 + // reposition the coordinates text
1.229 + std::ostringstream ostr;
1.230 + ostr << "(" <<
1.231 + ms.getNodeCoords(active_node).x << ", " <<
1.232 + ms.getNodeCoords(active_node).y << ")";
1.233 + double radius =
1.234 + (nodesmap[active_node]->property_x2().get_value() -
1.235 + nodesmap[active_node]->property_x1().get_value()) / 2.0;
1.236 + if (coord_text)
1.237 + {
1.238 + coord_text->property_text().set_value(ostr.str());
1.239 + coord_text->property_x().set_value(
1.240 + ms.getNodeCoords(active_node).x + radius);
1.241 + coord_text->property_y().set_value(
1.242 + ms.getNodeCoords(active_node).y - radius);
1.243 + }
1.244 + else
1.245 + {
1.246 + coord_text = new Gnome::Canvas::Text(
1.247 + displayed_graph,
1.248 + ms.getNodeCoords(active_node).x + radius,
1.249 + ms.getNodeCoords(active_node).y - radius,
1.250 + ostr.str());
1.251 + coord_text->property_fill_color().set_value("black");
1.252 + coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
1.253 + }
1.254 +
1.255 +
1.256 + }
1.257 default: break;
1.258 - }
1.259 + }
1.260
1.261 -return false;
1.262 + return false;
1.263 }
1.264
1.265 XY GraphDisplayerCanvas::calcArrowPos(XY moved_node_1, XY moved_node_2, XY fix_node, XY old_arrow_pos, int move_code)
1.266 {
1.267 switch(move_code)
1.268 - {
1.269 + {
1.270 case 1:
1.271 return XY((moved_node_2.x + fix_node.x) / 2.0, (moved_node_2.y + fix_node.y) / 2.0);
1.272 break;
1.273 @@ -236,57 +238,59 @@
1.274 break;
1.275 case 3:
1.276 {
1.277 - //////////////////////////////////////////////////////////////////////////////////////////////////////
1.278 - /////////// keeps shape-with scalar multiplication - version 2.
1.279 - //////////////////////////////////////////////////////////////////////////////////////////////////////
1.280 + //////////////////////////////////////////////////////////////////////////////////////////////////////
1.281 + /////////// keeps shape-with scalar multiplication - version 2.
1.282 + //////////////////////////////////////////////////////////////////////////////////////////////////////
1.283
1.284 - //old vector from one to the other node - a
1.285 - XY a_v(moved_node_1.x-fix_node.x,moved_node_1.y-fix_node.y);
1.286 - //new vector from one to the other node - b
1.287 - XY b_v(moved_node_2.x-fix_node.x,moved_node_2.y-fix_node.y);
1.288 + //old vector from one to the other node - a
1.289 + XY a_v(moved_node_1.x-fix_node.x,moved_node_1.y-fix_node.y);
1.290 + //new vector from one to the other node - b
1.291 + XY b_v(moved_node_2.x-fix_node.x,moved_node_2.y-fix_node.y);
1.292
1.293 - double absa=sqrt(a_v.normSquare());
1.294 - double absb=sqrt(b_v.normSquare());
1.295 + double absa=sqrt(a_v.normSquare());
1.296 + double absb=sqrt(b_v.normSquare());
1.297
1.298 - if ((absa == 0.0) || (absb == 0.0))
1.299 - {
1.300 - return old_arrow_pos;
1.301 - }
1.302 - else
1.303 - {
1.304 - //old vector from one node to the breakpoint - c
1.305 - XY c_v(old_arrow_pos.x-fix_node.x,old_arrow_pos.y-fix_node.y);
1.306 + if ((absa == 0.0) || (absb == 0.0))
1.307 + {
1.308 + return old_arrow_pos;
1.309 + }
1.310 + else
1.311 + {
1.312 + //old vector from one node to the breakpoint - c
1.313 + XY c_v(old_arrow_pos.x-fix_node.x,old_arrow_pos.y-fix_node.y);
1.314
1.315 - //unit vector with the same direction to a_v
1.316 - XY a_v_u(a_v.x/absa,a_v.y/absa);
1.317 + //unit vector with the same direction to a_v
1.318 + XY a_v_u(a_v.x/absa,a_v.y/absa);
1.319
1.320 - //normal vector of unit vector with the same direction to a_v
1.321 - XY a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
1.322 + //normal vector of unit vector with the same direction to a_v
1.323 + XY a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
1.324
1.325 - //unit vector with the same direction to b_v
1.326 - XY b_v_u(b_v.x/absb,b_v.y/absb);
1.327 + //unit vector with the same direction to b_v
1.328 + XY b_v_u(b_v.x/absb,b_v.y/absb);
1.329
1.330 - //normal vector of unit vector with the same direction to b_v
1.331 - XY b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
1.332 + //normal vector of unit vector with the same direction to b_v
1.333 + XY b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
1.334
1.335 - //vector c in a_v_u and a_v_u_n co-ordinate system
1.336 - XY c_a(c_v*a_v_u,c_v*a_v_u_n);
1.337 + //vector c in a_v_u and a_v_u_n co-ordinate system
1.338 + XY c_a(c_v*a_v_u,c_v*a_v_u_n);
1.339
1.340 - //new vector from one node to the breakpoint - d - we have to calculate this one
1.341 - XY d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
1.342 + //new vector from one node to the breakpoint - d - we have to calculate this one
1.343 + XY d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
1.344
1.345 - return XY(d_v.x+fix_node.x,d_v.y+fix_node.y);
1.346 - }
1.347 - break;
1.348 + return XY(d_v.x+fix_node.x,d_v.y+fix_node.y);
1.349 + }
1.350 + break;
1.351 }
1.352 default:
1.353 break;
1.354 - }
1.355 + }
1.356 }
1.357
1.358
1.359 bool GraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e)
1.360 {
1.361 + MapStorage& ms = *mytab.mapstorage;
1.362 +
1.363 switch(e->type)
1.364 {
1.365 //move the new node
1.366 @@ -301,35 +305,15 @@
1.367 }
1.368
1.369 case GDK_BUTTON_RELEASE:
1.370 - (mytab.mapstorage)->modified = true;
1.371 + ms.setModified();
1.372
1.373 is_drawn=true;
1.374
1.375 isbutton=1;
1.376
1.377 - active_node=(mytab.mapstorage)->graph.addNode();
1.378 -
1.379 - //initiating values corresponding to new node in maps
1.380 -
1.381 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.382
1.383 - // update coordinates
1.384 - (mytab.mapstorage)->coords.set(active_node, XY(clicked_x, clicked_y));
1.385 -
1.386 - // update all other maps
1.387 - for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
1.388 - (mytab.mapstorage)->nodemap_storage.begin(); it !=
1.389 - (mytab.mapstorage)->nodemap_storage.end(); ++it)
1.390 - {
1.391 - if ((it->first != "coordinates_x") &&
1.392 - (it->first != "coordinates_y"))
1.393 - {
1.394 - (*(it->second))[active_node] =
1.395 - (mytab.mapstorage)->nodemap_default[it->first];
1.396 - }
1.397 - }
1.398 - // increment the id map's default value
1.399 - (mytab.mapstorage)->nodemap_default["label"] += 1.0;
1.400 + active_node = ms.addNode(XY(clicked_x, clicked_y));
1.401
1.402 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
1.403 clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
1.404 @@ -348,7 +332,7 @@
1.405 nodetextmap[active_node]->property_fill_color().set_value("darkblue");
1.406 nodetextmap[active_node]->raise_to_top();
1.407
1.408 -// mapwin.updateNode(active_node);
1.409 + // mapwin.updateNode(active_node);
1.410 propertyUpdate(active_node);
1.411
1.412 isbutton=0;
1.413 @@ -364,6 +348,8 @@
1.414
1.415 bool GraphDisplayerCanvas::createEdgeEventHandler(GdkEvent* e)
1.416 {
1.417 + MapStorage& ms = *mytab.mapstorage;
1.418 +
1.419 switch(e->type)
1.420 {
1.421 case GDK_BUTTON_PRESS:
1.422 @@ -379,7 +365,7 @@
1.423
1.424 active_item=(get_item_at(clicked_x, clicked_y));
1.425 active_node=INVALID;
1.426 - for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.427 + for (NodeIt i(ms.graph); i!=INVALID; ++i)
1.428 {
1.429 if(nodesmap[i]==active_item)
1.430 {
1.431 @@ -408,7 +394,7 @@
1.432 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.433 target_item=(get_item_at(clicked_x, clicked_y));
1.434 Node target_node=INVALID;
1.435 - for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.436 + for (NodeIt i(ms.graph); i!=INVALID; ++i)
1.437 {
1.438 if(nodesmap[i]==target_item)
1.439 {
1.440 @@ -418,54 +404,24 @@
1.441 //the clicked item is a node, the edge can be drawn
1.442 if(target_node!=INVALID)
1.443 {
1.444 - (mytab.mapstorage)->modified = true;
1.445 + ms.setModified();
1.446
1.447 *(nodesmap[target_node]) <<
1.448 Gnome::Canvas::Properties::fill_color("red");
1.449
1.450 - //creating new edge
1.451 - active_edge=(mytab.mapstorage)->graph.addEdge(active_node,
1.452 - target_node);
1.453 -
1.454 - // update maps
1.455 - for (std::map<std::string,
1.456 - Graph::EdgeMap<double>*>::const_iterator it =
1.457 - (mytab.mapstorage)->edgemap_storage.begin(); it !=
1.458 - (mytab.mapstorage)->edgemap_storage.end(); ++it)
1.459 - {
1.460 - (*(it->second))[active_edge] =
1.461 - (mytab.mapstorage)->edgemap_default[it->first];
1.462 - }
1.463 - // increment the id map's default value
1.464 - (mytab.mapstorage)->edgemap_default["label"] += 1.0;
1.465 + active_edge = ms.addEdge(active_node, target_node);
1.466
1.467 if(target_node!=active_node)
1.468 {
1.469 - // set the coordinates of the arrow on the new edge
1.470 - MapStorage& ms = *mytab.mapstorage;
1.471 - ms.arrow_pos.set(active_edge,
1.472 - (ms.coords[ms.graph.source(active_edge)] +
1.473 - ms.coords[ms.graph.target(active_edge)])/ 2.0);
1.474 -
1.475 - //drawing new edge
1.476 - edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge,
1.477 - *this);
1.478 + edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge, *this);
1.479 }
1.480 else
1.481 {
1.482 - // set the coordinates of the arrow on the new edge
1.483 - MapStorage& ms = *mytab.mapstorage;
1.484 - ms.arrow_pos.set(active_edge,
1.485 - (ms.coords[ms.graph.source(active_edge)] +
1.486 - XY(0.0, 80.0)));
1.487 -
1.488 - //drawing new edge
1.489 - edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
1.490 - *this);
1.491 + edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge, *this);
1.492 }
1.493
1.494 //initializing edge-text as well, to empty string
1.495 - XY text_pos=mytab.mapstorage->arrow_pos[active_edge];
1.496 + XY text_pos=ms.getArrowCoords(active_edge);
1.497 text_pos+=(XY(10,10));
1.498
1.499 edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
1.500 @@ -494,12 +450,12 @@
1.501 {
1.502 if(active_item)
1.503 {
1.504 - propertyUpdate(active_node,N_COLOR);
1.505 + propertyUpdate(active_node,N_COLOR);
1.506 active_item=NULL;
1.507 }
1.508 if(target_item)
1.509 {
1.510 - propertyUpdate((mytab.mapstorage)->graph.target(active_edge),N_COLOR);
1.511 + propertyUpdate(ms.graph.target(active_edge),N_COLOR);
1.512 target_item=NULL;
1.513 }
1.514 active_node=INVALID;
1.515 @@ -514,8 +470,10 @@
1.516
1.517 bool GraphDisplayerCanvas::eraserEventHandler(GdkEvent* e)
1.518 {
1.519 + MapStorage& ms = *mytab.mapstorage;
1.520 +
1.521 switch(e->type)
1.522 - {
1.523 + {
1.524 case GDK_BUTTON_PRESS:
1.525 //finding the clicked items
1.526 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.527 @@ -523,88 +481,88 @@
1.528 active_node=INVALID;
1.529 active_edge=INVALID;
1.530 //was it a node?
1.531 - for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.532 - {
1.533 - if(nodesmap[i]==active_item)
1.534 - {
1.535 - active_node=i;
1.536 - }
1.537 - }
1.538 + for (NodeIt i(ms.graph); i!=INVALID; ++i)
1.539 + {
1.540 + if(nodesmap[i]==active_item)
1.541 + {
1.542 + active_node=i;
1.543 + }
1.544 + }
1.545 //or was it an edge?
1.546 if(active_node==INVALID)
1.547 - {
1.548 - for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.549 - {
1.550 - if(edgesmap[i]->getLine()==active_item)
1.551 - {
1.552 - active_edge=i;
1.553 - }
1.554 - }
1.555 - }
1.556 + {
1.557 + for (EdgeIt i(ms.graph); i!=INVALID; ++i)
1.558 + {
1.559 + if(edgesmap[i]->getLine()==active_item)
1.560 + {
1.561 + active_edge=i;
1.562 + }
1.563 + }
1.564 + }
1.565
1.566 // return if the clicked object is neither an edge nor a node
1.567 if (active_edge == INVALID) return false;
1.568 -
1.569 +
1.570 //recolor activated item
1.571 if(active_item)
1.572 - {
1.573 - *active_item << Gnome::Canvas::Properties::fill_color("red");
1.574 - }
1.575 + {
1.576 + *active_item << Gnome::Canvas::Properties::fill_color("red");
1.577 + }
1.578 break;
1.579
1.580 case GDK_BUTTON_RELEASE:
1.581 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.582 if(active_item)
1.583 - {
1.584 - //the cursor was not moved since pressing it
1.585 - if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
1.586 - {
1.587 - //a node was found
1.588 - if(active_node!=INVALID)
1.589 - {
1.590 - (mytab.mapstorage)->modified = true;
1.591 + {
1.592 + //the cursor was not moved since pressing it
1.593 + if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
1.594 + {
1.595 + //a node was found
1.596 + if(active_node!=INVALID)
1.597 + {
1.598 + ms.setModified();
1.599
1.600 - std::set<Graph::Edge> edges_to_delete;
1.601 + std::set<Graph::Edge> edges_to_delete;
1.602
1.603 - for(OutEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
1.604 - {
1.605 - edges_to_delete.insert(e);
1.606 - }
1.607 -
1.608 - for(InEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
1.609 - {
1.610 - edges_to_delete.insert(e);
1.611 - }
1.612 -
1.613 - //deleting collected edges
1.614 - for(std::set<Graph::Edge>::iterator
1.615 - edge_set_it=edges_to_delete.begin();
1.616 - edge_set_it!=edges_to_delete.end();
1.617 - ++edge_set_it)
1.618 - {
1.619 - deleteItem(*edge_set_it);
1.620 - }
1.621 - deleteItem(active_node);
1.622 - }
1.623 - //a simple edge was chosen
1.624 - else if (active_edge != INVALID)
1.625 - {
1.626 - deleteItem(active_edge);
1.627 - }
1.628 - }
1.629 - //pointer was moved, deletion is cancelled
1.630 - else
1.631 - {
1.632 - if(active_node!=INVALID)
1.633 - {
1.634 - *active_item << Gnome::Canvas::Properties::fill_color("blue");
1.635 - }
1.636 - else if (active_edge != INVALID)
1.637 - {
1.638 - *active_item << Gnome::Canvas::Properties::fill_color("green");
1.639 - }
1.640 - }
1.641 - }
1.642 + for(OutEdgeIt e(ms.graph,active_node);e!=INVALID;++e)
1.643 + {
1.644 + edges_to_delete.insert(e);
1.645 + }
1.646 +
1.647 + for(InEdgeIt e(ms.graph,active_node);e!=INVALID;++e)
1.648 + {
1.649 + edges_to_delete.insert(e);
1.650 + }
1.651 +
1.652 + //deleting collected edges
1.653 + for(std::set<Graph::Edge>::iterator
1.654 + edge_set_it=edges_to_delete.begin();
1.655 + edge_set_it!=edges_to_delete.end();
1.656 + ++edge_set_it)
1.657 + {
1.658 + deleteItem(*edge_set_it);
1.659 + }
1.660 + deleteItem(active_node);
1.661 + }
1.662 + //a simple edge was chosen
1.663 + else if (active_edge != INVALID)
1.664 + {
1.665 + deleteItem(active_edge);
1.666 + }
1.667 + }
1.668 + //pointer was moved, deletion is cancelled
1.669 + else
1.670 + {
1.671 + if(active_node!=INVALID)
1.672 + {
1.673 + *active_item << Gnome::Canvas::Properties::fill_color("blue");
1.674 + }
1.675 + else if (active_edge != INVALID)
1.676 + {
1.677 + *active_item << Gnome::Canvas::Properties::fill_color("green");
1.678 + }
1.679 + }
1.680 + }
1.681 //reseting datas
1.682 active_item=NULL;
1.683 active_edge=INVALID;
1.684 @@ -616,167 +574,201 @@
1.685
1.686 default:
1.687 break;
1.688 - }
1.689 + }
1.690 return false;
1.691 }
1.692
1.693 bool GraphDisplayerCanvas::mapEditEventHandler(GdkEvent* e)
1.694 {
1.695 + MapStorage& ms = *mytab.mapstorage;
1.696 +
1.697 if(actual_tool==MAP_EDIT)
1.698 + {
1.699 + switch(e->type)
1.700 {
1.701 - switch(e->type)
1.702 - {
1.703 - case GDK_BUTTON_PRESS:
1.704 - {
1.705 - //for determine, whether it was an edge
1.706 - Edge clicked_edge=INVALID;
1.707 - //for determine, whether it was a node
1.708 - Node clicked_node=INVALID;
1.709 + case GDK_BUTTON_PRESS:
1.710 + {
1.711 + //for determine, whether it was an edge
1.712 + Edge clicked_edge=INVALID;
1.713 + //for determine, whether it was a node
1.714 + Node clicked_node=INVALID;
1.715
1.716 - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.717 - active_item=(get_item_at(clicked_x, clicked_y));
1.718 + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.719 + active_item=(get_item_at(clicked_x, clicked_y));
1.720
1.721 - //find the activated item between text of nodes
1.722 - for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.723 - {
1.724 - //at the same time only one can be active
1.725 - if(nodetextmap[i]==active_item)
1.726 - {
1.727 - clicked_node=i;
1.728 - }
1.729 - }
1.730 + //find the activated item between text of nodes
1.731 + for (NodeIt i(ms.graph); i!=INVALID; ++i)
1.732 + {
1.733 + //at the same time only one can be active
1.734 + if(nodetextmap[i]==active_item)
1.735 + {
1.736 + clicked_node=i;
1.737 + }
1.738 + }
1.739
1.740 - //if there was not, search for it between nodes
1.741 - if(clicked_node==INVALID)
1.742 - {
1.743 - for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.744 - {
1.745 - //at the same time only one can be active
1.746 - if(nodesmap[i]==active_item)
1.747 - {
1.748 - clicked_node=i;
1.749 - }
1.750 - }
1.751 - }
1.752 + //if there was not, search for it between nodes
1.753 + if(clicked_node==INVALID)
1.754 + {
1.755 + for (NodeIt i(ms.graph); i!=INVALID; ++i)
1.756 + {
1.757 + //at the same time only one can be active
1.758 + if(nodesmap[i]==active_item)
1.759 + {
1.760 + clicked_node=i;
1.761 + }
1.762 + }
1.763 + }
1.764
1.765 - if(clicked_node==INVALID)
1.766 - {
1.767 - //find the activated item between texts
1.768 - for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.769 - {
1.770 - //at the same time only one can be active
1.771 - if(edgetextmap[i]==active_item)
1.772 - {
1.773 - clicked_edge=i;
1.774 - }
1.775 - }
1.776 + if(clicked_node==INVALID)
1.777 + {
1.778 + //find the activated item between texts
1.779 + for (EdgeIt i(ms.graph); i!=INVALID; ++i)
1.780 + {
1.781 + //at the same time only one can be active
1.782 + if(edgetextmap[i]==active_item)
1.783 + {
1.784 + clicked_edge=i;
1.785 + }
1.786 + }
1.787
1.788 - //if it was not between texts, search for it between edges
1.789 - if(clicked_edge==INVALID)
1.790 - {
1.791 - for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.792 - {
1.793 - //at the same time only one can be active
1.794 - if((edgesmap[i]->getLine())==active_item)
1.795 - {
1.796 - clicked_edge=i;
1.797 - }
1.798 - }
1.799 - }
1.800 - }
1.801 + //if it was not between texts, search for it between edges
1.802 + if(clicked_edge==INVALID)
1.803 + {
1.804 + for (EdgeIt i(ms.graph); i!=INVALID; ++i)
1.805 + {
1.806 + //at the same time only one can be active
1.807 + if((edgesmap[i]->getLine())==active_item)
1.808 + {
1.809 + clicked_edge=i;
1.810 + }
1.811 + }
1.812 + }
1.813 + }
1.814
1.815 - //if it was really a node...
1.816 - if(clicked_node!=INVALID)
1.817 - {
1.818 - // the id map is not editable
1.819 - if (nodemap_to_edit == "label") return 0;
1.820 + //if it was really a node...
1.821 + if(clicked_node!=INVALID)
1.822 + {
1.823 + // the id map is not editable
1.824 + if (nodemap_to_edit == "label") return 0;
1.825
1.826 - //and there is activated map
1.827 - if(nodetextmap[clicked_node]->property_text().get_value()!="")
1.828 - {
1.829 - //activate the general variable for it
1.830 - active_node=clicked_node;
1.831 + //and there is activated map
1.832 + if(nodetextmap[clicked_node]->property_text().get_value()!="")
1.833 + {
1.834 + //activate the general variable for it
1.835 + active_node=clicked_node;
1.836
1.837 - //create a dialog
1.838 - Gtk::Dialog dialog("Edit value", true);
1.839 - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.840 - dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
1.841 - Gtk::VBox* vbox = dialog.get_vbox();
1.842 - Gtk::SpinButton spin(0.0, 4);
1.843 - spin.set_increments(1.0, 10.0);
1.844 - spin.set_range(-1000000.0, 1000000.0);
1.845 - spin.set_numeric(true);
1.846 - spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
1.847 - vbox->add(spin);
1.848 - spin.show();
1.849 - switch (dialog.run())
1.850 - {
1.851 - case Gtk::RESPONSE_NONE:
1.852 - case Gtk::RESPONSE_CANCEL:
1.853 - break;
1.854 - case Gtk::RESPONSE_ACCEPT:
1.855 - double new_value = spin.get_value();
1.856 - (*(mytab.mapstorage)->nodemap_storage[nodemap_to_edit])[active_node] =
1.857 - new_value;
1.858 - std::ostringstream ostr;
1.859 - ostr << new_value;
1.860 - nodetextmap[active_node]->property_text().set_value(ostr.str());
1.861 - //mapwin.updateNode(active_node);
1.862 - //mapwin.updateNode(Node(INVALID));
1.863 - propertyUpdate(Node(INVALID));
1.864 - }
1.865 - }
1.866 - }
1.867 - else
1.868 - //if it was really an edge...
1.869 - if(clicked_edge!=INVALID)
1.870 - {
1.871 - // the id map is not editable
1.872 - if (edgemap_to_edit == "label") return 0;
1.873 + //create a dialog
1.874 + Gtk::Dialog dialog("Edit value", true);
1.875 + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.876 + dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
1.877 + Gtk::VBox* vbox = dialog.get_vbox();
1.878
1.879 - //and there is activated map
1.880 - if(edgetextmap[clicked_edge]->property_text().get_value()!="")
1.881 - {
1.882 - //activate the general variable for it
1.883 - active_edge=clicked_edge;
1.884 + /*
1.885 + Gtk::SpinButton spin(0.0, 4);
1.886 + spin.set_increments(1.0, 10.0);
1.887 + spin.set_range(-1000000.0, 1000000.0);
1.888 + spin.set_numeric(true);
1.889 + spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
1.890 + vbox->add(spin);
1.891 + spin.show();
1.892 + */
1.893 + Gtk::Entry entry;
1.894 + entry.set_text(nodetextmap[active_node]->property_text().get_value());
1.895 + vbox->add(entry);
1.896 + entry.show();
1.897
1.898 - //create a dialog
1.899 - Gtk::Dialog dialog("Edit value", true);
1.900 - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.901 - dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
1.902 - Gtk::VBox* vbox = dialog.get_vbox();
1.903 - Gtk::SpinButton spin(0.0, 4);
1.904 - spin.set_increments(1.0, 10.0);
1.905 - spin.set_range(-1000000.0, 1000000.0);
1.906 - spin.set_numeric(true);
1.907 - spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
1.908 - vbox->add(spin);
1.909 - spin.show();
1.910 - switch (dialog.run())
1.911 - {
1.912 - case Gtk::RESPONSE_NONE:
1.913 - case Gtk::RESPONSE_CANCEL:
1.914 - break;
1.915 - case Gtk::RESPONSE_ACCEPT:
1.916 - double new_value = spin.get_value();
1.917 - (*(mytab.mapstorage)->edgemap_storage[edgemap_to_edit])[active_edge] =
1.918 - new_value;
1.919 - std::ostringstream ostr;
1.920 - ostr << new_value;
1.921 - edgetextmap[active_edge]->property_text().set_value(
1.922 - ostr.str());
1.923 - //mapwin.updateEdge(active_edge);
1.924 - // mapwin.updateEdge(Edge(INVALID));
1.925 - propertyUpdate(Edge(INVALID));
1.926 - }
1.927 - }
1.928 - }
1.929 - break;
1.930 - }
1.931 - default:
1.932 - break;
1.933 - }
1.934 + switch (dialog.run())
1.935 + {
1.936 + case Gtk::RESPONSE_NONE:
1.937 + case Gtk::RESPONSE_CANCEL:
1.938 + break;
1.939 + case Gtk::RESPONSE_ACCEPT:
1.940 + switch (ms.getNodeMapElementType(nodemap_to_edit))
1.941 + {
1.942 + case MapValue::NUMERIC:
1.943 + ms.set(nodemap_to_edit, active_node,
1.944 + atof(entry.get_text().c_str()));
1.945 + break;
1.946 + case MapValue::STRING:
1.947 + ms.set(nodemap_to_edit, active_node,
1.948 + static_cast<std::string>(entry.get_text()));
1.949 + break;
1.950 + }
1.951 + nodetextmap[active_node]->property_text().set_value(
1.952 + static_cast<std::string>(ms.get(nodemap_to_edit, active_node)));
1.953 +
1.954 + //mapwin.updateNode(active_node);
1.955 + //mapwin.updateNode(Node(INVALID));
1.956 + propertyUpdate(Node(INVALID));
1.957 + }
1.958 + }
1.959 + }
1.960 + else
1.961 + //if it was really an edge...
1.962 + if(clicked_edge!=INVALID)
1.963 + {
1.964 + // the id map is not editable
1.965 + if (edgemap_to_edit == "label") return 0;
1.966 +
1.967 + //and there is activated map
1.968 + if(edgetextmap[clicked_edge]->property_text().get_value()!="")
1.969 + {
1.970 + //activate the general variable for it
1.971 + active_edge=clicked_edge;
1.972 +
1.973 + //create a dialog
1.974 + Gtk::Dialog dialog("Edit value", true);
1.975 + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.976 + dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
1.977 + Gtk::VBox* vbox = dialog.get_vbox();
1.978 +
1.979 + /*
1.980 + Gtk::SpinButton spin(0.0, 4);
1.981 + spin.set_increments(1.0, 10.0);
1.982 + spin.set_range(-1000000.0, 1000000.0);
1.983 + spin.set_numeric(true);
1.984 + spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
1.985 + vbox->add(spin);
1.986 + spin.show();
1.987 + */
1.988 + Gtk::Entry entry;
1.989 + entry.set_text(edgetextmap[active_edge]->property_text().get_value());
1.990 + vbox->add(entry);
1.991 + entry.show();
1.992 +
1.993 + std::cout << edgemap_to_edit << std::endl;
1.994 + switch (dialog.run())
1.995 + {
1.996 + case Gtk::RESPONSE_NONE:
1.997 + case Gtk::RESPONSE_CANCEL:
1.998 + break;
1.999 + case Gtk::RESPONSE_ACCEPT:
1.1000 + switch (ms.getEdgeMapElementType(edgemap_to_edit))
1.1001 + {
1.1002 + case MapValue::NUMERIC:
1.1003 + ms.set(edgemap_to_edit, active_edge,
1.1004 + atof(entry.get_text().c_str()));
1.1005 + break;
1.1006 + case MapValue::STRING:
1.1007 + ms.set(edgemap_to_edit, active_edge,
1.1008 + static_cast<std::string>(entry.get_text()));
1.1009 + break;
1.1010 + }
1.1011 + edgetextmap[active_edge]->property_text().set_value(
1.1012 + static_cast<std::string>(ms.get(edgemap_to_edit, active_edge)));
1.1013 +
1.1014 + //mapwin.updateEdge(active_edge);
1.1015 + // mapwin.updateEdge(Edge(INVALID));
1.1016 + propertyUpdate(Edge(INVALID));
1.1017 + }
1.1018 + }
1.1019 + }
1.1020 + break;
1.1021 + }
1.1022 + default:
1.1023 + break;
1.1024 }
1.1025 + }
1.1026 return false;
1.1027 }
1.1028
1.1029 @@ -784,14 +776,14 @@
1.1030 {
1.1031 delete(nodetextmap[node_to_delete]);
1.1032 delete(nodesmap[node_to_delete]);
1.1033 - (mytab.mapstorage)->graph.erase(node_to_delete);
1.1034 + mytab.mapstorage->graph.erase(node_to_delete);
1.1035 }
1.1036
1.1037 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
1.1038 {
1.1039 delete(edgetextmap[edge_to_delete]);
1.1040 delete(edgesmap[edge_to_delete]);
1.1041 - (mytab.mapstorage)->graph.erase(edge_to_delete);
1.1042 + mytab.mapstorage->graph.erase(edge_to_delete);
1.1043 }
1.1044
1.1045 void GraphDisplayerCanvas::textReposition(XY new_place)
1.1046 @@ -811,7 +803,7 @@
1.1047 }
1.1048 else
1.1049 {
1.1050 - for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
1.1051 + for (EdgeIt i(mytab.mapstorage->graph); i!=INVALID; ++i)
1.1052 {
1.1053 if(edgesmap[i]==active_bre)
1.1054 {
1.1055 @@ -821,99 +813,99 @@
1.1056 }
1.1057 }
1.1058 else
1.1059 + {
1.1060 + if(forming_edge!=INVALID)
1.1061 {
1.1062 - if(forming_edge!=INVALID)
1.1063 - {
1.1064 - forming_edge=INVALID;
1.1065 - }
1.1066 - else
1.1067 - {
1.1068 - std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
1.1069 - }
1.1070 + forming_edge=INVALID;
1.1071 }
1.1072 + else
1.1073 + {
1.1074 + std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
1.1075 + }
1.1076 + }
1.1077 }
1.1078
1.1079 void GraphDisplayerCanvas::moveNode(double dx, double dy, Gnome::Canvas::Item * item, Node node)
1.1080 {
1.1081 + MapStorage& ms = *mytab.mapstorage;
1.1082 +
1.1083 Gnome::Canvas::Item * moved_item=item;
1.1084 Node moved_node=node;
1.1085
1.1086 if(item==NULL && node==INVALID)
1.1087 - {
1.1088 - moved_item=active_item;
1.1089 - moved_node=active_node;
1.1090 - }
1.1091 + {
1.1092 + moved_item=active_item;
1.1093 + moved_node=active_node;
1.1094 + }
1.1095 else
1.1096 - {
1.1097 - isbutton=1;
1.1098 - }
1.1099 + {
1.1100 + isbutton=1;
1.1101 + }
1.1102
1.1103 //repositioning node and its text
1.1104 moved_item->move(dx, dy);
1.1105 nodetextmap[moved_node]->move(dx, dy);
1.1106
1.1107 // the new coordinates of the centre of the node
1.1108 - double coord_x = dx + (mytab.mapstorage)->coords[moved_node].x;
1.1109 - double coord_y = dy + (mytab.mapstorage)->coords[moved_node].y;
1.1110 + double coord_x = dx + ms.getNodeCoords(moved_node).x;
1.1111 + double coord_y = dy + ms.getNodeCoords(moved_node).y;
1.1112
1.1113 // write back the new coordinates to the coords map
1.1114 - (mytab.mapstorage)->coords.set(moved_node, XY(coord_x, coord_y));
1.1115 + ms.setNodeCoords(moved_node, XY(coord_x, coord_y));
1.1116
1.1117 //all the edges connected to the moved point has to be redrawn
1.1118 - for(OutEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
1.1119 + for(OutEdgeIt ei(ms.graph,moved_node);ei!=INVALID;++ei)
1.1120 + {
1.1121 + XY arrow_pos;
1.1122 +
1.1123 + if (ms.graph.source(ei) == ms.graph.target(ei))
1.1124 {
1.1125 + arrow_pos = ms.getArrowCoords(ei) + XY(dx, dy);
1.1126 + }
1.1127 + else
1.1128 + {
1.1129 + XY moved_node_1(coord_x - dx, coord_y - dy);
1.1130 + XY moved_node_2(coord_x, coord_y);
1.1131 + Node target = ms.graph.target(ei);
1.1132 + XY fix_node = ms.getNodeCoords(target);
1.1133 + XY old_arrow_pos(ms.getArrowCoords(ei));
1.1134 +
1.1135 + arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
1.1136 + }
1.1137 +
1.1138 + ms.setArrowCoords(ei, arrow_pos);
1.1139 + edgesmap[ei]->draw();
1.1140 +
1.1141 + //reposition of edgetext
1.1142 + XY text_pos=ms.getArrowCoords(ei);
1.1143 + text_pos+=(XY(10,10));
1.1144 + edgetextmap[ei]->property_x().set_value(text_pos.x);
1.1145 + edgetextmap[ei]->property_y().set_value(text_pos.y);
1.1146 + }
1.1147 +
1.1148 + for(InEdgeIt ei(ms.graph,moved_node);ei!=INVALID;++ei)
1.1149 + {
1.1150 + if (ms.graph.source(ei) != ms.graph.target(ei))
1.1151 + {
1.1152 + XY moved_node_1(coord_x - dx, coord_y - dy);
1.1153 + XY moved_node_2(coord_x, coord_y);
1.1154 + Node source = ms.graph.source(ei);
1.1155 + XY fix_node = ms.getNodeCoords(source);
1.1156 + XY old_arrow_pos(ms.getArrowCoords(ei));
1.1157 +
1.1158 XY arrow_pos;
1.1159 + arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
1.1160
1.1161 - if (mytab.mapstorage->graph.source(ei) == mytab.mapstorage->graph.target(ei))
1.1162 - {
1.1163 - arrow_pos = mytab.mapstorage->arrow_pos[ei] + XY(dx, dy);
1.1164 - }
1.1165 - else
1.1166 - {
1.1167 - XY moved_node_1(coord_x - dx, coord_y - dy);
1.1168 - XY moved_node_2(coord_x, coord_y);
1.1169 - Node target = mytab.mapstorage->graph.target(ei);
1.1170 - XY fix_node(mytab.mapstorage->coords[target].x,
1.1171 - mytab.mapstorage->coords[target].y);
1.1172 - XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
1.1173 -
1.1174 - arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
1.1175 - }
1.1176 -
1.1177 - mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
1.1178 + ms.setArrowCoords(ei, arrow_pos);
1.1179 edgesmap[ei]->draw();
1.1180
1.1181 //reposition of edgetext
1.1182 - XY text_pos=mytab.mapstorage->arrow_pos[ei];
1.1183 + XY text_pos=ms.getArrowCoords(ei);
1.1184 text_pos+=(XY(10,10));
1.1185 edgetextmap[ei]->property_x().set_value(text_pos.x);
1.1186 edgetextmap[ei]->property_y().set_value(text_pos.y);
1.1187 }
1.1188 -
1.1189 - for(InEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
1.1190 - {
1.1191 - if (mytab.mapstorage->graph.source(ei) != mytab.mapstorage->graph.target(ei))
1.1192 - {
1.1193 - XY moved_node_1(coord_x - dx, coord_y - dy);
1.1194 - XY moved_node_2(coord_x, coord_y);
1.1195 - Node source = mytab.mapstorage->graph.source(ei);
1.1196 - XY fix_node(mytab.mapstorage->coords[source].x,
1.1197 - mytab.mapstorage->coords[source].y);
1.1198 - XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
1.1199 -
1.1200 - XY arrow_pos;
1.1201 - arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
1.1202 -
1.1203 - mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
1.1204 - edgesmap[ei]->draw();
1.1205 -
1.1206 - //reposition of edgetext
1.1207 - XY text_pos=mytab.mapstorage->arrow_pos[ei];
1.1208 - text_pos+=(XY(10,10));
1.1209 - edgetextmap[ei]->property_x().set_value(text_pos.x);
1.1210 - edgetextmap[ei]->property_y().set_value(text_pos.y);
1.1211 - }
1.1212 - }
1.1213 + }
1.1214 }
1.1215
1.1216 Gdk::Color GraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
1.1217 @@ -928,48 +920,48 @@
1.1218 //first we determine the phase, in which
1.1219 //the actual value belongs to
1.1220 for (int i=0;i<=5;i++)
1.1221 + {
1.1222 + if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
1.1223 {
1.1224 - if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
1.1225 - {
1.1226 - phase=i;
1.1227 - }
1.1228 + phase=i;
1.1229 }
1.1230 + }
1.1231 if(phase<6)
1.1232 + {
1.1233 + //within its 1/6 long phase the relativ position
1.1234 + //determines the power of the color changed in
1.1235 + //that phase
1.1236 + //we normalize that to one, to be able to give percentage
1.1237 + //value for the function
1.1238 + double rel_pos=(pos-(phase/6.0))*6.0;
1.1239 +
1.1240 + switch(phase)
1.1241 {
1.1242 - //within its 1/6 long phase the relativ position
1.1243 - //determines the power of the color changed in
1.1244 - //that phase
1.1245 - //we normalize that to one, to be able to give percentage
1.1246 - //value for the function
1.1247 - double rel_pos=(pos-(phase/6.0))*6.0;
1.1248 -
1.1249 - switch(phase)
1.1250 - {
1.1251 - case 0:
1.1252 - color.set_rgb_p (1, 0, 1-rel_pos);
1.1253 - break;
1.1254 - case 1:
1.1255 - color.set_rgb_p (1, rel_pos, 0);
1.1256 - break;
1.1257 - case 2:
1.1258 - color.set_rgb_p (1-rel_pos, 1, 0);
1.1259 - break;
1.1260 - case 3:
1.1261 - color.set_rgb_p (0, 1, rel_pos);
1.1262 - break;
1.1263 - case 4:
1.1264 - color.set_rgb_p (0, 1-rel_pos, 1);
1.1265 - break;
1.1266 - case 5:
1.1267 - color.set_rgb_p ((rel_pos/3.0), 0, 1);
1.1268 - break;
1.1269 - default:
1.1270 - std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
1.1271 - }
1.1272 + case 0:
1.1273 + color.set_rgb_p (1, 0, 1-rel_pos);
1.1274 + break;
1.1275 + case 1:
1.1276 + color.set_rgb_p (1, rel_pos, 0);
1.1277 + break;
1.1278 + case 2:
1.1279 + color.set_rgb_p (1-rel_pos, 1, 0);
1.1280 + break;
1.1281 + case 3:
1.1282 + color.set_rgb_p (0, 1, rel_pos);
1.1283 + break;
1.1284 + case 4:
1.1285 + color.set_rgb_p (0, 1-rel_pos, 1);
1.1286 + break;
1.1287 + case 5:
1.1288 + color.set_rgb_p ((rel_pos/3.0), 0, 1);
1.1289 + break;
1.1290 + default:
1.1291 + std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
1.1292 }
1.1293 + }
1.1294 else
1.1295 - {
1.1296 - std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
1.1297 - }
1.1298 + {
1.1299 + std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
1.1300 + }
1.1301 return color;
1.1302 }