1.1 --- a/graph_displayer_canvas-event.cc Thu Sep 21 10:29:29 2006 +0000
1.2 +++ b/graph_displayer_canvas-event.cc Mon Sep 25 07:54:00 2006 +0000
1.3 @@ -409,39 +409,29 @@
1.4 //the clicked item is a node, the edge can be drawn
1.5 if(target_node!=INVALID)
1.6 {
1.7 + (mytab.mapstorage).modified = true;
1.8 +
1.9 + *(nodesmap[target_node]) <<
1.10 + Gnome::Canvas::Properties::fill_color("red");
1.11 +
1.12 + //creating new edge
1.13 + active_edge=(mytab.mapstorage).graph.addEdge(active_node,
1.14 + target_node);
1.15 +
1.16 + // update maps
1.17 + for (std::map<std::string,
1.18 + Graph::EdgeMap<double>*>::const_iterator it =
1.19 + (mytab.mapstorage).edgemap_storage.begin(); it !=
1.20 + (mytab.mapstorage).edgemap_storage.end(); ++it)
1.21 + {
1.22 + (*(it->second))[active_edge] =
1.23 + (mytab.mapstorage).edgemap_default[it->first];
1.24 + }
1.25 + // increment the id map's default value
1.26 + (mytab.mapstorage).edgemap_default["label"] += 1.0;
1.27 +
1.28 if(target_node!=active_node)
1.29 {
1.30 - (mytab.mapstorage).modified = true;
1.31 -
1.32 - *(nodesmap[target_node]) <<
1.33 - Gnome::Canvas::Properties::fill_color("red");
1.34 -
1.35 - //creating new edge
1.36 - active_edge=(mytab.mapstorage).graph.addEdge(active_node,
1.37 - target_node);
1.38 -
1.39 - // update maps
1.40 - for (std::map<std::string,
1.41 - Graph::EdgeMap<double>*>::const_iterator it =
1.42 - (mytab.mapstorage).edgemap_storage.begin(); it !=
1.43 - (mytab.mapstorage).edgemap_storage.end(); ++it)
1.44 - {
1.45 - (*(it->second))[active_edge] =
1.46 - (mytab.mapstorage).edgemap_default[it->first];
1.47 - }
1.48 - // increment the id map's default value
1.49 - (mytab.mapstorage).edgemap_default["label"] += 1.0;
1.50 -
1.51 - //calculating coordinates of new edge
1.52 - Gnome::Canvas::Points coos;
1.53 - double x1, x2, y1, y2;
1.54 -
1.55 - active_item->get_bounds(x1, y1, x2, y2);
1.56 - coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
1.57 -
1.58 - target_item->get_bounds(x1, y1, x2, y2);
1.59 - coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
1.60 -
1.61 // set the coordinates of the arrow on the new edge
1.62 MapStorage& ms = mytab.mapstorage;
1.63 ms.arrow_pos.set(active_edge,
1.64 @@ -451,26 +441,31 @@
1.65 //drawing new edge
1.66 edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge,
1.67 *this);
1.68 -
1.69 - //initializing edge-text as well, to empty string
1.70 - XY text_pos=mytab.mapstorage.arrow_pos[active_edge];
1.71 - text_pos+=(XY(10,10));
1.72 -
1.73 - edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
1.74 - text_pos.x, text_pos.y, "");
1.75 - edgetextmap[active_edge]->property_fill_color().set_value(
1.76 - "darkgreen");
1.77 - edgetextmap[active_edge]->raise_to_top();
1.78 -
1.79 - //updating its properties
1.80 -// mapwin.updateEdge(active_edge);
1.81 - propertyUpdate(active_edge);
1.82 }
1.83 else
1.84 {
1.85 - target_node=INVALID;
1.86 - std::cerr << "Loop edge is not yet implemented!" << std::endl;
1.87 + // set the coordinates of the arrow on the new edge
1.88 + MapStorage& ms = mytab.mapstorage;
1.89 + ms.arrow_pos.set(active_edge,
1.90 + (ms.coords[ms.graph.source(active_edge)] +
1.91 + XY(0.0, 80.0)));
1.92 +
1.93 + //drawing new edge
1.94 + edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
1.95 + *this);
1.96 }
1.97 +
1.98 + //initializing edge-text as well, to empty string
1.99 + XY text_pos=mytab.mapstorage.arrow_pos[active_edge];
1.100 + text_pos+=(XY(10,10));
1.101 +
1.102 + edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
1.103 + text_pos.x, text_pos.y, "");
1.104 + edgetextmap[active_edge]->property_fill_color().set_value(
1.105 + "darkgreen");
1.106 + edgetextmap[active_edge]->raise_to_top();
1.107 +
1.108 + propertyUpdate(active_edge);
1.109 }
1.110 //clicked item was not a node. it could be an e.g. edge. we do not
1.111 //deal with it furthermore.