Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QGLExaminerViewer.h

Go to the documentation of this file.
00001 /*
00002  * QGLExaminerViewer.h
00003  * $Id: QGLExaminerViewer.h,v 1.9 2001/11/20 16:23:48 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  * As a special exception to the GPL, the QGLViewer authors (Markus
00022  * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas
00023  * Woerner) give permission to link this program with Qt (non-)commercial
00024  * edition, and distribute the resulting executable, without including
00025  * the source code for the Qt (non-)commercial edition in the source
00026  * distribution.
00027  *
00028  */
00029 
00030 //  Description : Class QGLExaminerViewer
00031 //  Purpose     : Provides funcionality of a OpenGL viewer
00032 
00033 
00034 #ifndef __QGLEXAMINERVIEWER_H_
00035 #define __QGLEXAMINERVIEWER_H_
00036 
00037 
00038 // Qt
00040 #include <qlineedit.h>
00041 #include <qtimer.h>
00042 
00043 // System
00045 
00046 
00047 // Own
00049 #include "QGLViewer.h"
00050 
00051 
00052 // Defines
00054 #define NUM_WIDGETS 13       // number of widgets to delete when
00055                              // switching decoration
00056 
00057 
00058 // Forward declarations
00060 class QLabel;
00061 class QSlider;
00062 class QPushButton;
00063 class QBoxLayout;
00064 class QTimer;
00065 //class QLineEdit;
00066 
00067 //class CV4D;
00068 class QToggleButton;
00069 
00070 
00071 #define ZOOMSCALING       100.0    // used for translating slidervalue to real (double) value.
00072 
00073 
00074 
00076 
00105 class QGLExaminerViewer : public QGLViewer {
00106   Q_OBJECT
00107 
00108 public:
00109 
00113   QGLExaminerViewer(QWidget * parent=0, 
00114                     const char * name=0, const QGLWidget * shareWidget = 0, 
00115                     WFlags f=0, bool viewertype=true,
00116                     const QGLFormat &format=QGLFormat::defaultFormat())
00117     : QGLViewer(parent, name, shareWidget, f, viewertype, format)
00118     {
00119       init(viewertype);
00120       /* Nothing else to do. */
00121     };
00122 
00128   QGLExaminerViewer(const CCamera &homecam,
00129                     QWidget * parent=0, 
00130                     const char * name=0, const QGLWidget * shareWidget = 0, 
00131                     WFlags f=0, bool viewertype=true,
00132                     const QGLFormat &format=QGLFormat::defaultFormat())
00133     : QGLViewer(homecam, parent, name, shareWidget, f, viewertype, format)
00134     {
00135       init(viewertype);
00136       /* Nothing else to do. */
00137     };
00138 
00142   QGLExaminerViewer(const CBoundingBox3D &cBBox,
00143                     QWidget * parent=0, 
00144                     const char * name=0, const QGLWidget * shareWidget = 0, 
00145                     WFlags f=0, bool viewertype=true,
00146                     const QGLFormat &format=QGLFormat::defaultFormat())
00147     : QGLViewer(cBBox, parent, name, shareWidget, f, viewertype, format)
00148     {
00149       init(viewertype);
00150       /* Nothing else to do. */
00151     };
00152 
00156   virtual ~QGLExaminerViewer() {};
00157 
00161   virtual void setCamera(const CCamera &Camera, CameraType which=CurrentCam);
00162 
00166   virtual void setFullViewer(bool state);
00167 
00171   virtual void enableMouseEvents(bool state) {
00172     if (m_pqTimer->isActive())
00173       m_pqTimer->stop();
00174 
00175     QGLViewer::enableMouseEvents(state);
00176   };
00177 
00178 
00179 signals:
00181   // SIGNALS //
00183 
00184 
00188   void sigViewerClosed(void);
00189 
00190 
00191 
00192 public slots:
00194   // PUBLIC SLOTS //
00196 
00201  void sltResetXSlider();
00202 
00207   void sltResetYSlider();
00208 
00214   void sltSetZoomSlider(int scaling);
00215 
00219   virtual void sltToggleStereo();
00220 
00221 
00222 
00223 protected slots:
00225   // PROTECTED SLOTS //
00227 
00231   virtual void sltToggleRenderMode();
00232 
00233 
00238   virtual void sltGoHome();
00239 
00240 
00245   virtual void sltSetCamera(const CCamera &cCamera) {
00246     setCamera(cCamera);
00247   }
00248 
00249 
00250 private slots:
00252   // PRIVATE SLOTS //
00254 
00260  void sltCamXRotate(int iAngle);
00261 
00267   void sltCamYRotate(int iAngle);
00268 
00272   void sltSetZoom(int zoom_factor);
00273 
00278   void sltSetZoomSlider(double rdFovy);
00279   void sltSetZoomSlider(const QString &qText);
00280   void sltSetZoomText(int n);
00281 
00286   void sltSaveVectors();
00287 
00294   void sltCamRotStep();
00295 
00299   void sltToggleDeco();
00300 
00305   void sltToggleToolTips();
00306 
00310   void sltToggleSpinning() {
00311     setItemChecked(m_nSpinOnOffID, !(isItemChecked(m_nSpinOnOffID)));
00312   };
00313 
00317   void sltSwitchBehave() {
00318     setItemChecked(m_nSwitchBehaveID, !(isItemChecked(m_nSwitchBehaveID)));
00319     m_fOldBehave = m_fOldBehave ? false : true;
00320   };
00321 
00325   void sltMenuToggleRenderMode();
00326 
00330   void sltTimeOut() { m_fAnimationOn = false; };
00331 
00333   void sltSetRefreshRate();
00334 
00335 
00336 protected:
00338   // PROTECTED METHODS //
00340   
00364   virtual void keyPressEvent(QKeyEvent *event);
00365 
00371   virtual void closeEvent(QCloseEvent *event);
00372 
00376   virtual void ManageMouseMove(QMouseEvent *event);
00377 
00381   virtual void ManageMousePress(QMouseEvent *event);
00382 
00386   virtual void ManageMouseRelease(QMouseEvent *event);
00387 
00389   bool eventFilter(QObject *pqObject, QEvent *pqEvent);
00390 
00394   virtual void makeFullViewer();
00395 
00399   virtual void makeSimpleViewer();
00400 
00401 
00402 private:
00404   // PRIVATE METHODS //
00406 
00410   void init(bool viewertype);
00411 
00412 
00414   // PRIVATE MEMBERS //
00416 
00417   int m_nMousePosX, m_nMousePosY;      // last mouse position
00418   int m_nXDiff, m_nYDiff;              // saves the difference of the mouse 
00419                                        // position between two mouseevents
00420 
00421   float m_rfXAlpha, m_rfYAlpha;        // used for rotating the scene around the axis
00422                                        // of the view direction relative to the position
00423                                        // of the mouse pointer inside the drawarea.
00424 
00425   int m_nQuadrant;                     // saves the quadrant where the last mouseaction happened.
00426 
00427   CV3D m_cUp, m_cRight, m_cDir;        // saves the ViewUp, ViewRight and
00428                                        // ViewDirection vector by 'sltSaveVectors()'
00429 
00430   int m_nLastRotAngle;                 // last angle (in degrees) of rotation using the sliders
00431 
00432   bool m_fLeftButtonPressed;           // saves left button state
00433   bool m_fMiddleButtonPressed;         // saves middle button state
00434 
00435   QBoxLayout *m_pqTopLayout;           // pointer to the toplayout
00436 
00437   QSlider *m_pqXRot,                   // pointer to slider of x-rotation
00438           *m_pqYRot,                   // pointer to slider of y-rotation
00439           *m_pqZoom;                   // pointer to slider of zooming
00440 
00441   QLineEdit *m_pqZoomText;
00442 
00443   QTimer *m_pqTimer,                   // timer for rotation animation
00444          *m_pqTimeOut;                 // timer to manage the timeout
00445   QWidget *m_apqWidgets[NUM_WIDGETS];  // saves the pointers of all widgets (needed for switching
00446                                        // between full and simple viewer.
00447   int m_nSelectionID;                  // saves the ID of the menuentry 'Selection on'
00448   int m_nDecoID;                       // saves the ID of the menuentry 'Decoration on'
00449   int m_nTTipsID;                      // saves the ID of the menuentry 'Tooltips on'
00450   int m_nSpinOnOffID;                  // saves the ID of the menuentry 'Spinning On/Off'
00451   int m_nSwitchBehaveID;               // saves the ID of the menuentry 'Behave like old ExaminerViewer'
00452   int m_nStereoID;                     // saves the ID of the menuentry 'Stereo'
00453   bool m_fToolTips;                    // saves the state of the tooltips
00454   bool m_fAnimationOn;                 // triggers the timeout for starting the animation
00455   bool m_fOldBehave;                   // saves the state how the mousemoves behave like, old or new style
00456   bool m_fShiftPressed;                // saves the state of the shift key while rotating the camera 
00457 };
00458 
00459 #endif // __QGLEXAMINERVIEWER_H_

Generated on Wed Sep 14 04:50:34 2005 for QGLViewer by  doxygen 1.4.4