-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppConfig.h
173 lines (142 loc) · 5.38 KB
/
AppConfig.h
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
/* ***************************************************************************
* AppConfig.h: defines program configuration class
* author: Joe Petrus
* date: June 10th 2010
* ***************************************************************************/
#ifndef AppConfig_H
#define AppConfig_H
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Headers, definitions, etc.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
#include <QDialog>
#include <QPushButton>
#include <QDir>
#include <QVarLengthArray>
#include <iostream>
#include "ConfigFile/ConfigFile.h"
#include "ui_PreferencesDialog.h"
using namespace std;
#define SymmetryOpt 0
#define SharpnessOpt 1
#define CuIndex 0
#define CoIndex 1
#define CuLambda 1.5418e-10
#define CoLambda 1.7902e-10
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Structures
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
struct OptimizationRegion
{
QString name;
double start;
double stop;
};
struct MineralMacro
{
QString title;
double angleStart;
double angleStop;
double scale;
double offset;
bool autoSave;
};
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Main class definition
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/* ***************************************************************************
* class: AppConfig
* description: loads and saves and provides access to program configuration
* for other classes. Also provides a user interface to change some
* preferences.
* ***************************************************************************/
class AppConfig : public QObject
{
Q_OBJECT
public:
AppConfig(QWidget *parent);
/* Access methods */
string getLastPath() { return lastPath; }
bool getUntilNoChange() { return untilNoChange; }
bool getNormalizeOpt() { return normalizeOpt; }
bool getUseSearchGrid() { return useSearchGrid; }
int getOptIndex() { return optIndex; }
int getXRangeSharpness() { return xRangeSharpness; }
int getYRangeSharpness() { return yRangeSharpness; }
int getXRangeSymmetry() { return xRangeSymmetry; }
int getYRangeSymmetry() { return yRangeSymmetry; }
double getAlphaRange() { return alphaRange; }
double getPhiRange() { return phiRange; }
double getRadiusRange() { return radiusRange; }
double getCircleRadius() { return circleRadius; }
double getCameraRadius() { return cameraRadius; }
double getIntStepSize() { return intStepSize; }
double getIntWidth() { return intWidth; }
double getMachineOffset() { return machineOffset; }
double getLambda() { return (sourceIndex == CuIndex) ? CuLambda : CoLambda; }
QMap<QString, OptimizationRegion> getOptRegions() { return optRegions; }
OptimizationRegion getOptRegion(QString name) { return optRegions[name]; }
QMap<QString, MineralMacro> getMineralMacros() { return mineralMacros; }
MineralMacro getMineralMacro(QString title) { return mineralMacros[title]; }
/* Storing methods */
void saveOptRegion(QString name, OptimizationRegion oreg) { optRegions[name] = oreg; populateRegions(); }
void saveMineralMacro(QString title, MineralMacro mm) { mineralMacros[title] = mm; }
void setLastPath(string p) { lastPath = p; }
void deleteMacro(QString title) { mineralMacros.remove(title); }
void populateRegions();
void saveRegionsFromTable();
signals:
void valuesChanged();
public slots:
void loadConfig();
void saveConfig();
void showPrefs() { prefsDialog->show(); populateRegions(); }
void addRegion();
void deleteRegion();
private slots:
void updateNoChange(bool b) { untilNoChange = b; }
void updateIntStep(double d) { intStepSize = d; }
void updateOptIndex(int i) { optIndex = i; }
void updateSourceIndex(int i) { sourceIndex = i; }
void updateCircleRadius(double cR) { circleRadius = cR; }
void updateXRangeSharpness(int x) { xRangeSharpness = x; }
void updateYRangeSharpness(int y) { yRangeSharpness = y; }
void updateXRangeSymmetry(int x) { xRangeSymmetry = x; }
void updateYRangeSymmetry(int y) { yRangeSymmetry = y; }
void updatePhiRange(double r) { phiRange = r; }
void updateAlphaRange(double r) { alphaRange = r; }
void updateRadiusRange(double r) { radiusRange = r/1000.0; }
void updateCameraRadius(double r) { cameraRadius = r/1000.0; }
void updateIntWidth(double w) { intWidth = w/1000.0; }
void updateMachineOffset(double m) { machineOffset = m; }
void updateUseSearchGrid(bool b) { useSearchGrid = b; }
void updateNormalizeOpt(bool b) { normalizeOpt = b; }
private:
Ui::PreferencesDialog UiPrefs;
QDialog *prefsDialog;
ConfigFile *cfgFile;
/* General */
int sourceIndex;
double cameraRadius;
/* Optimization */
int optIndex;
int xRangeSymmetry;
int yRangeSymmetry;
int xRangeSharpness;
int yRangeSharpness;
bool untilNoChange;
bool normalizeOpt;
bool useSearchGrid;
double phiRange;
double alphaRange;
double radiusRange;
/* Integration */
double intStepSize;
double circleRadius;
double intWidth;
double machineOffset;
/* Other */
string lastPath;
QMap<QString, OptimizationRegion> optRegions;
QMap<QString, MineralMacro> mineralMacros;
};
#endif