constraint.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00004 
00005  This file is part of the QGLViewer library version 2.4.0.
00006 
00007  http://www.libqglviewer.com - contact@libqglviewer.com
00008 
00009  This file may be used under the terms of the GNU General Public License 
00010  versions 2.0 or 3.0 as published by the Free Software Foundation and
00011  appearing in the LICENSE file included in the packaging of this file.
00012  In addition, as a special exception, Gilles Debunne gives you certain 
00013  additional rights, described in the file GPL_EXCEPTION in this package.
00014 
00015  libQGLViewer uses dual licensing. Commercial/proprietary software must
00016  purchase a libQGLViewer Commercial License.
00017 
00018  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00019  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020 
00021 *****************************************************************************/
00022 
00023 #ifndef QGLVIEWER_CONSTRAINT_H
00024 #define QGLVIEWER_CONSTRAINT_H
00025 
00026 #include "vec.h"
00027 #include "quaternion.h"
00028 
00029 namespace qglviewer {
00030   class Frame;
00031   class Camera;
00032 
00117   class QGLVIEWER_EXPORT Constraint
00118   {
00119   public:
00121     virtual ~Constraint() {};
00122 
00133     virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); };
00142     virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); };
00143   };
00144 
00168   class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint
00169   {
00170   public:
00171     AxisPlaneConstraint();
00173     virtual ~AxisPlaneConstraint() {};
00174 
00207     enum Type { FREE, AXIS, PLANE, FORBIDDEN };
00208 
00212     virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); };
00213 
00214     void setTranslationConstraint(Type type, const Vec& direction);
00216     void setTranslationConstraintType(Type type) { translationConstraintType_ = type; };
00217     void setTranslationConstraintDirection(const Vec& direction);
00218 
00228     Type translationConstraintType() const { return translationConstraintType_; };
00238     Vec translationConstraintDirection() const { return translationConstraintDir_; };
00240 
00244     virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); };
00245 
00246     void setRotationConstraint(Type type, const Vec& direction);
00247     void setRotationConstraintType(Type type);
00248     void setRotationConstraintDirection(const Vec& direction);
00249 
00251     Type rotationConstraintType() const { return rotationConstraintType_; };
00259     Vec rotationConstraintDirection() const { return rotationConstraintDir_; };
00261 
00262   private:
00263     // int and not Type to allow for overloading and new types definition.
00264     Type translationConstraintType_;
00265     Type rotationConstraintType_;
00266 
00267     Vec translationConstraintDir_;
00268     Vec rotationConstraintDir_;
00269   };
00270 
00271 
00279   class QGLVIEWER_EXPORT LocalConstraint : public AxisPlaneConstraint
00280   {
00281   public:
00283     virtual ~LocalConstraint() {};
00284 
00285     virtual void constrainTranslation(Vec&     translation, Frame* const frame);
00286     virtual void constrainRotation   (Quaternion& rotation, Frame* const frame);
00287   };
00288 
00289 
00290 
00299   class QGLVIEWER_EXPORT WorldConstraint : public AxisPlaneConstraint
00300   {
00301   public:
00303     virtual ~WorldConstraint() {};
00304 
00305     virtual void constrainTranslation(Vec&     translation, Frame* const frame);
00306     virtual void constrainRotation   (Quaternion& rotation, Frame* const frame);
00307   };
00308 
00309 
00310 
00319   class QGLVIEWER_EXPORT CameraConstraint : public AxisPlaneConstraint
00320   {
00321   public:
00322     explicit CameraConstraint(const Camera* const camera);
00324     virtual ~CameraConstraint() {};
00325 
00326     virtual void constrainTranslation(Vec&     translation, Frame* const frame);
00327     virtual void constrainRotation   (Quaternion& rotation, Frame* const frame);
00328 
00330     const Camera* camera() const { return camera_; };
00331 
00332   private:
00333     const Camera* const camera_;
00334   };
00335 
00336 } // namespace qglviewer
00337 
00338 #endif // QGLVIEWER_CONSTRAINT_H


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26