1.1 --- a/gui/graph_displayer_canvas-event.cc Tue Aug 23 07:36:09 2005 +0000
1.2 +++ b/gui/graph_displayer_canvas-event.cc Tue Aug 23 15:57:12 2005 +0000
1.3 @@ -240,23 +240,20 @@
1.4 // update coordinates
1.5 mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));
1.6
1.7 - // update id map
1.8 - (*mapstorage.nodemap_storage["id"])[active_node] =
1.9 - mapstorage.graph.id(active_node);
1.10 -
1.11 // update all other maps
1.12 for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
1.13 mapstorage.nodemap_storage.begin(); it !=
1.14 mapstorage.nodemap_storage.end(); ++it)
1.15 {
1.16 - if ((it->first != "id") &&
1.17 - (it->first != "coordinates_x") &&
1.18 - (it->first != "coordiantes_y"))
1.19 + if ((it->first != "coordinates_x") &&
1.20 + (it->first != "coordinates_y"))
1.21 {
1.22 (*(it->second))[active_node] =
1.23 mapstorage.nodemap_default[it->first];
1.24 }
1.25 }
1.26 + // increment the id map's default value
1.27 + mapstorage.nodemap_default["id"] += 1.0;
1.28
1.29 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
1.30 clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
1.31 @@ -356,22 +353,17 @@
1.32 active_edge=mapstorage.graph.addEdge(active_node,
1.33 target_node);
1.34
1.35 - // update id map
1.36 - (*mapstorage.edgemap_storage["id"])[active_edge] =
1.37 - mapstorage.graph.id(active_edge);
1.38 -
1.39 - // update all other maps
1.40 + // update maps
1.41 for (std::map<std::string,
1.42 Graph::EdgeMap<double>*>::const_iterator it =
1.43 mapstorage.edgemap_storage.begin(); it !=
1.44 mapstorage.edgemap_storage.end(); ++it)
1.45 {
1.46 - if (it->first != "id")
1.47 - {
1.48 - (*(it->second))[active_edge] =
1.49 - mapstorage.edgemap_default[it->first];
1.50 - }
1.51 + (*(it->second))[active_edge] =
1.52 + mapstorage.edgemap_default[it->first];
1.53 }
1.54 + // increment the id map's default value
1.55 + mapstorage.edgemap_default["id"] += 1.0;
1.56
1.57 //calculating coordinates of new edge
1.58 Gnome::Canvas::Points coos;
2.1 --- a/gui/mapstorage.cc Tue Aug 23 07:36:09 2005 +0000
2.2 +++ b/gui/mapstorage.cc Tue Aug 23 15:57:12 2005 +0000
2.3 @@ -11,6 +11,9 @@
2.4
2.5 nodemap_storage["id"] = new Graph::NodeMap<double>(graph);
2.6 edgemap_storage["id"] = new Graph::EdgeMap<double>(graph);
2.7 +
2.8 + nodemap_default["id"] = 1.0;
2.9 + edgemap_default["id"] = 1.0;
2.10 }
2.11
2.12 MapStorage::~MapStorage()
2.13 @@ -125,6 +128,7 @@
2.14 {
2.15 bool read_x = false;
2.16 bool read_y = false;
2.17 + bool read_edge_id = false;
2.18
2.19 try {
2.20 LemonReader lreader(filename);
2.21 @@ -182,6 +186,16 @@
2.22 return 1;
2.23 }
2.24
2.25 + if (!read_edge_id)
2.26 + {
2.27 + edgemap_storage["id"] = new Graph::EdgeMap<double>(graph);
2.28 + int i = 1;
2.29 + for (EdgeIt e(graph); e != INVALID; ++e)
2.30 + {
2.31 + (*edgemap_storage["id"])[e] = i++;
2.32 + }
2.33 + }
2.34 +
2.35 if (!read_x || !read_y)
2.36 {
2.37 int node_num = 0;
2.38 @@ -210,6 +224,17 @@
2.39 {
2.40 nodemap_default[it->first] = 0.0;
2.41 }
2.42 + else if (it->first == "id")
2.43 + {
2.44 + NodeIt n(graph);
2.45 + double max = (*nodemap_storage["id"])[n];
2.46 + for (; n != INVALID; ++n)
2.47 + {
2.48 + if ((*nodemap_storage["id"])[n] > max)
2.49 + max = (*nodemap_storage["id"])[n];
2.50 + }
2.51 + nodemap_default["id"] = max + 1.0;
2.52 + }
2.53 }
2.54 for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
2.55 edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
2.56 @@ -218,6 +243,17 @@
2.57 {
2.58 edgemap_default[it->first] = 0.0;
2.59 }
2.60 + else
2.61 + {
2.62 + EdgeIt e(graph);
2.63 + double max = (*edgemap_storage["id"])[e];
2.64 + for (; e != INVALID; ++e)
2.65 + {
2.66 + if ((*edgemap_storage["id"])[e] > max)
2.67 + max = (*edgemap_storage["id"])[e];
2.68 + }
2.69 + edgemap_default["id"] = max + 1.0;
2.70 + }
2.71 }
2.72
2.73 return 0;
2.74 @@ -267,12 +303,14 @@
2.75 for (std::map<std::string, double>::iterator it =
2.76 nodemap_default.begin(); it != nodemap_default.end(); ++it)
2.77 {
2.78 - nodemap_default.erase(it);
2.79 + if (it->first != "id")
2.80 + nodemap_default.erase(it);
2.81 }
2.82 for (std::map<std::string, double>::iterator it =
2.83 edgemap_default.begin(); it != edgemap_default.end(); ++it)
2.84 {
2.85 - edgemap_default.erase(it);
2.86 + if (it->first != "id")
2.87 + edgemap_default.erase(it);
2.88 }
2.89 graph.clear();
2.90 file_name = "";