Back to index

kdeartwork  4.3.2
rotation.h
Go to the documentation of this file.
00001 
00024 #ifndef ROTATION2_H
00025 #define ROTATION2_H
00026 
00027 // Qt headers
00028 #include <qwidget.h>
00029 #include <qtimer.h>
00030 #include <qgl.h>
00031 
00032 // GL headers
00033 #include <GL/glu.h>
00034 #include <GL/gl.h>
00035 
00036 // KDE headers
00037 #include <kscreensaver.h>
00038 
00039 // Eigen2 from KDE support
00040 #include <Eigen/Core>
00041 // import most common Eigen types
00042 USING_PART_OF_NAMESPACE_EIGEN
00043 
00044 // own extension of typdefed vector types of Eigen2
00045 typedef Matrix<double,12,1> Vector12d;
00046 
00047 #include "rkodesolver.h"
00048 
00049 // KRotationSetupUi
00050 #include "ui_rotationcfg.h"
00051 
00052 //--------------------------------------------------------------------
00053 
00058 class EulerOdeSolver : public RkOdeSolver<double,12>
00059 {
00060   public:
00073    EulerOdeSolver(
00074       const double& t,
00075       const double& dt,
00076       const double& A,
00077       const double& B,
00078       const double& C,
00079       Vector12d&    y,
00080       const double& eps);
00081 
00082   protected:
00089    Vector12d f(const double& x, const Vector12d& y) const;
00090 
00091   private:
00093    double m_A, m_B, m_C;
00094 };
00095 
00096 //--------------------------------------------------------------------
00097 
00098 /* forward declaration */
00099 class KRotationSaver;
00100 
00101 //--------------------------------------------------------------------
00102 
00106 class RotationGLWidget : public QGLWidget
00107 {
00108    Q_OBJECT
00109 
00110   public:
00117    RotationGLWidget(
00118       QWidget*              parent,
00119       const KRotationSaver& saver);
00120 
00121   protected:
00123    virtual void paintGL();
00126    virtual void resizeGL(int w, int h);
00128    virtual void initializeGL();
00129 
00130   private:
00139    void myGlArrow(
00140       GLfloat total_length,
00141       GLfloat head_length,
00142       GLfloat base_width,
00143       GLfloat head_width);
00145    void draw_traces (void);
00146 
00147   private: // Private attributes
00149    GLfloat  m_eyeR;
00151    GLfloat  m_eyeTheta;
00153    GLfloat  m_eyePhi;
00155    Vector3d m_boxSize;
00157    GLuint   m_fixedAxses;
00159    GLuint   m_bodyAxses;
00161    GLfloat  m_lightR;
00163    GLfloat  m_lightTheta;
00165    GLfloat  m_lightPhi;
00166 
00168    GLfloat  m_bodyAxsesLength;
00170    GLfloat  m_fixedAxsesLength;
00171 
00173    const KRotationSaver& m_saver;
00174 };
00175 
00176 //--------------------------------------------------------------------
00177 
00181 class KRotationSaver : public KScreenSaver
00182 {
00183    Q_OBJECT
00184 
00185   public:
00186 
00187    /* public member functions */
00188 
00194    KRotationSaver(WId drawable);
00198    ~KRotationSaver();
00200    void readSettings();
00202    void initData();
00203 
00206    inline double traceLengthSeconds(void) const
00207       {
00208          return m_traceLengthSeconds;
00209       }
00211    void setTraceLengthSeconds(const double& t);
00212 
00215    inline bool traceFlag(unsigned int n) const
00216       {
00217          return m_traceFlag[n];
00218       }
00220    inline void setTraceFlag(unsigned int n, const bool& flag)
00221       {
00222          m_traceFlag[n] = flag;
00223       }
00224 
00227    inline bool randomTraces(void) const
00228       {
00229          return m_randomTraces;
00230       }
00232    inline void setRandomTraces(const bool& flag)
00233       {
00234          m_randomTraces = flag;
00235       }
00236 
00238    inline double Lz(void) const
00239       {
00240          return m_Lz;
00241       }
00243    void setLz(const double& Lz);
00244 
00246    inline double initEulerTheta(void) const
00247       {
00248          return m_initEulerTheta;
00249       }
00251    void setInitEulerTheta(const double& theta);
00252 
00254    inline const Vector3d& omega(void) const
00255       {
00256          return m_omega;
00257       }
00259    inline const std::deque<Matrix3d>& e(void) const
00260       {
00261          return m_e;
00262       }
00264    inline const Vector3d& J(void) const
00265       {
00266          return m_J;
00267       }
00268 
00269    /* public static class member variables */
00270 
00272    static const double sm_traceLengthSecondsLimitLower;
00274    static const double sm_traceLengthSecondsLimitUpper;
00276    static const double sm_traceLengthSecondsDefault;
00277 
00279    static const bool sm_traceFlagDefault[3];
00281    static const bool sm_randomTracesDefault;
00282 
00284    static const double sm_LzLimitLower;
00286    static const double sm_LzLimitUpper;
00288    static const double sm_LzDefault;
00289 
00291    static const double sm_initEulerThetaLimitLower;
00293    static const double sm_initEulerThetaLimitUpper;
00295    static const double sm_initEulerThetaDefault;
00296 
00297   public slots:
00299    void doTimeStep();
00302    void resizeGlArea(QResizeEvent* e);
00303 
00304   private:
00305 
00308    static const unsigned int sm_deltaT;
00309 
00311    EulerOdeSolver*   m_solver;
00313    RotationGLWidget* m_glArea;
00315    QTimer*           m_timer;
00316 
00318    Vector3d             m_omega;
00321    std::deque<Matrix3d> m_e;
00323    const Vector3d       m_J;
00324 
00326    double   m_traceLengthSeconds;
00329    bool     m_traceFlag[3];
00332    bool     m_randomTraces;
00335    double   m_Lz;
00336 
00338    double   m_initEulerPhi;
00340    double   m_initEulerPsi;
00343    double   m_initEulerTheta;
00344 };
00345 
00346 //--------------------------------------------------------------------
00347 
00351 class KRotationSetup : public QDialog, public Ui::KRotationSetupUi
00352 {
00353    Q_OBJECT
00354 
00355   public:
00356    KRotationSetup(QWidget* parent = NULL);
00357    ~KRotationSetup();
00358 
00359   public slots:
00361    void okButtonClickedSlot(void);
00363    void aboutButtonClickedSlot(void);
00364    void randomTracesToggled(bool state);
00365    void xTraceToggled(bool state);
00366    void yTraceToggled(bool state);
00367    void zTraceToggled(bool state);
00368    void lengthEnteredSlot(const QString& s);
00369    void LzEnteredSlot(const QString& s);
00370    void thetaEnteredSlot(const QString& s);
00371 
00372   private:
00374    KRotationSaver* m_saver;
00375 };
00376 
00377 #endif