00001
00002 #ifndef GLWIDGET_H
00003 #define GLWIDGET_H
00004
00005 #ifndef NOMINMAX
00006 #define NOMINMAX
00007 #endif
00008
00009 #include <QtOpenGL/qgl.h>
00010 #include <math.h>
00011 #include "volume.h"
00012 #include "color.h"
00013 #include "histogrampoint.h"
00014
00016 class GLWidget : public QGLWidget
00017 {
00018 Q_OBJECT
00019
00020 public:
00021 GLWidget(QWidget *parent = 0);
00022 ~GLWidget();
00023
00024 QSize minimumSizeHint() const;
00025 QSize sizeHint() const;
00026
00027 Volume *GLWidget::loadVolumne(std::string file);
00028 int getSlicesCount();
00029 void generateColorTexture(std::vector<HistogramPoint> *points, int width, int height);
00030 void createShaderForSlices();
00031 void saveImage();
00033
00035 public slots:
00036
00037 void setSlicing(bool checked);
00038 void setXAxis();
00039 void setYAxis();
00040 void setZAxis();
00041 void setSlice(int slice);
00042 void setMinDensity(int value) {m_min_density = value; this->update();};
00043 void setMaxDensity(int value) {m_max_density = value; this->update();};
00044 void setCompositeMode() {m_mode = 0; this->update();};
00045 void setAverageMode() {m_mode = 1; this->update();};
00046 void setMIPMode() {m_mode = 2; this->update();};
00047
00048 signals:
00049 void xRotationChanged(int angle);
00050 void yRotationChanged(int angle);
00051 void zRotationChanged(int angle);
00053
00055 protected:
00056 void initializeGL();
00057 void paintGL();
00058 void resizeGL(int width, int height);
00059 void mousePressEvent(QMouseEvent *event);
00060 void mouseMoveEvent(QMouseEvent *event);
00062
00064 private:
00065 GLuint makeObject();
00066 void quad(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2,
00067 GLdouble x3, GLdouble y3, GLdouble x4, GLdouble y4);
00068 void extrude(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
00069 void normalizeAngle(int *angle);
00070 void refreshSlices();
00071 char *textFileRead(char *fn);
00072 int GetNextPowerOfTwo(const int iNumber);
00073 void refreshRaycast();
00074 void drawBoundingBox();
00075
00076 int m_active_axis;
00077 bool m_slicing_active;
00078 bool m_colorMapLoaded;
00079 std::vector<Volume::Voxel> m_toDraw;
00080 GLuint m_slicingTexture[2];
00081 float m_slice_index;
00082 Volume m_Volume;
00083 int m_iWidth, m_iHeight;
00084 std::vector<Color> m_transferColors;
00085 GLuint m_fSlices, m_vSlices, m_pSlices;
00086 GLuint m_fFBO, m_vFBO,m_pFBO;
00087 GLuint m_fraycast, m_vraycast,m_praycast;
00088 GLuint m_front_back_Texture[2];
00089 GLuint m_front_back_FBO[2];
00090 int m_min_density;
00091 int m_max_density;
00092 int m_xRot;
00093 int m_yRot;
00094 QPoint m_lastPos;
00095 int m_mode;
00096
00097 GLuint object;
00098 int zRot;
00099
00100 QColor trolltechGreen;
00101 QColor trolltechPurple;
00102
00103 };
00105
00106 #endif