Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QtExaminerViewer.hh
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 //=============================================================================
53 //
54 // CLASS QtExaminerViewer
55 //
56 //=============================================================================
57 
58 #ifndef ACG_QTEXAMINERVIEWER_HH
59 #define ACG_QTEXAMINERVIEWER_HH
60 
61 
62 //== INCLUDES =================================================================
63 
64 
65 #include "QtBaseViewer.hh"
66 
67 #include <QTime>
68 #include <QMouseEvent>
69 #include <QWheelEvent>
70 #include <QKeyEvent>
71 
72 
73 //== NAMESPACES ===============================================================
74 
75 
76 namespace ACG {
77 namespace QtWidgets {
78 
79 
80 //== FORWARDDECLARATIONS ======================================================
81 
82 
83 class QWheel;
84 class QtQGLWidget_Internal;
85 class QtSceneGraphWidget;
86 
87 
88 //== CLASS DEFINITION =========================================================
89 
90 
97 class ACGDLLEXPORT QtExaminerViewer : public QtBaseViewer
98 {
99 Q_OBJECT
100 
101 public:
102 
103 
105  QtExaminerViewer( QWidget* _parent=0,
106  const char* _name=0,
107  QStatusBar *_statusBar=0,
108  const QGLFormat* _format=0,
109  const QtBaseViewer* _share=0,
110  Options _options=DefaultOptions );
111 
112  // Destructor.
113  virtual ~QtExaminerViewer() {}
114 
115 
117  void allowRotation( bool _mode ) { allowRotation_ = _mode; };
118 
119 
121 public:
122  double wheelZoomFactor();
123  double wheelZoomFactorShift();
124  void setWheelZoomFactor(double _factor);
125  void setWheelZoomFactorShift(double _factor);
126 private:
127  double wZoomFactor_;
128  double wZoomFactorShift_;
129 
130 
131 private slots:
132 
133  void slotAnimation();
134 
135 
136 protected:
137 
139  virtual bool viewKeyPressEvent(QKeyEvent* /* _event */ ) { return false; }
141  virtual void viewWheelEvent(QWheelEvent* _event);
143  virtual void viewMouseEvent(QMouseEvent* _event);
145  virtual void lightMouseEvent(QMouseEvent* _event);
146 
147 
148 protected:
149 
150  // mouse interaction
151  QPoint lastPoint2D_;
152 
153 
154 private:
155 
157  bool mapToSphere(const QPoint& _p, Vec3d& _result) const;
158 
159 
160  // mouse interaction
161  Vec3d lastPoint3D_;
162  bool lastPoint_hitSphere_;
163  bool allowRotation_;
164 
165 
166  // animation stuff
167  Vec3d lastRotationAxis_;
168  double lastRotationAngle_;
169  QTime lastMoveTime_;
170  QTimer* timer_;
171 };
172 
173 
174 //=============================================================================
175 } // namespace QtWidgets
176 } // namespace ACG
177 //=============================================================================
178 #endif // ACG_QTEXAMINERWIDGET_HH defined
179 //=============================================================================
180 
Inventor-like wheel widget.
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
void allowRotation(bool _mode)
Lock scene rotation.
virtual bool viewKeyPressEvent(QKeyEvent *)
handle new key events