00001 #ifndef GLWIDGET_H
00002 #define GLWIDGET_H
00003
00004 #include "Arrows.h"
00005 #include "Shader.h"
00006 #include "Texture.h"
00007 #include <QGLWidget>
00008 #include <QReadWriteLock>
00009 #include <il.h>
00010 #include "Transferfunction.h"
00011 #include "FBO.h"
00012
00013 #include "FlowData.h"
00014 #include "Streamlines.h"
00015 #include "States.h"
00016
00017 #include <QMutex>
00018 #include <QWaitCondition>
00019
00020 #include "GLTransfer.h"
00021 class QtLogo;
00022
00024
00030
00031
00032
00033
00034 class GLWidget : public QGLWidget
00035 {
00036 Q_OBJECT
00037
00038 public:
00039 FBO* fbo;
00040 FBO* fbo2;
00044 GLWidget(QWidget *parent = 0, QWidget *transfer = 0, QWidget *transfer2 = 0);
00049 ~GLWidget();
00053 QSize minimumSizeHint() const;
00054
00058 QSize sizeHint() const;
00059
00060 States states;
00061
00062 static bool waiting;
00063 static bool waiting2;
00064 static bool waiting3;
00065 QReadWriteLock* mutex2;
00066 static QWaitCondition condition;
00067
00068 QColor getArrowColor();
00069 std::string integType;
00070
00071 QWidget* m_scatter;
00072
00073
00075
00076 public slots:
00078
00082 void arrowLayer(bool active);
00083
00085
00089 void backgroundLayer(bool active);
00091
00095 void streamlineLayer(bool active);
00097
00102 void arrowSize(int size);
00104
00109 void arrowDistance(int distance);
00111
00115 void integration(QString type);
00117
00121 void dstep(int step);
00123
00127 void dtest(int test);
00129
00134 void dt(int dt);
00136
00141 void backLayerOpac(int backOpacity);
00143
00148 void arrowLayerOpac(int arrowOpac);
00150
00155 void slicLayerOpac(int opacity);
00157
00162 void glyph(bool check);
00164
00169 void tapering(bool check);
00171
00175 void openFile();
00177
00181 void openColorChooser();
00183
00188 void timeSlider(int time);
00190
00195 void arrowVelocity(bool active);
00197
00201 void slTextrue(bool active);
00203
00209 void dtest();
00211
00217 void dsteps();
00224 void dstepsize();
00226
00232 void dsep();
00234
00238 void dt();
00240
00245 void dtime();
00247
00252 void nsteps(int);
00254
00260 void stepsize(int);
00261
00263
00267
00268 signals:
00270
00274 void arrowLayerChanged(bool active);
00276
00280 void backgroundLayerChanged(bool active);
00282
00286 void streamlineLayerChanged(bool active);
00288
00292 void arrowSizeChanged(int size);
00294
00299 void arrowDistanceChanged(int distance);
00301
00306 void integrationChanged(QString type);
00307
00309
00314 void dstepChanged(int step);
00316
00321 void dtestChanged(int test);
00323
00328 void dtChanged(int dt);
00330
00335 void glyphChanged(bool check);
00337
00342 void taperingChanged(bool check);
00344
00349 void backLayerOpacChanged(int backOpacity);
00351
00356 void arrowLayerOpacChanged(int arrowOpac);
00358
00363 void slicLayerOpacChanged(int slicOpac);
00365
00369 void timeSliderChanged(int time);
00371
00375 void arrowVelocityChanged(bool active);
00377
00382 void slTextrueChanged(bool active);
00383
00385
00389 void nsliderChanged(int n);
00390
00392 protected:
00394
00398 void initializeGL();
00400
00403 void paintGL();
00405
00411 void resizeGL(int width, int height);
00413
00418 void mousePressEvent(QMouseEvent *event);
00420
00424 void mouseMoveEvent(QMouseEvent *event);
00426
00431 void wheelEvent(QWheelEvent *event);
00433
00438 void mouseReleaseEvent(QMouseEvent *event);
00440
00441 private:
00442 QWidget* m_parent;
00443 int initLibs();
00444
00445 int nexttimestep;
00446 float nextdt;
00447 float nextstepsize;
00448 float nextnumsteps;
00449 float nextdtest;
00450 float nextdsep;
00451 States::StreamlineIntMode nextIntegrationMode;
00452
00453
00454 QReadWriteLock qrw_timestep;
00455 QReadWriteLock qrw_dt;
00456 QReadWriteLock qrw_stepsize;
00457 QReadWriteLock qrw_numsteps;
00458 QReadWriteLock qrw_dtest;
00459 QReadWriteLock qrw_dsep;
00460 QReadWriteLock qrw_inte;
00461
00462
00463 vec3 cameraTranslation;
00464
00466 private:
00468
00471 void updateThread();
00473
00476 void updateCamera();
00477 std::vector<ThreadQTImplementation*> qt;
00478 QtLogo *logo;
00479 int xRot;
00480 int yRot;
00481 int zRot;
00482 QPoint lastPos;
00483 QColor qtGreen;
00484 QColor qtPurple;
00485
00486 Arrows* arrows;
00487 Arrows* glyphs;
00488 Shader* shader;
00489 Texture* gridtexture;
00490 FlowData* dataset;
00491 int chX;
00492 int chY;
00493 int vel;
00494
00495
00496 QWidget* m_transfer;
00497
00498 std::vector<float> diffx;
00499 std::vector<float> diffy;
00500
00501 std::vector<std::vector<std::vector<StreamlineObj*>>> stream;
00503
00508 void loadData(string filename);
00509
00511
00518 void upateTFTextureIntern(Transferfunction points, int actIndex, bool update);
00519
00520
00521 GLuint scatterfunc;
00522 float texscatter[512*512*4];
00523
00524 std::vector<Texture*> texture;
00525 std::vector<Texture*> texture2;
00526 std::vector<Texture*> texture_scatter;
00527
00528 Texture* gridtexture_copy;
00529 std::vector<Texture*> texture_copy;
00530
00531 int actTS;
00532
00533 QColor arrowColor;
00534
00535
00536 GLfloat texturefunction[1024*4];
00537 GLuint transferfunc;
00538
00539 public slots:
00541
00548 void updatePixmap(StreamlineObj* streamv, int index1, int index2);
00550
00556 void updateTFTexture(const Transferfunction tex, int index, bool update);
00557 void createdTexture(const vec3 pos1, vec3 pos2, bool update);
00558
00559 signals:
00561
00565 void sendTexture(std::vector<Texture*> asdf);
00566 void stopSignal();
00568
00580 void startSignal(vec3 startp, Texture* grid, Texture* tex, int numsteps, float stepsize, float dsep, float dtest, float dt, States::StreamlineIntMode intmode);
00582
00586
00587
00588 };
00590
00591 #endif