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