Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoQtRenderArea.h
1 #ifndef SOQT_RENDERAREA_H
2 #define SOQT_RENDERAREA_H
3 
4 //
5 
6 /**************************************************************************\
7  * Copyright (c) Kongsberg Oil & Gas Technologies AS
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are
12  * met:
13  *
14  * Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  *
17  * Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * Neither the name of the copyright holder nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 \**************************************************************************/
37 
38 #include <Inventor/SbColor.h>
39 #include <Inventor/SbViewportRegion.h>
42 
43 #include <Inventor/Qt/SoQtGLWidget.h>
44 
45 class SbColor;
46 class SoNode;
47 class SoSelection;
48 
49 class SoQtDevice;
50 // SoQtRenderAreaP is only used in the "friend class" statement in
51 // the class definition, so this shouldn't really be necessary. But
52 // the OSF1/cxx compiler complains if it's left out.
53 class SoQtRenderAreaP;
54 
55 typedef SbBool SoQtRenderAreaEventCB(void * closure, QEvent* event);
56 
57 // *************************************************************************
58 
59 class SOQT_DLL_API SoQtRenderArea : public SoQtGLWidget {
60  SOQT_OBJECT_HEADER(SoQtRenderArea, SoQtGLWidget);
61 
62 public:
63  SoQtRenderArea(QWidget* parent = NULL,
64  const char * name = NULL,
65  SbBool embed = TRUE,
66  SbBool mouseInput = TRUE,
67  SbBool keyboardInput = TRUE);
68  ~SoQtRenderArea();
69 
70  virtual void setSceneGraph(SoNode * scene);
71  virtual SoNode * getSceneGraph(void);
72  void setOverlaySceneGraph(SoNode * scene);
73  SoNode * getOverlaySceneGraph(void);
74 
75  void setBackgroundColor(const SbColor & color);
76  const SbColor & getBackgroundColor(void) const;
77  void setBackgroundIndex(int idx);
78  int getBackgroundIndex(void) const;
79  void setOverlayBackgroundIndex(int idx);
80  int getOverlayBackgroundIndex(void) const;
81  void setColorMap(int start, int num, const SbColor * colors);
82  void setOverlayColorMap(int start, int num, const SbColor * colors);
83  void setViewportRegion(const SbViewportRegion & newRegion);
84  const SbViewportRegion & getViewportRegion(void) const;
85  void setTransparencyType(SoGLRenderAction::TransparencyType type);
86  SoGLRenderAction::TransparencyType getTransparencyType(void) const;
87  void setAntialiasing(SbBool smoothing, int numPasses);
88  void getAntialiasing(SbBool & smoothing, int & numPasses) const;
89  void setClearBeforeRender(SbBool enable, SbBool zbEnable = TRUE);
90  SbBool isClearBeforeRender(void) const;
91  SbBool isClearZBufferBeforeRender(void) const;
92  void setClearBeforeOverlayRender(SbBool enable);
93  SbBool isClearBeforeOverlayRender(void) const;
94  void setAutoRedraw(SbBool enable);
95  SbBool isAutoRedraw(void) const;
96  void setRedrawPriority(uint32_t priority);
97  uint32_t getRedrawPriority(void) const;
98  static uint32_t getDefaultRedrawPriority(void);
99  void render(void);
100  void renderOverlay(void);
101  void scheduleRedraw(void);
102  void scheduleOverlayRedraw(void);
103  void redrawOnSelectionChange(SoSelection * selection);
104  void redrawOverlayOnSelectionChange(SoSelection * selection);
105  void setEventCallback(SoQtRenderAreaEventCB * func, void * user = NULL);
106  void setSceneManager(SoSceneManager * manager);
107  SoSceneManager * getSceneManager(void) const;
108  void setOverlaySceneManager(SoSceneManager * manager);
109  SoSceneManager * getOverlaySceneManager(void) const;
110  void setGLRenderAction(SoGLRenderAction * action);
111  SoGLRenderAction * getGLRenderAction(void) const;
112  void setOverlayGLRenderAction(SoGLRenderAction * action);
113  SoGLRenderAction * getOverlayGLRenderAction(void) const;
114 
115  SbBool sendSoEvent(const SoEvent * event);
116 
117  void registerDevice(SoQtDevice * device);
118  void unregisterDevice(SoQtDevice * device);
119 
120 
121 protected:
122  SoQtRenderArea(QWidget* parent,
123  const char * name,
124  SbBool embed,
125  SbBool mouseInput,
126  SbBool keyboardInput,
127  SbBool build);
128 
129  virtual void redraw(void);
130  virtual void actualRedraw(void);
131  virtual void redrawOverlay(void);
132  virtual void actualOverlayRedraw(void);
133 
134  virtual SbBool processSoEvent(const SoEvent * const event);
135  virtual void processEvent(QEvent* event);
136  virtual void initGraphic(void);
137  virtual void initOverlayGraphic(void);
138  virtual void sizeChanged(const SbVec2s & size);
139  virtual void widgetChanged(QWidget* widget);
140  virtual void afterRealizeHook(void);
141 
142  QWidget* buildWidget(QWidget* parent);
143 
144  virtual const char * getDefaultWidgetName(void) const;
145  virtual const char * getDefaultTitle(void) const;
146  virtual const char * getDefaultIconTitle(void) const;
147 
148  virtual SbBool glScheduleRedraw(void);
149 
150 private:
151  class SoQtRenderAreaP * pimpl;
152  friend class SoQtRenderAreaP;
153 };
154 
155 // *************************************************************************
156 
157 #endif // ! SOQT_RENDERAREA_H
virtual SbBool glScheduleRedraw(void)
Definition: SoQtGLWidget.cpp:741
virtual const char * getDefaultIconTitle(void) const
Definition: SoQtComponentCommon.cpp:324
The SoQtDevice class is the base class for the translation devices.
Definition: SoQtDevice.h:73
virtual const char * getDefaultWidgetName(void) const
Definition: SoQtComponentCommon.cpp:299
virtual void initGraphic(void)
Definition: SoQtGLWidget.cpp:715
virtual void sizeChanged(const SbVec2s &size)
Definition: SoQtGLWidget.cpp:735
virtual void widgetChanged(QWidget *w)
Definition: SoQtGLWidget.cpp:581
The SoQtRenderArea class adds scenegraph handling and event management.
Definition: SoQtRenderArea.h:59
virtual void redrawOverlay(void)
Definition: SoQtGLWidget.cpp:708
The SoQtGLWidget class manages OpenGL contexts.
Definition: SoQtGLWidget.h:93
virtual void processEvent(QEvent *event)
Definition: SoQtGLWidget.cpp:588
virtual const char * getDefaultTitle(void) const
Definition: SoQtComponentCommon.cpp:312
virtual void redraw(void)=0
virtual void afterRealizeHook(void)
Definition: SoQtComponent.cpp:897
virtual void initOverlayGraphic(void)
Definition: SoQtGLWidget.cpp:727
QWidget * buildWidget(QWidget *parent)
Definition: SoQtGLWidget.cpp:248