00001 #ifndef QVOLRENDCANVAS_H_
00002 #define QVOLRENDCANVAS_H_
00003
00004 #include <Qt/qobject.h>
00005
00006 #include <QtGui/QWidget>
00007 #include <QtOpenGL/QGLWidget>
00008 #include <QtGui/QKeyEvent>
00009 #include <QtGui/QMouseEvent>
00010
00011 #include "VEvent.h"
00012 #include "VTransferFunction.h"
00013 #include "VImage.h"
00014
00015 #include "VFlowData.h"
00016 #include "VFlowRenderer.h"
00017
00021 class VFramebufferObject;
00022
00026 enum MouseState
00027 {
00028 NO_DRAGGING = 0,
00029 ROTATE,
00030 ZOOM,
00031 PAN,
00032 };
00033
00034
00038 class QVolRendCanvas : public QObject, public QGLWidget
00039 {
00040 Q_OBJECT
00041
00042 public:
00043
00048 QVolRendCanvas(QWidget* parent = 0);
00049
00053 virtual ~QVolRendCanvas();
00054
00059 void setObjectName(const QString &name);
00060
00065 float getNumTimeSteps()
00066 {
00067
00068 return m_FlowData.getNumTimeSteps();
00069 }
00070
00075 float getNumDataValues()
00076 {
00077
00078 return m_FlowData.getNumDataValues();
00079 }
00080
00085 float getFlowDataMin()
00086 {
00087
00088 return m_FlowRenderer.getFlowDataMin( );
00089 }
00090
00095 float getFlowDataMax()
00096 {
00097
00098 return m_FlowRenderer.getFlowDataMax( );
00099 }
00100
00105 void timestep_changed_event( int val );
00106
00111 void coloringproperty_changed_event( int val );
00112
00117 void arrowscale_valuechanged(int val);
00118
00123 void iconscale_valuechanged(int val);
00124
00129 void icontail_valuechanged(int val);
00130
00135 void arrowspacing_valuechanged(int val);
00136
00141 void arrowalpha_changed_event(float val);
00142
00147 void salpha_changed_event(float val);
00148
00153 void licalpha_changed_event(float val);
00154
00159 void licsteps_changed_event(int val);
00160
00165 void licstepsize_changed_event(int val);
00166
00171 void dsep_valuechanged(int val);
00172
00177 void dtest_valuechanged(int val);
00178
00183 void steps_valuechanged(int val);
00184
00189 void dt_valuechanged(int val);
00190
00195 void setGlyph( bool val );
00196
00202 virtual void resizeGL( int w, int h );
00203
00208 virtual void paintEvent( QPaintEvent *e );
00209
00214 virtual void mousePressEvent ( QMouseEvent * e );
00215
00220 virtual void mouseReleaseEvent ( QMouseEvent * e );
00221
00226 virtual void mouseMoveEvent ( QMouseEvent * e );
00227
00228
00233 virtual void mouseDoubleClickEvent ( QMouseEvent * e );
00234
00235
00240 virtual void keyPressEvent ( QKeyEvent * e );
00241
00242
00247 virtual void keyReleaseEvent ( QKeyEvent * e );
00248
00254 const VMouseEvent getMouseEvent (QMouseEvent *e);
00255
00261 const VKeyboardEvent getKeyboardEvent (QKeyEvent *e);
00262
00266 virtual void redraw();
00267
00272 void setStreamlinesColorPtr(VVector *v);
00273
00278 void setArrowsColorPtr(VVector *v);
00279
00284 void setArrowplotState( bool state )
00285 {
00286 arrows_activated = state;
00287 }
00288
00293 void setLicplotState( bool state )
00294 {
00295 lic_activated = state;
00296 }
00297
00302 void enableIcons( bool state )
00303 {
00304 m_EnableIconSetting = state;
00305 if ( state ) m_FlowData.computeIcons( );
00306 }
00307
00312 void setTaperingState( bool state )
00313 {
00314 tapering_activated = state;
00315 m_FlowData.setTaperingState( state );
00316 }
00317
00322 void setStrGlyphes( bool state )
00323 {
00324
00325 m_FlowData.setStrGlyphes( state );
00326 m_FlowRenderer.setStrGlyphes( state );
00327 }
00328
00333 void setTaperingScale( float val )
00334 {
00335 m_FlowData.setTaperingScale( val );
00336 }
00337
00342 void setStreamlinesState( bool state )
00343 {
00344 streamlines_activated = state;
00345 }
00346
00351 void setArrowScaleModus( bool state)
00352 {
00353 m_FlowRenderer.setArrowScaleMode( state );
00354 }
00355
00356
00357
00362 void setIntegrationMethod( bool state)
00363 {
00364 m_FlowData.setIntegrationMethod( state );
00365 }
00366
00370 void computeStreamlines( )
00371 {
00372 if ( ! streamlines_activated ) return;
00373
00374
00375 repaint();
00376 }
00377
00381 void computeCPUStreamlines( )
00382 {
00383 if ( ! streamlines_activated ) return;
00384
00385 m_FlowData.generateCPUStreamLines( mStremSteps, mStreamSeedSpacing, timestep_activated - 1 );
00386 repaint();
00387 }
00388
00389
00394 void setPlacingMethod(int val)
00395 {
00396 m_FlowData.setPlacingMethod( val );
00397
00398 if ( m_FlowData.isIndexOfManualPlacingMethod( val ) )
00399 {
00400 m_EnableSeedpointsSetting = true;
00401 m_EnableEvenSeedpointsSetting = false;
00402 setCursor(QCursor(Qt::CursorShape::CrossCursor));
00403 }
00404 else if( m_FlowData.isIndexOfEvenPlacingMethod ( val ) )
00405 {
00406 m_EnableEvenSeedpointsSetting = true;
00407 m_EnableSeedpointsSetting = false;
00408 setCursor(QCursor(Qt::CursorShape::CrossCursor));
00409
00410 }
00411 else
00412 {
00413 m_EnableSeedpointsSetting = false;
00414 m_EnableEvenSeedpointsSetting = false;
00415 setCursor(QCursor(Qt::CursorShape::OpenHandCursor));
00416 }
00417
00418 repaint();
00419 }
00420
00425 bool getLoaded(){return data_loaded;};
00426
00431 void setTransferFunctionPtr(VTransferFunction * transfunc);
00432
00437 void setArrowTransferFunctionPtr(VTransferFunction * transfunc);
00438
00443 void setArrowTF(bool val);
00444
00449 void setLicTF(bool val);
00450
00455 void animateLic(bool val);
00456
00461 void setStrTF(bool val);
00462
00463
00468 void setStreamLineTransferFunctionPtr(VTransferFunction * transfunc);
00469
00474 void setLicTransferFunctionPtr(VTransferFunction * transfunc);
00475
00476
00481 void modifyLight(bool val);
00482
00483
00490 virtual bool load_data(QString filename, int *volsize);
00491
00498 virtual bool load_single_data(QString filename, QString datfilename);
00499
00504 bool save_data(std::string filename);
00505
00510 virtual void saveImage(std::string filename);
00511
00516 virtual void saveBigImage(std::string filename);
00517
00522 virtual void saveStreamLines(std::string filename);
00523
00528 virtual void loadStreamLines(std::string filename);
00529
00534 void setOrthoProjection(bool m_orth);
00535
00536 VTransferFunction * m_TransferFunction;
00537 VTransferFunction * m_ArrowTransferFunction;
00538 VTransferFunction * m_StreamLineTransferFunction;
00539 VTransferFunction * m_LicTransferFunction;
00541 float m_bgColor[4];
00543 VVector up;
00544 VVector view;
00545 VVector side;
00547 VVector lup;
00548 VVector lview;
00549 VVector lside;
00551 VVector m_lightDir;
00552 bool m_modifyLight;
00554 VImage testImage;
00556 protected:
00557
00561 virtual void initializeGL();
00562
00566 virtual void paintGL();
00567
00568
00569 private:
00570
00576 VVector getSphereProjection(float x, float y);
00577
00583 VVector getPlaneProjection(float x, float y);
00584
00588 void computeGlyphs();
00589
00596 double round(double Zahl, int Stellen)
00597 {
00598 double v[] = { 1, 10, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8 };
00599 return floor(Zahl * v[Stellen] + 0.5) / v[Stellen];
00600 }
00601
00602
00603 bool sliceview_active;
00604 bool data_loaded;
00605 int apply_tf_in_sv;
00606 int apply_tf_in_vv;
00607 VFramebufferObject * m_FramebufferObject;
00608 VVector *m_ArrowsColor;
00609 VVector *m_StreamlinesColor;
00610 VVector m_MouseLastPos;
00612 MouseState m_MouseState;
00614 VVector m_CamDat;
00615 VVector m_LookAtPoint;
00617 VVector m_Position;
00618 VVector m_LookAt;
00619 float m_Distance;
00620 VVector m_vecPosition;
00621 VVector m_PanOffset;
00623 VVector m_Rotation;
00624 float m_fAngle;
00626 bool m_EnableSeedpointsSetting;
00627 bool m_EnableEvenSeedpointsSetting;
00629 VFramebufferObject * m_SaveImageFBO;
00630 bool m_IsSaving;
00631 std::string m_SaveFileName;
00632
00633 VFlowData m_FlowData;
00634 VFlowRenderer m_FlowRenderer;
00635
00636 float mArrowSize;
00637 float mArrowSpacing;
00638 float mStreamSeedSpacing;
00639 float mStreamTestSpacing;
00640 float mStremSteps;
00641 float mStreamDT;
00642
00643
00644 bool arrows_activated;
00645 bool streamlines_activated;
00646 int timestep_activated;
00647 int coloring_property;
00648 bool lic_activated;
00649 bool tapering_activated;
00651 float m_EnableIconSetting;
00652 };
00653 #endif