QueueManager.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #ifndef QUEUEMANAGER_H_
  3. #define QUEUEMANAGER_H_
  4. #include <cinttypes>
  5. #include <vector>
  6. #include <future>
  7. #include "Bitmap.h"
  8. struct MandelViewport
  9. {
  10. /// real part of the top left corner
  11. double x = -2.1;
  12. /// imaginary part of the top left corner
  13. double y = -1.5;
  14. /// real-part span of the picture to be generated
  15. double width = 3;
  16. /// imaginary-part span of the picture to be generated
  17. double height = 3;
  18. /*!
  19. * \brief adjusts the aspect ratio of the viewport, making sure
  20. * the updated viewport contains all of the original one.
  21. */
  22. void adjustAspectRatio(double nwidth, double nheight);
  23. /*!
  24. * \brief make sure width and height are positive
  25. */
  26. void normalize(void);
  27. };
  28. struct MandelInfo
  29. {
  30. /// viewport
  31. MandelViewport view;
  32. /// width of the bitmap to be generated
  33. long bWidth;
  34. /// height of the bitmap to be generated
  35. long bHeight;
  36. /// maximum iterations
  37. int maxIter;
  38. };
  39. class MandelGenerator
  40. {
  41. public:
  42. MandelGenerator(void) = default;
  43. virtual ~MandelGenerator(void);
  44. virtual Bitmap<RGBColor> generate(const MandelInfo& mandelInfo);
  45. virtual Bitmap<float> generateRaw(const MandelInfo& info) = 0;
  46. };
  47. class QueueManager
  48. {
  49. public:
  50. QueueManager(void);
  51. ~QueueManager(void);
  52. std::future<Bitmap<RGBColor>> generate(const MandelInfo& mandelInfo);
  53. };
  54. #endif // QUEUEMANAGER_H_