constraint.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  Copyright (C) 2002-2014 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.6.3.
6 
7  http://www.libqglviewer.com - contact@libqglviewer.com
8 
9  This file may be used under the terms of the GNU General Public License
10  versions 2.0 or 3.0 as published by the Free Software Foundation and
11  appearing in the LICENSE file included in the packaging of this file.
12  In addition, as a special exception, Gilles Debunne gives you certain
13  additional rights, described in the file GPL_EXCEPTION in this package.
14 
15  libQGLViewer uses dual licensing. Commercial/proprietary software must
16  purchase a libQGLViewer Commercial License.
17 
18  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21 *****************************************************************************/
22 
23 #ifndef QGLVIEWER_CONSTRAINT_H
24 #define QGLVIEWER_CONSTRAINT_H
25 
26 #include "vec.h"
27 #include "quaternion.h"
28 
29 namespace qglviewer {
30 class Frame;
31 class Camera;
32 
117 class QGLVIEWER_EXPORT Constraint
118 {
119 public:
121  virtual ~Constraint() {}
122 
133  virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); }
142  virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); }
143 };
144 
168 class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint
169 {
170 public:
171  AxisPlaneConstraint();
173  virtual ~AxisPlaneConstraint() {}
174 
207  enum Type { FREE, AXIS, PLANE, FORBIDDEN };
208 
212  virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); }
213 
214  void setTranslationConstraint(Type type, const Vec& direction);
216  void setTranslationConstraintType(Type type) { translationConstraintType_ = type; }
217  void setTranslationConstraintDirection(const Vec& direction);
218 
228  Type translationConstraintType() const { return translationConstraintType_; }
238  Vec translationConstraintDirection() const { return translationConstraintDir_; }
240 
244  virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); }
245 
246  void setRotationConstraint(Type type, const Vec& direction);
247  void setRotationConstraintType(Type type);
248  void setRotationConstraintDirection(const Vec& direction);
249 
251  Type rotationConstraintType() const { return rotationConstraintType_; }
259  Vec rotationConstraintDirection() const { return rotationConstraintDir_; }
261 
262 private:
263  // int and not Type to allow for overloading and new types definition.
264  Type translationConstraintType_;
265  Type rotationConstraintType_;
266 
267  Vec translationConstraintDir_;
268  Vec rotationConstraintDir_;
269 };
270 
271 
280 {
281 public:
283  virtual ~LocalConstraint() {}
284 
285  virtual void constrainTranslation(Vec& translation, Frame* const frame);
286  virtual void constrainRotation (Quaternion& rotation, Frame* const frame);
287 };
288 
289 
290 
300 {
301 public:
303  virtual ~WorldConstraint() {}
304 
305  virtual void constrainTranslation(Vec& translation, Frame* const frame);
306  virtual void constrainRotation (Quaternion& rotation, Frame* const frame);
307 };
308 
309 
310 
320 {
321 public:
322  explicit CameraConstraint(const Camera* const camera);
324  virtual ~CameraConstraint() {}
325 
326  virtual void constrainTranslation(Vec& translation, Frame* const frame);
327  virtual void constrainRotation (Quaternion& rotation, Frame* const frame);
328 
330  const Camera* camera() const { return camera_; }
331 
332 private:
333  const Camera* const camera_;
334 };
335 
336 } // namespace qglviewer
337 
338 #endif // QGLVIEWER_CONSTRAINT_H
qglviewer::LocalConstraint
An AxisPlaneConstraint defined in the Frame local coordinate system.
Definition: constraint.h:299
qglviewer::Quaternion
The Quaternion class represents 3D rotations and orientations.
Definition: quaternion.h:86
quaternion.h
qglviewer::Vec
The Vec class represents 3D positions and 3D vectors.
Definition: vec.h:85
qglviewer
Definition: camera.h:29
qglviewer::AxisPlaneConstraint
An abstract class for Frame Constraints defined by an axis or a plane.
Definition: constraint.h:188
qglviewer::Frame
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition: frame.h:141
QGLVIEWER_EXPORT
#define QGLVIEWER_EXPORT
qglviewer::AxisPlaneConstraint::Type
Type
Definition: constraint.h:227
qglviewer::CameraConstraint
An AxisPlaneConstraint defined in the camera coordinate system.
Definition: constraint.h:339
vec.h
qglviewer::Camera
A perspective or orthographic camera.
Definition: camera.h:84
FREE
#define FREE(p)
Definition: gpc.cpp:155
qglviewer::WorldConstraint
An AxisPlaneConstraint defined in the world coordinate system.
Definition: constraint.h:319


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Apr 3 2025 02:40:44