graph_displayer_canvas.h
author ladanyi
Mon, 23 May 2005 04:48:14 +0000
branchgui
changeset 3 bd60a2909c53
child 4 e099638ff236
permissions -rw-r--r--
trunk/src/* move to trunk/
ladanyi@1
     1
// -*- C++ -*- //
ladanyi@1
     2
ladanyi@1
     3
#ifndef GRAPH_DISPLAYER_CANVAS_H
ladanyi@1
     4
#define GRAPH_DISPLAYER_CANVAS_H
ladanyi@1
     5
ladanyi@1
     6
#include <all_include.h>
ladanyi@1
     7
#include <mapstorage.h>
ladanyi@1
     8
#include <libgnomecanvasmm.h>
ladanyi@1
     9
#include <libgnomecanvasmm/polygon.h>
ladanyi@1
    10
ladanyi@1
    11
class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
ladanyi@1
    12
{
ladanyi@1
    13
  typedef Gnome::Canvas::CanvasAA Parent;
ladanyi@1
    14
ladanyi@1
    15
public:
ladanyi@1
    16
  GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
ladanyi@1
    17
  virtual ~GraphDisplayerCanvas();
ladanyi@1
    18
ladanyi@1
    19
  int changeLineWidth (std::string mapname);
ladanyi@1
    20
  int changeColor (std::string mapname);
ladanyi@1
    21
  int changeText (std::string mapname);
ladanyi@1
    22
  int rezoom();
ladanyi@1
    23
ladanyi@1
    24
protected:
ladanyi@1
    25
ladanyi@1
    26
  virtual bool on_expose_event(GdkEventExpose *);
ladanyi@1
    27
ladanyi@1
    28
private:
ladanyi@1
    29
ladanyi@1
    30
  ///Event handler function that handles dragging nodes of displayed_graph
ladanyi@1
    31
  bool event_handler(GdkEvent* e, Node n);
ladanyi@1
    32
ladanyi@1
    33
  ///The graph, on which we work
ladanyi@1
    34
  Graph g;
ladanyi@1
    35
  ///Map of nodes of planefigure
ladanyi@1
    36
  Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
ladanyi@1
    37
  ///Map of edges of planefigure
ladanyi@1
    38
  Graph::EdgeMap<Gnome::Canvas::Line *> edgesmap;
ladanyi@1
    39
ladanyi@1
    40
  ///Map of texts to write on edges
ladanyi@1
    41
  Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
ladanyi@1
    42
ladanyi@1
    43
  ///Group of graphical elements of displayed_graph
ladanyi@1
    44
  Gnome::Canvas::Group displayed_graph;
ladanyi@1
    45
ladanyi@1
    46
  ///Here we store the maps that can be displayed through properties.
ladanyi@1
    47
  MapStorage mapstorage;
ladanyi@1
    48
ladanyi@1
    49
  ///Indicates whether the button of mouse is pressed or not
ladanyi@1
    50
  bool isbutton;
ladanyi@1
    51
ladanyi@1
    52
  ///At this location was the mousebutton pressed.
ladanyi@1
    53
  ///It helps to calculate the distance of dragging.
ladanyi@1
    54
  double clicked_x, clicked_y;
ladanyi@1
    55
ladanyi@1
    56
  ///Remembers which Gnome::Canvas::Item was pressed.
ladanyi@1
    57
  ///this variable is needed, because
ladanyi@1
    58
  ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
ladanyi@1
    59
  ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
ladanyi@1
    60
  Gnome::Canvas::Item * active_item;
ladanyi@1
    61
ladanyi@1
    62
ladanyi@1
    63
};
ladanyi@1
    64
ladanyi@1
    65
#endif //GRAPH_DISPLAYER_CANVAS_H