Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
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
150 void setContextMenuEnabled(bool yes);
151 bool contextMenuEnabled(void) const;
152 QMenu * getContextMenu(void) const;
153
154 bool headlightEnabled(void) const;
155 void setHeadlightEnabled(bool onoff);
156 SoDirectionalLight * getHeadlight(void);
157
158 bool clearZBuffer(void) const;
159 void setClearZBuffer(bool onoff);
160
161 bool clearWindow(void) const;
162 void setClearWindow(bool onoff);
163
164 bool interactionModeEnabled(void) const;
165 void setInteractionModeEnabled(bool onoff);
166
167 bool interactionModeOn(void) const;
168 void setInteractionModeOn(bool onoff);
169
170 void setStateCursor(const SbName & state, const QCursor & cursor);
171 QCursor stateCursor(const SbName & state);
172
173 uint32_t getCacheContextId(void) const;
174
175 virtual void setSceneGraph(SoNode * root);
176 virtual SoNode * getSceneGraph(void) const;
177
178 void setSoEventManager(SoEventManager * manager);
179 SoEventManager * getSoEventManager(void) const;
180
181 void setSoRenderManager(SoRenderManager * manager);
182 SoRenderManager * getSoRenderManager(void) const;
183
184 EventFilter * getEventFilter(void) const;
185
186 void addStateMachine(SoScXMLStateMachine * statemachine);
187 void removeStateMachine(SoScXMLStateMachine * statemachine);
188
189 virtual bool processSoEvent(const SoEvent * event);
190 virtual QSize minimumSizeHint(void) const;
191
192 QList<QAction *> transparencyTypeActions(void) const;
193 QList<QAction *> stereoModeActions(void) const;
194 QList<QAction *> renderModeActions(void) const;
195
196public slots:
197 virtual void viewAll(void);
198 virtual void seek(void);
199
200 void redraw(void);
201
202 void setRenderMode(RenderMode mode);
203 void setStereoMode(StereoMode mode);
204 void setTransparencyType(TransparencyType type);
205
206signals:
207 void devicePixelRatioChanged(qreal dev_pixel_ratio);
208
209protected:
210 virtual void resizeGL(int width, int height);
211 virtual void initializeGL(void);
212 virtual void paintGL(void);
213 virtual void actualRedraw(void);
214 virtual bool updateDevicePixelRatio(void);
215
216private:
217 void constructor(const QUARTER_GL_WIDGET * sharewidget);
218 friend class QuarterWidgetP;
219 class QuarterWidgetP * pimpl;
220};
221
222}}} // namespace
223
224#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