choosegenerators.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef CHOOSEGENERATORS_H
  2. #define CHOOSEGENERATORS_H
  3. #include "ui_choosegenerators.h"
  4. #include <Mandel.h>
  5. #include <IterationCompiler.h>
  6. #include "Bitmap.h"
  7. #include <QDialog>
  8. #include <QValidator>
  9. #include <QLineEdit>
  10. #include <QComboBox>
  11. #include <QRunnable>
  12. #include <QThread>
  13. #include <QThreadPool>
  14. #include <memory>
  15. #include <map>
  16. class Almond;
  17. namespace Ui
  18. {
  19. class ChooseGenerators;
  20. }
  21. class Benchmarker : public QObject, public QRunnable
  22. {
  23. Q_OBJECT
  24. private:
  25. mnd::MandelContext& mndContext;
  26. mnd::MandelGenerator& generator;
  27. int row;
  28. float percentage;
  29. static const std::vector<mnd::MandelInfo> benches;
  30. public:
  31. inline Benchmarker(mnd::MandelContext& mndContext, mnd::MandelGenerator& generator, int row, float percentage) :
  32. mndContext{ mndContext },
  33. generator{ generator },
  34. row{ row },
  35. percentage{ percentage }
  36. {
  37. }
  38. virtual ~Benchmarker(void) override;
  39. static mnd::MandelViewport benchViewport(void);
  40. std::pair<long long, std::chrono::nanoseconds> measureMips(const std::function<Bitmap<float>*()>& bench) const;
  41. double benchmarkResult(mnd::MandelGenerator& mg) const;
  42. void run(void) override;
  43. signals:
  44. void finished(int row, float percentage, double mips);
  45. };
  46. struct FractalDef
  47. {
  48. QString name;
  49. QString z0;
  50. QString zi;
  51. mnd::GeneratorCollection gc;
  52. };
  53. class ChooseGenerators : public QDialog
  54. {
  55. Q_OBJECT
  56. private:
  57. Almond& owner;
  58. Ui::ChooseGenerators* sadfgsdfg;
  59. std::unique_ptr<Ui::ChooseGenerators> ui;
  60. mnd::MandelContext& mndCtxt;
  61. std::map<QString, mnd::MandelGenerator*> generators;
  62. std::vector<std::pair<QLineEdit*, QComboBox*>> tableContent;
  63. std::unique_ptr<QValidator> floatValidator;
  64. //std::unique_ptr<mnd::AdaptiveGenerator> createdGenerator;
  65. mnd::MandelGenerator* chosenGenerator;
  66. std::vector<mnd::MandelGenerator*> actualGenerators;
  67. std::vector<FractalDef> fractalDefs;
  68. QThreadPool benchmarker;
  69. public:
  70. ChooseGenerators(mnd::MandelContext& mndCtxt, Almond& owner);
  71. ~ChooseGenerators();
  72. inline mnd::MandelGenerator* getChosenGenerator(void) { return chosenGenerator; }
  73. private:
  74. QComboBox* createComboBox(void);
  75. QLineEdit* createFloatText(void);
  76. public slots:
  77. private slots:
  78. void setBenchmarkResult(int row, float percentage, double mips);
  79. void on_buttonBox_accepted();
  80. void on_run_clicked();
  81. void on_generatorTable_cellDoubleClicked(int row, int column);
  82. void on_compile_clicked();
  83. void on_benchmark_clicked();
  84. };
  85. #endif // CHOOSEGENERATORS_H