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

SoQtGLWidget.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2005 by Systems in Motion.  All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  ("GPL") version 2 as published by the Free Software Foundation.
00009  *  See the file LICENSE.GPL at the root directory of this source
00010  *  distribution for additional information about the GNU GPL.
00011  *
00012  *  For using Coin with software that can not be combined with the GNU
00013  *  GPL, and for taking advantage of the additional benefits of our
00014  *  support services, please contact Systems in Motion about acquiring
00015  *  a Coin Professional Edition License.
00016  *
00017  *  See <URL:http://www.coin3d.org/> for more information.
00018  *
00019  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00020  *  <URL:http://www.sim.no/>.
00021  *
00022 \**************************************************************************/
00023 
00024 #ifndef SOQT_GLWIDGET_H
00025 #define SOQT_GLWIDGET_H
00026 
00027 #include <Inventor/SbBasic.h>
00028 #include <Inventor/Qt/SoQtBasic.h>
00029 #include <Inventor/Qt/SoQtComponent.h>
00030 
00031 #ifdef __COIN_SOQT__
00032 class QEvent;
00033 #endif // __COIN_SOQT__
00034 #ifdef __COIN_SOXT__
00035 /*
00036  * GL/glx.h includes X11/Xmd.h which contains typedefs for BOOL and
00037  * INT32 that conflict with the definitions in windef.h (which is
00038  * included from windows.h, which may be included from
00039  * Inventor/system/gl.h).  To avoid this conflict, we rename the
00040  * typedefs done in X11/Xmd.h to use other names (tempbool and
00041  * tempint32), and try to clean up the hack after the header has been
00042  * parsed.  2003-06-25 larsa
00043  */
00044 #ifndef BOOL
00045 #define BOOL tempbool
00046 #define COIN_DEFINED_BOOL
00047 #endif /* !BOOL */
00048 #ifndef INT32
00049 #define INT32 tempint32
00050 #define COIN_DEFINED_INT32
00051 #endif /* !INT32 */
00052 #include <GL/glx.h>
00053 /*
00054  * This is the cleanup part of the X11/Xmd.h conflict fix hack set up
00055  * above.  2003-06-25 larsa
00056  */
00057 #ifdef COIN_DEFINED_BOOL
00058 #undef BOOL
00059 #undef COIN_DEFINED_BOOL
00060 #endif /* COIN_DEFINED_BOOL */
00061 #ifdef COIN_DEFINED_INT32
00062 #undef INT32
00063 #undef COIN_DEFINED_INT32
00064 #endif /* COIN_DEFINED_INT32 */
00065 #endif // __COIN_SOXT__
00066 #ifdef __COIN_SOGTK__
00067 #include <gtk/gtk.h>
00068 #endif // __COIN_SOGTK__
00069 
00070 // *************************************************************************
00071 
00072 enum GLModes {
00073   SO_GL_RGB      = 0x01, SO_GLX_RGB      = SO_GL_RGB,
00074   SO_GL_DOUBLE   = 0x02, SO_GLX_DOUBLE   = SO_GL_DOUBLE,
00075   SO_GL_ZBUFFER  = 0x04, SO_GLX_ZBUFFER  = SO_GL_ZBUFFER,
00076   SO_GL_OVERLAY  = 0x08, SO_GLX_OVERLAY  = SO_GL_OVERLAY,
00077   SO_GL_STEREO   = 0x10, SO_GLX_STEREO   = SO_GL_STEREO
00078 };
00079 
00080 // *************************************************************************
00081 
00082 class SOQT_DLL_API SoQtGLWidget : public SoQtComponent {
00083   SOQT_OBJECT_ABSTRACT_HEADER(SoQtGLWidget, SoQtComponent);
00084 
00085 public:
00086 
00087   void setBorder(const SbBool enable);
00088   SbBool isBorder(void) const;
00089 
00090   virtual void setDoubleBuffer(const SbBool enable);
00091   SbBool isDoubleBuffer(void) const;
00092 
00093   void setDrawToFrontBufferEnable(const SbBool enable);
00094   SbBool isDrawToFrontBufferEnable(void) const;
00095   
00096   void setQuadBufferStereo(const SbBool enable);
00097   SbBool isQuadBufferStereo(void) const;
00098 
00099   void setAccumulationBuffer(const SbBool enable);
00100   SbBool getAccumulationBuffer(void) const;
00101 
00102   void setStencilBuffer(const SbBool enable);
00103   SbBool getStencilBuffer(void) const;
00104 
00105   void setAlphaChannel(const SbBool enable);
00106   SbBool getAlphaChannel(void) const;
00107 
00108   void setOverlayRender(const SbBool onoff);
00109   SbBool isOverlayRender(void) const;
00110 
00111   void setStealFocus(SbBool enable);
00112   SbBool isStealFocus(void) const;
00113 
00114   QWidget * getGLWidget(void) const;
00115   QWidget * getNormalWidget(void) const;
00116   QWidget * getOverlayWidget(void) const;
00117 
00118   SbBool hasOverlayGLArea(void) const;
00119   SbBool hasNormalGLArea(void) const;
00120 
00121   unsigned long getOverlayTransparentPixel(void);
00122 
00123   // OpenGL query functions.
00124   void getPointSizeLimits(SbVec2f & range, float & granularity);
00125   void getLineWidthLimits(SbVec2f & range, float & granularity);
00126 
00127 protected:
00128   SoQtGLWidget(QWidget * const parent = NULL,
00129                   const char * const name = NULL,
00130                   const SbBool embed = TRUE,
00131                   const int glmodes = SO_GL_RGB,
00132                   const SbBool build = TRUE);
00133   ~SoQtGLWidget();
00134 
00135   virtual void processEvent(QEvent * event);
00136 
00137   QWidget * buildWidget(QWidget * parent);
00138 
00139   virtual void redraw(void) = 0;
00140   virtual void redrawOverlay(void);
00141 
00142   virtual void initGraphic(void);
00143   virtual void initOverlayGraphic(void);
00144 
00145   virtual void sizeChanged(const SbVec2s & size);
00146   virtual void widgetChanged(QWidget * w);
00147 
00148   void setGLSize(const SbVec2s size);
00149   SbVec2s getGLSize(void) const;
00150   float getGLAspectRatio(void) const;
00151 
00152   // old aliases
00153   void setGlxSize(const SbVec2s size) { this->setGLSize(size); }
00154   SbVec2s getGlxSize(void) const { return this->getGLSize(); }
00155   float getGlxAspectRatio(void) const { return this->getGLAspectRatio(); }
00156 
00157   void setStereoBuffer(SbBool flag);
00158   SbBool isStereoBuffer(void) const;
00159 
00160   SbBool isRGBMode(void);
00161 
00162   SbBool waitForExpose;
00163   SbBool drawToFrontBuffer;
00164 
00165   void glLockNormal(void);
00166   void glUnlockNormal(void);
00167 
00168   void glLockOverlay(void);
00169   void glUnlockOverlay(void);
00170 
00171   void glSwapBuffers(void);
00172   void glFlushBuffer(void);
00173 
00174   virtual SbBool glScheduleRedraw(void);
00175 
00176 private:
00177   class SoQtGLWidgetP * pimpl;
00178   friend class SoGuiGLWidgetP;
00179   friend class SoQtGLWidgetP;
00180 
00181   // FIXME: get rid of toolkit-specific stuff below. 20020613 mortene.
00182 
00183 #ifdef __COIN_SOXT__
00184 public:
00185   GLXContext getNormalContext(void);
00186   GLXContext getOverlayContext(void);
00187 
00188   Window getNormalWindow(void);
00189   Window getOverlayWindow(void);
00190 
00191   int getOverlayColorMapSize(void);
00192   int getColorMapSize(void);
00193 
00194   virtual void setNormalVisual(XVisualInfo * visual);
00195   XVisualInfo * getNormalVisual(void);
00196   virtual void setOverlayVisual(XVisualInfo * visual);
00197   XVisualInfo * getOverlayVisual(void);
00198 
00199 protected:
00200   static void eventHandler(Widget, SoXtGLWidget *, XAnyEvent *, Boolean *);
00201 
00202   int getDisplayListShareGroup(GLXContext context);
00203   Widget getGlxMgrWidget(void);
00204 #endif // __COIN_SOXT__
00205 
00206 #ifdef __COIN_SOGTK__
00207 protected:
00208   virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
00209 #endif // __COIN_SOGTK__
00210 
00211 };
00212 
00213 // *************************************************************************
00214 
00215 #endif // ! SOQT_GLWIDGET_H

Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.

Generated on Wed May 9 11:46:57 2007 for SoQt by Doxygen. 1.5.1