1 | /*
|
---|
2 | * QtGl.cpp
|
---|
3 | *
|
---|
4 | * Created on: Jul 19, 2011
|
---|
5 | * Author: lyard
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "RawEventsViewer.h"
|
---|
9 | #include "RawEventsViewerUi.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 | #include <QtGui/QFileDialog>
|
---|
19 |
|
---|
20 | //Coordinates of an hexagon of radius 1 and center 0
|
---|
21 | GLfloat hexcoords[6][2] = {{-0.577367206, 1},
|
---|
22 | { 0.577367206, 1},
|
---|
23 | { 1.154734411, 0},
|
---|
24 | { 0.577367206, -1},
|
---|
25 | {-0.577367206, -1},
|
---|
26 | {-1.154734411, 0}};
|
---|
27 |
|
---|
28 | //bounding box for diplaying the impulse curve
|
---|
29 | float bboxMin[2] = {-1,-0.9};
|
---|
30 | float bboxMax[2] = {1,-0.3};
|
---|
31 | /************************************************************
|
---|
32 | * UPDATE NEIGHBORS recalculate the neighbors of the current pixels.
|
---|
33 | * Only takes the previous pixels into account (and updates them, too)
|
---|
34 | ************************************************************/
|
---|
35 | void RawDataViewer::updateNeighbors(int currentPixel)
|
---|
36 | {
|
---|
37 | float squaredDistance = 0;
|
---|
38 | for (int i=0;i<currentPixel;i++)
|
---|
39 | {
|
---|
40 | squaredDistance = (pixelsCoords[i][0] - pixelsCoords[currentPixel][0])*
|
---|
41 | (pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) +
|
---|
42 | (pixelsCoords[i][1] - pixelsCoords[currentPixel][1])*
|
---|
43 | (pixelsCoords[i][1] - pixelsCoords[currentPixel][1]);
|
---|
44 | if (squaredDistance < 4*hexRadius*hexRadius*(1.0f+hexTolerance))//neighbor !
|
---|
45 | {//ok, but which one ?
|
---|
46 | if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
|
---|
47 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//top
|
---|
48 | neighbors[i][0] = currentPixel;
|
---|
49 | neighbors[currentPixel][3] = i;
|
---|
50 | continue;}
|
---|
51 | if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
|
---|
52 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//bottom
|
---|
53 | neighbors[i][3] = currentPixel;
|
---|
54 | neighbors[currentPixel][0] = i;
|
---|
55 | continue;}
|
---|
56 | if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
|
---|
57 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top right
|
---|
58 | neighbors[i][4] = currentPixel;
|
---|
59 | neighbors[currentPixel][1] = i;
|
---|
60 | continue;}
|
---|
61 | if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
|
---|
62 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom right
|
---|
63 | neighbors[i][5] = currentPixel;
|
---|
64 | neighbors[currentPixel][2] = i;
|
---|
65 | continue;}
|
---|
66 | if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
|
---|
67 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top left
|
---|
68 | neighbors[i][2] = currentPixel;
|
---|
69 | neighbors[currentPixel][5] = i;
|
---|
70 | continue;}
|
---|
71 | if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
|
---|
72 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom left
|
---|
73 | neighbors[i][1] = currentPixel;
|
---|
74 | neighbors[currentPixel][4] = i;
|
---|
75 | continue;}
|
---|
76 | }
|
---|
77 | }
|
---|
78 | }
|
---|
79 | /************************************************************
|
---|
80 | * SKIP PIXELS skips a given number of pixels.
|
---|
81 | * Only update the pixel coordinates. i.e. update neighbors must
|
---|
82 | * called again afterwards.
|
---|
83 | ************************************************************/
|
---|
84 | void RawDataViewer::skipPixels(int start, int howMany)
|
---|
85 | {
|
---|
86 | for (int i=start;i<MAX_NUM_PIXELS-howMany;i++)
|
---|
87 | {
|
---|
88 | pixelsCoords[i][0] = pixelsCoords[i+howMany][0];
|
---|
89 | pixelsCoords[i][1] = pixelsCoords[i+howMany][1];
|
---|
90 | }
|
---|
91 | }
|
---|
92 | /************************************************************
|
---|
93 | * CALCULATE PIXELS COORDS as the name suggests
|
---|
94 | ************************************************************/
|
---|
95 | void RawDataViewer::calculatePixelsCoords()
|
---|
96 | {
|
---|
97 | pixelsCoords[0][0] = 0;
|
---|
98 | pixelsCoords[0][1] = 0.3;
|
---|
99 | pixelsCoords[0][2] = 0;
|
---|
100 | pixelsCoords[1][0] = 0;
|
---|
101 | pixelsCoords[1][1] = 0.3+2*hexRadius;
|
---|
102 | pixelsCoords[1][2] = 0;
|
---|
103 | neighbors[0][0] = 1;
|
---|
104 | neighbors[1][3] = 0;
|
---|
105 | //from which side of the previous hexagon are we coming from ?
|
---|
106 | int fromSide = 3;
|
---|
107 | //to which side are we heading to ?
|
---|
108 | int toSide = 0;
|
---|
109 | for (int i=2;i<MAX_NUM_PIXELS;i++)
|
---|
110 | {
|
---|
111 | toSide = fromSide-1;
|
---|
112 | if (toSide < 0)
|
---|
113 | toSide =5;
|
---|
114 | while (neighbors[i-1][toSide] >= 0)
|
---|
115 | {
|
---|
116 | toSide--;
|
---|
117 | if (toSide < 0)
|
---|
118 | toSide = 5;
|
---|
119 | }
|
---|
120 | fromSide = toSide + 3;
|
---|
121 | if (fromSide > 5)
|
---|
122 | fromSide -= 6;
|
---|
123 | //ok. now we now in which direction we're heading
|
---|
124 | pixelsCoords[i][0] = pixelsCoords[i-1][0];
|
---|
125 | pixelsCoords[i][1] = pixelsCoords[i-1][1];
|
---|
126 | pixelsCoords[i][2] = pixelsCoords[i-1][2];
|
---|
127 | switch (toSide)
|
---|
128 | {
|
---|
129 | case 0:
|
---|
130 | pixelsCoords[i][1] += 2*hexRadius;
|
---|
131 | break;
|
---|
132 | case 1:
|
---|
133 | pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
|
---|
134 | pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
|
---|
135 | break;
|
---|
136 | case 2:
|
---|
137 | pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
|
---|
138 | pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
|
---|
139 | break;
|
---|
140 | case 3:
|
---|
141 | pixelsCoords[i][1] -= 2*hexRadius;
|
---|
142 | break;
|
---|
143 | case 4:
|
---|
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 5:
|
---|
148 | pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
|
---|
149 | pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
|
---|
150 | break;
|
---|
151 | };
|
---|
152 |
|
---|
153 | updateNeighbors(i);
|
---|
154 | }
|
---|
155 | //Ok. So now we've circled around all the way to MAX_NUM_PIXELS
|
---|
156 | //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels
|
---|
157 | skipPixels(1200, 1);
|
---|
158 | skipPixels(1218, 3);
|
---|
159 | skipPixels(1236, 1);
|
---|
160 | skipPixels(1256, 1);
|
---|
161 | skipPixels(1274, 3);
|
---|
162 | skipPixels(1292, 3);
|
---|
163 | skipPixels(1309, 6);
|
---|
164 | skipPixels(1323, 7);
|
---|
165 | skipPixels(1337, 6);
|
---|
166 | skipPixels(1354, 6);
|
---|
167 | skipPixels(1368, 7);
|
---|
168 | skipPixels(1382, 9);
|
---|
169 | skipPixels(1394, 12);
|
---|
170 | skipPixels(1402, 15);
|
---|
171 | skipPixels(1410, 12);
|
---|
172 | skipPixels(1422, 12);
|
---|
173 | skipPixels(1430, 15);
|
---|
174 | }
|
---|
175 | /************************************************************
|
---|
176 | * BUILD VERTICES LIST. from the coordinates of the camera pixels,
|
---|
177 | * calculate the list and coordinates of the vertices required to draw the
|
---|
178 | * entire camera.
|
---|
179 | ************************************************************/
|
---|
180 | void RawDataViewer::buildVerticesList()
|
---|
181 | {
|
---|
182 | numVertices = 0;
|
---|
183 | GLfloat cVertex[2];
|
---|
184 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
185 | {
|
---|
186 | for (int j=0;j<6;j++)
|
---|
187 | {
|
---|
188 | for (int k=0;k<2;k++)
|
---|
189 | cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
|
---|
190 | bool found = false;
|
---|
191 | for (int k=0;k<numVertices;k++)
|
---|
192 | {
|
---|
193 | if ((cVertex[0] - verticesList[k][0])*
|
---|
194 | (cVertex[0] - verticesList[k][0]) +
|
---|
195 | (cVertex[1] - verticesList[k][1])*
|
---|
196 | (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
|
---|
197 | {
|
---|
198 | found = true;
|
---|
199 | break;
|
---|
200 | }
|
---|
201 | }
|
---|
202 | if (!found)
|
---|
203 | {
|
---|
204 | for (int k=0;k<2;k++)
|
---|
205 | verticesList[numVertices][k] = cVertex[k];
|
---|
206 | numVertices++;
|
---|
207 | }
|
---|
208 | }
|
---|
209 | }
|
---|
210 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
211 | {
|
---|
212 | for (int j=0;j<6;j++)
|
---|
213 | {
|
---|
214 | for (int k=0;k<2;k++)
|
---|
215 | cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
|
---|
216 | for (int k=0;k<numVertices;k++)
|
---|
217 | {
|
---|
218 | if ((cVertex[0] - verticesList[k][0])*
|
---|
219 | (cVertex[0] - verticesList[k][0]) +
|
---|
220 | (cVertex[1] - verticesList[k][1])*
|
---|
221 | (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
|
---|
222 | {
|
---|
223 | verticesIndices[i][j] = k;
|
---|
224 | break;
|
---|
225 | }
|
---|
226 | }
|
---|
227 | }
|
---|
228 | }
|
---|
229 | }
|
---|
230 | /************************************************************
|
---|
231 | * BUILD PATCHES INDICES. from the list of patches, crawls through
|
---|
232 | * the list of camera pixels and build the list of edges that should be kept
|
---|
233 | * in order to display the patches' contours.
|
---|
234 | ************************************************************/
|
---|
235 | void RawDataViewer::buildPatchesIndices()
|
---|
236 | {
|
---|
237 | vector<edge>::iterator it;
|
---|
238 | bool erased = false;
|
---|
239 | for (int i=0;i<NTMARK;i++)//for all patches
|
---|
240 | {
|
---|
241 | patchesIndices[i].clear();
|
---|
242 | for (int j=0;j<9;j++)//for all cells of the current patch
|
---|
243 | {
|
---|
244 | if (patches[i][j] == 690 ||
|
---|
245 | patches[i][j] == 70)
|
---|
246 | continue;
|
---|
247 | for (int k=0;k<6;k++)//for all sides of the current cell
|
---|
248 | {
|
---|
249 | int first = k-1;
|
---|
250 | int second = k;
|
---|
251 | if (first < 0)
|
---|
252 | first = 5;
|
---|
253 | erased = false;
|
---|
254 | for (it=(patchesIndices[i]).begin(); it != (patchesIndices[i]).end(); it++)//check if this side is here already or not
|
---|
255 | {
|
---|
256 | if (((*it).first == verticesIndices[patches[i][j]][first] &&
|
---|
257 | (*it).second == verticesIndices[patches[i][j]][second]) ||
|
---|
258 | ((*it).first == verticesIndices[patches[i][j]][second] &&
|
---|
259 | (*it).second == verticesIndices[patches[i][j]][first]))
|
---|
260 | {
|
---|
261 | patchesIndices[i].erase(it);
|
---|
262 | erased = true;
|
---|
263 | break;
|
---|
264 | }
|
---|
265 | }
|
---|
266 | if (!erased)
|
---|
267 | {
|
---|
268 | edge temp;
|
---|
269 | temp.first = verticesIndices[patches[i][j]][first];
|
---|
270 | temp.second = verticesIndices[patches[i][j]][second];
|
---|
271 | patchesIndices[i].push_back(temp);
|
---|
272 | }
|
---|
273 | }
|
---|
274 | }
|
---|
275 | }
|
---|
276 | }
|
---|
277 | /************************************************************
|
---|
278 | * CALC BLUR COLOR if in blur display mode, calculate the interpolated
|
---|
279 | * colour for a given vertex
|
---|
280 | ************************************************************/
|
---|
281 | void RawDataViewer::calcBlurColor(int pixel, int vertex)
|
---|
282 | {
|
---|
283 | GLfloat color[3];
|
---|
284 | int first, second;
|
---|
285 | first = vertex-1;
|
---|
286 | second = vertex;
|
---|
287 | if (first < 0)
|
---|
288 | first = 5;
|
---|
289 | first = neighbors[pixel][first];
|
---|
290 | second = neighbors[pixel][second];
|
---|
291 | for (int i=0;i<3;i++)
|
---|
292 | color[i] = pixelsColor[pixel][i];
|
---|
293 | float divide = 1;
|
---|
294 | if (first != -1)
|
---|
295 | {
|
---|
296 | divide++;
|
---|
297 | for (int i=0;i<3;i++)
|
---|
298 | color[i] += pixelsColor[first][i];
|
---|
299 | }
|
---|
300 | if (second != -1)
|
---|
301 | {
|
---|
302 | divide++;
|
---|
303 | for (int i=0;i<3;i++)
|
---|
304 | color[i] += pixelsColor[second][i];
|
---|
305 | }
|
---|
306 | for (int i=0;i<3;i++)
|
---|
307 | color[i] /= divide;
|
---|
308 | glColor3fv(color);
|
---|
309 | }
|
---|
310 | /************************************************************
|
---|
311 | * DRAW BLURRY HEXAGON. draws a solid hexagon, with interpolated colours
|
---|
312 | ************************************************************/
|
---|
313 | void RawDataViewer::drawBlurryHexagon(int index)
|
---|
314 | {
|
---|
315 | GLfloat color[3];
|
---|
316 | for (int i=0;i<3;i++)
|
---|
317 | color[i] = pixelsColor[index][i];
|
---|
318 | glBegin(GL_TRIANGLES);
|
---|
319 | calcBlurColor(index, 0);
|
---|
320 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
321 | glColor3fv(color);
|
---|
322 | glVertex2fv(pixelsCoords[index]);
|
---|
323 | calcBlurColor(index, 1);
|
---|
324 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
325 |
|
---|
326 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
327 | glColor3fv(color);
|
---|
328 | glVertex2fv(pixelsCoords[index]);
|
---|
329 | calcBlurColor(index, 2);
|
---|
330 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
331 |
|
---|
332 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
333 | glColor3fv(color);
|
---|
334 | glVertex2fv(pixelsCoords[index]);
|
---|
335 | calcBlurColor(index, 3);
|
---|
336 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
337 |
|
---|
338 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
339 | glColor3fv(color);
|
---|
340 | glVertex2fv(pixelsCoords[index]);
|
---|
341 | calcBlurColor(index, 4);
|
---|
342 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
343 |
|
---|
344 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
345 | glColor3fv(color);
|
---|
346 | glVertex2fv(pixelsCoords[index]);
|
---|
347 | calcBlurColor(index, 5);
|
---|
348 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
349 |
|
---|
350 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
351 | glColor3fv(color);
|
---|
352 | glVertex2fv(pixelsCoords[index]);
|
---|
353 | calcBlurColor(index, 0);
|
---|
354 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
355 | glEnd();
|
---|
356 |
|
---|
357 | return;
|
---|
358 | }
|
---|
359 | /************************************************************
|
---|
360 | * DRAW HEXAGON. draws a single hexagon.
|
---|
361 | ************************************************************/
|
---|
362 | void RawDataViewer::drawHexagon(int index, bool solid)
|
---|
363 | {
|
---|
364 | if (solid)
|
---|
365 | glBegin(GL_POLYGON);
|
---|
366 | else
|
---|
367 | glBegin(GL_LINE_LOOP);
|
---|
368 |
|
---|
369 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
370 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
371 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
372 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
373 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
374 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
375 | if (solid)
|
---|
376 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
377 |
|
---|
378 | glEnd();
|
---|
379 |
|
---|
380 | return;
|
---|
381 | }
|
---|
382 |
|
---|
383 |
|
---|
384 | float ss[5] = {0.00, 0.25, 0.5, 0.75, 1.00};
|
---|
385 | float rr[5] = {0.15, 0.00, 0.00, 1.00, 0.85};
|
---|
386 | float gg[5] = {0.15, 0.00, 1.00, 0.00, 0.85};
|
---|
387 | float bb[5] = {0.15, 1.00, 0.00, 0.00, 0.85};
|
---|
388 | /*
|
---|
389 | float ss[5] = {0., 0.47, 0.475, 0.48, 1.00};
|
---|
390 | float rr[5] = {0., 0.35, 0.85, 1.00, 1.00};
|
---|
391 | float gg[5] = {0., 0.10, 0.20, 0.73, 1.00};
|
---|
392 | float bb[5] = {0., 0.03, 0.06, 0.00, 1.00};
|
---|
393 | */
|
---|
394 | /************************************************************
|
---|
395 | * DRAW PATCHES. draws the clustering patches
|
---|
396 | ************************************************************/
|
---|
397 | void RawDataViewer::drawPatches()
|
---|
398 | {
|
---|
399 | glLineWidth(2.0f);
|
---|
400 | float backupRadius = hexRadius;
|
---|
401 | hexRadius *= 0.95;
|
---|
402 | glBegin(GL_LINES);
|
---|
403 | for (int i=0;i<NTMARK;i++)
|
---|
404 | {
|
---|
405 | glColor3fv(patchesColor[i]);
|
---|
406 | for (unsigned int j=0;j<patchesIndices[i].size();j++)
|
---|
407 | {
|
---|
408 | glVertex2fv(verticesList[patchesIndices[i][j].first]);
|
---|
409 | glVertex2fv(verticesList[patchesIndices[i][j].second]);
|
---|
410 | }
|
---|
411 | }
|
---|
412 | glEnd();
|
---|
413 | hexRadius = backupRadius;
|
---|
414 | }
|
---|
415 | /************************************************************
|
---|
416 | * DRAW CAMERA draws all the camera pixels
|
---|
417 | ************************************************************/
|
---|
418 | void RawDataViewer::drawCamera(bool alsoWire)
|
---|
419 | {
|
---|
420 | glColor3f(0.5,0.5,0.5);
|
---|
421 | glLineWidth(1.0);
|
---|
422 | float color;
|
---|
423 |
|
---|
424 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
425 | {
|
---|
426 | if (!nRoi)
|
---|
427 | color = (float)(i)/(float)(ACTUAL_NUM_PIXELS);
|
---|
428 | else
|
---|
429 | #ifdef LOAD_RAW
|
---|
430 | color = float(eventsData[eventNum][i][whichSlice]+32767)/65535.0f;
|
---|
431 | #else
|
---|
432 | color = float(eventData[nRoi*i + whichSlice]+32767)/65535.0f;
|
---|
433 | #endif
|
---|
434 | int index = 0;
|
---|
435 | while (ss[index] < color)
|
---|
436 | index++;
|
---|
437 | index--;
|
---|
438 | float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
|
---|
439 | float weight1 = 1.0f-weight0;
|
---|
440 | pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
|
---|
441 | pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
|
---|
442 | pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
|
---|
443 | }
|
---|
444 |
|
---|
445 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
446 | {
|
---|
447 | if (i == 690 ||
|
---|
448 | i == 70)
|
---|
449 | continue;
|
---|
450 | glColor3fv(pixelsColor[i]);
|
---|
451 | glLoadName(i);
|
---|
452 | if (drawBlur)
|
---|
453 | drawBlurryHexagon(i);
|
---|
454 | else
|
---|
455 | drawHexagon(i,true);
|
---|
456 |
|
---|
457 | }
|
---|
458 | if (!alsoWire)
|
---|
459 | return;
|
---|
460 | glColor3f(0.0f,0.0f,0.0f);
|
---|
461 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
462 | {
|
---|
463 | if (i == 690 ||
|
---|
464 | i == 70)
|
---|
465 | continue;
|
---|
466 | drawHexagon(i, false);
|
---|
467 | }
|
---|
468 |
|
---|
469 | }
|
---|
470 |
|
---|
471 | /************************************************************
|
---|
472 | * TRIM. FIXME this should not be here but taken from an existing class (somewhere)
|
---|
473 | ************************************************************/
|
---|
474 | string Trim(const string &str)
|
---|
475 | {
|
---|
476 | // Trim Both leading and trailing spaces
|
---|
477 | const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
|
---|
478 | const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af
|
---|
479 |
|
---|
480 | // if all spaces or empty return an empty string
|
---|
481 | if (string::npos==start || string::npos==end)
|
---|
482 | return string();
|
---|
483 |
|
---|
484 | return str.substr(start, end-start+1);
|
---|
485 | }
|
---|
486 | /************************************************************
|
---|
487 | * DRAW PIXEL CURVE. draws the raw impulse curve of the currently selected pixel
|
---|
488 | ************************************************************/
|
---|
489 | void RawDataViewer::drawPixelCurve()
|
---|
490 | {
|
---|
491 | if (!nRoi)
|
---|
492 | return;
|
---|
493 | glBegin(GL_LINES);
|
---|
494 | glColor3f(0.5,0.5,0.5);
|
---|
495 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
496 | glVertex2f(bboxMax[0], bboxMin[1]);
|
---|
497 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
498 | glVertex2f(bboxMin[0], bboxMax[1]);
|
---|
499 |
|
---|
500 | float xRange = bboxMax[0] - bboxMin[0];
|
---|
501 | float yRange = bboxMax[1] - bboxMin[1];
|
---|
502 | glColor3f(1.0,1.0,1.0);
|
---|
503 | for (int i=0;i<nRoi-1;i++)
|
---|
504 | {
|
---|
505 | #ifdef LOAD_RAW
|
---|
506 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
507 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+32767) /65535.0);
|
---|
508 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
509 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+32767) /65535.0);
|
---|
510 | #else
|
---|
511 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
512 | bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+32767) /65535.0);
|
---|
513 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
514 | bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+32767) /65535.0);
|
---|
515 | #endif
|
---|
516 | }
|
---|
517 | glColor3f(1.0,0.0,0.0);
|
---|
518 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
519 | bboxMin[1]);
|
---|
520 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
521 | bboxMax[1]);
|
---|
522 |
|
---|
523 | glEnd();
|
---|
524 | }
|
---|
525 | /************************************************************
|
---|
526 | * CONSTRUCTOR.
|
---|
527 | ************************************************************/
|
---|
528 | RawDataViewer::RawDataViewer(QWidget *parent) : QGLWidget(parent)
|
---|
529 | {
|
---|
530 | setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
|
---|
531 | hexRadius = 0.015f;
|
---|
532 | hexTolerance = hexRadius/100.0f;
|
---|
533 | viewSize = 1.0f;
|
---|
534 | whichSlice = 0;
|
---|
535 | #ifdef LOAD_RAW
|
---|
536 | nRoi = 1024;
|
---|
537 | #else
|
---|
538 | nRoi = 0;
|
---|
539 | #endif
|
---|
540 | eventNum = 0;
|
---|
541 | rowNum = -1;
|
---|
542 | eventStep = 1;
|
---|
543 | selectedPixel = 0;
|
---|
544 | inputFile = NULL;
|
---|
545 | eventData = NULL;
|
---|
546 | drawPatch = false;
|
---|
547 | drawImpulse = false;
|
---|
548 | drawBlur = false;
|
---|
549 | #ifdef LOAD_RAW
|
---|
550 | loadEvents("/scratch/00000043.001_T.bin");
|
---|
551 | #endif
|
---|
552 | calculatePixelsCoords();
|
---|
553 |
|
---|
554 | ifstream fin2("MasterList-v3.txt");
|
---|
555 | if (!fin2.is_open())
|
---|
556 | {
|
---|
557 | cout << "Error: file \"MasterList-v3\" missing. aborting." << endl;
|
---|
558 | exit(-1);
|
---|
559 | }
|
---|
560 | int l = 0;
|
---|
561 | string buf;
|
---|
562 | while (getline(fin2, buf, '\n'))
|
---|
563 | {
|
---|
564 | buf = Trim(buf);
|
---|
565 | if (buf[0]=='#')
|
---|
566 | continue;
|
---|
567 |
|
---|
568 | unsigned int softid, hardid, dummy;
|
---|
569 |
|
---|
570 | stringstream str(buf);
|
---|
571 |
|
---|
572 | str >> softid;
|
---|
573 | str >> dummy;
|
---|
574 | str >> hardid;
|
---|
575 |
|
---|
576 | if (softid>=1440)
|
---|
577 | continue;
|
---|
578 |
|
---|
579 | hardwareMapping[softid] = hardid;
|
---|
580 |
|
---|
581 | l++;
|
---|
582 | }
|
---|
583 | GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3];
|
---|
584 | for (int i=0;i<1440;i++)
|
---|
585 | for (int j=0;j<3;j++)
|
---|
586 | tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j];
|
---|
587 | for (int i=0;i<1440;i++)
|
---|
588 | for (int j=0;j<3;j++)
|
---|
589 | pixelsCoords[i][j] = tempPixelsCoords[i][j];
|
---|
590 | buildVerticesList();
|
---|
591 | ifstream fin1("Trigger-Patches.txt");
|
---|
592 | if (!fin1.is_open())
|
---|
593 | {
|
---|
594 | cout << "Error: file \"Trigger-Patches.txt\" missing. Aborting." << endl;
|
---|
595 | exit(-1);
|
---|
596 | }
|
---|
597 | l=0;
|
---|
598 | while (getline(fin1, buf, '\n'))
|
---|
599 | {
|
---|
600 | buf = Trim(buf);
|
---|
601 | if (buf[0]=='#')
|
---|
602 | continue;
|
---|
603 |
|
---|
604 | stringstream str(buf);
|
---|
605 | for (int i=0; i<9; i++)
|
---|
606 | {
|
---|
607 | unsigned int n;
|
---|
608 | str >> n;
|
---|
609 |
|
---|
610 | if (n>=1440)
|
---|
611 | continue;
|
---|
612 |
|
---|
613 | patches[l][i] = hardwareMapping[n];
|
---|
614 | }
|
---|
615 | l++;
|
---|
616 | }
|
---|
617 | buildPatchesIndices();
|
---|
618 | float color[3];
|
---|
619 | for (int i=0;i<160;i++)
|
---|
620 | {
|
---|
621 | color[0] = 0.5; color[1] = 0.5; color[2] = 0.3;
|
---|
622 | // if (i==0 || i==2 || i==5 || i==126 || i==10 || i==23 || i==28 || i==38 || i==132 || i==42 || i==55 ||
|
---|
623 | // i==18 || i==21 || i==34 || i==136 || i==122 || i==8 || i==14 || i==32 || i==45 || i==51 || i==138 ||
|
---|
624 | // i==93 || i==75 || i==54 || i==158 || i==111 || i==105 || i==94 || i==82 || i==66 || i==61 || i==79 ||
|
---|
625 | // i==156 || i==115 || i==102 || i==89 || i==71 || i==63 || i==152 || i==98 || i==84)
|
---|
626 | // {
|
---|
627 | // color[0] = 102.f/255.f;
|
---|
628 | // color[1] = 0.f;
|
---|
629 | // color[2] = 153.f/255.f;
|
---|
630 | // }
|
---|
631 | for (int j=0;j<3;j++)
|
---|
632 | patchesColor[i][j] = color[j];
|
---|
633 | }
|
---|
634 |
|
---|
635 | for (int i=0;i<1440;i++)
|
---|
636 | updateNeighbors(i);
|
---|
637 |
|
---|
638 |
|
---|
639 |
|
---|
640 | }
|
---|
641 | /************************************************************
|
---|
642 | * DESTRUCTOR
|
---|
643 | ************************************************************/
|
---|
644 | RawDataViewer::~RawDataViewer()
|
---|
645 | {
|
---|
646 | if (inputFile != NULL)
|
---|
647 | {
|
---|
648 | inputFile->close();
|
---|
649 | delete inputFile;
|
---|
650 | }
|
---|
651 | if (eventData != NULL)
|
---|
652 | delete[] eventData;
|
---|
653 | }
|
---|
654 | /************************************************************
|
---|
655 | * INITIALIZE GL. does not do much.
|
---|
656 | ************************************************************/
|
---|
657 | void RawDataViewer::initializeGL()
|
---|
658 | {
|
---|
659 | qglClearColor(QColor(25,25,38));
|
---|
660 | glShadeModel(GL_FLAT);
|
---|
661 | glDisable(GL_DEPTH_TEST);
|
---|
662 | glDisable(GL_CULL_FACE);
|
---|
663 | // glEnable(GL_LINE_SMOOTH);
|
---|
664 | // glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
|
---|
665 | }
|
---|
666 |
|
---|
667 | /************************************************************
|
---|
668 | * RESIZE GL. reshapes the ortho projection to match the current window size
|
---|
669 | ************************************************************/
|
---|
670 | void RawDataViewer::resizeGL(int width, int height)
|
---|
671 | {
|
---|
672 | glViewport(0, 0, width, height);
|
---|
673 | glMatrixMode(GL_PROJECTION);
|
---|
674 | glLoadIdentity();
|
---|
675 | GLfloat windowRatio = (float)width/(float)height;
|
---|
676 | if (windowRatio < 1)
|
---|
677 | {
|
---|
678 | windowRatio = 1.0f/windowRatio;
|
---|
679 | gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
|
---|
680 | pixelSize = 2*viewSize/(float)width;
|
---|
681 | shownSizex = 2*viewSize;
|
---|
682 | shownSizey = 2*viewSize*windowRatio;
|
---|
683 | }
|
---|
684 | else
|
---|
685 | {
|
---|
686 | gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
|
---|
687 | pixelSize = 2*viewSize/(float)height;
|
---|
688 | shownSizex = 2*viewSize*windowRatio;
|
---|
689 | shownSizey = 2*viewSize;
|
---|
690 | }
|
---|
691 | glMatrixMode(GL_MODELVIEW);
|
---|
692 |
|
---|
693 | }
|
---|
694 |
|
---|
695 | /************************************************************
|
---|
696 | * PAINT GL. main drawing function.
|
---|
697 | ************************************************************/
|
---|
698 | void RawDataViewer::paintGL()
|
---|
699 | {
|
---|
700 | glClear(GL_COLOR_BUFFER_BIT);
|
---|
701 | glLoadIdentity();
|
---|
702 |
|
---|
703 | if (!drawImpulse)
|
---|
704 | {
|
---|
705 | glTranslatef(0,-0.44,0);
|
---|
706 | glScalef(1.5,1.5,1);
|
---|
707 | }
|
---|
708 | if (drawBlur)
|
---|
709 | {
|
---|
710 | glShadeModel(GL_SMOOTH);
|
---|
711 | drawCamera(false);
|
---|
712 | }
|
---|
713 | else
|
---|
714 | {
|
---|
715 | glShadeModel(GL_FLAT);
|
---|
716 | drawCamera(true);
|
---|
717 | }
|
---|
718 | if (drawImpulse)
|
---|
719 | {
|
---|
720 | glLineWidth(2.0);
|
---|
721 | drawPixelCurve();
|
---|
722 | }
|
---|
723 | if (drawPatch)
|
---|
724 | drawPatches();
|
---|
725 |
|
---|
726 | if (drawImpulse)
|
---|
727 | {
|
---|
728 | glLineWidth(1.0f);
|
---|
729 | glColor3f(1.0,1.0,1.0);
|
---|
730 | drawHexagon(selectedPixel, false);
|
---|
731 | }
|
---|
732 | }
|
---|
733 |
|
---|
734 | /************************************************************
|
---|
735 | * MOUSE PRESS EVENT. mouse click handler.
|
---|
736 | ************************************************************/
|
---|
737 | void RawDataViewer::mousePressEvent(QMouseEvent *event)
|
---|
738 | {
|
---|
739 | lastPos = event->pos();
|
---|
740 | setCorrectSlice(event);
|
---|
741 | updateGL();
|
---|
742 | }
|
---|
743 |
|
---|
744 | /************************************************************
|
---|
745 | * SET CORRECT SLICE. if displayed, figures out if the graph was
|
---|
746 | * clicked, and if so, which slice should be displayed
|
---|
747 | ************************************************************/
|
---|
748 | void RawDataViewer::setCorrectSlice(QMouseEvent* event)
|
---|
749 | {
|
---|
750 | if (!drawImpulse)
|
---|
751 | return;
|
---|
752 | float x = (float)event->x() * pixelSize - shownSizex/2;
|
---|
753 | float y = ((float)height()-(float)event->y())*pixelSize - shownSizey/2;
|
---|
754 | if (x < bboxMin[0] ||
|
---|
755 | x > bboxMax[0] ||
|
---|
756 | y < bboxMin[1] ||
|
---|
757 | y > bboxMax[1])
|
---|
758 | return;
|
---|
759 | whichSlice = (x - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
|
---|
760 | emit signalCurrentSlice(whichSlice);
|
---|
761 | }
|
---|
762 |
|
---|
763 | /************************************************************
|
---|
764 | * MOUSE MOVE EVENT. used to track the dragging of slices display
|
---|
765 | ************************************************************/
|
---|
766 | void RawDataViewer::mouseMoveEvent(QMouseEvent *event)
|
---|
767 | {
|
---|
768 | if (event->buttons() & Qt::LeftButton) {
|
---|
769 | setCorrectSlice(event);
|
---|
770 | updateGL();
|
---|
771 | } else if (event->buttons() & Qt::RightButton) {
|
---|
772 | updateGL();
|
---|
773 | }
|
---|
774 | lastPos = event->pos();
|
---|
775 | }
|
---|
776 |
|
---|
777 | /************************************************************
|
---|
778 | * MOUSE DOUBLE CLICK EVENT. used to select pixels
|
---|
779 | ************************************************************/
|
---|
780 | void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *event)
|
---|
781 | {
|
---|
782 | int face = PixelAtPosition(event->pos());
|
---|
783 | if (face != -1) {
|
---|
784 | selectedPixel = face;
|
---|
785 | updateGL();
|
---|
786 | }
|
---|
787 | }
|
---|
788 |
|
---|
789 | /************************************************************
|
---|
790 | * PIXEL AT POSITION. figures out which camera pixel was clicked.
|
---|
791 | ************************************************************/
|
---|
792 | int RawDataViewer::PixelAtPosition(const QPoint &pos)
|
---|
793 | {
|
---|
794 | const int MaxSize = 512;
|
---|
795 | GLuint buffer[MaxSize];
|
---|
796 | GLint viewport[4];
|
---|
797 |
|
---|
798 | makeCurrent();
|
---|
799 |
|
---|
800 | glGetIntegerv(GL_VIEWPORT, viewport);
|
---|
801 | glSelectBuffer(MaxSize, buffer);
|
---|
802 | glRenderMode(GL_SELECT);
|
---|
803 |
|
---|
804 | glInitNames();
|
---|
805 | glPushName(0);
|
---|
806 |
|
---|
807 | glMatrixMode(GL_PROJECTION);
|
---|
808 | glPushMatrix();
|
---|
809 | glLoadIdentity();
|
---|
810 | GLfloat windowRatio = GLfloat(width()) / GLfloat(height());
|
---|
811 | gluPickMatrix(GLdouble(pos.x()), GLdouble(viewport[3] - pos.y()),
|
---|
812 | 1.0, 1.0, viewport);
|
---|
813 |
|
---|
814 | if (windowRatio < 1)
|
---|
815 | {
|
---|
816 | windowRatio = 1.0f/windowRatio;
|
---|
817 | gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
|
---|
818 | }
|
---|
819 | else
|
---|
820 | {
|
---|
821 | gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
|
---|
822 | }
|
---|
823 |
|
---|
824 | glMatrixMode(GL_MODELVIEW);
|
---|
825 | drawCamera(false);
|
---|
826 | glMatrixMode(GL_PROJECTION);
|
---|
827 | glPopMatrix();
|
---|
828 |
|
---|
829 | //for some reason that I cannot understand, the push/pop matrix doesn't do the trick here... bizarre
|
---|
830 | //ok, so re-do the resizeGL thing.
|
---|
831 | resizeGL(width(), height());
|
---|
832 |
|
---|
833 | if (!glRenderMode(GL_RENDER))
|
---|
834 | return -1;
|
---|
835 |
|
---|
836 | return buffer[3];
|
---|
837 | }
|
---|
838 | /************************************************************
|
---|
839 | * IS FITS. checks if a given file is a fits file.
|
---|
840 | ************************************************************/
|
---|
841 | bool RawDataViewer::IsFits(const char *name)
|
---|
842 | {
|
---|
843 | MZlib fin(name);
|
---|
844 | if (!fin)
|
---|
845 | return 0;
|
---|
846 |
|
---|
847 | unsigned char c[6];
|
---|
848 | fin.read((char*)c, 6);
|
---|
849 | if (!fin)
|
---|
850 | return 0;
|
---|
851 |
|
---|
852 | return memcmp(c, "SIMPLE", 6)==0;
|
---|
853 | }
|
---|
854 | /************************************************************
|
---|
855 | * OPEN FILE. opens a new fits file
|
---|
856 | ************************************************************/
|
---|
857 | void RawDataViewer::openFile(string& file)
|
---|
858 | {
|
---|
859 | if (!IsFits(file.c_str()))
|
---|
860 | {
|
---|
861 | cout << "File does not seem to be fits. aborting" << endl;
|
---|
862 | return;
|
---|
863 | }
|
---|
864 | if (inputFile)
|
---|
865 | {
|
---|
866 | inputFile->close();
|
---|
867 | delete inputFile;
|
---|
868 | }
|
---|
869 | inputFile = new MFits(file);
|
---|
870 | nRows = inputFile->GetInt("NAXIS2");
|
---|
871 | nRoi = inputFile->GetInt("NROI");
|
---|
872 | runNumber = -1;
|
---|
873 | nTM = inputFile->GetInt("NTM");
|
---|
874 | runType = inputFile->GetInt("RUNTYPE");
|
---|
875 | firstDataTime = -1;
|
---|
876 | lastDataTime = -1;
|
---|
877 |
|
---|
878 | eventNum = 0;
|
---|
879 |
|
---|
880 | #ifdef LOAD_RAW
|
---|
881 | nRows = NUM_STORED_EVENTS;
|
---|
882 | #endif
|
---|
883 |
|
---|
884 | if (eventData != NULL)
|
---|
885 | delete[] eventData;
|
---|
886 | eventData = new int16_t[1440*nRoi];
|
---|
887 | inputFile->SetPtrAddress("Data", eventData);
|
---|
888 | inputFile->SetPtrAddress("EventNum", &eventNum);
|
---|
889 | inputFile->SetPtrAddress("TriggerType", &triggerType);
|
---|
890 | inputFile->SetPtrAddress("SoftTrig", &softTrig);
|
---|
891 | inputFile->SetPtrAddress("PCTime", &pcTime);
|
---|
892 | inputFile->SetPtrAddress("BoardTime", boardTime);
|
---|
893 | inputFile->SetPtrAddress("StartPix", startPix);
|
---|
894 | inputFile->SetPtrAddress("StartTM", startTM);
|
---|
895 | int backupStep = eventStep;
|
---|
896 | rowNum = -1;
|
---|
897 | eventStep = 1;
|
---|
898 | plusEvent();
|
---|
899 | eventStep = backupStep;
|
---|
900 | emit newFileLoaded();
|
---|
901 | }
|
---|
902 |
|
---|
903 | /************************************************************
|
---|
904 | * PLUS EVENT
|
---|
905 | ************************************************************/
|
---|
906 | void RawDataViewer::plusEvent()
|
---|
907 | {
|
---|
908 | eventStepping(true);
|
---|
909 | }
|
---|
910 | /************************************************************
|
---|
911 | * MINUS EVENT
|
---|
912 | ************************************************************/
|
---|
913 | void RawDataViewer::minusEvent()
|
---|
914 | {
|
---|
915 | eventStepping(false);
|
---|
916 | }
|
---|
917 | /************************************************************
|
---|
918 | * SET EVENT STEP
|
---|
919 | ************************************************************/
|
---|
920 | void RawDataViewer::setEventStep(int step)
|
---|
921 | {
|
---|
922 | eventStep = step;
|
---|
923 | }
|
---|
924 | /************************************************************
|
---|
925 | * EVENT STEPPING
|
---|
926 | ************************************************************/
|
---|
927 | void RawDataViewer::eventStepping(bool plus)
|
---|
928 | {
|
---|
929 | if (plus)
|
---|
930 | rowNum += eventStep;
|
---|
931 | else
|
---|
932 | rowNum -= eventStep;
|
---|
933 | if (rowNum >= nRows)
|
---|
934 | rowNum -= nRows;
|
---|
935 | if (rowNum < 0)
|
---|
936 | rowNum += nRows;
|
---|
937 | #ifdef LOAD_RAW
|
---|
938 | eventNum+=eventStep;
|
---|
939 | #else
|
---|
940 | if (inputFile == NULL)
|
---|
941 | return;
|
---|
942 | inputFile->GetRow(rowNum);
|
---|
943 | #endif
|
---|
944 | updateGL();
|
---|
945 | emit signalCurrentEvent(eventNum);
|
---|
946 | }
|
---|
947 | /************************************************************
|
---|
948 | * NEXT SLICE. deprec ?
|
---|
949 | ************************************************************/
|
---|
950 | void RawDataViewer::nextSlice()
|
---|
951 | {
|
---|
952 | whichSlice++;
|
---|
953 | if (whichSlice >= nRoi)
|
---|
954 | whichSlice=0;
|
---|
955 |
|
---|
956 | emit signalCurrentSlice(whichSlice);
|
---|
957 | updateGL();
|
---|
958 | }
|
---|
959 | /************************************************************
|
---|
960 | * UICONNECTOR CONSTRUCTOR
|
---|
961 | ************************************************************/
|
---|
962 | UIConnector::UIConnector(QWidget* parent)
|
---|
963 | {
|
---|
964 | timer.setInterval(1000.0);
|
---|
965 | QObject::connect(&timer, SIGNAL(timeout()),
|
---|
966 | this, SLOT(nextSlicePlease()));
|
---|
967 | }
|
---|
968 | /************************************************************
|
---|
969 | * DRAW PATCHES CHECK CHANGE. checkbox handler
|
---|
970 | ************************************************************/
|
---|
971 | void UIConnector::drawPatchesCheckChange(int state)
|
---|
972 | {
|
---|
973 | if (state)
|
---|
974 | viewer->drawPatch = true;
|
---|
975 | else
|
---|
976 | viewer->drawPatch = false;
|
---|
977 | viewer->updateGL();
|
---|
978 | }
|
---|
979 | /************************************************************
|
---|
980 | * DRAW IMPULSE CHECK CHANGE. checkbox handler
|
---|
981 | ************************************************************/
|
---|
982 | void UIConnector::drawImpulseCheckChange(int state)
|
---|
983 | {
|
---|
984 | if (state)
|
---|
985 | viewer->drawImpulse = true;
|
---|
986 | else
|
---|
987 | viewer->drawImpulse = false;
|
---|
988 | viewer->updateGL();
|
---|
989 | }
|
---|
990 | /************************************************************
|
---|
991 | * DRAW BLUR CHECK CHANGE. checkbox handler
|
---|
992 | ************************************************************/
|
---|
993 | void UIConnector::drawBlurCheckChange(int state)
|
---|
994 | {
|
---|
995 | if (state)
|
---|
996 | viewer->drawBlur = true;
|
---|
997 | else
|
---|
998 | viewer->drawBlur = false;
|
---|
999 | viewer->updateGL();
|
---|
1000 | }
|
---|
1001 | /************************************************************
|
---|
1002 | * NEXT SLICE PLEASE
|
---|
1003 | ************************************************************/
|
---|
1004 | void UIConnector::nextSlicePlease()
|
---|
1005 | {
|
---|
1006 | viewer->nextSlice();
|
---|
1007 | }
|
---|
1008 | /************************************************************
|
---|
1009 | * SET VIEWER.
|
---|
1010 | ************************************************************/
|
---|
1011 | void UIConnector::setViewer(RawDataViewer* v)
|
---|
1012 | {
|
---|
1013 | viewer = v;
|
---|
1014 | }
|
---|
1015 | /************************************************************
|
---|
1016 | * SLICES PER SECOND CHANGED. timing ui handler
|
---|
1017 | ************************************************************/
|
---|
1018 | void UIConnector::slicesPerSecondChanged(double value)
|
---|
1019 | {
|
---|
1020 | timer.setInterval(1000.0/value);
|
---|
1021 | }
|
---|
1022 | /************************************************************
|
---|
1023 | * RANGE CHANGED . colors tweaking handler
|
---|
1024 | ************************************************************/
|
---|
1025 | void UIConnector::rangeChanged0(double value)
|
---|
1026 | {
|
---|
1027 | ss[0] = (float)value;
|
---|
1028 | viewer->updateGL();
|
---|
1029 | }
|
---|
1030 | /************************************************************
|
---|
1031 | * RANGE CHANGED . colors tweaking handler
|
---|
1032 | ************************************************************/
|
---|
1033 | void UIConnector::rangeChanged1(double value)
|
---|
1034 | {
|
---|
1035 | ss[1] = (float)value;
|
---|
1036 | viewer->updateGL();
|
---|
1037 | }
|
---|
1038 | /************************************************************
|
---|
1039 | * RANGE CHANGED . colors tweaking handler
|
---|
1040 | ************************************************************/
|
---|
1041 | void UIConnector::rangeChanged2(double value)
|
---|
1042 | {
|
---|
1043 | ss[2] = (float)value;
|
---|
1044 | viewer->updateGL();
|
---|
1045 | }
|
---|
1046 | /************************************************************
|
---|
1047 | * RANGE CHANGED . colors tweaking handler
|
---|
1048 | ************************************************************/
|
---|
1049 | void UIConnector::rangeChanged3(double value)
|
---|
1050 | {
|
---|
1051 | ss[3] = (float)value;
|
---|
1052 | viewer->updateGL();
|
---|
1053 | }
|
---|
1054 | /************************************************************
|
---|
1055 | * RANGE CHANGED . colors tweaking handler
|
---|
1056 | ************************************************************/
|
---|
1057 | void UIConnector::rangeChanged4(double value)
|
---|
1058 | {
|
---|
1059 | ss[4] = (float)value;
|
---|
1060 | viewer->updateGL();
|
---|
1061 | }
|
---|
1062 | /************************************************************
|
---|
1063 | * RANGE CHANGED . colors tweaking handler
|
---|
1064 | ************************************************************/
|
---|
1065 | void UIConnector::redChanged0(double value)
|
---|
1066 | {
|
---|
1067 | rr[0] = (float)value;
|
---|
1068 | viewer->updateGL();
|
---|
1069 | }
|
---|
1070 | /************************************************************
|
---|
1071 | * RED CHANGED . colors tweaking handler
|
---|
1072 | ************************************************************/
|
---|
1073 | void UIConnector::redChanged1(double value)
|
---|
1074 | {
|
---|
1075 | rr[1] = (float)value;
|
---|
1076 | viewer->updateGL();
|
---|
1077 | }
|
---|
1078 | /************************************************************
|
---|
1079 | * RED CHANGED . colors tweaking handler
|
---|
1080 | ************************************************************/
|
---|
1081 | void UIConnector::redChanged2(double value)
|
---|
1082 | {
|
---|
1083 | rr[2] = (float)value;
|
---|
1084 | viewer->updateGL();
|
---|
1085 | }
|
---|
1086 | /************************************************************
|
---|
1087 | * RED CHANGED . colors tweaking handler
|
---|
1088 | ************************************************************/
|
---|
1089 | void UIConnector::redChanged3(double value)
|
---|
1090 | {
|
---|
1091 | rr[3] = (float)value;
|
---|
1092 | viewer->updateGL();
|
---|
1093 | }
|
---|
1094 | /************************************************************
|
---|
1095 | * RED CHANGED . colors tweaking handler
|
---|
1096 | ************************************************************/
|
---|
1097 | void UIConnector::redChanged4(double value)
|
---|
1098 | {
|
---|
1099 | rr[4] = (float)value;
|
---|
1100 | viewer->updateGL();
|
---|
1101 | }
|
---|
1102 | /************************************************************
|
---|
1103 | * GREEN CHANGED . colors tweaking handler
|
---|
1104 | ************************************************************/
|
---|
1105 | void UIConnector::greenChanged0(double value)
|
---|
1106 | {
|
---|
1107 | gg[0] = (float)value;
|
---|
1108 | viewer->updateGL();
|
---|
1109 | }
|
---|
1110 | /************************************************************
|
---|
1111 | * GREEN CHANGED . colors tweaking handler
|
---|
1112 | ************************************************************/
|
---|
1113 | void UIConnector::greenChanged1(double value)
|
---|
1114 | {
|
---|
1115 | gg[1] = (float)value;
|
---|
1116 | viewer->updateGL();
|
---|
1117 | }
|
---|
1118 | /************************************************************
|
---|
1119 | * GREEN CHANGED . colors tweaking handler
|
---|
1120 | ************************************************************/
|
---|
1121 | void UIConnector::greenChanged2(double value)
|
---|
1122 | {
|
---|
1123 | gg[2] = (float)value;
|
---|
1124 | viewer->updateGL();
|
---|
1125 | }
|
---|
1126 | /************************************************************
|
---|
1127 | * GREEN CHANGED . colors tweaking handler
|
---|
1128 | ************************************************************/
|
---|
1129 | void UIConnector::greenChanged3(double value)
|
---|
1130 | {
|
---|
1131 | gg[3] = (float)value;
|
---|
1132 | viewer->updateGL();
|
---|
1133 | }
|
---|
1134 | /************************************************************
|
---|
1135 | * GREEN CHANGED . colors tweaking handler
|
---|
1136 | ************************************************************/
|
---|
1137 | void UIConnector::greenChanged4(double value)
|
---|
1138 | {
|
---|
1139 | gg[4] = (float)value;
|
---|
1140 | viewer->updateGL();
|
---|
1141 | }
|
---|
1142 | /************************************************************
|
---|
1143 | * BLUE CHANGED . colors tweaking handler
|
---|
1144 | ************************************************************/
|
---|
1145 | void UIConnector::blueChanged0(double value)
|
---|
1146 | {
|
---|
1147 | bb[0] = (float)value;
|
---|
1148 | viewer->updateGL();
|
---|
1149 | }
|
---|
1150 | /************************************************************
|
---|
1151 | * BLUE CHANGED . colors tweaking handler
|
---|
1152 | ************************************************************/
|
---|
1153 | void UIConnector::blueChanged1(double value)
|
---|
1154 | {
|
---|
1155 | bb[1] = (float)value;
|
---|
1156 | viewer->updateGL();
|
---|
1157 | }
|
---|
1158 | /************************************************************
|
---|
1159 | * BLUE CHANGED . colors tweaking handler
|
---|
1160 | ************************************************************/
|
---|
1161 | void UIConnector::blueChanged2(double value)
|
---|
1162 | {
|
---|
1163 | bb[2] = (float)value;
|
---|
1164 | viewer->updateGL();
|
---|
1165 | }
|
---|
1166 | /************************************************************
|
---|
1167 | * BLUE CHANGED . colors tweaking handler
|
---|
1168 | ************************************************************/
|
---|
1169 | void UIConnector::blueChanged3(double value)
|
---|
1170 | {
|
---|
1171 | bb[3] = (float)value;
|
---|
1172 | viewer->updateGL();
|
---|
1173 | }
|
---|
1174 | /************************************************************
|
---|
1175 | * BLUE CHANGED . colors tweaking handler
|
---|
1176 | ************************************************************/
|
---|
1177 | void UIConnector::blueChanged4(double value)
|
---|
1178 | {
|
---|
1179 | bb[4] = (float)value;
|
---|
1180 | viewer->updateGL();
|
---|
1181 | }
|
---|
1182 | /************************************************************
|
---|
1183 | * LOAD NEW FILE CLICKED. button handler
|
---|
1184 | ************************************************************/
|
---|
1185 | void UIConnector::loadNewFileClicked()
|
---|
1186 | {
|
---|
1187 | QFileDialog dialog;
|
---|
1188 | dialog.setFileMode(QFileDialog::ExistingFile);
|
---|
1189 | dialog.open(this, SLOT(fileSelected(QString)));
|
---|
1190 | dialog.setVisible(true);
|
---|
1191 | dialog.exec();
|
---|
1192 | }
|
---|
1193 | /************************************************************
|
---|
1194 | * FILE SELECTED. return of the file open dialog handler
|
---|
1195 | ************************************************************/
|
---|
1196 | void UIConnector::fileSelected(QString file)
|
---|
1197 | {
|
---|
1198 | currentFile = file.toStdString();
|
---|
1199 | if (currentFile != "")
|
---|
1200 | viewer->openFile(currentFile);
|
---|
1201 | }
|
---|
1202 | /************************************************************
|
---|
1203 | * NEW FILE LOADED. update of the UI after a new file has been loaded
|
---|
1204 | ************************************************************/
|
---|
1205 | void UIConnector::newFileLoaded()
|
---|
1206 | {
|
---|
1207 | ostringstream str;
|
---|
1208 | str << "File loaded: " << currentFile;
|
---|
1209 | fileLoadedLabel->setText(QString(str.str().c_str()));
|
---|
1210 | str.str("");
|
---|
1211 | str << "Run number: " << viewer->runNumber;
|
---|
1212 | runNumberLabel->setText(QString(str.str().c_str()));
|
---|
1213 | str.str("");
|
---|
1214 | str << "Number of Events/Slices: " << viewer->nRows << "/" << viewer->nRoi;
|
---|
1215 | numberOfSlicesLabel->setText(QString(str.str().c_str()));
|
---|
1216 | str.str("");
|
---|
1217 | str << "Number of Time Marks: " << viewer->nTM;
|
---|
1218 | numberOfTimeMarksLabel->setText(QString(str.str().c_str()));
|
---|
1219 | str.str("");
|
---|
1220 | str << "Run Type: " << viewer->runType;
|
---|
1221 | runTypeLabel->setText(QString(str.str().c_str()));
|
---|
1222 | str.str("");
|
---|
1223 | str << "Time of 1st data: " << viewer->firstDataTime;
|
---|
1224 | firstTimeLabel->setText(QString(str.str().c_str()));
|
---|
1225 | str.str("");
|
---|
1226 | str << "Time of last data: " << viewer->lastDataTime;
|
---|
1227 | lastTimeLabel->setText(QString(str.str().c_str()));
|
---|
1228 | }
|
---|
1229 | /************************************************************
|
---|
1230 | * PLAY PAUSE CLICKED. ui handler
|
---|
1231 | ************************************************************/
|
---|
1232 | void UIConnector::playPauseClicked()
|
---|
1233 | {
|
---|
1234 | if (timer.isActive())
|
---|
1235 | timer.stop();
|
---|
1236 | else
|
---|
1237 | timer.start();
|
---|
1238 | }
|
---|
1239 | /************************************************************
|
---|
1240 | * CURRENT SLICE HAS CHANGE. ui handler
|
---|
1241 | ************************************************************/
|
---|
1242 | void UIConnector::currentSliceHasChanged(int slice)
|
---|
1243 | {
|
---|
1244 | ostringstream str;
|
---|
1245 | str << "Displaying Slice " << slice;
|
---|
1246 | QString qstr(str.str().c_str());
|
---|
1247 | emit updateCurrentSliceDisplay(qstr);
|
---|
1248 | }
|
---|
1249 | /************************************************************
|
---|
1250 | * CURRENT EVENT HAS CHANGED. ui handler
|
---|
1251 | ************************************************************/
|
---|
1252 | void UIConnector::currentEventHasChanged(int event)
|
---|
1253 | {
|
---|
1254 | ostringstream str;
|
---|
1255 | str << "Displaying Event " << event;
|
---|
1256 | QString qstr(str.str().c_str());
|
---|
1257 | emit updateCurrentEventDisplay(qstr);
|
---|
1258 | //retrieve the data that we want to display
|
---|
1259 | str.str("");
|
---|
1260 | str << "PC Time: " << viewer->pcTime;
|
---|
1261 | qstr = qstr.fromStdString(str.str());
|
---|
1262 | emit updateCurrentPCTime(qstr);
|
---|
1263 |
|
---|
1264 | str.str("");
|
---|
1265 | str << "Software Trigger: " << viewer->softTrig;
|
---|
1266 | qstr = qstr.fromStdString(str.str());
|
---|
1267 | emit updateCurrentSoftTrigger(qstr);
|
---|
1268 |
|
---|
1269 | str.str("");
|
---|
1270 | str << "Trigger Type: " << viewer->triggerType;
|
---|
1271 | qstr = qstr.fromStdString(str.str());
|
---|
1272 | emit updateCurrentTriggerType(qstr);
|
---|
1273 |
|
---|
1274 | boardsTimeList->clear();
|
---|
1275 | startPixelsList->clear();
|
---|
1276 | startTimeMarksList->clear();
|
---|
1277 | for (int i=0;i <NBOARDS; i++)
|
---|
1278 | {
|
---|
1279 | str.str("");
|
---|
1280 | str << i;
|
---|
1281 | if (i<10) str << " ";
|
---|
1282 | if (i<100) str << " ";
|
---|
1283 | if (i<1000) str << " ";
|
---|
1284 | str << ": " << viewer->boardTime[i];
|
---|
1285 | boardsTimeList->addItem(QString(str.str().c_str()));
|
---|
1286 | }
|
---|
1287 | for (int i=0;i <NPIX; i++)
|
---|
1288 | {
|
---|
1289 | str.str("");
|
---|
1290 | str << i;
|
---|
1291 | if (i<10) str << " ";
|
---|
1292 | if (i<100) str << " ";
|
---|
1293 | if (i<1000) str << " ";
|
---|
1294 | str << ": " << viewer->startPix[i];
|
---|
1295 | startPixelsList->addItem(QString(str.str().c_str()));
|
---|
1296 | }
|
---|
1297 | for (int i=0;i <NTMARK; i++)
|
---|
1298 | {
|
---|
1299 | str.str("");
|
---|
1300 | str << i;
|
---|
1301 | if (i<10) str << " ";
|
---|
1302 | if (i<100) str << " ";
|
---|
1303 | if (i<1000) str << " ";
|
---|
1304 | str << ": " << viewer->startTM[i];
|
---|
1305 | startTimeMarksList->addItem(QString(str.str().c_str()));
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 | /************************************************************
|
---|
1311 | * MAIN PROGRAM FUNCTION.
|
---|
1312 | ************************************************************/
|
---|
1313 | int main(int argc, char *argv[])
|
---|
1314 | {
|
---|
1315 | if (argc > 1)
|
---|
1316 | {
|
---|
1317 | cout << "Sorry, this program does not accept options (yet)." << endl;
|
---|
1318 | cout << "Usage: just launch it without arguments." << endl;
|
---|
1319 | cout << "Once launched, you can load a fits file (compressed: .fits.gz) using the \"Load New File\" button" << endl;
|
---|
1320 | cout << "Events stepping lets you crawl the events inside the loaded file, while the number between the \"-\" and \"+\" buttons determines how many events are skipped at every button click" << endl;
|
---|
1321 | cout << "Play/Pause start or stops the animation of the camera (looping over the current event's slices), while the \"slices per sec\" number determines how many slices are diplayed every second" << endl;
|
---|
1322 | cout << "The ranges, Red, Green and Blue series of inputs can be used to tweak the displayed colours. The range goes from 0 to 1, which would map to -32768 and 32767 respectively" << endl;
|
---|
1323 | cout << "Only 3 intermediate steps can be given, and the given colours are interpolated for the pixels accordingly" << endl;
|
---|
1324 | cout << "Eventually, the Draw Impulse, Draw Patches and Blur pixels checkboxes can be used to change what is displayed." << endl;
|
---|
1325 | cout << "when \"Draw Impulse\" is checked, it is possible to select a pixel by double clicking on it, and the current slice can be drag and dropped." << endl;
|
---|
1326 | return 0;
|
---|
1327 | }
|
---|
1328 | QApplication app(argc, argv);
|
---|
1329 |
|
---|
1330 | if (!QGLFormat::hasOpenGL()) {
|
---|
1331 | std::cout << "This system has no OpenGL support" << std::endl;
|
---|
1332 | return 1;
|
---|
1333 | }
|
---|
1334 |
|
---|
1335 | QMainWindow mainWindow;
|
---|
1336 |
|
---|
1337 | Ui_MainWindow myUi;
|
---|
1338 | myUi.setupUi(&mainWindow);
|
---|
1339 |
|
---|
1340 | RawDataViewer *canvas = myUi.GLWindow;
|
---|
1341 |
|
---|
1342 | QObject::connect(myUi.eventsMinusButton, SIGNAL(clicked()),
|
---|
1343 | canvas, SLOT(minusEvent()));
|
---|
1344 | QObject::connect(myUi.eventsPlusButton, SIGNAL(clicked()),
|
---|
1345 | canvas, SLOT(plusEvent()));
|
---|
1346 | QObject::connect(myUi.eventsStepBox, SIGNAL(valueChanged(int)),
|
---|
1347 | canvas, SLOT(setEventStep(int)));
|
---|
1348 | myUi.colorRange0->setValue(ss[0]);
|
---|
1349 | myUi.colorRange1->setValue(ss[1]);
|
---|
1350 | myUi.colorRange2->setValue(ss[2]);
|
---|
1351 | myUi.colorRange3->setValue(ss[3]);
|
---|
1352 | myUi.colorRange4->setValue(ss[4]);
|
---|
1353 | myUi.redValue0->setValue(rr[0]);
|
---|
1354 | myUi.redValue1->setValue(rr[1]);
|
---|
1355 | myUi.redValue2->setValue(rr[2]);
|
---|
1356 | myUi.redValue3->setValue(rr[3]);
|
---|
1357 | myUi.redValue4->setValue(rr[4]);
|
---|
1358 | myUi.greenValue0->setValue(gg[0]);
|
---|
1359 | myUi.greenValue1->setValue(gg[1]);
|
---|
1360 | myUi.greenValue2->setValue(gg[2]);
|
---|
1361 | myUi.greenValue3->setValue(gg[3]);
|
---|
1362 | myUi.greenValue4->setValue(gg[4]);
|
---|
1363 | myUi.blueValue0->setValue(bb[0]);
|
---|
1364 | myUi.blueValue1->setValue(bb[1]);
|
---|
1365 | myUi.blueValue2->setValue(bb[2]);
|
---|
1366 | myUi.blueValue3->setValue(bb[3]);
|
---|
1367 | myUi.blueValue4->setValue(bb[4]);
|
---|
1368 |
|
---|
1369 | UIConnector connector;
|
---|
1370 | connector.setViewer(canvas);
|
---|
1371 | connector.boardsTimeList = myUi.boardsTimeList;
|
---|
1372 | connector.startPixelsList = myUi.startPixelsList;
|
---|
1373 | connector.startTimeMarksList = myUi.startTimeMarksList;
|
---|
1374 | connector.fileLoadedLabel = myUi.fileLoadedLabel;
|
---|
1375 | connector.runNumberLabel = myUi.runNumberLabel;
|
---|
1376 | connector.numberOfSlicesLabel = myUi.numberOfSlicesLabel;
|
---|
1377 | connector.numberOfTimeMarksLabel = myUi.numberOfTimeMarksLabel;
|
---|
1378 | connector.runTypeLabel = myUi.runTypeLabel;
|
---|
1379 | connector.firstTimeLabel = myUi.timeOfFirstDataLabel;
|
---|
1380 | connector.lastTimeLabel = myUi.timeOfLastDataLabel;
|
---|
1381 |
|
---|
1382 | QObject::connect(myUi.drawPatchCheckBox, SIGNAL(stateChanged(int)),
|
---|
1383 | &connector, SLOT(drawPatchesCheckChange(int)));
|
---|
1384 | QObject::connect(myUi.drawImpulseCheckBox, SIGNAL(stateChanged(int)),
|
---|
1385 | &connector, SLOT(drawImpulseCheckChange(int)));
|
---|
1386 | QObject::connect(myUi.drawBlurCheckBox, SIGNAL(stateChanged(int)),
|
---|
1387 | &connector, SLOT(drawBlurCheckChange(int)));
|
---|
1388 | QObject::connect(canvas, SIGNAL(newFileLoaded()),
|
---|
1389 | &connector, SLOT(newFileLoaded()));
|
---|
1390 |
|
---|
1391 | QObject::connect(myUi.loadNewFileButton, SIGNAL(clicked()),
|
---|
1392 | &connector, SLOT(loadNewFileClicked()));
|
---|
1393 |
|
---|
1394 | QObject::connect(myUi.colorRange0, SIGNAL(valueChanged(double)),
|
---|
1395 | &connector, SLOT(rangeChanged0(double)));
|
---|
1396 |
|
---|
1397 | QObject::connect(myUi.colorRange1, SIGNAL(valueChanged(double)),
|
---|
1398 | &connector, SLOT(rangeChanged1(double)));
|
---|
1399 |
|
---|
1400 | QObject::connect(myUi.colorRange2, SIGNAL(valueChanged(double)),
|
---|
1401 | &connector, SLOT(rangeChanged2(double)));
|
---|
1402 |
|
---|
1403 | QObject::connect(myUi.colorRange3, SIGNAL(valueChanged(double)),
|
---|
1404 | &connector, SLOT(rangeChanged3(double)));
|
---|
1405 |
|
---|
1406 | QObject::connect(myUi.colorRange4, SIGNAL(valueChanged(double)),
|
---|
1407 | &connector, SLOT(rangeChanged4(double)));
|
---|
1408 |
|
---|
1409 | QObject::connect(myUi.redValue0, SIGNAL(valueChanged(double)),
|
---|
1410 | &connector, SLOT(redChanged0(double)));
|
---|
1411 |
|
---|
1412 | QObject::connect(myUi.redValue1, SIGNAL(valueChanged(double)),
|
---|
1413 | &connector, SLOT(redChanged1(double)));
|
---|
1414 |
|
---|
1415 | QObject::connect(myUi.redValue2, SIGNAL(valueChanged(double)),
|
---|
1416 | &connector, SLOT(redChanged2(double)));
|
---|
1417 |
|
---|
1418 | QObject::connect(myUi.redValue3, SIGNAL(valueChanged(double)),
|
---|
1419 | &connector, SLOT(redChanged3(double)));
|
---|
1420 |
|
---|
1421 | QObject::connect(myUi.redValue4, SIGNAL(valueChanged(double)),
|
---|
1422 | &connector, SLOT(redChanged4(double)));
|
---|
1423 |
|
---|
1424 | QObject::connect(myUi.greenValue0, SIGNAL(valueChanged(double)),
|
---|
1425 | &connector, SLOT(greenChanged0(double)));
|
---|
1426 |
|
---|
1427 | QObject::connect(myUi.greenValue1, SIGNAL(valueChanged(double)),
|
---|
1428 | &connector, SLOT(greenChanged1(double)));
|
---|
1429 |
|
---|
1430 | QObject::connect(myUi.greenValue2, SIGNAL(valueChanged(double)),
|
---|
1431 | &connector, SLOT(greenChanged2(double)));
|
---|
1432 |
|
---|
1433 | QObject::connect(myUi.greenValue3, SIGNAL(valueChanged(double)),
|
---|
1434 | &connector, SLOT(greenChanged3(double)));
|
---|
1435 |
|
---|
1436 | QObject::connect(myUi.greenValue4, SIGNAL(valueChanged(double)),
|
---|
1437 | &connector, SLOT(greenChanged4(double)));
|
---|
1438 |
|
---|
1439 | QObject::connect(myUi.blueValue0, SIGNAL(valueChanged(double)),
|
---|
1440 | &connector, SLOT(blueChanged0(double)));
|
---|
1441 |
|
---|
1442 | QObject::connect(myUi.blueValue1, SIGNAL(valueChanged(double)),
|
---|
1443 | &connector, SLOT(blueChanged1(double)));
|
---|
1444 |
|
---|
1445 | QObject::connect(myUi.blueValue2, SIGNAL(valueChanged(double)),
|
---|
1446 | &connector, SLOT(blueChanged2(double)));
|
---|
1447 |
|
---|
1448 | QObject::connect(myUi.blueValue3, SIGNAL(valueChanged(double)),
|
---|
1449 | &connector, SLOT(blueChanged3(double)));
|
---|
1450 |
|
---|
1451 | QObject::connect(myUi.blueValue4, SIGNAL(valueChanged(double)),
|
---|
1452 | &connector, SLOT(blueChanged4(double)));
|
---|
1453 |
|
---|
1454 | QObject::connect(myUi.slicesPerSecValue, SIGNAL(valueChanged(double)),
|
---|
1455 | &connector, SLOT(slicesPerSecondChanged(double)));
|
---|
1456 | QObject::connect(myUi.playPauseButton, SIGNAL(clicked()),
|
---|
1457 | &connector, SLOT(playPauseClicked()));
|
---|
1458 |
|
---|
1459 | QObject::connect(canvas, SIGNAL(signalCurrentSlice(int)),
|
---|
1460 | &connector, SLOT(currentSliceHasChanged(int)));
|
---|
1461 | QObject::connect(canvas, SIGNAL(signalCurrentEvent(int)),
|
---|
1462 | &connector, SLOT(currentEventHasChanged(int)));
|
---|
1463 |
|
---|
1464 | QObject::connect(&connector, SIGNAL(updateCurrentSliceDisplay(QString)),
|
---|
1465 | myUi.displayingSliceLabel, SLOT(setText(const QString)));
|
---|
1466 | QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(QString)),
|
---|
1467 | myUi.displayingEventLabel, SLOT(setText(const QString)));
|
---|
1468 | QObject::connect(&connector, SIGNAL(updateCurrentPCTime(QString)),
|
---|
1469 | myUi.PCTimeLabel, SLOT(setText(const QString)));
|
---|
1470 | QObject::connect(&connector, SIGNAL(updateCurrentSoftTrigger(QString)),
|
---|
1471 | myUi.softwareTriggerLabel, SLOT(setText(const QString)));
|
---|
1472 | QObject::connect(&connector, SIGNAL(updateCurrentTriggerType(QString)),
|
---|
1473 | myUi.triggerTypeLabel, SLOT(setText(const QString)));
|
---|
1474 |
|
---|
1475 | mainWindow.show();
|
---|
1476 |
|
---|
1477 | return app.exec();
|
---|
1478 | }
|
---|