1.1 --- a/graph_displayer_canvas.h Wed Jun 01 23:30:13 2005 +0000
1.2 +++ b/graph_displayer_canvas.h Wed Jun 01 23:33:26 2005 +0000
1.3 @@ -1,89 +1,89 @@
1.4 -// -*- C++ -*- //
1.5 -
1.6 -#ifndef GRAPH_DISPLAYER_CANVAS_H
1.7 -#define GRAPH_DISPLAYER_CANVAS_H
1.8 -
1.9 -#include <all_include.h>
1.10 -#include <mapstorage.h>
1.11 -#include <libgnomecanvasmm.h>
1.12 -#include <libgnomecanvasmm/polygon.h>
1.13 -
1.14 -///This class is the canvas, on which the graph can be drawn.
1.15 -class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
1.16 -{
1.17 - typedef Gnome::Canvas::CanvasAA Parent;
1.18 -
1.19 -public:
1.20 - GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
1.21 - virtual ~GraphDisplayerCanvas();
1.22 -
1.23 - ///Changes the linewidth attribute according to the given map.
1.24 - ///\param mapname is the name of the map which contains the new values
1.25 - int changeLineWidth (std::string mapname);
1.26 -
1.27 - ///Changes the linecolor attribute according to the given map.
1.28 - ///\param mapname is the name of the map which contains the new values
1.29 - int changeColor (std::string mapname);
1.30 -
1.31 - ///Changes the text of line attribute according to the given map.
1.32 - ///\param mapname is the name of the map which contains the new values
1.33 - int changeText (std::string mapname);
1.34 -
1.35 - ///Callback for 'ViewZoomIn' action.
1.36 - virtual void zoomIn();
1.37 - ///Callback for 'ViewZoomOut' action.
1.38 - virtual void zoomOut();
1.39 - ///Callback for 'ViewZoomFit' action.
1.40 - virtual void zoomFit();
1.41 - ///Callback for 'ViewZoom100' action.
1.42 - virtual void zoom100();
1.43 - ///Sets the scroll region of the convas to the bounding box of the graph.
1.44 - void updateScrollRegion();
1.45 -
1.46 -protected:
1.47 -
1.48 - //maximizing, minimizing, restoring window, etc.
1.49 - virtual bool on_expose_event(GdkEventExpose *);
1.50 -
1.51 -private:
1.52 -
1.53 - ///This function is responsible for the correct
1.54 - ///reaction of any action happened in the territory
1.55 - ///of the canvas
1.56 - bool event_handler(GdkEvent* e, Node n);
1.57 -
1.58 - ///The graph, on which we work
1.59 - Graph g;
1.60 -
1.61 - ///Map of nodes of graph
1.62 - Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
1.63 -
1.64 - ///Map of edges of graph
1.65 - Graph::EdgeMap<Gnome::Canvas::Line *> edgesmap;
1.66 -
1.67 - ///Map of texts to write on edges
1.68 - Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
1.69 -
1.70 - ///Group of graphical elements of displayed_graph
1.71 - Gnome::Canvas::Group displayed_graph;
1.72 -
1.73 - ///Here we store the maps that can be displayed through properties.
1.74 - MapStorage mapstorage;
1.75 -
1.76 - ///Indicates whether the button of mouse is pressed or not
1.77 - bool isbutton;
1.78 -
1.79 - ///At this location was the mousebutton pressed.
1.80 - ///It helps to calculate the distance of dragging.
1.81 - double clicked_x, clicked_y;
1.82 -
1.83 - ///Remembers which Gnome::Canvas::Item was pressed.
1.84 - ///this variable is needed, because
1.85 - ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
1.86 - ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
1.87 - Gnome::Canvas::Item * active_item;
1.88 -
1.89 - static const int zoom_step = 5;
1.90 -};
1.91 -
1.92 -#endif //GRAPH_DISPLAYER_CANVAS_H
1.93 +// -*- C++ -*- //
1.94 +
1.95 +#ifndef GRAPH_DISPLAYER_CANVAS_H
1.96 +#define GRAPH_DISPLAYER_CANVAS_H
1.97 +
1.98 +#include <all_include.h>
1.99 +#include <mapstorage.h>
1.100 +#include <libgnomecanvasmm.h>
1.101 +#include <libgnomecanvasmm/polygon.h>
1.102 +
1.103 +///This class is the canvas, on which the graph can be drawn.
1.104 +class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
1.105 +{
1.106 + typedef Gnome::Canvas::CanvasAA Parent;
1.107 +
1.108 +public:
1.109 + GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
1.110 + virtual ~GraphDisplayerCanvas();
1.111 +
1.112 + ///Changes the linewidth attribute according to the given map.
1.113 + ///\param mapname is the name of the map which contains the new values
1.114 + int changeLineWidth (std::string mapname);
1.115 +
1.116 + ///Changes the linecolor attribute according to the given map.
1.117 + ///\param mapname is the name of the map which contains the new values
1.118 + int changeColor (std::string mapname);
1.119 +
1.120 + ///Changes the text of line attribute according to the given map.
1.121 + ///\param mapname is the name of the map which contains the new values
1.122 + int changeText (std::string mapname);
1.123 +
1.124 + ///Callback for 'ViewZoomIn' action.
1.125 + virtual void zoomIn();
1.126 + ///Callback for 'ViewZoomOut' action.
1.127 + virtual void zoomOut();
1.128 + ///Callback for 'ViewZoomFit' action.
1.129 + virtual void zoomFit();
1.130 + ///Callback for 'ViewZoom100' action.
1.131 + virtual void zoom100();
1.132 + ///Sets the scroll region of the convas to the bounding box of the graph.
1.133 + void updateScrollRegion();
1.134 +
1.135 +protected:
1.136 +
1.137 + //maximizing, minimizing, restoring window, etc.
1.138 + virtual bool on_expose_event(GdkEventExpose *);
1.139 +
1.140 +private:
1.141 +
1.142 + ///This function is responsible for the correct
1.143 + ///reaction of any action happened in the territory
1.144 + ///of the canvas
1.145 + bool event_handler(GdkEvent* e, Node n);
1.146 +
1.147 + ///The graph, on which we work
1.148 + Graph g;
1.149 +
1.150 + ///Map of nodes of graph
1.151 + Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
1.152 +
1.153 + ///Map of edges of graph
1.154 + Graph::EdgeMap<Gnome::Canvas::Line *> edgesmap;
1.155 +
1.156 + ///Map of texts to write on edges
1.157 + Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
1.158 +
1.159 + ///Group of graphical elements of displayed_graph
1.160 + Gnome::Canvas::Group displayed_graph;
1.161 +
1.162 + ///Here we store the maps that can be displayed through properties.
1.163 + MapStorage mapstorage;
1.164 +
1.165 + ///Indicates whether the button of mouse is pressed or not
1.166 + bool isbutton;
1.167 +
1.168 + ///At this location was the mousebutton pressed.
1.169 + ///It helps to calculate the distance of dragging.
1.170 + double clicked_x, clicked_y;
1.171 +
1.172 + ///Remembers which Gnome::Canvas::Item was pressed.
1.173 + ///this variable is needed, because
1.174 + ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
1.175 + ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
1.176 + Gnome::Canvas::Item * active_item;
1.177 +
1.178 + static const int zoom_step = 5;
1.179 +};
1.180 +
1.181 +#endif //GRAPH_DISPLAYER_CANVAS_H