COIN-OR::LEMON - Graph Library

source: glemon-0.x/graph_displayer_canvas.h @ 88:c397e85ec555

gui
Last change on this file since 88:c397e85ec555 was 88:c397e85ec555, checked in by Hegyi Péter, 19 years ago

As initial value of a new map expression with ()+-/* operators can be given. These operators work on numbers, or on maps. If maps are given, then the new value for a given graph element will be calculated using the value from the given maps that belong to that graph element.

File size: 5.9 KB
RevLine 
[6]1// -*- C++ -*- //
2
3#ifndef GRAPH_DISPLAYER_CANVAS_H
4#define GRAPH_DISPLAYER_CANVAS_H
5
[21]6class GraphDisplayerCanvas;
7
[53]8#include "all_include.h"
9#include "mapstorage.h"
10#include "broken_edge.h"
11#include "map_win.h"
[6]12#include <libgnomecanvasmm.h>
13#include <libgnomecanvasmm/polygon.h>
14
15///This class is the canvas, on which the graph can be drawn.
16class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
17{
18  typedef Gnome::Canvas::CanvasAA Parent;
19
20public:
[55]21  GraphDisplayerCanvas(MapStorage &, MapWin &, Gtk::Window *);
[6]22  virtual ~GraphDisplayerCanvas();
23
24  ///Changes the linewidth attribute according to the given map.
25  ///\param mapname is the name of the map which contains the new values
[62]26  int changeEdgeWidth (std::string mapname, Edge new_item=INVALID);
[81]27  int resetEdgeWidth (Edge new_item=INVALID);
[6]28
29  ///Changes the linecolor attribute according to the given map.
30  ///\param mapname is the name of the map which contains the new values
[62]31  int changeEdgeColor (std::string mapname, Edge new_item=INVALID);
[81]32  int resetEdgeColor (Edge new_item=INVALID);
[6]33
34  ///Changes the text of line attribute according to the given map.
35  ///\param mapname is the name of the map which contains the new values
[62]36  int changeEdgeText (std::string mapname, Edge new_item=INVALID);
[81]37  int resetEdgeText (Edge new_item=INVALID);
[28]38
39  ///Changes the linewidth attribute according to the given map.
40  ///\param mapname is the name of the map which contains the new values
[62]41  int changeNodeRadius (std::string mapname, Node new_item=INVALID);
[81]42  int resetNodeRadius (Node new_item=INVALID);
[28]43
44  ///Changes the linecolor attribute according to the given map.
45  ///\param mapname is the name of the map which contains the new values
[62]46  int changeNodeColor (std::string mapname, Node new_item=INVALID);
[81]47  int resetNodeColor (Node new_item=INVALID);
[28]48
49  ///Changes the text of line attribute according to the given map.
50  ///\param mapname is the name of the map which contains the new values
[62]51  int changeNodeText (std::string mapname, Node new_item=INVALID);
[81]52  int resetNodeText (Node new_item=INVALID);
[6]53
54  ///Callback for 'ViewZoomIn' action.
55  virtual void zoomIn();
56  ///Callback for 'ViewZoomOut' action.
57  virtual void zoomOut();
58  ///Callback for 'ViewZoomFit' action.
59  virtual void zoomFit();
60  ///Callback for 'ViewZoom100' action.
61  virtual void zoom100();
62  ///Sets the scroll region of the convas to the bounding box of the graph.
63  void updateScrollRegion();
64
[9]65  ///This function changes the tool in the graph-editor's hand
66  void changeEditorialTool(int);
67
[6]68protected:
69
70  //maximizing, minimizing, restoring window, etc.
71  virtual bool on_expose_event(GdkEventExpose *);
72
73private:
74
75  ///This function is responsible for the correct
76  ///reaction of any action happened in the territory
77  ///of the canvas
[25]78  ///DEPRECATED!!!!
[30]79  bool eventHandler(GdkEvent* e, Node n);
[6]80
[9]81  ///actual event handler
82  ///
83  ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
84  sigc::connection actual_handler;
85
86  ///event handler for the case when move-tool is active
[30]87  bool moveEventHandler(GdkEvent*);
[9]88  ///event handler for the case when create_node-tool is active
[30]89  bool createNodeEventHandler(GdkEvent*);
[9]90  ///event handler for the case when create_edge-tool is active
[30]91  bool createEdgeEventHandler(GdkEvent*);
[13]92  ///event handler for the case when eraser-tool is active
[30]93  bool eraserEventHandler(GdkEvent*);
[32]94  ///event handler for the case when edge map editor tool is active
[30]95  bool edgeMapEditEventHandler(GdkEvent*);
[32]96  ///event handler for the case when node map editor tool is active
97  bool nodeMapEditEventHandler(GdkEvent*);
[13]98
[21]99public:
[25]100  ///Moves the text to new place
[30]101  void textReposition(xy<double>);
[25]102  ///Activates an edge belonging to a BrokenEdge
[35]103  ///
104  ///After we have activated an edge this way,
105  ///the GDC object will know, which edge is under forming
106  ///therefore it can redraw the necessarz elementy on the canvas,
107  ///for example the text belonging to the \ref BrokenEdge can be
108  ///redrawn (\ref textReposition).
[30]109  void toggleEdgeActivity(BrokenEdge*, bool);
[25]110
111public:
[21]112  ///\return the actual tool in hand
[30]113  int getActualTool();
[21]114
[53]115  void drawGraph();
116  void clear();
117
[37]118  ///creates a new Nodemap
[46]119  int addNewNodeMap(double,std::string);
[37]120  ///creates a new Edgemap
[46]121  int addNewEdgeMap(double,std::string);
[37]122
[21]123private:
[14]124  ///Deletes the given element.
[62]125  void deleteItem(Node);
[14]126  ///Deletes the given element.
[62]127  void deleteItem(Edge);
[9]128
[21]129private:
130
[6]131  ///Map of nodes of graph
132  Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
133
134  ///Map of edges of graph
[19]135  Graph::EdgeMap<BrokenEdge *> edgesmap;
[6]136
137  ///Map of texts to write on edges
138  Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
139
[28]140  ///Map of texts to write on nodes
141  Graph::NodeMap<Gnome::Canvas::Text *> nodetextmap;
142
[6]143  ///Group of graphical elements of displayed_graph
144  Gnome::Canvas::Group displayed_graph;
145
[88]146public:
[6]147  ///Here we store the maps that can be displayed through properties.
[40]148  MapStorage & mapstorage;
[6]149
[88]150private:
[6]151  ///Indicates whether the button of mouse is pressed or not
[20]152  int isbutton;
[6]153
[21]154  ///Stores the actual tool in hand
155  int actual_tool;
156
[6]157  ///At this location was the mousebutton pressed.
158  ///It helps to calculate the distance of dragging.
159  double clicked_x, clicked_y;
160
161  ///Remembers which Gnome::Canvas::Item was pressed.
162  ///this variable is needed, because
163  ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
164  ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
[11]165  Gnome::Canvas::Item * active_item, * target_item;
[62]166  Node active_node;
167  Edge active_edge;
168  Edge forming_edge;
[35]169
170  std::string nodemap_to_edit, edgemap_to_edit;
[6]171
172  static const int zoom_step = 5;
[19]173
[88]174public:
[28]175  ///We need to store mapwin, to be able to ask the appropriate values for properties of new items.
[53]176  MapWin & mapwin;
[28]177
[88]178private:
179
[66]180  ///pointer to the parent window
[55]181  Gtk::Window * parentwin;
182
[6]183};
184
185#endif //GRAPH_DISPLAYER_CANVAS_H
Note: See TracBrowser for help on using the repository browser.