-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolytope.h
277 lines (259 loc) · 7.72 KB
/
polytope.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
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
/*
MIT License
libahp_xc library to drive the AHP XC correlators
Copyright (C) 2020 Ilia Platone
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef POLYTOPE_H
#define POLYTOPE_H
#include <QThread>
#include <QList>
#include <QWidget>
#include <QSettings>
#include <QLineSeries>
#include <QSplineSeries>
#include <QMapNode>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <cmath>
#include "series.h"
#include "types.h"
#include "elemental.h"
using namespace QtCharts;
class Line;
class Graph;
class Polytope : public QWidget
{
Q_OBJECT
public:
Polytope(QString name, int index, QList<Line*> nodes, QSettings *settings = nullptr, QWidget *parent = nullptr);
~Polytope();
inline void setName(QString n)
{
name = n;
}
inline QString getName()
{
return name;
}
inline Series* getCounts()
{
return counts;
}
inline Series* getSpectrum()
{
return spectrum;
}
inline void setSpectrumSize(size_t size)
{
getSpectrum()->getElemental()->setStreamSize(size);
}
inline size_t getSpectrumSize()
{
return getSpectrum()->getElemental()->getStreamSize();
}
QMap<double, double>* getDark();
void setMode(Mode m);
inline Mode getMode()
{
return mode;
}
inline unsigned int getLineIndex()
{
return Index;
}
inline void setDelay(double s);
inline void setPercentPtr(double *ptr)
{
percent = ptr;
}
inline void resetPercentPtr()
{
percent = &localpercent;
}
inline int getStop()
{
return *stop;
}
inline void setStopPtr(int *ptr)
{
stop = ptr;
}
inline void resetStopPtr()
{
stop = &localstop;
}
inline double isScanning()
{
return scanning;
}
inline Line* getLine(int index)
{
return lines.at(index);
}
inline QList<Line*> getLines()
{
return lines;
}
void setCorrelationOrder(int order);
inline int getCorrelationOrder()
{
return correlation_order;
}
bool isActive(bool atleast1 = false);
bool scanActive(bool atleast1 = false);
void stackCorrelations();
void plot(bool success, double o, double s);
void SavePlot();
void TakeMeanValue(Line *sender);
void TakeDark(Line* sender);
bool haveSetting(QString setting);
void removeSetting(QString setting);
void saveSetting(QString name, QVariant value);
QVariant readSetting(QString name, QVariant defaultValue);
inline QString readString(QString setting, QString defaultValue)
{
return readSetting(setting, defaultValue).toString();
}
inline double readDouble(QString setting, double defaultValue)
{
return readSetting(setting, defaultValue).toDouble();
}
inline int readInt(QString setting, int defaultValue)
{
return readSetting(setting, defaultValue).toInt();
}
inline bool readBool(QString setting, bool defaultValue)
{
return readSetting(setting, defaultValue).toBool();
}
void addToVLBIContext(int index = -1);
void removeFromVLBIContext(int index = -1);
inline dsp_stream_p getStream()
{
return stream;
}
inline void setStream(dsp_stream_p s)
{
stream = s;
}
inline vlbi_context getVLBIContext(int index = -1)
{
if(index < 0) {
index = getMode() - HolographII;
if(index < 0)
return nullptr;
}
return context[index];
}
bool idft();
int smooth();
void lock()
{
while(!mutex.tryLock());
}
void unlock()
{
mutex.unlock();
}
inline double getPacketTime() { return packetTime; }
void addCount(double starttime, ahp_xc_packet *packet = nullptr);
inline double getTimeRange() { return timeRange; }
inline void setTimeRange(double range) { timeRange = range; }
inline ahp_xc_packet* getPacket() { return packet; }
inline void setPacket(ahp_xc_packet* p) { packet = p; }
inline Graph *getGraph() { return graph; }
inline void setGraph(Graph * g) { graph = g; }
inline Graph* gethistogram() { return histogram; }
inline void sethistogram(Graph* h) { histogram = h; }
inline int getStartLag()
{
return lag_head_size;
}
inline int getEndLag()
{
return lag_tail_size;
}
inline int getLagBandwidth()
{
return lag_size_2nd;
}
inline int getLagStep()
{
return lag_step_size;
}
inline int getScanStep()
{
return step_size;
}
private:
int localstop { 0 };
int *stop { nullptr };
double *percent { nullptr };
double localpercent { 0 };
Graph *graph;
Graph *histogram;
ahp_xc_packet* packet;
double timeRange { 10.0 };
double packetTime { 0.0 };
QMutex mutex;
bool running { false };
void setBufferSizes();
void stretch(Series* series);
dsp_stream_p stream { nullptr };
fftw_plan plan;
double MinValue { 0.0 };
size_t magnitude_size { 0 };
size_t phase_size { 0 };
double offset { 0.0 };
double timespan { 1.0 };
int Index;
int *start;
int *end;
int *step;
int *size;
double *lag_start;
double *lag_end;
double *lag_step;
double *lag_size;
int size_2nd {3};
int step_size {1};
int tail_size {1};
int head_size {1};
int len {1};
int lag_size_2nd {3};
int lag_step_size {1};
int lag_tail_size {1};
int lag_head_size {1};
QSettings *settings;
QString name;
bool scanning;
bool threadRunning;
bool oldstate;
Mode mode;
Series* counts;
Series* spectrum;
QList<Line*> Nodes;
int correlation_order {2};
QList<Line*> lines;
QList<int> indexes;
signals:
void activeStateChanging(Polytope*);
void activeStateChanged(Polytope*);
};
#endif // POLYTOPE_H