SGSolve
sgmainwindow.hpp
1 // This file is part of the SGSolve library for stochastic games
2 // Copyright (C) 2019 Benjamin A. Brooks
3 //
4 // SGSolve free software: you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // SGSolve is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see
16 // <http://www.gnu.org/licenses/>.
17 //
18 // Benjamin A. Brooks
19 // ben@benjaminbrooks.net
20 // Chicago, IL
21 
22 #ifndef SGMAINWINDOW_HPP
23 #define SGMAINWINDOW_HPP
24 
25 #include <QMainWindow>
26 #include <QtWidgets>
27 #include <QSettings>
28 #include "sggamehandler.hpp"
29 #include "sgsolutionhandler.hpp"
30 #include "sgsolverworker.hpp"
31 #include "sgsettingshandler.hpp"
32 #include "sgplotsettingshandler.hpp"
33 #include "sg.hpp"
34 #include "sgrisksharing.hpp"
35 #include "sgrisksharinghandler.hpp"
36 #include "sgrandom.hpp"
37 #include "sgrandomhandler.hpp"
38 #include "sglegend.hpp"
39 
40 using namespace std;
41 
43 
58 class SGMainWindow : public QMainWindow
59 {
60  Q_OBJECT;
61 
62 private:
63  // Tab widget
65  QTabWidget * tabWidget;
66 
69 
72 
74  QThread solverThread;
75 
78 
81 
84 
87 
89  QTextEdit * logTextEdit;
90 
92  QTime timer;
93 
96 
98  QString path;
99 
101  QSettings *settings;
102 
104  void settingsLoader();
105 
107  void settingsSaver();
108 
109 public:
111 
112  SGMainWindow();
113 
115 
118  {
119  solverThread.quit();
120  solverThread.wait();
121  settingsSaver();
122  }
123 
124 protected:
126  virtual void keyPressEvent(QKeyEvent * event);
127 
128 signals:
131 
132 private slots:
134  void loadSolution();
136  void saveSolution();
138  void loadGame();
140  void saveGame();
141 
143  void quitProgram();
144 
146  void changeSettings();
147 
149  void settingsHandlerClosed();
150 
152  void changePlotSettings();
153 
155  void plotSettingsHandlerClosed();
156 
158  void screenShot();
159 
161  void cancelSolve();
162 
164  void solveGame();
166 
171  void iterationFinished(bool);
172 
174 
176  void solverException();
177 
179  void displayAbout();
180 
182  void displayLegend();
183 
185  void generateRSG();
186 
188  void generatePD();
189 
191  void generateBoS();
192 
194  void generateRandom();
195 };
196 
197 
198 #endif
SGMainWindow::settings
QSettings * settings
Program settings.
Definition: sgmainwindow.hpp:101
SGPlotSettingsHandler
A widget for setting parameters of the algorithm.
Definition: sgplotsettingshandler.hpp:95
SGSolutionHandler
Handles the widgets for displaying the solution.
Definition: sgsolutionhandler.hpp:70
SGMainWindow::~SGMainWindow
~SGMainWindow()
Destructor.
Definition: sgmainwindow.hpp:117
SGMainWindow::solutionHandler
SGSolutionHandler * solutionHandler
The object for interfacing with the solution.
Definition: sgmainwindow.hpp:77
SGSolverWorker
Class for implementing the twist algorithm within SGViewer.
Definition: sgsolverworker.hpp:47
SGSettingsHandler
A widget for setting parameters of the algorithm.
Definition: sgsettingshandler.hpp:195
SGMainWindow::env
SGEnv * env
Environment for computations.
Definition: sgmainwindow.hpp:68
SGMainWindow::path
QString path
Most recent path for saves/loads.
Definition: sgmainwindow.hpp:98
SGMainWindow::settingsHandler
SGSettingsHandler * settingsHandler
The object for controling environment settings.
Definition: sgmainwindow.hpp:83
SGMainWindow::cancelSolveFlag
bool cancelSolveFlag
Flag for canceling solve next time an iteration finishes.
Definition: sgmainwindow.hpp:95
SGEnv
Manages parameters for algorithm behavior.
Definition: sgenv.hpp:35
SGMainWindow::solverWorker
SGSolverWorker * solverWorker
Worker that handles solution.
Definition: sgmainwindow.hpp:71
SGGameHandler
This class handles the widgets for editing/displaying the game.
Definition: sggamehandler.hpp:47
SGMainWindow::logTextEdit
QTextEdit * logTextEdit
Text edit containing the log output.
Definition: sgmainwindow.hpp:89
SGMainWindow::gameHandler
SGGameHandler * gameHandler
The object for interfacing with the game.
Definition: sgmainwindow.hpp:80
SGMainWindow::startIteration
void startIteration()
Signal for SGSolverThread to start next iteration.
SGMainWindow::plotSettingsHandler
SGPlotSettingsHandler * plotSettingsHandler
The object for controling plot settings.
Definition: sgmainwindow.hpp:86
SGMainWindow::solverThread
QThread solverThread
Separate thread for running solve routines, so gui doesn't hang.
Definition: sgmainwindow.hpp:74
SGMainWindow::timer
QTime timer
Times progress of the algorithm.
Definition: sgmainwindow.hpp:92
SGMainWindow::tabWidget
QTabWidget * tabWidget
Widget containing game, solution, and log tabs.
Definition: sgmainwindow.hpp:60
SGMainWindow
Main window for SGViewer.
Definition: sgmainwindow.hpp:59