// mandel.h #ifndef MANDEL_H #define MANDEL_H #include #include #include #include class MandelCell; class MpzPoint { mpz_class x, y; public: MpzPoint(); MpzPoint(mpz_class x, mpz_class y); MpzPoint(const MpzPoint &other); const mpz_class get_x() const { return x; } const mpz_class get_y() const { return y; } }; class MandelResultCell { friend class MandelMeta; size_t iter; MpzPoint rpos; public: MandelResultCell(); MandelResultCell(size_t iter, MpzPoint rpos); }; class MandelMeta { size_t max_iter; QImage img; QVector cells; MpzPoint center_f; mpz_class one; 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 MpzPoint get_center_f() const { return center_f; } const mpz_class get_one() const { return one; } 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; MpzPoint 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 MpzPoint get_rpos0() const { return rpos0; } QPoint update_result(size_t iter, const MpzPoint &rpos); void reset_iter_and_rpos(); void set_meta(MandelMeta *meta); void set_pos(const QPoint pos); MandelResultCell iterate() const; }; #endif // MANDEL_H