#ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include class QLineEdit; class QPushButton; class VisualizationWiew; /// State of the simulation enum class State { stopped, simulating, paused }; /// Main window of the simulation. Contains the visualization area and the simulation parameters class MainWindow : public QMainWindow { Q_OBJECT Q_DISABLE_COPY(MainWindow) protected: /// Paints itself choosing pixels according to the temperature of the surface VisualizationWiew* visualizationWiew = nullptr; /// Allows user to input the epsilon QLineEdit* epsilonControl = nullptr; /// Refresh rate chosen by user QLineEdit* refreshRateControl = nullptr; /// Starts or pauses the simulation QPushButton* startPauseButton = nullptr; /// Stops the simulation QPushButton* stopButton = nullptr; /// State of the simulation State state = State::stopped; /// Measure the duration of the simulation QTime time; public: /// Constructor explicit MainWindow(QWidget* parent = nullptr); /// Loads a csv file bool loadCsv(const QString& filePath); public slots: /// Called when user presses the start/pause button void startPauseSimulation(); /// Called when user presses the stop button void stopSimulation(); /// Called when the simulation finishes void simulationDone(unsigned long long generations); /// Called each time a refresh is done void refreshProgress(); protected: /// Constructs the GUI void buildInterface(); /// Accept only dragging of files virtual void dragEnterEvent(QDragEnterEvent* event) override; /// Open files when dropped from file explorer virtual void dropEvent(QDropEvent* event) override; /// Starts or resumes a simulation. It uses the given epsilon void startResumeSimulation(); /// Pauses the simulation void pauseSimulation(); }; #endif // MAINWINDOW_H