00001 #ifndef __RENDERER_WIDGET__
00002 #define __RENDERER_WIDGET__
00003
00004 #include <queue>
00005
00006 #include <GL/glew.h>
00007
00008 #include <QtOpenGL/QGLWidget>
00009 #include <QtGui/QColor>
00010 #include <QtGui/QMessageBox>
00011
00012 #include <QtGui/QMouseEvent>
00013 #include <QtGui/QWheelEvent>
00014
00015 #include "GLext.h"
00016 #include <gl/glut.h>
00017 #include <assert.h>
00018 #include "logger.h"
00019 #include "histogram.h"
00020 #include "integration.h"
00021
00022 #include <Cg/cg.h>
00023 #include <Cg/cgGL.h>
00024
00025 #include "FVF/FlowData.h"
00026
00027 #include "FlowGrid.h"
00028 #include "reggrid.h"
00029
00030 #include "settings.h"
00031 #include "streamline.h"
00032
00033 #include "shaderLoader.h"
00034
00035 using std::queue;
00036
00039 class RendererWidget : public QGLWidget
00040 {
00041 Q_OBJECT
00042 public:
00043 RendererWidget(QWidget *parent = 0);
00044
00045 QSize minimumSizeHint() const;
00046
00047 bool loadData(FlowData *stream);
00048
00051 enum RenderingState
00052 {
00053 RS_NOTHING
00054 };
00055
00056 public slots:
00057 void changeSettings(Settings *settings);
00058
00059 signals:
00060 void newDataLoaded(Histogram *histogram);
00061
00062 protected:
00063 bool leftButtonHeld;
00064
00065 unsigned int m_startingX;
00066 unsigned int m_startingY;
00067
00068
00069
00070 bool m_dragging;
00071 bool m_moving;
00072
00073 void mouseMoveEvent(QMouseEvent *event);
00074 void mousePressEvent(QMouseEvent * event);
00075 void mouseReleaseEvent(QMouseEvent *event);
00076
00077 void wheelEvent(QWheelEvent *event);
00078
00079
00080
00081
00082 void initializeGL();
00083 void paintGL();
00084 void resizeGL(int width, int height);
00085
00086
00087 GLuint BuildAdditionalTexture(int channelId);
00088 void BuildMainTexture();
00089
00090 void LoadArrowTexture();
00091
00092 void EnableBlending();
00093 void DisableBlending();
00094
00095 static void PackVector(float min, float max, float x, float y, float z, unsigned char *result);
00096 private:
00097
00098 void DrawBackgroundImage();
00099 void DrawArrows();
00100
00101 double GetNormalizedX(int x);
00102 double GetNormalizedY(int Y);
00103
00104 cml::vector2f *GenerateSeeds(int noSeedsX, int noSeedsY);
00105
00106
00107
00108 void DrawStreamline(Streamline *streamline);
00109 void DrawStreamlines(vector<Streamline *> &streamlines);
00110
00111 Streamline *RendererWidget::ConstructStreamline(
00112 cml::vector2f seed,
00113 const string &integrationSettingName,
00114 IntegrationType integrationType
00115 );
00116
00117
00118 void RendererWidget::ConstructStreamlines(
00119 std::vector<Streamline *> &streamlines,
00120 IntegrationType integrationType
00121 );
00122
00123 void RendererWidget::ConstructEvenlySpacedStreamline(
00124 Reggrid *regGrid,
00125 queue<cml::vector2f> &candidateList,
00126 float stepSize,
00127 float dSep,
00128 IntegrationType integrationType,
00129 Streamline **streamlines
00130 );
00131
00132 void RendererWidget::ConstructEvenlySpacedStreamlines(
00133 std::vector<Streamline *> &streamlines,
00134 float dSep,
00135 float dTest,
00136 IntegrationType integrationType
00137 );
00138
00139 std::vector<Streamline *> m_eulerStreamlines;
00140 std::vector<Streamline *> m_rkStreamlines;
00141
00142 void checkForCgError(const char *situation);
00143
00144 static const unsigned short int sizeLimit = 2000;
00145
00146 bool dataLoaded;
00147
00148 Settings *m_settings;
00149
00150 FlowData *m_flowData;
00151
00152 int m_velocityChannel;
00153 int m_xChannel;
00154 int m_yChannel;
00155 int m_zChannel;
00156 int m_firstAdditionalChannel;
00157 int m_secondAdditionalChannel;
00158 int m_geometryXChannel;
00159 int m_geometryYChannel;
00160
00161
00162
00163
00164
00165
00166
00167 int m_width;
00168 int m_height;
00169
00170 GLuint m_velocityTexture;
00171 GLuint m_firstAdditionalTexture;
00172 GLuint m_secondAdditionalTexture;
00173 GLuint m_mainTexture;
00174 GLuint m_arrowTexture;
00175
00176 float m_datasetWidth;
00177 float m_datasetHeight;
00178
00179
00180 FlowGrid m_flowGrid;
00181
00182 const int m_mainTextureSize;
00183 const int m_velocityTextureSize;
00184
00185 RenderingState m_renderingState;
00186
00187
00188 ShaderLoader *m_shaderLoader;
00189
00190
00191 ShaderProgram *m_backgroundQuadProgram;
00192 ShaderProgram *m_arrowVertexProgram;
00193 ShaderProgram *m_arrowFragmentProgram;
00194 };
00195
00196 #endif