COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/graph_displayer_canvas.h @ 1441:fd4b6f6d592a

Last change on this file since 1441:fd4b6f6d592a was 1441:fd4b6f6d592a, checked in by Akos Ladanyi, 19 years ago
File size: 2.8 KB
RevLine 
[1412]1// -*- C++ -*- //
2
3#ifndef GRAPH_DISPLAYER_CANVAS_H
4#define GRAPH_DISPLAYER_CANVAS_H
5
6#include <all_include.h>
7#include <mapstorage.h>
8#include <libgnomecanvasmm.h>
9#include <libgnomecanvasmm/polygon.h>
10
[1440]11///This class is the canvas, on which the graph can be drawn.
[1412]12class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
13{
14  typedef Gnome::Canvas::CanvasAA Parent;
15
16public:
17  GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
18  virtual ~GraphDisplayerCanvas();
19
[1440]20  ///Changes the linewidth attribute according to the given map.
21  ///\param mapname is the name of the map which contains the new values
[1412]22  int changeLineWidth (std::string mapname);
[1440]23
24  ///Changes the linecolor attribute according to the given map.
25  ///\param mapname is the name of the map which contains the new values
[1412]26  int changeColor (std::string mapname);
[1440]27
28  ///Changes the text of line attribute according to the given map.
29  ///\param mapname is the name of the map which contains the new values
[1412]30  int changeText (std::string mapname);
[1440]31
[1441]32  ///Callback for 'ViewZoomIn' action.
33  virtual void zoomIn();
34  ///Callback for 'ViewZoomOut' action.
35  virtual void zoomOut();
36  ///Callback for 'ViewZoomFit' action.
37  virtual void zoomFit();
38  ///Callback for 'ViewZoom100' action.
39  virtual void zoom100();
40  ///Sets the scroll region of the convas to the bounding box of the graph.
41  void updateScrollRegion();
[1412]42
43protected:
44
[1440]45  //maximizing, minimizing, restoring window, etc.
[1412]46  virtual bool on_expose_event(GdkEventExpose *);
47
48private:
49
[1440]50  ///This function is responsible for the correct
51  ///reaction of any action happened in the territory
52  ///of the canvas
[1412]53  bool event_handler(GdkEvent* e, Node n);
54
55  ///The graph, on which we work
56  Graph g;
[1440]57
58  ///Map of nodes of graph
[1412]59  Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
[1440]60
61  ///Map of edges of graph
[1412]62  Graph::EdgeMap<Gnome::Canvas::Line *> edgesmap;
63
64  ///Map of texts to write on edges
65  Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
66
67  ///Group of graphical elements of displayed_graph
68  Gnome::Canvas::Group displayed_graph;
69
70  ///Here we store the maps that can be displayed through properties.
71  MapStorage mapstorage;
72
73  ///Indicates whether the button of mouse is pressed or not
74  bool isbutton;
75
76  ///At this location was the mousebutton pressed.
77  ///It helps to calculate the distance of dragging.
78  double clicked_x, clicked_y;
79
80  ///Remembers which Gnome::Canvas::Item was pressed.
81  ///this variable is needed, because
82  ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
83  ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
84  Gnome::Canvas::Item * active_item;
85
[1441]86  static const int zoom_step = 5;
[1412]87};
88
89#endif //GRAPH_DISPLAYER_CANVAS_H
Note: See TracBrowser for help on using the repository browser.