graph_displayer_canvas.h
author hegyi
Fri, 27 May 2005 10:34:20 +0000
branchgui
changeset 4 e099638ff236
parent 1 c69fedfbb9b3
child 5 b7c36be1e35c
permissions -rw-r--r--
Small documentation is added to GUI
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
hegyi@4
    11
///This class is the canvas, on which the graph can be drawn.
ladanyi@1
    12
class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
ladanyi@1
    13
{
ladanyi@1
    14
  typedef Gnome::Canvas::CanvasAA Parent;
ladanyi@1
    15
ladanyi@1
    16
public:
ladanyi@1
    17
  GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
ladanyi@1
    18
  virtual ~GraphDisplayerCanvas();
ladanyi@1
    19
hegyi@4
    20
  ///Changes the linewidth attribute according to the given map.
hegyi@4
    21
  ///\param mapname is the name of the map which contains the new values
ladanyi@1
    22
  int changeLineWidth (std::string mapname);
hegyi@4
    23
hegyi@4
    24
  ///Changes the linecolor attribute according to the given map.
hegyi@4
    25
  ///\param mapname is the name of the map which contains the new values
ladanyi@1
    26
  int changeColor (std::string mapname);
hegyi@4
    27
hegyi@4
    28
  ///Changes the text of line attribute according to the given map.
hegyi@4
    29
  ///\param mapname is the name of the map which contains the new values
ladanyi@1
    30
  int changeText (std::string mapname);
hegyi@4
    31
hegyi@4
    32
  ///Changes the dot-pro-pixel to be able to show the whole graph.
ladanyi@1
    33
  int rezoom();
ladanyi@1
    34
ladanyi@1
    35
protected:
ladanyi@1
    36
hegyi@4
    37
  //maximizing, minimizing, restoring window, etc. 
ladanyi@1
    38
  virtual bool on_expose_event(GdkEventExpose *);
ladanyi@1
    39
ladanyi@1
    40
private:
ladanyi@1
    41
hegyi@4
    42
  ///This function is responsible for the correct
hegyi@4
    43
  ///reaction of any action happened in the territory
hegyi@4
    44
  ///of the canvas
ladanyi@1
    45
  bool event_handler(GdkEvent* e, Node n);
ladanyi@1
    46
ladanyi@1
    47
  ///The graph, on which we work
ladanyi@1
    48
  Graph g;
hegyi@4
    49
hegyi@4
    50
  ///Map of nodes of graph
ladanyi@1
    51
  Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
hegyi@4
    52
hegyi@4
    53
  ///Map of edges of graph
ladanyi@1
    54
  Graph::EdgeMap<Gnome::Canvas::Line *> edgesmap;
ladanyi@1
    55
ladanyi@1
    56
  ///Map of texts to write on edges
ladanyi@1
    57
  Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
ladanyi@1
    58
ladanyi@1
    59
  ///Group of graphical elements of displayed_graph
ladanyi@1
    60
  Gnome::Canvas::Group displayed_graph;
ladanyi@1
    61
ladanyi@1
    62
  ///Here we store the maps that can be displayed through properties.
ladanyi@1
    63
  MapStorage mapstorage;
ladanyi@1
    64
ladanyi@1
    65
  ///Indicates whether the button of mouse is pressed or not
ladanyi@1
    66
  bool isbutton;
ladanyi@1
    67
ladanyi@1
    68
  ///At this location was the mousebutton pressed.
ladanyi@1
    69
  ///It helps to calculate the distance of dragging.
ladanyi@1
    70
  double clicked_x, clicked_y;
ladanyi@1
    71
ladanyi@1
    72
  ///Remembers which Gnome::Canvas::Item was pressed.
ladanyi@1
    73
  ///this variable is needed, because
ladanyi@1
    74
  ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
ladanyi@1
    75
  ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
ladanyi@1
    76
  Gnome::Canvas::Item * active_item;
ladanyi@1
    77
ladanyi@1
    78
ladanyi@1
    79
};
ladanyi@1
    80
ladanyi@1
    81
#endif //GRAPH_DISPLAYER_CANVAS_H