Changeset 94:adfdc2f70548 in glemon-0.x
- Timestamp:
- 11/29/05 20:31:58 (19 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2389
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas-edge.cc
r91 r94 9 9 min=edge_property_defaults[E_WIDTH]; 10 10 max=edge_property_defaults[E_WIDTH]; 11 Graph::EdgeMap<double> actual_map( mapstorage.graph,edge_property_defaults[E_WIDTH]);11 Graph::EdgeMap<double> actual_map((mainwin.mapstorage).graph,edge_property_defaults[E_WIDTH]); 12 12 13 13 if(edge==INVALID) 14 14 { 15 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)15 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 16 16 { 17 17 double v=fabs(actual_map[i]); … … 45 45 double min, max; 46 46 47 min= mapstorage.minOfEdgeMap(mapname);48 max= mapstorage.maxOfEdgeMap(mapname);49 actual_map=( mapstorage.edgemap_storage)[mapname];50 51 if(edge==INVALID) 52 { 53 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)47 min=(mainwin.mapstorage).minOfEdgeMap(mapname); 48 max=(mainwin.mapstorage).maxOfEdgeMap(mapname); 49 actual_map=((mainwin.mapstorage).edgemap_storage)[mapname]; 50 51 if(edge==INVALID) 52 { 53 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 54 54 { 55 55 double v=fabs((*actual_map)[i]); … … 84 84 //green in RGB 85 85 Graph::EdgeMap<double> * actual_map; 86 actual_map=( mapstorage.edgemap_storage)[mapname];86 actual_map=((mainwin.mapstorage).edgemap_storage)[mapname]; 87 87 88 88 double max, min; 89 89 90 max= mapstorage.maxOfEdgeMap(mapname);91 min= mapstorage.minOfEdgeMap(mapname);92 93 if(edge==INVALID) 94 { 95 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)90 max=(mainwin.mapstorage).maxOfEdgeMap(mapname); 91 min=(mainwin.mapstorage).minOfEdgeMap(mapname); 92 93 if(edge==INVALID) 94 { 95 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 96 96 { 97 97 double w=(*actual_map)[i]; … … 135 135 //the minimum of the nodemap to the range of 136 136 //green in RGB 137 Graph::EdgeMap<double> actual_map( mapstorage.graph,edge_property_defaults[E_COLOR]);137 Graph::EdgeMap<double> actual_map((mainwin.mapstorage).graph,edge_property_defaults[E_COLOR]); 138 138 139 139 double max, min; … … 144 144 if(edge==INVALID) 145 145 { 146 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)146 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 147 147 { 148 148 double w=actual_map[i]; … … 189 189 if(edge==INVALID) 190 190 { 191 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)191 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 192 192 { 193 193 edgemap_to_edit=mapname; 194 double number=(*( mapstorage.edgemap_storage)[mapname])[i];194 double number=(*((mainwin.mapstorage).edgemap_storage)[mapname])[i]; 195 195 196 196 std::ostringstream ostr; … … 203 203 else 204 204 { 205 double number=(*( mapstorage.edgemap_storage)[mapname])[edge];205 double number=(*((mainwin.mapstorage).edgemap_storage)[mapname])[edge]; 206 206 207 207 std::ostringstream ostr; … … 224 224 if(edge==INVALID) 225 225 { 226 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)226 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 227 227 { 228 228 edgemap_to_edit=""; -
graph_displayer_canvas-event.cc
r92 r94 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 -
graph_displayer_canvas-node.cc
r91 r94 7 7 Graph::NodeMap<double> * actual_map; 8 8 double min, max; 9 min= mapstorage.minOfNodeMap(mapname);10 max= mapstorage.maxOfNodeMap(mapname);11 actual_map=( mapstorage.nodemap_storage)[mapname];12 13 if(node==INVALID) 14 { 15 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)9 min=(mainwin.mapstorage).minOfNodeMap(mapname); 10 max=(mainwin.mapstorage).maxOfNodeMap(mapname); 11 actual_map=((mainwin.mapstorage).nodemap_storage)[mapname]; 12 13 if(node==INVALID) 14 { 15 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 16 16 { 17 17 double v=fabs((*actual_map)[i]); … … 65 65 min=node_property_defaults[N_RADIUS]; 66 66 max=node_property_defaults[N_RADIUS]; 67 Graph::NodeMap<double> actual_map( mapstorage.graph,node_property_defaults[N_RADIUS]);67 Graph::NodeMap<double> actual_map((mainwin.mapstorage).graph,node_property_defaults[N_RADIUS]); 68 68 69 69 if(node==INVALID) 70 70 { 71 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)71 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 72 72 { 73 73 double v=fabs(actual_map[i]); … … 124 124 125 125 Graph::NodeMap<double> * actual_map; 126 actual_map=( mapstorage.nodemap_storage)[mapname];126 actual_map=((mainwin.mapstorage).nodemap_storage)[mapname]; 127 127 128 128 double max, min; 129 129 130 max= mapstorage.maxOfNodeMap(mapname);131 min= mapstorage.minOfNodeMap(mapname);132 133 if(node==INVALID) 134 { 135 136 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)130 max=(mainwin.mapstorage).maxOfNodeMap(mapname); 131 min=(mainwin.mapstorage).minOfNodeMap(mapname); 132 133 if(node==INVALID) 134 { 135 136 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 137 137 { 138 138 Gdk::Color color; … … 179 179 //green in RGB 180 180 181 Graph::NodeMap<double> actual_map( mapstorage.graph,node_property_defaults[N_COLOR]);181 Graph::NodeMap<double> actual_map((mainwin.mapstorage).graph,node_property_defaults[N_COLOR]); 182 182 183 183 double max, min; … … 189 189 { 190 190 191 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)191 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 192 192 { 193 193 Gdk::Color color; … … 236 236 237 237 Graph::NodeMap<double> * actual_map=NULL; 238 actual_map=( mapstorage.nodemap_storage)[mapname];239 240 if(node==INVALID) 241 { 242 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)238 actual_map=((mainwin.mapstorage).nodemap_storage)[mapname]; 239 240 if(node==INVALID) 241 { 242 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 243 243 { 244 244 nodemap_to_edit=mapname; … … 273 273 if(node==INVALID) 274 274 { 275 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)275 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 276 276 { 277 277 nodemap_to_edit=""; -
graph_displayer_canvas.cc
r89 r94 2 2 #include <cmath> 3 3 4 GraphDisplayerCanvas::GraphDisplayerCanvas(Ma pStorage & ms, MapWin & mw, Gtk::Window * mainwin) :5 nodesmap(m s.graph), edgesmap(ms.graph), edgetextmap(ms.graph),6 nodetextmap(m s.graph), displayed_graph(*(root()), 0, 0), mapstorage(ms),4 GraphDisplayerCanvas::GraphDisplayerCanvas(MainWin & mainw) : 5 nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph), 6 nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0), 7 7 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""), 8 edgemap_to_edit(""), mapwin(mw) 9 { 10 parentwin=mainwin; 11 8 edgemap_to_edit(""), mainwin(mainw) 9 { 12 10 //base event handler is move tool 13 11 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); … … 21 19 GraphDisplayerCanvas::~GraphDisplayerCanvas() 22 20 { 23 for (NodeIt n(mapstorage.graph); n != INVALID; ++n) 24 { 25 delete nodesmap[n]; 26 delete nodetextmap[n]; 27 } 28 29 for (EdgeIt e(mapstorage.graph); e != INVALID; ++e) 30 { 31 delete edgesmap[e]; 32 delete edgetextmap[e]; 33 } 21 for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n) 22 { 23 delete nodesmap[n]; 24 delete nodetextmap[n]; 25 } 26 27 for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e) 28 { 29 delete edgesmap[e]; 30 delete edgetextmap[e]; 31 } 32 } 33 34 void GraphDisplayerCanvas::propertyChange(bool itisedge, int prop) 35 { 36 if(itisedge) 37 { 38 propertyUpdate(Edge(INVALID), prop); 39 } 40 else 41 { 42 propertyUpdate(Node(INVALID), prop); 43 } 44 } 45 46 void GraphDisplayerCanvas::propertyUpdate(Edge edge) 47 { 48 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 49 { 50 propertyUpdate(edge, i); 51 } 52 } 53 54 void GraphDisplayerCanvas::propertyUpdate(Node node) 55 { 56 for(int i=0;i<NODE_PROPERTY_NUM;i++) 57 { 58 propertyUpdate(node, i); 59 } 60 } 61 62 void GraphDisplayerCanvas::propertyUpdate(Node node, int prop, int dummy) 63 { 64 dummy=dummy; 65 66 std::string mapname=mainwin.getActiveNodeMap(prop); 67 68 if(mapname!="") 69 { 70 if( ( ((mainwin.mapstorage).nodemap_storage).find(mapname) != ((mainwin.mapstorage).nodemap_storage).end() ) ) 71 { 72 switch(prop) 73 { 74 case N_RADIUS: 75 changeNodeRadius(mapname, node); 76 break; 77 case N_COLOR: 78 changeNodeColor(mapname, node); 79 break; 80 case N_TEXT: 81 changeNodeText(mapname, node); 82 break; 83 default: 84 std::cerr<<"Error\n"; 85 } 86 } 87 } 88 else //mapname=="" 89 { 90 Node node=INVALID; 91 switch(prop) 92 { 93 case N_RADIUS: 94 resetNodeRadius(node); 95 break; 96 case N_COLOR: 97 resetNodeColor(node); 98 break; 99 case N_TEXT: 100 resetNodeText(node); 101 break; 102 default: 103 std::cerr<<"Error\n"; 104 } 105 } 106 107 } 108 109 void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop, int dummy) 110 { 111 dummy=dummy; 112 113 std::string mapname=mainwin.getActiveEdgeMap(prop); 114 115 if(mapname!="") 116 { 117 if( ( ((mainwin.mapstorage).edgemap_storage).find(mapname) != ((mainwin.mapstorage).edgemap_storage).end() ) ) 118 { 119 switch(prop) 120 { 121 case E_WIDTH: 122 changeEdgeWidth(mapname, edge); 123 break; 124 case E_COLOR: 125 changeEdgeColor(mapname, edge); 126 break; 127 case E_TEXT: 128 changeEdgeText(mapname, edge); 129 break; 130 default: 131 std::cerr<<"Error\n"; 132 } 133 } 134 } 135 else //mapname=="" 136 { 137 switch(prop) 138 { 139 case E_WIDTH: 140 resetEdgeWidth(edge); 141 break; 142 case E_COLOR: 143 resetEdgeColor(edge); 144 break; 145 case E_TEXT: 146 resetEdgeText(edge); 147 break; 148 default: 149 std::cerr<<"Error\n"; 150 } 151 } 34 152 } 35 153 … … 38 156 //first edges are drawn, to hide joining with nodes later 39 157 40 for (EdgeIt i( mapstorage.graph); i!=INVALID; ++i)158 for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 41 159 { 42 160 … … 45 163 Gnome::Canvas::Points coos; 46 164 coos.push_back(Gnome::Art::Point( 47 mapstorage.coords[mapstorage.graph.source(i)].x,48 mapstorage.coords[mapstorage.graph.source(i)].y));165 (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].x, 166 (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].y)); 49 167 coos.push_back(Gnome::Art::Point( 50 mapstorage.coords[mapstorage.graph.target(i)].x,51 mapstorage.coords[mapstorage.graph.target(i)].y));168 (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].x, 169 (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].y)); 52 170 53 171 edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this); … … 69 187 //afterwards nodes come to be drawn 70 188 71 for (NodeIt i( mapstorage.graph); i!=INVALID; ++i)189 for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i) 72 190 { 73 191 //drawing bule nodes, with black line around them … … 75 193 nodesmap[i]=new Gnome::Canvas::Ellipse( 76 194 displayed_graph, 77 mapstorage.coords[i].x-20,78 mapstorage.coords[i].y-20,79 mapstorage.coords[i].x+20,80 mapstorage.coords[i].y+20);195 (mainwin.mapstorage).coords[i].x-20, 196 (mainwin.mapstorage).coords[i].y-20, 197 (mainwin.mapstorage).coords[i].x+20, 198 (mainwin.mapstorage).coords[i].y+20); 81 199 *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue"); 82 200 *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black"); … … 86 204 87 205 xy<double> text_pos( 88 ( mapstorage.coords[i].x+node_property_defaults[N_RADIUS]+5),89 ( mapstorage.coords[i].y+node_property_defaults[N_RADIUS]+5));206 ((mainwin.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5), 207 ((mainwin.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5)); 90 208 91 209 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph, … … 105 223 forming_edge=INVALID; 106 224 107 for (NodeIt n( mapstorage.graph); n != INVALID; ++n)225 for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n) 108 226 { 109 227 delete nodesmap[n]; … … 111 229 } 112 230 113 for (EdgeIt e( mapstorage.graph); e != INVALID; ++e)231 for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e) 114 232 { 115 233 delete edgesmap[e]; -
graph_displayer_canvas.h
r89 r94 7 7 8 8 #include "all_include.h" 9 #include "mapstorage.h" 10 #include "map_win.h" 9 #include "main_win.h" 11 10 #include <libgnomecanvasmm.h> 12 11 #include <libgnomecanvasmm/polygon.h> … … 41 40 42 41 public: 43 GraphDisplayerCanvas(Ma pStorage &, MapWin &, Gtk::Window *);42 GraphDisplayerCanvas(MainWin &); 44 43 virtual ~GraphDisplayerCanvas(); 45 44 … … 73 72 int changeNodeText (std::string mapname, Node new_item=INVALID); 74 73 int resetNodeText (Node new_item=INVALID); 74 75 void propertyChange(bool, int); 76 void propertyUpdate(Edge, int, int dummy=0); 77 void propertyUpdate(Node, int, int dummy=0); 78 79 void propertyUpdate(Edge); 80 void propertyUpdate(Node); 75 81 76 82 ///Callback for 'ViewZoomIn' action. … … 166 172 Gnome::Canvas::Group displayed_graph; 167 173 168 public:169 ///Here we store the maps that can be displayed through properties.170 MapStorage & mapstorage;171 172 174 private: 173 175 ///Indicates whether the button of mouse is pressed or not … … 194 196 static const int zoom_step = 5; 195 197 196 public: 197 ///We need to store mapwin, to be able to ask the appropriate values for properties of new items. 198 MapWin & mapwin; 199 200 private: 201 202 ///pointer to the parent window 203 Gtk::Window * parentwin; 198 private: 199 200 ///reference to the parent window 201 MainWin & mainwin; 204 202 205 203 }; -
main_win.cc
r90 r94 2 2 #include "icons/guipixbufs.h" 3 3 4 MainWin::MainWin() : 5 mapwin("Map Setup", mapstorage, gd_canvas), 6 gd_canvas(mapstorage, mapwin, (Gtk::Window *)this) 7 { 4 MainWin::MainWin() 5 { 6 mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); 7 gd_canvas=new GraphDisplayerCanvas(*this); 8 8 9 set_title ("unsaved file - " + prog_name); 9 10 set_default_size(WIN_WIDTH,WIN_HEIGHT); 10 11 add(vbox); 11 12 13 //connecting signals - controller character 14 mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange)); 12 15 13 16 // custom icons for the toolbar … … 93 96 ag->add( Gtk::Action::create("ViewMenu", "_View") ); 94 97 ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN), 95 sigc::mem_fun( this->gd_canvas, &GraphDisplayerCanvas::zoomIn));98 sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomIn)); 96 99 ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT), 97 sigc::mem_fun( this->gd_canvas, &GraphDisplayerCanvas::zoomOut));100 sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomOut)); 98 101 ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT), 99 sigc::mem_fun( this->gd_canvas, &GraphDisplayerCanvas::zoomFit));102 sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomFit)); 100 103 ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), 101 sigc::mem_fun( this->gd_canvas, &GraphDisplayerCanvas::zoom100));104 sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100)); 102 105 103 106 ag->add( Gtk::Action::create("ShowMenu", "_Show") ); 104 107 ag->add( Gtk::Action::create("ShowMaps", "_Maps"), 105 sigc::mem_fun( this->mapwin, &MapWin::show));108 sigc::mem_fun(*(this->mapwin), &MapWin::show)); 106 109 107 110 Gtk::RadioAction::Group tool_group; 108 111 ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), 109 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );112 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) ); 110 113 ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"), 111 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );114 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 1) ); 112 115 ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"), 113 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );116 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 2) ); 114 117 ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"), 115 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );118 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 3) ); 116 119 117 120 ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"), 118 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );121 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 4) ); 119 122 ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"), 120 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );123 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 5) ); 121 124 122 125 ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), 123 sigc::mem_fun (new NewMapWin("NewMapWin", gd_canvas), &NewMapWin::show ) );126 sigc::mem_fun (new NewMapWin("NewMapWin", *this), &NewMapWin::show ) ); 124 127 125 128 uim=Gtk::UIManager::create(); … … 195 198 Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow()); 196 199 pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN); 197 pScrolledWindow->add( gd_canvas);200 pScrolledWindow->add(*gd_canvas); 198 201 vbox.pack_start(*pScrolledWindow); 199 202 … … 209 212 mapstorage.file_name = file; 210 213 mapstorage.modified = false; 211 gd_canvas .drawGraph();212 mapwin .update();214 gd_canvas->drawGraph(); 215 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 213 216 set_title(Glib::filename_display_basename(file) + " - " + prog_name); 214 217 } … … 234 237 } 235 238 } 236 gd_canvas .clear();239 gd_canvas->clear(); 237 240 mapstorage.clear(); 238 mapwin .update();241 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 239 242 set_title("unsaved file - " + prog_name); 240 243 } … … 265 268 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT) 266 269 { 267 gd_canvas .clear();270 gd_canvas->clear(); 268 271 mapstorage.clear(); 269 272 Glib::ustring filename = fcdialog.get_filename(); … … 272 275 mapstorage.file_name = filename; 273 276 mapstorage.modified = false; 274 gd_canvas .drawGraph();275 mapwin .update();277 gd_canvas->drawGraph(); 278 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 276 279 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); 277 280 } … … 328 331 } 329 332 } 330 gd_canvas .clear();333 gd_canvas->clear(); 331 334 mapstorage.clear(); 332 mapwin .update();335 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 333 336 set_title("unsaved file - " + prog_name); 334 337 } 338 339 void MainWin::propertyChange(bool itisedge, int prop, std::string mapname) 340 { 341 mapstorage.changeActiveMap(itisedge, prop, mapname); 342 } 343 344 void MainWin::popupNewMapWin(bool itisedge, int prop) 345 { 346 prop=prop; 347 (new NewMapWin("NewMapWin", *this, itisedge, false))->run(); 348 } 349 350 std::string MainWin::getActiveEdgeMap(int prop) 351 { 352 return mapstorage.getActiveEdgeMap(prop); 353 } 354 355 std::string MainWin::getActiveNodeMap(int prop) 356 { 357 return mapstorage.getActiveNodeMap(prop); 358 } 359 360 void MainWin::registerNewEdgeMap(std::string mapname) 361 { 362 mapwin->registerNewEdgeMap(mapname); 363 } 364 365 void MainWin::registerNewNodeMap(std::string mapname) 366 { 367 mapwin->registerNewNodeMap(mapname); 368 } -
main_win.h
r90 r94 3 3 #ifndef MAIN_WIN_H 4 4 #define MAIN_WIN_H 5 6 class MainWin; 5 7 6 8 #include "all_include.h" … … 27 29 protected: 28 30 ///Window of map-showing setup. Its type is \ref MapWin 29 MapWin mapwin;31 MapWin * mapwin; 30 32 31 33 ///The graph will be drawn on this \ref GraphDisplayerCanvas 32 GraphDisplayerCanvas gd_canvas;34 GraphDisplayerCanvas * gd_canvas; 33 35 34 36 ///ActionGroup for menu … … 54 56 ///Callback for 'Close' action. 55 57 virtual void close(); 58 59 public: 60 void propertyChange(bool, int, std::string); 61 void popupNewMapWin(bool, int); 62 63 std::string getActiveEdgeMap(int); 64 std::string getActiveNodeMap(int); 65 66 void registerNewEdgeMap(std::string); 67 void registerNewNodeMap(std::string); 68 56 69 }; 57 70 -
map_win.cc
r90 r94 11 11 } 12 12 13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)13 MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw) 14 14 { 15 15 set_title(title); … … 24 24 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 25 25 { 26 e_combo_array[i]=new MapSelector( gdc, ms, i, true);26 e_combo_array[i]=new MapSelector(eml, i, true); 27 27 28 28 (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 29 30 e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i)); 31 e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i)); 29 32 } 30 33 … … 41 44 for(int i=0;i<NODE_PROPERTY_NUM;i++) 42 45 { 43 n_combo_array[i]=new MapSelector( gdc, ms, i, false);46 n_combo_array[i]=new MapSelector(nml, i, false); 44 47 45 48 (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 49 50 n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i)); 51 n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i)); 46 52 } 47 53 … … 56 62 } 57 63 58 void MapWin::update() 64 void MapWin::nodeMapChanged(std::string mapname, int prop) 65 { 66 mainwin.propertyChange(false, prop, mapname); 67 } 68 69 void MapWin::edgeMapChanged(std::string mapname, int prop) 70 { 71 mainwin.propertyChange(true, prop, mapname); 72 } 73 74 void MapWin::newMapWinNeeded(bool itisedge, int prop) 75 { 76 mainwin.popupNewMapWin(itisedge, prop); 77 } 78 79 void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml) 59 80 { 60 81 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 61 82 { 62 e_combo_array[i]->update_list( );83 e_combo_array[i]->update_list(eml); 63 84 } 64 85 65 86 for(int i=0;i<NODE_PROPERTY_NUM;i++) 66 87 { 67 n_combo_array[i]->update_list( );88 n_combo_array[i]->update_list(nml); 68 89 } 69 }70 71 72 void MapWin::updateNode(Node node)73 {74 for(int i=0;i<NODE_PROPERTY_NUM;i++)75 {76 n_combo_array[i]->update(node);77 }78 }79 80 void MapWin::updateEdge(Edge edge)81 {82 for(int i=0;i<EDGE_PROPERTY_NUM;i++)83 {84 e_combo_array[i]->update(edge);85 }86 90 } 87 91 -
map_win.h
r90 r94 6 6 class MapWin; 7 7 8 #include "all_include.h" 9 #include "graph_displayer_canvas.h" 10 #include "mapstorage.h" 11 #include "new_map_win.h" 8 #include <all_include.h> 9 #include <main_win.h> 12 10 #include <libgnomecanvasmm.h> 13 11 #include <libgnomecanvasmm/polygon.h> … … 22 20 { 23 21 protected: 24 GraphDisplayerCanvas & gdc; 25 ///The \ref MapStorage in which the visualizable maps are stored 26 MapStorage & ms; 22 sigc::signal<void, std::string> signal_cbt; 23 sigc::signal<void, bool> signal_newmapwin; 27 24 28 25 int id; … … 42 39 Gtk::Label * label; 43 40 44 Node node_to_update;45 Edge edge_to_update;46 47 48 41 public: 49 42 50 MapSelector( GraphDisplayerCanvas &, MapStorage &, int, bool);43 MapSelector(std::vector<std::string>, int, bool); 51 44 52 void update_list(); 45 sigc::signal<void, std::string> signal_cbt_ch(); 46 sigc::signal<void, bool> signal_newmapwin_needed(); 47 48 void update_list( std::vector<std::string> ); 53 49 54 50 ///If a radiobutton is clicked, this function determines … … 62 58 virtual void reset(); 63 59 64 virtual void update(Node node);65 virtual void update(Edge edge);66 67 60 Glib::ustring get_active_text(); 68 61 void set_active_text(Glib::ustring); … … 73 66 74 67 protected: 75 ///The \ref GraphDisplayerCanvas on which the graph will be drawn. 76 ///It has to be known for this class, because 77 ///when a map assigned to a certain attribute 78 ///a function of the \ref GraphDisplayerCanvas will be called. 79 GraphDisplayerCanvas & gdc; 80 81 ///The \ref MapStorage in which the visualizable maps are stored 82 MapStorage & ms; 68 MainWin & mainwin; 83 69 84 70 Gtk::Table * table; … … 92 78 public: 93 79 ///Constructor of MapWin creates the widgets shown in MapWin. 94 MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas &);80 MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin & mw); 95 81 96 ///This function is created to set the appropriate maps on the newly created node 97 void updateNode(Graph::Node); 82 void nodeMapChanged(std::string, int); 98 83 99 ///This function is created to set the appropriate maps on the newly created edge 100 void updateEdge(Graph::Edge); 84 void edgeMapChanged(std::string, int); 85 86 void newMapWinNeeded(bool, int); 101 87 102 88 ///This function inserts name of the new edgemap in the list in the combo box … … 108 94 virtual bool closeIfEscapeIsPressed(GdkEventKey*); 109 95 110 void update( );96 void update(std::vector<std::string>, std::vector<std::string>); 111 97 }; 112 98 -
mapstorage.cc
r79 r94 17 17 nodemap_default["id"] = 1.0; 18 18 edgemap_default["id"] = 1.0; 19 20 active_nodemaps.resize(NODE_PROPERTY_NUM); 21 for(int i=0;i<NODE_PROPERTY_NUM;i++) 22 { 23 active_nodemaps[i]=""; 24 } 25 26 active_edgemaps.resize(EDGE_PROPERTY_NUM); 27 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 28 { 29 active_edgemaps[i]=""; 30 } 19 31 } 20 32 … … 43 55 } 44 56 return 1; 57 } 58 59 void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname) 60 { 61 if(itisedge) 62 { 63 active_edgemaps[prop]=mapname; 64 } 65 else 66 { 67 active_nodemaps[prop]=mapname; 68 } 69 signal_prop.emit(itisedge, prop); 70 } 71 72 std::string MapStorage::getActiveEdgeMap(int prop) 73 { 74 return active_edgemaps[prop]; 75 } 76 77 std::string MapStorage::getActiveNodeMap(int prop) 78 { 79 return active_nodemaps[prop]; 80 } 81 82 std::vector<std::string> MapStorage::getEdgeMapList() 83 { 84 std::vector<std::string> eml; 85 eml.resize(edgemap_storage.size()); 86 int i=0; 87 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps(); 88 for(;emsi!=endOfEdgeMaps();emsi++) 89 { 90 eml[i]=(emsi->first); 91 i++; 92 } 93 return eml; 94 } 95 96 std::vector<std::string> MapStorage::getNodeMapList() 97 { 98 std::vector<std::string> nml; 99 nml.resize(nodemap_storage.size()); 100 int i=0; 101 std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps(); 102 for(;nmsi!=endOfNodeMaps();nmsi++) 103 { 104 nml[i]=(nmsi->first); 105 i++; 106 } 107 return nml; 108 } 109 110 MapStorage::Signal_Prop MapStorage::signal_prop_ch() 111 { 112 return signal_prop; 45 113 } 46 114 -
mapstorage.h
r63 r94 4 4 #define MAPSTORAGE_H 5 5 6 class Mapstorage; 7 6 8 #include "all_include.h" 7 9 #include "xymap.h" 10 #include <libgnomecanvasmm.h> 8 11 9 12 ///Class MapStorage is responsible for storing … … 38 41 std::vector<Graph::EdgeMap<double> > default_edgemaps; 39 42 43 //Stores the active maps for the different visualization node attributes 44 std::vector< std::string > active_nodemaps; 45 46 //Stores the active maps for the different visualization edge attributes 47 std::vector< std::string > active_edgemaps; 48 40 49 // Default values for the maps 41 50 std::map< std::string, double > nodemap_default; … … 43 52 // Default values for the maps 44 53 std::map< std::string, double > edgemap_default; 54 55 protected: 56 typedef sigc::signal<void, bool, int> Signal_Prop; 57 Signal_Prop signal_prop; 45 58 46 59 public: … … 54 67 55 68 ~MapStorage(); 69 70 void changeActiveMap(bool, int, std::string); 71 72 std::string getActiveEdgeMap(int); 73 std::string getActiveNodeMap(int); 74 75 std::vector<std::string> getEdgeMapList(); 76 std::vector<std::string> getNodeMapList(); 77 78 Signal_Prop signal_prop_ch(); 56 79 57 80 ///Adds given map to storage. A name and the map itself has to be provided. -
mw-mapselector.cc
r90 r94 1 1 #include "map_win.h" 2 2 3 MapWin::MapSelector::MapSelector( GraphDisplayerCanvas & grdispc, MapStorage & mapst, int identifier, bool edge):gdc(grdispc),ms(mapst),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)3 MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false) 4 4 { 5 update_list( );5 update_list(ml); 6 6 7 7 cbt.set_active(0); … … 51 51 { 52 52 set_new_map=true; 53 (new NewMapWin("NewMapWin", gdc, itisedge, false))->run();53 signal_newmapwin.emit(itisedge); 54 54 } 55 55 56 void MapWin::MapSelector::update_list( )56 void MapWin::MapSelector::update_list( std::vector< std::string > ml ) 57 57 { 58 58 cbt.clear(); 59 if(itisedge) 59 std::vector< std::string >::iterator emsi=ml.begin(); 60 for(;emsi!=ml.end();emsi++) 60 61 { 61 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps(); 62 for(;emsi!=ms.endOfEdgeMaps();emsi++) 63 { 64 cbt.append_text(emsi->first); 65 } 66 } 67 else 68 { 69 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps(); 70 for(;emsi!=ms.endOfNodeMaps();emsi++) 71 { 72 cbt.append_text(emsi->first); 73 } 62 cbt.append_text(*emsi); 74 63 } 75 64 cbt.prepend_text("Default values"); … … 84 73 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. 85 74 { 86 if(itisedge) 87 { 88 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) ) 89 { 90 Edge edge=edge_to_update; 91 switch(id) 92 { 93 case E_WIDTH: 94 gdc.changeEdgeWidth(mapname, edge); 95 break; 96 case E_COLOR: 97 gdc.changeEdgeColor(mapname, edge); 98 break; 99 case E_TEXT: 100 gdc.changeEdgeText(mapname, edge); 101 break; 102 default: 103 std::cerr<<"Error\n"; 104 } 105 } 106 } 107 else 108 { 109 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) ) 110 { 111 Node node=node_to_update; 112 switch(id) 113 { 114 case N_RADIUS: 115 gdc.changeNodeRadius(mapname, node); 116 break; 117 case N_COLOR: 118 gdc.changeNodeColor(mapname, node); 119 break; 120 case N_TEXT: 121 gdc.changeNodeText(mapname, node); 122 break; 123 default: 124 std::cerr<<"Error\n"; 125 } 126 } 127 } 75 signal_cbt.emit(mapname); 128 76 } 129 77 } 130 78 else if((!default_state)&&(cbt.get_active_row_number()==0)) 131 79 { 80 signal_cbt.emit(""); 132 81 reset(); 133 82 } … … 139 88 cbt.set_active(0); 140 89 141 if(itisedge) 142 { 143 Edge edge=edge_to_update; 144 switch(id) 145 { 146 case E_WIDTH: 147 gdc.resetEdgeWidth(edge); 148 break; 149 case E_COLOR: 150 gdc.resetEdgeColor(edge); 151 break; 152 case E_TEXT: 153 gdc.resetEdgeText(edge); 154 break; 155 default: 156 std::cerr<<"Error\n"; 157 } 158 } 159 else 160 { 161 Node node=node_to_update; 162 switch(id) 163 { 164 case N_RADIUS: 165 gdc.resetNodeRadius(node); 166 break; 167 case N_COLOR: 168 gdc.resetNodeColor(node); 169 break; 170 case N_TEXT: 171 gdc.resetNodeText(node); 172 break; 173 default: 174 std::cerr<<"Error\n"; 175 } 176 } 90 signal_cbt.emit(""); 177 91 } 178 92 179 void MapWin::MapSelector::update(Node node)180 {181 node_to_update=node;182 if(default_state)183 {184 reset();185 }186 else187 {188 comboChanged();189 }190 node_to_update=INVALID;191 }192 193 void MapWin::MapSelector::update(Edge edge)194 {195 edge_to_update=edge;196 if(default_state)197 {198 reset();199 }200 else201 {202 comboChanged();203 }204 edge_to_update=INVALID;205 }206 93 207 94 Glib::ustring MapWin::MapSelector::get_active_text() … … 224 111 } 225 112 } 113 114 sigc::signal<void, std::string> MapWin::MapSelector::signal_cbt_ch() 115 { 116 return signal_cbt; 117 } 118 119 sigc::signal<void, bool> MapWin::MapSelector::signal_newmapwin_needed() 120 { 121 return signal_newmapwin; 122 } -
new_map_win.cc
r90 r94 10 10 } 11 11 12 NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap")12 NewMapWin::NewMapWin(const std::string& title, MainWin & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mainwin(mw),node("Create NodeMap"),edge("Create EdgeMap") 13 13 { 14 14 set_default_size(200, 50); … … 84 84 { 85 85 //create the new map 86 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ( gdc.mapstorage.graph);86 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mainwin.mapstorage.graph); 87 87 88 88 std::stack<double> polishstack; 89 89 90 for(EdgeIt k( gdc.mapstorage.graph); k!=INVALID; ++k)90 for(EdgeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k) 91 91 { 92 92 for(int i=0;i<(int)polishform.size();i++) … … 107 107 default: 108 108 //substitute variable 109 std::map< std::string,Graph::EdgeMap<double> * > ems= gdc.mapstorage.edgemap_storage;109 std::map< std::string,Graph::EdgeMap<double> * > ems=mainwin.mapstorage.edgemap_storage; 110 110 bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end()); 111 111 if(itisvar) 112 112 { 113 polishstack.push( (*( gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);113 polishstack.push( (*(mainwin.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]); 114 114 } 115 115 else … … 154 154 //if addition was not successful addEdgeMap returns one. 155 155 //cause can be that there is already a map named like the new one 156 if( gdc.mapstorage.addEdgeMap(mapname, emptr, def_val))156 if(mainwin.mapstorage.addEdgeMap(mapname, emptr, def_val)) 157 157 { 158 158 abortion=1; … … 160 160 161 161 //add it to the list of the displayable maps 162 gdc.mapwin.registerNewEdgeMap(mapname);162 mainwin.registerNewEdgeMap(mapname); 163 163 164 164 //display it 165 gdc.changeEdgeText(mapname);165 //gdc.changeEdgeText(mapname); 166 166 } 167 167 else //!edge.get_active() 168 168 { 169 169 //create the new map 170 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ( gdc.mapstorage.graph);170 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mainwin.mapstorage.graph); 171 171 172 172 std::stack<double> polishstack; 173 173 174 for(NodeIt k( gdc.mapstorage.graph); k!=INVALID; ++k)174 for(NodeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k) 175 175 { 176 176 for(int i=0;i<(int)polishform.size();i++) … … 190 190 break; 191 191 default: 192 std::map< std::string,Graph::NodeMap<double> * > nms= gdc.mapstorage.nodemap_storage;192 std::map< std::string,Graph::NodeMap<double> * > nms=mainwin.mapstorage.nodemap_storage; 193 193 bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end()); 194 194 if(itisvar) 195 195 { 196 polishstack.push( (*( gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);196 polishstack.push( (*(mainwin.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]); 197 197 } 198 198 else … … 237 237 //if addition was not successful addNodeMap returns one. 238 238 //cause can be that there is already a map named like the new one 239 if( gdc.mapstorage.addNodeMap(mapname,emptr, def_val))239 if(mainwin.mapstorage.addNodeMap(mapname,emptr, def_val)) 240 240 { 241 241 abortion=1; … … 243 243 244 244 //add it to the list of the displayable maps 245 gdc.mapwin.registerNewNodeMap(mapname);245 mainwin.registerNewNodeMap(mapname); 246 246 247 247 //display it … … 432 432 if(itisedge) 433 433 { 434 cancel=( gdc.mapstorage.edgemap_storage.find(variable)==gdc.mapstorage.edgemap_storage.end());434 cancel=(mainwin.mapstorage.edgemap_storage.find(variable)==mainwin.mapstorage.edgemap_storage.end()); 435 435 } 436 436 else 437 437 { 438 cancel=( gdc.mapstorage.nodemap_storage.find(variable)==gdc.mapstorage.nodemap_storage.end());438 cancel=(mainwin.mapstorage.nodemap_storage.find(variable)==mainwin.mapstorage.nodemap_storage.end()); 439 439 } 440 440 //maybe it is number -
new_map_win.h
r90 r94 7 7 8 8 #include <all_include.h> 9 #include < graph_displayer_canvas.h>9 #include <main_win.h> 10 10 #include <libgnomecanvasmm.h> 11 11 #include <libgnomecanvasmm/polygon.h> … … 17 17 class NewMapWin : public Gtk::Dialog 18 18 { 19 ///The \ref GraphDisplayerCanvas on which the graph will be drawn. 20 ///It has to be known for this class, because 21 ///when a map is created 22 ///a function of the \ref GraphDisplayerCanvas will be called. 23 GraphDisplayerCanvas & gdc; 19 MainWin & mainwin; 24 20 25 21 public: … … 32 28 33 29 ///Constructor of NewMapWin creates the widgets shown in NewMapWin. 34 NewMapWin(const std::string& title, GraphDisplayerCanvas&, bool itisedge=true, bool edgenode=true);30 NewMapWin(const std::string& title, MainWin &, bool itisedge=true, bool edgenode=true); 35 31 36 32 ///Signal on button is connected to this function,
Note: See TracChangeset
for help on using the changeset viewer.