diff -r 56eb90299693 -r adfdc2f70548 graph_displayer_canvas-event.cc --- a/graph_displayer_canvas-event.cc Wed Nov 23 16:24:59 2005 +0000 +++ b/graph_displayer_canvas-event.cc Tue Nov 29 19:31:58 2005 +0000 @@ -94,7 +94,7 @@ active_item=(get_item_at(clicked_x, clicked_y)); active_node=INVALID; - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { if(nodesmap[i]==active_item) { @@ -125,7 +125,7 @@ //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 if(active_node!=INVALID) { - mapstorage.modified = true; + (mainwin.mapstorage).modified = true; //new coordinates will be the old values, //because the item will be moved to the @@ -144,52 +144,52 @@ nodetextmap[active_node]->move(dx, dy); // the new coordinates of the centre of the node - double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x); - double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y); + double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x); + double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y); clicked_x=new_x; clicked_y=new_y; // write back the new coordinates to the coords map - mapstorage.coords.set(active_node, xy(coord_x, coord_y)); + (mainwin.mapstorage).coords.set(active_node, xy(coord_x, coord_y)); // reposition the coordinates text std::ostringstream ostr; ostr << "(" << - mapstorage.coords[active_node].x << ", " << - mapstorage.coords[active_node].y << ")"; + (mainwin.mapstorage).coords[active_node].x << ", " << + (mainwin.mapstorage).coords[active_node].y << ")"; double radius = (nodesmap[active_node]->property_x2().get_value() - nodesmap[active_node]->property_x1().get_value()) / 2.0; if (coord_text) { coord_text->property_text().set_value(ostr.str()); - coord_text->property_x().set_value(mapstorage.coords[active_node].x + + coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x + radius); - coord_text->property_y().set_value(mapstorage.coords[active_node].y - + coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y - radius); } else { coord_text = new Gnome::Canvas::Text( displayed_graph, - mapstorage.coords[active_node].x + radius, - mapstorage.coords[active_node].y - radius, + (mainwin.mapstorage).coords[active_node].x + radius, + (mainwin.mapstorage).coords[active_node].y - radius, ostr.str()); coord_text->property_fill_color().set_value("black"); coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST); } //all the edges connected to the moved point has to be redrawn - for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei) + for(OutEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei) { Gnome::Canvas::Points coos; double x1, x2, y1, y2; - nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2); + nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2); + nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); if(isbutton==3) @@ -208,15 +208,15 @@ edgetextmap[ei]->property_y().set_value(text_pos.y); } - for(InEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei) + for(InEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei) { Gnome::Canvas::Points coos; double x1, x2, y1, y2; - nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2); + nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2); + nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); if(isbutton==3) @@ -256,33 +256,33 @@ } case GDK_BUTTON_RELEASE: - mapstorage.modified = true; + (mainwin.mapstorage).modified = true; isbutton=1; - active_node=mapstorage.graph.addNode(); + active_node=(mainwin.mapstorage).graph.addNode(); //initiating values corresponding to new node in maps window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); // update coordinates - mapstorage.coords.set(active_node, xy(clicked_x, clicked_y)); + (mainwin.mapstorage).coords.set(active_node, xy(clicked_x, clicked_y)); // update all other maps for (std::map*>::const_iterator it = - mapstorage.nodemap_storage.begin(); it != - mapstorage.nodemap_storage.end(); ++it) + (mainwin.mapstorage).nodemap_storage.begin(); it != + (mainwin.mapstorage).nodemap_storage.end(); ++it) { if ((it->first != "coordinates_x") && (it->first != "coordinates_y")) { (*(it->second))[active_node] = - mapstorage.nodemap_default[it->first]; + (mainwin.mapstorage).nodemap_default[it->first]; } } // increment the id map's default value - mapstorage.nodemap_default["id"] += 1.0; + (mainwin.mapstorage).nodemap_default["id"] += 1.0; nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20); @@ -301,7 +301,8 @@ nodetextmap[active_node]->property_fill_color().set_value("darkblue"); nodetextmap[active_node]->raise_to_top(); - mapwin.updateNode(active_node); +// mapwin.updateNode(active_node); + propertyUpdate(active_node); isbutton=0; target_item=NULL; @@ -331,7 +332,7 @@ active_item=(get_item_at(clicked_x, clicked_y)); active_node=INVALID; - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { if(nodesmap[i]==active_item) { @@ -360,7 +361,7 @@ window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); target_item=(get_item_at(clicked_x, clicked_y)); Node target_node=INVALID; - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { if(nodesmap[i]==target_item) { @@ -372,26 +373,26 @@ { if(target_node!=active_node) { - mapstorage.modified = true; + (mainwin.mapstorage).modified = true; *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red"); //creating new edge - active_edge=mapstorage.graph.addEdge(active_node, + active_edge=(mainwin.mapstorage).graph.addEdge(active_node, target_node); // update maps for (std::map*>::const_iterator it = - mapstorage.edgemap_storage.begin(); it != - mapstorage.edgemap_storage.end(); ++it) + (mainwin.mapstorage).edgemap_storage.begin(); it != + (mainwin.mapstorage).edgemap_storage.end(); ++it) { (*(it->second))[active_edge] = - mapstorage.edgemap_default[it->first]; + (mainwin.mapstorage).edgemap_default[it->first]; } // increment the id map's default value - mapstorage.edgemap_default["id"] += 1.0; + (mainwin.mapstorage).edgemap_default["id"] += 1.0; //calculating coordinates of new edge Gnome::Canvas::Points coos; @@ -423,7 +424,8 @@ edgetextmap[active_edge]->raise_to_top(); //updating its properties - mapwin.updateEdge(active_edge); +// mapwin.updateEdge(active_edge); + propertyUpdate(active_edge); } else { @@ -478,7 +480,7 @@ active_node=INVALID; active_edge=INVALID; //was it a node? - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { if(nodesmap[i]==active_item) { @@ -488,7 +490,7 @@ //or was it an edge? if(active_node==INVALID) { - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { if(edgesmap[i]==active_item) { @@ -514,16 +516,16 @@ //a node was found if(active_node!=INVALID) { - mapstorage.modified = true; + (mainwin.mapstorage).modified = true; std::set edges_to_delete; - for(OutEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e) + for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e) { edges_to_delete.insert(e); } - for(InEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e) + for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e) { edges_to_delete.insert(e); } @@ -587,7 +589,7 @@ active_item=(get_item_at(clicked_x, clicked_y)); //find the activated item between texts - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { //at the same time only one can be active if(edgetextmap[i]==active_item) @@ -599,7 +601,7 @@ //if it was not between texts, search for it between edges if(clicked_edge==INVALID) { - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { //at the same time only one can be active if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item)) @@ -622,7 +624,7 @@ active_edge=clicked_edge; //create a dialog - Gtk::Dialog dialog("Edit value", *parentwin, true); + Gtk::Dialog dialog("Edit value", mainwin, true); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); Gtk::VBox* vbox = dialog.get_vbox(); @@ -639,14 +641,15 @@ break; case Gtk::RESPONSE_ACCEPT: double new_value = spin.get_value(); - (*mapstorage.edgemap_storage[edgemap_to_edit])[active_edge] = + (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] = new_value; std::ostringstream ostr; ostr << new_value; edgetextmap[active_edge]->property_text().set_value( ostr.str()); //mapwin.updateEdge(active_edge); - mapwin.updateEdge(Edge(INVALID)); +// mapwin.updateEdge(Edge(INVALID)); + propertyUpdate(Edge(INVALID)); } } } @@ -674,7 +677,7 @@ active_item=(get_item_at(clicked_x, clicked_y)); //find the activated item between texts - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { //at the same time only one can be active if(nodetextmap[i]==active_item) @@ -686,7 +689,7 @@ //if there was not, search for it between nodes if(clicked_node==INVALID) { - for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) + for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { //at the same time only one can be active if(nodesmap[i]==active_item) @@ -709,7 +712,7 @@ active_node=clicked_node; //create a dialog - Gtk::Dialog dialog("Edit value", *parentwin, true); + Gtk::Dialog dialog("Edit value", mainwin, true); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); Gtk::VBox* vbox = dialog.get_vbox(); @@ -726,14 +729,15 @@ break; case Gtk::RESPONSE_ACCEPT: double new_value = spin.get_value(); - (*mapstorage.nodemap_storage[nodemap_to_edit])[active_node] = + (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] = new_value; std::ostringstream ostr; ostr << new_value; nodetextmap[active_node]->property_text().set_value( ostr.str()); //mapwin.updateNode(active_node); - mapwin.updateNode(Node(INVALID)); +// mapwin.updateNode(Node(INVALID)); + propertyUpdate(Node(INVALID)); } } } @@ -750,14 +754,14 @@ { delete(nodetextmap[node_to_delete]); delete(nodesmap[node_to_delete]); - mapstorage.graph.erase(node_to_delete); + (mainwin.mapstorage).graph.erase(node_to_delete); } void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete) { delete(edgetextmap[edge_to_delete]); delete(edgesmap[edge_to_delete]); - mapstorage.graph.erase(edge_to_delete); + (mainwin.mapstorage).graph.erase(edge_to_delete); } void GraphDisplayerCanvas::textReposition(xy new_place) @@ -777,7 +781,7 @@ } else { - for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) + for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) { if(edgesmap[i]==active_bre) { @@ -803,18 +807,18 @@ int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname) { //create the new map - Graph::EdgeMap * emptr=new Graph::EdgeMap (mapstorage.graph, default_value); + Graph::EdgeMap * emptr=new Graph::EdgeMap ((mainwin.mapstorage).graph, default_value); //if addition was not successful addEdgeMap returns one. //cause can be that there is already a map named like the new one - if(mapstorage.addEdgeMap(mapname,emptr, default_value)) + if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value)) { return 1; } //add it to the list of the displayable maps - mapwin.registerNewEdgeMap(mapname); + mainwin.registerNewEdgeMap(mapname); //display it changeEdgeText(mapname); @@ -825,17 +829,17 @@ int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname) { //create the new map - Graph::NodeMap * emptr=new Graph::NodeMap (mapstorage.graph,default_value); + Graph::NodeMap * emptr=new Graph::NodeMap ((mainwin.mapstorage).graph,default_value); //if addition was not successful addNodeMap returns one. //cause can be that there is already a map named like the new one - if(mapstorage.addNodeMap(mapname,emptr, default_value)) + if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value)) { return 1; } //add it to the list of the displayable maps - mapwin.registerNewNodeMap(mapname); + mainwin.registerNewNodeMap(mapname); //display it changeNodeText(mapname);