Changeset 11650 for trunk/FACT++
- Timestamp:
- 07/27/11 12:43:50 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
r11616 r11650 15 15 #include </home/lyard/Code/display.C> 16 16 #endif 17 18 #define VALUES_SPAN 4096 17 19 18 20 #include <QtGui/QFileDialog> … … 27 29 28 30 //bounding box for diplaying the impulse curve 29 float bboxMin[2] = {- 1,-0.9};30 float bboxMax[2] = { 1,-0.3};31 float bboxMin[2] = {-0.8,-0.9}; 32 float bboxMax[2] = {0.8,-0.3}; 31 33 /************************************************************ 32 34 * UPDATE NEIGHBORS recalculate the neighbors of the current pixels. … … 428 430 else 429 431 #ifdef LOAD_RAW 430 color = float(eventsData[eventNum][i][whichSlice]+ 32767)/65535.0f;432 color = float(eventsData[eventNum][i][whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1); 431 433 #else 432 color = float(eventData[nRoi*i + whichSlice]+ 32767)/65535.0f;434 color = float(eventData[nRoi*i + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1); 433 435 #endif 434 436 int index = 0; … … 491 493 if (!nRoi) 492 494 return; 495 496 float xZoom, yZoom; 497 xZoom = yZoom = 1.0f; 498 493 499 glBegin(GL_LINES); 500 glLineWidth(1.0f); 494 501 glColor3f(0.5,0.5,0.5); 495 502 glVertex2f(bboxMin[0], bboxMin[1]); … … 497 504 glVertex2f(bboxMin[0], bboxMin[1]); 498 505 glVertex2f(bboxMin[0], bboxMax[1]); 499 506 glVertex2f(bboxMin[0], (bboxMin[1]+bboxMax[1])/2.0f); 507 glVertex2f(bboxMax[0], (bboxMin[1]+bboxMax[1])/2.0f); 500 508 float xRange = bboxMax[0] - bboxMin[0]; 501 509 float yRange = bboxMax[1] - bboxMin[1]; … … 505 513 #ifdef LOAD_RAW 506 514 glVertex2f(bboxMin[0] + xRange*i/(float)nRoi, 507 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+ 32767) /65535.0);515 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1)); 508 516 glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi, 509 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+ 32767) /65535.0);517 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1)); 510 518 #else 511 519 glVertex2f(bboxMin[0] + xRange*i/(float)nRoi, 512 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+ 32767) /65535.0);520 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1)); 513 521 glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi, 514 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+ 32767) /65535.0);522 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+(VALUES_SPAN/2)) /(float)(VALUES_SPAN-1)); 515 523 #endif 516 524 } … … 520 528 glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi, 521 529 bboxMax[1]); 522 523 530 glEnd(); 531 glEnable(GL_MULTISAMPLE); 532 setFont(QFont("Times", 12)); 533 qglColor(QColor(255,223,127)); 534 float xShift = 0.10f; 535 float yShift = 0.01f; 536 renderText(bboxMin[0]-xShift/2.0f, bboxMax[1]+3*yShift, 0, QString("Volts")); 537 renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+1.05")); 538 renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+0.00"));//((bboxMin[1]+bboxMax[1])/2.0f) 539 renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("-1.05")); 540 541 renderText(bboxMax[0]+xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("Slices")); 542 renderText(bboxMin[0]-yShift/2.0f, bboxMin[1]-4*yShift, 0, QString("0")); 543 renderText(((bboxMin[0]+bboxMax[0])/2.0f)-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("512")); 544 renderText(bboxMax[0]-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("1024")); 545 524 546 } 525 547 /************************************************************ 526 548 * CONSTRUCTOR. 527 549 ************************************************************/ 528 RawDataViewer::RawDataViewer(QWidget * parent) : QGLWidget(parent)550 RawDataViewer::RawDataViewer(QWidget *cParent) : QGLWidget(cParent) 529 551 { 530 552 setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer)); … … 668 690 * RESIZE GL. reshapes the ortho projection to match the current window size 669 691 ************************************************************/ 670 void RawDataViewer::resizeGL(int width, int height)671 { 672 glViewport(0, 0, width, height);692 void RawDataViewer::resizeGL(int cWidth, int cHeight) 693 { 694 glViewport(0, 0, cWidth, cHeight); 673 695 glMatrixMode(GL_PROJECTION); 674 696 glLoadIdentity(); 675 GLfloat windowRatio = (float) width/(float)height;697 GLfloat windowRatio = (float)cWidth/(float)cHeight; 676 698 if (windowRatio < 1) 677 699 { 678 700 windowRatio = 1.0f/windowRatio; 679 701 gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio); 680 pixelSize = 2*viewSize/(float) width;702 pixelSize = 2*viewSize/(float)cWidth; 681 703 shownSizex = 2*viewSize; 682 704 shownSizey = 2*viewSize*windowRatio; … … 685 707 { 686 708 gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize); 687 pixelSize = 2*viewSize/(float) height;709 pixelSize = 2*viewSize/(float)cHeight; 688 710 shownSizex = 2*viewSize*windowRatio; 689 711 shownSizey = 2*viewSize; … … 735 757 * MOUSE PRESS EVENT. mouse click handler. 736 758 ************************************************************/ 737 void RawDataViewer::mousePressEvent(QMouseEvent * event)738 { 739 lastPos = event->pos();740 setCorrectSlice( event);759 void RawDataViewer::mousePressEvent(QMouseEvent *cEvent) 760 { 761 lastPos = cEvent->pos(); 762 setCorrectSlice(cEvent); 741 763 updateGL(); 742 764 } … … 746 768 * clicked, and if so, which slice should be displayed 747 769 ************************************************************/ 748 void RawDataViewer::setCorrectSlice(QMouseEvent* event)770 void RawDataViewer::setCorrectSlice(QMouseEvent* cEvent) 749 771 { 750 772 if (!drawImpulse) 751 773 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])774 float cx = (float)cEvent->x() * pixelSize - shownSizex/2; 775 float cy = ((float)height()-(float)cEvent->y())*pixelSize - shownSizey/2; 776 if (cx < bboxMin[0] || 777 cx > bboxMax[0] || 778 cy < bboxMin[1] || 779 cy > bboxMax[1]) 758 780 return; 759 whichSlice = ( x - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);781 whichSlice = (cx - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]); 760 782 emit signalCurrentSlice(whichSlice); 761 783 } … … 764 786 * MOUSE MOVE EVENT. used to track the dragging of slices display 765 787 ************************************************************/ 766 void RawDataViewer::mouseMoveEvent(QMouseEvent * event)767 { 768 if ( event->buttons() & Qt::LeftButton) {769 setCorrectSlice( event);788 void RawDataViewer::mouseMoveEvent(QMouseEvent *cEvent) 789 { 790 if (cEvent->buttons() & Qt::LeftButton) { 791 setCorrectSlice(cEvent); 770 792 updateGL(); 771 } else if ( event->buttons() & Qt::RightButton) {793 } else if (cEvent->buttons() & Qt::RightButton) { 772 794 updateGL(); 773 795 } 774 lastPos = event->pos();796 lastPos = cEvent->pos(); 775 797 } 776 798 … … 778 800 * MOUSE DOUBLE CLICK EVENT. used to select pixels 779 801 ************************************************************/ 780 void RawDataViewer::mouseDoubleClickEvent(QMouseEvent * event)781 { 782 int face = PixelAtPosition( event->pos());802 void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *cEvent) 803 { 804 int face = PixelAtPosition(cEvent->pos()); 783 805 if (face != -1) { 784 806 selectedPixel = face; … … 790 812 * PIXEL AT POSITION. figures out which camera pixel was clicked. 791 813 ************************************************************/ 792 int RawDataViewer::PixelAtPosition(const QPoint & pos)814 int RawDataViewer::PixelAtPosition(const QPoint &cPos) 793 815 { 794 816 const int MaxSize = 512; … … 809 831 glLoadIdentity(); 810 832 GLfloat windowRatio = GLfloat(width()) / GLfloat(height()); 811 gluPickMatrix(GLdouble( pos.x()), GLdouble(viewport[3] - pos.y()),833 gluPickMatrix(GLdouble(cPos.x()), GLdouble(viewport[3] - cPos.y()), 812 834 1.0, 1.0, viewport); 813 835 … … 946 968 * UICONNECTOR CONSTRUCTOR 947 969 ************************************************************/ 948 UIConnector::UIConnector(QWidget* parent)970 UIConnector::UIConnector(QWidget*) 949 971 { 950 972 timer.setInterval(1000.0); … … 1236 1258 * CURRENT EVENT HAS CHANGED. ui handler 1237 1259 ************************************************************/ 1238 void UIConnector::currentEventHasChanged(int event)1260 void UIConnector::currentEventHasChanged(int cEvent) 1239 1261 { 1240 1262 ostringstream str; 1241 str << "Displaying Event " << event;1263 str << "Displaying Event " << cEvent; 1242 1264 QString qstr(str.str().c_str()); 1243 1265 emit updateCurrentEventDisplay(qstr);
Note:
See TracChangeset
for help on using the changeset viewer.