#ifndef CHOOSEGENERATORS_H #define CHOOSEGENERATORS_H #include "ui_choosegenerators.h" #include #include #include "Bitmap.h" #include #include #include #include #include #include #include #include #include class Almond; namespace Ui { class ChooseGenerators; } class Benchmarker : public QObject, public QRunnable { Q_OBJECT private: mnd::MandelContext& mndContext; mnd::MandelGenerator& generator; int row; float percentage; static const std::vector benches; public: inline Benchmarker(mnd::MandelContext& mndContext, mnd::MandelGenerator& generator, int row, float percentage) : mndContext{ mndContext }, generator{ generator }, row{ row }, percentage{ percentage } { } virtual ~Benchmarker(void) override; static mnd::MandelViewport benchViewport(void); std::pair measureMips(const std::function*()>& bench) const; double benchmarkResult(mnd::MandelGenerator& mg) const; void run(void) override; signals: void finished(int row, float percentage, double mips); }; class ChooseGenerators : public QDialog { Q_OBJECT private: Almond& owner; Ui::ChooseGenerators* sadfgsdfg; std::unique_ptr ui; mnd::MandelContext& mndCtxt; std::map generators; std::vector> tableContent; std::unique_ptr chosenGenerator; std::vector actualGenerators; mnd::AdaptiveGenerator& generator; std::vector allGenerators; std::unique_ptr floatValidator; QThreadPool benchmarker; public: /*! * \brief create a dialog that lets choose from the default mandelbrot generators */ ChooseGenerators(mnd::MandelContext& mndCtxt, mnd::AdaptiveGenerator& generator, Almond& owner); /*! * \brief create a dialog that lets choose from the default mandelbrot generators */ ChooseGenerators(mnd::MandelContext& mndCtxt, mnd::GeneratorCollection& gc, mnd::AdaptiveGenerator& generator, Almond& owner); ~ChooseGenerators(); inline std::unique_ptr extractChosenGenerator(void) { return std::move(chosenGenerator); } private: void initializeTables(const std::vector &allGenerators); QComboBox* createComboBox(void); QLineEdit* createFloatText(void); void addRowAt(int index); public slots: private slots: void setBenchmarkResult(int row, float percentage, double mips); void on_buttonBox_accepted(); void on_run_clicked(); void on_generatorTable_cellDoubleClicked(int row, int column); void on_addRow_clicked(); void on_removeRow_clicked(); }; #endif // CHOOSEGENERATORS_H