Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoWinRenderArea.h
1 #ifndef SOWIN_RENDERAREA_H
2 #define SOWIN_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/Win/SoWinGLWidget.h>
44 
45 class SbColor;
46 class SoNode;
47 class SoSelection;
48 
49 class SoWinDevice;
50 // SoWinRenderAreaP 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 SoWinRenderAreaP;
54 
55 typedef SbBool SoWinRenderAreaEventCB(void * closure, MSG* event);
56 
57 // *************************************************************************
58 
59 class SOWIN_DLL_API SoWinRenderArea : public SoWinGLWidget {
60  SOWIN_OBJECT_HEADER(SoWinRenderArea, SoWinGLWidget);
61 
62 public:
63  SoWinRenderArea(HWND parent = NULL,
64  const char * name = NULL,
65  SbBool embed = TRUE,
66  SbBool mouseInput = TRUE,
67  SbBool keyboardInput = TRUE);
68  ~SoWinRenderArea();
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(SoWinRenderAreaEventCB * 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(SoWinDevice * device);
118  void unregisterDevice(SoWinDevice * device);
119 
120 
121 protected:
122  SoWinRenderArea(HWND 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(MSG* event);
136  virtual void initGraphic(void);
137  virtual void initOverlayGraphic(void);
138  virtual void sizeChanged(const SbVec2s & size);
139  virtual void widgetChanged(HWND widget);
140  virtual void afterRealizeHook(void);
141 
142  HWND buildWidget(HWND 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 SoWinRenderAreaP * pimpl;
152  friend class SoWinRenderAreaP;
153 };
154 
155 // *************************************************************************
156 
157 #endif // ! SOWIN_RENDERAREA_H
virtual void afterRealizeHook(void)
Definition: SoWinComponent.cpp:604
virtual const char * getDefaultTitle(void) const
Definition: SoWinComponentCommon.cpp:312
HWND buildWidget(HWND parent)
Definition: SoWinGLWidget.cpp:434
virtual const char * getDefaultWidgetName(void) const
Definition: SoWinComponentCommon.cpp:299
The SoWinRenderArea class adds scenegraph handling and event management.
Definition: SoWinRenderArea.h:59
virtual SbBool glScheduleRedraw(void)
Definition: SoWinGLWidget.cpp:314
virtual void redraw(void)=0
Definition: SoWinGLWidget.cpp:321
virtual void redrawOverlay(void)
Definition: SoWinGLWidget.cpp:328
virtual void sizeChanged(const SbVec2s &size)
Definition: SoWinGLWidget.cpp:365
The SoWinDevice class is the base class for the translation devices.
Definition: SoWinDevice.h:73
virtual void initOverlayGraphic(void)
Definition: SoWinGLWidget.cpp:358
virtual void initGraphic(void)
Definition: SoWinGLWidget.cpp:349
virtual void widgetChanged(HWND w)
Definition: SoWinGLWidget.cpp:372
virtual void processEvent(MSG *event)
Definition: SoWinGLWidget.cpp:335
virtual const char * getDefaultIconTitle(void) const
Definition: SoWinComponentCommon.cpp:324
The SoWinGLWidget class manages OpenGL contexts.
Definition: SoWinGLWidget.h:93