Changeset 11650


Ignore:
Timestamp:
07/27/11 12:43:50 (13 years ago)
Author:
lyard
Message:
removed warning messages
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc

    r11616 r11650  
    1515#include </home/lyard/Code/display.C>
    1616#endif
     17
     18#define VALUES_SPAN 4096
    1719
    1820#include <QtGui/QFileDialog>
     
    2729
    2830//bounding box for diplaying the impulse curve
    29 float bboxMin[2] = {-1,-0.9};
    30 float bboxMax[2] = {1,-0.3};
     31float bboxMin[2] = {-0.8,-0.9};
     32float bboxMax[2] = {0.8,-0.3};
    3133/************************************************************
    3234 * UPDATE NEIGHBORS recalculate the neighbors of the current pixels.
     
    428430        else
    429431#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);
    431433#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);
    433435#endif
    434436        int index = 0;
     
    491493    if (!nRoi)
    492494        return;
     495
     496    float xZoom, yZoom;
     497    xZoom = yZoom = 1.0f;
     498
    493499    glBegin(GL_LINES);
     500    glLineWidth(1.0f);
    494501    glColor3f(0.5,0.5,0.5);
    495502    glVertex2f(bboxMin[0], bboxMin[1]);
     
    497504    glVertex2f(bboxMin[0], bboxMin[1]);
    498505    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);
    500508    float xRange = bboxMax[0] - bboxMin[0];
    501509    float yRange = bboxMax[1] - bboxMin[1];
     
    505513#ifdef LOAD_RAW
    506514        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));
    508516        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));
    510518#else
    511519        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));
    513521        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));
    515523#endif
    516524    }
     
    520528    glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
    521529               bboxMax[1]);
    522 
    523530    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
    524546}
    525547/************************************************************
    526548 * CONSTRUCTOR.
    527549 ************************************************************/
    528 RawDataViewer::RawDataViewer(QWidget *parent) : QGLWidget(parent)
     550RawDataViewer::RawDataViewer(QWidget *cParent) : QGLWidget(cParent)
    529551{
    530552    setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
     
    668690 * RESIZE GL. reshapes the ortho projection to match the current window size
    669691 ************************************************************/
    670 void RawDataViewer::resizeGL(int width, int height)
    671 {
    672     glViewport(0, 0, width, height);
     692void RawDataViewer::resizeGL(int cWidth, int cHeight)
     693{
     694    glViewport(0, 0, cWidth, cHeight);
    673695    glMatrixMode(GL_PROJECTION);
    674696    glLoadIdentity();
    675     GLfloat windowRatio = (float)width/(float)height;
     697    GLfloat windowRatio = (float)cWidth/(float)cHeight;
    676698    if (windowRatio < 1)
    677699    {
    678700        windowRatio = 1.0f/windowRatio;
    679701        gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
    680         pixelSize = 2*viewSize/(float)width;
     702        pixelSize = 2*viewSize/(float)cWidth;
    681703        shownSizex = 2*viewSize;
    682704        shownSizey = 2*viewSize*windowRatio;
     
    685707    {
    686708        gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
    687         pixelSize = 2*viewSize/(float)height;
     709        pixelSize = 2*viewSize/(float)cHeight;
    688710        shownSizex = 2*viewSize*windowRatio;
    689711        shownSizey = 2*viewSize;
     
    735757 * MOUSE PRESS EVENT. mouse click handler.
    736758 ************************************************************/
    737 void RawDataViewer::mousePressEvent(QMouseEvent *event)
    738 {
    739     lastPos = event->pos();
    740     setCorrectSlice(event);
     759void RawDataViewer::mousePressEvent(QMouseEvent *cEvent)
     760{
     761    lastPos = cEvent->pos();
     762    setCorrectSlice(cEvent);
    741763    updateGL();
    742764}
     
    746768 * clicked, and if so, which slice should be displayed
    747769 ************************************************************/
    748 void RawDataViewer::setCorrectSlice(QMouseEvent* event)
     770void RawDataViewer::setCorrectSlice(QMouseEvent* cEvent)
    749771{
    750772    if (!drawImpulse)
    751773        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])
    758780        return;
    759     whichSlice = (x - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
     781    whichSlice = (cx - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
    760782    emit signalCurrentSlice(whichSlice);
    761783}
     
    764786 * MOUSE MOVE EVENT. used to track the dragging of slices display
    765787 ************************************************************/
    766 void RawDataViewer::mouseMoveEvent(QMouseEvent *event)
    767 {
    768     if (event->buttons() & Qt::LeftButton) {
    769         setCorrectSlice(event);
     788void RawDataViewer::mouseMoveEvent(QMouseEvent *cEvent)
     789{
     790    if (cEvent->buttons() & Qt::LeftButton) {
     791        setCorrectSlice(cEvent);
    770792        updateGL();
    771     } else if (event->buttons() & Qt::RightButton) {
     793    } else if (cEvent->buttons() & Qt::RightButton) {
    772794        updateGL();
    773795    }
    774     lastPos = event->pos();
     796    lastPos = cEvent->pos();
    775797}
    776798
     
    778800 * MOUSE DOUBLE CLICK EVENT. used to select pixels
    779801 ************************************************************/
    780 void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *event)
    781 {
    782     int face = PixelAtPosition(event->pos());
     802void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *cEvent)
     803{
     804    int face = PixelAtPosition(cEvent->pos());
    783805    if (face != -1) {
    784806        selectedPixel = face;
     
    790812 * PIXEL AT POSITION. figures out which camera pixel was clicked.
    791813 ************************************************************/
    792 int RawDataViewer::PixelAtPosition(const QPoint &pos)
     814int RawDataViewer::PixelAtPosition(const QPoint &cPos)
    793815{
    794816    const int MaxSize = 512;
     
    809831    glLoadIdentity();
    810832    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()),
    812834            1.0, 1.0, viewport);
    813835
     
    946968 * UICONNECTOR CONSTRUCTOR
    947969 ************************************************************/
    948 UIConnector::UIConnector(QWidget* parent)
     970UIConnector::UIConnector(QWidget*)
    949971{
    950972    timer.setInterval(1000.0);
     
    12361258 * CURRENT EVENT HAS CHANGED. ui handler
    12371259 ************************************************************/
    1238 void UIConnector::currentEventHasChanged(int event)
     1260void UIConnector::currentEventHasChanged(int cEvent)
    12391261{
    12401262    ostringstream str;
    1241     str << "Displaying Event " << event;
     1263    str << "Displaying Event " << cEvent;
    12421264    QString qstr(str.str().c_str());
    12431265    emit updateCurrentEventDisplay(qstr);
Note: See TracChangeset for help on using the changeset viewer.