Coin Logo http://www.sim.no
http://www.coin3d.org

SoQtGLWidget.h
1 #ifndef SOQT_GLWIDGET_H
2 #define SOQT_GLWIDGET_H
3 
4 // src/Inventor/Qt/SoQtGLWidget.h. Generated from SoGuiGLWidget.h.in by configure.
5 
6 /**************************************************************************\
7  *
8  * This file is part of the Coin 3D visualization library.
9  * Copyright (C) by Kongsberg Oil & Gas Technologies.
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * ("GPL") version 2 as published by the Free Software Foundation.
14  * See the file LICENSE.GPL at the root directory of this source
15  * distribution for additional information about the GNU GPL.
16  *
17  * For using Coin with software that can not be combined with the GNU
18  * GPL, and for taking advantage of the additional benefits of our
19  * support services, please contact Kongsberg Oil & Gas Technologies
20  * about acquiring a Coin Professional Edition License.
21  *
22  * See http://www.coin3d.org/ for more information.
23  *
24  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
25  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
26  *
27 \**************************************************************************/
28 
29 #include <Inventor/SbBasic.h>
30 #include <Inventor/Qt/SoQtBasic.h>
31 #include <Inventor/Qt/SoQtComponent.h>
32 
33 #ifdef __COIN_SOQT__
34 class QEvent;
35 #endif // __COIN_SOQT__
36 #ifdef __COIN_SOXT__
37 /*
38  * GL/glx.h includes X11/Xmd.h which contains typedefs for BOOL and
39  * INT32 that conflict with the definitions in windef.h (which is
40  * included from windows.h, which may be included from
41  * Inventor/system/gl.h). To avoid this conflict, we rename the
42  * typedefs done in X11/Xmd.h to use other names (tempbool and
43  * tempint32), and try to clean up the hack after the header has been
44  * parsed. 2003-06-25 larsa
45  */
46 #ifndef BOOL
47 #define BOOL tempbool
48 #define COIN_DEFINED_BOOL
49 #endif /* !BOOL */
50 #ifndef INT32
51 #define INT32 tempint32
52 #define COIN_DEFINED_INT32
53 #endif /* !INT32 */
54 #include <GL/glx.h>
55 /*
56  * This is the cleanup part of the X11/Xmd.h conflict fix hack set up
57  * above. 2003-06-25 larsa
58  */
59 #ifdef COIN_DEFINED_BOOL
60 #undef BOOL
61 #undef COIN_DEFINED_BOOL
62 #endif /* COIN_DEFINED_BOOL */
63 #ifdef COIN_DEFINED_INT32
64 #undef INT32
65 #undef COIN_DEFINED_INT32
66 #endif /* COIN_DEFINED_INT32 */
67 #endif // __COIN_SOXT__
68 #ifdef __COIN_SOGTK__
69 #include <gtk/gtk.h>
70 #endif // __COIN_SOGTK__
71 
72 // *************************************************************************
73 
74 enum GLModes {
75  SO_GL_RGB = 0x01, SO_GLX_RGB = SO_GL_RGB,
76  SO_GL_DOUBLE = 0x02, SO_GLX_DOUBLE = SO_GL_DOUBLE,
77  SO_GL_ZBUFFER = 0x04, SO_GLX_ZBUFFER = SO_GL_ZBUFFER,
78  SO_GL_OVERLAY = 0x08, SO_GLX_OVERLAY = SO_GL_OVERLAY,
79  SO_GL_STEREO = 0x10, SO_GLX_STEREO = SO_GL_STEREO
80 };
81 
82 // *************************************************************************
83 
84 class SOQT_DLL_API SoQtGLWidget : public SoQtComponent {
85  SOQT_OBJECT_ABSTRACT_HEADER(SoQtGLWidget, SoQtComponent);
86 
87 public:
88 
89  void setBorder(const SbBool enable);
90  SbBool isBorder(void) const;
91 
92  virtual void setDoubleBuffer(const SbBool enable);
93  SbBool isDoubleBuffer(void) const;
94 
95  void setDrawToFrontBufferEnable(const SbBool enable);
96  SbBool isDrawToFrontBufferEnable(void) const;
97 
98  void setQuadBufferStereo(const SbBool enable);
99  SbBool isQuadBufferStereo(void) const;
100 
101  void setAccumulationBuffer(const SbBool enable);
102  SbBool getAccumulationBuffer(void) const;
103 
104  void setStencilBuffer(const SbBool enable);
105  SbBool getStencilBuffer(void) const;
106 
107  void setAlphaChannel(const SbBool enable);
108  SbBool getAlphaChannel(void) const;
109 
110  void setOverlayRender(const SbBool onoff);
111  SbBool isOverlayRender(void) const;
112 
113  void setSampleBuffers(const int numsamples);
114  int getSampleBuffers(void) const;
115 
116  void setStealFocus(SbBool enable);
117  SbBool isStealFocus(void) const;
118 
119  QWidget * getGLWidget(void) const;
120  QWidget * getNormalWidget(void) const;
121  QWidget * getOverlayWidget(void) const;
122 
123  SbBool hasOverlayGLArea(void) const;
124  SbBool hasNormalGLArea(void) const;
125 
126  unsigned long getOverlayTransparentPixel(void);
127 
128  // OpenGL query functions.
129  void getPointSizeLimits(SbVec2f & range, float & granularity);
130  void getLineWidthLimits(SbVec2f & range, float & granularity);
131 
132 protected:
133  SoQtGLWidget(QWidget * const parent = NULL,
134  const char * const name = NULL,
135  const SbBool embed = TRUE,
136  const int glmodes = SO_GL_RGB,
137  const SbBool build = TRUE);
138  ~SoQtGLWidget();
139 
140  virtual void processEvent(QEvent * event);
141 
142  QWidget * buildWidget(QWidget * parent);
143 
144  virtual void redraw(void) = 0;
145  virtual void redrawOverlay(void);
146 
147  virtual void initGraphic(void);
148  virtual void initOverlayGraphic(void);
149 
150  virtual void sizeChanged(const SbVec2s & size);
151  virtual void widgetChanged(QWidget * w);
152 
153  void setGLSize(const SbVec2s size);
154  SbVec2s getGLSize(void) const;
155  float getGLAspectRatio(void) const;
156 
157  // old aliases
158  void setGlxSize(const SbVec2s size) { this->setGLSize(size); }
159  SbVec2s getGlxSize(void) const { return this->getGLSize(); }
160  float getGlxAspectRatio(void) const { return this->getGLAspectRatio(); }
161 
162  void setStereoBuffer(SbBool flag);
163  SbBool isStereoBuffer(void) const;
164 
165  SbBool isRGBMode(void);
166 
169 
170  void glLockNormal(void);
171  void glUnlockNormal(void);
172 
173  void glLockOverlay(void);
174  void glUnlockOverlay(void);
175 
176  void glSwapBuffers(void);
177  void glFlushBuffer(void);
178 
179  virtual SbBool glScheduleRedraw(void);
180 
181 private:
182  class SoQtGLWidgetP * pimpl;
183  friend class SoGuiGLWidgetP;
184  friend class SoQtGLWidgetP;
185 
186  // FIXME: get rid of toolkit-specific stuff below. 20020613 mortene.
187 
188 #ifdef __COIN_SOXT__
189 public:
190  GLXContext getNormalContext(void);
191  GLXContext getOverlayContext(void);
192 
193  Window getNormalWindow(void);
194  Window getOverlayWindow(void);
195 
196  int getOverlayColorMapSize(void);
197  int getColorMapSize(void);
198 
199  virtual void setNormalVisual(XVisualInfo * visual);
200  XVisualInfo * getNormalVisual(void);
201  virtual void setOverlayVisual(XVisualInfo * visual);
202  XVisualInfo * getOverlayVisual(void);
203 
204 protected:
205  static void eventHandler(Widget, SoXtGLWidget *, XAnyEvent *, Boolean *);
206 
207  int getDisplayListShareGroup(GLXContext context);
208  Widget getGlxMgrWidget(void);
209 #endif // __COIN_SOXT__
210 
211 #ifdef __COIN_SOGTK__
212 protected:
213  virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
214 #endif // __COIN_SOGTK__
215 
216 };
217 
218 // *************************************************************************
219 
220 #endif // ! SOQT_GLWIDGET_H
SbBool drawToFrontBuffer
Definition: SoQtGLWidget.h:168
The SoQtComponent class is the base class for all GUI components.
Definition: SoQtComponent.h:54
float getGlxAspectRatio(void) const
Definition: SoQtGLWidget.h:160
SbVec2s getGlxSize(void) const
Definition: SoQtGLWidget.h:159
SbBool waitForExpose
Definition: SoQtGLWidget.h:167
The SoQtGLWidget class manages OpenGL contexts.This is the basic, abstract component class which sets...
Definition: SoQtGLWidget.h:84
virtual void sizeChanged(const SbVec2s &size)
Definition: SoQtComponent.cpp:868
void setGlxSize(const SbVec2s size)
Definition: SoQtGLWidget.h:158

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Thu Oct 13 2016 for SoQt by Doxygen 1.8.5.