Developer Documentation

TrackballNode.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44
45
46
47 //=============================================================================
48 //
49 // CLASS TrackballNode
50 //
51 //=============================================================================
52
53
54 #ifndef ACG_TRACKBALL_NODE_HH
55 #define ACG_TRACKBALL_NODE_HH
56
57
58 //== INCLUDES =================================================================
59
60 // GMU
61 #include "BaseNode.hh"
62 #include "TransformNode.hh"
63
64 // Qt
65 #include <QEvent>
66 #include <QMouseEvent>
67
68 #ifdef max
69 # undef max
70 #endif
71
72 #ifdef min
73 # undef min
74 #endif
75
76
77
78 //== NAMESPACES ===============================================================
79
80
81 namespace ACG {
82 namespace SceneGraph {
83
84
85 //== CLASS DEFINITION =========================================================
86
87
96 class ACGDLLEXPORT TrackballNode : public TransformNode
97 {
98 public:
99
100
102 TrackballNode( BaseNode* _parent=0,
103 const std::string& _name="<TrackballNode>" )
104 : TransformNode(_parent, _name),
105 drawTrackball_(false),
106 drawAxes_(false),
107 radius_(1.0),
108 xAxis_(1.0, 0.0, 0.0),
109 yAxis_(0.0, 1.0, 0.0),
110 zAxis_(0.0, 0.0, 1.0)
111 {}
112
113
115 ~TrackballNode() {}
116
117
119 ACG_CLASSNAME(TrackballNode);
120
121
122 //
123 // METHODS
124 //
125
126
128 void set_radius(double _r) { radius_ = _r; }
130 double radius() const { return radius_; }
131
132
134 virtual void setIdentity() {
135 Vec3d vec (1.0, 1.0, 1.0);
136
137 vec = scale ().transform_point(vec);
138 radius_ *= vec.max ();
139 TransformNode::setIdentity();
140 }
141
142
144 void set_draw_trackball(bool _b) { drawTrackball_ = _b; }
146 bool draw_trackball() const { return drawTrackball_; }
147
148
150 void set_draw_axes(bool _b) { drawAxes_ = _b; }
152 bool draw_axes() const { return drawAxes_; }
153
154
156 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
157
158
160 virtual void mouseEvent(GLState& _state, QMouseEvent* _event);
161
162
163 private:
164
166 bool mapToSphere(GLState& _state, const Vec2i& _v2, Vec3d& _v3);
167
168
169 // ELEMENTS
170 bool drawTrackball_,
171 drawAxes_;
172 double radius_;
173 Vec3d xAxis_, yAxis_, zAxis_;
174 Vec2i oldPoint2D_;
175 };
176
177
178 //=============================================================================
179 } // namespace SceneGraph
180 } // namespace ACG
181 //=============================================================================
182 #endif // ACG_TRACKBALL_NODE_HH defined
183 //=============================================================================
184
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::SceneGraph::TrackballNode::draw_trackball
bool draw_trackball() const
Is trackball-drawing on?
Definition: TrackballNode.hh:146
ACG::SceneGraph::TrackballNode
Definition: TrackballNode.hh:96
ACG::SceneGraph::TrackballNode::set_draw_axes
void set_draw_axes(bool _b)
Turn drawing the axes on/off.
Definition: TrackballNode.hh:150
ACG::SceneGraph::TrackballNode::setIdentity
virtual void setIdentity()
override TransformNode::setIdentity() (update radius_)
Definition: TrackballNode.hh:134
ACG::SceneGraph::TrackballNode::draw_axes
bool draw_axes() const
Is axes-drawing on?
Definition: TrackballNode.hh:152
ACG::SceneGraph::TrackballNode::set_draw_trackball
void set_draw_trackball(bool _b)
Turn on/off drawing of the trackball.
Definition: TrackballNode.hh:144
ACG::SceneGraph::TrackballNode::TrackballNode
TrackballNode(BaseNode *_parent=0, const std::string &_name="<TrackballNode>")
Default constructor.
Definition: TrackballNode.hh:102
ACG::GLState
Definition: GLState.hh:213
ACG::SceneGraph::TransformNode::setIdentity
virtual void setIdentity()
Definition: TransformNode.cc:112
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:288
ACG::SceneGraph::TrackballNode::~TrackballNode
~TrackballNode()
Destructor.
Definition: TrackballNode.hh:115
SceneGraph
Definition: QtPrincipalAxisDialog.hh:67
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::TrackballNode::set_radius
void set_radius(double _r)
Set trackball radius.
Definition: TrackballNode.hh:128
ACG::SceneGraph::TrackballNode::radius
double radius() const
Get trackball radius.
Definition: TrackballNode.hh:130
ACG::SceneGraph::TransformNode
Definition: TransformNode.hh:89
OpenMesh::VectorT::max
Scalar max() const
return the maximal component
Definition: Vector11T.hh:493