Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlPolyQuad.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 ///@cond DOXYGEN_HIDDEN
20 
21 
22 #ifndef GLPOLYQUAD_H_
23 #define GLPOLYQUAD_H_
24 
25 #include <tulip/tulipconf.h>
26 #include <tulip/Coord.h>
27 #include <tulip/Color.h>
28 #include <tulip/Size.h>
29 #include <tulip/GlSimpleEntity.h>
30 
31 #include <vector>
32 #include <string>
33 
34 namespace tlp {
35 
36 /**
37  * @ingroup OpenGL
38  * \brief General class used to render a connected group of quadrilaterals (textured or not) that shares edges as GlEntity
39  *
40  * This generic class is used to render a connected group of quadrilaterals (textured or not) that shares edges as GlEntity
41  */
42 class TLP_GL_SCOPE GlPolyQuad : public GlSimpleEntity {
43 
44 public :
45 
46  /**
47  * Default Constructor for initializing an empty polyquad
48  * Use the addQuadEdge method to set the quads edges
49  *
50  * \param textureName The absolute path of the texture image file to use
51  *
52  *
53  */
54  GlPolyQuad(const std::string &textureName = "", const bool outlined = false, const int outlineWidth = 1, const Color &outlineColor = Color(0,0,0));
55 
56  /**
57  * Constructor for building a polyquad with spefific colors for each edges
58  *
59  * Pay attention to the order of the edges point in the polyQuadEdges vector. Indeed, to draw the following polyquad
60  *
61  * v2
62  * v0+--------+--------+ v4
63  * | | |
64  * | | |
65  * | | |
66  * v1+--------+--------+ v5
67  * v3
68  *
69  * The content of the polyQuadEdges vector should be {v0, v1, v2, v3, v4, v5} or {v1, v0, v3, v2, v5, v4}
70  *
71  * \param polyQuadEdges A vector containing the coordinates of the quad edges, its size must be a multiple of 2 because an edge is defined by 2 points
72  * \param polyQuadEdgesColor A vector containing the edges's colors, its size must be equal to the number of edges defined by the polyQuadEdges vector
73  * \param textureName The absolute path of the texture image file to use
74  */
75  GlPolyQuad(const std::vector<Coord> &polyQuadEdges, const std::vector<Color> &polyQuadEdgesColor, const std::string &textureName = "",
76  const bool outlined = false, const int outlineWidth = 1, const Color &outlineColor = Color(0,0,0));
77 
78  /**
79  * Constructor for building a polyquad with a single color
80  *
81  * \param polyQuadEdges A vector containing the coordinates of the quad edges, its size must be a multiple of 2 because an edge is defined by 2 points
82  * \param polyQuadColor The polyquad color
83  * \param textureName The absolute path of the texture image file to use
84  */
85  GlPolyQuad(const std::vector<Coord> &polyQuadEdges, const Color &polyQuadColor, const std::string &textureName = "",
86  const bool outlined = false, const int outlineWidth = 1, const Color &outlineColor = Color(0,0,0));
87 
88  /**
89  * Method to add a polyquad edge
90  *
91  * \param edgeStart The first end of the edge
92  * \param edgeEnd The other end of the edge
93  * \param edgeColor The edge's color
94  *
95  */
96  void addQuadEdge(const Coord &edgeStart, const Coord &edgeEnd, const Color &edgeColor);
97 
98  /**
99  * Virtual function used to draw the polyquad.
100  */
101  void draw(float lod,Camera *camera);
102 
103  /**
104  * Method to set the polyquad color (all edges share the same color)
105  */
106  void setColor(const Color &color);
107 
108  /**
109  * Method to set the polyquad outline color
110  */
111  void setOutlineColor(const Color &color) {
112  outlineColor = color;
113  }
114 
115  /**
116  * Method to toggle polyquad outline
117  */
118  void setOutlined(const bool outline) {
119  outlined = outline;
120  }
121 
122  /**
123  * Method to set the polyquad outline width
124  */
125  void setOutlineWidth(const int width) {
126  outlineWidth = width;
127  }
128 
129  /**
130  * Method to translate entity
131  */
132  void translate(const Coord &move);
133 
134  /**
135  * Function to export data in outString (in XML format)
136  */
137  void getXML(std::string &outString);
138 
139  /**
140  * Function to set data with inString (in XML format)
141  */
142  void setWithXML(const std::string &inString,unsigned int &currentPosition);
143 
144 private :
145  std::vector<Coord> polyQuadEdges; // vector which contains polyquad edges, an edge being defined by a pair of Coord
146  std::vector<Color> polyQuadEdgesColors; // vector which contains polyquad edges colors
147  std::string textureName;
148  bool outlined;
149  int outlineWidth;
150  Color outlineColor;
151 };
152 
153 
154 }
155 #endif /* GLPOLYQUAD_H_ */
156 ///@endcond