Changeset 1837:8dd6160ff699 in lemon-0.x for gui/graph_displayer_canvas-event.cc
- Timestamp:
- 11/29/05 20:31:58 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2389
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/graph_displayer_canvas-event.cc
r1826 r1837 95 95 active_item=(get_item_at(clicked_x, clicked_y)); 96 96 active_node=INVALID; 97 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)97 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 98 98 { 99 99 if(nodesmap[i]==active_item) … … 126 126 if(active_node!=INVALID) 127 127 { 128 mapstorage.modified = true;128 (mainwin.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 - mapstorage.coords[active_node].x);148 double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y);147 double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x); 148 double coord_y = new_y - (clicked_y - (mainwin.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 mapstorage.coords.set(active_node, xy<double>(coord_x, coord_y));154 (mainwin.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 mapstorage.coords[active_node].x << ", " <<160 mapstorage.coords[active_node].y << ")";159 (mainwin.mapstorage).coords[active_node].x << ", " << 160 (mainwin.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( mapstorage.coords[active_node].x +167 coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x + 168 168 radius); 169 coord_text->property_y().set_value( mapstorage.coords[active_node].y -169 coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y - 170 170 radius); 171 171 } … … 174 174 coord_text = new Gnome::Canvas::Text( 175 175 displayed_graph, 176 mapstorage.coords[active_node].x + radius,177 mapstorage.coords[active_node].y - radius,176 (mainwin.mapstorage).coords[active_node].x + radius, 177 (mainwin.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( mapstorage.graph,active_node);ei!=INVALID;++ei)184 for(OutEdgeIt ei((mainwin.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[ mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);189 nodesmap[(mainwin.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[ mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);192 nodesmap[(mainwin.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( mapstorage.graph,active_node);ei!=INVALID;++ei)211 for(InEdgeIt ei((mainwin.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[ mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);216 nodesmap[(mainwin.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[ mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);219 nodesmap[(mainwin.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 mapstorage.modified = true;259 (mainwin.mapstorage).modified = true; 260 260 261 261 isbutton=1; 262 262 263 active_node= mapstorage.graph.addNode();263 active_node=(mainwin.mapstorage).graph.addNode(); 264 264 265 265 //initiating values corresponding to new node in maps … … 268 268 269 269 // update coordinates 270 mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));270 (mainwin.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 mapstorage.nodemap_storage.begin(); it !=275 mapstorage.nodemap_storage.end(); ++it)274 (mainwin.mapstorage).nodemap_storage.begin(); it != 275 (mainwin.mapstorage).nodemap_storage.end(); ++it) 276 276 { 277 277 if ((it->first != "coordinates_x") && … … 279 279 { 280 280 (*(it->second))[active_node] = 281 mapstorage.nodemap_default[it->first];281 (mainwin.mapstorage).nodemap_default[it->first]; 282 282 } 283 283 } 284 284 // increment the id map's default value 285 mapstorage.nodemap_default["id"] += 1.0;285 (mainwin.mapstorage).nodemap_default["id"] += 1.0; 286 286 287 287 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, … … 302 302 nodetextmap[active_node]->raise_to_top(); 303 303 304 mapwin.updateNode(active_node); 304 // mapwin.updateNode(active_node); 305 propertyUpdate(active_node); 305 306 306 307 isbutton=0; … … 332 333 active_item=(get_item_at(clicked_x, clicked_y)); 333 334 active_node=INVALID; 334 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)335 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 335 336 { 336 337 if(nodesmap[i]==active_item) … … 361 362 target_item=(get_item_at(clicked_x, clicked_y)); 362 363 Node target_node=INVALID; 363 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)364 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 364 365 { 365 366 if(nodesmap[i]==target_item) … … 373 374 if(target_node!=active_node) 374 375 { 375 mapstorage.modified = true;376 (mainwin.mapstorage).modified = true; 376 377 377 378 *(nodesmap[target_node]) << … … 379 380 380 381 //creating new edge 381 active_edge= mapstorage.graph.addEdge(active_node,382 active_edge=(mainwin.mapstorage).graph.addEdge(active_node, 382 383 target_node); 383 384 … … 385 386 for (std::map<std::string, 386 387 Graph::EdgeMap<double>*>::const_iterator it = 387 mapstorage.edgemap_storage.begin(); it !=388 mapstorage.edgemap_storage.end(); ++it)388 (mainwin.mapstorage).edgemap_storage.begin(); it != 389 (mainwin.mapstorage).edgemap_storage.end(); ++it) 389 390 { 390 391 (*(it->second))[active_edge] = 391 mapstorage.edgemap_default[it->first];392 (mainwin.mapstorage).edgemap_default[it->first]; 392 393 } 393 394 // increment the id map's default value 394 mapstorage.edgemap_default["id"] += 1.0;395 (mainwin.mapstorage).edgemap_default["id"] += 1.0; 395 396 396 397 //calculating coordinates of new edge … … 424 425 425 426 //updating its properties 426 mapwin.updateEdge(active_edge); 427 // mapwin.updateEdge(active_edge); 428 propertyUpdate(active_edge); 427 429 } 428 430 else … … 479 481 active_edge=INVALID; 480 482 //was it a node? 481 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)483 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 482 484 { 483 485 if(nodesmap[i]==active_item) … … 489 491 if(active_node==INVALID) 490 492 { 491 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)493 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 492 494 { 493 495 if(edgesmap[i]==active_item) … … 515 517 if(active_node!=INVALID) 516 518 { 517 mapstorage.modified = true;519 (mainwin.mapstorage).modified = true; 518 520 519 521 std::set<Graph::Edge> edges_to_delete; 520 522 521 for(OutEdgeIt e( mapstorage.graph,active_node);e!=INVALID;++e)523 for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e) 522 524 { 523 525 edges_to_delete.insert(e); 524 526 } 525 527 526 for(InEdgeIt e( mapstorage.graph,active_node);e!=INVALID;++e)528 for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e) 527 529 { 528 530 edges_to_delete.insert(e); … … 588 590 589 591 //find the activated item between texts 590 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)592 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 591 593 { 592 594 //at the same time only one can be active … … 600 602 if(clicked_edge==INVALID) 601 603 { 602 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)604 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 603 605 { 604 606 //at the same time only one can be active … … 623 625 624 626 //create a dialog 625 Gtk::Dialog dialog("Edit value", *parentwin, true);627 Gtk::Dialog dialog("Edit value", mainwin, true); 626 628 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 627 629 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); … … 640 642 case Gtk::RESPONSE_ACCEPT: 641 643 double new_value = spin.get_value(); 642 (* mapstorage.edgemap_storage[edgemap_to_edit])[active_edge] =644 (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] = 643 645 new_value; 644 646 std::ostringstream ostr; … … 647 649 ostr.str()); 648 650 //mapwin.updateEdge(active_edge); 649 mapwin.updateEdge(Edge(INVALID)); 651 // mapwin.updateEdge(Edge(INVALID)); 652 propertyUpdate(Edge(INVALID)); 650 653 } 651 654 } … … 675 678 676 679 //find the activated item between texts 677 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)680 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 678 681 { 679 682 //at the same time only one can be active … … 687 690 if(clicked_node==INVALID) 688 691 { 689 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)692 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 690 693 { 691 694 //at the same time only one can be active … … 710 713 711 714 //create a dialog 712 Gtk::Dialog dialog("Edit value", *parentwin, true);715 Gtk::Dialog dialog("Edit value", mainwin, true); 713 716 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 714 717 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); … … 727 730 case Gtk::RESPONSE_ACCEPT: 728 731 double new_value = spin.get_value(); 729 (* mapstorage.nodemap_storage[nodemap_to_edit])[active_node] =732 (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] = 730 733 new_value; 731 734 std::ostringstream ostr; … … 734 737 ostr.str()); 735 738 //mapwin.updateNode(active_node); 736 mapwin.updateNode(Node(INVALID)); 739 // mapwin.updateNode(Node(INVALID)); 740 propertyUpdate(Node(INVALID)); 737 741 } 738 742 } … … 751 755 delete(nodetextmap[node_to_delete]); 752 756 delete(nodesmap[node_to_delete]); 753 mapstorage.graph.erase(node_to_delete);757 (mainwin.mapstorage).graph.erase(node_to_delete); 754 758 } 755 759 … … 758 762 delete(edgetextmap[edge_to_delete]); 759 763 delete(edgesmap[edge_to_delete]); 760 mapstorage.graph.erase(edge_to_delete);764 (mainwin.mapstorage).graph.erase(edge_to_delete); 761 765 } 762 766 … … 778 782 else 779 783 { 780 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)784 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 781 785 { 782 786 if(edgesmap[i]==active_bre) … … 804 808 { 805 809 //create the new map 806 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ( mapstorage.graph, default_value);810 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value); 807 811 808 812 //if addition was not successful addEdgeMap returns one. 809 813 //cause can be that there is already a map named like the new one 810 if( mapstorage.addEdgeMap(mapname,emptr, default_value))814 if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value)) 811 815 { 812 816 return 1; … … 815 819 816 820 //add it to the list of the displayable maps 817 ma pwin.registerNewEdgeMap(mapname);821 mainwin.registerNewEdgeMap(mapname); 818 822 819 823 //display it … … 826 830 { 827 831 //create the new map 828 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ( mapstorage.graph,default_value);832 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value); 829 833 830 834 //if addition was not successful addNodeMap returns one. 831 835 //cause can be that there is already a map named like the new one 832 if( mapstorage.addNodeMap(mapname,emptr, default_value))836 if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value)) 833 837 { 834 838 return 1; … … 836 840 837 841 //add it to the list of the displayable maps 838 ma pwin.registerNewNodeMap(mapname);842 mainwin.registerNewNodeMap(mapname); 839 843 840 844 //display it
Note: See TracChangeset
for help on using the changeset viewer.