]>
git.mar77i.info Git - bigintmandel/blob - bigintwidget.cpp
6 #include <QtConcurrent/QtConcurrent>
8 #include "bigintwidget.h"
10 BigintWidget::BigintWidget(QWidget
*parent
)
12 fw(new QFutureWatcher
<MandelResultCell
>(this)),
13 meta(1024, QSize(1800, 1000)),
14 img_label(new QLabel(this)),
19 &QFutureWatcher
<MandelResultCell
>::resultReadyAt
,
21 &BigintWidget::finished_cell
25 &QFutureWatcher
<MandelResultCell
>::finished
,
27 &BigintWidget::finished
29 fw
->setFuture(QtConcurrent::mapped(meta
.get_cells(), MandelMeta::iterate
));
30 setLayout(new QVBoxLayout());
31 layout()->addWidget(img_label
);
32 img_label
->setMinimumSize(meta
.get_size());
35 BigintWidget::~BigintWidget() {
37 fw
->waitForFinished();
40 void BigintWidget::finished_cell(int num
) {
41 meta
.finished_cell(num
, fw
->resultAt(num
));
46 void BigintWidget::finished() {
51 void BigintWidget::paintEvent(QPaintEvent
*event
) {
53 img_label
->setPixmap(meta
.get_pixmap());
58 void BigintWidget::mousePressEvent(QMouseEvent
*event
) {
59 if (!fw
->isFinished() || event
->button() != Qt::MouseButton::LeftButton
)
61 QPoint pos
= img_label
->mapFromParent(event
->pos());
62 if (pos
.x() < 0 || pos
.x() >= meta
.get_width()
63 || pos
.y() < 0 || pos
.y() >= meta
.get_height())
66 fw
->setFuture(QtConcurrent::mapped(meta
.get_cells(), MandelMeta::iterate
));