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 <algorithm> 00009 #include <math.h> 00010 #include <queue> 00011 #include "FlowData.h" 00012 #include "gradienteditor.h" 00013 00017 class GLWidget : public QGLWidget 00018 { 00019 Q_OBJECT 00020 00021 public: 00022 GLWidget(QWidget *parent = 0); 00023 ~GLWidget(); 00024 00025 QSize minimumSizeHint() const; 00026 QSize sizeHint() const; 00027 void setFlowData(FlowData *newFlowData); 00028 void setBackgroundColorsPtr(QRgb* colorsPtr); 00029 void setArrowColorsPtr(QRgb* colorsPtr); 00030 void setStreamlineColorsPtr(QRgb* colorsPtr); 00031 00032 public slots: 00033 void setBackgroundColors(); 00034 void setArrowColors(); 00035 void setStreamlineColors(); 00036 void setDrawBackground(bool state); 00037 void setBackgroundColorChannel(int channel); 00038 void setDrawArrows(bool state); 00039 void setArrowQuantity(int quantity); 00040 void setArrowColorChannel(int channel); 00041 void setDrawStreamlines(bool state); 00042 void setStreamlineMode(int mode); 00043 void setStreamlineDtest(int newDtest); 00044 void setStreamlineDsep(int newDsep); 00045 void setStreamlineDt(int newDt); 00046 void setStreamlinePeriod(int Period); 00047 void setStreamlineLineMode(int mode); 00048 void setStreamlineColorChannel(int channel); 00049 00050 signals: 00051 00052 protected: 00053 void initializeGL(); 00054 void paintGL(); 00055 void resizeGL(int width, int height); 00056 void mousePressEvent(QMouseEvent *event); 00057 void mouseReleaseEvent(QMouseEvent *event); 00058 void mouseMoveEvent(QMouseEvent *event); 00059 void wheelEvent(QWheelEvent *event); 00060 00061 private: 00062 void draw(); 00063 void normalizeAngle(int *angle); 00064 void buildTexture(void); 00065 char *file2string(const std::string & strFilename); 00066 GLuint loadShader(const std::string & strFilename); 00067 void printLog(GLuint obj); 00068 void drawArrowPlot(const int xScaler, const int yScaler); 00069 void calcEuler(float x, float y); 00070 void calcRunge(float x, float y); 00071 void calculateBackground(); 00072 void drawStreamline(int mode); 00073 bool testRange(vec3 point); 00074 bool testCell(int cellx, int celly, vec3 point); 00075 float getTapering(vec3 point, vector<vec3> line, unsigned int i); 00076 float testCellTapering(int cellx, int celly, vec3 point, vector<vec3> line, unsigned int i); 00077 bool testSLDist(vec3 point, vector<vec3> line, unsigned int i); 00078 void calculateEvenStreamlines(); 00079 void addPoint2Grid(vec3 point); 00080 void calcStartCandidates(vec3 pos); 00081 void initStreamlines(); 00082 void removeLastPointfromCell(vec3 point); 00083 00084 00085 float flowDataWidthRatio; 00086 float flowDataHeightRatio; 00087 bool drawBackground; 00088 int backgroundColorChannel; 00089 bool drawArrows; 00090 int arrowQuantity; 00091 int arrowColorChannel; 00092 bool drawStreamlines; 00093 float dtest_factor; 00094 float dt_factor; 00095 int streamlineLineMode; 00096 int streamlineColorChannel; 00097 QRgb* backgroundColors; 00098 QRgb* arrowColors; 00099 QRgb* streamlineColors; 00100 FlowData* dataset; 00101 vector<vector<vec3> > streamlines; 00102 vector<vector<vec3> > pointgrid; 00103 queue<vec3> startCandidates; 00104 float dsep; 00105 float dtest; 00106 float dt; 00107 float cellSize; 00108 int gridSize[2]; 00109 int cells; 00110 int period; 00111 bool integrationMode; 00112 00113 GLuint channelTextureId; 00114 }; 00115 00116 #endif