00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef BROTDISPLAY_H
00015 #define BROTDISPLAY_H
00016
00017 #include <QWidget>
00018 #include <QtOpenGL>
00019 #include <QTimer>
00020
00021 #include "fractal.h"
00022 #include "renderthread.h"
00023
00025 class BrotDisplay : public QGLWidget
00026 {
00027 Q_OBJECT
00028 public:
00029 BrotDisplay( QWidget *parent = 0 );
00030 ~BrotDisplay();
00031
00032
00033 void SetupThread(int count);
00034
00035
00036 void Cancel();
00037
00038
00039 bool Save(QString file);
00040 public slots:
00041 void SetPosX( double x );
00042 void SetPosY( double y );
00043 void SetZoom( double z );
00044 void SetIteration( int ite );
00045 void SetFractal( Fractal frac );
00046 void SetThreadCount( int count );
00047 void SetPrecision( double precision );
00048 void SetMinIteration( int min );
00049 void SetReal( double real );
00050 void SetImaginary( double imaginary );
00051 void SetSmoothColors( bool smooth );
00052 void SetAnimatedRender( bool animated );
00053
00054 void SetGradient( const QGradientStops& stops );
00055 void SetDilatation( double dilatation );
00056
00057 void OnThreadFinish(int id);
00058 void OnThreadProgress(float, int);
00059
00060
00061 void RedrawFractal();
00062
00063 void OnTimer();
00064 signals:
00065 void ZoomChanged( double );
00066 void PosXChanged( double );
00067 void PosYChanged( double );
00068 void IterationChanged( int );
00069 void ThreadCountChanged( int );
00070 void PrecisionChanged( double );
00071 void RealChanged( double );
00072 void ImaginaryChanged( double );
00073 void SmoothColorsChanged( bool );
00074 void AnimatedRenderChanged( bool );
00075 void DilatationChanged( double );
00076
00077 void Progress( float );
00078 protected:
00079 void wheelEvent( QWheelEvent *event );
00080 void mousePressEvent( QMouseEvent *event );
00081 void mouseReleaseEvent( QMouseEvent *event );
00082 void mouseMoveEvent( QMouseEvent *event );
00083
00084 virtual void paintEvent( QPaintEvent *event );
00085 virtual void resizeEvent( QResizeEvent *event );
00086
00087 virtual void initializeGL();
00088 virtual void paintGL();
00089 virtual void resizeGL( int width, int height );
00090
00092 QString LoadResTxt( const char *file );
00093
00095 void GenerateTexture();
00096 protected:
00097 Fractal m_iFractal;
00098 QImage m_Image;
00099 QMutex m_ImageMutex;
00100
00101 QTimer m_Timer;
00102 QTime m_iLastPaint;
00103
00104
00105 double m_fCurrentZoom;
00106 int m_iZoomCount;
00107
00108 double m_fRenderPosX;
00109 double m_fRenderPosY;
00110 double m_fRenderZoom;
00111
00112 bool m_bDrag;
00113 QPoint m_MousePoint;
00114 double m_fOrigX;
00115 double m_fOrigY;
00116 bool m_bWaitRender;
00117
00118 QImage m_GradientImage;
00119 QImage m_TempGradientImage;
00121 QList<RenderThread*> m_RenderThreads;
00122 QVector<float> m_RenderProgress;
00123 int m_iRenderFinishCount;
00124
00127 #if QT_VERSION >= 0x040600
00128 QGLShader* m_pVertexShader;
00129 QGLShader* m_pFragmentShader[2];
00130 QGLShaderProgram* m_pShader[2];
00131 #endif
00132 GLuint m_iTexture;
00133
00134 float m_fRatio;
00135 double m_fPosX;
00136 double m_fPosY;
00137 double m_fZoom;
00138 int m_iIteration;
00139 double m_fPrecision;
00140 int m_iMinIteration;
00141 double m_fReal;
00142 double m_fImaginary;
00143 double m_fDilatation;
00144
00145 QGradientStops m_Gradient;
00146 bool m_bSmoothColors;
00147 bool m_bAnimatedRender;
00148 };
00149
00150 #endif // BROTDISPLAY_H