Changeset 96:e664d8aa3f72 in glemon-0.x for graph_displayer_canvas-event.cc
- Timestamp:
- 12/06/05 11:53:38 (18 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2414
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas-event.cc
r94 r96 95 95 active_item=(get_item_at(clicked_x, clicked_y)); 96 96 active_node=INVALID; 97 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)97 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 98 98 { 99 99 if(nodesmap[i]==active_item) … … 126 126 if(active_node!=INVALID) 127 127 { 128 (m ainwin.mapstorage).modified = true;128 (mytab.mapstorage).modified = true; 129 129 130 130 //new coordinates will be the old values, … … 145 145 146 146 // the new coordinates of the centre of the node 147 double coord_x = new_x - (clicked_x - (m ainwin.mapstorage).coords[active_node].x);148 double coord_y = new_y - (clicked_y - (m ainwin.mapstorage).coords[active_node].y);147 double coord_x = new_x - (clicked_x - (mytab.mapstorage).coords[active_node].x); 148 double coord_y = new_y - (clicked_y - (mytab.mapstorage).coords[active_node].y); 149 149 150 150 clicked_x=new_x; … … 152 152 153 153 // write back the new coordinates to the coords map 154 (m ainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));154 (mytab.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y)); 155 155 156 156 // reposition the coordinates text 157 157 std::ostringstream ostr; 158 158 ostr << "(" << 159 (m ainwin.mapstorage).coords[active_node].x << ", " <<160 (m ainwin.mapstorage).coords[active_node].y << ")";159 (mytab.mapstorage).coords[active_node].x << ", " << 160 (mytab.mapstorage).coords[active_node].y << ")"; 161 161 double radius = 162 162 (nodesmap[active_node]->property_x2().get_value() - … … 165 165 { 166 166 coord_text->property_text().set_value(ostr.str()); 167 coord_text->property_x().set_value((m ainwin.mapstorage).coords[active_node].x +167 coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x + 168 168 radius); 169 coord_text->property_y().set_value((m ainwin.mapstorage).coords[active_node].y -169 coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y - 170 170 radius); 171 171 } … … 174 174 coord_text = new Gnome::Canvas::Text( 175 175 displayed_graph, 176 (m ainwin.mapstorage).coords[active_node].x + radius,177 (m ainwin.mapstorage).coords[active_node].y - radius,176 (mytab.mapstorage).coords[active_node].x + radius, 177 (mytab.mapstorage).coords[active_node].y - radius, 178 178 ostr.str()); 179 179 coord_text->property_fill_color().set_value("black"); … … 182 182 183 183 //all the edges connected to the moved point has to be redrawn 184 for(OutEdgeIt ei((m ainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)184 for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei) 185 185 { 186 186 Gnome::Canvas::Points coos; 187 187 double x1, x2, y1, y2; 188 188 189 nodesmap[(m ainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);189 nodesmap[(mytab.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2); 190 190 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 191 191 192 nodesmap[(m ainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);192 nodesmap[(mytab.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2); 193 193 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 194 194 … … 209 209 } 210 210 211 for(InEdgeIt ei((m ainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)211 for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei) 212 212 { 213 213 Gnome::Canvas::Points coos; 214 214 double x1, x2, y1, y2; 215 215 216 nodesmap[(m ainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);216 nodesmap[(mytab.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2); 217 217 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 218 218 219 nodesmap[(m ainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);219 nodesmap[(mytab.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2); 220 220 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 221 221 … … 257 257 258 258 case GDK_BUTTON_RELEASE: 259 (m ainwin.mapstorage).modified = true;259 (mytab.mapstorage).modified = true; 260 260 261 261 isbutton=1; 262 262 263 active_node=(m ainwin.mapstorage).graph.addNode();263 active_node=(mytab.mapstorage).graph.addNode(); 264 264 265 265 //initiating values corresponding to new node in maps … … 268 268 269 269 // update coordinates 270 (m ainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));270 (mytab.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y)); 271 271 272 272 // update all other maps 273 273 for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it = 274 (m ainwin.mapstorage).nodemap_storage.begin(); it !=275 (m ainwin.mapstorage).nodemap_storage.end(); ++it)274 (mytab.mapstorage).nodemap_storage.begin(); it != 275 (mytab.mapstorage).nodemap_storage.end(); ++it) 276 276 { 277 277 if ((it->first != "coordinates_x") && … … 279 279 { 280 280 (*(it->second))[active_node] = 281 (m ainwin.mapstorage).nodemap_default[it->first];281 (mytab.mapstorage).nodemap_default[it->first]; 282 282 } 283 283 } 284 284 // increment the id map's default value 285 (m ainwin.mapstorage).nodemap_default["id"] += 1.0;285 (mytab.mapstorage).nodemap_default["id"] += 1.0; 286 286 287 287 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, … … 333 333 active_item=(get_item_at(clicked_x, clicked_y)); 334 334 active_node=INVALID; 335 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)335 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 336 336 { 337 337 if(nodesmap[i]==active_item) … … 362 362 target_item=(get_item_at(clicked_x, clicked_y)); 363 363 Node target_node=INVALID; 364 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)364 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 365 365 { 366 366 if(nodesmap[i]==target_item) … … 374 374 if(target_node!=active_node) 375 375 { 376 (m ainwin.mapstorage).modified = true;376 (mytab.mapstorage).modified = true; 377 377 378 378 *(nodesmap[target_node]) << … … 380 380 381 381 //creating new edge 382 active_edge=(m ainwin.mapstorage).graph.addEdge(active_node,382 active_edge=(mytab.mapstorage).graph.addEdge(active_node, 383 383 target_node); 384 384 … … 386 386 for (std::map<std::string, 387 387 Graph::EdgeMap<double>*>::const_iterator it = 388 (m ainwin.mapstorage).edgemap_storage.begin(); it !=389 (m ainwin.mapstorage).edgemap_storage.end(); ++it)388 (mytab.mapstorage).edgemap_storage.begin(); it != 389 (mytab.mapstorage).edgemap_storage.end(); ++it) 390 390 { 391 391 (*(it->second))[active_edge] = 392 (m ainwin.mapstorage).edgemap_default[it->first];392 (mytab.mapstorage).edgemap_default[it->first]; 393 393 } 394 394 // increment the id map's default value 395 (m ainwin.mapstorage).edgemap_default["id"] += 1.0;395 (mytab.mapstorage).edgemap_default["id"] += 1.0; 396 396 397 397 //calculating coordinates of new edge … … 481 481 active_edge=INVALID; 482 482 //was it a node? 483 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)483 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 484 484 { 485 485 if(nodesmap[i]==active_item) … … 491 491 if(active_node==INVALID) 492 492 { 493 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)493 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 494 494 { 495 495 if(edgesmap[i]==active_item) … … 517 517 if(active_node!=INVALID) 518 518 { 519 (m ainwin.mapstorage).modified = true;519 (mytab.mapstorage).modified = true; 520 520 521 521 std::set<Graph::Edge> edges_to_delete; 522 522 523 for(OutEdgeIt e((m ainwin.mapstorage).graph,active_node);e!=INVALID;++e)523 for(OutEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e) 524 524 { 525 525 edges_to_delete.insert(e); 526 526 } 527 527 528 for(InEdgeIt e((m ainwin.mapstorage).graph,active_node);e!=INVALID;++e)528 for(InEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e) 529 529 { 530 530 edges_to_delete.insert(e); … … 590 590 591 591 //find the activated item between texts 592 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)592 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 593 593 { 594 594 //at the same time only one can be active … … 602 602 if(clicked_edge==INVALID) 603 603 { 604 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)604 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 605 605 { 606 606 //at the same time only one can be active … … 625 625 626 626 //create a dialog 627 Gtk::Dialog dialog("Edit value", mainwin,true);627 Gtk::Dialog dialog("Edit value", true); 628 628 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 629 629 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); … … 642 642 case Gtk::RESPONSE_ACCEPT: 643 643 double new_value = spin.get_value(); 644 (*(m ainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =644 (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] = 645 645 new_value; 646 646 std::ostringstream ostr; … … 678 678 679 679 //find the activated item between texts 680 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)680 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 681 681 { 682 682 //at the same time only one can be active … … 690 690 if(clicked_node==INVALID) 691 691 { 692 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)692 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 693 693 { 694 694 //at the same time only one can be active … … 713 713 714 714 //create a dialog 715 Gtk::Dialog dialog("Edit value", mainwin,true);715 Gtk::Dialog dialog("Edit value", true); 716 716 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 717 717 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); … … 730 730 case Gtk::RESPONSE_ACCEPT: 731 731 double new_value = spin.get_value(); 732 (*(m ainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =732 (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] = 733 733 new_value; 734 734 std::ostringstream ostr; … … 755 755 delete(nodetextmap[node_to_delete]); 756 756 delete(nodesmap[node_to_delete]); 757 (m ainwin.mapstorage).graph.erase(node_to_delete);757 (mytab.mapstorage).graph.erase(node_to_delete); 758 758 } 759 759 … … 762 762 delete(edgetextmap[edge_to_delete]); 763 763 delete(edgesmap[edge_to_delete]); 764 (m ainwin.mapstorage).graph.erase(edge_to_delete);764 (mytab.mapstorage).graph.erase(edge_to_delete); 765 765 } 766 766 … … 782 782 else 783 783 { 784 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)784 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 785 785 { 786 786 if(edgesmap[i]==active_bre) … … 808 808 { 809 809 //create the new map 810 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((m ainwin.mapstorage).graph, default_value);810 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mytab.mapstorage).graph, default_value); 811 811 812 812 //if addition was not successful addEdgeMap returns one. 813 813 //cause can be that there is already a map named like the new one 814 if((m ainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))814 if((mytab.mapstorage).addEdgeMap(mapname,emptr, default_value)) 815 815 { 816 816 return 1; … … 819 819 820 820 //add it to the list of the displayable maps 821 m ainwin.registerNewEdgeMap(mapname);821 mytab.registerNewEdgeMap(mapname); 822 822 823 823 //display it … … 830 830 { 831 831 //create the new map 832 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((m ainwin.mapstorage).graph,default_value);832 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mytab.mapstorage).graph,default_value); 833 833 834 834 //if addition was not successful addNodeMap returns one. 835 835 //cause can be that there is already a map named like the new one 836 if((m ainwin.mapstorage).addNodeMap(mapname,emptr, default_value))836 if((mytab.mapstorage).addNodeMap(mapname,emptr, default_value)) 837 837 { 838 838 return 1; … … 840 840 841 841 //add it to the list of the displayable maps 842 m ainwin.registerNewNodeMap(mapname);842 mytab.registerNewNodeMap(mapname); 843 843 844 844 //display it
Note: See TracChangeset
for help on using the changeset viewer.