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