COIN-OR::LEMON - Graph Library

Changeset 147:10ef59f6633c in glemon-0.x for graph_displayer_canvas.h


Ignore:
Timestamp:
09/13/06 11:16:29 (18 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@2943
Message:

Loop edges.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas.h

    r127 r147  
    1616{
    1717  friend class BrokenEdge;
     18  friend class LoopEdge;
     19
     20  class EdgeBase : public Gnome::Canvas::Group
     21  {
     22    protected:
     23      ///Reference to the canvas, on which the graph is drawn.
     24
     25      ///It is needed, because some datas needed from
     26      ///graph can be accessed by this or should be sent
     27      ///as parameter, but it would be complicated
     28      GraphDisplayerCanvas& canvas;
     29
     30      ///The edge that the class displays.
     31
     32      ///It is needed, because some datas needed from
     33      ///graph can be accessed by this or should be sent
     34      ///as parameter, but it would be complicated
     35      Edge edge;
     36
     37      Gnome::Canvas::Polygon arrow;
     38
     39      void drawArrow(XY);
     40    public:
     41      EdgeBase(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
     42      virtual ~EdgeBase();
     43      virtual void draw() = 0;
     44      virtual void setLineWidth(int) = 0;
     45      virtual void setFillColor(Gdk::Color) = 0;
     46  };
    1847
    1948  ///Edge displayer class
     
    2453  ///and to be able to display more then one edges between the
    2554  ///same source and target
    26   class BrokenEdge : public Gnome::Canvas::Line
     55  class BrokenEdge : public EdgeBase
    2756  {
    28     ///The edge that the class displays.
    29 
    30     ///It is needed, because some datas needed from
    31     ///graph can be accessed by this or should be sent
    32     ///as parameter, but it would be complicated
    33     Edge edge;
    34 
    35     ///Reference to the canvas, on which the graph is drawn.
    36 
    37     ///It is needed, because some datas needed from
    38     ///graph can be accessed by this or should be sent
    39     ///as parameter, but it would be complicated
    40     GraphDisplayerCanvas & gdc;
    41 
    42     ///An arrow that indicates the direction of the edges
    43 
    44     ///in case of directional graph direction can be indicated
    45     ///by this polygon. The polygon formulates a red arrow.
    46     Gnome::Canvas::Polygon * arrow;
    47 
    48     ///Indicates whether the button of mouse is pressed or not at the moment.
    49     bool isbutton;
    50 
    51     ///At this location was the mousebutton pressed. Horizontal component.
    52 
    53     ///It helps to calculate the
    54     ///distance of dragging.
    55     double clicked_x;
    56 
    57     ///At this location was the mousebutton pressed. Vertical component.
    58 
    59     ///It helps to calculate the
    60     ///distance of dragging.
    61     double clicked_y;
    62 
    63     ///event handler for forming broken edges
    64 
    65     ///\param event the
    66     ///event to handle
    67     bool edgeFormerEventHandler(GdkEvent* event);
    68   public:
    69 
    70     ///Constructor of broken edge class.
    71 
    72     ///\param g the group to which the edge belongs
    73     ///\param _edge the represented edge
    74     ///\param gc the canvas
    75     BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc);
    76 
    77     ///Destructor of broken edge class
    78 
    79     ///Frees up
    80     ///reserved memory
    81     ~BrokenEdge();
    82 
    83     ///The function that draws the edge based on collected data
    84     void draw();
     57    private:
     58      Gnome::Canvas::Line line;
     59
     60      ///Indicates whether the button of mouse is pressed or not at the moment.
     61      bool isbutton;
     62
     63      ///At this location was the mousebutton pressed. Horizontal component.
     64
     65      ///It helps to calculate the
     66      ///distance of dragging.
     67      double clicked_x;
     68
     69      ///At this location was the mousebutton pressed. Vertical component.
     70
     71      ///It helps to calculate the
     72      ///distance of dragging.
     73      double clicked_y;
     74
     75      ///event handler for forming broken edges
     76
     77      ///\param event the
     78      ///event to handle
     79      bool edgeFormerEventHandler(GdkEvent* event);
     80
     81    public:
     82      ///Constructor of broken edge class.
     83
     84      ///\param g the group to which the edge belongs
     85      ///\param _edge the represented edge
     86      ///\param gc the canvas
     87      BrokenEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
     88
     89      ///Destructor of broken edge class
     90
     91      ///Frees up
     92      ///reserved memory
     93      ~BrokenEdge();
     94
     95      ///The function that draws the edge based on collected data
     96      void draw();
     97
     98      void setLineWidth(int);
     99      void setFillColor(Gdk::Color);
     100  };
     101
     102  class LoopEdge : public EdgeBase
     103  {
     104    private:
     105      Gnome::Canvas::Ellipse line;
     106    public:
     107      LoopEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
     108      ~LoopEdge();
     109      void draw();
     110      void setLineWidth(int);
     111      void setFillColor(Gdk::Color);
    85112  };
    86113
     
    242269  void textReposition(xy<double>);
    243270
    244   ///Activates an edge belonging to a BrokenEdge
     271  ///Activates an edge belonging to an EdgeBase
    245272
    246273  ///After we have activated an edge this way,
    247274  ///the GDC object will know, which edge is under forming
    248275  ///therefore it can redraw the necessary elements on the canvas,
    249   ///for example the text belonging to the \ref BrokenEdge can be
     276  ///for example the text belonging to the \ref EdgeBase can be
    250277  ///redrawn (\ref textReposition).
    251   void toggleEdgeActivity(BrokenEdge*, bool);
     278  void toggleEdgeActivity(EdgeBase*, bool);
    252279
    253280public:
     
    290317
    291318  ///Map of edges of graph
    292   Graph::EdgeMap<BrokenEdge *> edgesmap;
     319  Graph::EdgeMap<EdgeBase*> edgesmap;
    293320
    294321  ///Map of texts to write on edges
Note: See TracChangeset for help on using the changeset viewer.