Coin Logo http://www.coin3d.org/
http://www.kongsberg.com/kogt/

SoQtGLWidget.h

00001 #ifndef SOQT_GLWIDGET_H
00002 #define SOQT_GLWIDGET_H
00003 
00004 // src/Inventor/Qt/SoQtGLWidget.h.  Generated from SoGuiGLWidget.h.in by configure.
00005 
00006 /**************************************************************************\
00007  * Copyright (c) Kongsberg Oil & Gas Technologies AS
00008  * All rights reserved.
00009  * 
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions are
00012  * met:
00013  * 
00014  * Redistributions of source code must retain the above copyright notice,
00015  * this list of conditions and the following disclaimer.
00016  * 
00017  * Redistributions in binary form must reproduce the above copyright
00018  * notice, this list of conditions and the following disclaimer in the
00019  * documentation and/or other materials provided with the distribution.
00020  * 
00021  * Neither the name of the copyright holder nor the names of its
00022  * contributors may be used to endorse or promote products derived from
00023  * this software without specific prior written permission.
00024  * 
00025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 \**************************************************************************/
00037 
00038 #include <Inventor/SbBasic.h>
00039 #include <Inventor/Qt/SoQtBasic.h>
00040 #include <Inventor/Qt/SoQtComponent.h>
00041 
00042 #ifdef __COIN_SOQT__
00043 class QEvent;
00044 #endif // __COIN_SOQT__
00045 #ifdef __COIN_SOXT__
00046 /*
00047  * GL/glx.h includes X11/Xmd.h which contains typedefs for BOOL and
00048  * INT32 that conflict with the definitions in windef.h (which is
00049  * included from windows.h, which may be included from
00050  * Inventor/system/gl.h).  To avoid this conflict, we rename the
00051  * typedefs done in X11/Xmd.h to use other names (tempbool and
00052  * tempint32), and try to clean up the hack after the header has been
00053  * parsed.  2003-06-25 larsa
00054  */
00055 #ifndef BOOL
00056 #define BOOL tempbool
00057 #define COIN_DEFINED_BOOL
00058 #endif /* !BOOL */
00059 #ifndef INT32
00060 #define INT32 tempint32
00061 #define COIN_DEFINED_INT32
00062 #endif /* !INT32 */
00063 #include <GL/glx.h>
00064 /*
00065  * This is the cleanup part of the X11/Xmd.h conflict fix hack set up
00066  * above.  2003-06-25 larsa
00067  */
00068 #ifdef COIN_DEFINED_BOOL
00069 #undef BOOL
00070 #undef COIN_DEFINED_BOOL
00071 #endif /* COIN_DEFINED_BOOL */
00072 #ifdef COIN_DEFINED_INT32
00073 #undef INT32
00074 #undef COIN_DEFINED_INT32
00075 #endif /* COIN_DEFINED_INT32 */
00076 #endif // __COIN_SOXT__
00077 #ifdef __COIN_SOGTK__
00078 #include <gtk/gtk.h>
00079 #endif // __COIN_SOGTK__
00080 
00081 // *************************************************************************
00082 
00083 enum GLModes {
00084   SO_GL_RGB      = 0x01, SO_GLX_RGB      = SO_GL_RGB,
00085   SO_GL_DOUBLE   = 0x02, SO_GLX_DOUBLE   = SO_GL_DOUBLE,
00086   SO_GL_ZBUFFER  = 0x04, SO_GLX_ZBUFFER  = SO_GL_ZBUFFER,
00087   SO_GL_OVERLAY  = 0x08, SO_GLX_OVERLAY  = SO_GL_OVERLAY,
00088   SO_GL_STEREO   = 0x10, SO_GLX_STEREO   = SO_GL_STEREO
00089 };
00090 
00091 // *************************************************************************
00092 
00093 class SOQT_DLL_API SoQtGLWidget : public SoQtComponent {
00094   SOQT_OBJECT_ABSTRACT_HEADER(SoQtGLWidget, SoQtComponent);
00095 
00096 public:
00097 
00098   void setBorder(const SbBool enable);
00099   SbBool isBorder(void) const;
00100 
00101   virtual void setDoubleBuffer(const SbBool enable);
00102   SbBool isDoubleBuffer(void) const;
00103 
00104   void setDrawToFrontBufferEnable(const SbBool enable);
00105   SbBool isDrawToFrontBufferEnable(void) const;
00106   
00107   void setQuadBufferStereo(const SbBool enable);
00108   SbBool isQuadBufferStereo(void) const;
00109 
00110   void setAccumulationBuffer(const SbBool enable);
00111   SbBool getAccumulationBuffer(void) const;
00112 
00113   void setStencilBuffer(const SbBool enable);
00114   SbBool getStencilBuffer(void) const;
00115 
00116   void setAlphaChannel(const SbBool enable);
00117   SbBool getAlphaChannel(void) const;
00118 
00119   void setOverlayRender(const SbBool onoff);
00120   SbBool isOverlayRender(void) const;
00121 
00122   void setSampleBuffers(const int numsamples);
00123   int getSampleBuffers(void) const;
00124 
00125   void setStealFocus(SbBool enable);
00126   SbBool isStealFocus(void) const;
00127 
00128   QWidget * getGLWidget(void) const;
00129   QWidget * getNormalWidget(void) const;
00130   QWidget * getOverlayWidget(void) const;
00131 
00132   SbBool hasOverlayGLArea(void) const;
00133   SbBool hasNormalGLArea(void) const;
00134 
00135   unsigned long getOverlayTransparentPixel(void);
00136 
00137   // OpenGL query functions.
00138   void getPointSizeLimits(SbVec2f & range, float & granularity);
00139   void getLineWidthLimits(SbVec2f & range, float & granularity);
00140 
00141 protected:
00142   SoQtGLWidget(QWidget * const parent = NULL,
00143                   const char * const name = NULL,
00144                   const SbBool embed = TRUE,
00145                   const int glmodes = SO_GL_RGB,
00146                   const SbBool build = TRUE);
00147   ~SoQtGLWidget();
00148 
00149   virtual void processEvent(QEvent * event);
00150 
00151   QWidget * buildWidget(QWidget * parent);
00152 
00153   virtual void redraw(void) = 0;
00154   virtual void redrawOverlay(void);
00155 
00156   virtual void initGraphic(void);
00157   virtual void initOverlayGraphic(void);
00158 
00159   virtual void sizeChanged(const SbVec2s & size);
00160   virtual void widgetChanged(QWidget * w);
00161 
00162   void setGLSize(const SbVec2s size);
00163   SbVec2s getGLSize(void) const;
00164   float getGLAspectRatio(void) const;
00165 
00166   // old aliases
00167   void setGlxSize(const SbVec2s size) { this->setGLSize(size); }
00168   SbVec2s getGlxSize(void) const { return this->getGLSize(); }
00169   float getGlxAspectRatio(void) const { return this->getGLAspectRatio(); }
00170 
00171   void setStereoBuffer(SbBool flag);
00172   SbBool isStereoBuffer(void) const;
00173 
00174   SbBool isRGBMode(void);
00175 
00176   SbBool waitForExpose;
00177   SbBool drawToFrontBuffer;
00178 
00179   void glLockNormal(void);
00180   void glUnlockNormal(void);
00181 
00182   void glLockOverlay(void);
00183   void glUnlockOverlay(void);
00184 
00185   void glSwapBuffers(void);
00186   void glFlushBuffer(void);
00187 
00188   virtual SbBool glScheduleRedraw(void);
00189 
00190 private:
00191   class SoQtGLWidgetP * pimpl;
00192   friend class SoGuiGLWidgetP;
00193   friend class SoQtGLWidgetP;
00194 
00195   // FIXME: get rid of toolkit-specific stuff below. 20020613 mortene.
00196 
00197 #ifdef __COIN_SOXT__
00198 public:
00199   GLXContext getNormalContext(void);
00200   GLXContext getOverlayContext(void);
00201 
00202   Window getNormalWindow(void);
00203   Window getOverlayWindow(void);
00204 
00205   int getOverlayColorMapSize(void);
00206   int getColorMapSize(void);
00207 
00208   virtual void setNormalVisual(XVisualInfo * visual);
00209   XVisualInfo * getNormalVisual(void);
00210   virtual void setOverlayVisual(XVisualInfo * visual);
00211   XVisualInfo * getOverlayVisual(void);
00212 
00213 protected:
00214   static void eventHandler(Widget, SoXtGLWidget *, XAnyEvent *, Boolean *);
00215 
00216   int getDisplayListShareGroup(GLXContext context);
00217   Widget getGlxMgrWidget(void);
00218 #endif // __COIN_SOXT__
00219 
00220 #ifdef __COIN_SOGTK__
00221 protected:
00222   virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
00223 #endif // __COIN_SOGTK__
00224 
00225 };
00226 
00227 // *************************************************************************
00228 
00229 #endif // ! SOQT_GLWIDGET_H

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

Generated on Mon Sep 7 11:22:57 2015 for SoQt by Doxygen 1.5.6.