#include "graph_displayer_canvas.h" #include GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) : nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph), nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0), isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""), edgemap_to_edit(""), mytab(mainw) { //base event handler is move tool actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); actual_tool=MOVE; active_node=INVALID; active_edge=INVALID; forming_edge=INVALID; } GraphDisplayerCanvas::~GraphDisplayerCanvas() { for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n) { delete nodesmap[n]; delete nodetextmap[n]; } for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e) { delete edgesmap[e]; delete edgetextmap[e]; } } void GraphDisplayerCanvas::propertyChange(bool itisedge, int prop) { if(itisedge) { propertyUpdate(Edge(INVALID), prop); } else { propertyUpdate(Node(INVALID), prop); } } void GraphDisplayerCanvas::propertyUpdate(Edge edge) { for(int i=0;iproperty_width_units().set_value(10); edgesmap[i]->lower_to_bottom(); //initializing edge-text as well, to empty string XY text_pos=mytab.mapstorage.arrow_pos[i]; text_pos+=(XY(10,10)); edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); edgetextmap[i]->property_fill_color().set_value("darkgreen"); edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false); edgetextmap[i]->raise_to_top(); } //afterwards nodes come to be drawn for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) { //drawing bule nodes, with black line around them nodesmap[i]=new Gnome::Canvas::Ellipse( displayed_graph, (mytab.mapstorage).coords[i].x-20, (mytab.mapstorage).coords[i].y-20, (mytab.mapstorage).coords[i].x+20, (mytab.mapstorage).coords[i].y+20); *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue"); *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black"); nodesmap[i]->raise_to_top(); //initializing edge-text as well, to empty string xy text_pos( ((mytab.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5), ((mytab.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5)); nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); nodetextmap[i]->property_fill_color().set_value("darkblue"); nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false); nodetextmap[i]->raise_to_top(); } updateScrollRegion(); } void GraphDisplayerCanvas::clear() { active_node=INVALID; active_edge=INVALID; forming_edge=INVALID; for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n) { delete nodesmap[n]; delete nodetextmap[n]; } for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e) { delete edgesmap[e]; delete edgetextmap[e]; } }