#include "bigintmandelwidget.h"
#include "mandellabel.h"
#include "menubar.h"
+#include "settingswidget.h"
BigintMandelWidget::BigintMandelWidget(QWidget *parent)
: QWidget(parent),
ss.setString(new QString());
if (num_threads != -1)
ss << "Calculating with " << num_threads << " threads ...";
+ else if (settings.get_zoom_factor() == -1)
+ ss << "Choose a zoom factor from the \"Zoom\" menu.";
else
ss << "Click the rendering to zoom.";
status_bar->showMessage(*ss.string());
[](const MandelCell &cell){ return cell.iterate(); }
)
);
- menu_bar->set_zoom_factor(-1);
+ settings.set_zoom_factor(-1);
update();
}
QSize size(settings.get_params().get_size());
QPoint pos(event->pos());
QWidget *w;
- int zoom_factor = menu_bar->get_zoom_factor();
+ int zoom_factor = settings.get_zoom_factor();
for (w = mandel_label; w != this; w = w->parentWidget())
pos = w->mapFromParent(pos);
if (event->button() != Qt::MouseButton::LeftButton
#include <QWidget>
#include "mandel.h"
-#include "settingswidget.h"
class MenuBar;
class MandelLabel;
+class SettingsWidget;
class BigintMandelWidget : public QWidget {
Q_OBJECT
public:
explicit BigintMandelWidget(QWidget *parent = nullptr);
~BigintMandelWidget();
- inline const MandelSettings *get_settings() const {
+ inline MandelSettings * const get_settings() {
return &settings;
}
- inline const MenuBar *get_menu_bar() const {
- return menu_bar;
- }
public Q_SLOTS:
void reset();
MandelParams params;
QImage *img;
QVector<MandelCell> cells;
+ int zoom_factor;
public:
explicit MandelSettings(quint64 max_iter, QSize size);
inline void set_size(const QSize &size) {
params.set_size(size);
}
+ inline int get_zoom_factor() const {
+ return zoom_factor;
+ }
+ inline void set_zoom_factor(int zoom_factor) {
+ this->zoom_factor = zoom_factor;
+ }
void zoom(const QSize size, int zoom_factor, const QPoint pos);
void finished_cell(int num, const MandelResultCell &cell);
#include <QPainter>
#include "mandellabel.h"
-#include "menubar.h"
#include "qevent.h"
MandelLabel::MandelLabel(BigintMandelWidget *parent)
: QLabel(parent),
settings(parent->get_settings()),
- menu_bar(parent->get_menu_bar()),
draw_progress(-1),
zoom_rect_center(-1, -1) {
setMouseTracking(true);
void MandelLabel::paintEvent(QPaintEvent *event) {
QPixmap pixmap;
QPainter qp;
- int zoom_factor = menu_bar->get_zoom_factor();
+ int zoom_factor = settings->get_zoom_factor();
bool draw_zoom_rect = (
zoom_factor != -1
&& zoom_rect_center.x() != -1
&& zoom_rect_center.y() != -1
);
pixmap = settings->get_pixmap();
- if (draw_progress != -1 || draw_zoom_rect)
+ if (draw_progress != -1 || draw_zoom_rect) {
qp.begin(&pixmap);
- if (draw_progress != -1) {
- qp.setPen(Qt::GlobalColor::gray);
- qp.drawLine(0, draw_progress, pixmap.width() - 1, draw_progress);
- }
- if (draw_zoom_rect) {
- qp.setPen(Qt::GlobalColor::gray);
- qp.drawRect(
- get_rect(
- pixmap.size(),
- zoom_rect_center,
- zoom_factor
- )
- );
- }
- if (draw_progress != -1 || draw_zoom_rect)
+ if (draw_progress != -1) {
+ qp.setPen(Qt::GlobalColor::gray);
+ qp.drawLine(0, draw_progress, pixmap.width() - 1, draw_progress);
+ }
+ if (draw_zoom_rect) {
+ qp.setPen(Qt::GlobalColor::gray);
+ qp.drawRect(
+ get_rect(
+ pixmap.size(),
+ zoom_rect_center,
+ zoom_factor
+ )
+ );
+ }
qp.end();
+ }
resize(pixmap.size());
setPixmap(pixmap);
QLabel::paintEvent(event);
#include "mandel.h"
class MandelLabel : public QLabel {
- const MandelSettings *settings;
- const MenuBar *menu_bar;
+ Q_OBJECT
+
+ const MandelSettings * const settings;
int draw_progress;
QPoint zoom_rect_center;
MenuBar::MenuBar(BigintMandelWidget *parent)
: QMenuBar(parent),
+ settings(parent->get_settings()),
file_menu(new QMenu("&File", parent)),
calc_menu(new QMenu("&Calculation", parent)),
- zoom_menu(new QMenu("&Zoom", parent)),
- zoom_factor(-1) {
+ zoom_menu(new QMenu("&Zoom", parent)) {
QKeySequence no_key;
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
load_action = file_menu->addAction(
class MenuBar : public QMenuBar {
Q_OBJECT
+ MandelSettings * const settings;
QMenu *file_menu;
QAction *load_action, *save_action;
QAction *export_action, *exit_action;
QMenu *zoom_menu;
QAction *no_action, *two_action, *four_action;
QAction *eight_action, *sixteen_action;
- int zoom_factor;
inline void check_action() {
- no_action->setChecked(zoom_factor == -1);
- two_action->setChecked(zoom_factor == 2);
- four_action->setChecked(zoom_factor == 4);
- eight_action->setChecked(zoom_factor == 8);
- sixteen_action->setChecked(zoom_factor == 16);
+ no_action->setChecked(settings->get_zoom_factor() == -1);
+ two_action->setChecked(settings->get_zoom_factor() == 2);
+ four_action->setChecked(settings->get_zoom_factor() == 4);
+ eight_action->setChecked(settings->get_zoom_factor() == 8);
+ sixteen_action->setChecked(settings->get_zoom_factor() == 16);
}
public:
explicit MenuBar(BigintMandelWidget *parent);
- inline int get_zoom_factor() const { return zoom_factor; }
- inline void set_zoom_factor(int zoom_factor) {
- this->zoom_factor = zoom_factor;
- check_action();
- }
public Q_SLOTS:
void change_zoom_factor() {
- set_zoom_factor(static_cast<QAction*>(sender())->data().toInt());
+ settings->set_zoom_factor(
+ static_cast<QAction*>(sender())->data().toInt()
+ );
}
};