Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

QGLExaminerViewer.h

Go to the documentation of this file.
00001 /*
00002  * QGLExaminerViewer.h
00003  * $Id: QGLExaminerViewer.h,v 1.7 2001/09/28 09:17:10 guenth Exp $
00004  *
00005  * Copyright (C) 1999, 2000 Markus Janich
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 //  Description : Class QGLExaminerViewer
00024 //  Purpose     : Provides funcionality of a OpenGL viewer
00025 
00026 
00027 #ifndef __QGLEXAMINERVIEWER_H_
00028 #define __QGLEXAMINERVIEWER_H_
00029 
00030 
00031 // Qt
00033 #include <qlineedit.h>
00034 #include <qtimer.h>
00035 
00036 // System
00038 
00039 
00040 // Own
00042 #include "QGLViewer.h"
00043 
00044 
00045 // Defines
00047 #define NUM_WIDGETS 13       // number of widgets to delete when
00048                              // switching decoration
00049 
00050 
00051 // Forward declarations
00053 class QLabel;
00054 class QSlider;
00055 class QPushButton;
00056 class QBoxLayout;
00057 class QTimer;
00058 //class QLineEdit;
00059 
00060 //class CV4D;
00061 class QToggleButton;
00062 
00063 // for Qt 2.x compatibility
00064 #if QT_VERSION >= 300
00065 #define CHECK_PTR Q_CHECK_PTR
00066 #endif
00067 
00068 #define ZOOMSCALING       100.0    // used for translating slidervalue to real (double) value.
00069 
00070 
00071 
00073 
00102 class QGLExaminerViewer : public QGLViewer {
00103   Q_OBJECT
00104 
00105 public:
00106 
00110   QGLExaminerViewer(QWidget * parent=0, 
00111                     const char * name=0, const QGLWidget * shareWidget = 0, 
00112                     WFlags f=0, bool viewertype=true,
00113                     const QGLFormat &format=QGLFormat::defaultFormat())
00114     : QGLViewer(parent, name, shareWidget, f, viewertype, format)
00115     {
00116       init(viewertype);
00117       /* Nothing else to do. */
00118     };
00119 
00125   QGLExaminerViewer(const CCamera &homecam,
00126                     QWidget * parent=0, 
00127                     const char * name=0, const QGLWidget * shareWidget = 0, 
00128                     WFlags f=0, bool viewertype=true,
00129                     const QGLFormat &format=QGLFormat::defaultFormat())
00130     : QGLViewer(homecam, parent, name, shareWidget, f, viewertype, format)
00131     {
00132       init(viewertype);
00133       /* Nothing else to do. */
00134     };
00135 
00139   QGLExaminerViewer(const CBoundingBox3D &cBBox,
00140                     QWidget * parent=0, 
00141                     const char * name=0, const QGLWidget * shareWidget = 0, 
00142                     WFlags f=0, bool viewertype=true,
00143                     const QGLFormat &format=QGLFormat::defaultFormat())
00144     : QGLViewer(cBBox, parent, name, shareWidget, f, viewertype, format)
00145     {
00146       init(viewertype);
00147       /* Nothing else to do. */
00148     };
00149 
00153   virtual ~QGLExaminerViewer() {};
00154 
00158   virtual void setCamera(const CCamera &Camera, CameraType which=CurrentCam);
00159 
00163   virtual void setFullViewer(bool state);
00164 
00168   virtual void enableMouseEvents(bool state) {
00169     if (m_pqTimer->isActive())
00170       m_pqTimer->stop();
00171 
00172     QGLViewer::enableMouseEvents(state);
00173   };
00174 
00175 
00176 signals:
00178   // SIGNALS //
00180 
00181 
00185   void sigViewerClosed(void);
00186 
00187 
00188 
00189 public slots:
00191   // PUBLIC SLOTS //
00193 
00198  void sltResetXSlider();
00199 
00204   void sltResetYSlider();
00205 
00211   void sltSetZoomSlider(int scaling);
00212 
00216   virtual void sltToggleStereo();
00217 
00218 
00219 
00220 protected slots:
00222   // PROTECTED SLOTS //
00224 
00228   virtual void sltToggleRenderMode();
00229 
00230 
00235   virtual void sltGoHome();
00236 
00237 
00242   virtual void sltSetCamera(const CCamera &cCamera) {
00243     setCamera(cCamera);
00244   }
00245 
00246 
00247 private slots:
00249   // PRIVATE SLOTS //
00251 
00257  void sltCamXRotate(int iAngle);
00258 
00264   void sltCamYRotate(int iAngle);
00265 
00269   void sltSetZoom(int zoom_factor);
00270 
00275   void sltSetZoomSlider(double rdFovy);
00276   void sltSetZoomSlider(const QString &qText);
00277   void sltSetZoomText(int n);
00278 
00283   void sltSaveVectors();
00284 
00291   void sltCamRotStep();
00292 
00296   void sltToggleDeco();
00297 
00302   void sltToggleToolTips();
00303 
00307   void sltToggleSpinning() {
00308     setItemChecked(m_nSpinOnOffID, !(isItemChecked(m_nSpinOnOffID)));
00309   };
00310 
00314   void sltSwitchBehave() {
00315     setItemChecked(m_nSwitchBehaveID, !(isItemChecked(m_nSwitchBehaveID)));
00316     m_fOldBehave = m_fOldBehave ? false : true;
00317   };
00318 
00322   void sltMenuToggleRenderMode();
00323 
00327   void sltTimeOut() { m_fAnimationOn = false; };
00328 
00330   void sltSetRefreshRate();
00331 
00332 
00333 protected:
00335   // PROTECTED METHODS //
00337   
00361   virtual void keyPressEvent(QKeyEvent *event);
00362 
00368   virtual void closeEvent(QCloseEvent *event);
00369 
00373   virtual void ManageMouseMove(QMouseEvent *event);
00374 
00378   virtual void ManageMousePress(QMouseEvent *event);
00379 
00383   virtual void ManageMouseRelease(QMouseEvent *event);
00384 
00386   bool eventFilter(QObject *pqObject, QEvent *pqEvent);
00387 
00391   virtual void makeFullViewer();
00392 
00396   virtual void makeSimpleViewer();
00397 
00398 
00399 private:
00401   // PRIVATE METHODS //
00403 
00407   void init(bool viewertype);
00408 
00409 
00411   // PRIVATE MEMBERS //
00413 
00414   int m_nMousePosX, m_nMousePosY;      // last mouse position
00415   int m_nXDiff, m_nYDiff;              // saves the difference of the mouse 
00416                                        // position between two mouseevents
00417 
00418   float m_rfXAlpha, m_rfYAlpha;        // used for rotating the scene around the axis
00419                                        // of the view direction relative to the position
00420                                        // of the mouse pointer inside the drawarea.
00421 
00422   int m_nQuadrant;                     // saves the quadrant where the last mouseaction happened.
00423 
00424   CV3D m_cUp, m_cRight, m_cDir;        // saves the ViewUp, ViewRight and
00425                                        // ViewDirection vector by 'sltSaveVectors()'
00426 
00427   int m_nLastRotAngle;                 // last angle (in degrees) of rotation using the sliders
00428 
00429   bool m_fLeftButtonPressed;           // saves left button state
00430   bool m_fMiddleButtonPressed;         // saves middle button state
00431 
00432   QBoxLayout *m_pqTopLayout;           // pointer to the toplayout
00433 
00434   QSlider *m_pqXRot,                   // pointer to slider of x-rotation
00435           *m_pqYRot,                   // pointer to slider of y-rotation
00436           *m_pqZoom;                   // pointer to slider of zooming
00437 
00438   QLineEdit *m_pqZoomText;
00439 
00440   QTimer *m_pqTimer,                   // timer for rotation animation
00441          *m_pqTimeOut;                 // timer to manage the timeout
00442   QWidget *m_apqWidgets[NUM_WIDGETS];  // saves the pointers of all widgets (needed for switching
00443                                        // between full and simple viewer.
00444   int m_nSelectionID;                  // saves the ID of the menuentry 'Selection on'
00445   int m_nDecoID;                       // saves the ID of the menuentry 'Decoration on'
00446   int m_nTTipsID;                      // saves the ID of the menuentry 'Tooltips on'
00447   int m_nSpinOnOffID;                  // saves the ID of the menuentry 'Spinning On/Off'
00448   int m_nSwitchBehaveID;               // saves the ID of the menuentry 'Behave like old ExaminerViewer'
00449   int m_nStereoID;                     // saves the ID of the menuentry 'Stereo'
00450   bool m_fToolTips;                    // saves the state of the tooltips
00451   bool m_fAnimationOn;                 // triggers the timeout for starting the animation
00452   bool m_fOldBehave;                   // saves the state how the mousemoves behave like, old or new style
00453   bool m_fShiftPressed;                // saves the state of the shift key while rotating the camera 
00454 };
00455 
00456 #endif // __QGLEXAMINERVIEWER_H_

Generated at Thu Oct 4 17:17:25 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001