ROOT  6.06/09
Reference Guide
mandel.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Matthias Kretz <kretz@kde.org>
3 
4  Permission to use, copy, modify, and distribute this software
5  and its documentation for any purpose and without fee is hereby
6  granted, provided that the above copyright notice appear in all
7  copies and that both that the copyright notice and this
8  permission notice and warranty disclaimer appear in supporting
9  documentation, and that the name of the author not be used in
10  advertising or publicity pertaining to distribution of the
11  software without specific, written prior permission.
12 
13  The author disclaim all warranties with regard to this
14  software, including all implied warranties of merchantability
15  and fitness. In no event shall the author be liable for any
16  special, indirect or consequential damages or any damages
17  whatsoever resulting from loss of use, data or profits, whether
18  in an action of contract, negligence or other tortious action,
19  arising out of or in connection with the use or performance of
20  this software.
21 
22 */
23 
24 #include <QImage>
25 #include <QMutex>
26 #include <QSize>
27 #include <QThread>
28 #include <QWaitCondition>
29 #include <complex>
30 
31 enum MandelImpl {
33 };
34 
35 class MandelBase : public QThread
36 {
37  Q_OBJECT
38  public:
39  void brot(const QSize &size, float x, float y, float scale);
40 
41  protected:
42  MandelBase(QObject* _parent = 0);
43  ~MandelBase();
44  void emitImage(const QImage &image, quint64 cycles) { emit ready(image, cycles); }
45 
46  void run();
47  virtual void mandelMe(QImage &image, float x, float y, float scale, int maxIterations) = 0;
48  inline bool restart() const { return m_restart; }
49 
50  signals:
51  void ready(const QImage &image, quint64 cycles);
52 
53  private:
54  QMutex m_mutex;
55  QWaitCondition m_wait;
56  QSize m_size;
57  float m_x, m_y, m_scale;
58  bool m_restart;
59  bool m_abort;
60 };
61 
62 template<MandelImpl Impl>
63 class Mandel : public MandelBase
64 {
65  public:
66  Mandel(QObject *_parent = 0);
67 
68  protected:
69  void mandelMe(QImage &image, float x, float y, float scale, int maxIterations);
70 };
71 
void run()
Definition: mandel.cpp:76
~MandelBase()
Definition: mandel.cpp:49
MandelImpl
Definition: mandel.h:31
void emitImage(const QImage &image, quint64 cycles)
Definition: mandel.h:44
QSize m_size
Definition: mandel.h:56
bool m_restart
Definition: mandel.h:58
float m_x
Definition: mandel.h:57
virtual void mandelMe(QImage &image, float x, float y, float scale, int maxIterations)=0
Double_t x[n]
Definition: legend1.C:17
QMutex m_mutex
Definition: mandel.h:54
float m_scale
Definition: mandel.h:57
QWaitCondition m_wait
Definition: mandel.h:55
MandelBase(QObject *_parent=0)
Definition: mandel.cpp:43
Definition: mandel.h:63
float m_y
Definition: mandel.h:57
Double_t y[n]
Definition: legend1.C:17
Definition: mandel.h:32
bool restart() const
Definition: mandel.h:48
bool m_abort
Definition: mandel.h:59
void brot(const QSize &size, float x, float y, float scale)
Definition: mandel.cpp:59
Mandel(QObject *_parent=0)
Definition: mandel.cpp:38
void ready(const QImage &image, quint64 cycles)
void mandelMe(QImage &image, float x, float y, float scale, int maxIterations)
const char Int_t const char * image
Definition: TXSlave.cxx:46