- Timer can be stop()ed and (re)start()ed.
- Obsolete \bug removed
1 #include "graph_displayer_canvas.h"
2 #include "broken_edge.h"
5 GraphDisplayerCanvas::GraphDisplayerCanvas(MapStorage & ms, MapWin & mw, Gtk::Window * mainwin) :
6 nodesmap(ms.graph), edgesmap(ms.graph), edgetextmap(ms.graph),
7 nodetextmap(ms.graph), displayed_graph(*(root()), 0, 0), mapstorage(ms),
8 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
9 edgemap_to_edit(""), mapwin(mw)
13 //base event handler is move tool
14 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
22 GraphDisplayerCanvas::~GraphDisplayerCanvas()
24 for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
27 delete nodetextmap[n];
30 for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
33 delete edgetextmap[e];
37 void GraphDisplayerCanvas::drawGraph()
39 //first edges are drawn, to hide joining with nodes later
41 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
44 //drawing green lines, coordinates are from mapstorage.coords
46 Gnome::Canvas::Points coos;
47 coos.push_back(Gnome::Art::Point(
48 mapstorage.coords[mapstorage.graph.source(i)].x,
49 mapstorage.coords[mapstorage.graph.source(i)].y));
50 coos.push_back(Gnome::Art::Point(
51 mapstorage.coords[mapstorage.graph.target(i)].x,
52 mapstorage.coords[mapstorage.graph.target(i)].y));
54 edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
55 *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
56 edgesmap[i]->property_width_units().set_value(10);
57 edgesmap[i]->lower_to_bottom();
59 //initializing edge-text as well, to empty string
61 xy<double> text_pos=edgesmap[i]->getArrowPos();
62 text_pos+=(xy<double>(10,10));
64 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
65 edgetextmap[i]->property_fill_color().set_value("darkgreen");
66 edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
67 edgetextmap[i]->raise_to_top();
70 //afterwards nodes come to be drawn
72 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
74 //drawing bule nodes, with black line around them
76 nodesmap[i]=new Gnome::Canvas::Ellipse(
78 mapstorage.coords[i].x-20,
79 mapstorage.coords[i].y-20,
80 mapstorage.coords[i].x+20,
81 mapstorage.coords[i].y+20);
82 *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
83 *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
84 nodesmap[i]->raise_to_top();
86 //initializing edge-text as well, to empty string
89 (mapstorage.coords[i].x+node_property_defaults[N_RADIUS]+5),
90 (mapstorage.coords[i].y+node_property_defaults[N_RADIUS]+5));
92 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
93 text_pos.x, text_pos.y, "");
94 nodetextmap[i]->property_fill_color().set_value("darkblue");
95 nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
96 nodetextmap[i]->raise_to_top();
102 void GraphDisplayerCanvas::clear()
106 forming_edge=INVALID;
108 for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
111 delete nodetextmap[n];
114 for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
117 delete edgetextmap[e];