SGSolve
sgplotsettingshandler.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 SGPLOTSETTINGSHANDLER_HPP
23 #define SGPLOTSETTINGSHANDLER_HPP
24 
25 #include <QWidget>
26 #include <QMenuBar>
27 #include <QAction>
28 #include <QFormLayout>
29 #include <QLineEdit>
30 #include <QPushButton>
31 #include <QCheckBox>
32 #include <QDialog>
33 #include "sgplotsettings.hpp"
34 
35 class SGPlotFeatureBox : public QCheckBox
36 {
37  Q_OBJECT;
38 private:
40  SGPlotSettings::SGPlotFeature param;
44  void setCheck(bool tf)
45  {
46  if (tf)
47  setCheckState(Qt::Checked);
48  else
49  setCheckState(Qt::Unchecked);
50  }
51 
52 public:
54  SGPlotFeatureBox(QWidget * parent,
55  SGPlotSettings * _plotSettings,
56  SGPlotSettings::SGPlotFeature _param):
57  plotSettings(_plotSettings),
58  param(_param),
59  QCheckBox()
60  {
62 
63  connect(this,SIGNAL(clicked(bool)),
64  this,SLOT(changeParam()));
65  connect(parent,SIGNAL(restoreDefaultSignal()),
66  this,SLOT(resetParam()));
67 
68  } // constructor
69 
70 private slots:
72  void changeParam()
73  {
74  plotSettings->set(param,isChecked());
75  }
77  void resetParam()
78  {
79  setCheck(Qt::Checked);
80  plotSettings->set(param,true);
81  }
82 }; // SGPlotFeatureBox
83 
85 
94 class SGPlotSettingsHandler : public QDialog
95 {
96  Q_OBJECT;
97 
98 private:
101 
102 public:
104  SGPlotSettingsHandler(QWidget * parent,
105  SGPlotSettings * _plotSettings);
108 
109 signals:
114 private slots:
120  {
121  plotSettings->restoreDefaults();
123  emit restoreDefaultSignal();
124  } // restoreDefaults
125 
126 };
127 
128 #endif
SGPlotSettingsHandler
A widget for setting parameters of the algorithm.
Definition: sgplotsettingshandler.hpp:95
SGPlotSettingsHandler::closeWindow
void closeWindow()
Closes the window by sending signal to SGSolutionHandler.
Definition: sgplotsettingshandler.hpp:116
SGPlotFeatureBox::SGPlotFeatureBox
SGPlotFeatureBox(QWidget *parent, SGPlotSettings *_plotSettings, SGPlotSettings::SGPlotFeature _param)
Constructor.
Definition: sgplotsettingshandler.hpp:54
SGPlotFeatureBox::resetParam
void resetParam()
Slot called when resetting to default values.
Definition: sgplotsettingshandler.hpp:77
SGPlotFeatureBox
Definition: sgplotsettingshandler.hpp:36
SGPlotSettingsHandler::closePlotSettingsHandler
void closePlotSettingsHandler()
Signals to SGSolutionHandler to delete this widget.
SGPlotSettingsHandler::plotSettings
SGPlotSettings * plotSettings
Pointer to the associated SGEnv object.
Definition: sgplotsettingshandler.hpp:96
SGPlotFeatureBox::changeParam
void changeParam()
Slot called when the check is modified.
Definition: sgplotsettingshandler.hpp:72
SGPlotSettingsHandler::restoreDefaultSignal
void restoreDefaultSignal()
Signals all of the edits and check boxes to reset to default values.
SGPlotSettings
Definition: sgplotsettings.hpp:28
SGPlotSettingsHandler::SGPlotSettingsHandler
SGPlotSettingsHandler(QWidget *parent, SGPlotSettings *_plotSettings)
Constructor.
Definition: sgplotsettingshandler.cpp:24
SGPlotSettingsHandler::~SGPlotSettingsHandler
virtual ~SGPlotSettingsHandler()
Destructor.
Definition: sgplotsettingshandler.hpp:107
SGPlotFeatureBox::plotSettings
SGPlotSettings * plotSettings
The associated environment.
Definition: sgplotsettingshandler.hpp:42
SGPlotFeatureBox::setCheck
void setCheck(bool tf)
The set method.
Definition: sgplotsettingshandler.hpp:44
SGPlotFeatureBox::param
SGPlotSettings::SGPlotFeature param
The boolean parameter associated with the box.
Definition: sgplotsettingshandler.hpp:37
SGPlotSettingsHandler::restoreDefaults
void restoreDefaults()
Definition: sgplotsettingshandler.hpp:119