Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoQtViewer.h
1 #ifndef SOQT_VIEWER_H
2 #define SOQT_VIEWER_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 /**************************************************************************\
39  *
40  * A WORD OF ADVICE
41  *
42  * It is fruitless to modify the contents of the SoQtViewer.h file
43  * because it is autogenerated by configure from the SoAnyViewer.h.in
44  * file which you will find in the src/Inventor/Qt/common/ directory.
45  * Do your modifications to that file instead.
46  *
47 \**************************************************************************/
48 
49 // Include this first, as a workaround for building on top of SGI and
50 // TGS Inventor on some Linux distributions. (The bug is in SGI/TGS
51 // Inventor.)
52 #include <math.h>
53 
54 #include <Inventor/SbTime.h>
55 #include <Inventor/SoType.h>
56 #include <Inventor/SbLinear.h>
57 
58 #include <Inventor/Qt/SoQtRenderArea.h>
59 
60 #ifndef SOQT_INTERNAL
61 #include <Inventor/events/SoKeyboardEvent.h>
62 #endif // SOQT_INTERNAL
63 
64 class SoCallbackList;
65 class SoBaseColor;
66 class SoCamera;
67 class SoComplexity;
68 class SoDirectionalLight;
69 class SoDrawStyle;
71 class SoGroup;
72 class SoLightModel;
73 class SoMaterialBinding;
74 class SoNode;
75 class SoPolygonOffset;
76 class SoSensor;
77 class SoSeparator;
78 class SoSwitch;
79 class SoTimerSensor;
80 
81 class SoQtViewer;
82 
83 typedef void SoQtViewerCB(void * data, SoQtViewer * viewer);
84 typedef void SoQtViewerFPSCB(float fps, void * data, SoQtViewer * viewer);
85 
86 typedef SbVec2f SoQtAutoClippingCB(void * data, const SbVec2f & nearfar);
87 
88 // *************************************************************************
89 
90 class SOQT_DLL_API SoQtViewer : public SoQtRenderArea {
91  SOQT_OBJECT_ABSTRACT_HEADER(SoQtViewer, SoQtRenderArea);
92 
93 public:
94  enum Type {
96  EDITOR
97  };
98 
99  enum DrawStyle {
110  VIEW_WIREFRAME_OVERLAY
111  };
112 
113  enum DrawType {
114  STILL = 0,
115  INTERACTIVE
116  };
117 
118  enum BufferType {
121  BUFFER_INTERACTIVE
122  };
123 
126  CONSTANT_NEAR_PLANE
127  };
128 
129  virtual void setCamera(SoCamera * camera);
130  SoCamera * getCamera(void) const;
131 
132  virtual void setCameraType(SoType type);
133  SoType getCameraType(void) const;
134 
135  virtual void toggleCameraType(void);
136 
137  virtual void viewAll(void);
138 
139  virtual void saveHomePosition(void);
140  virtual void resetToHomePosition(void);
141 
142  virtual void setHeadlight(SbBool enable);
143  SbBool isHeadlight(void) const;
144  SoDirectionalLight * getHeadlight(void) const;
145 
146  virtual void setDrawStyle(SoQtViewer::DrawType type, SoQtViewer::DrawStyle style);
147  SoQtViewer::DrawStyle getDrawStyle(const SoQtViewer::DrawType type) const;
148 
149  virtual void setBufferingType(SoQtViewer::BufferType type);
150  SoQtViewer::BufferType getBufferingType(void) const;
151 
152  virtual void setViewing(SbBool enable);
153  SbBool isViewing(void) const;
154 
155  virtual void setCursorEnabled(SbBool enable);
156  SbBool isCursorEnabled(void) const;
157 
158  void setAutoClipping(SbBool enable);
159  SbBool isAutoClipping(void) const;
160 
161  void setAutoClippingStrategy(const AutoClippingStrategy strategy,
162  const float value = 0.6f,
163  SoQtAutoClippingCB * cb = NULL,
164  void * cbuserdata = NULL);
165 
166  virtual void setStereoViewing(SbBool enable);
167  SbBool isStereoViewing(void) const;
168 
169  virtual void setStereoOffset(const float dist);
170  float getStereoOffset(void) const;
171 
172  enum StereoType {
173  STEREO_NONE, STEREO_ANAGLYPH, STEREO_QUADBUFFER,
174  STEREO_INTERLEAVED_ROWS, STEREO_INTERLEAVED_COLUMNS
175  };
176 
177  SbBool setStereoType(SoQtViewer::StereoType s);
178  SoQtViewer::StereoType getStereoType(void) const;
179 
180  void setAnaglyphStereoColorMasks(const SbBool left[3], const SbBool right[3]);
181  void getAnaglyphStereoColorMasks(SbBool left[3], SbBool right[3]);
182 
183  void setDetailSeek(const SbBool enable);
184  SbBool isDetailSeek(void) const;
185 
186  void setSeekTime(const float seconds);
187  float getSeekTime(void) const;
188 
189  void addStartCallback(SoQtViewerCB * func, void * data = NULL);
190  void addFinishCallback(SoQtViewerCB * func, void * data = NULL);
191  void removeStartCallback(SoQtViewerCB * func, void * data = NULL);
192  void removeFinishCallback(SoQtViewerCB * func, void * data = NULL);
193 
194  void setWireframeOverlayColor(const SbColor & color);
195  const SbColor & getWireframeOverlayColor(void) const;
196 
197  virtual void setDoubleBuffer(const SbBool enable);
198 
199  virtual void setSceneGraph(SoNode * root);
200  virtual SoNode * getSceneGraph(void);
201 
202 protected:
203  SoQtViewer(QWidget* parent,
204  const char * name,
205  SbBool embed,
206  Type type,
207  SbBool build);
208  ~SoQtViewer();
209 
210  virtual void sizeChanged(const SbVec2s & size);
211  virtual void setSeekMode(SbBool enable);
212  SbBool isSeekMode(void) const;
213  SbBool seekToPoint(const SbVec2s screenpos);
214  void seekToPoint(const SbVec3f & scenepos);
215  virtual void computeSeekFinalOrientation(void);
216 
217  virtual void actualRedraw(void);
218  virtual SbBool processSoEvent(const SoEvent * const event);
219 
220  void interactiveCountInc(void);
221  void interactiveCountDec(void);
222  int getInteractiveCount(void) const;
223 
224  void setSeekDistance(const float distance);
225  float getSeekDistance(void) const;
226  void setSeekValueAsPercentage(const SbBool on);
227  SbBool isSeekValuePercentage(void) const;
228 
229  virtual void changeCameraValues(SoCamera * camera);
230 
231  void addSuperimposition(SoNode * scene);
232  void removeSuperimposition(SoNode * scene);
233  void setSuperimpositionEnabled(SoNode * scene, const SbBool enable);
234  SbBool getSuperimpositionEnabled(SoNode * scene) const;
235 
236 private:
237  class SoQtViewerP * pimpl;
238  friend class SoQtViewerP;
239  friend class SoQtPlaneViewer;
240 };
241 
242 // *************************************************************************
243 
244 #endif // ! SOQT_VIEWER_H
Definition: SoQtViewer.h:108
Definition: SoQtViewer.h:95
BufferType
Definition: SoQtViewer.h:118
Definition: SoQtViewer.h:106
Definition: SoQtViewer.h:101
AutoClippingStrategy
Definition: SoQtViewer.h:124
virtual SoNode * getSceneGraph(void)
Definition: SoQtRenderArea.cpp:1018
virtual void actualRedraw(void)
Definition: SoQtRenderArea.cpp:1884
Definition: SoQtViewer.h:174
The SoQtViewer class is the top level base viewer class.
Definition: SoQtViewer.h:90
Definition: SoQtViewer.h:105
Definition: SoQtViewer.h:102
StereoType
Definition: SoQtViewer.h:172
DrawStyle
Definition: SoQtViewer.h:99
Type
Definition: SoQtViewer.h:94
virtual void setSceneGraph(SoNode *scene)
Definition: SoQtRenderArea.cpp:1006
virtual SbBool processSoEvent(const SoEvent *const event)
Definition: SoQtRenderArea.cpp:2136
The SoQtRenderArea class adds scenegraph handling and event management.
Definition: SoQtRenderArea.h:59
Definition: SoQtViewer.h:100
Definition: SoQtViewer.h:173
The SoQtPlaneViewer class is for examining 3D models by moving the camera in orthogonal planes...
Definition: SoQtPlaneViewer.h:42
Definition: SoQtViewer.h:119
Definition: SoQtViewer.h:120
virtual void setDoubleBuffer(const SbBool enable)
Definition: SoQtGLWidget.cpp:328
Definition: SoQtViewer.h:109
Definition: SoQtViewer.h:104
Definition: SoQtViewer.h:103
Definition: SoQtViewer.h:107
DrawType
Definition: SoQtViewer.h:113
virtual void sizeChanged(const SbVec2s &size)
Definition: SoQtRenderArea.cpp:1966
Definition: SoQtViewer.h:125