1 | /*
|
---|
2 | * QtGl.cpp
|
---|
3 | *
|
---|
4 | * Created on: Jul 19, 2011
|
---|
5 | * Author: lyard
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "RawEventsViewer.h"
|
---|
9 | #include "viewer.h"
|
---|
10 | #include <math.h>
|
---|
11 | #include <fstream>
|
---|
12 |
|
---|
13 | #ifdef LOAD_RAW
|
---|
14 | int16_t eventsData[NUM_STORED_EVENTS][ACTUAL_NUM_PIXELS][1024];
|
---|
15 | #include </home/lyard/Code/display.C>
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | #define VALUES_SPAN 4096
|
---|
19 |
|
---|
20 | #include <QtGui/QFileDialog>
|
---|
21 |
|
---|
22 | #include <qwt_plot_grid.h>
|
---|
23 | #include <qwt_symbol.h>
|
---|
24 |
|
---|
25 | #include "src/Configuration.h"
|
---|
26 |
|
---|
27 | //Coordinates of an hexagon of radius 1 and center 0
|
---|
28 | GLfloat hexcoords[6][2] = {{-0.577367206, 1},
|
---|
29 | { 0.577367206, 1},
|
---|
30 | { 1.154734411, 0},
|
---|
31 | { 0.577367206, -1},
|
---|
32 | {-0.577367206, -1},
|
---|
33 | {-1.154734411, 0}};
|
---|
34 |
|
---|
35 | //bounding box for diplaying the impulse curve
|
---|
36 | float bboxMin[2] = {-0.8,-0.9};
|
---|
37 | float bboxMax[2] = {0.8,-0.3};
|
---|
38 | /************************************************************
|
---|
39 | * UPDATE NEIGHBORS recalculate the neighbors of the current pixels.
|
---|
40 | * Only takes the previous pixels into account (and updates them, too)
|
---|
41 | ************************************************************/
|
---|
42 | void RawDataViewer::updateNeighbors(int currentPixel)
|
---|
43 | {
|
---|
44 | float squaredDistance = 0;
|
---|
45 | for (int i=0;i<currentPixel;i++)
|
---|
46 | {
|
---|
47 | squaredDistance = (pixelsCoords[i][0] - pixelsCoords[currentPixel][0])*
|
---|
48 | (pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) +
|
---|
49 | (pixelsCoords[i][1] - pixelsCoords[currentPixel][1])*
|
---|
50 | (pixelsCoords[i][1] - pixelsCoords[currentPixel][1]);
|
---|
51 | if (squaredDistance < 4*hexRadius*hexRadius*(1.0f+hexTolerance))//neighbor !
|
---|
52 | {//ok, but which one ?
|
---|
53 | if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
|
---|
54 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//top
|
---|
55 | neighbors[i][0] = currentPixel;
|
---|
56 | neighbors[currentPixel][3] = i;
|
---|
57 | continue;}
|
---|
58 | if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
|
---|
59 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//bottom
|
---|
60 | neighbors[i][3] = currentPixel;
|
---|
61 | neighbors[currentPixel][0] = i;
|
---|
62 | continue;}
|
---|
63 | if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
|
---|
64 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top right
|
---|
65 | neighbors[i][4] = currentPixel;
|
---|
66 | neighbors[currentPixel][1] = i;
|
---|
67 | continue;}
|
---|
68 | if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
|
---|
69 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom right
|
---|
70 | neighbors[i][5] = currentPixel;
|
---|
71 | neighbors[currentPixel][2] = i;
|
---|
72 | continue;}
|
---|
73 | if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
|
---|
74 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top left
|
---|
75 | neighbors[i][2] = currentPixel;
|
---|
76 | neighbors[currentPixel][5] = i;
|
---|
77 | continue;}
|
---|
78 | if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
|
---|
79 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom left
|
---|
80 | neighbors[i][1] = currentPixel;
|
---|
81 | neighbors[currentPixel][4] = i;
|
---|
82 | continue;}
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|
86 | /************************************************************
|
---|
87 | * SKIP PIXELS skips a given number of pixels.
|
---|
88 | * Only update the pixel coordinates. i.e. update neighbors must
|
---|
89 | * called again afterwards.
|
---|
90 | ************************************************************/
|
---|
91 | void RawDataViewer::skipPixels(int start, int howMany)
|
---|
92 | {
|
---|
93 | for (int i=start;i<MAX_NUM_PIXELS-howMany;i++)
|
---|
94 | {
|
---|
95 | pixelsCoords[i][0] = pixelsCoords[i+howMany][0];
|
---|
96 | pixelsCoords[i][1] = pixelsCoords[i+howMany][1];
|
---|
97 | }
|
---|
98 | }
|
---|
99 | /************************************************************
|
---|
100 | * CALCULATE PIXELS COORDS as the name suggests
|
---|
101 | ************************************************************/
|
---|
102 | void RawDataViewer::calculatePixelsCoords()
|
---|
103 | {
|
---|
104 | pixelsCoords[0][0] = 0;
|
---|
105 | pixelsCoords[0][1] = 0.3;
|
---|
106 | pixelsCoords[0][2] = 0;
|
---|
107 | pixelsCoords[1][0] = 0;
|
---|
108 | pixelsCoords[1][1] = 0.3+2*hexRadius;
|
---|
109 | pixelsCoords[1][2] = 0;
|
---|
110 | neighbors[0][0] = 1;
|
---|
111 | neighbors[1][3] = 0;
|
---|
112 | //from which side of the previous hexagon are we coming from ?
|
---|
113 | int fromSide = 3;
|
---|
114 | //to which side are we heading to ?
|
---|
115 | int toSide = 0;
|
---|
116 | for (int i=2;i<MAX_NUM_PIXELS;i++)
|
---|
117 | {
|
---|
118 | toSide = fromSide-1;
|
---|
119 | if (toSide < 0)
|
---|
120 | toSide =5;
|
---|
121 | while (neighbors[i-1][toSide] >= 0)
|
---|
122 | {
|
---|
123 | toSide--;
|
---|
124 | if (toSide < 0)
|
---|
125 | toSide = 5;
|
---|
126 | }
|
---|
127 | fromSide = toSide + 3;
|
---|
128 | if (fromSide > 5)
|
---|
129 | fromSide -= 6;
|
---|
130 | //ok. now we now in which direction we're heading
|
---|
131 | pixelsCoords[i][0] = pixelsCoords[i-1][0];
|
---|
132 | pixelsCoords[i][1] = pixelsCoords[i-1][1];
|
---|
133 | pixelsCoords[i][2] = pixelsCoords[i-1][2];
|
---|
134 | switch (toSide)
|
---|
135 | {
|
---|
136 | case 0:
|
---|
137 | pixelsCoords[i][1] += 2*hexRadius;
|
---|
138 | break;
|
---|
139 | case 1:
|
---|
140 | pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
|
---|
141 | pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
|
---|
142 | break;
|
---|
143 | case 2:
|
---|
144 | pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
|
---|
145 | pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
|
---|
146 | break;
|
---|
147 | case 3:
|
---|
148 | pixelsCoords[i][1] -= 2*hexRadius;
|
---|
149 | break;
|
---|
150 | case 4:
|
---|
151 | pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
|
---|
152 | pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
|
---|
153 | break;
|
---|
154 | case 5:
|
---|
155 | pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
|
---|
156 | pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
|
---|
157 | break;
|
---|
158 | };
|
---|
159 |
|
---|
160 | updateNeighbors(i);
|
---|
161 | }
|
---|
162 | //Ok. So now we've circled around all the way to MAX_NUM_PIXELS
|
---|
163 | //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels
|
---|
164 | skipPixels(1200, 1);
|
---|
165 | skipPixels(1218, 3);
|
---|
166 | skipPixels(1236, 1);
|
---|
167 | skipPixels(1256, 1);
|
---|
168 | skipPixels(1274, 3);
|
---|
169 | skipPixels(1292, 3);
|
---|
170 | skipPixels(1309, 6);
|
---|
171 | skipPixels(1323, 7);
|
---|
172 | skipPixels(1337, 6);
|
---|
173 | skipPixels(1354, 6);
|
---|
174 | skipPixels(1368, 7);
|
---|
175 | skipPixels(1382, 9);
|
---|
176 | skipPixels(1394, 12);
|
---|
177 | skipPixels(1402, 15);
|
---|
178 | skipPixels(1410, 12);
|
---|
179 | skipPixels(1422, 12);
|
---|
180 | skipPixels(1430, 15);
|
---|
181 | }
|
---|
182 | /************************************************************
|
---|
183 | * BUILD VERTICES LIST. from the coordinates of the camera pixels,
|
---|
184 | * calculate the list and coordinates of the vertices required to draw the
|
---|
185 | * entire camera.
|
---|
186 | ************************************************************/
|
---|
187 | void RawDataViewer::buildVerticesList()
|
---|
188 | {
|
---|
189 | numVertices = 0;
|
---|
190 | GLfloat cVertex[2];
|
---|
191 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
192 | {
|
---|
193 | for (int j=0;j<6;j++)
|
---|
194 | {
|
---|
195 | for (int k=0;k<2;k++)
|
---|
196 | cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
|
---|
197 | bool found = false;
|
---|
198 | for (int k=0;k<numVertices;k++)
|
---|
199 | {
|
---|
200 | if ((cVertex[0] - verticesList[k][0])*
|
---|
201 | (cVertex[0] - verticesList[k][0]) +
|
---|
202 | (cVertex[1] - verticesList[k][1])*
|
---|
203 | (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
|
---|
204 | {
|
---|
205 | found = true;
|
---|
206 | break;
|
---|
207 | }
|
---|
208 | }
|
---|
209 | if (!found)
|
---|
210 | {
|
---|
211 | for (int k=0;k<2;k++)
|
---|
212 | verticesList[numVertices][k] = cVertex[k];
|
---|
213 | numVertices++;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | }
|
---|
217 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
218 | {
|
---|
219 | for (int j=0;j<6;j++)
|
---|
220 | {
|
---|
221 | for (int k=0;k<2;k++)
|
---|
222 | cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
|
---|
223 | for (int k=0;k<numVertices;k++)
|
---|
224 | {
|
---|
225 | if ((cVertex[0] - verticesList[k][0])*
|
---|
226 | (cVertex[0] - verticesList[k][0]) +
|
---|
227 | (cVertex[1] - verticesList[k][1])*
|
---|
228 | (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
|
---|
229 | {
|
---|
230 | verticesIndices[i][j] = k;
|
---|
231 | break;
|
---|
232 | }
|
---|
233 | }
|
---|
234 | }
|
---|
235 | }
|
---|
236 | }
|
---|
237 | /************************************************************
|
---|
238 | * BUILD PATCHES INDICES. from the list of patches, crawls through
|
---|
239 | * the list of camera pixels and build the list of edges that should be kept
|
---|
240 | * in order to display the patches' contours.
|
---|
241 | ************************************************************/
|
---|
242 | void RawDataViewer::buildPatchesIndices()
|
---|
243 | {
|
---|
244 | vector<edge>::iterator it;
|
---|
245 | bool erased = false;
|
---|
246 | for (int i=0;i<NTMARK;i++)//for all patches
|
---|
247 | {
|
---|
248 | patchesIndices[i].clear();
|
---|
249 | for (int j=0;j<9;j++)//for all cells of the current patch
|
---|
250 | {
|
---|
251 | if (patches[i][j] == 690 ||
|
---|
252 | patches[i][j] == 70)
|
---|
253 | continue;
|
---|
254 | for (int k=0;k<6;k++)//for all sides of the current cell
|
---|
255 | {
|
---|
256 | int first = k-1;
|
---|
257 | int second = k;
|
---|
258 | if (first < 0)
|
---|
259 | first = 5;
|
---|
260 | erased = false;
|
---|
261 | for (it=(patchesIndices[i]).begin(); it != (patchesIndices[i]).end(); it++)//check if this side is here already or not
|
---|
262 | {
|
---|
263 | if (((*it).first == verticesIndices[patches[i][j]][first] &&
|
---|
264 | (*it).second == verticesIndices[patches[i][j]][second]) ||
|
---|
265 | ((*it).first == verticesIndices[patches[i][j]][second] &&
|
---|
266 | (*it).second == verticesIndices[patches[i][j]][first]))
|
---|
267 | {
|
---|
268 | patchesIndices[i].erase(it);
|
---|
269 | erased = true;
|
---|
270 | break;
|
---|
271 | }
|
---|
272 | }
|
---|
273 | if (!erased)
|
---|
274 | {
|
---|
275 | edge temp;
|
---|
276 | temp.first = verticesIndices[patches[i][j]][first];
|
---|
277 | temp.second = verticesIndices[patches[i][j]][second];
|
---|
278 | patchesIndices[i].push_back(temp);
|
---|
279 | }
|
---|
280 | }
|
---|
281 | }
|
---|
282 | }
|
---|
283 | }
|
---|
284 | /************************************************************
|
---|
285 | * CALC BLUR COLOR if in blur display mode, calculate the interpolated
|
---|
286 | * colour for a given vertex
|
---|
287 | ************************************************************/
|
---|
288 | void RawDataViewer::calcBlurColor(int pixel, int vertex)
|
---|
289 | {
|
---|
290 | GLfloat color[3];
|
---|
291 | int first, second;
|
---|
292 | first = vertex-1;
|
---|
293 | second = vertex;
|
---|
294 | if (first < 0)
|
---|
295 | first = 5;
|
---|
296 | first = neighbors[pixel][first];
|
---|
297 | second = neighbors[pixel][second];
|
---|
298 | for (int i=0;i<3;i++)
|
---|
299 | color[i] = pixelsColor[pixel][i];
|
---|
300 | float divide = 1;
|
---|
301 | if (first != -1)
|
---|
302 | {
|
---|
303 | divide++;
|
---|
304 | for (int i=0;i<3;i++)
|
---|
305 | color[i] += pixelsColor[first][i];
|
---|
306 | }
|
---|
307 | if (second != -1)
|
---|
308 | {
|
---|
309 | divide++;
|
---|
310 | for (int i=0;i<3;i++)
|
---|
311 | color[i] += pixelsColor[second][i];
|
---|
312 | }
|
---|
313 | for (int i=0;i<3;i++)
|
---|
314 | color[i] /= divide;
|
---|
315 | glColor3fv(color);
|
---|
316 | }
|
---|
317 | /************************************************************
|
---|
318 | * DRAW BLURRY HEXAGON. draws a solid hexagon, with interpolated colours
|
---|
319 | ************************************************************/
|
---|
320 | void RawDataViewer::drawBlurryHexagon(int index)
|
---|
321 | {
|
---|
322 | GLfloat color[3];
|
---|
323 | for (int i=0;i<3;i++)
|
---|
324 | color[i] = pixelsColor[index][i];
|
---|
325 | glBegin(GL_TRIANGLES);
|
---|
326 | calcBlurColor(index, 0);
|
---|
327 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
328 | glColor3fv(color);
|
---|
329 | glVertex2fv(pixelsCoords[index]);
|
---|
330 | calcBlurColor(index, 1);
|
---|
331 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
332 |
|
---|
333 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
334 | glColor3fv(color);
|
---|
335 | glVertex2fv(pixelsCoords[index]);
|
---|
336 | calcBlurColor(index, 2);
|
---|
337 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
338 |
|
---|
339 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
340 | glColor3fv(color);
|
---|
341 | glVertex2fv(pixelsCoords[index]);
|
---|
342 | calcBlurColor(index, 3);
|
---|
343 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
344 |
|
---|
345 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
346 | glColor3fv(color);
|
---|
347 | glVertex2fv(pixelsCoords[index]);
|
---|
348 | calcBlurColor(index, 4);
|
---|
349 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
350 |
|
---|
351 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
352 | glColor3fv(color);
|
---|
353 | glVertex2fv(pixelsCoords[index]);
|
---|
354 | calcBlurColor(index, 5);
|
---|
355 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
356 |
|
---|
357 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
358 | glColor3fv(color);
|
---|
359 | glVertex2fv(pixelsCoords[index]);
|
---|
360 | calcBlurColor(index, 0);
|
---|
361 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
362 | glEnd();
|
---|
363 |
|
---|
364 | return;
|
---|
365 | }
|
---|
366 | /************************************************************
|
---|
367 | * DRAW HEXAGON. draws a single hexagon.
|
---|
368 | ************************************************************/
|
---|
369 | void RawDataViewer::drawHexagon(int index, bool solid)
|
---|
370 | {
|
---|
371 | if (solid)
|
---|
372 | glBegin(GL_POLYGON);
|
---|
373 | else
|
---|
374 | glBegin(GL_LINE_LOOP);
|
---|
375 |
|
---|
376 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
377 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
378 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
379 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
380 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
381 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
382 | if (solid)
|
---|
383 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
384 |
|
---|
385 | glEnd();
|
---|
386 |
|
---|
387 | return;
|
---|
388 | }
|
---|
389 |
|
---|
390 |
|
---|
391 | float ss[5] = {0.00, 0.25, 0.5, 0.75, 1.00};
|
---|
392 | float rr[5] = {0.15, 0.00, 0.00, 1.00, 0.85};
|
---|
393 | float gg[5] = {0.15, 0.00, 1.00, 0.00, 0.85};
|
---|
394 | float bb[5] = {0.15, 1.00, 0.00, 0.00, 0.85};
|
---|
395 | /*
|
---|
396 | float ss[5] = {0., 0.47, 0.475, 0.48, 1.00};
|
---|
397 | float rr[5] = {0., 0.35, 0.85, 1.00, 1.00};
|
---|
398 | float gg[5] = {0., 0.10, 0.20, 0.73, 1.00};
|
---|
399 | float bb[5] = {0., 0.03, 0.06, 0.00, 1.00};
|
---|
400 | */
|
---|
401 | /************************************************************
|
---|
402 | * DRAW PATCHES. draws the clustering patches
|
---|
403 | ************************************************************/
|
---|
404 | void RawDataViewer::drawPatches()
|
---|
405 | {
|
---|
406 | glLineWidth(2.0f);
|
---|
407 | float backupRadius = hexRadius;
|
---|
408 | hexRadius *= 0.95;
|
---|
409 | glBegin(GL_LINES);
|
---|
410 | for (int i=0;i<NTMARK;i++)
|
---|
411 | {
|
---|
412 | glColor3fv(patchesColor[i]);
|
---|
413 | for (unsigned int j=0;j<patchesIndices[i].size();j++)
|
---|
414 | {
|
---|
415 | glVertex2fv(verticesList[patchesIndices[i][j].first]);
|
---|
416 | glVertex2fv(verticesList[patchesIndices[i][j].second]);
|
---|
417 | }
|
---|
418 | }
|
---|
419 | glEnd();
|
---|
420 | hexRadius = backupRadius;
|
---|
421 | }
|
---|
422 | /************************************************************
|
---|
423 | * DRAW CAMERA draws all the camera pixels
|
---|
424 | ************************************************************/
|
---|
425 | void RawDataViewer::drawCamera(bool alsoWire)
|
---|
426 | {
|
---|
427 | glColor3f(0.5,0.5,0.5);
|
---|
428 | glLineWidth(1.0);
|
---|
429 | float color;
|
---|
430 |
|
---|
431 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
432 | {
|
---|
433 | if (!nRoi)
|
---|
434 | color = (float)(i)/(float)(ACTUAL_NUM_PIXELS);
|
---|
435 | else
|
---|
436 | #ifdef LOAD_RAW
|
---|
437 | color = float(eventsData[eventNum][i][whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
438 | #else
|
---|
439 | color = float(eventData[nRoi*i + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
440 | #endif
|
---|
441 | int index = 0;
|
---|
442 | while (ss[index] < color)
|
---|
443 | index++;
|
---|
444 | index--;
|
---|
445 | float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
|
---|
446 | float weight1 = 1.0f-weight0;
|
---|
447 | pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
|
---|
448 | pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
|
---|
449 | pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
|
---|
450 | }
|
---|
451 |
|
---|
452 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
453 | {
|
---|
454 | if (i == 690 ||
|
---|
455 | i == 70)
|
---|
456 | continue;
|
---|
457 | glColor3fv(pixelsColor[i]);
|
---|
458 | glLoadName(i);
|
---|
459 | if (drawBlur)
|
---|
460 | drawBlurryHexagon(i);
|
---|
461 | else
|
---|
462 | drawHexagon(i,true);
|
---|
463 |
|
---|
464 | }
|
---|
465 | if (!alsoWire)
|
---|
466 | return;
|
---|
467 | glColor3f(0.0f,0.0f,0.0f);
|
---|
468 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
469 | {
|
---|
470 | if (i == 690 ||
|
---|
471 | i == 70)
|
---|
472 | continue;
|
---|
473 | drawHexagon(i, false);
|
---|
474 | }
|
---|
475 |
|
---|
476 | }
|
---|
477 |
|
---|
478 | /************************************************************
|
---|
479 | * TRIM. FIXME this should not be here but taken from an existing class (somewhere)
|
---|
480 | ************************************************************/
|
---|
481 | string Trim(const string &str)
|
---|
482 | {
|
---|
483 | // Trim Both leading and trailing spaces
|
---|
484 | const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
|
---|
485 | const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af
|
---|
486 |
|
---|
487 | // if all spaces or empty return an empty string
|
---|
488 | if (string::npos==start || string::npos==end)
|
---|
489 | return string();
|
---|
490 |
|
---|
491 | return str.substr(start, end-start+1);
|
---|
492 | }
|
---|
493 | /************************************************************
|
---|
494 | * DRAW PIXEL CURVE. draws the raw impulse curve of the currently selected pixel
|
---|
495 | ************************************************************/
|
---|
496 | void RawDataViewer::drawPixelCurve()
|
---|
497 | {
|
---|
498 | if (!nRoi)
|
---|
499 | return;
|
---|
500 |
|
---|
501 | float xZoom, yZoom;
|
---|
502 | xZoom = yZoom = 1.0f;
|
---|
503 |
|
---|
504 | glBegin(GL_LINES);
|
---|
505 | glLineWidth(1.0f);
|
---|
506 | glColor3f(0.5,0.5,0.5);
|
---|
507 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
508 | glVertex2f(bboxMax[0], bboxMin[1]);
|
---|
509 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
510 | glVertex2f(bboxMin[0], bboxMax[1]);
|
---|
511 | glVertex2f(bboxMin[0], (bboxMin[1]+bboxMax[1])/2.0f);
|
---|
512 | glVertex2f(bboxMax[0], (bboxMin[1]+bboxMax[1])/2.0f);
|
---|
513 | float xRange = bboxMax[0] - bboxMin[0];
|
---|
514 | float yRange = bboxMax[1] - bboxMin[1];
|
---|
515 | glColor3f(1.0,1.0,1.0);
|
---|
516 | for (int i=0;i<nRoi-1;i++)
|
---|
517 | {
|
---|
518 | #ifdef LOAD_RAW
|
---|
519 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
520 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));
|
---|
521 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
522 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));
|
---|
523 | #else
|
---|
524 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
525 | bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));
|
---|
526 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
527 | bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));
|
---|
528 | #endif
|
---|
529 | }
|
---|
530 | glColor3f(1.0,0.0,0.0);
|
---|
531 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
532 | bboxMin[1]);
|
---|
533 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
534 | bboxMax[1]);
|
---|
535 | glEnd();
|
---|
536 | glEnable(GL_MULTISAMPLE);
|
---|
537 | setFont(QFont("Times", 12));
|
---|
538 | qglColor(QColor(255,223,127));
|
---|
539 | float xShift = 0.10f;
|
---|
540 | float yShift = 0.01f;
|
---|
541 | renderText(bboxMin[0]-xShift/2.0f, bboxMax[1]+3*yShift, 0, QString("Volts"));
|
---|
542 | renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+1.05"));
|
---|
543 | renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+0.00"));//((bboxMin[1]+bboxMax[1])/2.0f)
|
---|
544 | renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("-1.05"));
|
---|
545 |
|
---|
546 | renderText(bboxMax[0]+xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("Slices"));
|
---|
547 | renderText(bboxMin[0]-yShift/2.0f, bboxMin[1]-4*yShift, 0, QString("0"));
|
---|
548 | ostringstream str;
|
---|
549 | str << nRoi/2;
|
---|
550 | renderText(((bboxMin[0]+bboxMax[0])/2.0f)-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str()));
|
---|
551 | str.str("");
|
---|
552 | str << nRoi;
|
---|
553 | renderText(bboxMax[0]-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str()));
|
---|
554 |
|
---|
555 | }
|
---|
556 | /************************************************************
|
---|
557 | * CONSTRUCTOR.
|
---|
558 | ************************************************************/
|
---|
559 | RawDataViewer::RawDataViewer(QWidget *cParent) : QGLWidget(cParent)
|
---|
560 | {
|
---|
561 | setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
|
---|
562 | hexRadius = 0.015f;
|
---|
563 | hexTolerance = hexRadius/100.0f;
|
---|
564 | viewSize = 1.0f;
|
---|
565 | whichSlice = 0;
|
---|
566 | #ifdef LOAD_RAW
|
---|
567 | nRoi = 1024;
|
---|
568 | #else
|
---|
569 | nRoi = 0;
|
---|
570 | #endif
|
---|
571 | eventNum = 0;
|
---|
572 | rowNum = -1;
|
---|
573 | eventStep = 1;
|
---|
574 | selectedPixel = 393;
|
---|
575 | inputFile = NULL;
|
---|
576 | eventData = NULL;
|
---|
577 | drawPatch = true;
|
---|
578 | drawImpulse = false;
|
---|
579 | drawBlur = false;
|
---|
580 | loopCurrentEvent = false;
|
---|
581 | #ifdef LOAD_RAW
|
---|
582 | loadEvents("/scratch/00000043.001_T.bin");
|
---|
583 | #endif
|
---|
584 | calculatePixelsCoords();
|
---|
585 |
|
---|
586 | ifstream fin2("MasterList-v3.txt");
|
---|
587 | if (!fin2.is_open())
|
---|
588 | {
|
---|
589 | cout << "Error: file \"MasterList-v3\" missing. aborting." << endl;
|
---|
590 | exit(-1);
|
---|
591 | }
|
---|
592 | int l = 0;
|
---|
593 | string buf;
|
---|
594 | while (getline(fin2, buf, '\n'))
|
---|
595 | {
|
---|
596 | buf = Trim(buf);
|
---|
597 | if (buf[0]=='#')
|
---|
598 | continue;
|
---|
599 |
|
---|
600 | unsigned int softid, hardid, dummy;
|
---|
601 |
|
---|
602 | stringstream str(buf);
|
---|
603 |
|
---|
604 | str >> softid;
|
---|
605 | str >> dummy;
|
---|
606 | str >> hardid;
|
---|
607 |
|
---|
608 | if (softid>=1440)
|
---|
609 | continue;
|
---|
610 |
|
---|
611 | hardwareMapping[softid] = hardid;
|
---|
612 | softwareMapping[hardid] = softid;
|
---|
613 |
|
---|
614 | l++;
|
---|
615 | }
|
---|
616 | GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3];
|
---|
617 | for (int i=0;i<1440;i++)
|
---|
618 | for (int j=0;j<3;j++)
|
---|
619 | tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j];
|
---|
620 | for (int i=0;i<1440;i++)
|
---|
621 | for (int j=0;j<3;j++)
|
---|
622 | pixelsCoords[i][j] = tempPixelsCoords[i][j];
|
---|
623 | buildVerticesList();
|
---|
624 | ifstream fin1("Trigger-Patches.txt");
|
---|
625 | if (!fin1.is_open())
|
---|
626 | {
|
---|
627 | cout << "Error: file \"Trigger-Patches.txt\" missing. Aborting." << endl;
|
---|
628 | exit(-1);
|
---|
629 | }
|
---|
630 | l=0;
|
---|
631 | while (getline(fin1, buf, '\n'))
|
---|
632 | {
|
---|
633 | buf = Trim(buf);
|
---|
634 | if (buf[0]=='#')
|
---|
635 | continue;
|
---|
636 |
|
---|
637 | stringstream str(buf);
|
---|
638 | for (int i=0; i<9; i++)
|
---|
639 | {
|
---|
640 | unsigned int n;
|
---|
641 | str >> n;
|
---|
642 |
|
---|
643 | if (n>=1440)
|
---|
644 | continue;
|
---|
645 |
|
---|
646 | patches[l][i] = hardwareMapping[n];
|
---|
647 | }
|
---|
648 | l++;
|
---|
649 | }
|
---|
650 | buildPatchesIndices();
|
---|
651 | float color[3];
|
---|
652 | for (int i=0;i<160;i++)
|
---|
653 | {
|
---|
654 | color[0] = 0.5; color[1] = 0.5; color[2] = 0.3;
|
---|
655 | for (int j=0;j<3;j++)
|
---|
656 | patchesColor[i][j] = color[j];
|
---|
657 | }
|
---|
658 |
|
---|
659 | for (int i=0;i<1440;i++)
|
---|
660 | updateNeighbors(i);
|
---|
661 | }
|
---|
662 | /************************************************************
|
---|
663 | * DESTRUCTOR
|
---|
664 | ************************************************************/
|
---|
665 | RawDataViewer::~RawDataViewer()
|
---|
666 | {
|
---|
667 | if (inputFile != NULL)
|
---|
668 | {
|
---|
669 | inputFile->close();
|
---|
670 | delete inputFile;
|
---|
671 | }
|
---|
672 | if (eventData != NULL)
|
---|
673 | delete[] eventData;
|
---|
674 | }
|
---|
675 | /************************************************************
|
---|
676 | * INITIALIZE GL. does not do much.
|
---|
677 | ************************************************************/
|
---|
678 | void RawDataViewer::initializeGL()
|
---|
679 | {
|
---|
680 | qglClearColor(QColor(25,25,38));
|
---|
681 | glShadeModel(GL_FLAT);
|
---|
682 | glDisable(GL_DEPTH_TEST);
|
---|
683 | glDisable(GL_CULL_FACE);
|
---|
684 | // glEnable(GL_LINE_SMOOTH);
|
---|
685 | // glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
|
---|
686 | }
|
---|
687 |
|
---|
688 | /************************************************************
|
---|
689 | * RESIZE GL. reshapes the ortho projection to match the current window size
|
---|
690 | ************************************************************/
|
---|
691 | void RawDataViewer::resizeGL(int cWidth, int cHeight)
|
---|
692 | {
|
---|
693 | glViewport(0, 0, cWidth, cHeight);
|
---|
694 | glMatrixMode(GL_PROJECTION);
|
---|
695 | glLoadIdentity();
|
---|
696 | GLfloat windowRatio = (float)cWidth/(float)cHeight;
|
---|
697 | if (windowRatio < 1)
|
---|
698 | {
|
---|
699 | windowRatio = 1.0f/windowRatio;
|
---|
700 | gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
|
---|
701 | pixelSize = 2*viewSize/(float)cWidth;
|
---|
702 | shownSizex = 2*viewSize;
|
---|
703 | shownSizey = 2*viewSize*windowRatio;
|
---|
704 | }
|
---|
705 | else
|
---|
706 | {
|
---|
707 | gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
|
---|
708 | pixelSize = 2*viewSize/(float)cHeight;
|
---|
709 | shownSizex = 2*viewSize*windowRatio;
|
---|
710 | shownSizey = 2*viewSize;
|
---|
711 | }
|
---|
712 | glMatrixMode(GL_MODELVIEW);
|
---|
713 | }
|
---|
714 |
|
---|
715 | /************************************************************
|
---|
716 | * PAINT GL. main drawing function.
|
---|
717 | ************************************************************/
|
---|
718 | void RawDataViewer::paintGL()
|
---|
719 | {
|
---|
720 | glClear(GL_COLOR_BUFFER_BIT);
|
---|
721 | glLoadIdentity();
|
---|
722 |
|
---|
723 | if (!drawImpulse)
|
---|
724 | {
|
---|
725 | glTranslatef(0,-0.44,0);
|
---|
726 | glScalef(1.5,1.5,1);
|
---|
727 | }
|
---|
728 | if (drawBlur)
|
---|
729 | {
|
---|
730 | glShadeModel(GL_SMOOTH);
|
---|
731 | drawCamera(false);
|
---|
732 | }
|
---|
733 | else
|
---|
734 | {
|
---|
735 | glShadeModel(GL_FLAT);
|
---|
736 | drawCamera(true);
|
---|
737 | }
|
---|
738 | if (drawImpulse)
|
---|
739 | {
|
---|
740 | glLineWidth(2.0);
|
---|
741 | drawPixelCurve();
|
---|
742 | }
|
---|
743 | if (drawPatch)
|
---|
744 | drawPatches();
|
---|
745 |
|
---|
746 | if (!drawBlur)
|
---|
747 | {
|
---|
748 | glLineWidth(1.0f);
|
---|
749 | glColor3f(1.0,1.0,1.0);
|
---|
750 | drawHexagon(selectedPixel, false);
|
---|
751 | }
|
---|
752 | }
|
---|
753 |
|
---|
754 | /************************************************************
|
---|
755 | * MOUSE PRESS EVENT. mouse click handler.
|
---|
756 | ************************************************************/
|
---|
757 | void RawDataViewer::mousePressEvent(QMouseEvent *cEvent)
|
---|
758 | {
|
---|
759 | lastPos = cEvent->pos();
|
---|
760 | setCorrectSlice(cEvent);
|
---|
761 | updateGL();
|
---|
762 | }
|
---|
763 |
|
---|
764 | /************************************************************
|
---|
765 | * SET CORRECT SLICE. if displayed, figures out if the graph was
|
---|
766 | * clicked, and if so, which slice should be displayed
|
---|
767 | ************************************************************/
|
---|
768 | void RawDataViewer::setCorrectSlice(QMouseEvent* cEvent)
|
---|
769 | {
|
---|
770 | if (!drawImpulse)
|
---|
771 | return;
|
---|
772 | float cx = (float)cEvent->x() * pixelSize - shownSizex/2;
|
---|
773 | float cy = ((float)height()-(float)cEvent->y())*pixelSize - shownSizey/2;
|
---|
774 | if (cx < bboxMin[0] ||
|
---|
775 | cx > bboxMax[0] ||
|
---|
776 | cy < bboxMin[1] ||
|
---|
777 | cy > bboxMax[1])
|
---|
778 | return;
|
---|
779 | whichSlice = (cx - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
|
---|
780 | emit signalCurrentSlice(whichSlice);
|
---|
781 | }
|
---|
782 |
|
---|
783 | /************************************************************
|
---|
784 | * MOUSE MOVE EVENT. used to track the dragging of slices display
|
---|
785 | ************************************************************/
|
---|
786 | void RawDataViewer::mouseMoveEvent(QMouseEvent *cEvent)
|
---|
787 | {
|
---|
788 | if (cEvent->buttons() & Qt::LeftButton) {
|
---|
789 | setCorrectSlice(cEvent);
|
---|
790 | updateGL();
|
---|
791 | } else if (cEvent->buttons() & Qt::RightButton) {
|
---|
792 | updateGL();
|
---|
793 | }
|
---|
794 | lastPos = cEvent->pos();
|
---|
795 | }
|
---|
796 |
|
---|
797 | /************************************************************
|
---|
798 | * MOUSE DOUBLE CLICK EVENT. used to select pixels
|
---|
799 | ************************************************************/
|
---|
800 | void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *cEvent)
|
---|
801 | {
|
---|
802 | int face = PixelAtPosition(cEvent->pos());
|
---|
803 | if (face != -1) {
|
---|
804 | selectedPixel = face;
|
---|
805 | emit signalCurrentPixel(face);
|
---|
806 | updateGL();
|
---|
807 | }
|
---|
808 | }
|
---|
809 |
|
---|
810 | /************************************************************
|
---|
811 | * PIXEL AT POSITION. figures out which camera pixel was clicked.
|
---|
812 | ************************************************************/
|
---|
813 | int RawDataViewer::PixelAtPosition(const QPoint &cPos)
|
---|
814 | {
|
---|
815 | const int MaxSize = 512;
|
---|
816 | GLuint buffer[MaxSize];
|
---|
817 | GLint viewport[4];
|
---|
818 |
|
---|
819 | makeCurrent();
|
---|
820 |
|
---|
821 | glGetIntegerv(GL_VIEWPORT, viewport);
|
---|
822 | glSelectBuffer(MaxSize, buffer);
|
---|
823 | glRenderMode(GL_SELECT);
|
---|
824 |
|
---|
825 | glInitNames();
|
---|
826 | glPushName(0);
|
---|
827 |
|
---|
828 | glMatrixMode(GL_PROJECTION);
|
---|
829 | glPushMatrix();
|
---|
830 | glLoadIdentity();
|
---|
831 | GLfloat windowRatio = GLfloat(width()) / GLfloat(height());
|
---|
832 | gluPickMatrix(GLdouble(cPos.x()), GLdouble(viewport[3] - cPos.y()),
|
---|
833 | 1.0, 1.0, viewport);
|
---|
834 |
|
---|
835 | if (windowRatio < 1)
|
---|
836 | {
|
---|
837 | windowRatio = 1.0f/windowRatio;
|
---|
838 | gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
|
---|
839 | }
|
---|
840 | else
|
---|
841 | {
|
---|
842 | gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
|
---|
843 | }
|
---|
844 |
|
---|
845 | glMatrixMode(GL_MODELVIEW);
|
---|
846 | drawCamera(false);
|
---|
847 | glMatrixMode(GL_PROJECTION);
|
---|
848 | glPopMatrix();
|
---|
849 |
|
---|
850 | //for some reason that I cannot understand, the push/pop matrix doesn't do the trick here... bizarre
|
---|
851 | //ok, so re-do the resizeGL thing.
|
---|
852 | resizeGL(width(), height());
|
---|
853 |
|
---|
854 | if (!glRenderMode(GL_RENDER))
|
---|
855 | return -1;
|
---|
856 |
|
---|
857 | return buffer[3];
|
---|
858 | }
|
---|
859 | /************************************************************
|
---|
860 | * OPEN FILE. opens a new fits file
|
---|
861 | ************************************************************/
|
---|
862 | void RawDataViewer::openFile(string& file)
|
---|
863 | {
|
---|
864 | if (inputFile)
|
---|
865 | {
|
---|
866 | inputFile->close();
|
---|
867 | delete inputFile;
|
---|
868 | }
|
---|
869 | inputFile = new fits(file);
|
---|
870 | if (!*inputFile)
|
---|
871 | {
|
---|
872 | delete inputFile;
|
---|
873 | inputFile = NULL;
|
---|
874 | return;
|
---|
875 | }
|
---|
876 | vector<string> entriesToCheck;
|
---|
877 | entriesToCheck.push_back("NAXIS2");
|
---|
878 | entriesToCheck.push_back("NROI");
|
---|
879 | entriesToCheck.push_back("NTMARK");
|
---|
880 | entriesToCheck.push_back("RUNTYPE");
|
---|
881 | entriesToCheck.push_back("REVISION");
|
---|
882 | entriesToCheck.push_back("BLDVER");
|
---|
883 | entriesToCheck.push_back("RUNID");
|
---|
884 | entriesToCheck.push_back("NBOARD");
|
---|
885 | entriesToCheck.push_back("NPIX");
|
---|
886 | entriesToCheck.push_back("NROITM");
|
---|
887 | entriesToCheck.push_back("TIMESYS");
|
---|
888 | entriesToCheck.push_back("DATE");
|
---|
889 | entriesToCheck.push_back("NIGHT");
|
---|
890 | entriesToCheck.push_back("CAMERA");
|
---|
891 | entriesToCheck.push_back("DAQ");
|
---|
892 | entriesToCheck.push_back("ADCCOUNT");
|
---|
893 | entriesToCheck.push_back("TSTART");
|
---|
894 | entriesToCheck.push_back("TSTOP");
|
---|
895 | entriesToCheck.push_back("NBEVTOK");
|
---|
896 | entriesToCheck.push_back("NBEVTREJ");
|
---|
897 | entriesToCheck.push_back("NBEVTBAD");
|
---|
898 |
|
---|
899 | for (vector<string>::const_iterator it=entriesToCheck.begin(); it != entriesToCheck.end(); it++)
|
---|
900 | {
|
---|
901 | if (!inputFile->HasKey(*it)){
|
---|
902 | cout << *it << " missing. Aborting load..." << endl;
|
---|
903 | return;}
|
---|
904 | }
|
---|
905 | nRows = inputFile->GetInt("NAXIS2");
|
---|
906 | nRoi = inputFile->GetInt("NROI");
|
---|
907 | runNumber = inputFile->GetInt("RUNID");
|
---|
908 | nTM = inputFile->GetInt("NTMARK");
|
---|
909 | runType = inputFile->GetInt("RUNTYPE");
|
---|
910 | firstDataTime = inputFile->GetInt("TSTART");
|
---|
911 | lastDataTime = inputFile->GetInt("TSTOP");
|
---|
912 | nRoiTM = inputFile->GetInt("NROITM");
|
---|
913 | revision = inputFile->GetInt("REVISION");
|
---|
914 | builderVersion = inputFile->GetInt("BLDVER");
|
---|
915 | nBoards = inputFile->GetInt("NBOARD");
|
---|
916 | nPixels = inputFile->GetInt("NPIX");
|
---|
917 | timeSystem = inputFile->GetStr("TIMESYS");
|
---|
918 | creationDate = inputFile->GetStr("DATE");
|
---|
919 | nightInt = inputFile->GetInt("NIGHT");
|
---|
920 | camera = inputFile->GetStr("CAMERA");
|
---|
921 | daq = inputFile->GetStr("DAQ");
|
---|
922 | adcCount = inputFile->GetFloat("ADCCOUNT");
|
---|
923 | nbOk = inputFile->GetInt("NBEVTOK");
|
---|
924 | nbRej = inputFile->GetInt("NBEVTREJ");
|
---|
925 | nbBad = inputFile->GetInt("NBEVTBAD");
|
---|
926 |
|
---|
927 | eventNum = 0;
|
---|
928 |
|
---|
929 | #ifdef LOAD_RAW
|
---|
930 | nRows = NUM_STORED_EVENTS;
|
---|
931 | #endif
|
---|
932 |
|
---|
933 | if (eventData != NULL)
|
---|
934 | delete[] eventData;
|
---|
935 | eventData = new int16_t[(1440+160)*nRoi];
|
---|
936 | if (!inputFile->SetPtrAddress("Data", eventData)){
|
---|
937 | cout << "Missing column " << "Data" << " Aborting load..." << endl;
|
---|
938 | nRoi = nRows = 0;}
|
---|
939 | if (!inputFile->SetPtrAddress("EventNum", &eventNum)){
|
---|
940 | cout << "Missing column " << "EventNum" << " Aborting load..." << endl;
|
---|
941 | nRoi = nRows = 0;}
|
---|
942 | if (!inputFile->SetPtrAddress("TriggerType", &triggerType)){
|
---|
943 | cout << "Missing column " << "TriggerType" << " Aborting load..." << endl;
|
---|
944 | nRoi = nRows = 0;}
|
---|
945 | if (!inputFile->SetPtrAddress("SoftTrig", &softTrig)){
|
---|
946 | cout << "Missing column " << "SoftTrig" << " Aborting load..." << endl;
|
---|
947 | nRoi = nRows = 0;}
|
---|
948 | if (!inputFile->SetPtrAddress("PCTime", &pcTime)){
|
---|
949 | cout << "Missing column " << "PCTime" << " Aborting load..." << endl;
|
---|
950 | nRoi = nRows = 0;}
|
---|
951 | if (!inputFile->SetPtrAddress("BoardTime", boardTime)){
|
---|
952 | cout << "Missing column " << "BoardTime" << " Aborting load..." << endl;
|
---|
953 | nRoi = nRows = 0;}
|
---|
954 | if (!inputFile->SetPtrAddress("StartCellData", startPix)){
|
---|
955 | cout << "Missing column " << "StartCellData" << " Aborting load..." << endl;
|
---|
956 | nRoi = nRows = 0;}
|
---|
957 | if (!inputFile->SetPtrAddress("StartCellTimeMarker", startTM)){
|
---|
958 | cout << "Missing column " << "StartCellTimeMarker" << " Aborting load..." << endl;
|
---|
959 | nRoi = nRows = 0;}
|
---|
960 | int backupStep = eventStep;
|
---|
961 | rowNum = -1;
|
---|
962 | eventStep = 1;
|
---|
963 | plusEvent();
|
---|
964 | eventStep = backupStep;
|
---|
965 | emit newFileLoaded();
|
---|
966 | emit signalCurrentPixel(selectedPixel);
|
---|
967 | }
|
---|
968 |
|
---|
969 | /************************************************************
|
---|
970 | * PLUS EVENT
|
---|
971 | ************************************************************/
|
---|
972 | void RawDataViewer::plusEvent()
|
---|
973 | {
|
---|
974 | eventStepping(true);
|
---|
975 | }
|
---|
976 | /************************************************************
|
---|
977 | * MINUS EVENT
|
---|
978 | ************************************************************/
|
---|
979 | void RawDataViewer::minusEvent()
|
---|
980 | {
|
---|
981 | eventStepping(false);
|
---|
982 | }
|
---|
983 | /************************************************************
|
---|
984 | * SET EVENT STEP
|
---|
985 | ************************************************************/
|
---|
986 | void RawDataViewer::setEventStep(int step)
|
---|
987 | {
|
---|
988 | eventStep = step;
|
---|
989 | }
|
---|
990 | /************************************************************
|
---|
991 | * EVENT STEPPING
|
---|
992 | ************************************************************/
|
---|
993 | void RawDataViewer::eventStepping(bool plus)
|
---|
994 | {
|
---|
995 | if (plus)
|
---|
996 | rowNum += eventStep;
|
---|
997 | else
|
---|
998 | rowNum -= eventStep;
|
---|
999 | if (rowNum >= nRows)
|
---|
1000 | rowNum -= nRows;
|
---|
1001 | if (rowNum < 0)
|
---|
1002 | rowNum += nRows;
|
---|
1003 | #ifdef LOAD_RAW
|
---|
1004 | eventNum+=eventStep;
|
---|
1005 | #else
|
---|
1006 | if (inputFile == NULL)
|
---|
1007 | return;
|
---|
1008 | inputFile->GetRow(rowNum);
|
---|
1009 | #endif
|
---|
1010 |
|
---|
1011 | updateGL();
|
---|
1012 | emit signalCurrentEvent(eventNum);
|
---|
1013 | emit signalCurrentPixel(selectedPixel);
|
---|
1014 |
|
---|
1015 | }
|
---|
1016 | /************************************************************
|
---|
1017 | * NEXT SLICE. deprec ?
|
---|
1018 | ************************************************************/
|
---|
1019 | void RawDataViewer::nextSlice()
|
---|
1020 | {
|
---|
1021 | whichSlice++;
|
---|
1022 | if (whichSlice >= nRoi)
|
---|
1023 | {
|
---|
1024 | if (!loopCurrentEvent)
|
---|
1025 | {
|
---|
1026 | int backupStep = eventStep;
|
---|
1027 | eventStep = 1;
|
---|
1028 | eventStepping(true);
|
---|
1029 | eventStep = backupStep;
|
---|
1030 | }
|
---|
1031 | whichSlice=0;
|
---|
1032 | }
|
---|
1033 | emit signalCurrentSlice(whichSlice);
|
---|
1034 | updateGL();
|
---|
1035 | }
|
---|
1036 | void RawDataViewer::previousSlice()
|
---|
1037 | {
|
---|
1038 | whichSlice--;
|
---|
1039 | if (whichSlice < 0)
|
---|
1040 | {
|
---|
1041 | if (!loopCurrentEvent)
|
---|
1042 | {
|
---|
1043 | int backupStep = eventStep;
|
---|
1044 | eventStep = 1;
|
---|
1045 | eventStepping(false);
|
---|
1046 | eventStep = backupStep;
|
---|
1047 | }
|
---|
1048 | whichSlice = nRoi-1;
|
---|
1049 | }
|
---|
1050 | emit signalCurrentSlice(whichSlice);
|
---|
1051 | updateGL();
|
---|
1052 | }
|
---|
1053 | /************************************************************
|
---|
1054 | * UICONNECTOR CONSTRUCTOR
|
---|
1055 | ************************************************************/
|
---|
1056 | UIConnector::UIConnector(QWidget*)
|
---|
1057 | {
|
---|
1058 | timer.setInterval(10.0);
|
---|
1059 | QObject::connect(&timer, SIGNAL(timeout()),
|
---|
1060 | this, SLOT(nextSlicePlease()));
|
---|
1061 | hwID = 393;
|
---|
1062 | swID = 0;
|
---|
1063 | crateID = 9;
|
---|
1064 | boardID = 8;
|
---|
1065 | patchID = 1;
|
---|
1066 | rescaleWholeCamera = true;
|
---|
1067 | }
|
---|
1068 | void UIConnector::slicesPlusPlus()
|
---|
1069 | {
|
---|
1070 | viewer->nextSlice();
|
---|
1071 | }
|
---|
1072 | void UIConnector::slicesMinusMinus()
|
---|
1073 | {
|
---|
1074 | viewer->previousSlice();
|
---|
1075 | }
|
---|
1076 | /************************************************************
|
---|
1077 | * DRAW PATCHES CHECK CHANGE. checkbox handler
|
---|
1078 | ************************************************************/
|
---|
1079 | void UIConnector::drawPatchesCheckChange(int state)
|
---|
1080 | {
|
---|
1081 | if (state)
|
---|
1082 | viewer->drawPatch = true;
|
---|
1083 | else
|
---|
1084 | viewer->drawPatch = false;
|
---|
1085 | viewer->updateGL();
|
---|
1086 | }
|
---|
1087 | /************************************************************
|
---|
1088 | * DRAW IMPULSE CHECK CHANGE. checkbox handler
|
---|
1089 | ************************************************************/
|
---|
1090 | void UIConnector::drawImpulseCheckChange(int state)
|
---|
1091 | {
|
---|
1092 | if (state)
|
---|
1093 | viewer->drawImpulse = true;
|
---|
1094 | else
|
---|
1095 | viewer->drawImpulse = false;
|
---|
1096 | viewer->updateGL();
|
---|
1097 | }
|
---|
1098 | /************************************************************
|
---|
1099 | * DRAW BLUR CHECK CHANGE. checkbox handler
|
---|
1100 | ************************************************************/
|
---|
1101 | void UIConnector::drawBlurCheckChange(int state)
|
---|
1102 | {
|
---|
1103 | if (state)
|
---|
1104 | viewer->drawBlur = true;
|
---|
1105 | else
|
---|
1106 | viewer->drawBlur = false;
|
---|
1107 | viewer->updateGL();
|
---|
1108 | }
|
---|
1109 | void UIConnector::loopEventCheckChange(int state)
|
---|
1110 | {
|
---|
1111 | if (state)
|
---|
1112 | viewer->loopCurrentEvent = true;
|
---|
1113 | else
|
---|
1114 | viewer->loopCurrentEvent = false;
|
---|
1115 | }
|
---|
1116 | /************************************************************
|
---|
1117 | * NEXT SLICE PLEASE
|
---|
1118 | ************************************************************/
|
---|
1119 | void UIConnector::nextSlicePlease()
|
---|
1120 | {
|
---|
1121 | viewer->nextSlice();
|
---|
1122 | }
|
---|
1123 | /************************************************************
|
---|
1124 | * SET VIEWER.
|
---|
1125 | ************************************************************/
|
---|
1126 | void UIConnector::setViewer(RawDataViewer* v)
|
---|
1127 | {
|
---|
1128 | viewer = v;
|
---|
1129 | }
|
---|
1130 | /************************************************************
|
---|
1131 | * SLICES PER SECOND CHANGED. timing ui handler
|
---|
1132 | ************************************************************/
|
---|
1133 | void UIConnector::slicesPerSecondChanged(double value)
|
---|
1134 | {
|
---|
1135 | timer.setInterval(1000.0/value);
|
---|
1136 | }
|
---|
1137 | /************************************************************
|
---|
1138 | * RANGE CHANGED . colors tweaking handler
|
---|
1139 | ************************************************************/
|
---|
1140 | void UIConnector::rangeChanged0(double value)
|
---|
1141 | {
|
---|
1142 | ss[0] = (float)value;
|
---|
1143 | viewer->updateGL();
|
---|
1144 | }
|
---|
1145 | /************************************************************
|
---|
1146 | * RANGE CHANGED . colors tweaking handler
|
---|
1147 | ************************************************************/
|
---|
1148 | void UIConnector::rangeChanged1(double value)
|
---|
1149 | {
|
---|
1150 | ss[1] = (float)value;
|
---|
1151 | viewer->updateGL();
|
---|
1152 | }
|
---|
1153 | /************************************************************
|
---|
1154 | * RANGE CHANGED . colors tweaking handler
|
---|
1155 | ************************************************************/
|
---|
1156 | void UIConnector::rangeChanged2(double value)
|
---|
1157 | {
|
---|
1158 | ss[2] = (float)value;
|
---|
1159 | viewer->updateGL();
|
---|
1160 | }
|
---|
1161 | /************************************************************
|
---|
1162 | * RANGE CHANGED . colors tweaking handler
|
---|
1163 | ************************************************************/
|
---|
1164 | void UIConnector::rangeChanged3(double value)
|
---|
1165 | {
|
---|
1166 | ss[3] = (float)value;
|
---|
1167 | viewer->updateGL();
|
---|
1168 | }
|
---|
1169 | /************************************************************
|
---|
1170 | * RANGE CHANGED . colors tweaking handler
|
---|
1171 | ************************************************************/
|
---|
1172 | void UIConnector::rangeChanged4(double value)
|
---|
1173 | {
|
---|
1174 | ss[4] = (float)value;
|
---|
1175 | viewer->updateGL();
|
---|
1176 | }
|
---|
1177 | /************************************************************
|
---|
1178 | * RANGE CHANGED . colors tweaking handler
|
---|
1179 | ************************************************************/
|
---|
1180 | void UIConnector::redChanged0(double value)
|
---|
1181 | {
|
---|
1182 | rr[0] = (float)value;
|
---|
1183 | viewer->updateGL();
|
---|
1184 | }
|
---|
1185 | /************************************************************
|
---|
1186 | * RED CHANGED . colors tweaking handler
|
---|
1187 | ************************************************************/
|
---|
1188 | void UIConnector::redChanged1(double value)
|
---|
1189 | {
|
---|
1190 | rr[1] = (float)value;
|
---|
1191 | viewer->updateGL();
|
---|
1192 | }
|
---|
1193 | /************************************************************
|
---|
1194 | * RED CHANGED . colors tweaking handler
|
---|
1195 | ************************************************************/
|
---|
1196 | void UIConnector::redChanged2(double value)
|
---|
1197 | {
|
---|
1198 | rr[2] = (float)value;
|
---|
1199 | viewer->updateGL();
|
---|
1200 | }
|
---|
1201 | /************************************************************
|
---|
1202 | * RED CHANGED . colors tweaking handler
|
---|
1203 | ************************************************************/
|
---|
1204 | void UIConnector::redChanged3(double value)
|
---|
1205 | {
|
---|
1206 | rr[3] = (float)value;
|
---|
1207 | viewer->updateGL();
|
---|
1208 | }
|
---|
1209 | /************************************************************
|
---|
1210 | * RED CHANGED . colors tweaking handler
|
---|
1211 | ************************************************************/
|
---|
1212 | void UIConnector::redChanged4(double value)
|
---|
1213 | {
|
---|
1214 | rr[4] = (float)value;
|
---|
1215 | viewer->updateGL();
|
---|
1216 | }
|
---|
1217 | /************************************************************
|
---|
1218 | * GREEN CHANGED . colors tweaking handler
|
---|
1219 | ************************************************************/
|
---|
1220 | void UIConnector::greenChanged0(double value)
|
---|
1221 | {
|
---|
1222 | gg[0] = (float)value;
|
---|
1223 | viewer->updateGL();
|
---|
1224 | }
|
---|
1225 | /************************************************************
|
---|
1226 | * GREEN CHANGED . colors tweaking handler
|
---|
1227 | ************************************************************/
|
---|
1228 | void UIConnector::greenChanged1(double value)
|
---|
1229 | {
|
---|
1230 | gg[1] = (float)value;
|
---|
1231 | viewer->updateGL();
|
---|
1232 | }
|
---|
1233 | /************************************************************
|
---|
1234 | * GREEN CHANGED . colors tweaking handler
|
---|
1235 | ************************************************************/
|
---|
1236 | void UIConnector::greenChanged2(double value)
|
---|
1237 | {
|
---|
1238 | gg[2] = (float)value;
|
---|
1239 | viewer->updateGL();
|
---|
1240 | }
|
---|
1241 | /************************************************************
|
---|
1242 | * GREEN CHANGED . colors tweaking handler
|
---|
1243 | ************************************************************/
|
---|
1244 | void UIConnector::greenChanged3(double value)
|
---|
1245 | {
|
---|
1246 | gg[3] = (float)value;
|
---|
1247 | viewer->updateGL();
|
---|
1248 | }
|
---|
1249 | /************************************************************
|
---|
1250 | * GREEN CHANGED . colors tweaking handler
|
---|
1251 | ************************************************************/
|
---|
1252 | void UIConnector::greenChanged4(double value)
|
---|
1253 | {
|
---|
1254 | gg[4] = (float)value;
|
---|
1255 | viewer->updateGL();
|
---|
1256 | }
|
---|
1257 | /************************************************************
|
---|
1258 | * BLUE CHANGED . colors tweaking handler
|
---|
1259 | ************************************************************/
|
---|
1260 | void UIConnector::blueChanged0(double value)
|
---|
1261 | {
|
---|
1262 | bb[0] = (float)value;
|
---|
1263 | viewer->updateGL();
|
---|
1264 | }
|
---|
1265 | /************************************************************
|
---|
1266 | * BLUE CHANGED . colors tweaking handler
|
---|
1267 | ************************************************************/
|
---|
1268 | void UIConnector::blueChanged1(double value)
|
---|
1269 | {
|
---|
1270 | bb[1] = (float)value;
|
---|
1271 | viewer->updateGL();
|
---|
1272 | }
|
---|
1273 | /************************************************************
|
---|
1274 | * BLUE CHANGED . colors tweaking handler
|
---|
1275 | ************************************************************/
|
---|
1276 | void UIConnector::blueChanged2(double value)
|
---|
1277 | {
|
---|
1278 | bb[2] = (float)value;
|
---|
1279 | viewer->updateGL();
|
---|
1280 | }
|
---|
1281 | /************************************************************
|
---|
1282 | * BLUE CHANGED . colors tweaking handler
|
---|
1283 | ************************************************************/
|
---|
1284 | void UIConnector::blueChanged3(double value)
|
---|
1285 | {
|
---|
1286 | bb[3] = (float)value;
|
---|
1287 | viewer->updateGL();
|
---|
1288 | }
|
---|
1289 | /************************************************************
|
---|
1290 | * BLUE CHANGED . colors tweaking handler
|
---|
1291 | ************************************************************/
|
---|
1292 | void UIConnector::blueChanged4(double value)
|
---|
1293 | {
|
---|
1294 | bb[4] = (float)value;
|
---|
1295 | viewer->updateGL();
|
---|
1296 | }
|
---|
1297 | /************************************************************
|
---|
1298 | * LOAD NEW FILE CLICKED. button handler
|
---|
1299 | ************************************************************/
|
---|
1300 | void UIConnector::loadNewFileClicked()
|
---|
1301 | {
|
---|
1302 | QFileDialog dialog;
|
---|
1303 | dialog.setFileMode(QFileDialog::ExistingFile);
|
---|
1304 | dialog.open(this, SLOT(fileSelected(QString)));
|
---|
1305 | dialog.setVisible(true);
|
---|
1306 | dialog.exec();
|
---|
1307 | }
|
---|
1308 | /************************************************************
|
---|
1309 | * FILE SELECTED. return of the file open dialog handler
|
---|
1310 | ************************************************************/
|
---|
1311 | void UIConnector::fileSelected(QString file)
|
---|
1312 | {
|
---|
1313 | currentFile = file.toStdString();
|
---|
1314 | if (currentFile != "")
|
---|
1315 | viewer->openFile(currentFile);
|
---|
1316 | }
|
---|
1317 | /************************************************************
|
---|
1318 | * NEW FILE LOADED. update of the UI after a new file has been loaded
|
---|
1319 | ************************************************************/
|
---|
1320 | void UIConnector::newFileLoaded()
|
---|
1321 | {
|
---|
1322 | ostringstream str;
|
---|
1323 | str << "File loaded: " << currentFile << "\n";
|
---|
1324 | // fileLoadedLabel->setText(QString(str.str().c_str()));
|
---|
1325 | // str.str("");
|
---|
1326 | str << "Run number: " << viewer->runNumber << "\n";
|
---|
1327 | // runNumberLabel->setText(QString(str.str().c_str()));
|
---|
1328 | // str.str("");
|
---|
1329 | str << "Number of Events: " << viewer->nRows << "\n";
|
---|
1330 | str << "Number of Slices: " << viewer->nRoi << "\n";// << "/1024";
|
---|
1331 | // numberOfSlicesLabel->setText(QString(str.str().c_str()));
|
---|
1332 | // str.str("");
|
---|
1333 | str << "Number of Time Marks: " << viewer->nTM << "\n";
|
---|
1334 | // numberOfTimeMarksLabel->setText(QString(str.str().c_str()));
|
---|
1335 |
|
---|
1336 | // str.str("");
|
---|
1337 | str << "Run Type: " << viewer->runType << "\n";
|
---|
1338 | // runTypeLabel->setText(QString(str.str().c_str()));
|
---|
1339 | // str.str("");
|
---|
1340 | str << "Time of 1st data: " << viewer->firstDataTime << "\n";
|
---|
1341 | // firstTimeLabel->setText(QString(str.str().c_str()));
|
---|
1342 | // str.str("");
|
---|
1343 | str << "Time of last data: " << viewer->lastDataTime << "\n";
|
---|
1344 | // lastTimeLabel->setText(QString(str.str().c_str()));
|
---|
1345 | // str.str("");
|
---|
1346 | str << "SVN revision: " << viewer->revision << '\n';
|
---|
1347 | str << "Number of boards: " << viewer->nBoards << '\n';
|
---|
1348 | str << "Number of pixels: " << viewer->nPixels << '\n';
|
---|
1349 | str << "Number of Slices TM: " << viewer->nRoiTM << '\n';
|
---|
1350 | str << "Time system: " << viewer->timeSystem << '\n';
|
---|
1351 | str << "Date: " << viewer->creationDate << '\n';
|
---|
1352 | str << "Night: " << viewer->nightInt << '\n';
|
---|
1353 | str << "Camera: " << viewer->camera << '\n';
|
---|
1354 | str << "DAQ: " << viewer->daq << '\n';
|
---|
1355 | str << "ADC Count: " << viewer->adcCount << '\n';
|
---|
1356 | str << "NB Evts OK:" << viewer->nbOk << '\n';
|
---|
1357 | str << "NB Evts Rejected: " << viewer->nbRej << '\n';
|
---|
1358 | str << "NB Evts Bad: " << viewer->nbBad << '\n';
|
---|
1359 | extraInfoLabel->setText(QString(str.str().c_str()));
|
---|
1360 |
|
---|
1361 |
|
---|
1362 | }
|
---|
1363 | /************************************************************
|
---|
1364 | * PLAY PAUSE CLICKED. ui handler
|
---|
1365 | ************************************************************/
|
---|
1366 | void UIConnector::playPauseClicked()
|
---|
1367 | {
|
---|
1368 | if (timer.isActive())
|
---|
1369 | timer.stop();
|
---|
1370 | else
|
---|
1371 | timer.start();
|
---|
1372 | }
|
---|
1373 | /************************************************************
|
---|
1374 | * CURRENT SLICE HAS CHANGE. ui handler
|
---|
1375 | ************************************************************/
|
---|
1376 | void UIConnector::currentSliceHasChanged(int slice)
|
---|
1377 | {
|
---|
1378 | ostringstream str;
|
---|
1379 | str << "Displaying Slice " << slice;
|
---|
1380 | QString qstr(str.str().c_str());
|
---|
1381 | emit updateCurrentSliceDisplay(qstr);
|
---|
1382 |
|
---|
1383 | str.str("");
|
---|
1384 | str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
|
---|
1385 | qstr = qstr.fromStdString(str.str());
|
---|
1386 | emit updateCurrentPixelSliceValue(qstr);
|
---|
1387 |
|
---|
1388 | }
|
---|
1389 | /************************************************************
|
---|
1390 | * CURRENT EVENT HAS CHANGED. ui handler
|
---|
1391 | ************************************************************/
|
---|
1392 | double xval[4096];
|
---|
1393 | double yval[4096];
|
---|
1394 |
|
---|
1395 | void UIConnector::currentEventHasChanged(int cEvent)
|
---|
1396 | {
|
---|
1397 | ostringstream str;
|
---|
1398 | str << "Displaying Event " << cEvent;
|
---|
1399 | QString qstr(str.str().c_str());
|
---|
1400 | emit updateCurrentEventDisplay(qstr);
|
---|
1401 | //retrieve the data that we want to display
|
---|
1402 | str.str("");
|
---|
1403 | str << "PC Time: " << viewer->pcTime;
|
---|
1404 | qstr = qstr.fromStdString(str.str());
|
---|
1405 | emit updateCurrentPCTime(qstr);
|
---|
1406 |
|
---|
1407 | str.str("");
|
---|
1408 | str << "Software Trigger: " << viewer->softTrig;
|
---|
1409 | qstr = qstr.fromStdString(str.str());
|
---|
1410 | emit updateCurrentSoftTrigger(qstr);
|
---|
1411 |
|
---|
1412 | str.str("");
|
---|
1413 | str << "Trigger Type: " << viewer->triggerType;
|
---|
1414 | qstr = qstr.fromStdString(str.str());
|
---|
1415 | emit updateCurrentTriggerType(qstr);
|
---|
1416 |
|
---|
1417 | str.str("");
|
---|
1418 | str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
|
---|
1419 | qstr = qstr.fromStdString(str.str());
|
---|
1420 | emit updateCurrentPixelSliceValue(qstr);
|
---|
1421 |
|
---|
1422 | boardsTimeList->clear();
|
---|
1423 | startPixelsList->clear();
|
---|
1424 | startTimeMarksList->clear();
|
---|
1425 | triggerDelayList->clear();
|
---|
1426 | std::map<int, int> boardsHistoMap;
|
---|
1427 | for (int i=0;i <NBOARDS; i++)
|
---|
1428 | {
|
---|
1429 | str.str("");
|
---|
1430 | str << i;
|
---|
1431 | if (i<10) str << " ";
|
---|
1432 | if (i<100) str << " ";
|
---|
1433 | if (i<1000) str << " ";
|
---|
1434 | str << ": " << viewer->boardTime[i];
|
---|
1435 | boardsTimeList->addItem(QString(str.str().c_str()));
|
---|
1436 | if (boardsHistoMap.find(viewer->boardTime[i]) != boardsHistoMap.end())
|
---|
1437 | boardsHistoMap[viewer->boardTime[i]]++;
|
---|
1438 | else
|
---|
1439 | boardsHistoMap[viewer->boardTime[i]] = 1;
|
---|
1440 | }
|
---|
1441 | std::map<int, int> pixelHistoMap;
|
---|
1442 | for (int i=0;i <NPIX; i++)
|
---|
1443 | {
|
---|
1444 | str.str("");
|
---|
1445 | str << i;
|
---|
1446 | if (i<10) str << " ";
|
---|
1447 | if (i<100) str << " ";
|
---|
1448 | if (i<1000) str << " ";
|
---|
1449 | str << ": " << viewer->startPix[i];
|
---|
1450 | startPixelsList->addItem(QString(str.str().c_str()));
|
---|
1451 | if (pixelHistoMap.find(viewer->startPix[i]) != pixelHistoMap.end())
|
---|
1452 | pixelHistoMap[viewer->startPix[i]]++;
|
---|
1453 | else
|
---|
1454 | pixelHistoMap[viewer->startPix[i]] = 1;
|
---|
1455 | }
|
---|
1456 | std::map<int, int> timeMarksMap;
|
---|
1457 | for (int i=0;i <NTMARK; i++)
|
---|
1458 | {
|
---|
1459 | str.str("");
|
---|
1460 | str << i;
|
---|
1461 | if (i<10) str << " ";
|
---|
1462 | if (i<100) str << " ";
|
---|
1463 | if (i<1000) str << " ";
|
---|
1464 | str << ": " << viewer->startTM[i];
|
---|
1465 | startTimeMarksList->addItem(QString(str.str().c_str()));
|
---|
1466 | if (timeMarksMap.find(viewer->startTM[i]) != timeMarksMap.end())
|
---|
1467 | timeMarksMap[viewer->startTM[i]]++;
|
---|
1468 | else
|
---|
1469 | timeMarksMap[viewer->startTM[i]] = 1;
|
---|
1470 | }
|
---|
1471 | std::map<int,int> delayMap;
|
---|
1472 | triggerDelayList->addItem(QString("Patch | Slice:Delay Slice:Delay..."));
|
---|
1473 | for (int i=0;i<NTMARK; i++)
|
---|
1474 | {
|
---|
1475 | str.str("");
|
---|
1476 | str << i << " | ";
|
---|
1477 | for (int j=0;j<viewer->nRoi;j++)
|
---|
1478 | {
|
---|
1479 | int value = viewer->eventData[1440*viewer->nRoi + i*viewer->nRoi + j];
|
---|
1480 | if (delayMap.find(value) != delayMap.end())
|
---|
1481 | delayMap[value]++;
|
---|
1482 | else
|
---|
1483 | delayMap[value] = 1;
|
---|
1484 | str << j << ":" << value << " ";
|
---|
1485 | }
|
---|
1486 | triggerDelayList->addItem(QString(str.str().c_str()));
|
---|
1487 | }
|
---|
1488 |
|
---|
1489 | std::map<int,int>::iterator it = boardsHistoMap.begin();
|
---|
1490 | int nsamples = 0;
|
---|
1491 | int previousValue = it->first-10;
|
---|
1492 | for (unsigned int i=0;i<boardsHistoMap.size();i++)
|
---|
1493 | {
|
---|
1494 | if (previousValue != it->first-1)
|
---|
1495 | {
|
---|
1496 | xval[nsamples] = previousValue+1;
|
---|
1497 | yval[nsamples] = 0;
|
---|
1498 | nsamples++;
|
---|
1499 | xval[nsamples] = it->first-1;
|
---|
1500 | yval[nsamples] = 0;
|
---|
1501 | nsamples++;
|
---|
1502 | }
|
---|
1503 | xval[nsamples] = it->first;
|
---|
1504 | yval[nsamples] = it->second;
|
---|
1505 | previousValue = it->first;
|
---|
1506 | it++;
|
---|
1507 | nsamples++;
|
---|
1508 | xval[nsamples] = previousValue;
|
---|
1509 | yval[nsamples] = 0;
|
---|
1510 | nsamples++;
|
---|
1511 | if (nsamples > 4090)
|
---|
1512 | {
|
---|
1513 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1514 | break;
|
---|
1515 | }
|
---|
1516 | }
|
---|
1517 | it--;
|
---|
1518 | xval[nsamples] = it->first+1;
|
---|
1519 | yval[nsamples] = 0;
|
---|
1520 | nsamples++;
|
---|
1521 | // if (nsamples > 5)
|
---|
1522 | #if QWT_VERSION < 0x060000
|
---|
1523 | boardsTimeHistoItem.setData(xval, yval, nsamples);
|
---|
1524 | #else
|
---|
1525 | boardsTimeHistoItem.setSamples(xval, yval, nsamples);
|
---|
1526 | #endif
|
---|
1527 |
|
---|
1528 | it = pixelHistoMap.begin();
|
---|
1529 | nsamples = 0;
|
---|
1530 | previousValue = it->first-10;
|
---|
1531 | for (unsigned int i=0;i<pixelHistoMap.size();i++)
|
---|
1532 | {
|
---|
1533 | if (previousValue != it->first-1)
|
---|
1534 | {
|
---|
1535 | xval[nsamples] = previousValue+1;
|
---|
1536 | yval[nsamples] = 0;
|
---|
1537 | nsamples++;
|
---|
1538 | xval[nsamples] = it->first-1;
|
---|
1539 | yval[nsamples] = 0;
|
---|
1540 | nsamples++;
|
---|
1541 | }
|
---|
1542 | xval[nsamples] = it->first;
|
---|
1543 | yval[nsamples] = it->second;
|
---|
1544 | previousValue = it->first;
|
---|
1545 | it++;
|
---|
1546 | nsamples++;
|
---|
1547 | xval[nsamples] = previousValue;
|
---|
1548 | yval[nsamples] = 0;
|
---|
1549 | nsamples++;
|
---|
1550 | if (nsamples > 4090)
|
---|
1551 | {
|
---|
1552 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1553 | break;
|
---|
1554 | }
|
---|
1555 | }
|
---|
1556 | it--;
|
---|
1557 | xval[nsamples] = it->first+1;
|
---|
1558 | yval[nsamples] = 0;
|
---|
1559 | nsamples++;
|
---|
1560 | // if (nsamples > 5)
|
---|
1561 | #if QWT_VERSION < 0x060000
|
---|
1562 | startCellHistoItem.setData(xval, yval, nsamples);
|
---|
1563 | #else
|
---|
1564 | startCellHistoItem.setSamples(xval, yval, nsamples);
|
---|
1565 | #endif
|
---|
1566 |
|
---|
1567 | it = timeMarksMap.begin();
|
---|
1568 | nsamples = 0;
|
---|
1569 | previousValue = it->first-10;
|
---|
1570 | for (unsigned int i=0;i<timeMarksMap.size();i++)
|
---|
1571 | {
|
---|
1572 | if (previousValue != it->first-1)
|
---|
1573 | {
|
---|
1574 | xval[nsamples] = previousValue+1;
|
---|
1575 | yval[nsamples] = 0;
|
---|
1576 | nsamples++;
|
---|
1577 | xval[nsamples] = it->first-1;
|
---|
1578 | yval[nsamples] = 0;
|
---|
1579 | nsamples++;
|
---|
1580 | }
|
---|
1581 | xval[nsamples] = it->first;
|
---|
1582 | yval[nsamples] = it->second;
|
---|
1583 | previousValue = it->first;
|
---|
1584 | it++;
|
---|
1585 | nsamples++;
|
---|
1586 | xval[nsamples] = previousValue;
|
---|
1587 | yval[nsamples] = 0;
|
---|
1588 | nsamples++;
|
---|
1589 | if (nsamples > 4090)
|
---|
1590 | {
|
---|
1591 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1592 | break;
|
---|
1593 | }
|
---|
1594 | }
|
---|
1595 | it--;
|
---|
1596 | xval[nsamples] = it->first+1;
|
---|
1597 | yval[nsamples] = 0;
|
---|
1598 | nsamples++;
|
---|
1599 | // if (nsamples > 5)
|
---|
1600 | #if QWT_VERSION < 0x060000
|
---|
1601 | startTimeMarkHistoItem.setData(xval, yval, nsamples);
|
---|
1602 | #else
|
---|
1603 | startTimeMarkHistoItem.setSamples(xval, yval, nsamples);
|
---|
1604 | #endif
|
---|
1605 |
|
---|
1606 | it = delayMap.begin();
|
---|
1607 | nsamples = 0;
|
---|
1608 | previousValue = it->first-10;
|
---|
1609 | for (unsigned int i=0;i<delayMap.size();i++)
|
---|
1610 | {
|
---|
1611 | if (previousValue != it->first-1)
|
---|
1612 | {
|
---|
1613 | xval[nsamples] = previousValue+1;
|
---|
1614 | yval[nsamples] = 0;
|
---|
1615 | nsamples++;
|
---|
1616 | xval[nsamples] = it->first-1;
|
---|
1617 | yval[nsamples] = 0;
|
---|
1618 | nsamples++;
|
---|
1619 | }
|
---|
1620 | xval[nsamples] = it->first;
|
---|
1621 | yval[nsamples] = it->second;
|
---|
1622 | previousValue = it->first;
|
---|
1623 | it++;
|
---|
1624 | nsamples++;
|
---|
1625 | xval[nsamples] = previousValue;
|
---|
1626 | yval[nsamples] = 0;
|
---|
1627 | nsamples++;
|
---|
1628 | if (nsamples > 4090)
|
---|
1629 | {
|
---|
1630 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1631 | break;
|
---|
1632 | }
|
---|
1633 | }
|
---|
1634 | it--;
|
---|
1635 | xval[nsamples] = it->first+1;
|
---|
1636 | yval[nsamples] = 0;
|
---|
1637 | nsamples++;
|
---|
1638 | // if (nsamples > 5)
|
---|
1639 | #if QWT_VERSION < 0x060000
|
---|
1640 | triggerDelayHistoItem.setData(xval, yval, nsamples);
|
---|
1641 | #else
|
---|
1642 | triggerDelayHistoItem.setSamples(xval, yval, nsamples);
|
---|
1643 | #endif
|
---|
1644 |
|
---|
1645 |
|
---|
1646 | // startCellHistoZoom->setZoomBase(startCellHistoItem.boundingRect());
|
---|
1647 | QStack< QRectF > stack;
|
---|
1648 | stack.push(boardsTimeHistoItem.boundingRect());
|
---|
1649 | boardsTimeHistoZoom->setZoomStack(stack);
|
---|
1650 | stack.pop();
|
---|
1651 | stack.push(startCellHistoItem.boundingRect());
|
---|
1652 | startCellHistoZoom->setZoomStack(stack);
|
---|
1653 | stack.pop();
|
---|
1654 | stack.push(startTimeMarkHistoItem.boundingRect());
|
---|
1655 | startTimeMarkHistoZoom->setZoomStack(stack);
|
---|
1656 | stack.pop();
|
---|
1657 | stack.push(triggerDelayHistoItem.boundingRect());
|
---|
1658 | triggerDelayHistoZoom->setZoomStack(stack);
|
---|
1659 | stack.pop();
|
---|
1660 | pixelChanged(viewer->selectedPixel);
|
---|
1661 |
|
---|
1662 |
|
---|
1663 |
|
---|
1664 | }
|
---|
1665 |
|
---|
1666 | void UIConnector::initHistograms()
|
---|
1667 | {
|
---|
1668 | // QwtPlot* boardsTimeHisto;
|
---|
1669 | // QwtPlotHistogram boardsTimeHistoItem;
|
---|
1670 | QwtPlotGrid* grid = new QwtPlotGrid;
|
---|
1671 | grid->enableX(false);
|
---|
1672 | grid->enableY(true);
|
---|
1673 | grid->enableXMin(false);
|
---|
1674 | grid->enableYMin(false);
|
---|
1675 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1676 | grid->attach(boardsTimeHisto);
|
---|
1677 |
|
---|
1678 | grid = new QwtPlotGrid;
|
---|
1679 | grid->enableX(false);
|
---|
1680 | grid->enableY(true);
|
---|
1681 | grid->enableXMin(false);
|
---|
1682 | grid->enableYMin(false);
|
---|
1683 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1684 | grid->attach(startCellHisto);
|
---|
1685 |
|
---|
1686 | grid = new QwtPlotGrid;
|
---|
1687 | grid->enableX(false);
|
---|
1688 | grid->enableY(true);
|
---|
1689 | grid->enableXMin(false);
|
---|
1690 | grid->enableYMin(false);
|
---|
1691 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1692 | grid->attach(startTimeMarkHisto);
|
---|
1693 |
|
---|
1694 | grid = new QwtPlotGrid;
|
---|
1695 | grid->enableX(false);
|
---|
1696 | grid->enableY(true);
|
---|
1697 | grid->enableXMin(false);
|
---|
1698 | grid->enableYMin(false);
|
---|
1699 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1700 | grid->attach(pixelValueCurve);
|
---|
1701 |
|
---|
1702 | grid = new QwtPlotGrid;
|
---|
1703 | grid->enableX(false);
|
---|
1704 | grid->enableY(true);
|
---|
1705 | grid->enableXMin(false);
|
---|
1706 | grid->enableYMin(false);
|
---|
1707 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1708 | grid->attach(triggerDelayHisto);
|
---|
1709 |
|
---|
1710 |
|
---|
1711 | boardsTimeHisto->setAutoReplot(true);
|
---|
1712 | startCellHisto->setAutoReplot(true);
|
---|
1713 | startTimeMarkHisto->setAutoReplot(true);
|
---|
1714 | pixelValueCurve->setAutoReplot(true);
|
---|
1715 | triggerDelayHisto->setAutoReplot(true);
|
---|
1716 | boardsTimeHisto->setTitle("Boards time values");
|
---|
1717 | startCellHisto->setTitle("Start Cell values");
|
---|
1718 | startTimeMarkHisto->setTitle("Start Time Marks values");
|
---|
1719 | pixelValueCurve->setTitle("Current pixel values");
|
---|
1720 | triggerDelayHisto->setTitle("Trigger Delays");
|
---|
1721 |
|
---|
1722 | // boardsTimeHistoItem.setBrush(QBrush(Qt::red));
|
---|
1723 | // startCellHistoItem.setBrush(QBrush(Qt::red));
|
---|
1724 | // startTimeMarkHistoItem.setBrush(QBrush(Qt::red));
|
---|
1725 | // triggerDelayHistoItem.setBrush(QBrush(Qt::red));
|
---|
1726 | // pixelValueCurveItem.setBrush(QBrush(Qt::red));
|
---|
1727 |
|
---|
1728 | boardsTimeHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1729 | boardsTimeHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1730 | startCellHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1731 | startCellHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1732 | startTimeMarkHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1733 | startTimeMarkHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1734 | triggerDelayHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1735 | triggerDelayHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1736 |
|
---|
1737 | boardsTimeHistoItem.attach(boardsTimeHisto);
|
---|
1738 | startCellHistoItem.attach(startCellHisto);
|
---|
1739 | startTimeMarkHistoItem.attach(startTimeMarkHisto);
|
---|
1740 | triggerDelayHistoItem.attach(triggerDelayHisto);
|
---|
1741 |
|
---|
1742 | //curve
|
---|
1743 | // pixelValueCurveItem.setSymbol(new QwtSymbol(QwtSymbol::Cross, Qt::NoBrush, QPen(Qt::black), QSize(5,5)));
|
---|
1744 | pixelValueCurveItem.setPen(QColor(Qt::darkGreen));
|
---|
1745 | pixelValueCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
1746 | // pixelValueCurveItem.setCurveAttribute(QwtPlotCurve::Fitted);
|
---|
1747 | pixelValueCurveItem.attach(pixelValueCurve);
|
---|
1748 |
|
---|
1749 | //FIXME delete these pointers with the destructor
|
---|
1750 | curveZoom = new QwtPlotZoomer(pixelValueCurve->canvas());
|
---|
1751 | curveZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1752 | curveZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1753 | boardsTimeHistoZoom = new QwtPlotZoomer(boardsTimeHisto->canvas());
|
---|
1754 | boardsTimeHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1755 | boardsTimeHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1756 | startCellHistoZoom = new QwtPlotZoomer(startCellHisto->canvas());
|
---|
1757 | startCellHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1758 | startCellHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1759 | startTimeMarkHistoZoom = new QwtPlotZoomer(startTimeMarkHisto->canvas());
|
---|
1760 | startTimeMarkHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1761 | startTimeMarkHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1762 | triggerDelayHistoZoom = new QwtPlotZoomer(triggerDelayHisto->canvas());
|
---|
1763 | triggerDelayHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1764 | triggerDelayHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1765 |
|
---|
1766 |
|
---|
1767 | }
|
---|
1768 | void UIConnector::pixelChanged(int pixel)
|
---|
1769 | {
|
---|
1770 | if (!viewer->nRoi)
|
---|
1771 | return;
|
---|
1772 |
|
---|
1773 | for (int i=0;i<viewer->nRoi;i++)
|
---|
1774 | {
|
---|
1775 | xval[i] = i;
|
---|
1776 | #ifdef LOAD_RAW
|
---|
1777 | yval[i] = eventsData[0][pixel][i];
|
---|
1778 | #else
|
---|
1779 | yval[i] = viewer->eventData[viewer->nRoi*pixel + i];
|
---|
1780 | #endif
|
---|
1781 | }
|
---|
1782 | #if QWT_VERSION < 0x060000
|
---|
1783 | pixelValueCurveItem.setRawData(xval, yval, viewer->nRoi);
|
---|
1784 | #else
|
---|
1785 | pixelValueCurveItem.setRawSamples(xval, yval, viewer->nRoi);
|
---|
1786 | #endif
|
---|
1787 |
|
---|
1788 | QStack< QRectF > stack;
|
---|
1789 | stack.push(pixelValueCurveItem.boundingRect());
|
---|
1790 | curveZoom->setZoomStack(stack);
|
---|
1791 | stack.pop();
|
---|
1792 |
|
---|
1793 | hwID = pixel;
|
---|
1794 | swID = viewer->softwareMapping[pixel];
|
---|
1795 | crateID = (pixel/4)/10;
|
---|
1796 | boardID = (pixel/4)%10;
|
---|
1797 | patchID = pixel%4;
|
---|
1798 | HwIDBox->setValue(hwID);
|
---|
1799 | SwIDBox->setValue(swID);
|
---|
1800 | crateIDBox->setValue(crateID);
|
---|
1801 | boardIDBox->setValue(boardID);
|
---|
1802 | patchIDBox->setValue(patchID);
|
---|
1803 |
|
---|
1804 | ostringstream str;
|
---|
1805 | QString qstr;
|
---|
1806 | str.str("");
|
---|
1807 | str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
|
---|
1808 | qstr = qstr.fromStdString(str.str());
|
---|
1809 | emit updateCurrentPixelSliceValue(qstr);
|
---|
1810 |
|
---|
1811 | // cout << "Pixel: " << viewer->softwareMapping[pixel] << " Hardware ID: " << pixel << " Patch: " << pixel%4;
|
---|
1812 | // cout << " Board: " << (pixel/4)%10 << " Crate: " << (pixel/4)/10 << endl;
|
---|
1813 |
|
---|
1814 | // curveZoom->setZoomBase();
|
---|
1815 | // cout << "pixel changed ! " << pixel << endl;
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 | void UIConnector::hwIDChanged(int hwid)
|
---|
1819 | {
|
---|
1820 | hwID = hwid;
|
---|
1821 | swID = viewer->softwareMapping[hwid];
|
---|
1822 | crateID = (hwid/4)/10;
|
---|
1823 | boardID = (hwid/4)%10;
|
---|
1824 | patchID = hwid%4;
|
---|
1825 | HwIDBox->setValue(hwID);
|
---|
1826 | SwIDBox->setValue(swID);
|
---|
1827 | crateIDBox->setValue(crateID);
|
---|
1828 | boardIDBox->setValue(boardID);
|
---|
1829 | patchIDBox->setValue(patchID);
|
---|
1830 |
|
---|
1831 | viewer->selectedPixel = hwid;
|
---|
1832 | pixelChanged(hwid);
|
---|
1833 | viewer->updateGL();
|
---|
1834 |
|
---|
1835 | }
|
---|
1836 | void UIConnector::swIDChanged(int swid)
|
---|
1837 | {
|
---|
1838 | swID = swid;
|
---|
1839 | hwID = viewer->hardwareMapping[swid];
|
---|
1840 | crateID = (hwID/4)/10;
|
---|
1841 | boardID = (hwID/4)%10;
|
---|
1842 | patchID = hwID%4;
|
---|
1843 | HwIDBox->setValue(hwID);
|
---|
1844 | SwIDBox->setValue(swID);
|
---|
1845 | crateIDBox->setValue(crateID);
|
---|
1846 | boardIDBox->setValue(boardID);
|
---|
1847 | patchIDBox->setValue(patchID);
|
---|
1848 |
|
---|
1849 | viewer->selectedPixel = hwID;
|
---|
1850 | pixelChanged(hwID);
|
---|
1851 | viewer->updateGL();
|
---|
1852 | }
|
---|
1853 | void UIConnector::crateIDChanged(int cid)
|
---|
1854 | {
|
---|
1855 | crateID = cid;
|
---|
1856 | hwID = 40*crateID + 4*boardID + patchID;
|
---|
1857 | swID = viewer->softwareMapping[hwID];
|
---|
1858 | HwIDBox->setValue(hwID);
|
---|
1859 | SwIDBox->setValue(swID);
|
---|
1860 | viewer->selectedPixel = hwID;
|
---|
1861 | pixelChanged(hwID);
|
---|
1862 | viewer->updateGL();
|
---|
1863 | }
|
---|
1864 | void UIConnector::boardIDChanged(int bid)
|
---|
1865 | {
|
---|
1866 | boardID = bid;
|
---|
1867 | hwID = 40*crateID + 4*boardID + patchID;
|
---|
1868 | swID = viewer->softwareMapping[hwID];
|
---|
1869 | HwIDBox->setValue(hwID);
|
---|
1870 | SwIDBox->setValue(swID);
|
---|
1871 | viewer->selectedPixel = hwID;
|
---|
1872 | pixelChanged(hwID);
|
---|
1873 | viewer->updateGL();
|
---|
1874 | }
|
---|
1875 | void UIConnector::patchIDChanged(int pid)
|
---|
1876 | {
|
---|
1877 | patchID = pid;
|
---|
1878 | hwID = 40*crateID + 4*boardID + patchID;
|
---|
1879 | swID = viewer->softwareMapping[hwID];
|
---|
1880 | HwIDBox->setValue(hwID);
|
---|
1881 | SwIDBox->setValue(swID);
|
---|
1882 | viewer->selectedPixel = hwID;
|
---|
1883 | pixelChanged(hwID);
|
---|
1884 | viewer->updateGL();
|
---|
1885 | }
|
---|
1886 | void UIConnector::autoScalePressed()
|
---|
1887 | {
|
---|
1888 | if (!viewer->nRoi)
|
---|
1889 | return;
|
---|
1890 | int start, end;
|
---|
1891 | if (rescaleWholeCamera)
|
---|
1892 | {
|
---|
1893 | start = 0;
|
---|
1894 | end = 1440;
|
---|
1895 | }
|
---|
1896 | else
|
---|
1897 | {
|
---|
1898 | start = viewer->selectedPixel;
|
---|
1899 | end = viewer->selectedPixel+1;
|
---|
1900 | }
|
---|
1901 |
|
---|
1902 | int min = 10000; //real min = -2048
|
---|
1903 | int max = -10000; //real max = 2047
|
---|
1904 | long average = 0;
|
---|
1905 | int numSamples = 0;
|
---|
1906 | for (int i=start;i<end;i++)
|
---|
1907 | {
|
---|
1908 | for (int j=0;j<viewer->nRoi;j++)
|
---|
1909 | {
|
---|
1910 | int cValue = viewer->eventData[i*viewer->nRoi+j];
|
---|
1911 | if (cValue > max)
|
---|
1912 | max = cValue;
|
---|
1913 | if (cValue < min)
|
---|
1914 | min = cValue;
|
---|
1915 | average+=cValue;
|
---|
1916 | numSamples++;
|
---|
1917 | }
|
---|
1918 | }
|
---|
1919 | average /= numSamples;
|
---|
1920 |
|
---|
1921 | double minRange = (double)(min+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
1922 | double maxRange = (double)(max+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
1923 | double midRange = (double)(average+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
1924 | ss[0] = minRange;
|
---|
1925 | range0->setValue(ss[0]);
|
---|
1926 | ss[4] = maxRange;
|
---|
1927 | range4->setValue(ss[4]);
|
---|
1928 | ss[2] = midRange;
|
---|
1929 | range2->setValue(ss[2]);
|
---|
1930 | ss[1] = (minRange+midRange)/2;
|
---|
1931 | range1->setValue(ss[1]);
|
---|
1932 | ss[3] = (maxRange+midRange)/2;
|
---|
1933 | range3->setValue(ss[3]);
|
---|
1934 |
|
---|
1935 |
|
---|
1936 | }
|
---|
1937 | void UIConnector::entireCameraChanged(bool state)
|
---|
1938 | {
|
---|
1939 | if (state)
|
---|
1940 | {
|
---|
1941 | rescaleWholeCamera = true;
|
---|
1942 | currentPixelScale->setChecked(false);
|
---|
1943 | }
|
---|
1944 | else
|
---|
1945 | {
|
---|
1946 | rescaleWholeCamera = false;
|
---|
1947 | currentPixelScale->setChecked(true);
|
---|
1948 | }
|
---|
1949 | }
|
---|
1950 | void UIConnector::currentPixelChanged(bool state)
|
---|
1951 | {
|
---|
1952 |
|
---|
1953 | if (state)
|
---|
1954 | {
|
---|
1955 | rescaleWholeCamera = false;
|
---|
1956 | entireCameraScale->setChecked(false);
|
---|
1957 | }
|
---|
1958 | else
|
---|
1959 | {
|
---|
1960 | rescaleWholeCamera = true;
|
---|
1961 | entireCameraScale->setChecked(true);
|
---|
1962 | }
|
---|
1963 | }
|
---|
1964 | void PrintHelp()
|
---|
1965 | {
|
---|
1966 | cout <<
|
---|
1967 | "\n"
|
---|
1968 | << endl;
|
---|
1969 | }
|
---|
1970 | void SetupConfiguration(Configuration& conf)
|
---|
1971 | {
|
---|
1972 | po::options_description configs("Raw Events Viewer Options");
|
---|
1973 | configs.add_options()
|
---|
1974 | ("color.range", vars<double>(), "Range of the display colours")
|
---|
1975 | ("color.red", vars<double>(), "Range of red values")
|
---|
1976 | ("color.rreen", vars<double>(), "Range of green values")
|
---|
1977 | ("color.blue", vars<double>(), "Range of blue values")
|
---|
1978 | ("file,f", var<string>(), "File to be loaded at startup")
|
---|
1979 | ;
|
---|
1980 | conf.AddOptions(configs);
|
---|
1981 |
|
---|
1982 | po::positional_options_description p;
|
---|
1983 | p.add("file", 1); // The first positional options
|
---|
1984 | conf.SetArgumentPositions(p);
|
---|
1985 |
|
---|
1986 | }
|
---|
1987 | /************************************************************
|
---|
1988 | * MAIN PROGRAM FUNCTION.
|
---|
1989 | ************************************************************/
|
---|
1990 | int main(int argc, char *argv[])
|
---|
1991 | {
|
---|
1992 | Configuration conf(argv[0]);
|
---|
1993 | conf.SetPrintUsage(PrintHelp);
|
---|
1994 | SetupConfiguration(conf);
|
---|
1995 | if (!conf.DoParse(argc, const_cast<const char**>(argv), PrintHelp))
|
---|
1996 | return -1;
|
---|
1997 |
|
---|
1998 | if (conf.Has("color.range"))
|
---|
1999 | {
|
---|
2000 | vector<double> value = conf.Vec<double>("color.range");
|
---|
2001 | if (value.size() != 5)
|
---|
2002 | {
|
---|
2003 | cout << "Error, colorRange option should have exactly 5 double values" << endl;
|
---|
2004 | return -1;
|
---|
2005 | }
|
---|
2006 | for (int i=0;i<5;i++)
|
---|
2007 | ss[i] = value[i];
|
---|
2008 | }
|
---|
2009 |
|
---|
2010 | if (conf.Has("color.red"))
|
---|
2011 | {
|
---|
2012 | vector<double> value = conf.Vec<double>("color.red");
|
---|
2013 | if (value.size() != 5)
|
---|
2014 | {
|
---|
2015 | cout << "Error, colorRed option should have exactly 5 double values" << endl;
|
---|
2016 | return -1;
|
---|
2017 | }
|
---|
2018 | for (int i=0;i<5;i++)
|
---|
2019 | rr[i] = value[i];
|
---|
2020 | }
|
---|
2021 |
|
---|
2022 | if (conf.Has("color.green"))
|
---|
2023 | {
|
---|
2024 | vector<double> value = conf.Vec<double>("color.green");
|
---|
2025 | if (value.size() != 5)
|
---|
2026 | {
|
---|
2027 | cout << "Error, colorGreen option should have exactly 5 double values" << endl;
|
---|
2028 | return -1;
|
---|
2029 | }
|
---|
2030 | for (int i=0;i<5;i++)
|
---|
2031 | gg[i] = value[i];
|
---|
2032 | }
|
---|
2033 |
|
---|
2034 | if (conf.Has("color.blue"))
|
---|
2035 | {
|
---|
2036 | vector<double> value = conf.Vec<double>("color.blue");
|
---|
2037 | if (value.size() != 5)
|
---|
2038 | {
|
---|
2039 | cout << "Error, colorBlue option should have exactly 5 double values" << endl;
|
---|
2040 | return -1;
|
---|
2041 | }
|
---|
2042 | for (int i=0;i<5;i++)
|
---|
2043 | bb[i] = value[i];
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 | QApplication app(argc, argv);
|
---|
2047 |
|
---|
2048 | if (!QGLFormat::hasOpenGL()) {
|
---|
2049 | std::cerr << "This system has no OpenGL support" << std::endl;
|
---|
2050 | return 1;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | QMainWindow mainWindow;
|
---|
2054 |
|
---|
2055 | Ui_MainWindow myUi;
|
---|
2056 | myUi.setupUi(&mainWindow);
|
---|
2057 |
|
---|
2058 | RawDataViewer *canvas = myUi.GLWindow;
|
---|
2059 |
|
---|
2060 | QObject::connect(myUi.eventsMinusButton, SIGNAL(clicked()),
|
---|
2061 | canvas, SLOT(minusEvent()));
|
---|
2062 | QObject::connect(myUi.eventsPlusButton, SIGNAL(clicked()),
|
---|
2063 | canvas, SLOT(plusEvent()));
|
---|
2064 | QObject::connect(myUi.eventsStepBox, SIGNAL(valueChanged(int)),
|
---|
2065 | canvas, SLOT(setEventStep(int)));
|
---|
2066 | myUi.colorRange0->setValue(ss[0]);
|
---|
2067 | myUi.colorRange1->setValue(ss[1]);
|
---|
2068 | myUi.colorRange2->setValue(ss[2]);
|
---|
2069 | myUi.colorRange3->setValue(ss[3]);
|
---|
2070 | myUi.colorRange4->setValue(ss[4]);
|
---|
2071 | myUi.redValue0->setValue(rr[0]);
|
---|
2072 | myUi.redValue1->setValue(rr[1]);
|
---|
2073 | myUi.redValue2->setValue(rr[2]);
|
---|
2074 | myUi.redValue3->setValue(rr[3]);
|
---|
2075 | myUi.redValue4->setValue(rr[4]);
|
---|
2076 | myUi.greenValue0->setValue(gg[0]);
|
---|
2077 | myUi.greenValue1->setValue(gg[1]);
|
---|
2078 | myUi.greenValue2->setValue(gg[2]);
|
---|
2079 | myUi.greenValue3->setValue(gg[3]);
|
---|
2080 | myUi.greenValue4->setValue(gg[4]);
|
---|
2081 | myUi.blueValue0->setValue(bb[0]);
|
---|
2082 | myUi.blueValue1->setValue(bb[1]);
|
---|
2083 | myUi.blueValue2->setValue(bb[2]);
|
---|
2084 | myUi.blueValue3->setValue(bb[3]);
|
---|
2085 | myUi.blueValue4->setValue(bb[4]);
|
---|
2086 |
|
---|
2087 | UIConnector connector;
|
---|
2088 | connector.setViewer(canvas);
|
---|
2089 | connector.boardsTimeList = myUi.boardsTimeList;
|
---|
2090 | connector.boardsTimeHisto = myUi.boardsTimeHisto;
|
---|
2091 | connector.startPixelsList = myUi.startPixelsList;
|
---|
2092 | connector.startCellHisto = myUi.startCellsHisto;
|
---|
2093 | connector.startTimeMarkHisto = myUi.startTimeMarkHisto;
|
---|
2094 | connector.pixelValueCurve = myUi.pixelValueCurve;
|
---|
2095 | connector.triggerDelayHisto = myUi.triggerDelayHisto;
|
---|
2096 | connector.triggerDelayList = myUi.triggerDelayList;
|
---|
2097 |
|
---|
2098 | connector.startTimeMarksList = myUi.startTimeMarksList;
|
---|
2099 | // connector.fileLoadedLabel = myUi.fileLoadedLabel;
|
---|
2100 | // connector.runNumberLabel = myUi.runNumberLabel;
|
---|
2101 | // connector.numberOfSlicesLabel = myUi.numberOfSlicesLabel;
|
---|
2102 | // connector.numberOfTimeMarksLabel = myUi.numberOfTimeMarksLabel;
|
---|
2103 | // connector.runTypeLabel = myUi.runTypeLabel;
|
---|
2104 | // connector.firstTimeLabel = myUi.timeOfFirstDataLabel;
|
---|
2105 | // connector.lastTimeLabel = myUi.timeOfLastDataLabel;
|
---|
2106 | connector.currentPixelValue = myUi.currentPixelValue;
|
---|
2107 |
|
---|
2108 | connector.currentPixelScale = myUi.currentPixelScale;
|
---|
2109 | connector.entireCameraScale = myUi.entireCameraScale;
|
---|
2110 |
|
---|
2111 | connector.extraInfoLabel = myUi.extraInfoLabel;
|
---|
2112 |
|
---|
2113 | connector.HwIDBox = myUi.HwIDBox;
|
---|
2114 | connector.SwIDBox = myUi.SwIDBox;
|
---|
2115 | connector.crateIDBox = myUi.crateIDBox;
|
---|
2116 | connector.boardIDBox = myUi.boardIDBox;
|
---|
2117 | connector.patchIDBox = myUi.patchIDBox;
|
---|
2118 |
|
---|
2119 | connector.range0 = myUi.colorRange0;
|
---|
2120 | connector.range1 = myUi.colorRange1;
|
---|
2121 | connector.range2 = myUi.colorRange2;
|
---|
2122 | connector.range3 = myUi.colorRange3;
|
---|
2123 | connector.range4 = myUi.colorRange4;
|
---|
2124 |
|
---|
2125 | connector.initHistograms();
|
---|
2126 |
|
---|
2127 | QObject::connect(myUi.slicesPlusPlusButton, SIGNAL(clicked()),
|
---|
2128 | &connector, SLOT(slicesPlusPlus()));
|
---|
2129 | QObject::connect(myUi.slicesMinusMinusButton, SIGNAL(clicked()),
|
---|
2130 | &connector, SLOT(slicesMinusMinus()));
|
---|
2131 | QObject::connect(myUi.autoScaleColor, SIGNAL(clicked()),
|
---|
2132 | &connector, SLOT(autoScalePressed()));
|
---|
2133 | QObject::connect(myUi.currentPixelScale, SIGNAL(toggled(bool)),
|
---|
2134 | &connector, SLOT(currentPixelChanged(bool)));
|
---|
2135 | QObject::connect(myUi.entireCameraScale, SIGNAL(toggled(bool)),
|
---|
2136 | &connector, SLOT(entireCameraChanged(bool)));
|
---|
2137 |
|
---|
2138 | QObject::connect(myUi.HwIDBox, SIGNAL(valueChanged(int)),
|
---|
2139 | &connector, SLOT(hwIDChanged(int)));
|
---|
2140 | QObject::connect(myUi.SwIDBox, SIGNAL(valueChanged(int)),
|
---|
2141 | &connector, SLOT(swIDChanged(int)));
|
---|
2142 | QObject::connect(myUi.crateIDBox, SIGNAL(valueChanged(int)),
|
---|
2143 | &connector, SLOT(crateIDChanged(int)));
|
---|
2144 | QObject::connect(myUi.boardIDBox, SIGNAL(valueChanged(int)),
|
---|
2145 | &connector, SLOT(boardIDChanged(int)));
|
---|
2146 | QObject::connect(myUi.patchIDBox, SIGNAL(valueChanged(int)),
|
---|
2147 | &connector, SLOT(patchIDChanged(int)));
|
---|
2148 |
|
---|
2149 | // connector.pixelChanged(0);
|
---|
2150 | QObject::connect(canvas, SIGNAL(signalCurrentPixel(int)),
|
---|
2151 | &connector, SLOT(pixelChanged(int)));
|
---|
2152 | QObject::connect(myUi.drawPatchCheckBox, SIGNAL(stateChanged(int)),
|
---|
2153 | &connector, SLOT(drawPatchesCheckChange(int)));
|
---|
2154 | QObject::connect(myUi.drawImpulseCheckBox, SIGNAL(stateChanged(int)),
|
---|
2155 | &connector, SLOT(drawImpulseCheckChange(int)));
|
---|
2156 | QObject::connect(myUi.drawBlurCheckBox, SIGNAL(stateChanged(int)),
|
---|
2157 | &connector, SLOT(drawBlurCheckChange(int)));
|
---|
2158 | QObject::connect(myUi.loopOverCurrentEventBox, SIGNAL(stateChanged(int)),
|
---|
2159 | &connector, SLOT(loopEventCheckChange(int)));
|
---|
2160 | QObject::connect(canvas, SIGNAL(newFileLoaded()),
|
---|
2161 | &connector, SLOT(newFileLoaded()));
|
---|
2162 |
|
---|
2163 | QObject::connect(myUi.loadNewFileButton, SIGNAL(clicked()),
|
---|
2164 | &connector, SLOT(loadNewFileClicked()));
|
---|
2165 |
|
---|
2166 | QObject::connect(myUi.colorRange0, SIGNAL(valueChanged(double)),
|
---|
2167 | &connector, SLOT(rangeChanged0(double)));
|
---|
2168 |
|
---|
2169 | QObject::connect(myUi.colorRange1, SIGNAL(valueChanged(double)),
|
---|
2170 | &connector, SLOT(rangeChanged1(double)));
|
---|
2171 |
|
---|
2172 | QObject::connect(myUi.colorRange2, SIGNAL(valueChanged(double)),
|
---|
2173 | &connector, SLOT(rangeChanged2(double)));
|
---|
2174 |
|
---|
2175 | QObject::connect(myUi.colorRange3, SIGNAL(valueChanged(double)),
|
---|
2176 | &connector, SLOT(rangeChanged3(double)));
|
---|
2177 |
|
---|
2178 | QObject::connect(myUi.colorRange4, SIGNAL(valueChanged(double)),
|
---|
2179 | &connector, SLOT(rangeChanged4(double)));
|
---|
2180 |
|
---|
2181 | QObject::connect(myUi.redValue0, SIGNAL(valueChanged(double)),
|
---|
2182 | &connector, SLOT(redChanged0(double)));
|
---|
2183 |
|
---|
2184 | QObject::connect(myUi.redValue1, SIGNAL(valueChanged(double)),
|
---|
2185 | &connector, SLOT(redChanged1(double)));
|
---|
2186 |
|
---|
2187 | QObject::connect(myUi.redValue2, SIGNAL(valueChanged(double)),
|
---|
2188 | &connector, SLOT(redChanged2(double)));
|
---|
2189 |
|
---|
2190 | QObject::connect(myUi.redValue3, SIGNAL(valueChanged(double)),
|
---|
2191 | &connector, SLOT(redChanged3(double)));
|
---|
2192 |
|
---|
2193 | QObject::connect(myUi.redValue4, SIGNAL(valueChanged(double)),
|
---|
2194 | &connector, SLOT(redChanged4(double)));
|
---|
2195 |
|
---|
2196 | QObject::connect(myUi.greenValue0, SIGNAL(valueChanged(double)),
|
---|
2197 | &connector, SLOT(greenChanged0(double)));
|
---|
2198 |
|
---|
2199 | QObject::connect(myUi.greenValue1, SIGNAL(valueChanged(double)),
|
---|
2200 | &connector, SLOT(greenChanged1(double)));
|
---|
2201 |
|
---|
2202 | QObject::connect(myUi.greenValue2, SIGNAL(valueChanged(double)),
|
---|
2203 | &connector, SLOT(greenChanged2(double)));
|
---|
2204 |
|
---|
2205 | QObject::connect(myUi.greenValue3, SIGNAL(valueChanged(double)),
|
---|
2206 | &connector, SLOT(greenChanged3(double)));
|
---|
2207 |
|
---|
2208 | QObject::connect(myUi.greenValue4, SIGNAL(valueChanged(double)),
|
---|
2209 | &connector, SLOT(greenChanged4(double)));
|
---|
2210 |
|
---|
2211 | QObject::connect(myUi.blueValue0, SIGNAL(valueChanged(double)),
|
---|
2212 | &connector, SLOT(blueChanged0(double)));
|
---|
2213 |
|
---|
2214 | QObject::connect(myUi.blueValue1, SIGNAL(valueChanged(double)),
|
---|
2215 | &connector, SLOT(blueChanged1(double)));
|
---|
2216 |
|
---|
2217 | QObject::connect(myUi.blueValue2, SIGNAL(valueChanged(double)),
|
---|
2218 | &connector, SLOT(blueChanged2(double)));
|
---|
2219 |
|
---|
2220 | QObject::connect(myUi.blueValue3, SIGNAL(valueChanged(double)),
|
---|
2221 | &connector, SLOT(blueChanged3(double)));
|
---|
2222 |
|
---|
2223 | QObject::connect(myUi.blueValue4, SIGNAL(valueChanged(double)),
|
---|
2224 | &connector, SLOT(blueChanged4(double)));
|
---|
2225 |
|
---|
2226 | QObject::connect(myUi.slicesPerSecValue, SIGNAL(valueChanged(double)),
|
---|
2227 | &connector, SLOT(slicesPerSecondChanged(double)));
|
---|
2228 | QObject::connect(myUi.playPauseButton, SIGNAL(clicked()),
|
---|
2229 | &connector, SLOT(playPauseClicked()));
|
---|
2230 |
|
---|
2231 | QObject::connect(canvas, SIGNAL(signalCurrentSlice(int)),
|
---|
2232 | &connector, SLOT(currentSliceHasChanged(int)));
|
---|
2233 | QObject::connect(canvas, SIGNAL(signalCurrentEvent(int)),
|
---|
2234 | &connector, SLOT(currentEventHasChanged(int)));
|
---|
2235 |
|
---|
2236 | QObject::connect(&connector, SIGNAL(updateCurrentSliceDisplay(QString)),
|
---|
2237 | myUi.displayingSliceLabel, SLOT(setText(const QString)));
|
---|
2238 | QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(QString)),
|
---|
2239 | myUi.displayingEventLabel, SLOT(setText(const QString)));
|
---|
2240 | QObject::connect(&connector, SIGNAL(updateCurrentPCTime(QString)),
|
---|
2241 | myUi.PCTimeLabel, SLOT(setText(const QString)));
|
---|
2242 | QObject::connect(&connector, SIGNAL(updateCurrentSoftTrigger(QString)),
|
---|
2243 | myUi.softwareTriggerLabel, SLOT(setText(const QString)));
|
---|
2244 | QObject::connect(&connector, SIGNAL(updateCurrentTriggerType(QString)),
|
---|
2245 | myUi.triggerTypeLabel, SLOT(setText(const QString)));
|
---|
2246 | QObject::connect(&connector, SIGNAL(updateCurrentPixelSliceValue(const QString)),
|
---|
2247 | myUi.currentPixelValue, SLOT(setText(const QString)));
|
---|
2248 |
|
---|
2249 | if (conf.Has("file"))
|
---|
2250 | {
|
---|
2251 | string str = conf.Get<string>("file");
|
---|
2252 | QString qstr(str.c_str());
|
---|
2253 | connector.fileSelected(qstr);
|
---|
2254 | }
|
---|
2255 |
|
---|
2256 | mainWindow.show();
|
---|
2257 |
|
---|
2258 | return app.exec();
|
---|
2259 | }
|
---|