1 | /*
|
---|
2 | * QtGl.cpp
|
---|
3 | *
|
---|
4 | * Created on: Jul 19, 2011
|
---|
5 | * Author: lyard
|
---|
6 | */
|
---|
7 |
|
---|
8 |
|
---|
9 | #include "RawEventsViewer.h"
|
---|
10 | #include "viewer.h"
|
---|
11 | #include <math.h>
|
---|
12 | #include <fstream>
|
---|
13 |
|
---|
14 | #ifdef LOAD_RAW
|
---|
15 | int16_t eventsData[NUM_STORED_EVENTS][ACTUAL_NUM_PIXELS][1024];
|
---|
16 | #include </home/lyard/Code/display.C>
|
---|
17 | #endif
|
---|
18 |
|
---|
19 | #define VALUES_SPAN 4096
|
---|
20 |
|
---|
21 | #include <QFileDialog>
|
---|
22 |
|
---|
23 | #include <qwt_plot_grid.h>
|
---|
24 | #include <qwt_symbol.h>
|
---|
25 |
|
---|
26 | #include "src/Configuration.h"
|
---|
27 | #include "externals/fits.h"
|
---|
28 |
|
---|
29 | using namespace std;
|
---|
30 |
|
---|
31 | #undef ACTUAL_NUM_PIXELS
|
---|
32 | #define ACTUAL_NUM_PIXELS 1440
|
---|
33 |
|
---|
34 | //bounding box for diplaying the impulse curve
|
---|
35 | float bboxMin[2] = {-0.8,-0.9};
|
---|
36 | float bboxMax[2] = {0.8,-0.3};
|
---|
37 | /************************************************************
|
---|
38 | * CALC BLUR COLOR if in blur display mode, calculate the interpolated
|
---|
39 | * colour for a given vertex
|
---|
40 | ************************************************************/
|
---|
41 | void RawDataViewer::calcBlurColor(int pixel, int vertex)
|
---|
42 | {
|
---|
43 | GLfloat color[3];
|
---|
44 | int first, second;
|
---|
45 | first = vertex-1;
|
---|
46 | second = vertex;
|
---|
47 | if (first < 0)
|
---|
48 | first = 5;
|
---|
49 | first = neighbors[pixel][first];
|
---|
50 | second = neighbors[pixel][second];
|
---|
51 | for (int i=0;i<3;i++)
|
---|
52 | color[i] = pixelsColor[pixel][i];
|
---|
53 | float divide = 1;
|
---|
54 | if (first != -1)
|
---|
55 | {
|
---|
56 | divide++;
|
---|
57 | for (int i=0;i<3;i++)
|
---|
58 | color[i] += pixelsColor[first][i];
|
---|
59 | }
|
---|
60 | if (second != -1)
|
---|
61 | {
|
---|
62 | divide++;
|
---|
63 | for (int i=0;i<3;i++)
|
---|
64 | color[i] += pixelsColor[second][i];
|
---|
65 | }
|
---|
66 | for (int i=0;i<3;i++)
|
---|
67 | color[i] /= divide;
|
---|
68 | glColor3fv(color);
|
---|
69 | }
|
---|
70 | /************************************************************
|
---|
71 | * DRAW BLURRY HEXAGON. draws a solid hexagon, with interpolated colours
|
---|
72 | ************************************************************/
|
---|
73 | void RawDataViewer::drawBlurryHexagon(int index)
|
---|
74 | {
|
---|
75 | GLfloat color[3];
|
---|
76 | for (int i=0;i<3;i++)
|
---|
77 | color[i] = pixelsColor[index][i];
|
---|
78 | glBegin(GL_TRIANGLES);
|
---|
79 | calcBlurColor(index, 0);
|
---|
80 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
81 | glColor3fv(color);
|
---|
82 | glVertex2fv(pixelsCoords[index]);
|
---|
83 | calcBlurColor(index, 1);
|
---|
84 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
85 |
|
---|
86 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
87 | glColor3fv(color);
|
---|
88 | glVertex2fv(pixelsCoords[index]);
|
---|
89 | calcBlurColor(index, 2);
|
---|
90 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
91 |
|
---|
92 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
93 | glColor3fv(color);
|
---|
94 | glVertex2fv(pixelsCoords[index]);
|
---|
95 | calcBlurColor(index, 3);
|
---|
96 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
97 |
|
---|
98 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
99 | glColor3fv(color);
|
---|
100 | glVertex2fv(pixelsCoords[index]);
|
---|
101 | calcBlurColor(index, 4);
|
---|
102 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
103 |
|
---|
104 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
105 | glColor3fv(color);
|
---|
106 | glVertex2fv(pixelsCoords[index]);
|
---|
107 | calcBlurColor(index, 5);
|
---|
108 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
109 |
|
---|
110 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
111 | glColor3fv(color);
|
---|
112 | glVertex2fv(pixelsCoords[index]);
|
---|
113 | calcBlurColor(index, 0);
|
---|
114 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
115 | glEnd();
|
---|
116 |
|
---|
117 | return;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /************************************************************
|
---|
121 | * DRAW CAMERA draws all the camera pixels
|
---|
122 | ************************************************************/
|
---|
123 | void RawDataViewer::drawCamera(bool alsoWire)
|
---|
124 | {
|
---|
125 | glLoadIdentity();
|
---|
126 | if (!drawImpulse)
|
---|
127 | {
|
---|
128 | glTranslatef(0,-0.44,0);
|
---|
129 | glRotatef(cameraRotation, 0,0,-1);
|
---|
130 | if (cameraRotation == 90)
|
---|
131 | {
|
---|
132 | glTranslatef(-0.45,-0.45,0);
|
---|
133 | // cout << "correction" << endl;
|
---|
134 | }
|
---|
135 | if (cameraRotation == -90)
|
---|
136 | {
|
---|
137 | glTranslatef(0.45,-0.45,0);
|
---|
138 | }
|
---|
139 | glScalef(1.5,1.5,1);
|
---|
140 | }
|
---|
141 | else
|
---|
142 | {
|
---|
143 | glRotatef(cameraRotation, 0,0,-1);
|
---|
144 | if (cameraRotation == 90)
|
---|
145 | {
|
---|
146 | glTranslatef(-0.45/1.5,-0.45/1.5,0);
|
---|
147 | // cout << "correction" << endl;
|
---|
148 | }
|
---|
149 | if (cameraRotation == -90)
|
---|
150 | {
|
---|
151 | glTranslatef(0.45/1.5,-0.45/1.5,0);
|
---|
152 | }
|
---|
153 | }
|
---|
154 | glColor3f(0.5,0.5,0.5);
|
---|
155 | glLineWidth(1.0);
|
---|
156 | float color;
|
---|
157 | //cout << "Actual num pixels: " << ACTUAL_NUM_PIXELS << endl;
|
---|
158 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
159 | {
|
---|
160 | if (!nRoi)
|
---|
161 | color = (float)(i)/(float)(ACTUAL_NUM_PIXELS);
|
---|
162 | else
|
---|
163 | #ifdef LOAD_RAW
|
---|
164 | color = float(eventsData[eventNum][i][whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
165 | #else
|
---|
166 | color = float(eventData[nRoi*i + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
167 | if (logScale)
|
---|
168 | {
|
---|
169 | color *= 9;
|
---|
170 | color += 1;
|
---|
171 | color = log10(color);
|
---|
172 | }
|
---|
173 | #endif
|
---|
174 | if (color < 0)
|
---|
175 | {
|
---|
176 | pixelsColor[i][0] = tooLowValueCoulour[0];
|
---|
177 | pixelsColor[i][1] = tooLowValueCoulour[1];
|
---|
178 | pixelsColor[i][2] = tooLowValueCoulour[2];
|
---|
179 | continue;
|
---|
180 | }
|
---|
181 | if (color > 1)
|
---|
182 | {
|
---|
183 | pixelsColor[i][0] = tooHighValueCoulour[0];
|
---|
184 | pixelsColor[i][1] = tooHighValueCoulour[1];
|
---|
185 | pixelsColor[i][2] = tooHighValueCoulour[2];
|
---|
186 | continue;
|
---|
187 | }
|
---|
188 | int index = 0;
|
---|
189 | while (ss[index] < color && index < 4)
|
---|
190 | index++;
|
---|
191 | index--;
|
---|
192 | if (index < 0) index = 0;
|
---|
193 | float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
|
---|
194 | if (weight0 > 1.0f) weight0 = 1.0f;
|
---|
195 | if (weight0 < 0.0f) weight0 = 0.0f;
|
---|
196 | float weight1 = 1.0f-weight0;
|
---|
197 | pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
|
---|
198 | pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
|
---|
199 | pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
|
---|
200 | }
|
---|
201 |
|
---|
202 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
203 | {
|
---|
204 | // if (i == 690 ||
|
---|
205 | // i == 70)
|
---|
206 | // continue;
|
---|
207 | glColor3fv(pixelsColor[i]);
|
---|
208 | glLoadName(i);
|
---|
209 | if (drawBlur)
|
---|
210 | drawBlurryHexagon(i);
|
---|
211 | else
|
---|
212 | drawHexagon(i,true);
|
---|
213 |
|
---|
214 | }
|
---|
215 | if (!alsoWire)
|
---|
216 | return;
|
---|
217 | glColor3f(0.0f,0.0f,0.0f);
|
---|
218 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
219 | {
|
---|
220 | // if (i == 690 ||
|
---|
221 | // i == 70)
|
---|
222 | // continue;
|
---|
223 | drawHexagon(i, false);
|
---|
224 | }
|
---|
225 |
|
---|
226 | }
|
---|
227 |
|
---|
228 | /************************************************************
|
---|
229 | * TRIM. FIXME this should not be here but taken from an existing class (somewhere)
|
---|
230 | ***********************************************************
|
---|
231 | string Trim(const string &str)
|
---|
232 | {
|
---|
233 | // Trim Both leading and trailing spaces
|
---|
234 | const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
|
---|
235 | const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af
|
---|
236 |
|
---|
237 | // if all spaces or empty return an empty string
|
---|
238 | if (string::npos==start || string::npos==end)
|
---|
239 | return string();
|
---|
240 |
|
---|
241 | return str.substr(start, end-start+1);
|
---|
242 | }*/
|
---|
243 | /************************************************************
|
---|
244 | * DRAW PIXEL CURVE. draws the raw impulse curve of the currently selected pixel
|
---|
245 | ************************************************************/
|
---|
246 | void RawDataViewer::drawPixelCurve()
|
---|
247 | {
|
---|
248 | if (!nRoi)
|
---|
249 | return;
|
---|
250 |
|
---|
251 | float xZoom, yZoom;
|
---|
252 | xZoom = yZoom = 1.0f;
|
---|
253 |
|
---|
254 | glBegin(GL_LINES);
|
---|
255 | glLineWidth(1.0f);
|
---|
256 | glColor3f(0.5,0.5,0.5);
|
---|
257 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
258 | glVertex2f(bboxMax[0], bboxMin[1]);
|
---|
259 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
260 | glVertex2f(bboxMin[0], bboxMax[1]);
|
---|
261 | glVertex2f(bboxMin[0], (bboxMin[1]+bboxMax[1])/2.0f);
|
---|
262 | glVertex2f(bboxMax[0], (bboxMin[1]+bboxMax[1])/2.0f);
|
---|
263 | float xRange = bboxMax[0] - bboxMin[0];
|
---|
264 | float yRange = bboxMax[1] - bboxMin[1];
|
---|
265 | glColor3f(1.0,1.0,1.0);
|
---|
266 | float divideMe = (float)(VALUES_SPAN-1);
|
---|
267 | float plusMe = VALUES_SPAN/2;
|
---|
268 | if (drawCalibrationLoaded)
|
---|
269 | plusMe += 0;//VALUES_SPAN/2;
|
---|
270 | if (drawCalibrationLoaded && calibrationLoaded)
|
---|
271 | {
|
---|
272 | divideMe /=2;
|
---|
273 | plusMe /=2;
|
---|
274 | }
|
---|
275 | for (int i=0;i<nRoi-1;i++)
|
---|
276 | {
|
---|
277 | #ifdef LOAD_RAW
|
---|
278 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
279 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+plusMe) /divideMe);
|
---|
280 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
281 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+plusMe) /divideMe);
|
---|
282 | #else
|
---|
283 |
|
---|
284 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
285 | bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+plusMe) /divideMe);
|
---|
286 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
287 | bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+plusMe) /divideMe);
|
---|
288 | #endif
|
---|
289 | }
|
---|
290 | glColor3f(1.0,0.0,0.0);
|
---|
291 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
292 | bboxMin[1]);
|
---|
293 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
294 | bboxMax[1]);
|
---|
295 |
|
---|
296 | /* glColor3f(0.f,0.5f,0.f);
|
---|
297 | for (int i=0;i<nRoi-1;i++)
|
---|
298 | {
|
---|
299 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
300 | bboxMin[1] + yRange*(n1mean[ i]+plusMe) /divideMe);
|
---|
301 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
302 | bboxMin[1] + yRange*(n1mean[i+1]+plusMe) /divideMe);
|
---|
303 | }
|
---|
304 | */
|
---|
305 | glEnd();
|
---|
306 | glEnable(GL_MULTISAMPLE);
|
---|
307 | setFont(QFont("Times", 12));
|
---|
308 | qglColor(QColor(255,223,127));
|
---|
309 | float xShift = 0.10f;
|
---|
310 | float yShift = 0.01f;
|
---|
311 | renderText(bboxMin[0]-xShift/2.0f, bboxMax[1]+3*yShift, 0, QString("Volts"));
|
---|
312 | if (drawCalibrationLoaded)
|
---|
313 | {
|
---|
314 | renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+2.10"));
|
---|
315 | renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+1.05"));//((bboxMin[1]+bboxMax[1])/2.0f)
|
---|
316 | renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("0.00"));
|
---|
317 | }
|
---|
318 | else
|
---|
319 | {
|
---|
320 | renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+1.05"));
|
---|
321 | renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+0.00"));//((bboxMin[1]+bboxMax[1])/2.0f)
|
---|
322 | renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("-1.05"));
|
---|
323 | }
|
---|
324 | renderText(bboxMax[0]+xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("Slices"));
|
---|
325 | renderText(bboxMin[0]-yShift/2.0f, bboxMin[1]-4*yShift, 0, QString("0"));
|
---|
326 | ostringstream str;
|
---|
327 | str << nRoi/2;
|
---|
328 | renderText(((bboxMin[0]+bboxMax[0])/2.0f)-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str()));
|
---|
329 | str.str("");
|
---|
330 | str << nRoi;
|
---|
331 | renderText(bboxMax[0]-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str()));
|
---|
332 |
|
---|
333 | }
|
---|
334 | /************************************************************
|
---|
335 | * CONSTRUCTOR.
|
---|
336 | ************************************************************/
|
---|
337 | RawDataViewer::RawDataViewer(QWidget *cParent) : BasicGlCamera(cParent)
|
---|
338 | {
|
---|
339 | // setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
|
---|
340 | whichSlice = 0;
|
---|
341 | #ifdef LOAD_RAW
|
---|
342 | nRoi = 1024;
|
---|
343 | #else
|
---|
344 | nRoi = 0;
|
---|
345 | #endif
|
---|
346 | eventNum = 0;
|
---|
347 | rowNum = -1;
|
---|
348 | eventStep = 1;
|
---|
349 | selectedPixel = 393;
|
---|
350 | inputFile = NULL;
|
---|
351 | eventData = NULL;
|
---|
352 | drawPatch = true;
|
---|
353 | drawImpulse = false;
|
---|
354 | drawBlur = false;
|
---|
355 | loopCurrentEvent = false;
|
---|
356 | SetAutoRefresh(true);
|
---|
357 | #ifdef LOAD_RAW
|
---|
358 | loadEvents("/scratch/00000043.001_T.bin");
|
---|
359 | #endif
|
---|
360 | PixelMap mypMap;
|
---|
361 | if (!mypMap.Read("FACTmapV5.txt"))
|
---|
362 | {
|
---|
363 | cerr << "ERROR - Problems reading FACTmapV5.txt" << endl;
|
---|
364 | exit(-1);
|
---|
365 | }
|
---|
366 | ifstream fin1("Trigger-Patches.txt");
|
---|
367 | if (!fin1.is_open())
|
---|
368 | {
|
---|
369 | cout << "Error: file \"Trigger-Patches\" missing. aborting." << endl;
|
---|
370 | exit(-1);
|
---|
371 | }
|
---|
372 | string buf;
|
---|
373 | vector<int> patchHW(1440);
|
---|
374 | int l = 0;
|
---|
375 | while (getline(fin1, buf, '\n'))
|
---|
376 | {
|
---|
377 | buf = Tools::Trim(buf);
|
---|
378 | if (buf[0]=='#')
|
---|
379 | continue;
|
---|
380 |
|
---|
381 | stringstream str(buf);
|
---|
382 | for (int i=0; i<9; i++)
|
---|
383 | {
|
---|
384 | unsigned int n;
|
---|
385 | str >> n;
|
---|
386 |
|
---|
387 | if (n>=patchHW.size())
|
---|
388 | continue;
|
---|
389 |
|
---|
390 | patchHW[n] = l;
|
---|
391 | }
|
---|
392 | l++;
|
---|
393 | }
|
---|
394 | if (l!=160)
|
---|
395 | cerr << "WARNING - Problems reading Trigger-Patches.txt" << endl;
|
---|
396 |
|
---|
397 | assignPixelMap(mypMap);
|
---|
398 | assignTriggerPatchesMap(patchHW);
|
---|
399 |
|
---|
400 | GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3];
|
---|
401 | for (int i=0;i<1440;i++)
|
---|
402 | for (int j=0;j<3;j++)
|
---|
403 | tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j];
|
---|
404 | for (int i=0;i<1440;i++)
|
---|
405 | for (int j=0;j<3;j++)
|
---|
406 | pixelsCoords[i][j] = tempPixelsCoords[i][j];
|
---|
407 |
|
---|
408 | for (int i=0;i<1440;i++)
|
---|
409 | updateNeighbors(i);
|
---|
410 | buildVerticesList();
|
---|
411 |
|
---|
412 | /* ifstream fin1("Trigger-Patches.txt");
|
---|
413 | if (!fin1.is_open())
|
---|
414 | {
|
---|
415 | cout << "Error: file \"Trigger-Patches.txt\" missing. Aborting." << endl;
|
---|
416 | exit(-1);
|
---|
417 | }
|
---|
418 | l=0;
|
---|
419 | while (getline(fin1, buf, '\n'))
|
---|
420 | {
|
---|
421 | buf = Trim(buf);
|
---|
422 | if (buf[0]=='#')
|
---|
423 | continue;
|
---|
424 |
|
---|
425 | stringstream str(buf);
|
---|
426 | for (int i=0; i<9; i++)
|
---|
427 | {
|
---|
428 | unsigned int n;
|
---|
429 | str >> n;
|
---|
430 |
|
---|
431 | if (n>=1440)
|
---|
432 | continue;
|
---|
433 |
|
---|
434 | patches[l][i] = hardwareMapping[n];
|
---|
435 | }
|
---|
436 | l++;
|
---|
437 | }*/
|
---|
438 |
|
---|
439 | buildPatchesIndices();
|
---|
440 | float color[3];
|
---|
441 | for (int i=0;i<160;i++)
|
---|
442 | {
|
---|
443 | color[0] = 0.5; color[1] = 0.5; color[2] = 0.3;
|
---|
444 | for (int j=0;j<3;j++)
|
---|
445 | patchesColor[i][j] = color[j];
|
---|
446 | }
|
---|
447 |
|
---|
448 | for (int i=0;i<1440;i++)
|
---|
449 | updateNeighbors(i);
|
---|
450 |
|
---|
451 | calibrationLoaded = false;
|
---|
452 | drawCalibrationLoaded = false;
|
---|
453 |
|
---|
454 | }
|
---|
455 | /************************************************************
|
---|
456 | * DESTRUCTOR
|
---|
457 | ************************************************************/
|
---|
458 | RawDataViewer::~RawDataViewer()
|
---|
459 | {
|
---|
460 | if (inputFile != NULL)
|
---|
461 | {
|
---|
462 | inputFile->close();
|
---|
463 | delete inputFile;
|
---|
464 | }
|
---|
465 | if (eventData != NULL) {
|
---|
466 | delete[] eventData;
|
---|
467 | delete[] rawEventData;
|
---|
468 | delete[] waveLetArray;
|
---|
469 | }
|
---|
470 | }
|
---|
471 |
|
---|
472 | void RawDataViewer::buildPatchesIndices()
|
---|
473 | {
|
---|
474 | vector<edge>::iterator it;
|
---|
475 | bool erased = false;
|
---|
476 | // patchesIndices.resize(NTMARK);
|
---|
477 | for (int i=0;i<NTMARK;i++)//for all patches
|
---|
478 | {
|
---|
479 | patchesIndices[i].clear();
|
---|
480 | for (int j=0;j<9;j++)//for all cells of the current patch
|
---|
481 | {
|
---|
482 | // if (patches[i][j] == 690 ||
|
---|
483 | // patches[i][j] == 70)
|
---|
484 | // continue;
|
---|
485 | for (int k=0;k<6;k++)//for all sides of the current cell
|
---|
486 | {
|
---|
487 | int first = k-1;
|
---|
488 | int second = k;
|
---|
489 | if (first < 0)
|
---|
490 | first = 5;
|
---|
491 | erased = false;
|
---|
492 | for (it=(patchesIndices[i]).begin(); it != (patchesIndices[i]).end(); it++)//check if this side is here already or not
|
---|
493 | {
|
---|
494 | if (((*it).first == verticesIndices[patches[i][j]][first] &&
|
---|
495 | (*it).second == verticesIndices[patches[i][j]][second]) ||
|
---|
496 | ((*it).first == verticesIndices[patches[i][j]][second] &&
|
---|
497 | (*it).second == verticesIndices[patches[i][j]][first]))
|
---|
498 | {
|
---|
499 | patchesIndices[i].erase(it);
|
---|
500 | erased = true;
|
---|
501 | break;
|
---|
502 | }
|
---|
503 | }
|
---|
504 | if (!erased)
|
---|
505 | {
|
---|
506 | edge temp;
|
---|
507 | temp.first = verticesIndices[patches[i][j]][first];
|
---|
508 | temp.second = verticesIndices[patches[i][j]][second];
|
---|
509 | patchesIndices[i].push_back(temp);
|
---|
510 | }
|
---|
511 | }
|
---|
512 | }
|
---|
513 | }
|
---|
514 | }
|
---|
515 | /************************************************************
|
---|
516 | * PAINT GL. main drawing function.
|
---|
517 | ************************************************************/
|
---|
518 | void RawDataViewer::paintGL()
|
---|
519 | {
|
---|
520 | glClear(GL_COLOR_BUFFER_BIT);
|
---|
521 | glLoadIdentity();
|
---|
522 |
|
---|
523 |
|
---|
524 | if (drawBlur)
|
---|
525 | {
|
---|
526 | glShadeModel(GL_SMOOTH);
|
---|
527 | drawCamera(false);
|
---|
528 | }
|
---|
529 | else
|
---|
530 | {
|
---|
531 | glShadeModel(GL_FLAT);
|
---|
532 | drawCamera(true);
|
---|
533 | }
|
---|
534 | if (drawPatch)
|
---|
535 | drawPatches();
|
---|
536 |
|
---|
537 | if (!drawBlur)
|
---|
538 | {
|
---|
539 | glLineWidth(1.0f);
|
---|
540 | glColor3f(1.0,1.0,1.0);
|
---|
541 | drawHexagon(selectedPixel, false);
|
---|
542 | }
|
---|
543 | if (drawImpulse)
|
---|
544 | {
|
---|
545 | // glRotatef(cameraRotation, 0,0,1);
|
---|
546 | glLoadIdentity();
|
---|
547 | glLineWidth(2.0);
|
---|
548 | drawPixelCurve();
|
---|
549 | }
|
---|
550 |
|
---|
551 | DrawScale();
|
---|
552 | }
|
---|
553 |
|
---|
554 | /************************************************************
|
---|
555 | * MOUSE PRESS EVENT. mouse click handler.
|
---|
556 | ************************************************************/
|
---|
557 | void RawDataViewer::mousePressEvent(QMouseEvent *cEvent)
|
---|
558 | {
|
---|
559 | if (cEvent->pos().x() > width()-(width()/50.f))
|
---|
560 | {
|
---|
561 | toggleInterfaceDisplay();
|
---|
562 | return;
|
---|
563 | }
|
---|
564 | lastPos = cEvent->pos();
|
---|
565 | setCorrectSlice(cEvent);
|
---|
566 | updateGL();
|
---|
567 | }
|
---|
568 |
|
---|
569 | /************************************************************
|
---|
570 | * SET CORRECT SLICE. if displayed, figures out if the graph was
|
---|
571 | * clicked, and if so, which slice should be displayed
|
---|
572 | ************************************************************/
|
---|
573 | void RawDataViewer::setCorrectSlice(QMouseEvent* cEvent)
|
---|
574 | {
|
---|
575 | if (!drawImpulse)
|
---|
576 | return;
|
---|
577 | float cx = (float)cEvent->x() * pixelSize - shownSizex/2;
|
---|
578 | float cy = ((float)height()-(float)cEvent->y())*pixelSize - shownSizey/2;
|
---|
579 | if (cx < bboxMin[0] ||
|
---|
580 | cx > bboxMax[0] ||
|
---|
581 | cy < bboxMin[1] ||
|
---|
582 | cy > bboxMax[1])
|
---|
583 | return;
|
---|
584 | whichSlice = (cx - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
|
---|
585 | emit signalCurrentSlice(whichSlice);
|
---|
586 | }
|
---|
587 |
|
---|
588 | /************************************************************
|
---|
589 | * MOUSE MOVE EVENT. used to track the dragging of slices display
|
---|
590 | ************************************************************/
|
---|
591 | void RawDataViewer::mouseMoveEvent(QMouseEvent *cEvent)
|
---|
592 | {
|
---|
593 | if (cEvent->buttons() & Qt::LeftButton) {
|
---|
594 | setCorrectSlice(cEvent);
|
---|
595 | updateGL();
|
---|
596 | } else if (cEvent->buttons() & Qt::RightButton) {
|
---|
597 | updateGL();
|
---|
598 | }
|
---|
599 | lastPos = cEvent->pos();
|
---|
600 | }
|
---|
601 |
|
---|
602 | /************************************************************
|
---|
603 | * MOUSE DOUBLE CLICK EVENT. used to select pixels
|
---|
604 | ************************************************************/
|
---|
605 | void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *cEvent)
|
---|
606 | {
|
---|
607 | int face = PixelAtPosition(cEvent->pos());
|
---|
608 | if (face != -1) {
|
---|
609 | selectedPixel = face;
|
---|
610 | emit signalCurrentPixel(face);
|
---|
611 | updateGL();
|
---|
612 | }
|
---|
613 | }
|
---|
614 |
|
---|
615 | /************************************************************
|
---|
616 | * OPEN FILE. opens a new fits file
|
---|
617 | ************************************************************/
|
---|
618 | void RawDataViewer::openFile(string& file)
|
---|
619 | {
|
---|
620 | if (inputFile)
|
---|
621 | {
|
---|
622 | inputFile->close();
|
---|
623 | delete inputFile;
|
---|
624 | }
|
---|
625 | try {
|
---|
626 | inputFile = new fits(file);
|
---|
627 | }
|
---|
628 | catch (std::runtime_error e)
|
---|
629 | {
|
---|
630 | cout << "Something went wrong while loading fits. aborting: " << e.what() << endl;
|
---|
631 | return;
|
---|
632 | }
|
---|
633 | if (!*inputFile)
|
---|
634 | {
|
---|
635 | delete inputFile;
|
---|
636 | inputFile = NULL;
|
---|
637 | return;
|
---|
638 | }
|
---|
639 | vector<string> entriesToCheck;
|
---|
640 | entriesToCheck.push_back("NAXIS2");
|
---|
641 | entriesToCheck.push_back("NROI");
|
---|
642 | entriesToCheck.push_back("NTMARK");
|
---|
643 | entriesToCheck.push_back("RUNTYPE");
|
---|
644 | entriesToCheck.push_back("REVISION");
|
---|
645 | entriesToCheck.push_back("BLDVER");
|
---|
646 | entriesToCheck.push_back("RUNID");
|
---|
647 | entriesToCheck.push_back("NBOARD");
|
---|
648 | entriesToCheck.push_back("NPIX");
|
---|
649 | entriesToCheck.push_back("NROITM");
|
---|
650 | entriesToCheck.push_back("TIMESYS");
|
---|
651 | entriesToCheck.push_back("DATE");
|
---|
652 | entriesToCheck.push_back("NIGHT");
|
---|
653 | entriesToCheck.push_back("CAMERA");
|
---|
654 | entriesToCheck.push_back("DAQ");
|
---|
655 | entriesToCheck.push_back("TSTART");
|
---|
656 | entriesToCheck.push_back("TSTOP");
|
---|
657 | //entriesToCheck.push_back("ADCRANGE");
|
---|
658 | //entriesToCheck.push_back("NBEVTOK");
|
---|
659 | //entriesToCheck.push_back("NBEVTREJ");
|
---|
660 | //entriesToCheck.push_back("NBEVTBAD");
|
---|
661 |
|
---|
662 | for (vector<string>::const_iterator it=entriesToCheck.begin(); it != entriesToCheck.end(); it++)
|
---|
663 | {
|
---|
664 | try {
|
---|
665 | if (!inputFile->HasKey(*it)){
|
---|
666 | cout << *it << " missing. Aborting load..." << endl;
|
---|
667 | return;}
|
---|
668 | }
|
---|
669 | catch (std::runtime_error e)
|
---|
670 | {
|
---|
671 | cout << e.what() << endl;
|
---|
672 | return;
|
---|
673 | }
|
---|
674 | }
|
---|
675 | nRows = inputFile->GetInt("NAXIS2");
|
---|
676 | nRoi = inputFile->GetInt("NROI");
|
---|
677 | runNumber = inputFile->GetInt("RUNID");
|
---|
678 | nTM = inputFile->GetInt("NTMARK");
|
---|
679 | runType = inputFile->GetInt("RUNTYPE");
|
---|
680 | firstDataTime = inputFile->GetInt("TSTART");
|
---|
681 | lastDataTime = inputFile->GetInt("TSTOP");
|
---|
682 | nRoiTM = inputFile->GetInt("NROITM");
|
---|
683 | revision = inputFile->GetInt("REVISION");
|
---|
684 | builderVersion = inputFile->GetInt("BLDVER");
|
---|
685 | nBoards = inputFile->GetInt("NBOARD");
|
---|
686 | nPixels = inputFile->GetInt("NPIX");
|
---|
687 | timeSystem = inputFile->GetStr("TIMESYS");
|
---|
688 | creationDate = inputFile->GetStr("DATE");
|
---|
689 | nightInt = inputFile->GetInt("NIGHT");
|
---|
690 | camera = inputFile->GetStr("CAMERA");
|
---|
691 | daq = inputFile->GetStr("DAQ");
|
---|
692 | adcCount = inputFile->HasKey("ADCRANGE") ? inputFile->GetFloat("ADCRANGE") : 2000;
|
---|
693 | nbOk = 0;//inputFile->GetInt("NBEVTOK");
|
---|
694 | nbRej = 0;//inputFile->GetInt("NBEVTREJ");
|
---|
695 | nbBad = 0;//inputFile->GetInt("NBEVTBAD");
|
---|
696 |
|
---|
697 | eventNum = 0;
|
---|
698 |
|
---|
699 | #ifdef LOAD_RAW
|
---|
700 | nRows = NUM_STORED_EVENTS;
|
---|
701 | #endif
|
---|
702 |
|
---|
703 | if (eventData != NULL) {
|
---|
704 | delete[] eventData;
|
---|
705 | delete[] rawEventData;
|
---|
706 | delete[] waveLetArray;
|
---|
707 | }
|
---|
708 | eventData = new float[(1440+160)*nRoi];
|
---|
709 | rawEventData = new int16_t[(1440+160)*nRoi];
|
---|
710 | waveLetArray = new int16_t[1024*1440];
|
---|
711 | if (!inputFile->SetPtrAddress("Data", rawEventData)){
|
---|
712 | cout << "Missing column " << "Data" << " Aborting load..." << endl;
|
---|
713 | nRoi = nRows = 0;return;}
|
---|
714 | if (!inputFile->SetPtrAddress("EventNum", &eventNum)){
|
---|
715 | cout << "Missing column " << "EventNum" << " Aborting load..." << endl;
|
---|
716 | nRoi = nRows = 0;return;}
|
---|
717 | if (!inputFile->SetPtrAddress("TriggerType", &triggerType)){
|
---|
718 | cout << "Missing column " << "TriggerType" << " Aborting load..." << endl;
|
---|
719 | nRoi = nRows = 0;return;}
|
---|
720 | if (!inputFile->SetPtrAddress("SoftTrig", &softTrig)){
|
---|
721 | cout << "Missing column " << "SoftTrig" << " Aborting load..." << endl;
|
---|
722 | nRoi = nRows = 0;return;}
|
---|
723 | if (!inputFile->SetPtrAddress("PCTime", &pcTime)){
|
---|
724 | cout << "Missing column " << "PCTime" << " Aborting load..." << endl;
|
---|
725 | nRoi = nRows = 0;return;}
|
---|
726 | if (!inputFile->SetPtrAddress("BoardTime", boardTime)){
|
---|
727 | cout << "Missing column " << "BoardTime" << " Aborting load..." << endl;
|
---|
728 | nRoi = nRows = 0;return;}
|
---|
729 | if (!inputFile->SetPtrAddress("StartCellData", startPix)){
|
---|
730 | cout << "Missing column " << "StartCellData" << " Aborting load..." << endl;
|
---|
731 | nRoi = nRows = 0;return;}
|
---|
732 | if (!inputFile->SetPtrAddress("StartCellTimeMarker", startTM)){
|
---|
733 | cout << "Missing column " << "StartCellTimeMarker" << " Aborting load..." << endl;
|
---|
734 | nRoi = nRows = 0;return;}
|
---|
735 | int backupStep = eventStep;
|
---|
736 | rowNum = -1;
|
---|
737 | eventStep = 1;
|
---|
738 |
|
---|
739 | doMyWaveletTestPlease();
|
---|
740 |
|
---|
741 |
|
---|
742 | plusEvent();
|
---|
743 | eventStep = backupStep;
|
---|
744 | emit newFileLoaded();
|
---|
745 | emit signalCurrentPixel(selectedPixel);
|
---|
746 | }
|
---|
747 | /*
|
---|
748 | bool RawDataViewer::doWaveLetsPlease(int givenSpan, int16_t* orig_in, int16_t* wavelets_in, bool verifyResult)
|
---|
749 | {
|
---|
750 | float* interArray = new float[givenSpan];
|
---|
751 | float* resultArray = new float[givenSpan];
|
---|
752 | float* orig = new float[givenSpan];
|
---|
753 | float* wavelets = new float[givenSpan];
|
---|
754 | for (int i=0;i<givenSpan;i++)
|
---|
755 | {
|
---|
756 | if (fabs((float)(orig_in[i])) > 32767.f)
|
---|
757 | cout << "Input overflow: " << orig_in[i] << endl;
|
---|
758 | orig[i] = (float)orig_in[i];
|
---|
759 | }
|
---|
760 | for (int k=0;k<givenSpan;k++)
|
---|
761 | interArray[k] = orig[k];
|
---|
762 | int span = givenSpan/2;
|
---|
763 | while (span > 0)
|
---|
764 | {
|
---|
765 | for (int k=0;k<span;k++)
|
---|
766 | {
|
---|
767 | wavelets[k] = (interArray[2*k] + interArray[2*k + 1])/2.f;
|
---|
768 | wavelets[k + span] = (interArray[2*k + 1] - interArray[2*k])/2.f;
|
---|
769 | }
|
---|
770 | for (int k=0;k<givenSpan;k++)
|
---|
771 | interArray[k] = wavelets[k];
|
---|
772 | span /= 2;
|
---|
773 | }
|
---|
774 | //move float results to int16_t array
|
---|
775 | float intScaling = 15.9f;
|
---|
776 | int max = 0;
|
---|
777 | for (int i=0;i<givenSpan;i++)
|
---|
778 | {
|
---|
779 | float cValue = intScaling*wavelets[i];//
|
---|
780 | if (cValue > 0)
|
---|
781 | cValue += 0.5f;
|
---|
782 | else
|
---|
783 | cValue -= 0.5f;
|
---|
784 | wavelets_in[i] = (int16_t)(cValue);
|
---|
785 | if (fabs(cValue) > 32767.f)
|
---|
786 | {
|
---|
787 | cout << "Overflow ! " << cValue << endl;
|
---|
788 | }
|
---|
789 | if (fabs(cValue) > fabs(max))
|
---|
790 | max = cValue;
|
---|
791 | }
|
---|
792 | // cout << "Max wave value: " << max << endl;
|
---|
793 | //result reconstruction and checking
|
---|
794 | if (!verifyResult)
|
---|
795 | return true;
|
---|
796 |
|
---|
797 | for (int k=0;k<givenSpan;k++)
|
---|
798 | {
|
---|
799 | resultArray[k] = wavelets_in[k]/intScaling;
|
---|
800 | }
|
---|
801 |
|
---|
802 | span = 1;
|
---|
803 | while (span < givenSpan)
|
---|
804 | {
|
---|
805 | for (int k=0;k<givenSpan;k++)
|
---|
806 | interArray[k] = resultArray[k];
|
---|
807 | for (int k=0;k<span;k++)
|
---|
808 | {
|
---|
809 | resultArray[2*k] = (float)(((interArray[k] - interArray[k + span])*(1.f/1.f)) + 0.0f);
|
---|
810 | resultArray[2*k + 1] = (float)(((interArray[k] + interArray[k + span])*(1.f/1.f)) + 0.0f);
|
---|
811 | }
|
---|
812 | span *= 2;
|
---|
813 | }
|
---|
814 |
|
---|
815 | for (int k=0;k<givenSpan;k++)
|
---|
816 | {
|
---|
817 | float plus = 0.5f;
|
---|
818 | if (resultArray[k] < 0)
|
---|
819 | plus *= -1.f;
|
---|
820 | if ((int)(resultArray[k]+plus) != (int)(orig_in[k]))
|
---|
821 | {
|
---|
822 | cout << "Nop, sorry: k: " << k << " " << resultArray[k] << " " << (int)(resultArray[k]+plus) << " " << plus << " " << orig[k] << endl;
|
---|
823 | return false;
|
---|
824 | }
|
---|
825 | }
|
---|
826 | return true;
|
---|
827 | }
|
---|
828 | */
|
---|
829 | bool RawDataViewer::doWaveLetsPlease(int givenSpan, int16_t* orig_in, int16_t* wavelets_in, bool verifyResult)
|
---|
830 | {
|
---|
831 | float* interArray = new float[givenSpan];
|
---|
832 | float* resultArray = new float[givenSpan];
|
---|
833 | float* orig = new float[givenSpan];
|
---|
834 | float* wavelets = new float[givenSpan];
|
---|
835 | for (int i=0;i<givenSpan;i++)
|
---|
836 | {
|
---|
837 | if (fabs((float)(orig_in[i])) > 32767.f)
|
---|
838 | cout << "Input overflow: " << orig_in[i] << endl;
|
---|
839 | orig[i] = (float)orig_in[i];
|
---|
840 | }
|
---|
841 | for (int k=0;k<givenSpan;k++)
|
---|
842 | interArray[k] = orig[k];
|
---|
843 | int span = givenSpan/2;
|
---|
844 | while (span > 0)
|
---|
845 | {
|
---|
846 | for (int k=0;k<span;k++)
|
---|
847 | {
|
---|
848 | wavelets[k] = interArray[2*k];// + interArray[2*k + 1])/2.f;
|
---|
849 | wavelets[k + span] = interArray[2*k + 1] - interArray[2*k];//)/2.f;
|
---|
850 | }
|
---|
851 | for (int k=0;k<givenSpan;k++)
|
---|
852 | interArray[k] = wavelets[k];
|
---|
853 | span /= 2;
|
---|
854 | }
|
---|
855 | //move float results to int16_t array
|
---|
856 | float intScaling = 1.f;
|
---|
857 | int max = 0;
|
---|
858 | for (int i=0;i<givenSpan;i++)
|
---|
859 | {
|
---|
860 | float cValue = intScaling*wavelets[i];//
|
---|
861 | if (cValue > 0)
|
---|
862 | cValue += 0.5f;
|
---|
863 | else
|
---|
864 | cValue -= 0.5f;
|
---|
865 | wavelets_in[i] = (int16_t)(cValue);
|
---|
866 | if (fabs(cValue) > 32767.f)
|
---|
867 | {
|
---|
868 | cout << "Overflow ! " << cValue << endl;
|
---|
869 | }
|
---|
870 | if (fabs(cValue) > fabs(max))
|
---|
871 | max = cValue;
|
---|
872 | }
|
---|
873 | // cout << "Max wave value: " << max << endl;
|
---|
874 | //result reconstruction and checking
|
---|
875 | if (!verifyResult)
|
---|
876 | return true;
|
---|
877 |
|
---|
878 | for (int k=0;k<givenSpan;k++)
|
---|
879 | {
|
---|
880 | resultArray[k] = wavelets_in[k]/intScaling;
|
---|
881 | }
|
---|
882 |
|
---|
883 | span = 1;
|
---|
884 | while (span < givenSpan)
|
---|
885 | {
|
---|
886 | for (int k=0;k<givenSpan;k++)
|
---|
887 | interArray[k] = resultArray[k];
|
---|
888 | for (int k=0;k<span;k++)
|
---|
889 | {
|
---|
890 | resultArray[2*k] = (float)(((interArray[k])*(1.f/1.f)) + 0.0f);
|
---|
891 | resultArray[2*k + 1] = (float)(((interArray[k] + interArray[k + span])*(1.f/1.f)) + 0.0f);
|
---|
892 | }
|
---|
893 | span *= 2;
|
---|
894 | }
|
---|
895 |
|
---|
896 | for (int k=0;k<givenSpan;k++)
|
---|
897 | {
|
---|
898 | float plus = 0.5f;
|
---|
899 | if (resultArray[k] < 0)
|
---|
900 | plus *= -1.f;
|
---|
901 | if ((int)(resultArray[k]+plus) != (int)(orig_in[k]))
|
---|
902 | {
|
---|
903 | cout << "Nop, sorry: k: " << k << " " << resultArray[k] << " " << (int)(resultArray[k]+plus) << " " << plus << " " << orig[k] << endl;
|
---|
904 | return false;
|
---|
905 | }
|
---|
906 | }
|
---|
907 | delete[] interArray;
|
---|
908 | delete[] resultArray;
|
---|
909 | delete[] orig;
|
---|
910 | delete[] wavelets;
|
---|
911 | return true;
|
---|
912 | }
|
---|
913 |
|
---|
914 | void RawDataViewer::doWaveLetOnCurrentEventPlease()
|
---|
915 | {
|
---|
916 | int16_t* origTheWayIWant = new int16_t[1024*1440];
|
---|
917 |
|
---|
918 | // int numPixels = 1024;
|
---|
919 | // int leftOver = 1440-numPixels;
|
---|
920 | for (int k=0;k<1024;k++)
|
---|
921 | for (int j=0;j<1440;j++)
|
---|
922 | {
|
---|
923 | origTheWayIWant[k*1440 + j] = rawEventData[j + k*1440];
|
---|
924 | }
|
---|
925 |
|
---|
926 | int waveSpan = 1024;
|
---|
927 | int waveToPixelsRatio = 32;
|
---|
928 | waveSpan = waveSpan*waveToPixelsRatio;
|
---|
929 | int totalNumSamples = 1024*1440;
|
---|
930 | int j=0;
|
---|
931 | for (;j<totalNumSamples;j+= waveSpan)
|
---|
932 | {
|
---|
933 | if (j + waveSpan < totalNumSamples)
|
---|
934 | if (!doWaveLetsPlease(waveSpan, &origTheWayIWant[j], &waveLetArray[j], true))
|
---|
935 | return;
|
---|
936 | }
|
---|
937 |
|
---|
938 | while (j%1440 != 0)
|
---|
939 | {
|
---|
940 | int lastRun = 1;
|
---|
941 | while (lastRun < 1440 - j%1440)
|
---|
942 | lastRun *= 2;
|
---|
943 | lastRun /= 2;
|
---|
944 | if (lastRun > 2)
|
---|
945 | {
|
---|
946 | doWaveLetsPlease(lastRun, &origTheWayIWant[j], &waveLetArray[j], true);
|
---|
947 | }
|
---|
948 | else
|
---|
949 | {
|
---|
950 | for (int l=0;l<lastRun;l++)
|
---|
951 | waveLetArray[j+l] = origTheWayIWant[j+l];
|
---|
952 | }
|
---|
953 | if (!lastRun)
|
---|
954 | break;
|
---|
955 | j += lastRun;
|
---|
956 | }
|
---|
957 |
|
---|
958 | delete[] origTheWayIWant;
|
---|
959 |
|
---|
960 | }
|
---|
961 | void RawDataViewer::doMyWaveletTestPlease()
|
---|
962 | {
|
---|
963 | // cout << "Size of float: " << sizeof(float) << endl;
|
---|
964 | return;
|
---|
965 | ofstream outBin("/scratch/bin/outputBin.bin", ios_base::out | ios_base::binary);
|
---|
966 | ofstream outWave("/scratch/bin/outputWave.bin", ios_base::out | ios_base::binary);
|
---|
967 | int16_t* waveLetArray_ = new int16_t[1024*1440];
|
---|
968 | int16_t* origTheWayIWant = new int16_t[1024*1440];
|
---|
969 |
|
---|
970 | for (int i=0;i<nRows;i++)
|
---|
971 | {
|
---|
972 | cout << '\r' << "Doing row " << i << " of " << nRows;
|
---|
973 | cout.flush();
|
---|
974 | inputFile->GetRow(i);
|
---|
975 | outBin.write((const char*)(rawEventData), 1440*1024*2);
|
---|
976 |
|
---|
977 | // int numPixels = 1024;
|
---|
978 | // int leftOver = 1440-numPixels;
|
---|
979 | for (int k=0;k<1024;k++)
|
---|
980 | for (int j=0;j<1440;j++)
|
---|
981 | {
|
---|
982 | origTheWayIWant[k*1440 + j] = rawEventData[j + k*1440];
|
---|
983 | }
|
---|
984 |
|
---|
985 | int waveSpan = 1024;
|
---|
986 | int waveToPixelsRatio = 32;
|
---|
987 | waveSpan = waveSpan*waveToPixelsRatio;
|
---|
988 | int totalNumSamples = 1024*1440;
|
---|
989 | int j=0;
|
---|
990 | for (;j<totalNumSamples;j+= waveSpan)//1440/waveToPixelsRatio;j++)
|
---|
991 | {
|
---|
992 | if (j + waveSpan < totalNumSamples)
|
---|
993 | if (!doWaveLetsPlease(waveSpan, &origTheWayIWant[j], &waveLetArray_[j], true))
|
---|
994 | return;
|
---|
995 | }
|
---|
996 |
|
---|
997 | while (j%1440 != 0)// < totalNumSamples)
|
---|
998 | {
|
---|
999 | cout << "Copying the remaining of the data" << endl;
|
---|
1000 | int lastRun = 1;
|
---|
1001 | while (lastRun < 1440 - j%1440)//totalNumSamples-j)
|
---|
1002 | lastRun *= 2;
|
---|
1003 | lastRun /= 2;
|
---|
1004 | if (lastRun > 2)
|
---|
1005 | {
|
---|
1006 | // cout << " Doint one last run of " << lastRun << " samples" << endl;
|
---|
1007 | doWaveLetsPlease(lastRun, &origTheWayIWant[j], &waveLetArray_[j], true);
|
---|
1008 | }
|
---|
1009 | else
|
---|
1010 | {
|
---|
1011 | // cout << " Filling in " << lastRun << " samples" << endl;
|
---|
1012 | for (int l=0;l<lastRun;l++)
|
---|
1013 | waveLetArray_[j+l] = origTheWayIWant[j+l];
|
---|
1014 | }
|
---|
1015 | if (!lastRun)
|
---|
1016 | break;
|
---|
1017 | j += lastRun;
|
---|
1018 | }
|
---|
1019 | outWave.write((const char*)(waveLetArray_), 1440*1024*2);
|
---|
1020 | }
|
---|
1021 | outWave.close();
|
---|
1022 | outBin.close();
|
---|
1023 | inputFile->GetRow(0);
|
---|
1024 |
|
---|
1025 | delete[] waveLetArray_;
|
---|
1026 | delete[] origTheWayIWant;
|
---|
1027 | }
|
---|
1028 | void RawDataViewer::openCalibFile(string& file)
|
---|
1029 | {
|
---|
1030 | calibrationLoaded = false;
|
---|
1031 | calibInputFile = new fits(file);
|
---|
1032 | if (!*calibInputFile)
|
---|
1033 | {
|
---|
1034 | delete calibInputFile;
|
---|
1035 | calibInputFile = NULL;
|
---|
1036 | return;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | if (calibInputFile->HasKey("NROI"))
|
---|
1040 | {
|
---|
1041 | cout << "Looks like you're trying to load a regular raw data file as DRS calib. aborting." << endl;
|
---|
1042 | delete calibInputFile;
|
---|
1043 | calibInputFile = NULL;
|
---|
1044 | return;
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | if (!calibInputFile->SetPtrAddress("BaselineMean", baseLineMean)){
|
---|
1048 | cout << "Missing column " << "BaseLineMean" << " Aborting load..." << endl;
|
---|
1049 | return;}
|
---|
1050 | if (!calibInputFile->SetPtrAddress("GainMean", gainMean)){
|
---|
1051 | cout << "Missing column " << "GainMean" << " Aborting load..." << endl;
|
---|
1052 | return;}
|
---|
1053 | if (!calibInputFile->SetPtrAddress("TriggerOffsetMean", triggerOffsetMean)){
|
---|
1054 | cout << "Missing column " << "TriggerOffsetMean" << " Aborting load..." << endl;
|
---|
1055 | return;}
|
---|
1056 |
|
---|
1057 | calibInputFile->GetNextRow();
|
---|
1058 |
|
---|
1059 | // for (int i=0;i<1024;i++)
|
---|
1060 | // cout << gainMean[i] << " ";
|
---|
1061 | // cout << endl << endl;
|
---|
1062 |
|
---|
1063 | delete calibInputFile;
|
---|
1064 |
|
---|
1065 | calibrationLoaded = true;
|
---|
1066 |
|
---|
1067 | emit newFileLoaded();
|
---|
1068 | if (drawCalibrationLoaded)
|
---|
1069 | updateGL();
|
---|
1070 | }
|
---|
1071 | /************************************************************
|
---|
1072 | * PLUS EVENT
|
---|
1073 | ************************************************************/
|
---|
1074 | void RawDataViewer::plusEvent()
|
---|
1075 | {
|
---|
1076 | eventStepping(true);
|
---|
1077 | }
|
---|
1078 | /************************************************************
|
---|
1079 | * MINUS EVENT
|
---|
1080 | ************************************************************/
|
---|
1081 | void RawDataViewer::minusEvent()
|
---|
1082 | {
|
---|
1083 | eventStepping(false);
|
---|
1084 | }
|
---|
1085 | /************************************************************
|
---|
1086 | * SET EVENT STEP
|
---|
1087 | ************************************************************/
|
---|
1088 | void RawDataViewer::setEventStep(int step)
|
---|
1089 | {
|
---|
1090 | eventStep = step;
|
---|
1091 | }
|
---|
1092 | /************************************************************
|
---|
1093 | * EVENT STEPPING
|
---|
1094 | ************************************************************/
|
---|
1095 | void RawDataViewer::eventStepping(bool plus)
|
---|
1096 | {
|
---|
1097 | if (plus)
|
---|
1098 | rowNum += eventStep;
|
---|
1099 | else
|
---|
1100 | rowNum -= eventStep;
|
---|
1101 | if (rowNum >= nRows)
|
---|
1102 | rowNum -= nRows;
|
---|
1103 | if (rowNum < 0)
|
---|
1104 | rowNum += nRows;
|
---|
1105 | #ifdef LOAD_RAW
|
---|
1106 | eventNum+=eventStep;
|
---|
1107 | #else
|
---|
1108 | if (inputFile == NULL)
|
---|
1109 | return;
|
---|
1110 | inputFile->GetRow(rowNum);
|
---|
1111 | // cout << "Getting row " << rowNum << endl;
|
---|
1112 | for (int i=0;i<(1440+160)*nRoi;i++)
|
---|
1113 | eventData[i] = (float)rawEventData[i];
|
---|
1114 | #endif
|
---|
1115 |
|
---|
1116 | if (drawCalibrationLoaded && calibrationLoaded)
|
---|
1117 | {
|
---|
1118 | for (int i=0;i<1440;i++)
|
---|
1119 | for (int j=0;j<nRoi;j++)
|
---|
1120 | {
|
---|
1121 | int realj = (j+startPix[j])%1024;
|
---|
1122 | eventData[i*1024+j] *= 2000.f/4096.f;
|
---|
1123 | eventData[i*1024+j] -= (baseLineMean[i*1024+realj]+triggerOffsetMean[i*1024+j]);
|
---|
1124 | eventData[i*1024+j] /= gainMean[i*1024+realj];
|
---|
1125 | eventData[i*1024+j] *= (50000.f/65536.f) * 2500.f;
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 | updateGL();
|
---|
1129 | emit signalCurrentEvent(eventNum);
|
---|
1130 | emit signalCurrentPixel(selectedPixel);
|
---|
1131 | }
|
---|
1132 | /************************************************************
|
---|
1133 | * NEXT SLICE. deprec ?
|
---|
1134 | ************************************************************/
|
---|
1135 | void RawDataViewer::nextSlice()
|
---|
1136 | {
|
---|
1137 | whichSlice++;
|
---|
1138 | if (whichSlice >= nRoi)
|
---|
1139 | {
|
---|
1140 | whichSlice = 0;
|
---|
1141 | if (!loopCurrentEvent)
|
---|
1142 | {
|
---|
1143 | int backupStep = eventStep;
|
---|
1144 | eventStep = 1;
|
---|
1145 | eventStepping(true);
|
---|
1146 | eventStep = backupStep;
|
---|
1147 | }
|
---|
1148 | }
|
---|
1149 | emit signalCurrentSlice(whichSlice);
|
---|
1150 | updateGL();
|
---|
1151 | }
|
---|
1152 | void RawDataViewer::previousSlice()
|
---|
1153 | {
|
---|
1154 | whichSlice--;
|
---|
1155 | if (whichSlice < 0)
|
---|
1156 | {
|
---|
1157 | whichSlice = nRoi-1;
|
---|
1158 | if (!loopCurrentEvent)
|
---|
1159 | {
|
---|
1160 | int backupStep = eventStep;
|
---|
1161 | eventStep = 1;
|
---|
1162 | eventStepping(false);
|
---|
1163 | eventStep = backupStep;
|
---|
1164 | }
|
---|
1165 | }
|
---|
1166 | emit signalCurrentSlice(whichSlice);
|
---|
1167 | updateGL();
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | void RawDataViewer::computePulsesStatistics()
|
---|
1171 | {
|
---|
1172 | if (!inputFile)
|
---|
1173 | {
|
---|
1174 | cout << "A FITS file must be open in order to complete this operation" << endl;
|
---|
1175 | return;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 |
|
---|
1179 | // for (int i=0;i<nRows;i++)//for all events
|
---|
1180 | // {
|
---|
1181 | // inputFile->GetRow(rowNum);
|
---|
1182 | // for (int i=0;i<(1440+160)*nRoi;i++)
|
---|
1183 | // eventData[i] = (float)rawEventData[i];
|
---|
1184 |
|
---|
1185 | // for (int j=0;j<ACTUAL_NUM_PIXELS;j++)
|
---|
1186 | /// {
|
---|
1187 | int j = selectedPixel;
|
---|
1188 | for (int i=0;i<nRoi;i++)
|
---|
1189 | {
|
---|
1190 | aMeas[i] = eventData[j*1024+i];// * adcCount;
|
---|
1191 |
|
---|
1192 | }
|
---|
1193 | for (int i=0;i<nRoi;i++)
|
---|
1194 | {
|
---|
1195 | if (i==0)
|
---|
1196 | n1mean[i] = aMeas[i+1];
|
---|
1197 | else
|
---|
1198 | {
|
---|
1199 | if (i==1023)
|
---|
1200 | n1mean[i] = aMeas[i-1];
|
---|
1201 | else
|
---|
1202 | n1mean[i] = (aMeas[i-1]+aMeas[i+1])/2.f;
|
---|
1203 | }
|
---|
1204 | }
|
---|
1205 | //find spike
|
---|
1206 | for (int i=0;i<nRoi-3;i++)
|
---|
1207 | {
|
---|
1208 | const float fract = 0.8f;
|
---|
1209 | float xx, xp, xpp;
|
---|
1210 | vCorr[i] = 0;//aMeas[i];
|
---|
1211 | xx = aMeas[i] - n1mean[i];
|
---|
1212 | if (xx < -8.f)
|
---|
1213 | {
|
---|
1214 | xp = aMeas[i+1] - n1mean[i+1];
|
---|
1215 | xpp = aMeas[i+2] - n1mean[i+2];
|
---|
1216 | if ((aMeas[i+2] - (aMeas[i] + aMeas[i+3])/2.f) > 10.f)
|
---|
1217 | {
|
---|
1218 | vCorr[i+1] = (aMeas[i] + aMeas[i+3])/2.f;
|
---|
1219 | vCorr[i+2] = (aMeas[i] + aMeas[i+3])/2.f;
|
---|
1220 | i = i+2;
|
---|
1221 | }
|
---|
1222 | else
|
---|
1223 | {
|
---|
1224 | if ((xp > -2.*xx*fract) && (xpp < -10.f))
|
---|
1225 | {
|
---|
1226 | vCorr[i+1] = n1mean[i+1];
|
---|
1227 | n1mean[i+2] = aMeas[i+1] - aMeas[i+3]/2.f;
|
---|
1228 | i++;
|
---|
1229 | }
|
---|
1230 | }
|
---|
1231 | }
|
---|
1232 | }
|
---|
1233 | for (int i=0;i<nRoi;i++)
|
---|
1234 | n1mean[i] = aMeas[i]-n1mean[i];
|
---|
1235 | // }
|
---|
1236 | // }
|
---|
1237 | }
|
---|
1238 | /************************************************************
|
---|
1239 | * UICONNECTOR CONSTRUCTOR
|
---|
1240 | ************************************************************/
|
---|
1241 | UIConnector::UIConnector(QWidget*)
|
---|
1242 | {
|
---|
1243 | updateSpinnerDisplay = true;
|
---|
1244 |
|
---|
1245 | timer.setInterval(10.0);
|
---|
1246 | QObject::connect(&timer, SIGNAL(timeout()),
|
---|
1247 | this, SLOT(nextSlicePlease()));
|
---|
1248 | hwID = 393;
|
---|
1249 | swID = 0;
|
---|
1250 | crateID = 9;
|
---|
1251 | boardID = 8;
|
---|
1252 | patchID = 1;
|
---|
1253 | rescaleWholeCamera = true;
|
---|
1254 | currentFile = "none";
|
---|
1255 | currentCalibFile = "none";
|
---|
1256 |
|
---|
1257 | }
|
---|
1258 | void UIConnector::slicesPlusPlus()
|
---|
1259 | {
|
---|
1260 | viewer->nextSlice();
|
---|
1261 | }
|
---|
1262 | void UIConnector::slicesMinusMinus()
|
---|
1263 | {
|
---|
1264 | viewer->previousSlice();
|
---|
1265 | }
|
---|
1266 | void UIConnector::drawCalibratedDataChanged(int state)
|
---|
1267 | {
|
---|
1268 | if (state)
|
---|
1269 | {
|
---|
1270 | if (viewer->calibrationLoaded)
|
---|
1271 | {
|
---|
1272 | viewer->drawCalibrationLoaded = true;
|
---|
1273 | for (int i=0;i<1440;i++)
|
---|
1274 | for (int j=0;j<viewer->nRoi;j++)
|
---|
1275 | {
|
---|
1276 | int realj = (j+viewer->startPix[j])%1024;
|
---|
1277 | viewer->eventData[i*1024+j] *= 2000.f/4096.f;
|
---|
1278 | viewer->eventData[i*1024+j] -= (viewer->baseLineMean[i*1024+realj]+viewer->triggerOffsetMean[i*1024+j]);
|
---|
1279 | viewer->eventData[i*1024+j] /= viewer->gainMean[i*1024+realj];
|
---|
1280 | viewer->eventData[i*1024+j] *= (50000.f/65536.f) * 2500.f;
|
---|
1281 | }
|
---|
1282 | viewer->updateGL();
|
---|
1283 | }
|
---|
1284 | else
|
---|
1285 | {
|
---|
1286 | drawCalibrationCheckBox->setChecked(false);
|
---|
1287 | }
|
---|
1288 | }
|
---|
1289 | else
|
---|
1290 | {
|
---|
1291 | viewer->drawCalibrationLoaded = false;
|
---|
1292 | if (viewer->calibrationLoaded)
|
---|
1293 | {
|
---|
1294 | for (int i=0;i<1440;i++)
|
---|
1295 | for (int j=0;j<viewer->nRoi;j++)
|
---|
1296 | {
|
---|
1297 | int realj = (j+viewer->startPix[j])%1024;
|
---|
1298 | viewer->eventData[i*1024+j] /= (50000.f/65536.f) * 2500.f;
|
---|
1299 | viewer->eventData[i*1024+j] *= viewer->gainMean[i*1024+realj];
|
---|
1300 | viewer->eventData[i*1024+j] += (viewer->baseLineMean[i*1024+realj]+viewer->triggerOffsetMean[i*1024+j]);
|
---|
1301 | viewer->eventData[i*1024+j] /= 2000.f/4096.f;
|
---|
1302 | }
|
---|
1303 | viewer->updateGL();
|
---|
1304 | }
|
---|
1305 |
|
---|
1306 | }
|
---|
1307 | autoScalePressed();
|
---|
1308 |
|
---|
1309 | }
|
---|
1310 | /************************************************************
|
---|
1311 | * DRAW PATCHES CHECK CHANGE. checkbox handler
|
---|
1312 | ************************************************************/
|
---|
1313 | void UIConnector::drawPatchesCheckChange(int state)
|
---|
1314 | {
|
---|
1315 | if (state)
|
---|
1316 | viewer->drawPatch = true;
|
---|
1317 | else
|
---|
1318 | viewer->drawPatch = false;
|
---|
1319 | viewer->updateGL();
|
---|
1320 | }
|
---|
1321 | /************************************************************
|
---|
1322 | * DRAW IMPULSE CHECK CHANGE. checkbox handler
|
---|
1323 | ************************************************************/
|
---|
1324 | void UIConnector::drawImpulseCheckChange(int state)
|
---|
1325 | {
|
---|
1326 | if (state)
|
---|
1327 | viewer->drawImpulse = true;
|
---|
1328 | else
|
---|
1329 | viewer->drawImpulse = false;
|
---|
1330 | viewer->updateGL();
|
---|
1331 | }
|
---|
1332 | /************************************************************
|
---|
1333 | * DRAW BLUR CHECK CHANGE. checkbox handler
|
---|
1334 | ************************************************************/
|
---|
1335 | void UIConnector::drawBlurCheckChange(int state)
|
---|
1336 | {
|
---|
1337 | if (state)
|
---|
1338 | viewer->drawBlur = true;
|
---|
1339 | else
|
---|
1340 | viewer->drawBlur = false;
|
---|
1341 | viewer->updateGL();
|
---|
1342 | }
|
---|
1343 | void UIConnector::loopEventCheckChange(int state)
|
---|
1344 | {
|
---|
1345 | if (state)
|
---|
1346 | viewer->loopCurrentEvent = true;
|
---|
1347 | else
|
---|
1348 | viewer->loopCurrentEvent = false;
|
---|
1349 | }
|
---|
1350 | /************************************************************
|
---|
1351 | * NEXT SLICE PLEASE
|
---|
1352 | ************************************************************/
|
---|
1353 | void UIConnector::nextSlicePlease()
|
---|
1354 | {
|
---|
1355 | if (playEventsRadio->isChecked ())
|
---|
1356 | viewer->eventStepping(true);
|
---|
1357 | else
|
---|
1358 | viewer->nextSlice();
|
---|
1359 | }
|
---|
1360 | /************************************************************
|
---|
1361 | * SET VIEWER.
|
---|
1362 | ************************************************************/
|
---|
1363 | void UIConnector::setViewer(RawDataViewer* v)
|
---|
1364 | {
|
---|
1365 | viewer = v;
|
---|
1366 | }
|
---|
1367 | /************************************************************
|
---|
1368 | * SLICES PER SECOND CHANGED. timing ui handler
|
---|
1369 | ************************************************************/
|
---|
1370 | void UIConnector::slicesPerSecondChanged(double value)
|
---|
1371 | {
|
---|
1372 | timer.setInterval(1000.0/value);
|
---|
1373 | }
|
---|
1374 | /************************************************************
|
---|
1375 | * RANGE CHANGED . colors tweaking handler
|
---|
1376 | ************************************************************/
|
---|
1377 | void UIConnector::rangeChanged0(double value)
|
---|
1378 | {
|
---|
1379 | viewer->ss[0] = (float)value;
|
---|
1380 | viewer->updateGL();
|
---|
1381 | }
|
---|
1382 | /************************************************************
|
---|
1383 | * RANGE CHANGED . colors tweaking handler
|
---|
1384 | ************************************************************/
|
---|
1385 | void UIConnector::rangeChanged1(double value)
|
---|
1386 | {
|
---|
1387 | viewer->ss[1] = (float)value;
|
---|
1388 | viewer->updateGL();
|
---|
1389 | }
|
---|
1390 | /************************************************************
|
---|
1391 | * RANGE CHANGED . colors tweaking handler
|
---|
1392 | ************************************************************/
|
---|
1393 | void UIConnector::rangeChanged2(double value)
|
---|
1394 | {
|
---|
1395 | viewer->ss[2] = (float)value;
|
---|
1396 | viewer->updateGL();
|
---|
1397 | }
|
---|
1398 | /************************************************************
|
---|
1399 | * RANGE CHANGED . colors tweaking handler
|
---|
1400 | ************************************************************/
|
---|
1401 | void UIConnector::rangeChanged3(double value)
|
---|
1402 | {
|
---|
1403 | viewer->ss[3] = (float)value;
|
---|
1404 | viewer->updateGL();
|
---|
1405 | }
|
---|
1406 | /************************************************************
|
---|
1407 | * RANGE CHANGED . colors tweaking handler
|
---|
1408 | ************************************************************/
|
---|
1409 | void UIConnector::rangeChanged4(double value)
|
---|
1410 | {
|
---|
1411 | viewer->ss[4] = (float)value;
|
---|
1412 | viewer->updateGL();
|
---|
1413 | }
|
---|
1414 | /************************************************************
|
---|
1415 | * RANGE CHANGED . colors tweaking handler
|
---|
1416 | ************************************************************/
|
---|
1417 | void UIConnector::redChanged0(double value)
|
---|
1418 | {
|
---|
1419 | viewer->rr[0] = (float)value;
|
---|
1420 | viewer->updateGL();
|
---|
1421 | }
|
---|
1422 | /************************************************************
|
---|
1423 | * RED CHANGED . colors tweaking handler
|
---|
1424 | ************************************************************/
|
---|
1425 | void UIConnector::redChanged1(double value)
|
---|
1426 | {
|
---|
1427 | viewer->rr[1] = (float)value;
|
---|
1428 | viewer->updateGL();
|
---|
1429 | }
|
---|
1430 | /************************************************************
|
---|
1431 | * RED CHANGED . colors tweaking handler
|
---|
1432 | ************************************************************/
|
---|
1433 | void UIConnector::redChanged2(double value)
|
---|
1434 | {
|
---|
1435 | viewer->rr[2] = (float)value;
|
---|
1436 | viewer->updateGL();
|
---|
1437 | }
|
---|
1438 | /************************************************************
|
---|
1439 | * RED CHANGED . colors tweaking handler
|
---|
1440 | ************************************************************/
|
---|
1441 | void UIConnector::redChanged3(double value)
|
---|
1442 | {
|
---|
1443 | viewer->rr[3] = (float)value;
|
---|
1444 | viewer->updateGL();
|
---|
1445 | }
|
---|
1446 | /************************************************************
|
---|
1447 | * RED CHANGED . colors tweaking handler
|
---|
1448 | ************************************************************/
|
---|
1449 | void UIConnector::redChanged4(double value)
|
---|
1450 | {
|
---|
1451 | viewer->rr[4] = (float)value;
|
---|
1452 | viewer->updateGL();
|
---|
1453 | }
|
---|
1454 | /************************************************************
|
---|
1455 | * GREEN CHANGED . colors tweaking handler
|
---|
1456 | ************************************************************/
|
---|
1457 | void UIConnector::greenChanged0(double value)
|
---|
1458 | {
|
---|
1459 | viewer->gg[0] = (float)value;
|
---|
1460 | viewer->updateGL();
|
---|
1461 | }
|
---|
1462 | /************************************************************
|
---|
1463 | * GREEN CHANGED . colors tweaking handler
|
---|
1464 | ************************************************************/
|
---|
1465 | void UIConnector::greenChanged1(double value)
|
---|
1466 | {
|
---|
1467 | viewer->gg[1] = (float)value;
|
---|
1468 | viewer->updateGL();
|
---|
1469 | }
|
---|
1470 | /************************************************************
|
---|
1471 | * GREEN CHANGED . colors tweaking handler
|
---|
1472 | ************************************************************/
|
---|
1473 | void UIConnector::greenChanged2(double value)
|
---|
1474 | {
|
---|
1475 | viewer->gg[2] = (float)value;
|
---|
1476 | viewer->updateGL();
|
---|
1477 | }
|
---|
1478 | /************************************************************
|
---|
1479 | * GREEN CHANGED . colors tweaking handler
|
---|
1480 | ************************************************************/
|
---|
1481 | void UIConnector::greenChanged3(double value)
|
---|
1482 | {
|
---|
1483 | viewer->gg[3] = (float)value;
|
---|
1484 | viewer->updateGL();
|
---|
1485 | }
|
---|
1486 | /************************************************************
|
---|
1487 | * GREEN CHANGED . colors tweaking handler
|
---|
1488 | ************************************************************/
|
---|
1489 | void UIConnector::greenChanged4(double value)
|
---|
1490 | {
|
---|
1491 | viewer->gg[4] = (float)value;
|
---|
1492 | viewer->updateGL();
|
---|
1493 | }
|
---|
1494 | /************************************************************
|
---|
1495 | * BLUE CHANGED . colors tweaking handler
|
---|
1496 | ************************************************************/
|
---|
1497 | void UIConnector::blueChanged0(double value)
|
---|
1498 | {
|
---|
1499 | viewer->bb[0] = (float)value;
|
---|
1500 | viewer->updateGL();
|
---|
1501 | }
|
---|
1502 | /************************************************************
|
---|
1503 | * BLUE CHANGED . colors tweaking handler
|
---|
1504 | ************************************************************/
|
---|
1505 | void UIConnector::blueChanged1(double value)
|
---|
1506 | {
|
---|
1507 | viewer->bb[1] = (float)value;
|
---|
1508 | viewer->updateGL();
|
---|
1509 | }
|
---|
1510 | /************************************************************
|
---|
1511 | * BLUE CHANGED . colors tweaking handler
|
---|
1512 | ************************************************************/
|
---|
1513 | void UIConnector::blueChanged2(double value)
|
---|
1514 | {
|
---|
1515 | viewer->bb[2] = (float)value;
|
---|
1516 | viewer->updateGL();
|
---|
1517 | }
|
---|
1518 | /************************************************************
|
---|
1519 | * BLUE CHANGED . colors tweaking handler
|
---|
1520 | ************************************************************/
|
---|
1521 | void UIConnector::blueChanged3(double value)
|
---|
1522 | {
|
---|
1523 | viewer->bb[3] = (float)value;
|
---|
1524 | viewer->updateGL();
|
---|
1525 | }
|
---|
1526 | /************************************************************
|
---|
1527 | * BLUE CHANGED . colors tweaking handler
|
---|
1528 | ************************************************************/
|
---|
1529 | void UIConnector::blueChanged4(double value)
|
---|
1530 | {
|
---|
1531 | viewer->bb[4] = (float)value;
|
---|
1532 | viewer->updateGL();
|
---|
1533 | }
|
---|
1534 | /************************************************************
|
---|
1535 | * LOAD NEW FILE CLICKED. button handler
|
---|
1536 | ************************************************************/
|
---|
1537 | void UIConnector::loadNewFileClicked()
|
---|
1538 | {
|
---|
1539 | QFileDialog dialog;
|
---|
1540 | dialog.setFileMode(QFileDialog::ExistingFile);
|
---|
1541 | dialog.open(this, SLOT(fileSelected(QString)));
|
---|
1542 | dialog.setVisible(true);
|
---|
1543 | dialog.exec();
|
---|
1544 | }
|
---|
1545 | void UIConnector::loadNewCalibFileClicked()
|
---|
1546 | {
|
---|
1547 | QFileDialog dialog;
|
---|
1548 | dialog.setFileMode(QFileDialog::ExistingFile);
|
---|
1549 | dialog.open(this, SLOT(calibFileSelected(QString)));
|
---|
1550 | dialog.setVisible(true);
|
---|
1551 | dialog.exec();
|
---|
1552 | }
|
---|
1553 | /************************************************************
|
---|
1554 | * FILE SELECTED. return of the file open dialog handler
|
---|
1555 | ************************************************************/
|
---|
1556 | void UIConnector::fileSelected(QString file)
|
---|
1557 | {
|
---|
1558 | currentFile = file.toStdString();
|
---|
1559 | if (currentFile != "")
|
---|
1560 | viewer->openFile(currentFile);
|
---|
1561 | }
|
---|
1562 | void UIConnector::calibFileSelected(QString file)
|
---|
1563 | {
|
---|
1564 | currentCalibFile = file.toStdString();
|
---|
1565 | if (currentCalibFile != "")
|
---|
1566 | viewer->openCalibFile(currentCalibFile);
|
---|
1567 | }
|
---|
1568 | /************************************************************
|
---|
1569 | * NEW FILE LOADED. update of the UI after a new file has been loaded
|
---|
1570 | ************************************************************/
|
---|
1571 | void UIConnector::newFileLoaded()
|
---|
1572 | {
|
---|
1573 | ostringstream str;
|
---|
1574 |
|
---|
1575 | //extract the file name only (no path) from the full name
|
---|
1576 | str << "File: " << currentFile.substr(currentFile.find_last_of("//")+1, currentFile.size()) << "\n";
|
---|
1577 | str << "Calibration: " << currentCalibFile.substr(currentCalibFile.find_last_of("//")+1, currentCalibFile.size()) << "\n";
|
---|
1578 | // fileLoadedLabel->setText(QString(str.str().c_str()));
|
---|
1579 | // str.str("");
|
---|
1580 | str << "Run number: " << viewer->runNumber << "\n";
|
---|
1581 | // runNumberLabel->setText(QString(str.str().c_str()));
|
---|
1582 | // str.str("");
|
---|
1583 | str << "Number of Events: " << viewer->nRows << "\n";
|
---|
1584 |
|
---|
1585 | eventNumberBox->setMaximum(viewer->nRows-1);
|
---|
1586 |
|
---|
1587 | str << "Number of Slices: " << viewer->nRoi << "\n";// << "/1024";
|
---|
1588 | // numberOfSlicesLabel->setText(QString(str.str().c_str()));
|
---|
1589 | // str.str("");
|
---|
1590 | str << "Number of Time Marks: " << viewer->nTM << "\n";
|
---|
1591 | // numberOfTimeMarksLabel->setText(QString(str.str().c_str()));
|
---|
1592 |
|
---|
1593 | // str.str("");
|
---|
1594 | str << "Run Type: " << viewer->runType << "\n";
|
---|
1595 | // runTypeLabel->setText(QString(str.str().c_str()));
|
---|
1596 | // str.str("");
|
---|
1597 | str << "Time of 1st data: " << viewer->firstDataTime << "\n";
|
---|
1598 | // firstTimeLabel->setText(QString(str.str().c_str()));
|
---|
1599 | // str.str("");
|
---|
1600 | str << "Time of last data: " << viewer->lastDataTime << "\n";
|
---|
1601 | // lastTimeLabel->setText(QString(str.str().c_str()));
|
---|
1602 | // str.str("");
|
---|
1603 | str << "SVN revision: " << viewer->revision << '\n';
|
---|
1604 | str << "Number of boards: " << viewer->nBoards << '\n';
|
---|
1605 | str << "Number of pixels: " << viewer->nPixels << '\n';
|
---|
1606 | str << "Number of Slices TM: " << viewer->nRoiTM << '\n';
|
---|
1607 | str << "Time system: " << viewer->timeSystem << '\n';
|
---|
1608 | str << "Date: " << viewer->creationDate << '\n';
|
---|
1609 | str << "Night: " << viewer->nightInt << '\n';
|
---|
1610 | str << "Camera: " << viewer->camera << '\n';
|
---|
1611 | str << "DAQ: " << viewer->daq << '\n';
|
---|
1612 | str << "ADC Count: " << viewer->adcCount << '\n';
|
---|
1613 | str << "NB Evts OK:" << viewer->nbOk << '\n';
|
---|
1614 | str << "NB Evts Rejected: " << viewer->nbRej << '\n';
|
---|
1615 | str << "NB Evts Bad: " << viewer->nbBad << '\n';
|
---|
1616 | extraInfoLabel->setText(QString(str.str().c_str()));
|
---|
1617 |
|
---|
1618 | if (viewer->calibrationLoaded)
|
---|
1619 | {
|
---|
1620 | drawCalibrationCheckBox->setEnabled(true);
|
---|
1621 | }
|
---|
1622 |
|
---|
1623 |
|
---|
1624 | }
|
---|
1625 | /************************************************************
|
---|
1626 | * PLAY PAUSE CLICKED. ui handler
|
---|
1627 | ************************************************************/
|
---|
1628 | void UIConnector::playPauseClicked()
|
---|
1629 | {
|
---|
1630 | if (timer.isActive())
|
---|
1631 | timer.stop();
|
---|
1632 | else
|
---|
1633 | timer.start();
|
---|
1634 | }
|
---|
1635 | /************************************************************
|
---|
1636 | * CURRENT SLICE HAS CHANGE. ui handler
|
---|
1637 | ************************************************************/
|
---|
1638 | void UIConnector::currentSliceHasChanged(int slice)
|
---|
1639 | {
|
---|
1640 | if (!viewer->nRoi)
|
---|
1641 | return;
|
---|
1642 | ostringstream str;
|
---|
1643 | // str << "Displaying Slice " << slice;
|
---|
1644 | // QString qstr(str.str().c_str());
|
---|
1645 | if (updateSpinnerDisplay)
|
---|
1646 | emit updateCurrentSliceDisplay(slice);
|
---|
1647 |
|
---|
1648 | str.str("");
|
---|
1649 | str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
|
---|
1650 | QString qstr = qstr.fromStdString(str.str());
|
---|
1651 | emit updateCurrentPixelSliceValue(qstr);
|
---|
1652 |
|
---|
1653 | }
|
---|
1654 | /************************************************************
|
---|
1655 | * CURRENT EVENT HAS CHANGED. ui handler
|
---|
1656 | ************************************************************/
|
---|
1657 | double xval[50000];
|
---|
1658 | double yval[50000];
|
---|
1659 | void UIConnector::eventChangedFromSpinner(int cEvent)
|
---|
1660 | {
|
---|
1661 | // cout << "Here " << updateSpinnerDisplay << endl;
|
---|
1662 | if (!updateSpinnerDisplay)
|
---|
1663 | return;
|
---|
1664 | updateSpinnerDisplay = false;
|
---|
1665 | // currentEventHasChanged(cEvent);
|
---|
1666 | viewer->rowNum = cEvent - viewer->eventStep;
|
---|
1667 | viewer->eventStepping(true);
|
---|
1668 | updateSpinnerDisplay = true;
|
---|
1669 |
|
---|
1670 | // viewer->updateGL();
|
---|
1671 | }
|
---|
1672 | void UIConnector::sliceChangedFromSpinner(int cSlice)
|
---|
1673 | {
|
---|
1674 | updateSpinnerDisplay = false;
|
---|
1675 | currentSliceHasChanged(cSlice);
|
---|
1676 | updateSpinnerDisplay = true;
|
---|
1677 | viewer->whichSlice = cSlice;
|
---|
1678 | viewer->updateGL();
|
---|
1679 | }
|
---|
1680 | void UIConnector::currentEventHasChanged(int )
|
---|
1681 | {
|
---|
1682 | ostringstream str;
|
---|
1683 | // str << "Displaying Event " << cEvent;
|
---|
1684 | // QString qstr(str.str().c_str());
|
---|
1685 | // emit updateCurrentEventDisplay(qstr);
|
---|
1686 | if (updateSpinnerDisplay)
|
---|
1687 | {
|
---|
1688 | updateSpinnerDisplay = false;
|
---|
1689 | emit updateCurrentEventDisplay(viewer->rowNum);
|
---|
1690 | updateSpinnerDisplay = true;
|
---|
1691 | }
|
---|
1692 |
|
---|
1693 | // viewer->doWaveLetOnCurrentEventPlease();
|
---|
1694 |
|
---|
1695 | //retrieve the data that we want to display
|
---|
1696 | str.str("");
|
---|
1697 | str << "PC Time: " << viewer->pcTime;
|
---|
1698 | QString qstr = qstr.fromStdString(str.str());
|
---|
1699 | emit updateCurrentPCTime(qstr);
|
---|
1700 |
|
---|
1701 | str.str("");
|
---|
1702 | str << "Software Trigger: " << viewer->softTrig;
|
---|
1703 | qstr = qstr.fromStdString(str.str());
|
---|
1704 | emit updateCurrentSoftTrigger(qstr);
|
---|
1705 |
|
---|
1706 | str.str("");
|
---|
1707 | str << "Trigger Type: " << viewer->triggerType;
|
---|
1708 | qstr = qstr.fromStdString(str.str());
|
---|
1709 | emit updateCurrentTriggerType(qstr);
|
---|
1710 |
|
---|
1711 | str.str("");
|
---|
1712 | str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
|
---|
1713 | qstr = qstr.fromStdString(str.str());
|
---|
1714 | emit updateCurrentPixelSliceValue(qstr);
|
---|
1715 |
|
---|
1716 | if (autoScaleColor->isChecked())
|
---|
1717 | emit viewer->colorPaletteHasChanged();//autoScalePressed();
|
---|
1718 |
|
---|
1719 | boardsTimeList->clear();
|
---|
1720 | startPixelsList->clear();
|
---|
1721 | startTimeMarksList->clear();
|
---|
1722 | triggerDelayList->clear();
|
---|
1723 | std::map<int, int> boardsHistoMap;
|
---|
1724 | for (int i=0;i <NBOARDS; i++)
|
---|
1725 | {
|
---|
1726 | str.str("");
|
---|
1727 | str << i;
|
---|
1728 | if (i<10) str << " ";
|
---|
1729 | if (i<100) str << " ";
|
---|
1730 | if (i<1000) str << " ";
|
---|
1731 | str << ": " << viewer->boardTime[i];
|
---|
1732 | boardsTimeList->addItem(QString(str.str().c_str()));
|
---|
1733 | if (boardsHistoMap.find(viewer->boardTime[i]) != boardsHistoMap.end())
|
---|
1734 | boardsHistoMap[viewer->boardTime[i]]++;
|
---|
1735 | else
|
---|
1736 | boardsHistoMap[viewer->boardTime[i]] = 1;
|
---|
1737 | }
|
---|
1738 | std::map<int, int> pixelHistoMap;
|
---|
1739 | for (int i=0;i <NPIX; i++)
|
---|
1740 | {
|
---|
1741 | str.str("");
|
---|
1742 | str << i;
|
---|
1743 | if (i<10) str << " ";
|
---|
1744 | if (i<100) str << " ";
|
---|
1745 | if (i<1000) str << " ";
|
---|
1746 | str << ": " << viewer->startPix[i];
|
---|
1747 | startPixelsList->addItem(QString(str.str().c_str()));
|
---|
1748 | if (pixelHistoMap.find(viewer->startPix[i]) != pixelHistoMap.end())
|
---|
1749 | pixelHistoMap[viewer->startPix[i]]++;
|
---|
1750 | else
|
---|
1751 | pixelHistoMap[viewer->startPix[i]] = 1;
|
---|
1752 | }
|
---|
1753 |
|
---|
1754 | std::map<int, int> timeMarksMap;
|
---|
1755 | for (int i=0;i <NTMARK; i++)
|
---|
1756 | {
|
---|
1757 | str.str("");
|
---|
1758 | str << i;
|
---|
1759 | if (i<10) str << " ";
|
---|
1760 | if (i<100) str << " ";
|
---|
1761 | if (i<1000) str << " ";
|
---|
1762 | str << ": " << viewer->startTM[i];
|
---|
1763 | startTimeMarksList->addItem(QString(str.str().c_str()));
|
---|
1764 | if (timeMarksMap.find(viewer->startTM[i]) != timeMarksMap.end())
|
---|
1765 | timeMarksMap[viewer->startTM[i]]++;
|
---|
1766 | else
|
---|
1767 | timeMarksMap[viewer->startTM[i]] = 1;
|
---|
1768 | }
|
---|
1769 | std::map<int,int> delayMap;
|
---|
1770 | triggerDelayList->addItem(QString("Patch | Slice:Delay Slice:Delay..."));
|
---|
1771 | for (int i=0;i<NTMARK; i++)
|
---|
1772 | {
|
---|
1773 | str.str("");
|
---|
1774 | str << i << " | ";
|
---|
1775 | for (int j=0;j<viewer->nRoi;j++)
|
---|
1776 | {
|
---|
1777 | int value = viewer->eventData[1440*viewer->nRoi + i*viewer->nRoi + j];
|
---|
1778 | if (delayMap.find(value) != delayMap.end())
|
---|
1779 | delayMap[value]++;
|
---|
1780 | else
|
---|
1781 | delayMap[value] = 1;
|
---|
1782 | str << j << ":" << value << " ";
|
---|
1783 | }
|
---|
1784 | triggerDelayList->addItem(QString(str.str().c_str()));
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | std::map<int,int>::iterator it = boardsHistoMap.begin();
|
---|
1788 | int nsamples = 0;
|
---|
1789 | int previousValue = it->first-10;
|
---|
1790 | for (unsigned int i=0;i<boardsHistoMap.size();i++)
|
---|
1791 | {
|
---|
1792 | if (previousValue != it->first-1)
|
---|
1793 | {
|
---|
1794 | xval[nsamples] = previousValue+1;
|
---|
1795 | yval[nsamples] = 0;
|
---|
1796 | nsamples++;
|
---|
1797 | xval[nsamples] = it->first-1;
|
---|
1798 | yval[nsamples] = 0;
|
---|
1799 | nsamples++;
|
---|
1800 | }
|
---|
1801 | xval[nsamples] = it->first;
|
---|
1802 | yval[nsamples] = it->second;
|
---|
1803 | previousValue = it->first;
|
---|
1804 | it++;
|
---|
1805 | nsamples++;
|
---|
1806 | xval[nsamples] = previousValue;
|
---|
1807 | yval[nsamples] = 0;
|
---|
1808 | nsamples++;
|
---|
1809 | if (nsamples > 4090)
|
---|
1810 | {
|
---|
1811 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1812 | break;
|
---|
1813 | }
|
---|
1814 | }
|
---|
1815 | xval[nsamples] = it==boardsHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1816 | yval[nsamples] = 0;
|
---|
1817 | nsamples++;
|
---|
1818 | // if (nsamples > 5)
|
---|
1819 | #if QWT_VERSION < 0x060000
|
---|
1820 | boardsTimeHistoItem.setData(xval, yval, nsamples);
|
---|
1821 | #else
|
---|
1822 | boardsTimeHistoItem.setSamples(xval, yval, nsamples);
|
---|
1823 | #endif
|
---|
1824 |
|
---|
1825 | it = pixelHistoMap.begin();
|
---|
1826 | nsamples = 0;
|
---|
1827 | previousValue = it->first-10;
|
---|
1828 | for (unsigned int i=0;i<pixelHistoMap.size();i++)
|
---|
1829 | {
|
---|
1830 | if (previousValue != it->first-1)
|
---|
1831 | {
|
---|
1832 | xval[nsamples] = previousValue+1;
|
---|
1833 | yval[nsamples] = 0;
|
---|
1834 | nsamples++;
|
---|
1835 | xval[nsamples] = it->first-1;
|
---|
1836 | yval[nsamples] = 0;
|
---|
1837 | nsamples++;
|
---|
1838 | }
|
---|
1839 | xval[nsamples] = it->first;
|
---|
1840 | yval[nsamples] = it->second;
|
---|
1841 | previousValue = it->first;
|
---|
1842 | it++;
|
---|
1843 | nsamples++;
|
---|
1844 | xval[nsamples] = previousValue;
|
---|
1845 | yval[nsamples] = 0;
|
---|
1846 | nsamples++;
|
---|
1847 | if (nsamples > 4090)
|
---|
1848 | {
|
---|
1849 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1850 | break;
|
---|
1851 | }
|
---|
1852 | }
|
---|
1853 | xval[nsamples] = it==pixelHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1854 | yval[nsamples] = 0;
|
---|
1855 | nsamples++;
|
---|
1856 | // if (nsamples > 5)
|
---|
1857 | #if QWT_VERSION < 0x060000
|
---|
1858 | startCellHistoItem.setData(xval, yval, nsamples);
|
---|
1859 | #else
|
---|
1860 | startCellHistoItem.setSamples(xval, yval, nsamples);
|
---|
1861 | #endif
|
---|
1862 |
|
---|
1863 | it = timeMarksMap.begin();
|
---|
1864 | nsamples = 0;
|
---|
1865 | previousValue = it->first-10;
|
---|
1866 | for (unsigned int i=0;i<timeMarksMap.size();i++)
|
---|
1867 | {
|
---|
1868 | if (previousValue != it->first-1)
|
---|
1869 | {
|
---|
1870 | xval[nsamples] = previousValue+1;
|
---|
1871 | yval[nsamples] = 0;
|
---|
1872 | nsamples++;
|
---|
1873 | xval[nsamples] = it->first-1;
|
---|
1874 | yval[nsamples] = 0;
|
---|
1875 | nsamples++;
|
---|
1876 | }
|
---|
1877 | xval[nsamples] = it->first;
|
---|
1878 | yval[nsamples] = it->second;
|
---|
1879 | previousValue = it->first;
|
---|
1880 | it++;
|
---|
1881 | nsamples++;
|
---|
1882 | xval[nsamples] = previousValue;
|
---|
1883 | yval[nsamples] = 0;
|
---|
1884 | nsamples++;
|
---|
1885 | if (nsamples > 4090)
|
---|
1886 | {
|
---|
1887 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1888 | break;
|
---|
1889 | }
|
---|
1890 | }
|
---|
1891 | xval[nsamples] = it==timeMarksMap.begin() ? 0 : (--it)->first+1;
|
---|
1892 | yval[nsamples] = 0;
|
---|
1893 | nsamples++;
|
---|
1894 | // if (nsamples > 5)
|
---|
1895 | #if QWT_VERSION < 0x060000
|
---|
1896 | startTimeMarkHistoItem.setData(xval, yval, nsamples);
|
---|
1897 | #else
|
---|
1898 | startTimeMarkHistoItem.setSamples(xval, yval, nsamples);
|
---|
1899 | #endif
|
---|
1900 |
|
---|
1901 | it = delayMap.begin();
|
---|
1902 | nsamples = 0;
|
---|
1903 | previousValue = it->first-10;
|
---|
1904 | for (unsigned int i=0;i<delayMap.size();i++)
|
---|
1905 | {
|
---|
1906 | if (previousValue != it->first-1)
|
---|
1907 | {
|
---|
1908 | xval[nsamples] = previousValue+1;
|
---|
1909 | yval[nsamples] = 0;
|
---|
1910 | nsamples++;
|
---|
1911 | xval[nsamples] = it->first-1;
|
---|
1912 | yval[nsamples] = 0;
|
---|
1913 | nsamples++;
|
---|
1914 | }
|
---|
1915 | xval[nsamples] = it->first;
|
---|
1916 | yval[nsamples] = it->second;
|
---|
1917 | previousValue = it->first;
|
---|
1918 | it++;
|
---|
1919 | nsamples++;
|
---|
1920 | xval[nsamples] = previousValue;
|
---|
1921 | yval[nsamples] = 0;
|
---|
1922 | nsamples++;
|
---|
1923 | if (nsamples > 4090)
|
---|
1924 | {
|
---|
1925 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1926 | break;
|
---|
1927 | }
|
---|
1928 | }
|
---|
1929 | xval[nsamples] = it==delayMap.begin() ? 0 : (--it)->first+1;
|
---|
1930 | yval[nsamples] = 0;
|
---|
1931 | nsamples++;
|
---|
1932 | // if (nsamples > 5)
|
---|
1933 | #if QWT_VERSION < 0x060000
|
---|
1934 | triggerDelayHistoItem.setData(xval, yval, nsamples);
|
---|
1935 | #else
|
---|
1936 | triggerDelayHistoItem.setSamples(xval, yval, nsamples);
|
---|
1937 | #endif
|
---|
1938 | //WAVELETS HACK
|
---|
1939 | /* std::map<int, int> valuesHistoMap;
|
---|
1940 | std::map<int, int> waveletHistoMap;
|
---|
1941 | for (int i=0;i<1024*1440;i++)
|
---|
1942 | {
|
---|
1943 | if (valuesHistoMap.find(viewer->rawEventData[i]) != valuesHistoMap.end())
|
---|
1944 | valuesHistoMap[viewer->rawEventData[i]]++;
|
---|
1945 | else
|
---|
1946 | valuesHistoMap[viewer->rawEventData[i]] = 1;
|
---|
1947 | if (waveletHistoMap.find(viewer->waveLetArray[i]) != waveletHistoMap.end())
|
---|
1948 | waveletHistoMap[viewer->waveLetArray[i]]++;
|
---|
1949 | else
|
---|
1950 | waveletHistoMap[viewer->waveLetArray[i]] = 1;
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | it = valuesHistoMap.begin();
|
---|
1954 | nsamples = 0;
|
---|
1955 | previousValue = it->first-10;
|
---|
1956 | cout << "Num values Original: " << valuesHistoMap.size() << endl;
|
---|
1957 | for (unsigned int i=0;i<valuesHistoMap.size();i++)
|
---|
1958 | {
|
---|
1959 | if (previousValue != it->first-1)
|
---|
1960 | {
|
---|
1961 | xval[nsamples] = previousValue+1;
|
---|
1962 | yval[nsamples] = 0;
|
---|
1963 | nsamples++;
|
---|
1964 | xval[nsamples] = it->first-1;
|
---|
1965 | yval[nsamples] = 0;
|
---|
1966 | nsamples++;
|
---|
1967 | }
|
---|
1968 | xval[nsamples] = it->first;
|
---|
1969 | yval[nsamples] = it->second;
|
---|
1970 | previousValue = it->first;
|
---|
1971 | it++;
|
---|
1972 | nsamples++;
|
---|
1973 | xval[nsamples] = previousValue;
|
---|
1974 | yval[nsamples] = 0;
|
---|
1975 | nsamples++;
|
---|
1976 | if (nsamples > 50000)
|
---|
1977 | {
|
---|
1978 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1979 | break;
|
---|
1980 | }
|
---|
1981 | }
|
---|
1982 | xval[nsamples] = it==valuesHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1983 | yval[nsamples] = 0;
|
---|
1984 | nsamples++;
|
---|
1985 | // if (nsamples > 5)
|
---|
1986 | #if QWT_VERSION < 0x060000
|
---|
1987 | triggerDelayHistoItem.setData(xval, yval, nsamples);
|
---|
1988 | #else
|
---|
1989 | triggerDelayHistoItem.setSamples(xval, yval, nsamples);
|
---|
1990 | #endif
|
---|
1991 |
|
---|
1992 | it = waveletHistoMap.begin();
|
---|
1993 | nsamples = 0;
|
---|
1994 | previousValue = it->first-10;
|
---|
1995 | cout << "Num values WaveLets: " << waveletHistoMap.size() << endl;
|
---|
1996 | for (unsigned int i=0;i<waveletHistoMap.size();i++)
|
---|
1997 | {
|
---|
1998 | if (previousValue != it->first-1)
|
---|
1999 | {
|
---|
2000 | xval[nsamples] = previousValue+1;
|
---|
2001 | yval[nsamples] = 0;
|
---|
2002 | nsamples++;
|
---|
2003 | xval[nsamples] = it->first-1;
|
---|
2004 | yval[nsamples] = 0;
|
---|
2005 | nsamples++;
|
---|
2006 | }
|
---|
2007 | xval[nsamples] = it->first;
|
---|
2008 | yval[nsamples] = it->second;
|
---|
2009 | previousValue = it->first;
|
---|
2010 | it++;
|
---|
2011 | nsamples++;
|
---|
2012 | xval[nsamples] = previousValue;
|
---|
2013 | yval[nsamples] = 0;
|
---|
2014 | nsamples++;
|
---|
2015 | if (nsamples > 50000)
|
---|
2016 | {
|
---|
2017 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
2018 | break;
|
---|
2019 | }
|
---|
2020 | }
|
---|
2021 | xval[nsamples] = it==waveletHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
2022 | yval[nsamples] = 0;
|
---|
2023 | nsamples++;
|
---|
2024 | // if (nsamples > 5)
|
---|
2025 | #if QWT_VERSION < 0x060000
|
---|
2026 | startTimeMarkHistoItem.setData(xval, yval, nsamples);
|
---|
2027 | #else
|
---|
2028 | startTimeMarkHistoItem.setSamples(xval, yval, nsamples);
|
---|
2029 | #endif
|
---|
2030 | */
|
---|
2031 | //END OF WAVELETS HACK
|
---|
2032 | // startCellHistoZoom->setZoomBase(startCellHistoItem.boundingRect());
|
---|
2033 | QStack< QRectF > stack;
|
---|
2034 | // QRectF cRectangle = boardsTimeHistoItem.boundingRect();
|
---|
2035 | stack.push(scaleBoundingRectangle(boardsTimeHistoItem.boundingRect(), 1.05f));//cRectangle);//boardsTimeHistoItem.boundingRect());
|
---|
2036 | boardsTimeHistoZoom->setZoomStack(stack);
|
---|
2037 | stack.pop();
|
---|
2038 | stack.push(scaleBoundingRectangle(startCellHistoItem.boundingRect(), 1.05f));
|
---|
2039 | startCellHistoZoom->setZoomStack(stack);
|
---|
2040 | stack.pop();
|
---|
2041 | stack.push(scaleBoundingRectangle(startTimeMarkHistoItem.boundingRect(), 1.05f));
|
---|
2042 | startTimeMarkHistoZoom->setZoomStack(stack);
|
---|
2043 | stack.pop();
|
---|
2044 | stack.push(scaleBoundingRectangle(triggerDelayHistoItem.boundingRect(), 1.05f));
|
---|
2045 | triggerDelayHistoZoom->setZoomStack(stack);
|
---|
2046 | stack.pop();
|
---|
2047 | pixelChanged(viewer->selectedPixel);
|
---|
2048 | }
|
---|
2049 | //can't use a ref to rectangle, as the type must be converted first
|
---|
2050 | QRectF UIConnector::scaleBoundingRectangle(QRectF rectangle, float scale)
|
---|
2051 | {
|
---|
2052 | QPointF bottomRight = rectangle.bottomRight();
|
---|
2053 | QPointF topLeft = rectangle.topLeft();
|
---|
2054 | QPointF center = rectangle.center();
|
---|
2055 | return QRectF(topLeft + (topLeft-center)*(scale-1.0f), //top left
|
---|
2056 | bottomRight + (bottomRight-center)*(scale-1.0f)); //bottom right
|
---|
2057 | }
|
---|
2058 | void UIConnector::initHistograms()
|
---|
2059 | {
|
---|
2060 | // QwtPlot* boardsTimeHisto;
|
---|
2061 | // QwtPlotHistogram boardsTimeHistoItem;
|
---|
2062 | QwtPlotGrid* grid = new QwtPlotGrid;
|
---|
2063 | grid->enableX(false);
|
---|
2064 | grid->enableY(true);
|
---|
2065 | grid->enableXMin(false);
|
---|
2066 | grid->enableYMin(false);
|
---|
2067 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
2068 | grid->attach(boardsTimeHisto);
|
---|
2069 |
|
---|
2070 | grid = new QwtPlotGrid;
|
---|
2071 | grid->enableX(false);
|
---|
2072 | grid->enableY(true);
|
---|
2073 | grid->enableXMin(false);
|
---|
2074 | grid->enableYMin(false);
|
---|
2075 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
2076 | grid->attach(startCellHisto);
|
---|
2077 |
|
---|
2078 | grid = new QwtPlotGrid;
|
---|
2079 | grid->enableX(false);
|
---|
2080 | grid->enableY(true);
|
---|
2081 | grid->enableXMin(false);
|
---|
2082 | grid->enableYMin(false);
|
---|
2083 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
2084 | grid->attach(startTimeMarkHisto);
|
---|
2085 |
|
---|
2086 | grid = new QwtPlotGrid;
|
---|
2087 | grid->enableX(false);
|
---|
2088 | grid->enableY(true);
|
---|
2089 | grid->enableXMin(false);
|
---|
2090 | grid->enableYMin(false);
|
---|
2091 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
2092 | grid->attach(pixelValueCurve);
|
---|
2093 |
|
---|
2094 | grid = new QwtPlotGrid;
|
---|
2095 | grid->enableX(false);
|
---|
2096 | grid->enableY(true);
|
---|
2097 | grid->enableXMin(false);
|
---|
2098 | grid->enableYMin(false);
|
---|
2099 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
2100 | grid->attach(triggerDelayHisto);
|
---|
2101 |
|
---|
2102 |
|
---|
2103 | boardsTimeHisto->setAutoReplot(true);
|
---|
2104 | startCellHisto->setAutoReplot(true);
|
---|
2105 | startTimeMarkHisto->setAutoReplot(true);
|
---|
2106 | pixelValueCurve->setAutoReplot(true);
|
---|
2107 | triggerDelayHisto->setAutoReplot(true);
|
---|
2108 | boardsTimeHisto->setTitle("Boards time values");
|
---|
2109 | startCellHisto->setTitle("Start Cell values");
|
---|
2110 | startTimeMarkHisto->setTitle("Start Time Marks values");
|
---|
2111 | pixelValueCurve->setTitle("Current pixel values");
|
---|
2112 | triggerDelayHisto->setTitle("Trigger Delays");
|
---|
2113 |
|
---|
2114 | // boardsTimeHistoItem.setBrush(QBrush(Qt::red));
|
---|
2115 | // startCellHistoItem.setBrush(QBrush(Qt::red));
|
---|
2116 | // startTimeMarkHistoItem.setBrush(QBrush(Qt::red));
|
---|
2117 | // triggerDelayHistoItem.setBrush(QBrush(Qt::red));
|
---|
2118 | // pixelValueCurveItem.setBrush(QBrush(Qt::red));
|
---|
2119 |
|
---|
2120 | boardsTimeHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
2121 | boardsTimeHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
2122 | startCellHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
2123 | startCellHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
2124 | startTimeMarkHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
2125 | startTimeMarkHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
2126 | triggerDelayHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
2127 | triggerDelayHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
2128 |
|
---|
2129 | boardsTimeHistoItem.attach(boardsTimeHisto);
|
---|
2130 | startCellHistoItem.attach(startCellHisto);
|
---|
2131 | startTimeMarkHistoItem.attach(startTimeMarkHisto);
|
---|
2132 | triggerDelayHistoItem.attach(triggerDelayHisto);
|
---|
2133 |
|
---|
2134 | //curve
|
---|
2135 | // pixelValueCurveItem.setSymbol(new QwtSymbol(QwtSymbol::Cross, Qt::NoBrush, QPen(Qt::black), QSize(5,5)));
|
---|
2136 | pixelValueCurveItem.setPen(QColor(Qt::black));
|
---|
2137 | aMeanCurveItem.setPen(QColor(Qt::darkGreen));
|
---|
2138 | vCorrCurveItem.setPen(QColor(Qt::red));
|
---|
2139 | meanCurveItem.setPen(QColor(Qt::blue));
|
---|
2140 | pixelValueCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
2141 | aMeanCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
2142 | vCorrCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
2143 | meanCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
2144 |
|
---|
2145 | // pixelValueCurveItem.setCurveAttribute(QwtPlotCurve::Fitted);
|
---|
2146 | pixelValueCurveItem.attach(pixelValueCurve);
|
---|
2147 | // aMeanCurveItem.attach(pixelValueCurve);
|
---|
2148 | // vCorrCurveItem.attach(pixelValueCurve);
|
---|
2149 | // meanCurveItem.attach(pixelValueCurve);
|
---|
2150 |
|
---|
2151 | //FIXME delete these pointers with the destructor
|
---|
2152 | curveZoom = new QwtPlotZoomer(pixelValueCurve->canvas());
|
---|
2153 | curveZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
2154 | curveZoom->setTrackerPen(QPen(Qt::gray));
|
---|
2155 | boardsTimeHistoZoom = new QwtPlotZoomer(boardsTimeHisto->canvas());
|
---|
2156 | boardsTimeHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
2157 | boardsTimeHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
2158 | startCellHistoZoom = new QwtPlotZoomer(startCellHisto->canvas());
|
---|
2159 | startCellHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
2160 | startCellHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
2161 | startTimeMarkHistoZoom = new QwtPlotZoomer(startTimeMarkHisto->canvas());
|
---|
2162 | startTimeMarkHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
2163 | startTimeMarkHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
2164 | triggerDelayHistoZoom = new QwtPlotZoomer(triggerDelayHisto->canvas());
|
---|
2165 | triggerDelayHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
2166 | triggerDelayHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
2167 |
|
---|
2168 |
|
---|
2169 | }
|
---|
2170 | void UIConnector::pixelChanged(int pixel)
|
---|
2171 | {
|
---|
2172 | if (!viewer->nRoi)
|
---|
2173 | return;
|
---|
2174 |
|
---|
2175 | if (hwID == pixel)
|
---|
2176 | return;
|
---|
2177 | for (int i=0;i<viewer->nRoi;i++)
|
---|
2178 | {
|
---|
2179 | xval[i] = i;
|
---|
2180 | #ifdef LOAD_RAW
|
---|
2181 | yval[i] = eventsData[0][pixel][i];
|
---|
2182 | #else
|
---|
2183 | yval[i] = viewer->eventData[viewer->nRoi*pixel + i];
|
---|
2184 | #endif
|
---|
2185 | }
|
---|
2186 |
|
---|
2187 | // viewer->computePulsesStatistics();
|
---|
2188 | #if QWT_VERSION < 0x060000
|
---|
2189 | pixelValueCurveItem.setData(xval, yval, viewer->nRoi);
|
---|
2190 | //// aMeanCurveItem.setData(xval, viewer->aMeas, viewer->nRoi);
|
---|
2191 | // meanCurveItem.setData(xval, viewer->n1mean, viewer->nRoi);
|
---|
2192 | // vCorrCurveItem.setData(xval, viewer->vCorr, viewer->nRoi-3);
|
---|
2193 | #else
|
---|
2194 | pixelValueCurveItem.setSamples(xval, yval, viewer->nRoi);
|
---|
2195 | // aMeanCurveItem.setSamples(xval, viewer->aMeas, viewer->nRoi);
|
---|
2196 | // meanCurveItem.setSamples(xval, viewer->n1mean, viewer->nRoi);
|
---|
2197 | // vCorrCurveItem.setSamples(xval, viewer->vCorr, viewer->nRoi-3);
|
---|
2198 | #endif
|
---|
2199 |
|
---|
2200 |
|
---|
2201 | QStack< QRectF > stack;
|
---|
2202 | stack.push(scaleBoundingRectangle(pixelValueCurveItem.boundingRect(), 1.5f));
|
---|
2203 | curveZoom->setZoomStack(stack);
|
---|
2204 | stack.pop();
|
---|
2205 |
|
---|
2206 | hwID = pixel;
|
---|
2207 | swID = viewer->softwareMapping[pixel];
|
---|
2208 | crateID = pixel/360;
|
---|
2209 | boardID = (pixel - crateID*360)/36;
|
---|
2210 | patchID = (pixel - crateID*360 - boardID*36)/9;
|
---|
2211 |
|
---|
2212 | if (HwIDBox->value() != hwID)
|
---|
2213 | HwIDBox->setValue(hwID);
|
---|
2214 | if (SwIDBox->value() != swID)
|
---|
2215 | SwIDBox->setValue(swID);
|
---|
2216 | if (crateIDBox->value() != crateID)
|
---|
2217 | crateIDBox->setValue(crateID);
|
---|
2218 | if (boardIDBox->value() != boardID)
|
---|
2219 | boardIDBox->setValue(boardID);
|
---|
2220 | if (patchIDBox->value() != patchID)
|
---|
2221 | patchIDBox->setValue(patchID);
|
---|
2222 |
|
---|
2223 | ostringstream str;
|
---|
2224 | QString qstr;
|
---|
2225 | str.str("");
|
---|
2226 | str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
|
---|
2227 | qstr = qstr.fromStdString(str.str());
|
---|
2228 | emit updateCurrentPixelSliceValue(qstr);
|
---|
2229 | autoScalePressed();
|
---|
2230 |
|
---|
2231 | }
|
---|
2232 |
|
---|
2233 | void UIConnector::hwIDChanged(int hwid)
|
---|
2234 | {
|
---|
2235 | hwID = hwid;
|
---|
2236 | swID = viewer->softwareMapping[hwid];
|
---|
2237 | crateID = hwID/360;
|
---|
2238 | boardID = (hwID - crateID*360)/36;
|
---|
2239 | patchID = (hwID - crateID*360 - boardID*36)/9;
|
---|
2240 |
|
---|
2241 | // crateID = (hwid/4)/10;
|
---|
2242 | // boardID = (hwid/4)%10;
|
---|
2243 | // patchID = hwid%4;
|
---|
2244 | HwIDBox->setValue(hwID);
|
---|
2245 | SwIDBox->setValue(swID);
|
---|
2246 | crateIDBox->setValue(crateID);
|
---|
2247 | boardIDBox->setValue(boardID);
|
---|
2248 | patchIDBox->setValue(patchID);
|
---|
2249 |
|
---|
2250 | viewer->selectedPixel = hwid;
|
---|
2251 | pixelChanged(hwid);
|
---|
2252 | viewer->updateGL();
|
---|
2253 |
|
---|
2254 | }
|
---|
2255 | void UIConnector::swIDChanged(int swid)
|
---|
2256 | {
|
---|
2257 | swID = swid;
|
---|
2258 | hwID = viewer->hardwareMapping[swid];
|
---|
2259 | crateID = hwID/360;
|
---|
2260 | boardID = (hwID - crateID*360)/36;
|
---|
2261 | patchID = (hwID - crateID*360 - boardID*36)/9;
|
---|
2262 |
|
---|
2263 | // crateID = (hwID/4)/10;
|
---|
2264 | // boardID = (hwID/4)%10;
|
---|
2265 | // patchID = hwID%4;
|
---|
2266 | HwIDBox->setValue(hwID);
|
---|
2267 | SwIDBox->setValue(swID);
|
---|
2268 | crateIDBox->setValue(crateID);
|
---|
2269 | boardIDBox->setValue(boardID);
|
---|
2270 | patchIDBox->setValue(patchID);
|
---|
2271 |
|
---|
2272 | viewer->selectedPixel = hwID;
|
---|
2273 | pixelChanged(hwID);
|
---|
2274 | viewer->updateGL();
|
---|
2275 | }
|
---|
2276 | void UIConnector::crateIDChanged(int cid)
|
---|
2277 | {
|
---|
2278 | hwID -= 360*crateID;
|
---|
2279 | crateID = cid;
|
---|
2280 | hwID += 360*crateID;
|
---|
2281 | swID = viewer->softwareMapping[hwID];
|
---|
2282 | HwIDBox->setValue(hwID);
|
---|
2283 | SwIDBox->setValue(swID);
|
---|
2284 | viewer->selectedPixel = hwID;
|
---|
2285 | pixelChanged(hwID);
|
---|
2286 | viewer->updateGL();
|
---|
2287 | }
|
---|
2288 | void UIConnector::boardIDChanged(int bid)
|
---|
2289 | {
|
---|
2290 | hwID -= 36*boardID;
|
---|
2291 | boardID = bid;
|
---|
2292 | hwID += 36*boardID;
|
---|
2293 | swID = viewer->softwareMapping[hwID];
|
---|
2294 | HwIDBox->setValue(hwID);
|
---|
2295 | SwIDBox->setValue(swID);
|
---|
2296 | viewer->selectedPixel = hwID;
|
---|
2297 | pixelChanged(hwID);
|
---|
2298 | viewer->updateGL();
|
---|
2299 | }
|
---|
2300 | void UIConnector::patchIDChanged(int pid)
|
---|
2301 | {
|
---|
2302 | hwID -= 9*patchID;
|
---|
2303 | patchID = pid;
|
---|
2304 | hwID += 9*patchID;
|
---|
2305 | swID = viewer->softwareMapping[hwID];
|
---|
2306 | HwIDBox->setValue(hwID);
|
---|
2307 | SwIDBox->setValue(swID);
|
---|
2308 | viewer->selectedPixel = hwID;
|
---|
2309 | pixelChanged(hwID);
|
---|
2310 | viewer->updateGL();
|
---|
2311 | }
|
---|
2312 | void UIConnector::autoScalePressed()
|
---|
2313 | {
|
---|
2314 | if (!autoScaleColor->isChecked())
|
---|
2315 | {
|
---|
2316 | viewer->ss[0] = 0;
|
---|
2317 | viewer->ss[1] = 0.25;
|
---|
2318 | viewer->ss[2] = 0.5;
|
---|
2319 | viewer->ss[3] = 0.75;
|
---|
2320 | viewer->ss[4] = 1;
|
---|
2321 | range0->setValue(viewer->ss[0]);
|
---|
2322 | range1->setValue(viewer->ss[1]);
|
---|
2323 | range2->setValue(viewer->ss[2]);
|
---|
2324 | range3->setValue(viewer->ss[3]);
|
---|
2325 | range4->setValue(viewer->ss[4]);
|
---|
2326 | return;
|
---|
2327 | }
|
---|
2328 | if (!viewer->nRoi)
|
---|
2329 | return;
|
---|
2330 | int start, end;
|
---|
2331 | if (rescaleWholeCamera)
|
---|
2332 | {
|
---|
2333 | start = 0;
|
---|
2334 | end = 1440;
|
---|
2335 | }
|
---|
2336 | else
|
---|
2337 | {
|
---|
2338 | start = viewer->selectedPixel;
|
---|
2339 | end = viewer->selectedPixel+1;
|
---|
2340 | }
|
---|
2341 |
|
---|
2342 | int min = 100000; //real min = -2048, int_16 = -32768 to 32767
|
---|
2343 | int max = -100000; //real max = 2047
|
---|
2344 | long average = 0;
|
---|
2345 | long numSamples = 0;
|
---|
2346 | int errorDetected = -1;
|
---|
2347 | for (int i=start;i<end;i++)
|
---|
2348 | {
|
---|
2349 | for (int j=0;j<viewer->nRoi;j++)
|
---|
2350 | {
|
---|
2351 | int cValue = viewer->eventData[i*viewer->nRoi+j];
|
---|
2352 | if (cValue > max && cValue < 32767)
|
---|
2353 | max = cValue;
|
---|
2354 | if (cValue < min && cValue > -32768)
|
---|
2355 | min = cValue;
|
---|
2356 | if (cValue < 32767 && cValue > -32768)
|
---|
2357 | {
|
---|
2358 | average+=cValue;
|
---|
2359 | numSamples++;
|
---|
2360 | }
|
---|
2361 | else
|
---|
2362 | {
|
---|
2363 | errorDetected = i;
|
---|
2364 | }
|
---|
2365 | // numSamples++;
|
---|
2366 | }
|
---|
2367 | }
|
---|
2368 | average /= numSamples;
|
---|
2369 | if (errorDetected != -1)
|
---|
2370 | {
|
---|
2371 | cout << "Overflow detected at pixel " << errorDetected << " (at least)" << endl;
|
---|
2372 | }
|
---|
2373 | // cout << "min: " << min << " max: " << max << " average: " << average << endl;
|
---|
2374 | double minRange = (double)(min+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
2375 | double maxRange = (double)(max+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
2376 | double midRange = (double)(average+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
2377 | if (viewer->logScale)
|
---|
2378 | {
|
---|
2379 | minRange *= 9;
|
---|
2380 | maxRange *= 9;
|
---|
2381 | // midRange *= 9;
|
---|
2382 | minRange += 1;
|
---|
2383 | maxRange += 1;
|
---|
2384 | // midRange += 1;
|
---|
2385 | minRange = log10(minRange);
|
---|
2386 | maxRange = log10(maxRange);
|
---|
2387 | // midRange = (minRange + maxRange)/2.f;
|
---|
2388 | midRange = log10(midRange);
|
---|
2389 | }
|
---|
2390 | viewer->ss[0] = minRange;
|
---|
2391 | range0->setValue(viewer->ss[0]);
|
---|
2392 | viewer->ss[4] = maxRange;
|
---|
2393 | range4->setValue(viewer->ss[4]);
|
---|
2394 | viewer->ss[2] = midRange;
|
---|
2395 | range2->setValue(viewer->ss[2]);
|
---|
2396 | viewer->ss[1] = (minRange+midRange)/2;
|
---|
2397 | range1->setValue(viewer->ss[1]);
|
---|
2398 | viewer->ss[3] = (maxRange+midRange)/2;
|
---|
2399 | range3->setValue(viewer->ss[3]);
|
---|
2400 |
|
---|
2401 |
|
---|
2402 | }
|
---|
2403 | void UIConnector::entireCameraChanged(bool state)
|
---|
2404 | {
|
---|
2405 | if (state)
|
---|
2406 | {
|
---|
2407 | rescaleWholeCamera = true;
|
---|
2408 | currentPixelScale->setChecked(false);
|
---|
2409 | }
|
---|
2410 | else
|
---|
2411 | {
|
---|
2412 | rescaleWholeCamera = false;
|
---|
2413 | currentPixelScale->setChecked(true);
|
---|
2414 | }
|
---|
2415 | autoScalePressed();
|
---|
2416 | }
|
---|
2417 | void UIConnector::currentPixelChanged(bool state)
|
---|
2418 | {
|
---|
2419 |
|
---|
2420 | if (state)
|
---|
2421 | {
|
---|
2422 | rescaleWholeCamera = false;
|
---|
2423 | entireCameraScale->setChecked(false);
|
---|
2424 | }
|
---|
2425 | else
|
---|
2426 | {
|
---|
2427 | rescaleWholeCamera = true;
|
---|
2428 | entireCameraScale->setChecked(true);
|
---|
2429 | }
|
---|
2430 | autoScalePressed();
|
---|
2431 | }
|
---|
2432 |
|
---|
2433 |
|
---|
2434 |
|
---|
2435 | void PrintHelp()
|
---|
2436 | {
|
---|
2437 | cout <<
|
---|
2438 | "\n"
|
---|
2439 | << endl;
|
---|
2440 | }
|
---|
2441 | void SetupConfiguration(Configuration& conf)
|
---|
2442 | {
|
---|
2443 | po::options_description configs("Raw Events Viewer Options");
|
---|
2444 | configs.add_options()
|
---|
2445 | ("color.range", vars<double>(), "Range of the display colours")
|
---|
2446 | ("color.red", vars<double>(), "Range of red values")
|
---|
2447 | ("color.green", vars<double>(), "Range of green values")
|
---|
2448 | ("color.blue", vars<double>(), "Range of blue values")
|
---|
2449 | ("file,f", var<string>(), "File to be loaded at startup")
|
---|
2450 | ;
|
---|
2451 | conf.AddOptions(configs);
|
---|
2452 |
|
---|
2453 | po::positional_options_description p;
|
---|
2454 | p.add("file", 1); // The first positional options
|
---|
2455 | conf.SetArgumentPositions(p);
|
---|
2456 |
|
---|
2457 | }
|
---|
2458 | /************************************************************
|
---|
2459 | * MAIN PROGRAM FUNCTION.
|
---|
2460 | ************************************************************/
|
---|
2461 | int main(int argc, char *argv[])
|
---|
2462 | {
|
---|
2463 | QApplication app(argc, argv);
|
---|
2464 |
|
---|
2465 | if (!QGLFormat::hasOpenGL()) {
|
---|
2466 | std::cerr << "This system has no OpenGL support" << std::endl;
|
---|
2467 | return 1;
|
---|
2468 | }
|
---|
2469 |
|
---|
2470 | QMainWindow mainWindow;
|
---|
2471 |
|
---|
2472 | Ui_MainWindow myUi;
|
---|
2473 | myUi.setupUi(&mainWindow);
|
---|
2474 |
|
---|
2475 | UIConnector connector;
|
---|
2476 |
|
---|
2477 | RawDataViewer *canvas = myUi.GLWindow;
|
---|
2478 |
|
---|
2479 | Configuration conf(argv[0]);
|
---|
2480 | conf.SetPrintUsage(PrintHelp);
|
---|
2481 | SetupConfiguration(conf);
|
---|
2482 | if (!conf.DoParse(argc, const_cast<const char**>(argv), PrintHelp))
|
---|
2483 | return -1;
|
---|
2484 |
|
---|
2485 | if (conf.Has("color.range"))
|
---|
2486 | {
|
---|
2487 | vector<double> value = conf.Vec<double>("color.range");
|
---|
2488 | if (value.size() != 5)
|
---|
2489 | {
|
---|
2490 | cout << "Error, colorRange option should have exactly 5 double values" << endl;
|
---|
2491 | return -1;
|
---|
2492 | }
|
---|
2493 | for (int i=0;i<5;i++)
|
---|
2494 | canvas->ss[i] = value[i];
|
---|
2495 | }
|
---|
2496 |
|
---|
2497 | if (conf.Has("color.red"))
|
---|
2498 | {
|
---|
2499 | vector<double> value = conf.Vec<double>("color.red");
|
---|
2500 | if (value.size() != 5)
|
---|
2501 | {
|
---|
2502 | cout << "Error, colorRed option should have exactly 5 double values" << endl;
|
---|
2503 | return -1;
|
---|
2504 | }
|
---|
2505 | for (int i=0;i<5;i++)
|
---|
2506 | canvas->rr[i] = value[i];
|
---|
2507 | }
|
---|
2508 |
|
---|
2509 | if (conf.Has("color.green"))
|
---|
2510 | {
|
---|
2511 | vector<double> value = conf.Vec<double>("color.green");
|
---|
2512 | if (value.size() != 5)
|
---|
2513 | {
|
---|
2514 | cout << "Error, colorGreen option should have exactly 5 double values" << endl;
|
---|
2515 | return -1;
|
---|
2516 | }
|
---|
2517 | for (int i=0;i<5;i++)
|
---|
2518 | canvas->gg[i] = value[i];
|
---|
2519 | }
|
---|
2520 |
|
---|
2521 | if (conf.Has("color.blue"))
|
---|
2522 | {
|
---|
2523 | vector<double> value = conf.Vec<double>("color.blue");
|
---|
2524 | if (value.size() != 5)
|
---|
2525 | {
|
---|
2526 | cout << "Error, colorBlue option should have exactly 5 double values" << endl;
|
---|
2527 | return -1;
|
---|
2528 | }
|
---|
2529 | for (int i=0;i<5;i++)
|
---|
2530 | canvas->bb[i] = value[i];
|
---|
2531 | }
|
---|
2532 |
|
---|
2533 |
|
---|
2534 |
|
---|
2535 | // QObject::connect(myUi.eventsMinusButton, SIGNAL(clicked()),
|
---|
2536 | // canvas, SLOT(minusEvent()));
|
---|
2537 | // QObject::connect(myUi.eventsPlusButton, SIGNAL(clicked()),
|
---|
2538 | // canvas, SLOT(plusEvent()));
|
---|
2539 | // QObject::connect(myUi.eventsStepBox, SIGNAL(valueChanged(int)),
|
---|
2540 | // canvas, SLOT(setEventStep(int)));
|
---|
2541 |
|
---|
2542 | myUi.colorRange0->setValue(canvas->ss[0]);
|
---|
2543 | myUi.colorRange1->setValue(canvas->ss[1]);
|
---|
2544 | myUi.colorRange2->setValue(canvas->ss[2]);
|
---|
2545 | myUi.colorRange3->setValue(canvas->ss[3]);
|
---|
2546 | myUi.colorRange4->setValue(canvas->ss[4]);
|
---|
2547 | myUi.redValue0->setValue(canvas->rr[0]);
|
---|
2548 | myUi.redValue1->setValue(canvas->rr[1]);
|
---|
2549 | myUi.redValue2->setValue(canvas->rr[2]);
|
---|
2550 | myUi.redValue3->setValue(canvas->rr[3]);
|
---|
2551 | myUi.redValue4->setValue(canvas->rr[4]);
|
---|
2552 | myUi.greenValue0->setValue(canvas->gg[0]);
|
---|
2553 | myUi.greenValue1->setValue(canvas->gg[1]);
|
---|
2554 | myUi.greenValue2->setValue(canvas->gg[2]);
|
---|
2555 | myUi.greenValue3->setValue(canvas->gg[3]);
|
---|
2556 | myUi.greenValue4->setValue(canvas->gg[4]);
|
---|
2557 | myUi.blueValue0->setValue(canvas->bb[0]);
|
---|
2558 | myUi.blueValue1->setValue(canvas->bb[1]);
|
---|
2559 | myUi.blueValue2->setValue(canvas->bb[2]);
|
---|
2560 | myUi.blueValue3->setValue(canvas->bb[3]);
|
---|
2561 | myUi.blueValue4->setValue(canvas->bb[4]);
|
---|
2562 |
|
---|
2563 | connector.setViewer(canvas);
|
---|
2564 | connector.boardsTimeList = myUi.boardsTimeList;
|
---|
2565 | connector.boardsTimeHisto = myUi.boardsTimeHisto;
|
---|
2566 | connector.startPixelsList = myUi.startPixelsList;
|
---|
2567 | connector.startCellHisto = myUi.startCellsHisto;
|
---|
2568 | connector.startTimeMarkHisto = myUi.startTimeMarkHisto;
|
---|
2569 | connector.pixelValueCurve = myUi.pixelValueCurve;
|
---|
2570 | connector.triggerDelayHisto = myUi.triggerDelayHisto;
|
---|
2571 | connector.triggerDelayList = myUi.triggerDelayList;
|
---|
2572 | connector.autoScaleColor = myUi.autoScaleColor;
|
---|
2573 |
|
---|
2574 | connector.startTimeMarksList = myUi.startTimeMarksList;
|
---|
2575 | // connector.fileLoadedLabel = myUi.fileLoadedLabel;
|
---|
2576 | // connector.runNumberLabel = myUi.runNumberLabel;
|
---|
2577 | // connector.numberOfSlicesLabel = myUi.numberOfSlicesLabel;
|
---|
2578 | // connector.numberOfTimeMarksLabel = myUi.numberOfTimeMarksLabel;
|
---|
2579 | // connector.runTypeLabel = myUi.runTypeLabel;
|
---|
2580 | // connector.firstTimeLabel = myUi.timeOfFirstDataLabel;
|
---|
2581 | // connector.lastTimeLabel = myUi.timeOfLastDataLabel;
|
---|
2582 | connector.currentPixelValue = myUi.currentPixelValue;
|
---|
2583 |
|
---|
2584 | connector.currentPixelScale = myUi.currentPixelScale;
|
---|
2585 | connector.entireCameraScale = myUi.entireCameraScale;
|
---|
2586 | connector.playEventsRadio = myUi.playEventsRadio;
|
---|
2587 |
|
---|
2588 | connector.extraInfoLabel = myUi.extraInfoLabel;
|
---|
2589 |
|
---|
2590 | connector.HwIDBox = myUi.HwIDBox;
|
---|
2591 | connector.SwIDBox = myUi.SwIDBox;
|
---|
2592 | connector.crateIDBox = myUi.crateIDBox;
|
---|
2593 | connector.boardIDBox = myUi.boardIDBox;
|
---|
2594 | connector.patchIDBox = myUi.patchIDBox;
|
---|
2595 |
|
---|
2596 | connector.eventNumberBox = myUi.displayingEventBox;
|
---|
2597 |
|
---|
2598 | connector.range0 = myUi.colorRange0;
|
---|
2599 | connector.range1 = myUi.colorRange1;
|
---|
2600 | connector.range2 = myUi.colorRange2;
|
---|
2601 | connector.range3 = myUi.colorRange3;
|
---|
2602 | connector.range4 = myUi.colorRange4;
|
---|
2603 | connector.drawCalibrationCheckBox = myUi.calibratedCheckBox;
|
---|
2604 | connector.drawCalibrationCheckBox->setEnabled(false);
|
---|
2605 |
|
---|
2606 | connector.initHistograms();
|
---|
2607 |
|
---|
2608 | QButtonGroup scaleGroup(canvas);// = new QButtonGroup(canvas);
|
---|
2609 | QButtonGroup animateGroup(canvas);// = new QButtonGroup(canvas);
|
---|
2610 | scaleGroup.addButton(myUi.currentPixelScale);
|
---|
2611 | scaleGroup.addButton(myUi.entireCameraScale);
|
---|
2612 | animateGroup.addButton(myUi.playEventsRadio);
|
---|
2613 | animateGroup.addButton(myUi.playSlicesRadio);
|
---|
2614 | myUi.entireCameraScale->setChecked(true);
|
---|
2615 | // QObject::connect(myUi.slicesPlusPlusButton, SIGNAL(clicked()),
|
---|
2616 | // &connector, SLOT(slicesPlusPlus()));
|
---|
2617 | // QObject::connect(myUi.slicesMinusMinusButton, SIGNAL(clicked()),
|
---|
2618 | // &connector, SLOT(slicesMinusMinus()));
|
---|
2619 |
|
---|
2620 | QObject::connect(myUi.autoScaleColor, SIGNAL(clicked()),
|
---|
2621 | &connector, SLOT(autoScalePressed()));
|
---|
2622 | QObject::connect(canvas, SIGNAL(colorPaletteHasChanged()),
|
---|
2623 | &connector, SLOT(autoScalePressed()));
|
---|
2624 |
|
---|
2625 | QObject::connect(myUi.currentPixelScale, SIGNAL(toggled(bool)),
|
---|
2626 | &connector, SLOT(currentPixelChanged(bool)));
|
---|
2627 | QObject::connect(myUi.entireCameraScale, SIGNAL(toggled(bool)),
|
---|
2628 | &connector, SLOT(entireCameraChanged(bool)));
|
---|
2629 |
|
---|
2630 | QObject::connect(myUi.HwIDBox, SIGNAL(valueChanged(int)),
|
---|
2631 | &connector, SLOT(hwIDChanged(int)));
|
---|
2632 | QObject::connect(myUi.SwIDBox, SIGNAL(valueChanged(int)),
|
---|
2633 | &connector, SLOT(swIDChanged(int)));
|
---|
2634 | QObject::connect(myUi.crateIDBox, SIGNAL(valueChanged(int)),
|
---|
2635 | &connector, SLOT(crateIDChanged(int)));
|
---|
2636 | QObject::connect(myUi.boardIDBox, SIGNAL(valueChanged(int)),
|
---|
2637 | &connector, SLOT(boardIDChanged(int)));
|
---|
2638 | QObject::connect(myUi.patchIDBox, SIGNAL(valueChanged(int)),
|
---|
2639 | &connector, SLOT(patchIDChanged(int)));
|
---|
2640 |
|
---|
2641 | // connector.pixelChanged(0);
|
---|
2642 | QObject::connect(canvas, SIGNAL(signalCurrentPixel(int)),
|
---|
2643 | &connector, SLOT(pixelChanged(int)));
|
---|
2644 | QObject::connect(myUi.drawPatchCheckBox, SIGNAL(stateChanged(int)),
|
---|
2645 | &connector, SLOT(drawPatchesCheckChange(int)));
|
---|
2646 | QObject::connect(myUi.drawImpulseCheckBox, SIGNAL(stateChanged(int)),
|
---|
2647 | &connector, SLOT(drawImpulseCheckChange(int)));
|
---|
2648 | QObject::connect(myUi.drawBlurCheckBox, SIGNAL(stateChanged(int)),
|
---|
2649 | &connector, SLOT(drawBlurCheckChange(int)));
|
---|
2650 | QObject::connect(myUi.loopOverCurrentEventBox, SIGNAL(stateChanged(int)),
|
---|
2651 | &connector, SLOT(loopEventCheckChange(int)));
|
---|
2652 | QObject::connect(canvas, SIGNAL(newFileLoaded()),
|
---|
2653 | &connector, SLOT(newFileLoaded()));
|
---|
2654 |
|
---|
2655 | QObject::connect(myUi.calibratedCheckBox, SIGNAL(stateChanged(int)),
|
---|
2656 | &connector, SLOT(drawCalibratedDataChanged(int)));
|
---|
2657 | QObject::connect(myUi.loadNewFileButton, SIGNAL(clicked()),
|
---|
2658 | &connector, SLOT(loadNewFileClicked()));
|
---|
2659 | QObject::connect(myUi.loadDRSCalibButton, SIGNAL(clicked()),
|
---|
2660 | &connector, SLOT(loadNewCalibFileClicked()));
|
---|
2661 |
|
---|
2662 | QObject::connect(myUi.colorRange0, SIGNAL(valueChanged(double)),
|
---|
2663 | &connector, SLOT(rangeChanged0(double)));
|
---|
2664 |
|
---|
2665 | QObject::connect(myUi.colorRange1, SIGNAL(valueChanged(double)),
|
---|
2666 | &connector, SLOT(rangeChanged1(double)));
|
---|
2667 |
|
---|
2668 | QObject::connect(myUi.colorRange2, SIGNAL(valueChanged(double)),
|
---|
2669 | &connector, SLOT(rangeChanged2(double)));
|
---|
2670 |
|
---|
2671 | QObject::connect(myUi.colorRange3, SIGNAL(valueChanged(double)),
|
---|
2672 | &connector, SLOT(rangeChanged3(double)));
|
---|
2673 |
|
---|
2674 | QObject::connect(myUi.colorRange4, SIGNAL(valueChanged(double)),
|
---|
2675 | &connector, SLOT(rangeChanged4(double)));
|
---|
2676 |
|
---|
2677 | QObject::connect(myUi.redValue0, SIGNAL(valueChanged(double)),
|
---|
2678 | &connector, SLOT(redChanged0(double)));
|
---|
2679 |
|
---|
2680 | QObject::connect(myUi.redValue1, SIGNAL(valueChanged(double)),
|
---|
2681 | &connector, SLOT(redChanged1(double)));
|
---|
2682 |
|
---|
2683 | QObject::connect(myUi.redValue2, SIGNAL(valueChanged(double)),
|
---|
2684 | &connector, SLOT(redChanged2(double)));
|
---|
2685 |
|
---|
2686 | QObject::connect(myUi.redValue3, SIGNAL(valueChanged(double)),
|
---|
2687 | &connector, SLOT(redChanged3(double)));
|
---|
2688 |
|
---|
2689 | QObject::connect(myUi.redValue4, SIGNAL(valueChanged(double)),
|
---|
2690 | &connector, SLOT(redChanged4(double)));
|
---|
2691 |
|
---|
2692 | QObject::connect(myUi.greenValue0, SIGNAL(valueChanged(double)),
|
---|
2693 | &connector, SLOT(greenChanged0(double)));
|
---|
2694 |
|
---|
2695 | QObject::connect(myUi.greenValue1, SIGNAL(valueChanged(double)),
|
---|
2696 | &connector, SLOT(greenChanged1(double)));
|
---|
2697 |
|
---|
2698 | QObject::connect(myUi.greenValue2, SIGNAL(valueChanged(double)),
|
---|
2699 | &connector, SLOT(greenChanged2(double)));
|
---|
2700 |
|
---|
2701 | QObject::connect(myUi.greenValue3, SIGNAL(valueChanged(double)),
|
---|
2702 | &connector, SLOT(greenChanged3(double)));
|
---|
2703 |
|
---|
2704 | QObject::connect(myUi.greenValue4, SIGNAL(valueChanged(double)),
|
---|
2705 | &connector, SLOT(greenChanged4(double)));
|
---|
2706 |
|
---|
2707 | QObject::connect(myUi.blueValue0, SIGNAL(valueChanged(double)),
|
---|
2708 | &connector, SLOT(blueChanged0(double)));
|
---|
2709 |
|
---|
2710 | QObject::connect(myUi.blueValue1, SIGNAL(valueChanged(double)),
|
---|
2711 | &connector, SLOT(blueChanged1(double)));
|
---|
2712 |
|
---|
2713 | QObject::connect(myUi.blueValue2, SIGNAL(valueChanged(double)),
|
---|
2714 | &connector, SLOT(blueChanged2(double)));
|
---|
2715 |
|
---|
2716 | QObject::connect(myUi.blueValue3, SIGNAL(valueChanged(double)),
|
---|
2717 | &connector, SLOT(blueChanged3(double)));
|
---|
2718 |
|
---|
2719 | QObject::connect(myUi.blueValue4, SIGNAL(valueChanged(double)),
|
---|
2720 | &connector, SLOT(blueChanged4(double)));
|
---|
2721 |
|
---|
2722 | QObject::connect(myUi.slicesPerSecValue, SIGNAL(valueChanged(double)),
|
---|
2723 | &connector, SLOT(slicesPerSecondChanged(double)));
|
---|
2724 | QObject::connect(myUi.playPauseButton, SIGNAL(clicked()),
|
---|
2725 | &connector, SLOT(playPauseClicked()));
|
---|
2726 |
|
---|
2727 | QObject::connect(canvas, SIGNAL(signalCurrentSlice(int)),
|
---|
2728 | &connector, SLOT(currentSliceHasChanged(int)));
|
---|
2729 | QObject::connect(canvas, SIGNAL(signalCurrentEvent(int)),
|
---|
2730 | &connector, SLOT(currentEventHasChanged(int)));
|
---|
2731 |
|
---|
2732 | QObject::connect(&connector, SIGNAL(updateCurrentSliceDisplay(int)),
|
---|
2733 | myUi.displayingSliceBox, SLOT(setValue(int)));
|
---|
2734 |
|
---|
2735 | QObject::connect(myUi.displayingSliceBox, SIGNAL(valueChanged(int)),
|
---|
2736 | &connector, SLOT(sliceChangedFromSpinner(int)));
|
---|
2737 | QObject::connect(myUi.displayingEventBox, SIGNAL(valueChanged(int)),
|
---|
2738 | &connector, SLOT(eventChangedFromSpinner(int)));
|
---|
2739 |
|
---|
2740 | // QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(QString)),
|
---|
2741 | // myUi.displayingEventLabel, SLOT(setText(const QString)));
|
---|
2742 | QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(int)),
|
---|
2743 | myUi.displayingEventBox, SLOT(setValue(int)));
|
---|
2744 |
|
---|
2745 | QObject::connect(&connector, SIGNAL(updateCurrentPCTime(QString)),
|
---|
2746 | myUi.PCTimeLabel, SLOT(setText(const QString)));
|
---|
2747 | QObject::connect(&connector, SIGNAL(updateCurrentSoftTrigger(QString)),
|
---|
2748 | myUi.softwareTriggerLabel, SLOT(setText(const QString)));
|
---|
2749 | QObject::connect(&connector, SIGNAL(updateCurrentTriggerType(QString)),
|
---|
2750 | myUi.triggerTypeLabel, SLOT(setText(const QString)));
|
---|
2751 | QObject::connect(&connector, SIGNAL(updateCurrentPixelSliceValue(const QString)),
|
---|
2752 | myUi.currentPixelValue, SLOT(setText(const QString)));
|
---|
2753 |
|
---|
2754 | if (conf.Has("file"))
|
---|
2755 | {
|
---|
2756 | string str = conf.Get<string>("file");
|
---|
2757 | QString qstr(str.c_str());
|
---|
2758 | connector.fileSelected(qstr);
|
---|
2759 | }
|
---|
2760 |
|
---|
2761 | mainWindow.show();
|
---|
2762 |
|
---|
2763 | return app.exec();
|
---|
2764 | }
|
---|
2765 |
|
---|