]> git.mar77i.info Git - bigintmandel/blob - mandel.h
use gmp big ints rather than qreal
[bigintmandel] / mandel.h
1
2 // mandel.h
3
4 #ifndef MANDEL_H
5 #define MANDEL_H
6
7 #include <QPixmap>
8 #include <QPoint>
9 #include <QVector>
10 #include <gmpxx.h>
11
12 class MandelCell;
13
14 class MpzPoint {
15 mpz_class x, y;
16 public:
17 MpzPoint();
18 MpzPoint(mpz_class x, mpz_class y);
19 MpzPoint(const MpzPoint &other);
20 const mpz_class get_x() const { return x; }
21 const mpz_class get_y() const { return y; }
22 };
23
24 class MandelResultCell {
25 friend class MandelMeta;
26
27 size_t iter;
28 MpzPoint rpos;
29 public:
30 MandelResultCell();
31 MandelResultCell(size_t iter, MpzPoint rpos);
32 };
33
34 class MandelMeta {
35 size_t max_iter;
36 QImage img;
37 QVector<MandelCell> cells;
38 MpzPoint center_f;
39 mpz_class one;
40
41 public:
42 MandelMeta(size_t max_iter, QSize size);
43 const size_t get_max_iter() const { return max_iter; }
44 const QPixmap get_pixmap() const { return QPixmap::fromImage(img); }
45 const int get_width() const { return img.width(); }
46 const int get_height() const { return img.height(); }
47 const QSize get_size() const { return img.size(); }
48 const QVector<MandelCell> get_cells() const { return cells; }
49 const MpzPoint get_center_f() const { return center_f; }
50 const mpz_class get_one() const { return one; }
51
52 void zoom2x(QPoint pos);
53 void finished_cell(int num, const MandelResultCell &cell);
54 static MandelResultCell iterate(const MandelCell &cell);
55 };
56
57 class MandelCell {
58 MandelMeta *meta;
59 QPoint pos;
60 size_t iter;
61 MpzPoint rpos, rpos0;
62
63 protected:
64 void reset_rpos0();
65
66 public:
67 MandelCell(MandelMeta *meta);
68 MandelCell(const MandelCell &cell);
69 inline const size_t get_iter() const { return iter; }
70 inline const MpzPoint get_rpos0() const { return rpos0; }
71
72 QPoint update_result(size_t iter, const MpzPoint &rpos);
73 void reset_iter_and_rpos();
74 void set_meta(MandelMeta *meta);
75 void set_pos(const QPoint pos);
76 MandelResultCell iterate() const;
77 };
78
79 #endif // MANDEL_H