SGSolve
sgplotsettings.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 SGPLOTSETTINGS_HPP
23 #define SGPLOTSETTINGS_HPP
24 
25 #include "qcustomplot.h"
26 
28 {
29 private:
30  std::vector<QCPScatterStyle> styles;
31  std::vector<QPen> pens;
32  std::vector<bool> features;
33 public:
34  enum SGScatterParam
35  {
36  PivotStyle,
37  ExpPivotStyle,
38  StageStyle,
39  BindingPayoffStyle,
40  ICPayoffStyle,
41  PayoffStyle,
42  TupleStyle,
43  NumScatterParams
44  };
45 
46  enum SGPenParam
47  {
48  StagePen,
49  PivotPen,
50  ExpPivotPen,
51  ExpPen,
52  PrevExpPen,
53  ValuePen,
54  ICPen,
55  BindingPayoffPen,
56  DirectionPen,
57  GenLinePen,
58  NumPenParams
59  };
60 
61  enum SGPlotFeature
62  {
63  StagePayoffs,
64  Pivot,
65  ExpPivot,
66  PayoffSet,
67  ExpPayoffSet,
68  PrevExpPayoffSet,
69  ICBoundary,
70  BindingPayoffs,
71  Direction,
72  GenLines,
73  GridLines,
74  ZeroLines,
75  UniformRanges,
76  NumPlotFeatures
77  };
78 
81  styles(SGPlotSettings::NumScatterParams),
82  pens(SGPlotSettings::NumPenParams),
83  features(SGPlotSettings::NumPlotFeatures,true)
84  {
85  restoreDefaults();
86  }
87 
88  void restoreDefaults()
89  {
90  // Set default values
91  for (int param = 0; param < SGPlotSettings::NumScatterParams; param++)
92  restoreDefault(static_cast<SGPlotSettings::SGScatterParam>(param));
93  for (int param = 0; param < SGPlotSettings::NumPenParams; param++)
94  restoreDefault(static_cast<SGPlotSettings::SGPenParam>(param));
95  } // restore defaults
96 
97  void restoreDefault(const SGPlotSettings::SGScatterParam param);
98 
99  void restoreDefault(const SGPlotSettings::SGPenParam param);
100 
101  const QCPScatterStyle & get(const SGPlotSettings::SGScatterParam param) const
102  { return styles[param]; }
103 
104  const QPen & get(const SGPlotSettings::SGPenParam param) const
105  { return pens[param]; }
106 
107  bool get(const SGPlotSettings::SGPlotFeature param) const
108  { return features[param]; }
109 
110  void set(const SGPlotSettings::SGScatterParam param,
111  const QCPScatterStyle & newStyle)
112  { styles[param] = newStyle; }
113 
114  void set(const SGPlotSettings::SGPenParam param,
115  const QPen & newPen)
116  { pens[param] = newPen; }
117 
118  void set(const SGPlotSettings::SGPlotFeature param, bool tf);
119 
120  void disable(const SGPlotSettings::SGScatterParam param)
121  { styles[param].setPen(Qt::NoPen); }
122 
123  void disable(const SGPlotSettings::SGPenParam param)
124  { pens[param].setStyle(Qt::NoPen); }
125 
126 
127 }; // SGPlotSettings
128 
129 
130 
131 
132 #endif
SGPlotSettings::SGPlotSettings
SGPlotSettings()
Constructor.
Definition: sgplotsettings.hpp:80
SGPlotSettings
Definition: sgplotsettings.hpp:28