// // Created by natty on 15.7.23. // #ifndef TSP_RENDERWINDOW_H #define TSP_RENDERWINDOW_H #include #include #include #include #include #include #include #include #include #include struct State; struct Vertex { double x; double y; }; struct Edge { size_t from; size_t to; double distanceOf(const State& state, const Vertex& vertex) const; }; struct State { std::vector vertices; std::vector edges; }; class Strategy { public: virtual ~Strategy() = default; virtual bool step(State& state) = 0; }; class AnnaStrategy : public Strategy { public: bool step(State& state) override; private: bool init; std::vector unvisited; }; class RenderWindow : public QMainWindow { Q_OBJECT public: RenderWindow(); ~RenderWindow() override; void paintEvent(QPaintEvent* event) override; public slots: void render(); void step(); void solve(); private: QVBoxLayout *layout; QHBoxLayout *controlsLayout; QWidget *renderArea; QWidget *mainWindowWidget; QLabel *distanceLabel; QPushButton *playButton; QComboBox *strategySelector; QTimer *animTimer; SDL_Window *window{}; SDL_Renderer* renderer{}; State state; std::unique_ptr strategy; private slots: void resetState(); void hardResetState(); void togglePlay(bool play); }; #endif //TSP_RENDERWINDOW_H