FractalWidget.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. bool displayInfo = false;
  24. /// the target of an ongoing animation
  25. mnd::MandelViewport targetViewport;
  26. std::chrono::time_point<std::chrono::high_resolution_clock> lastAnimUpdate;
  27. public:
  28. FractalWidget(QWidget* parent = nullptr);
  29. void mousePressEvent(QMouseEvent* me) override;
  30. void mouseMoveEvent(QMouseEvent* me) override;
  31. void mouseReleaseEvent(QMouseEvent* me) override;
  32. void wheelEvent(QWheelEvent* we) override;
  33. virtual void zoom(float factor) override;
  34. virtual void zoom(float factor, float fx, float fy);
  35. virtual void setViewport(const mnd::MandelViewport& viewport) override;
  36. virtual const mnd::MandelViewport& getViewport(void) const override;
  37. void setDisplayInfo(bool displayInfo);
  38. virtual void resizeGL(int w, int h) override;
  39. virtual void paintGL(void) override;
  40. void drawDisplayInfo(void);
  41. private:
  42. void newAnimation(void);
  43. void updateAnimations(void);
  44. };
  45. #endif // FRACTALWIDGET_H