source: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc@ 11920

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