This repository has been archived by the owner on Nov 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Option.cpp
304 lines (241 loc) · 7.64 KB
/
Option.cpp
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
// Copyright (C) 2012-2015, Ali Baharev
// All rights reserved.
// This code is published under the GNU Lesser General Public License.
#include <QStringList>
#include <QDebug>
#include "Option.hpp"
namespace {
const Default setDefault = Default();
// Keep this as the first item (index 0), and in this order.
// It will be treated as special, and not shown on the GUI.
// Compare with SettingsWidget hacks, concering the run mode.
Option mode_opts[] = {
Option("Field or well data", "WELLDATA")
<< "Field" << "N" << setDefault
<< "Well" << "Y"
};
Option conv_opts[] = {
Option("Data convention", "DATARULE")
<< "German dip directon" << "G" << setDefault
<< "Right hand rule" << "R",
Option("Plot type", "PLOT")
<< "Angelier plot" << "A" << setDefault
<< "Hoeppner pole point" << "H",
Option("Projection type", "PLOTTYPE")
<< "Schmidt" << "S" << setDefault
<< "Wulff" << "W",
Option("Hemisphere", "HEMISPHERE")
<< "Upper" << "U"
<< "Lower" << "L" << setDefault,
Option("Contouring on stereonet", "CONTOURING")
<< "None" << "N" << setDefault
//<< "Schmidt 1% method" << "S"
//<< "Kamb\'s (1959) method" << "K"
<< "Dip direction / bearing" << "D"
<< "Strike direction / bearing" << "S"
<< "Plane normal / bearing" << "O"
<< "Striae bearing / bearing" << "B",
Option("Bedding & palaeonorth correction", "TILTING")
<< "Re-tilt with bedding" << "B"
<< "Only palaeonorth" << "P"
<< "Both" << "A" << setDefault
};
Option inver_opts[] = {
Option("Inversion methodology", "INVERSION")
<< "NDA after Spang (1972)" << "D" << setDefault
<< "PTN after Turner (1953)" << "P"
<< "Fry (1999)" << "F"
<< "Shan et al (2003)" << "S"
<< "Michael (1984)" << "M"
<< "Angelier (1990)" << "A"
<< "Mostafa (2005)" << "O"
<< "Brute force" << "B"
<< "None" << "N",
Option("Bingham statistics", "BINGHAM")
<< "Yes" << "B" << setDefault
<< "No" << "N",
// TODO Spinbox would be more appropriate
Option("Maximum stress & slickenside direction angle", "STRESSANGLE")
<< "10" << "10"
<< "15" << "15"
<< "20" << "20"
<< "25" << "25"
<< "30" << "30" << setDefault
<< "35" << "35"
<< "40" << "40"
<< "45" << "45"
<< "50" << "50"
<< "55" << "55"
<< "60" << "60"
<< "65" << "65"
<< "70" << "70"
<< "75" << "75"
<< "80" << "80",
Option("Forced Andersonian stress conditions", "VIRTUAL")
<< "Yes" << "Y"
<< "No" << "N" << setDefault
};
Option group_opts[] = {
Option("Use formation name to group", "FORMATION")
<< "Yes" << "Y" << setDefault
<< "No" << "N",
Option("Use user-defined groups", "GROUP")
<< "Yes" << "Y" << setDefault
<< "No" << "N",
Option("Cluster numbers", "CLUSTERNUMBER")
<< "Ideal" << "A"
<< "Don\'t use" << "N" << setDefault
<< "2" << "2"
<< "3" << "3"
<< "4" << "4"
<< "5" << "5"
<< "6" << "6"
<< "7" << "7"
<< "8" << "8"
<< "9" << "9",
Option("Clustering by stress estimator", "RUP_CLUSTERING")
<< "Don\'t use" << "N" << setDefault
<< "Angular misfit (ANG)" << "A"
<< "Relative upsilon (RUP)" << "R",
Option("Separation of the output by", "GROUPSEPARATION")
<< "Don\'t separate" << "I" << setDefault
<< "User-defined groups" << "G"
<< "K-means clustering" << "K"
<< "RUP/ANG clustering" << "R",
Option("Group re-processing", "INPUTGROUP")
<< "Ignore groups" << "N" << setDefault
<< "Original user-defined" << "F"
<< "Former k-means clustering" << "S"
<< "Former RUP/ANG clustering" << "T",
};
Option rose_opts[] = {
Option("Rose plot type", "ROSETYPE")
<< "Bidirectional" << "S" << setDefault
<< "Unidirectional" << "A",
Option("Plot rose diagram according to", "ROSEDIRECTION")
<< "Strike directions" << "S" << setDefault
<< "Dip directions" << "D",
Option("Bin size for rose plot in degrees", "ROSEBINNING")
<< "2.5" << "A"
<< "5.0" << "B"
<< "10.0" << "C" << setDefault
<< "22.5" << "D"
};
Option plot_opts[] = {
Option("Display resolved shear direction", "IDEALMOVEMENT")
<< "Yes" << "Y"
<< "No" << "N" << setDefault,
Option("Labeling", "LABELING")
<< "Yes" << "Y"
<< "No" << "N" << setDefault,
// TODO Spinbox would be more appropriate
Option("Line width used on stereonets in points", "LINEWIDTH")
<< "0.1" << "1"
<< "0.2" << "2"
<< "0.3" << "3"
<< "0.4" << "4"
<< "0.5" << "5"
<< "0.6" << "6" << setDefault
<< "0.7" << "7"
<< "0.8" << "8"
<< "0.9" << "9"
<< "1.0" << "0",
Option("Coloring by", "COLORING")
<< "Uniform black" << "I" << setDefault
<< "Color code" << "C"
<< "User-defined groups" << "G"
<< "K-means clustering" << "K"
<< "RUP/ANG clustering" << "R",
Option("Grayscale", "GRAYSCALE")
<< "Coloured output" << "N" << setDefault
<< "Grayscale mode" << "Y"
};
Option well_opts[] = {
Option("Bin size measured in", "WELLINTERVAL")
<< "meters" << "M" << setDefault
<< "data points" << "D",
Option("Bin size", "WELLINTERVAL_LENGTH")
<< "1" << "1"
<< "2" << "2"
<< "5" << "5"
<< "10" << "10"
<< "20" << "20"
<< "50" << "50"
<< "100" << "100" << setDefault
<< "200" << "200"
<< "500" << "500"
<< "1000" << "1000"
<< "2000" << "2000"
<< "5000" << "5000",
Option("Bin midpoint", "WELLINTERVAL_MIDDLE")
<< "average depth" << "A"
<< "median depth" << "M" << setDefault
};
template <typename T, int N>
QVector<T> qVec(T (&arr)[N]) {
QVector<T> vec;
vec.reserve(N);
for (int i=0; i<N; ++i) {
vec.push_back(arr[i]);
}
return vec;
}
template <typename T, typename U, int N>
void add(QVector<T>& vec, const char* name, U (&options)[N]) {
vec.push_back( qMakePair(QString(name), qVec(options)) );
}
// TODO A hack so that the SettingsWidget can
// disable the well options if we are in field mode.
int WELL_GROUP_INDEX;
QVector<OptionGroup> createOptionGroups() {
QVector<OptionGroup> vec;
add(vec, "Processing mode", mode_opts);
add(vec, "Conventions", conv_opts);
add(vec, "Inversion", inver_opts);
add(vec, "Rose diagram", rose_opts);
add(vec, "Well data processing", well_opts);
WELL_GROUP_INDEX = vec.size()-1;
add(vec, "Group management", group_opts);
add(vec, "Plotting", plot_opts);
return vec;
}
const QVector<OptionGroup> optionGroups( createOptionGroups() );
} // end of anonymous namespace
const QVector<OptionGroup>& getOptionGroups() {
return optionGroups;
}
int numberOfGroups() {
return optionGroups.size();
}
int wellGroupIndex() {
return WELL_GROUP_INDEX;
}
Option::Option(const QString& guiKey, const QString& cliKey)
: key(guiKey),
cliKey(cliKey),
defaultElem(-1)
{
}
Option& Option::operator<<(const QString& value_str) {
if (cliValues.size() == values.size()) {
values.append(value_str);
}
else {
cliValues.append(value_str);
}
return *this;
}
Option& Option::operator<<(const Default& ) {
defaultElem = values.size() - 1;
return *this;
}
void Option::checkConsistency() const {
Q_ASSERT( values.size()==cliValues.size() );
Q_ASSERT( 0 <= defaultElem);
Q_ASSERT( defaultElem < values.size() );
}
QString Option::toCLIString(int i) const {
// compare with SettingsWidget loadSettings()
// where the file is parsed
return cliKey + ":\t" + cliValues.at(i);
}