]>
git.mar77i.info Git - bigintmandel/blob - mandel.h
5 * This file is covered by the LICENSE file in the root of this project.
11 #include <QJsonObject>
20 MpzPoint() : x(), y() {}
21 explicit MpzPoint(mpz_class x
, mpz_class y
) : x(x
), y(y
) {}
22 MpzPoint(const MpzPoint
&other
) : x(other
.x
), y(other
.y
) {}
23 inline const mpz_class
get_x() const { return x
; }
24 inline const mpz_class
get_y() const { return y
; }
27 class MandelResultCell
{
31 MandelResultCell() : iter(0) {}
32 explicit MandelResultCell(quint64 iter
, MpzPoint rpos
)
33 : iter(iter
), rpos(rpos
) {}
34 inline const quint64
get_iter() const { return iter
; }
35 inline const MpzPoint
get_rpos() const { return rpos
; }
42 MpzPoint center_f
, offset
;
46 // required by the MandelSettings constructor
48 explicit MandelParams(
54 MandelParams(const MandelParams
&other
);
55 inline const quint64
get_max_iter() const { return max_iter
; }
56 inline void set_max_iter(const quint64 max_iter
) {
57 this->max_iter
= max_iter
;
59 inline const QSize
get_size() const { return size
; }
60 void set_size(const QSize
&size
);
61 inline const MpzPoint
get_center_f() const { return center_f
; }
62 inline const MpzPoint
&get_offset() const {
65 inline const mpz_class
get_one() const { return one
; }
67 static MandelParams
from_json(const QJsonObject
&json
);
68 QJsonObject
to_json() const;
73 class MandelSettings
{
76 QVector
<MandelCell
> cells
;
80 explicit MandelSettings(quint64 max_iter
, QSize size
);
82 inline QPixmap
get_pixmap() const { return QPixmap::fromImage(*img
); }
83 inline const QVector
<MandelCell
> get_cells() const { return cells
; }
84 inline const MandelParams
&get_params() const { return params
; }
85 inline void set_params(const MandelParams
¶ms
) {
86 this->params
= params
;
88 inline quint64
get_max_iter() const { return params
.get_max_iter(); }
89 inline void set_max_iter(quint64 max_iter
) {
90 params
.set_max_iter(max_iter
);
92 inline void set_size(const QSize
&size
) {
93 params
.set_size(size
);
95 inline int get_zoom_factor() const {
98 inline void set_zoom_factor(int zoom_factor
) {
99 this->zoom_factor
= zoom_factor
;
102 void zoom(const QSize size
, int zoom_factor
, const QPoint pos
);
103 void finished_cell(int num
, const MandelResultCell
&cell
);
104 void save_img(QString file_name
);
105 void reset(quint64 max_iter
, QSize size
);
106 void from_json(const QJsonObject
&json
);
107 QJsonObject
to_json();
110 extern QVector
<QColor
> colors
;
113 const MandelParams
*params
;
116 MandelResultCell result
;
119 MandelCell(const MandelParams
*params
);
121 const MandelParams
*params
,
123 const MpzPoint rpos0
,
124 const MandelResultCell result
126 MandelCell(const MandelCell
&cell
);
127 inline const QPoint
get_pos() const { return pos
; }
128 inline const MpzPoint
get_rpos0() const { return rpos0
; }
129 inline const QColor
get_color() const {
130 quint64 iter
= result
.get_iter();
131 return iter
< params
->get_max_iter()
132 ? colors
[iter
% colors
.size()]
133 : Qt::GlobalColor::black
;
136 void setup(const QPoint pos
);
137 inline void set_result(const MandelResultCell
&result
) {
138 this->result
= result
;
140 MandelResultCell
iterate() const;
141 MandelResultCell
from_json(const QJsonObject
&json
);
142 QJsonObject
to_json() const;