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

Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members

SoQtGLWidget.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2004 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, Teknobyen, Abels Gate 5, 7030 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   QWidget * getGLWidget(void) const;
00112   QWidget * getNormalWidget(void) const;
00113   QWidget * getOverlayWidget(void) const;
00114 
00115   SbBool hasOverlayGLArea(void) const;
00116   SbBool hasNormalGLArea(void) const;
00117 
00118   unsigned long getOverlayTransparentPixel(void);
00119 
00120   // OpenGL query functions.
00121   void getPointSizeLimits(SbVec2f & range, float & granularity);
00122   void getLineWidthLimits(SbVec2f & range, float & granularity);
00123 
00124 protected:
00125   SoQtGLWidget(QWidget * const parent = NULL,
00126                   const char * const name = NULL,
00127                   const SbBool embed = TRUE,
00128                   const int glmodes = SO_GL_RGB,
00129                   const SbBool build = TRUE);
00130   ~SoQtGLWidget();
00131 
00132   virtual void processEvent(QEvent * event);
00133 
00134   QWidget * buildWidget(QWidget * parent);
00135 
00136   virtual void redraw(void) = 0;
00137   virtual void redrawOverlay(void);
00138 
00139   virtual void initGraphic(void);
00140   virtual void initOverlayGraphic(void);
00141 
00142   virtual void sizeChanged(const SbVec2s & size);
00143   virtual void widgetChanged(QWidget * w);
00144 
00145   void setGLSize(const SbVec2s size);
00146   SbVec2s getGLSize(void) const;
00147   float getGLAspectRatio(void) const;
00148 
00149   // old aliases
00150   void setGlxSize(const SbVec2s size) { this->setGLSize(size); }
00151   SbVec2s getGlxSize(void) const { return this->getGLSize(); }
00152   float getGlxAspectRatio(void) const { return this->getGLAspectRatio(); }
00153 
00154   void setStereoBuffer(SbBool flag);
00155   SbBool isStereoBuffer(void) const;
00156 
00157   SbBool isRGBMode(void);
00158 
00159   SbBool waitForExpose;
00160   SbBool drawToFrontBuffer;
00161 
00162   void glLockNormal(void);
00163   void glUnlockNormal(void);
00164 
00165   void glLockOverlay(void);
00166   void glUnlockOverlay(void);
00167 
00168   void glSwapBuffers(void);
00169   void glFlushBuffer(void);
00170 
00171   virtual SbBool glScheduleRedraw(void);
00172 
00173 private:
00174   class SoQtGLWidgetP * pimpl;
00175   friend class SoGuiGLWidgetP;
00176   friend class SoQtGLWidgetP;
00177 
00178   // FIXME: get rid of toolkit-specific stuff below. 20020613 mortene.
00179 
00180 #ifdef __COIN_SOXT__
00181 public:
00182   GLXContext getNormalContext(void);
00183   GLXContext getOverlayContext(void);
00184 
00185   Window getNormalWindow(void);
00186   Window getOverlayWindow(void);
00187 
00188   int getOverlayColorMapSize(void);
00189   int getColorMapSize(void);
00190 
00191   virtual void setNormalVisual(XVisualInfo * visual);
00192   XVisualInfo * getNormalVisual(void);
00193   virtual void setOverlayVisual(XVisualInfo * visual);
00194   XVisualInfo * getOverlayVisual(void);
00195 
00196 protected:
00197   static void eventHandler(Widget, SoXtGLWidget *, XAnyEvent *, Boolean *);
00198 
00199   int getDisplayListShareGroup(GLXContext context);
00200   Widget getGlxMgrWidget(void);
00201 #endif // __COIN_SOXT__
00202 
00203 #ifdef __COIN_SOGTK__
00204 protected:
00205   virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
00206 #endif // __COIN_SOGTK__
00207 };
00208 
00209 // *************************************************************************
00210 
00211 #endif // ! SOQT_GLWIDGET_H

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

Generated on Wed Jun 22 15:22:22 2005 for SoQt by Doxygen. 1.4.3-20050530