00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef RENDERTHREAD_H
00015 #define RENDERTHREAD_H
00016
00017 #include <QtGui>
00018 #include <QMutex>
00019 #include <QSize>
00020 #include <QThread>
00021 #include <QWaitCondition>
00022 #include <QImage>
00023
00024 #include "fractal.h"
00025
00026
00028 class RenderThread : public QThread
00029 {
00030 Q_OBJECT
00031
00032 public:
00033 RenderThread(QObject *parent = 0, int id = 0);
00034 ~RenderThread();
00035
00036
00037 void SetRender(int w, int h,
00038 int threadCount,
00039 double centerx, double centery,
00040 double precision, int minIteration,
00041 double real, double imaginary,
00042 double zoom, int iteration, Fractal fractal,
00043 const QGradientStops& gradient, QImage *gradientImage, bool smooth, float dilatation,
00044 QImage *image, QMutex *imageMutex);
00045
00046 void Stop();
00047
00048 void Finish();
00049 protected:
00050 void run();
00051
00052
00053 void RenderMandelBrot();
00054 void RenderBuddhabrot();
00055 void RenderJulia();
00056 signals:
00057 void Progress(float pourcent, int threadId);
00058 void Finish(int threadId);
00059 protected:
00060 QMutex m_Mutex;
00061 QWaitCondition m_Condition;
00062
00063
00064 static QVector<unsigned long> m_Map;
00065 static int m_iThreadFinish;
00066 static unsigned long m_iMax;
00067
00068 int m_iId;
00069
00070 bool m_bRestart;
00071 bool m_bStop;
00072 bool m_bFinish;
00073
00074 Fractal m_iFractal;
00075 int m_iThreadCount;
00076 int m_iProgress;
00077 int m_iX;
00078 int m_iY;
00079 int m_iW;
00080 int m_iH;
00081 int m_iRW;
00082 int m_iRH;
00083 double m_fCenterX;
00084 double m_fCenterY;
00085 double m_fZoom;
00086 double m_fPrecision;
00087 int m_iMinIteration;
00088 int m_iIteration;
00089 double m_fReal;
00090 double m_fImaginary;
00091 bool m_bSmoothColors;
00092 float m_fDilatation;
00093 QImage *m_pImage;
00094 QMutex *m_pImageMutex;
00095
00096 QGradientStops m_Gradient;
00097 QImage *m_pGradientImage;
00098 };
00099
00100 #endif