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