Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ManipulatorNode.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  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // CLASS ManipulatorNode
56 //
57 //=============================================================================
58 
59 
60 #ifndef ACG_MANIPULATOR_NODE_HH
61 #define ACG_MANIPULATOR_NODE_HH
62 
63 
64 //== INCLUDES =================================================================
65 
66 // GMU
67 #include "BaseNode.hh"
68 #include "TransformNode.hh"
69 
70 // Qt
71 #include <QEvent>
72 #include <QMouseEvent>
73 
74 #include <ACG/GL/GLPrimitives.hh>
75 
76 
77 //== NAMESPACES ===============================================================
78 
79 namespace ACG {
80 namespace SceneGraph {
81 
82 
83 //== CLASS DEFINITION =========================================================
84 
85 
91 class ACGDLLEXPORT ManipulatorNode : public TransformNode
92 {
93 public:
94 
95 
97  ManipulatorNode( BaseNode* _parent=0,
98  const std::string& _name="<ManipulatorNode>" );
99 
101  ~ManipulatorNode();
102 
103 
105  ACG_CLASSNAME(ManipulatorNode);
106 
107 
108  //
109  // METHODS
110  //
111 
112 
113 
114  virtual void setIdentity();
115 
117  void set_draw_cylinder(bool _b) { draw_cylinder_ = _b; }
118 
120  bool draw_cylinder() const { return draw_cylinder_; }
121 
124  void set_direction(Vec3d& _v);
125 
128  Vec3d direction() const;
129 
131  void set_size( double _size) { cylinder_height_ = _size;
132  cylinder_radius_ = _size/10.0;}
133 
135  double size() const { return cylinder_height_; }
136 
138  void translate(double _s) {
139  Vec3d rel_dir = rotation().transform_vector(direction_);
140  TransformNode::translate(_s * rel_dir);
141  }
142 
144  void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
145 
147  void pick(GLState& _state, PickTarget _target);
148 
150  virtual void mouseEvent(GLState& _state, QMouseEvent* _event);
151 
155  bool touched() { return touched_; };
156 
158  void reset_touched() { touched_ = false; };
159 
160 
161 private:
162 
163  void setup_sphere_system(GLState& _state);
164  void setup_cylinder_system(GLState& _state);
165 
166  bool mapToSphere(GLState& _state, const Vec2i& _v2, Vec3d& _v3);
167  bool hitSphere(GLState& _state, const Vec2i& _v2);
168  bool mapToCylinder (GLState& _state, const Vec2i& _v2, double& axis_hit);
169 
170 
171 
172 
173 
174  // ELEMENTS
175  bool draw_cylinder_;
176 
177  Vec3d direction_;
178  GLCylinder* cylinder_;
179  double cylinder_radius_;
180  double cylinder_height_;
181  int cylinder_slices_;
182  int cylinder_stacks_;
183 
184 
185  bool cylinder_clicked_;
186  bool sphere_clicked_;
187 
188  Vec2i oldPoint2D_;
189 
191  bool touched_;
192 };
193 
194 
195 //=============================================================================
196 } // namespace SceneGraph
197 } // namespace ACG
198 //=============================================================================
199 #endif // ACG_MANIPUKATOR_NODE_HH defined
200 //=============================================================================
201 
double size() const
get cylindersize
void translate(double _s)
translate in cylinder direction
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
bool touched_
if the manipulator is cklicked with a mouse, this flag will be set to true
bool draw_cylinder() const
get drawCylinder
void reset_touched()
Reset the touched flag ( see touched for details )
void translate(const Vec3d &_v)
Add a translation to the current Transformation.
void set_draw_cylinder(bool _b)
set draw_cylinder_
void set_size(double _size)
set cylindersize (height + radius)