00001 #ifndef GLWIDGET_H
00002 #define GLWIDGET_H
00003
00004 #define GL_GLEXT_PROTOTYPES
00005 #include <GL/glew.h>
00006 #include <QGLWidget>
00007 #include <GL/glext.h>
00008 #include "Volume.h"
00009 #include "gradienteditor.h"
00010
00014 class GLWidget : public QGLWidget
00015 {
00016 Q_OBJECT
00017
00018 public:
00019 GLWidget(QWidget *parent = 0);
00020 ~GLWidget();
00021
00022 QSize minimumSizeHint() const;
00023 QSize sizeHint() const;
00024 void setVolume(Volume *newVolume);
00025 void setColorsPtr(unsigned int* colorsPtr);
00026
00027 public slots:
00028 void setXRotation(int angle);
00029 void setYRotation(int angle);
00030 void setZRotation(int angle);
00031 void setLength(int length);
00032 void setWidth(int width);
00033 void setDepth(int depth);
00034 void setColors();
00035 void setRenderMode(bool mode);
00036
00037
00038 signals:
00043 void xRotationChanged(int angle);
00048 void yRotationChanged(int angle);
00053 void zRotationChanged(int angle);
00054
00055 protected:
00056 void initializeGL();
00057 void paintGL();
00058 void resizeGL(int width, int height);
00059 void mousePressEvent(QMouseEvent *event);
00060 void mouseReleaseEvent(QMouseEvent *event);
00061 void mouseMoveEvent(QMouseEvent *event);
00062 void wheelEvent(QWheelEvent *event);
00063
00064 private:
00065 void drawSlice();
00066 void normalizeAngle(int *angle);
00067 void buildTexture(void);
00068 char *file2string(const std::string & strFilename);
00069 GLuint loadShader(const std::string & strFilename);
00070 void printLog(GLuint obj);
00071 void setVertexProp(float s, float t, float p);
00072 void renderBoundingBox();
00073 void genTransferTexture();
00074 void initBackfaceBuffer();
00075 void updateRelVolSize();
00076
00077
00078 Volume *volume;
00079 unsigned int* colors;
00080 GLuint volumeTextureId;
00081 GLuint transferTextureId;
00082 GLuint framebuffer;
00083 GLuint backfaceTextureId;
00084 GLuint raycastShader;
00085 GLuint sliceShader;
00086 int xRot;
00087 int yRot;
00088 int zRot;
00089 float distance;
00090 float lengthf;
00091 float widthf;
00092 float depthf;
00093 int *volSize;
00094 float *relVolSize;
00095 int renderMode;
00096 int raySteps;
00097 QPoint lastPos;
00098 };
00099
00100 #endif