1.1 --- a/graph_displayer_canvas-event.cc Wed Nov 23 16:24:59 2005 +0000
1.2 +++ b/graph_displayer_canvas-event.cc Tue Nov 29 19:31:58 2005 +0000
1.3 @@ -94,7 +94,7 @@
1.4
1.5 active_item=(get_item_at(clicked_x, clicked_y));
1.6 active_node=INVALID;
1.7 - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
1.8 + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.9 {
1.10 if(nodesmap[i]==active_item)
1.11 {
1.12 @@ -125,7 +125,7 @@
1.13 //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.14 if(active_node!=INVALID)
1.15 {
1.16 - mapstorage.modified = true;
1.17 + (mainwin.mapstorage).modified = true;
1.18
1.19 //new coordinates will be the old values,
1.20 //because the item will be moved to the
1.21 @@ -144,52 +144,52 @@
1.22 nodetextmap[active_node]->move(dx, dy);
1.23
1.24 // the new coordinates of the centre of the node
1.25 - double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x);
1.26 - double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y);
1.27 + double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x);
1.28 + double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y);
1.29
1.30 clicked_x=new_x;
1.31 clicked_y=new_y;
1.32
1.33 // write back the new coordinates to the coords map
1.34 - mapstorage.coords.set(active_node, xy<double>(coord_x, coord_y));
1.35 + (mainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
1.36
1.37 // reposition the coordinates text
1.38 std::ostringstream ostr;
1.39 ostr << "(" <<
1.40 - mapstorage.coords[active_node].x << ", " <<
1.41 - mapstorage.coords[active_node].y << ")";
1.42 + (mainwin.mapstorage).coords[active_node].x << ", " <<
1.43 + (mainwin.mapstorage).coords[active_node].y << ")";
1.44 double radius =
1.45 (nodesmap[active_node]->property_x2().get_value() -
1.46 nodesmap[active_node]->property_x1().get_value()) / 2.0;
1.47 if (coord_text)
1.48 {
1.49 coord_text->property_text().set_value(ostr.str());
1.50 - coord_text->property_x().set_value(mapstorage.coords[active_node].x +
1.51 + coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x +
1.52 radius);
1.53 - coord_text->property_y().set_value(mapstorage.coords[active_node].y -
1.54 + coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y -
1.55 radius);
1.56 }
1.57 else
1.58 {
1.59 coord_text = new Gnome::Canvas::Text(
1.60 displayed_graph,
1.61 - mapstorage.coords[active_node].x + radius,
1.62 - mapstorage.coords[active_node].y - radius,
1.63 + (mainwin.mapstorage).coords[active_node].x + radius,
1.64 + (mainwin.mapstorage).coords[active_node].y - radius,
1.65 ostr.str());
1.66 coord_text->property_fill_color().set_value("black");
1.67 coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
1.68 }
1.69
1.70 //all the edges connected to the moved point has to be redrawn
1.71 - for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
1.72 + for(OutEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
1.73 {
1.74 Gnome::Canvas::Points coos;
1.75 double x1, x2, y1, y2;
1.76
1.77 - nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
1.78 + nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
1.79 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
1.80
1.81 - nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
1.82 + nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
1.83 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
1.84
1.85 if(isbutton==3)
1.86 @@ -208,15 +208,15 @@
1.87 edgetextmap[ei]->property_y().set_value(text_pos.y);
1.88 }
1.89
1.90 - for(InEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
1.91 + for(InEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
1.92 {
1.93 Gnome::Canvas::Points coos;
1.94 double x1, x2, y1, y2;
1.95
1.96 - nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
1.97 + nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
1.98 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
1.99
1.100 - nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
1.101 + nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
1.102 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
1.103
1.104 if(isbutton==3)
1.105 @@ -256,33 +256,33 @@
1.106 }
1.107
1.108 case GDK_BUTTON_RELEASE:
1.109 - mapstorage.modified = true;
1.110 + (mainwin.mapstorage).modified = true;
1.111
1.112 isbutton=1;
1.113
1.114 - active_node=mapstorage.graph.addNode();
1.115 + active_node=(mainwin.mapstorage).graph.addNode();
1.116
1.117 //initiating values corresponding to new node in maps
1.118
1.119 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.120
1.121 // update coordinates
1.122 - mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));
1.123 + (mainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
1.124
1.125 // update all other maps
1.126 for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
1.127 - mapstorage.nodemap_storage.begin(); it !=
1.128 - mapstorage.nodemap_storage.end(); ++it)
1.129 + (mainwin.mapstorage).nodemap_storage.begin(); it !=
1.130 + (mainwin.mapstorage).nodemap_storage.end(); ++it)
1.131 {
1.132 if ((it->first != "coordinates_x") &&
1.133 (it->first != "coordinates_y"))
1.134 {
1.135 (*(it->second))[active_node] =
1.136 - mapstorage.nodemap_default[it->first];
1.137 + (mainwin.mapstorage).nodemap_default[it->first];
1.138 }
1.139 }
1.140 // increment the id map's default value
1.141 - mapstorage.nodemap_default["id"] += 1.0;
1.142 + (mainwin.mapstorage).nodemap_default["id"] += 1.0;
1.143
1.144 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
1.145 clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
1.146 @@ -301,7 +301,8 @@
1.147 nodetextmap[active_node]->property_fill_color().set_value("darkblue");
1.148 nodetextmap[active_node]->raise_to_top();
1.149
1.150 - mapwin.updateNode(active_node);
1.151 +// mapwin.updateNode(active_node);
1.152 + propertyUpdate(active_node);
1.153
1.154 isbutton=0;
1.155 target_item=NULL;
1.156 @@ -331,7 +332,7 @@
1.157
1.158 active_item=(get_item_at(clicked_x, clicked_y));
1.159 active_node=INVALID;
1.160 - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
1.161 + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.162 {
1.163 if(nodesmap[i]==active_item)
1.164 {
1.165 @@ -360,7 +361,7 @@
1.166 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.167 target_item=(get_item_at(clicked_x, clicked_y));
1.168 Node target_node=INVALID;
1.169 - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
1.170 + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.171 {
1.172 if(nodesmap[i]==target_item)
1.173 {
1.174 @@ -372,26 +373,26 @@
1.175 {
1.176 if(target_node!=active_node)
1.177 {
1.178 - mapstorage.modified = true;
1.179 + (mainwin.mapstorage).modified = true;
1.180
1.181 *(nodesmap[target_node]) <<
1.182 Gnome::Canvas::Properties::fill_color("red");
1.183
1.184 //creating new edge
1.185 - active_edge=mapstorage.graph.addEdge(active_node,
1.186 + active_edge=(mainwin.mapstorage).graph.addEdge(active_node,
1.187 target_node);
1.188
1.189 // update maps
1.190 for (std::map<std::string,
1.191 Graph::EdgeMap<double>*>::const_iterator it =
1.192 - mapstorage.edgemap_storage.begin(); it !=
1.193 - mapstorage.edgemap_storage.end(); ++it)
1.194 + (mainwin.mapstorage).edgemap_storage.begin(); it !=
1.195 + (mainwin.mapstorage).edgemap_storage.end(); ++it)
1.196 {
1.197 (*(it->second))[active_edge] =
1.198 - mapstorage.edgemap_default[it->first];
1.199 + (mainwin.mapstorage).edgemap_default[it->first];
1.200 }
1.201 // increment the id map's default value
1.202 - mapstorage.edgemap_default["id"] += 1.0;
1.203 + (mainwin.mapstorage).edgemap_default["id"] += 1.0;
1.204
1.205 //calculating coordinates of new edge
1.206 Gnome::Canvas::Points coos;
1.207 @@ -423,7 +424,8 @@
1.208 edgetextmap[active_edge]->raise_to_top();
1.209
1.210 //updating its properties
1.211 - mapwin.updateEdge(active_edge);
1.212 +// mapwin.updateEdge(active_edge);
1.213 + propertyUpdate(active_edge);
1.214 }
1.215 else
1.216 {
1.217 @@ -478,7 +480,7 @@
1.218 active_node=INVALID;
1.219 active_edge=INVALID;
1.220 //was it a node?
1.221 - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
1.222 + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.223 {
1.224 if(nodesmap[i]==active_item)
1.225 {
1.226 @@ -488,7 +490,7 @@
1.227 //or was it an edge?
1.228 if(active_node==INVALID)
1.229 {
1.230 - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.231 + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.232 {
1.233 if(edgesmap[i]==active_item)
1.234 {
1.235 @@ -514,16 +516,16 @@
1.236 //a node was found
1.237 if(active_node!=INVALID)
1.238 {
1.239 - mapstorage.modified = true;
1.240 + (mainwin.mapstorage).modified = true;
1.241
1.242 std::set<Graph::Edge> edges_to_delete;
1.243
1.244 - for(OutEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
1.245 + for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
1.246 {
1.247 edges_to_delete.insert(e);
1.248 }
1.249
1.250 - for(InEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
1.251 + for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
1.252 {
1.253 edges_to_delete.insert(e);
1.254 }
1.255 @@ -587,7 +589,7 @@
1.256 active_item=(get_item_at(clicked_x, clicked_y));
1.257
1.258 //find the activated item between texts
1.259 - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.260 + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.261 {
1.262 //at the same time only one can be active
1.263 if(edgetextmap[i]==active_item)
1.264 @@ -599,7 +601,7 @@
1.265 //if it was not between texts, search for it between edges
1.266 if(clicked_edge==INVALID)
1.267 {
1.268 - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.269 + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.270 {
1.271 //at the same time only one can be active
1.272 if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item))
1.273 @@ -622,7 +624,7 @@
1.274 active_edge=clicked_edge;
1.275
1.276 //create a dialog
1.277 - Gtk::Dialog dialog("Edit value", *parentwin, true);
1.278 + Gtk::Dialog dialog("Edit value", mainwin, true);
1.279 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.280 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
1.281 Gtk::VBox* vbox = dialog.get_vbox();
1.282 @@ -639,14 +641,15 @@
1.283 break;
1.284 case Gtk::RESPONSE_ACCEPT:
1.285 double new_value = spin.get_value();
1.286 - (*mapstorage.edgemap_storage[edgemap_to_edit])[active_edge] =
1.287 + (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
1.288 new_value;
1.289 std::ostringstream ostr;
1.290 ostr << new_value;
1.291 edgetextmap[active_edge]->property_text().set_value(
1.292 ostr.str());
1.293 //mapwin.updateEdge(active_edge);
1.294 - mapwin.updateEdge(Edge(INVALID));
1.295 +// mapwin.updateEdge(Edge(INVALID));
1.296 + propertyUpdate(Edge(INVALID));
1.297 }
1.298 }
1.299 }
1.300 @@ -674,7 +677,7 @@
1.301 active_item=(get_item_at(clicked_x, clicked_y));
1.302
1.303 //find the activated item between texts
1.304 - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
1.305 + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.306 {
1.307 //at the same time only one can be active
1.308 if(nodetextmap[i]==active_item)
1.309 @@ -686,7 +689,7 @@
1.310 //if there was not, search for it between nodes
1.311 if(clicked_node==INVALID)
1.312 {
1.313 - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
1.314 + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.315 {
1.316 //at the same time only one can be active
1.317 if(nodesmap[i]==active_item)
1.318 @@ -709,7 +712,7 @@
1.319 active_node=clicked_node;
1.320
1.321 //create a dialog
1.322 - Gtk::Dialog dialog("Edit value", *parentwin, true);
1.323 + Gtk::Dialog dialog("Edit value", mainwin, true);
1.324 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.325 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
1.326 Gtk::VBox* vbox = dialog.get_vbox();
1.327 @@ -726,14 +729,15 @@
1.328 break;
1.329 case Gtk::RESPONSE_ACCEPT:
1.330 double new_value = spin.get_value();
1.331 - (*mapstorage.nodemap_storage[nodemap_to_edit])[active_node] =
1.332 + (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
1.333 new_value;
1.334 std::ostringstream ostr;
1.335 ostr << new_value;
1.336 nodetextmap[active_node]->property_text().set_value(
1.337 ostr.str());
1.338 //mapwin.updateNode(active_node);
1.339 - mapwin.updateNode(Node(INVALID));
1.340 +// mapwin.updateNode(Node(INVALID));
1.341 + propertyUpdate(Node(INVALID));
1.342 }
1.343 }
1.344 }
1.345 @@ -750,14 +754,14 @@
1.346 {
1.347 delete(nodetextmap[node_to_delete]);
1.348 delete(nodesmap[node_to_delete]);
1.349 - mapstorage.graph.erase(node_to_delete);
1.350 + (mainwin.mapstorage).graph.erase(node_to_delete);
1.351 }
1.352
1.353 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
1.354 {
1.355 delete(edgetextmap[edge_to_delete]);
1.356 delete(edgesmap[edge_to_delete]);
1.357 - mapstorage.graph.erase(edge_to_delete);
1.358 + (mainwin.mapstorage).graph.erase(edge_to_delete);
1.359 }
1.360
1.361 void GraphDisplayerCanvas::textReposition(xy<double> new_place)
1.362 @@ -777,7 +781,7 @@
1.363 }
1.364 else
1.365 {
1.366 - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.367 + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
1.368 {
1.369 if(edgesmap[i]==active_bre)
1.370 {
1.371 @@ -803,18 +807,18 @@
1.372 int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
1.373 {
1.374 //create the new map
1.375 - Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mapstorage.graph, default_value);
1.376 + Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value);
1.377
1.378 //if addition was not successful addEdgeMap returns one.
1.379 //cause can be that there is already a map named like the new one
1.380 - if(mapstorage.addEdgeMap(mapname,emptr, default_value))
1.381 + if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))
1.382 {
1.383 return 1;
1.384 }
1.385
1.386
1.387 //add it to the list of the displayable maps
1.388 - mapwin.registerNewEdgeMap(mapname);
1.389 + mainwin.registerNewEdgeMap(mapname);
1.390
1.391 //display it
1.392 changeEdgeText(mapname);
1.393 @@ -825,17 +829,17 @@
1.394 int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
1.395 {
1.396 //create the new map
1.397 - Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mapstorage.graph,default_value);
1.398 + Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value);
1.399
1.400 //if addition was not successful addNodeMap returns one.
1.401 //cause can be that there is already a map named like the new one
1.402 - if(mapstorage.addNodeMap(mapname,emptr, default_value))
1.403 + if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value))
1.404 {
1.405 return 1;
1.406 }
1.407
1.408 //add it to the list of the displayable maps
1.409 - mapwin.registerNewNodeMap(mapname);
1.410 + mainwin.registerNewNodeMap(mapname);
1.411
1.412 //display it
1.413 changeNodeText(mapname);