00001 #ifndef FRACTALMAP_H
00002 #define FRACTALMAP_H
00003
00004 #include <QApplication>
00005 #include <QVector>
00006 #include <math.h>
00007 #include <complex>
00008 #include "QtConcurrentRun"
00009 #include <QString>
00010 #include <QtGui>
00011
00012 enum EStatus{
00013 NOTSTARTED,
00014 RUNNING,
00015 PAUSED,
00016 CALCULATED,
00017 RENDERED,
00018 ERROR
00019 };
00020
00021 enum EFractalType{
00022 MANDELBROT,
00023 JULIA,
00024 BUDDHABROT,
00025 CLIFFORD,
00026 NOVA,
00027 CRAB,
00028 NEWTON,
00029 BURNINGSHIP,
00030 TRICORN,
00031 SHARINGAN
00032 };
00033
00034
00035 struct SubFractal
00036 {
00037 int offsetX;
00038 int offsetY;
00039 int width;
00040 int height;
00041 double startX;
00042 double startY;
00043 double stepX;
00044 double stepY;
00045 EFractalType fractalType;
00046 EStatus status;
00047 QVector<int> vector;
00048 };
00049
00050
00051 typedef std::complex<double> point;
00052 typedef QFutureWatcher<void> VoidWatcher;
00053
00054 #ifndef QT_NO_CONCURRENT
00055
00056 class CFractalMap : public QObject
00057 {
00058 Q_OBJECT
00059 public:
00060 CFractalMap(QObject *parent = 0);
00061 ~CFractalMap();
00062
00063 void define (EFractalType fracType,
00064 const int width,
00065 const int height,
00066 const int subStepX=1,
00067 const int subStepY=1,
00068 const double centerX=0,
00069 const double centerY=0,
00070 const double pixelStep=0);
00071 static void doCalculate(SubFractal &sub);
00072
00073 int getSize() {return dataSize;}
00074 int getIndex() {return fractalIndex;}
00075
00076
00077 QVector<SubFractal> subFractals;
00078
00079
00080 QStringList fractalTypeNames;
00081
00082 public slots:
00083 void start();
00084 void stop();
00085 void pause();
00086 void resume();
00087 void cancel();
00088 void updateSubFractalAt(int index);
00089 void updateAllFinished();
00090 void updateProgressValue(int value);
00091 void updateProgressRange(int minimum, int maximum);
00092
00093 signals:
00094 void allFinished();
00095 void finishedAt(int index);
00096 void progressValueChanged ( int progressValue);
00097 void progressRangeChanged (int minimum, int maximum);
00098
00099 private:
00100 static int fractalIndex;
00101 QString fractalName;
00102 bool hasVerticalSymmetry;
00103 int gridHeight;
00104 int gridWidth;
00105 int gridStepX;
00106 int gridStepY;
00107 double gridCenterX;
00108 double gridCenterY;
00109 double gridStartX;
00110 double gridStartY;
00111 int dataSize;
00112 double stepBetweenPoints;
00113 EFractalType fractalType;
00114
00115 VoidWatcher watcher;
00116 };
00117
00118 #else
00119
00120 class CFractalMap : public QObject
00121 {
00122 Q_OBJECT
00123 public Q_SLOTS:
00124 void start();
00125 void stop();
00126 void pause();
00127 void resume();
00128 };
00129 #endif // QT_NO_CONCURRENT
00130
00131 #endif // FRACTALMAP_H