Bugfix.
1 #include "graph_displayer_canvas.h"
4 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & 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 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
8 edgemap_to_edit(""), mytab(mainw)
10 //base event handler is move tool
11 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
19 GraphDisplayerCanvas::~GraphDisplayerCanvas()
21 for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n)
24 delete nodetextmap[n];
27 for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e)
30 delete edgetextmap[e];
34 void GraphDisplayerCanvas::propertyChange(bool itisedge, int prop)
38 propertyUpdate(Edge(INVALID), prop);
42 propertyUpdate(Node(INVALID), prop);
46 void GraphDisplayerCanvas::propertyUpdate(Edge edge)
48 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
50 propertyUpdate(edge, i);
54 void GraphDisplayerCanvas::propertyUpdate(Node node)
56 for(int i=0;i<NODE_PROPERTY_NUM;i++)
58 propertyUpdate(node, i);
62 void GraphDisplayerCanvas::propertyUpdate(Node node, int prop)
66 std::string mapname=mytab.getActiveNodeMap(prop);
70 if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) )
75 changeNodeRadius(mapname, node);
78 changeNodeColor(mapname, node);
81 changeNodeText(mapname, node);
94 resetNodeRadius(node);
103 std::cerr<<"Error\n";
109 void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop)
113 std::string mapname=mytab.getActiveEdgeMap(prop);
117 if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) )
122 changeEdgeWidth(mapname, edge);
125 changeEdgeColor(mapname, edge);
128 changeEdgeText(mapname, edge);
131 std::cerr<<"Error\n";
140 resetEdgeWidth(edge);
143 resetEdgeColor(edge);
149 std::cerr<<"Error\n";
154 void GraphDisplayerCanvas::drawGraph()
156 //first edges are drawn, to hide joining with nodes later
158 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
160 if (mytab.mapstorage.graph.source(i) == mytab.mapstorage.graph.target(i))
162 edgesmap[i]=new LoopEdge(displayed_graph, i, *this);
166 edgesmap[i]=new BrokenEdge(displayed_graph, i, *this);
168 //initializing edge-text as well, to empty string
170 XY text_pos=mytab.mapstorage.arrow_pos[i];
171 text_pos+=(XY(10,10));
173 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
174 edgetextmap[i]->property_fill_color().set_value("darkgreen");
175 edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
176 edgetextmap[i]->raise_to_top();
179 //afterwards nodes come to be drawn
181 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
183 //drawing bule nodes, with black line around them
185 nodesmap[i]=new Gnome::Canvas::Ellipse(
187 (mytab.mapstorage).coords[i].x-20,
188 (mytab.mapstorage).coords[i].y-20,
189 (mytab.mapstorage).coords[i].x+20,
190 (mytab.mapstorage).coords[i].y+20);
191 *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
192 *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
193 nodesmap[i]->raise_to_top();
195 //initializing edge-text as well, to empty string
198 ((mytab.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),
199 ((mytab.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));
201 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
202 text_pos.x, text_pos.y, "");
203 nodetextmap[i]->property_fill_color().set_value("darkblue");
204 nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
205 nodetextmap[i]->raise_to_top();
208 updateScrollRegion();
211 void GraphDisplayerCanvas::clear()
215 forming_edge=INVALID;
217 for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n)
220 delete nodetextmap[n];
223 for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e)
226 delete edgetextmap[e];