Quarter  1.2.2
Coin3D GUI binding for Qt
Loading...
Searching...
No Matches
QuarterWidget.h
1#ifndef QUARTER_QUARTERWIDGET_H
2#define QUARTER_QUARTERWIDGET_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/SbBasic.h>
37#include <Inventor/SoRenderManager.h>
38#include <Inventor/actions/SoGLRenderAction.h>
39
40#include <QColor>
41#include <QUrl>
42#if QT_VERSION >= 0x060000
43#include <QOpenGLWidget>
44#include <QOpenGLContext>
45#define QUARTER_GL_WIDGET QOpenGLWidget
46#define QUARTER_GL_CONTEXT QOpenGLContext
47#define QUARTER_GL_FORMAT QSurfaceFormat
48#else
49#include <QGLWidget>
50#define QUARTER_GL_WIDGET QGLWidget
51#define QUARTER_GL_CONTEXT QGLContext
52#define QUARTER_GL_FORMAT QGLFormat
53#endif
54#include <Quarter/Basic.h>
55
56class QAction;
57class QMenu;
58class SoNode;
59class SoEvent;
60class SoCamera;
61class SoEventManager;
62class SoRenderManager;
63class SoDirectionalLight;
64class SoScXMLStateMachine;
65
66namespace SIM { namespace Coin3D { namespace Quarter {
67
68class EventFilter;
69const char DEFAULT_NAVIGATIONFILE [] = "coin:///scxml/navigation/examiner.xml";
70
71class QUARTER_DLL_API QuarterWidget : public QUARTER_GL_WIDGET {
72 typedef QUARTER_GL_WIDGET inherited;
73 Q_OBJECT
74
75 Q_PROPERTY(QUrl navigationModeFile READ navigationModeFile WRITE setNavigationModeFile RESET resetNavigationModeFile)
76 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
77 Q_PROPERTY(bool contextMenuEnabled READ contextMenuEnabled WRITE setContextMenuEnabled)
78 Q_PROPERTY(bool headlightEnabled READ headlightEnabled WRITE setHeadlightEnabled)
79 Q_PROPERTY(bool clearZBuffer READ clearZBuffer WRITE setClearZBuffer)
80 Q_PROPERTY(bool clearWindow READ clearWindow WRITE setClearWindow)
81 Q_PROPERTY(bool interactionModeEnabled READ interactionModeEnabled WRITE setInteractionModeEnabled)
82 Q_PROPERTY(bool interactionModeOn READ interactionModeOn WRITE setInteractionModeOn)
83
84 Q_PROPERTY(TransparencyType transparencyType READ transparencyType WRITE setTransparencyType)
85 Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode)
86 Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode)
87 Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged)
88
89 Q_ENUMS(TransparencyType)
90 Q_ENUMS(RenderMode)
91 Q_ENUMS(StereoMode)
92
93
94public:
95#if QT_VERSION >= 0x050F00
96 explicit QuarterWidget(QWidget * parent = 0, const QUARTER_GL_WIDGET * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
97 explicit QuarterWidget(QUARTER_GL_CONTEXT * context, QWidget * parent = 0, const QUARTER_GL_WIDGET * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
98 explicit QuarterWidget(const QUARTER_GL_FORMAT & format, QWidget * parent = 0, const QUARTER_GL_WIDGET * shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
99#else
100 explicit QuarterWidget(QWidget * parent = 0, const QUARTER_GL_WIDGET * sharewidget = 0, Qt::WindowFlags f = 0);
101 explicit QuarterWidget(QUARTER_GL_CONTEXT * context, QWidget* parent = 0, const QUARTER_GL_WIDGET * sharewidget = 0, Qt::WindowFlags f = 0);
102 explicit QuarterWidget(const QUARTER_GL_FORMAT & format, QWidget * parent = 0, const QUARTER_GL_WIDGET * shareWidget = 0, Qt::WindowFlags f = 0);
103#endif
104 virtual ~QuarterWidget();
105
107 SCREEN_DOOR = SoGLRenderAction::SCREEN_DOOR,
108 ADD = SoGLRenderAction::ADD,
109 DELAYED_ADD = SoGLRenderAction::DELAYED_ADD,
110 SORTED_OBJECT_ADD = SoGLRenderAction::SORTED_OBJECT_ADD,
111 BLEND = SoGLRenderAction::BLEND,
112 DELAYED_BLEND = SoGLRenderAction::DELAYED_BLEND,
113 SORTED_OBJECT_BLEND = SoGLRenderAction::SORTED_OBJECT_BLEND,
114 SORTED_OBJECT_SORTED_TRIANGLE_ADD = SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD,
115 SORTED_OBJECT_SORTED_TRIANGLE_BLEND = SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND,
116 NONE = SoGLRenderAction::NONE,
117 SORTED_LAYERS_BLEND = SoGLRenderAction::SORTED_LAYERS_BLEND
118 };
119
121 AS_IS = SoRenderManager::AS_IS,
122 WIREFRAME = SoRenderManager::WIREFRAME,
123 WIREFRAME_OVERLAY = SoRenderManager::WIREFRAME_OVERLAY,
124 POINTS = SoRenderManager::POINTS,
125 HIDDEN_LINE = SoRenderManager::HIDDEN_LINE,
126 BOUNDING_BOX = SoRenderManager::BOUNDING_BOX
127 };
128
130 MONO = SoRenderManager::MONO,
131 ANAGLYPH = SoRenderManager::ANAGLYPH,
132 QUAD_BUFFER = SoRenderManager::QUAD_BUFFER,
133 INTERLEAVED_ROWS = SoRenderManager::INTERLEAVED_ROWS,
134 INTERLEAVED_COLUMNS = SoRenderManager::INTERLEAVED_COLUMNS
135 };
136
137 TransparencyType transparencyType(void) const;
138 RenderMode renderMode(void) const;
139 StereoMode stereoMode(void) const;
140
141 void setBackgroundColor(const QColor & color);
142 QColor backgroundColor(void) const;
143
144 qreal devicePixelRatio(void) const;
145
146 void resetNavigationModeFile(void);
147 void setNavigationModeFile(const QUrl & url = QUrl(DEFAULT_NAVIGATIONFILE));
148 const QUrl & navigationModeFile(void) const;
149 void setupDefaultCursors();
150
151 void setContextMenuEnabled(bool yes);
152 bool contextMenuEnabled(void) const;
153 QMenu * getContextMenu(void) const;
154
155 bool headlightEnabled(void) const;
156 void setHeadlightEnabled(bool onoff);
157 SoDirectionalLight * getHeadlight(void);
158
159 bool clearZBuffer(void) const;
160 void setClearZBuffer(bool onoff);
161
162 bool clearWindow(void) const;
163 void setClearWindow(bool onoff);
164
165 bool interactionModeEnabled(void) const;
166 void setInteractionModeEnabled(bool onoff);
167
168 bool interactionModeOn(void) const;
169 void setInteractionModeOn(bool onoff);
170
171 void setStateCursor(const SbName & state, const QCursor & cursor);
172 QCursor stateCursor(const SbName & state);
173
174 uint32_t getCacheContextId(void) const;
175
176 virtual void setSceneGraph(SoNode * root);
177 virtual SoNode * getSceneGraph(void) const;
178
179 void setSoEventManager(SoEventManager * manager);
180 SoEventManager * getSoEventManager(void) const;
181
182 void setSoRenderManager(SoRenderManager * manager);
183 SoRenderManager * getSoRenderManager(void) const;
184
185 EventFilter * getEventFilter(void) const;
186
187 void addStateMachine(SoScXMLStateMachine * statemachine);
188 void removeStateMachine(SoScXMLStateMachine * statemachine);
189
190 virtual bool processSoEvent(const SoEvent * event);
191 virtual QSize minimumSizeHint(void) const;
192
193 QList<QAction *> transparencyTypeActions(void) const;
194 QList<QAction *> stereoModeActions(void) const;
195 QList<QAction *> renderModeActions(void) const;
196
197public slots:
198 virtual void viewAll(void);
199 virtual void seek(void);
200
201 void redraw(void);
202
203 void setRenderMode(RenderMode mode);
204 void setStereoMode(StereoMode mode);
205 void setTransparencyType(TransparencyType type);
206
207signals:
208 void devicePixelRatioChanged(qreal dev_pixel_ratio);
209
210protected:
211 virtual void resizeGL(int width, int height);
212 virtual void initializeGL(void);
213 virtual void paintGL(void);
214 virtual void actualRedraw(void);
215 virtual bool updateDevicePixelRatio(void);
216
217private:
218 void constructor(const QUARTER_GL_WIDGET * sharewidget);
219 friend class QuarterWidgetP;
220 class QuarterWidgetP * pimpl;
221};
222
223}}} // namespace
224
225#endif // QUARTER_QUARTERWIDGET_H
Definition EventFilter.h:46
The QuarterWidget class is the main class in Quarter. It provides a widget for Coin rendering....
Definition QuarterWidget.h:71
RenderMode
Definition QuarterWidget.h:120
StereoMode
Definition QuarterWidget.h:129
TransparencyType
Definition QuarterWidget.h:106