FractalWidget.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef FRACTALWIDGET_H
  2. #define FRACTALWIDGET_H
  3. #include "FractalZoomWidget.h"
  4. #include <QPropertyAnimation>
  5. #include <chrono>
  6. class ViewportAnimation :
  7. public QPropertyAnimation
  8. {
  9. public:
  10. ViewportAnimation(QObject* parent = nullptr);
  11. QVariant interpolated(const QVariant& from, const QVariant& to,
  12. qreal progress) const override;
  13. };
  14. class FractalWidget :
  15. public FractalZoomWidget
  16. {
  17. bool rubberbanding = false;
  18. QRectF rubberband;
  19. bool dragging = false;
  20. float dragX, dragY;
  21. bool selectingPoint = false;
  22. float pointX, pointY;
  23. /// the target of an ongoing animation
  24. mnd::MandelViewport targetViewport;
  25. std::chrono::time_point<std::chrono::high_resolution_clock> lastAnimUpdate;
  26. public:
  27. FractalWidget(QWidget* parent = nullptr);
  28. void mousePressEvent(QMouseEvent* me) override;
  29. void mouseMoveEvent(QMouseEvent* me) override;
  30. void mouseReleaseEvent(QMouseEvent* me) override;
  31. void wheelEvent(QWheelEvent* we) override;
  32. virtual void zoom(float factor) override;
  33. virtual void zoom(float factor, float fx, float fy);
  34. virtual void setViewport(const mnd::MandelViewport& viewport) override;
  35. virtual const mnd::MandelViewport& getViewport(void) const override;
  36. virtual void resizeGL(int w, int h) override;
  37. virtual void paintGL(void) override;
  38. private:
  39. void newAnimation(void);
  40. void updateAnimations(void);
  41. };
  42. #endif // FRACTALWIDGET_H