// bigintwidget.cpp #include #include #include #include "bigintwidget.h" BigintWidget::BigintWidget(QWidget *parent) : QWidget(parent), fw(new QFutureWatcher(this)), meta(8192, QSize(1800, 1000)), img_label(new QLabel(this)), img_dirty(true) { connect( fw, &QFutureWatcher::resultReadyAt, this, &BigintWidget::finished_cell ); connect( fw, &QFutureWatcher::finished, this, &BigintWidget::finished ); fw->setFuture(QtConcurrent::mapped(meta.get_cells(), MandelMeta::iterate)); setLayout(new QVBoxLayout()); layout()->addWidget(img_label); img_label->setMinimumSize(meta.get_size()); } BigintWidget::~BigintWidget() { fw->cancel(); fw->waitForFinished(); } void BigintWidget::finished_cell(int num) { meta.finished_cell(num, fw->resultAt(num)); img_dirty = true; update(); } void BigintWidget::finished() { img_dirty = true; update(); } void BigintWidget::paintEvent(QPaintEvent *event) { if (img_dirty) { img_label->setPixmap(meta.get_pixmap()); img_dirty = false; } } void BigintWidget::mousePressEvent(QMouseEvent *event) { if (!fw->isFinished() || event->button() != Qt::MouseButton::LeftButton) return; QPoint pos = img_label->mapFromParent(event->pos()); if (pos.x() < 0 || pos.x() >= meta.get_width() || pos.y() < 0 || pos.y() >= meta.get_height()) return; meta.zoom2x(pos); fw->setFuture(QtConcurrent::mapped(meta.get_cells(), MandelMeta::iterate)); img_dirty = true; update(); }