// mandel.h #ifndef MANDEL_H #define MANDEL_H #include #include #include class MandelCell; class MandelResultCell { friend class MandelMeta; size_t iter; QPointF rpos; public: MandelResultCell(); MandelResultCell(size_t iter, QPointF rpos); }; class MandelMeta { size_t max_iter; QImage img; QVector cells; QPointF center_f; qreal one, four, scale; public: MandelMeta(size_t max_iter, QSize size); const size_t get_max_iter() const { return max_iter; } const QPixmap get_pixmap() const { return QPixmap::fromImage(img); } const int get_width() const { return img.width(); } const int get_height() const { return img.height(); } const QSize get_size() const { return img.size(); } const QVector get_cells() const { return cells; } const QPointF get_center_f() const { return center_f; } const qreal get_four() const { return four; } const qreal get_scale() const { return scale; } void zoom2x(QPoint pos); void finished_cell(int num, const MandelResultCell &cell); static MandelResultCell iterate(const MandelCell &cell); }; class MandelCell { MandelMeta *meta; QPoint pos; size_t iter; QPointF rpos, rpos0; protected: void reset_rpos0(); public: MandelCell(MandelMeta *meta); MandelCell(const MandelCell &cell); inline const size_t get_iter() const { return iter; } inline const QPointF get_rpos0() const { return rpos0; } QPoint update_result(size_t iter, const QPointF &rpos); void reset_iter_and_rpos(); void set_meta(MandelMeta *meta); void set_pos(const QPoint pos); MandelResultCell iterate() const; }; #endif // MANDEL_H