-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.h
More file actions
247 lines (186 loc) · 4.9 KB
/
mainwindow.h
File metadata and controls
247 lines (186 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <string.h>
#include <QMainWindow>
#include "parameterwizard.h"
#include <QList>
#include <QListWidgetItem>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
#include <QValueAxis>
#include <QMenuBar>
#include <QAction>
#include <QLabel>
#include <QMdiArea>
//#include "account.h"
//#include "behaviour.h"
//#include "controlwidget.h"
#include "statsdialog.h"
#define QT_DEBUG
namespace Ui {
class MainWindow;
}
/*
* UPGRADE
* -------
* Parameters are used by Behaviours, Properties by Domains. Previously there
* was no distinction as a Model had both and only one Model
* could be active at any time.
*/
// This makes references to QCharts and related classes simpler.
QT_CHARTS_USE_NAMESPACE
//static QList<Domain*> domains;
//static Domain *currentDomain = nullptr;
//static Domain *defaultDomain = nullptr;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow() override;
void show();
static int magnitude(double);
signals:
void clockTick(int period);
void modelChanged(QString);
void windowShown();
void windowLoaded();
void drawingCompleted();
protected:
//void run(bool randomised = false);
int getStartPeriod();
// Much of this should be transferred to Domain
int _period;
int _iterations;
int _first_period;
// Domain *getDomain(QString);
int loadDomains(QListWidget *domainList);
// int loadDomainList();
int loadProfileList();
int getIters(); // number of iterations (periods)
int getPeriod();
void saveCSV();
void editParameters();
void createDomain();
void createProfile();
void removeProfile();
void saveSettingsAsProfile(QString name);
void remove();
void about();
void aboutQt();
void nyi();
// errorMessage terminates the program
void errorMessage [[noreturn]] (QString);
void setOptions();
void showWiki();
void showStatistics(); // will replace showStats()
//void showStats(QListWidgetItem *current, QListWidgetItem *prev);
void updateStatsDialog(QListWidgetItem *current/*, QListWidgetItem *previous*/);
void closeEvent(QCloseEvent *event) override;
//void restoreState();
void propertyChanged();
QMenuBar *myMenuBar;
QMenu *applicationMenu;
QMenu *fileMenu;
QMenu *editMenu;
QMenu *viewMenu;
QMenu *helpMenu;
QAction *saveCSVAction;
QAction *saveProfileAction;
QAction *removeProfileAction;
QAction *changeAction;
QAction *domainAction;
QAction *aboutAction;
QAction *aboutQtAction;
QAction *setOptionsAction;
QAction *helpAction;
QAction *statsAction;
QAction *runAction;
QAction *randomAction;
QAction *closeAction;
bool isBehaviourSelected();
private:
Ui::MainWindow *ui;
ParameterWizard *wiz;
QMdiArea mdi; // *****
QList<QMdiSubWindow*> mdiWindowList;
// QList<Domain*> domains;
QString chartProfile;
StatsDialog *statsDialog;
bool first_time_shown;
bool first_time_loaded;
bool profile_changed = false;
bool reloading = false;
bool updatingProfileList = false;
bool property_selected = false;
bool changing_profile = false;
//QMap<QString,Domain::Property> propertyMap;
QChartView *createChart();
void createActions();
void createMenus();
void createStatusBar();
void createDockWindows();
int createSubWindows();
/*
void drawChart(bool rerun, bool randomised = true);
void drawChartRandomised();
*/
void drawChartNormal();
void selectProfile(QString text);
//void changeBehaviour(QListWidgetItem*);
void changeProfile(QListWidgetItem*);
//void changeDomain(QListWidgetItem*);
QMap<Property,QColor> propertyColours;
QListWidgetItem *selectedBehaviourItem;
QMenu *mainMenu;
QChartView *chartView;
QChart *chart;
QListWidget *behaviourList;
QListWidget *profileList;
QListWidget *propertyList;
QStringList domainNameList;
QLabel *productivityLabel;
QLabel *inequalityLabel;
QLabel *infoLabel;
enum Opr
{
invalid_op,
eq,
neq,
lt,
gt,
leq,
geq
};
struct Condition
{
Property property = Property::zero;
Opr opr;
int val; // possibly extend to allow expressions later
};
struct Pair
{
bool is_set = false;
int val;
};
struct Params
{
Params();
Condition condition;
Pair invalid;
Pair iters;
Pair count;
Pair emp_rate;
Pair prop_con;
Pair inc_tax_rate;
Pair sales_tax_rate;
Pair firm_creation_prob;
Pair dedns;
Pair unemp_ben_rate;
Pair active_pop;
Pair reserve;
Pair prop_inv;
};
QList<Params*> paramList;
};
#endif // MAINWINDOW_H