Displaying the fractal with MandelbrotWidget
Here we are, the Mandelbrot algorithm is done and the multithreading system is ready to compute complex fractals over all your CPU cores. We can now create the widget that will convert all the JobResult
to display a pretty picture.
Create a new C++ class called MandelbrotWidget
. For this widget, we will handle the painting ourselves. Thus, we do not need any .ui Qt Designer Form
file. Let's begin with the MandelbrotWidget.h
file:
#include <memory> #include <QWidget> #include <QPoint> #include <QThread> #include <QList> #include "MandelbrotCalculator.h" class QResizeEvent; class MandelbrotWidget : public QWidget { Q_OBJECT public: explicit MandelbrotWidget(QWidget *parent = 0); ~MandelbrotWidget(); private: MandelbrotCalculator mMandelbrotCalculator; QThread mThreadCalculator; double mScaleFactor; QPoint mLastMouseMovePosition; QPointF mMoveOffset; ...