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

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

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

Generated on Thu May 21 13:49:55 2009 for SoQt by Doxygen. 1.5.8