SGSolve
SGMainWindow Class Reference

Main window for SGViewer. More...

#include <sgmainwindow.hpp>

Inheritance diagram for SGMainWindow:
Collaboration diagram for SGMainWindow:

Signals

void startIteration ()
 Signal for SGSolverThread to start next iteration.
 

Public Member Functions

 SGMainWindow ()
 Constructor. More...
 
 ~SGMainWindow ()
 Destructor. More...
 

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *event)
 Handles keyboard shortcuts.
 

Private Slots

void loadSolution ()
 Triggers a solution load.
 
void saveSolution ()
 Triggers a solution save.
 
void loadGame ()
 Triggers a game load.
 
void saveGame ()
 Triggers a game save.
 
void quitProgram ()
 Quits the program.
 
void changeSettings ()
 Changes settings for the SGEnv object.
 
void settingsHandlerClosed ()
 Changes settings for the SGEnv object.
 
void changePlotSettings ()
 Changes plot settings.
 
void plotSettingsHandlerClosed ()
 Changes plot settings.
 
void screenShot ()
 Triggers a new screen shot.
 
void cancelSolve ()
 Throws the cancel solution flag.
 
void solveGame ()
 Initializes solve routine for ABS 2018.
 
void iterationFinished (bool)
 Slot when iteration finishes. More...
 
void solverException ()
 Triggers error message in log. More...
 
void displayAbout ()
 Displays an about message.
 
void displayLegend ()
 Displays a legend.
 
void generateRSG ()
 Generate risk sharing game.
 
void generatePD ()
 Generate prisoner's dilemma game.
 
void generateBoS ()
 Generate a Battle of the Sexes.
 
void generateRandom ()
 Generates a random game.
 

Private Member Functions

void settingsLoader ()
 Loads saved settings.
 
void settingsSaver ()
 Saves settings.
 

Private Attributes

QTabWidget * tabWidget
 Widget containing game, solution, and log tabs.
 
SGEnvenv
 Environment for computations.
 
SGSolverWorkersolverWorker
 Worker that handles solution.
 
QThread solverThread
 Separate thread for running solve routines, so gui doesn't hang.
 
SGSolutionHandlersolutionHandler
 The object for interfacing with the solution.
 
SGGameHandlergameHandler
 The object for interfacing with the game.
 
SGSettingsHandlersettingsHandler
 The object for controling environment settings.
 
SGPlotSettingsHandlerplotSettingsHandler
 The object for controling plot settings.
 
QTextEdit * logTextEdit
 Text edit containing the log output.
 
QTime timer
 Times progress of the algorithm.
 
bool cancelSolveFlag
 Flag for canceling solve next time an iteration finishes.
 
QString path
 Most recent path for saves/loads.
 
QSettings * settings
 Program settings.
 

Detailed Description

Main window for SGViewer.

This class constructs the tabs and layouts. It also contains signals and slots for handling certain high level functions, such as solving, saving, and loading saved content.

Note that rather than using SGSolver, this class essentially replicates the behavior of the SGSolver class in its solveGame routine. The reason is that SGSolver runs straight through. We want to provide updates in the log window as the solver proceeds, which is facilitated by running SGSolverWorker one iteration at a time, printing the output when each revolution finishes, and then restarting the solve routine. Also allows the user to cancel a computation when the next iteration finishes.

Constructor & Destructor Documentation

◆ SGMainWindow()

SGMainWindow::SGMainWindow ( )

Constructor.

Initializes member objects and connects signals and slots.

◆ ~SGMainWindow()

SGMainWindow::~SGMainWindow ( )
inline

Destructor.

Just closes down the solver thread. Should other objects be destroyed?

Member Function Documentation

◆ iterationFinished

void SGMainWindow::iterationFinished ( bool  tf)
privateslot

Slot when iteration finishes.

Checks if the algorithm has converged or if maximum number of iterations has finished. If the algorithm has finished, plots the solution. If the algorithm has not converged and the cancel flag is false, the next iteration is started. If the cancel flag is thrown, will not trigger the next iteration.

◆ solverException

void SGMainWindow::solverException ( )
privateslot

Triggers error message in log.

When the algorithm throws an exception, triggers an error message report.


The documentation for this class was generated from the following files: