Put an end to every gcc-4.0 warning.
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),
8 canvasentrywidget(NULL), mapstorage(ms), isbutton(0), active_item(NULL),
9 target_item(NULL), nodemap_to_edit(""), 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);
17 //setting event handler for the editor widget
18 entrywidget.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::entryWidgetChangeHandler), false);
25 GraphDisplayerCanvas::~GraphDisplayerCanvas()
27 for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
30 delete nodetextmap[n];
33 for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
36 delete edgetextmap[e];
41 delete(canvasentrywidget);
45 void GraphDisplayerCanvas::drawGraph()
47 //first edges are drawn, to hide joining with nodes later
49 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
52 //drawing green lines, coordinates are from mapstorage.coords
54 Gnome::Canvas::Points coos;
55 coos.push_back(Gnome::Art::Point(
56 mapstorage.coords[mapstorage.graph.source(i)].x,
57 mapstorage.coords[mapstorage.graph.source(i)].y));
58 coos.push_back(Gnome::Art::Point(
59 mapstorage.coords[mapstorage.graph.target(i)].x,
60 mapstorage.coords[mapstorage.graph.target(i)].y));
62 edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
63 *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
64 edgesmap[i]->property_width_units().set_value(10);
66 //initializing edge-text as well, to empty string
68 xy<double> text_pos=edgesmap[i]->getArrowPos();
69 text_pos+=(xy<double>(10,10));
71 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
72 edgetextmap[i]->property_fill_color().set_value("darkgreen");
73 edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
76 //afterwards nodes come to be drawn
78 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
80 //drawing bule nodes, with black line around them
82 nodesmap[i]=new Gnome::Canvas::Ellipse(
84 mapstorage.coords[i].x-20,
85 mapstorage.coords[i].y-20,
86 mapstorage.coords[i].x+20,
87 mapstorage.coords[i].y+20);
88 *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
89 *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
91 //initializing edge-text as well, to empty string
94 (mapstorage.coords[i].x+node_property_defaults[N_RADIUS]+5),
95 (mapstorage.coords[i].y+node_property_defaults[N_RADIUS]+5));
97 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
98 text_pos.x, text_pos.y, "");
99 nodetextmap[i]->property_fill_color().set_value("darkblue");
100 nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
103 updateScrollRegion();
106 void GraphDisplayerCanvas::clear()
110 forming_edge=INVALID;
112 for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
115 delete nodetextmap[n];
118 for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
121 delete edgetextmap[e];