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