Tulip  5.6.0
Large graphs analysis and drawing
GlRect.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef GL_RECT_H
21 #define GL_RECT_H
22 
23 #include <tulip/GlPolygon.h>
24 #include <tulip/Size.h>
25 
26 namespace tlp {
27 
28 /**
29  * @ingroup OpenGL
30  * \brief This is a general class for the rendering of 2D rectangles.
31  *
32  * This class is used as a 2D HUD for the rendering of 2D rectangles.
33  */
34 
35 class TLP_GL_SCOPE GlRect : public GlPolygon {
36 protected:
37 public:
38  /**
39  * Constructor : with topLeft/bottomRight coords, topLeft/bottomRight colors and if GlRect is
40  * filled/outlined
41  */
42  GlRect(const Coord &topLeftPos, const Coord &bottomRightPos, const Color &topLeftCol,
43  const Color &bottomRightCol, bool filled = true, bool outlined = false);
44 
45  /**
46  * Constructor : with center coords and size, fill color and outline color
47  */
48  GlRect(const Coord &center, const float width, const float height, const Color &fillColor,
49  const Color &outlineColor);
50 
51  /**
52  * Constructor : with GlRect is filled/outlined
53  */
54  GlRect(bool filled = true, bool outlined = false);
55 
56  /**
57  * Destructor
58  */
59  ~GlRect() override;
60 
61  /**
62  * Accessor in reading to the Top Left Corner of the rectangle
63  */
64  virtual Coord getCenter();
65 
66  /**
67  * Set the center and the size of the GlRect
68  */
69  void setCenterAndSize(const Coord &center, const Size &size);
70 
71  /**
72  * Accessor in reading to the Top Left Corner of the rectangle
73  */
74  virtual Coord getTopLeftPos();
75 
76  /**
77  * Accessor in reading to the Bottom Right Corner of the rectangle
78  */
79  virtual Coord getBottomRightPos();
80 
81  /**
82  * Accessor in reading to the Top Left Corner Color of the rectangle
83  */
84  virtual Color getTopLeftColor();
85 
86  /**
87  * Accessor in reading to the Bottom Right Corner Color of the Rectangle
88  */
89  virtual Color getBottomRightColor();
90 
91  /**
92  * Accessor in writing to the Top Left Corner of the rectangle
93  */
94  virtual void setTopLeftPos(const Coord &topLeftPos);
95 
96  /**
97  * Accessor in writing to the Bottom Right Corner Color of the rectangle
98  */
99  virtual void setBottomRightPos(const Coord &bottomRightPos);
100 
101  /**
102  * Accessor in writing to the Top Left Corner of the rectangle
103  */
104  virtual void setTopLeftColor(const Color &topLeftCol);
105 
106  /**
107  * Accessor in writing to the Bottom Right Corner Color of the rectangle
108  */
109  virtual void setBottomRightColor(const Color &bottomRightCol);
110 
111  /**
112  * Is the point in the rectangle ?
113  */
114  bool inRect(double x, double y);
115 
116  void draw(float lod, Camera *camera) override;
117 };
118 } // namespace tlp
119 #endif
tlp::GlPolygon
Class to create a polygon GlEntity.
Definition: GlPolygon.h:36
tlp::GlRect
This is a general class for the rendering of 2D rectangles.
Definition: GlRect.h:35
tlp
Definition: AbstractProperty.h:34
tlp::Camera
Tulip OpenGL camera object.
Definition: Camera.h:47