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#else
46#include <QGLWidget>
47#endif
48#include <Quarter/Basic.h>
49
50class QAction;
51class QMenu;
52class SoNode;
53class SoEvent;
54class SoCamera;
55class SoEventManager;
56class SoRenderManager;
57class SoDirectionalLight;
58class SoScXMLStateMachine;
59
60namespace SIM { namespace Coin3D { namespace Quarter {
61
62class EventFilter;
63const char DEFAULT_NAVIGATIONFILE [] = "coin:///scxml/navigation/examiner.xml";
64
65#if QT_VERSION >= 0x060000
66class QUARTER_DLL_API QuarterWidget : public QOpenGLWidget {
67 typedef QOpenGLWidget inherited;
68#else
69class QUARTER_DLL_API QuarterWidget : public QGLWidget {
70 typedef QGLWidget inherited;
71#endif
72 Q_OBJECT
73
74 Q_PROPERTY(QUrl navigationModeFile READ navigationModeFile WRITE setNavigationModeFile RESET resetNavigationModeFile)
75 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
76 Q_PROPERTY(bool contextMenuEnabled READ contextMenuEnabled WRITE setContextMenuEnabled)
77 Q_PROPERTY(bool headlightEnabled READ headlightEnabled WRITE setHeadlightEnabled)
78 Q_PROPERTY(bool clearZBuffer READ clearZBuffer WRITE setClearZBuffer)
79 Q_PROPERTY(bool clearWindow READ clearWindow WRITE setClearWindow)
80 Q_PROPERTY(bool interactionModeEnabled READ interactionModeEnabled WRITE setInteractionModeEnabled)
81 Q_PROPERTY(bool interactionModeOn READ interactionModeOn WRITE setInteractionModeOn)
82
83 Q_PROPERTY(TransparencyType transparencyType READ transparencyType WRITE setTransparencyType)
84 Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode)
85 Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode)
86 Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged)
87
88 Q_ENUMS(TransparencyType)
89 Q_ENUMS(RenderMode)
90 Q_ENUMS(StereoMode)
91
92
93public:
94#if QT_VERSION >= 0x060000
95 explicit QuarterWidget(QWidget * parent = 0, const QOpenGLWidget* sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
96 explicit QuarterWidget(QOpenGLContext * context, QWidget * parent = 0, const QOpenGLWidget* sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
97 explicit QuarterWidget(const QSurfaceFormat & format, QWidget * parent = 0, const QOpenGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
98#elif QT_VERSION >= 0x050F00
99 explicit QuarterWidget(QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
100 explicit QuarterWidget(QGLContext * context, QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
101 explicit QuarterWidget(const QGLFormat & format, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags());
102#else
103 explicit QuarterWidget(QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
104 explicit QuarterWidget(QGLContext* context, QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
105 explicit QuarterWidget(const QGLFormat& format, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
106#endif
107 virtual ~QuarterWidget();
108
110 SCREEN_DOOR = SoGLRenderAction::SCREEN_DOOR,
111 ADD = SoGLRenderAction::ADD,
112 DELAYED_ADD = SoGLRenderAction::DELAYED_ADD,
113 SORTED_OBJECT_ADD = SoGLRenderAction::SORTED_OBJECT_ADD,
114 BLEND = SoGLRenderAction::BLEND,
115 DELAYED_BLEND = SoGLRenderAction::DELAYED_BLEND,
116 SORTED_OBJECT_BLEND = SoGLRenderAction::SORTED_OBJECT_BLEND,
117 SORTED_OBJECT_SORTED_TRIANGLE_ADD = SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD,
118 SORTED_OBJECT_SORTED_TRIANGLE_BLEND = SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND,
119 NONE = SoGLRenderAction::NONE,
120 SORTED_LAYERS_BLEND = SoGLRenderAction::SORTED_LAYERS_BLEND
121 };
122
124 AS_IS = SoRenderManager::AS_IS,
125 WIREFRAME = SoRenderManager::WIREFRAME,
126 WIREFRAME_OVERLAY = SoRenderManager::WIREFRAME_OVERLAY,
127 POINTS = SoRenderManager::POINTS,
128 HIDDEN_LINE = SoRenderManager::HIDDEN_LINE,
129 BOUNDING_BOX = SoRenderManager::BOUNDING_BOX
130 };
131
133 MONO = SoRenderManager::MONO,
134 ANAGLYPH = SoRenderManager::ANAGLYPH,
135 QUAD_BUFFER = SoRenderManager::QUAD_BUFFER,
136 INTERLEAVED_ROWS = SoRenderManager::INTERLEAVED_ROWS,
137 INTERLEAVED_COLUMNS = SoRenderManager::INTERLEAVED_COLUMNS
138 };
139
140 TransparencyType transparencyType(void) const;
141 RenderMode renderMode(void) const;
142 StereoMode stereoMode(void) const;
143
144 void setBackgroundColor(const QColor & color);
145 QColor backgroundColor(void) const;
146
147 qreal devicePixelRatio(void) const;
148
149 void resetNavigationModeFile(void);
150 void setNavigationModeFile(const QUrl & url = QUrl(DEFAULT_NAVIGATIONFILE));
151 const QUrl & navigationModeFile(void) const;
152
153 void setContextMenuEnabled(bool yes);
154 bool contextMenuEnabled(void) const;
155 QMenu * getContextMenu(void) const;
156
157 bool headlightEnabled(void) const;
158 void setHeadlightEnabled(bool onoff);
159 SoDirectionalLight * getHeadlight(void);
160
161 bool clearZBuffer(void) const;
162 void setClearZBuffer(bool onoff);
163
164 bool clearWindow(void) const;
165 void setClearWindow(bool onoff);
166
167 bool interactionModeEnabled(void) const;
168 void setInteractionModeEnabled(bool onoff);
169
170 bool interactionModeOn(void) const;
171 void setInteractionModeOn(bool onoff);
172
173 void setStateCursor(const SbName & state, const QCursor & cursor);
174 QCursor stateCursor(const SbName & state);
175
176 uint32_t getCacheContextId(void) const;
177
178 virtual void setSceneGraph(SoNode * root);
179 virtual SoNode * getSceneGraph(void) const;
180
181 void setSoEventManager(SoEventManager * manager);
182 SoEventManager * getSoEventManager(void) const;
183
184 void setSoRenderManager(SoRenderManager * manager);
185 SoRenderManager * getSoRenderManager(void) const;
186
187 EventFilter * getEventFilter(void) const;
188
189 void addStateMachine(SoScXMLStateMachine * statemachine);
190 void removeStateMachine(SoScXMLStateMachine * statemachine);
191
192 virtual bool processSoEvent(const SoEvent * event);
193 virtual QSize minimumSizeHint(void) const;
194
195 QList<QAction *> transparencyTypeActions(void) const;
196 QList<QAction *> stereoModeActions(void) const;
197 QList<QAction *> renderModeActions(void) const;
198
199public slots:
200 virtual void viewAll(void);
201 virtual void seek(void);
202
203 void redraw(void);
204
205 void setRenderMode(RenderMode mode);
206 void setStereoMode(StereoMode mode);
207 void setTransparencyType(TransparencyType type);
208
209signals:
210 void devicePixelRatioChanged(qreal dev_pixel_ratio);
211
212protected:
213 virtual void resizeGL(int width, int height);
214 virtual void initializeGL(void);
215 virtual void paintGL(void);
216 virtual void actualRedraw(void);
217 virtual bool updateDevicePixelRatio(void);
218
219private:
220#if QT_VERSION >= 0x060000
221 void constructor(const QOpenGLWidget* sharewidget);
222#else
223 void constructor(const QGLWidget* sharewidget);
224#endif
225 friend class QuarterWidgetP;
226 class QuarterWidgetP * pimpl;
227};
228
229}}} // namespace
230
231#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:69
RenderMode
Definition QuarterWidget.h:123
StereoMode
Definition QuarterWidget.h:132
TransparencyType
Definition QuarterWidget.h:109