Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

frame.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the QGLViewer library
00004  Copyright (C) 2002-2004  Gilles Debunne (Gilles.Debunne@imag.fr)
00005  Version 1.3.5 Release 8. Packaged on Monday December 22, 2003.
00006 
00007  http://www-imagis.imag.fr/Membres/Gilles.Debunne/CODE/QGLViewer
00008 
00009  libQGLViewer is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  libQGLViewer is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with libQGLViewer; if not, write to the Free Software
00021  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023 *****************************************************************************/
00024 
00025 #ifndef QGLVIEWER_FRAME_H
00026 #define QGLVIEWER_FRAME_H
00027 
00028 #include <qobject.h>
00029 #include <qstring.h>
00030 
00031 #include "vec.h"
00032 #include "quaternion.h"
00033 #include "constraint.h"
00034 // #include "GL/gl.h" is now included in config.h for ease of configuration
00035 
00036 
00037 namespace qglviewer {
00128   class QGLVIEWER_EXPORT Frame : public QObject
00129   {
00130     Q_OBJECT
00131 
00132   public:
00133     Frame();
00134     
00136     virtual ~Frame() {};
00137 
00138     Frame& operator=(const Frame& f);
00139 
00140     Frame(const Frame& f);
00141 
00142   signals:
00162     void modified();
00163 
00164   public:
00174     explicit Frame(const Vec& pos, const Quaternion& orien);
00175 
00176     void setPosition(const Vec& t);
00177     void setPosition(const float x, const float y, const float z);
00178     void setPositionWithConstraint(Vec& t);
00179     
00180     void setOrientation(const float x, const float y, const float z, const float a);
00181     void setOrientation(const Quaternion& q);
00182     void setOrientationWithConstraint(Quaternion& q);
00183     void setOrientationAxisAngle(const float x, const float y, const float z, const float a);
00184 
00185     void setPositionAndOrientation(const Vec& t, const Quaternion& q);
00186     void setPositionAndOrientationWithConstraint(Vec& t, Quaternion& q);
00187     
00189     Vec position() const { return inverseCoordinatesOf(Vec(0.0,0.0,0.0)); };
00190     void getPosition(float& x, float& y, float& z) const;
00191 
00192     Quaternion orientation() const;
00193     void getOrientation(float& q0, float& q1, float& q2, float& q3) const;
00195 
00196     
00197   public:
00222     Frame* referenceFrame() const { return referenceFrame_; };
00223     void setReferenceFrame(Frame* const fr);
00224 
00225     bool settingAsReferenceFrameWillCreateALoop(Frame* const fr);
00227 
00236     void setTranslation(const float x, const float y, const float z);
00240     void setTranslation(const Vec& t) { t_ = t; emit modified(); };
00241     void setTranslationWithConstraint(Vec& t);
00242 
00243     void setRotation(const float x, const float y, const float z, const float a);
00247     void setRotation(const Quaternion& q) { q_ = q; emit modified(); };
00248     void setRotationWithConstraint(Quaternion& q);
00249     void setRotationAxisAngle(const float x, const float y, const float z, const float a);
00250 
00251     void setTranslationAndRotation(const Vec& t, const Quaternion& q);
00252     void setTranslationAndRotationWithConstraint(Vec& t, Quaternion& q);
00253 
00254     void getTranslation(float& x, float& y, float& z) const;
00256     Vec translation() const { return t_; };
00257 
00258     void getRotation(float& x, float& y, float& z, float& a) const;
00260     Quaternion rotation() const { return q_; };
00262 
00266     void translate(Vec& t);
00267     void translate(const Vec& t);
00268     void translate(float t[3]);
00269     void translate(float& x, float& y, float& z);
00270     void translate(const float x, const float y, const float z);
00271     
00272     void rotate(Quaternion& q);
00273     void rotate(const Quaternion& q);
00274     void rotate(float q[4]);
00275     void rotate(float& x, float& y, float& z, float& a);
00276     void rotate(const float x, const float y, const float z, const float a);
00277 
00278     void rotateAroundPoint(Quaternion& q, const Vec& p);
00279     void rotateAroundPoint(const Quaternion& q, const Vec& p);
00281 
00282 
00307     Vec coordinatesOf(const Vec& src) const;
00308     Vec inverseCoordinatesOf(const Vec& src) const;
00309     Vec localCoordinatesOf(const Vec& src) const;
00310     Vec localInverseCoordinatesOf(const Vec& src) const;
00311     Vec coordinatesOfIn(const Vec& src, const Frame* in) const;
00312     Vec coordinatesOfFrom(const Vec& src, const Frame* from) const;
00313     
00314     void getCoordinatesOf(const float src[3], float res[3]) const;
00315     void getInverseCoordinatesOf(const float src[3], float res[3]) const;
00316     void getLocalCoordinatesOf(const float src[3], float res[3]) const;
00317     void getLocalInverseCoordinatesOf(const float src[3], float res[3]) const;
00318     void getCoordinatesOfIn(const float src[3], float res[3], const Frame* in) const;
00319     void getCoordinatesOfFrom(const float src[3], float res[3], const Frame* from) const;
00321 
00346     Vec transformOf(const Vec& src) const;
00347     Vec inverseTransformOf(const Vec& src) const;
00348     Vec localTransformOf(const Vec& src) const;
00349     Vec localInverseTransformOf(const Vec& src) const;
00350     Vec transformOfIn(const Vec& src, const Frame* in) const;
00351     Vec transformOfFrom(const Vec& src, const Frame* from) const;
00352     
00353     void getTransformOf(const float src[3], float res[3]) const;
00354     void getInverseTransformOf(const float src[3], float res[3]) const;
00355     void getLocalTransformOf(const float src[3], float res[3]) const;
00356     void getLocalInverseTransformOf(const float src[3], float res[3]) const;
00357     void getTransformOfIn(const float src[3], float res[3], const Frame* in) const;
00358     void getTransformOfFrom(const float src[3], float res[3], const Frame* from) const;
00360 
00369     Constraint* constraint() const { return constraint_; }
00373     void setConstraint(Constraint* c) { constraint_ = c; }
00375 
00378   public:
00379     const GLdouble* matrix() const;
00380     void getMatrix(GLdouble m[4][4]) const;
00381     void getMatrix(GLdouble m[16]) const;
00382     
00383     const GLdouble* worldMatrix() const;
00384     void getWorldMatrix(GLdouble m[4][4]) const;
00385     void getWorldMatrix(GLdouble m[16]) const;
00386 
00387     void setFromMatrix(const float m[4][4]);
00388     void alignWithFrame(const Frame* const fr, bool move=false, float threshold=0.85f);
00389     void projectOnLine(const Vec& origin, const Vec& dir);
00391 
00392   public:
00395     virtual QDomElement domElement(const QString& name, QDomDocument& doc) const;
00396     virtual void initFromDOMElement(const QDomElement& de);
00398 
00399   private:
00401     Vec t_;
00402     Quaternion q_;
00403 
00404     // C o n s t r a i n t s
00405     Constraint* constraint_;
00406     
00407     // F r a m e   c o m p o s i t i o n
00408     Frame* referenceFrame_;    
00409   };
00410   
00411 } // namespace qglviewer
00412 
00413 #endif // QGLVIEWER_FRAME_H

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2