FractalWidgetUtils.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef FRACTALWIDGETUTILS_H
  2. #define FRACTALWIDGETUTILS_H
  3. #include "Mandel.h"
  4. #include "EscapeTimeVisualWidget.h"
  5. #include <unordered_map>
  6. #include <QMetaType>
  7. using GridIndex = mnd::Integer;
  8. Q_DECLARE_METATYPE(GridIndex)
  9. Q_DECLARE_METATYPE(mnd::Real)
  10. class CellImage
  11. {
  12. public:
  13. CellImage(void) = default;
  14. CellImage(CellImage&& b) = default;
  15. CellImage(const CellImage& b) = delete;
  16. virtual ~CellImage(void);
  17. virtual void drawRect(float x, float y, float width, float height) = 0;
  18. virtual std::shared_ptr<CellImage> clip(short i, short j) = 0;
  19. virtual int getRecalcPriority(void) const = 0;
  20. };
  21. class ImageClip :
  22. public CellImage
  23. {
  24. std::shared_ptr<ETVImage> etvImage;
  25. float tx, ty, tw, th;
  26. public:
  27. ImageClip(std::shared_ptr<ETVImage> tex,
  28. float tx, float ty, float tw, float th);
  29. inline ImageClip(std::shared_ptr<ETVImage> tex) :
  30. ImageClip{ tex, 0.0f, 0.0f, 1.0f, 1.0f }
  31. {}
  32. ImageClip(ImageClip&&) = default;
  33. ImageClip(const ImageClip&) = delete;
  34. virtual ~ImageClip(void);
  35. void drawRect(float x, float y, float width, float height) override;
  36. ImageClip clip(float x, float y, float w, float h);
  37. std::shared_ptr<CellImage> clip(short i, short j) override;
  38. int getRecalcPriority(void) const override;
  39. };
  40. class QuadImage :
  41. public CellImage
  42. {
  43. std::shared_ptr<CellImage> cells[2][2];
  44. public:
  45. QuadImage(std::shared_ptr<CellImage> i00,
  46. std::shared_ptr<CellImage> i01,
  47. std::shared_ptr<CellImage> i10,
  48. std::shared_ptr<CellImage> i11);
  49. QuadImage(QuadImage&&) = default;
  50. QuadImage(const QuadImage&) = delete;
  51. virtual ~QuadImage(void);
  52. void drawRect(float x, float y, float width, float height) override;
  53. std::shared_ptr<CellImage> clip(short i, short j) override;
  54. int getRecalcPriority(void) const override;
  55. };
  56. struct GridElement
  57. {
  58. bool enoughResolution;
  59. std::shared_ptr<CellImage> img;
  60. inline GridElement(bool enoughResolution, std::shared_ptr<CellImage> img) :
  61. enoughResolution{ enoughResolution },
  62. img{ std::move(img) }
  63. {}
  64. };
  65. #endif // FRACTALWIDGETUTILS_H