Debian Codegraph @

vcg/wrap/gui/coordinateframe.h

raw symbols SCIP
1 /****************************************************************************
2 * MeshLab o o *
3 * A versatile mesh processing toolbox o o *
4 * _ O _ *
5 * Copyright(C) 2008 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 /****************************************************************************
24 History
25 $Log: coordinateframe.h,v $
26 Revision 1.8 2008/04/10 11:09:34 cignoni
27 made generic functions static
28
29 Revision 1.7 2008/03/14 16:54:34 benedetti
30 Added doxygen documentation
31
32 Revision 1.6 2008/03/02 16:44:18 benedetti
33 moved ActiveCoordinateFrame to its own files
34
35 Revision 1.5 2008/02/22 20:04:02 benedetti
36 many user interface improvements, cleaned up a little
37
38 Revision 1.4 2008/02/17 20:52:53 benedetti
39 some generalization made
40
41 Revision 1.3 2008/02/16 14:12:30 benedetti
42 first version
43
44
45 ****************************************************************************/
46 #ifndef COORDINATEFRAME_H
47 #define COORDINATEFRAME_H
48
49
50 #include <vcg/math/similarity.h>
51 #include <vcg/space/color4.h>
52
53 #include <QGLWidget>
54
55 namespace vcg {
56
57 /*!
58 @brief The CoordinateFrame class.
59
60 This class can draw the standard icon for a 3D coordinate frame.
61 */
62 class CoordinateFrame
63 {
64 public:
65 // functions:
66 /*!
67 @brief The constructor.
68
69 Initialize the CoordinateFrame data.
70 @param size the distance from the origin to the endpoint of the arrows.
71 */
72 CoordinateFrame(float size);
73
74 /*!
75 @brief The destructor.
76
77 The destructor.
78 */
79 virtual ~CoordinateFrame() {}
80
81 /*!
82 @brief Render the coordinate frame.
83
84 @param glw the GL widget.
85 */
86 virtual void Render(QGLWidget* glw);
87 // data
88
89 /// The color used for the ticks, the ticks values and the head of the arrows.
90 Color4b basecolor;
91
92 /// The color of the X axis and label.
93 Color4b xcolor;
94
95 /// The color of the Y axis and label.
96 Color4b ycolor;
97
98 /// The color of the Z axis and label.
99 Color4b zcolor;
100
101 /// The distance from the origin to the endpoint of the arrows.
102 float size;
103
104 /// The width of the lines.
105 float linewidth;
106
107 /// The font used for the labels and the ticks values.
108 QFont font;
109
110 /// The flag that enables axes rendering.
111 bool drawaxis;
112
113 /// The flag that enables lablels rendering.
114 bool drawlabels;
115
116 /// The flag that enables ticks values rendering.
117 bool drawvalues;
118
119 // useful functions:
120 static void drawTickedLine(const Point3d &, const Point3d &, float, float,float);
121 static float calcSlope(const Point3d &, const Point3d &, float, int , double *, double *, GLint *);
122 static float niceRound(float);
123 };
124
125 /*!
126 @brief The MovableCoordinateFrame class.
127
128 This class extends the coordinate frame with the ability of being programmatically rototranslated.
129 */
130 class MovableCoordinateFrame: public CoordinateFrame
131 {
132
133 public:
134 /*!
135 @brief The constructor.
136
137 Initialize the MovableCoordinateFrame data.
138 @param size the distance from the origin to the endpoint of the arrows.
139 */
140 MovableCoordinateFrame(float);
141
142 /*!
143 @brief The destructor.
144
145 The destructor.
146 */
147 virtual ~MovableCoordinateFrame(){}
148
149 /*!
150 @brief Render the movable coordinate frame in its position.
151
152 @param glw the GL widget.
153 */
154 virtual void Render(QGLWidget* glw);
155
156 /*!
157 @brief Reset the position and/or the rotation of the coordinate frame.
158
159 @param reset_position set to true to reset the position.
160 @param reset_alignment set to true to reset the rotation.
161 */
162 virtual void Reset(bool reset_position,bool reset_alignment);
163
164 /*!
165 @brief Set the position of the coordinate frame.
166
167 @param new_position the new position of the coordinate frame.
168 */
169 virtual void SetPosition(const Point3f new_position);
170
171 /*!
172 @brief Set the rotation of the coordinate frame.
173
174 @param new_rotation the new rotation of the coordinate frame.
175 */
176 virtual void SetRotation(const Quaternionf rotation);
177
178 /*!
179 @brief Get the position of the coordinate frame.
180
181 @return the position of the coordinate frame.
182 */
183 virtual Point3f GetPosition();
184
185 /*!
186 @brief Get the rotation of the coordinate frame.
187
188 @return the rotation of the coordinate frame.
189 */
190 virtual Quaternionf GetRotation();
191
192 /*!
193 @brief Computes the transformation matrix relative to the current rototranslation.
194
195 @param m is set to the transformation matrix.
196 */
197 virtual void GetTransform(Matrix44f &m);
198
199 /*!
200 @brief Rotates the coordinate frame wrt itself.
201
202 @param angle the angle of the rotation, in degrees.
203 @param axis the axis of the rotation.
204 */
205 virtual void Rot(float angle,const Point3f axis);
206
207 /*!
208 @brief Align the coordinate frame to one or two directions.
209
210 If the primary direction of alignment is null this function does nothing, otherwise two rotations are performed: the first rotation aligns the axis named axis_1 to the primary direction of alignment, the second rotation never moves axis_1 away from the primary direction.
211
212 If the secondary direction of alignment is not null and is not parallel to the primary direction the axis named axis_2 is rotated as much as possible to be aligned to secondary direction.
213
214 If the secondary direction of alignment is null the axis named axis_2 is rotated as much as possible to be realigned to its old direction, if this is impossible the remaining axis is used.
215
216 @param primary the primary direction of alignment.
217 @param secondary the secondary direction of alignment.
218 @param axis_1 the name of the axis to align to the primary direction, must be a char choosen from 'X', 'Y' and 'Z'
219 @param axis_2 the name of the axis to align to the secondary direction, must be different from axis_1 and must be a char choosen from 'X', 'Y', 'Z' and ' '; if the char is ' ' the axis is choosen automatically.
220 */
221 virtual void AlignWith(const Point3f primary, const Point3f secondary, const char axis_1, const char axis_2);
222
223 protected:
224 // data:
225 Point3f position;
226 Quaternionf rotation;
227
228 // functions:
229 virtual void Move(const Similarityf);
230 void RotateToAlign(const Point3f, const Point3f);
231
232 };
233
234 }//namespace
235 #endif /*COORDINATEFRAME_H*/