00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
#include <GL/glx.h>
00036
#endif // __COIN_SOXT__
00037
#ifdef __COIN_SOGTK__
00038
#include <gtk/gtk.h>
00039
#endif // __COIN_SOGTK__
00040
#ifdef __COIN_SOWIN__
00041
#include <windows.h>
00042
#endif // __COIN_SOWIN__
00043
00044
00045
00046
enum GLModes {
00047 SO_GL_RGB = 0x01, SO_GLX_RGB = SO_GL_RGB,
00048 SO_GL_DOUBLE = 0x02, SO_GLX_DOUBLE = SO_GL_DOUBLE,
00049 SO_GL_ZBUFFER = 0x04, SO_GLX_ZBUFFER = SO_GL_ZBUFFER,
00050 SO_GL_OVERLAY = 0x08, SO_GLX_OVERLAY = SO_GL_OVERLAY,
00051 SO_GL_STEREO = 0x10, SO_GLX_STEREO = SO_GL_STEREO
00052 };
00053
00054
00055
00056 class SOQT_DLL_API SoQtGLWidget :
public SoQtComponent {
00057 SOQT_OBJECT_ABSTRACT_HEADER(SoQtGLWidget,
SoQtComponent);
00058
00059
public:
00060
00061
void setBorder(
const SbBool enable);
00062 SbBool isBorder(
void)
const;
00063
00064
virtual void setDoubleBuffer(
const SbBool enable);
00065 SbBool isDoubleBuffer(
void)
const;
00066
00067
void setDrawToFrontBufferEnable(
const SbBool enable);
00068 SbBool isDrawToFrontBufferEnable(
void)
const;
00069
00070
void setQuadBufferStereo(
const SbBool enable);
00071 SbBool isQuadBufferStereo(
void)
const;
00072
00073
void setAccumulationBuffer(
const SbBool enable);
00074 SbBool getAccumulationBuffer(
void)
const;
00075
00076
void setStencilBuffer(
const SbBool enable);
00077 SbBool getStencilBuffer(
void)
const;
00078
00079
void setOverlayRender(
const SbBool onoff);
00080 SbBool isOverlayRender(
void)
const;
00081
00082 QWidget * getGLWidget(
void)
const;
00083 QWidget * getNormalWidget(
void)
const;
00084 QWidget * getOverlayWidget(
void)
const;
00085
00086 SbBool hasOverlayGLArea(
void)
const;
00087 SbBool hasNormalGLArea(
void)
const;
00088
00089
unsigned long getOverlayTransparentPixel(
void);
00090
00091
00092
void getPointSizeLimits(SbVec2f & range,
float & granularity);
00093
void getLineWidthLimits(SbVec2f & range,
float & granularity);
00094
00095
protected:
00096 SoQtGLWidget(QWidget *
const parent = NULL,
00097
const char *
const name = NULL,
00098
const SbBool embed = TRUE,
00099
const int glmodes = SO_GL_RGB,
00100
const SbBool build = TRUE);
00101 ~SoQtGLWidget();
00102
00103
virtual void processEvent(QEvent * event);
00104
00105 QWidget * buildWidget(QWidget * parent);
00106
00107
virtual void redraw(
void) = 0;
00108
virtual void redrawOverlay(
void);
00109
00110
virtual void initGraphic(
void);
00111
virtual void initOverlayGraphic(
void);
00112
00113
virtual void sizeChanged(
const SbVec2s & size);
00114
virtual void widgetChanged(QWidget * w);
00115
00116
void setGLSize(
const SbVec2s size);
00117 SbVec2s getGLSize(
void)
const;
00118
float getGLAspectRatio(
void)
const;
00119
00120
00121 void setGlxSize(
const SbVec2s size) { this->setGLSize(size); }
00122 SbVec2s getGlxSize(
void)
const {
return this->getGLSize(); }
00123 float getGlxAspectRatio(
void)
const {
return this->getGLAspectRatio(); }
00124
00125
void setStereoBuffer(SbBool flag);
00126 SbBool isStereoBuffer(
void) const;
00127
00128 SbBool isRGBMode(
void);
00129
00130 SbBool waitForExpose;
00131 SbBool drawToFrontBuffer;
00132
00133
void glLockNormal(
void);
00134
void glUnlockNormal(
void);
00135
00136
void glLockOverlay(
void);
00137
void glUnlockOverlay(
void);
00138
00139
void glSwapBuffers(
void);
00140
void glFlushBuffer(
void);
00141
00142 virtual SbBool glScheduleRedraw(
void);
00143
00144 private:
00145 class SoQtGLWidgetP * pimpl;
00146 #ifndef DOXYGEN_SKIP_THIS
00147 friend class SoGuiGLWidgetP;
00148 friend class SoQtGLWidgetP;
00149 #endif
00150
00151
00152
00153 #ifdef __COIN_SOXT__
00154 public:
00155 Window getNormalWindow(
void);
00156 Window getOverlayWindow(
void);
00157
00158
int getOverlayColorMapSize(
void);
00159
int getColorMapSize(
void);
00160
00161 virtual
void setNormalVisual(XVisualInfo * visual);
00162 XVisualInfo * getNormalVisual(
void);
00163 virtual
void setOverlayVisual(XVisualInfo * visual);
00164 XVisualInfo * getOverlayVisual(
void);
00165
00166 protected:
00167
int getDisplayListShareGroup(GLXContext context);
00168 Widget getGlxMgrWidget(
void);
00169 #endif
00170 #ifdef __COIN_SOWIN__
00171 public:
00172 HWND getNormalWindow(
void) const;
00173 HWND getOverlayWindow(
void) const;
00174 HDC getNormalDC(
void) const;
00175 HDC getOverlayDC(
void) const;
00176
00177
void setStealFocus(SbBool doStealFocus);
00178
00179 virtual
void setNormalVisual(PIXELFORMATDESCRIPTOR * vis);
00180 PIXELFORMATDESCRIPTOR * getNormalVisual(
void);
00181 virtual
void setOverlayVisual(PIXELFORMATDESCRIPTOR * vis);
00182 PIXELFORMATDESCRIPTOR * getOverlayVisual(
void);
00183 virtual
void setPixelFormat(
int format);
00184
int getPixelFormat(
void);
00185 #endif
00186
00187 #ifdef __COIN_SOGTK__
00188 protected:
00189 virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
00190 #endif
00191 };
00192
00193
00194
00195 #endif