Changeset 11985 for trunk/FACT++


Ignore:
Timestamp:
09/06/11 17:13:56 (13 years ago)
Author:
lyard
Message:
various display changes
Location:
trunk/FACT++/gui
Files:
4 edited

Legend:

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

    r11941 r11985  
    255255                 this, SLOT(minus90RotationPlease(bool)));
    256256
     257        connect(this, SIGNAL(signalUpdateCamera()),
     258                this, SLOT(timedUpdate()));
    257259
    258260
     
    345347        median /= 2;
    346348
    347         str << "Min: " << min << " Max: " << max << " Mean: " << mean << " RMS: " << rms << " Median: " << median;
     349        str << "Min: " << min << endl << " Max: " << max << " Mean: " << mean << " RMS: " << rms << " Median: " << median;
    348350        str << " Units: " << unitsText;
    349351        dataText = str.str();
     352
     353        fmin = min;
     354        fmax = max;
     355        fmean = mean;
     356        frms = rms;
     357        fmedian = median;
    350358    }
    351359    void BasicGlCamera::DrawCameraText()
     
    359367        float shiftx = 0.01f;//0.55f;
    360368        float shifty = 0.01f;//0.65f;
    361         renderText(-shownSizex/2.f + shiftx, -shownSizey/2.f + shifty, 0.f, QString(dataText.c_str()));
     369        renderText(-shownSizex/2.f + shiftx, 0.f, 0.f, QString(dataText.c_str()));//-shownSizey/2.f + shifty, 0.f, QString(dataText.c_str()));
    362370
    363371
     
    652660    {
    653661
     662    }
     663    void BasicGlCamera::timedUpdate()
     664    {
     665        if (isVisible())
     666            updateGL();
     667    }
     668    void BasicGlCamera::updateCamera()
     669    {
     670        emit signalUpdateCamera();
    654671    }
    655672    void BasicGlCamera::drawCamera(bool alsoWire)
  • trunk/FACT++/gui/BasicGlCamera.h

    r11941 r11985  
    7575    void SetMax(int64_t max);
    7676    void SetAutoRefresh(bool on);
     77    void updateCamera();
    7778
    7879    float ss[5];// = {0.00, 0.25, 0.5, 0.75, 1.00};
     
    9192        void plus90RotationPlease(bool);
    9293        void minus90RotationPlease(bool);
     94        void timedUpdate();
    9395
    9496Q_SIGNALS:
     
    9799         void signalPixelDoubleClick(int pixel);
    98100         void colorPaletteHasChanged();
     101         void signalUpdateCamera();
    99102
    100103
     
    111114    virtual void setPatchColor(int id, float color[3]);
    112115    virtual int PixelAtPosition(const QPoint &pos);
     116    virtual void DrawCameraText();
    113117    void drawHexagon(int index, bool solid);
    114118
     
    131135    float shownSizey;
    132136    float pixelSize;
    133     void DrawCameraText();
    134137    virtual void UpdateText();
    135138    void DrawScale();
     
    166169    float hexTolerance;
    167170     int numVertices;
     171  protected:
     172     float fmin, fmax, fmean, frms, fmedian;
    168173
    169174
  • trunk/FACT++/gui/QCameraWidget.cc

    r11944 r11985  
    2121
    2222         glTranslatef(0,-0.44,0);
     23         glTranslatef(-0.1,0,0);
    2324         glRotatef(cameraRotation, 0,0,-1);
    2425         if (cameraRotation == 90)
     
    3334         glScalef(1.5, 1.5, 1.5);
    3435         drawCamera(true);
     36
     37         drawPatches();
    3538
    3639         glLineWidth(1.0f);
     
    4043             drawHexagon(*it, false);
    4144         }
    42          drawPatches();
    4345
    4446        glLineWidth(1.0f);
     
    5961    void QCameraWidget::drawCamera(bool alsoWire)
    6062    {
     63
    6164        if (!pixelColorUpToDate)
    6265            CalculatePixelsColor();
     
    7679        }
    7780    }
     81    void QCameraWidget::DrawCameraText()
     82    {
     83        glPushMatrix();
     84        glLoadIdentity();
     85
     86
     87
     88        int textSize = (int)(height()*14/600);
     89        setFont(QFont("Monospace", textSize));
     90        qglColor(QColor(255, 223, 127));
     91
     92        //first let's draw the usual data
     93        //title
     94        renderText(-shownSizex/2.f + 0.01f, shownSizey/2.f - textSize*pixelSize - 0.01f, 0.f, QString(titleText.c_str()));
     95        //stats
     96        ostringstream str;
     97        str.precision(2);
     98        str.setf(ios::fixed,ios::floatfield);
     99        str << "Med. " << fmedian << unitsText;
     100        renderText(1, height()-4*textSize-10, QString(str.str().c_str()));
     101        str.str("");
     102        str << "Mea. " << fmean <<  unitsText;
     103        renderText(1, height()-3*textSize-8, QString(str.str().c_str()));
     104        str.str("");
     105        str << "Rms  " << frms <<  unitsText;
     106        renderText(1, height()-2*textSize-6, QString(str.str().c_str()));
     107        str.str("");
     108        str << "Min. " << fmin << unitsText;
     109        renderText(1, height()-1*textSize-4, QString(str.str().c_str()));
     110        str.str("");
     111        str << "Max. " << fmax << unitsText;
     112        renderText(1, height()-2, QString(str.str().c_str()));
     113        //then draw the values beside the scale
     114        //the difficulty here is to write the correct min/max besides the scale
     115        //it depends whether the actual mean of the data is given by the user
     116        //or not. the values given by user are fMin and fMax, while the data
     117        //real min/max are fmin and fmax (I know, quite confusing... sorry about that)
     118        //so. first let's see what is the span of one pixel
     119        float min = (fMin < 0) ? fmin : fMin;
     120        float max = (fMax < 0) ? fmax : fMax;
     121        textSize = (int)(height()*12/600);
     122        setFont(QFont("Monospace", textSize));
     123        float pixelSpan = (height() - textSize - 1)/(max - min);
     124
     125        //draw the scale values
     126        float value = min;
     127        int fontWidth = textSize;
     128        if (textSize > 12) fontWidth-=3; else fontWidth -=2;
     129        if (textSize < 7) fontWidth++;
     130        for (int i=0;i<6;i++)
     131        {
     132            str.str("");
     133            str << value << unitsText;
     134            int h = (value - min)*pixelSpan;
     135            if (logScale && h != 0)
     136            {
     137                float fh = h;
     138                float mult = (max - min)*pixelSpan;
     139                fh = log10(h*10.f/mult);
     140                fh *= mult;
     141                h = (int)fh;
     142            }
     143            h = height()-h;
     144            int w = width() - (width()/50) - fontWidth*str.str().size();
     145            if (i==0 || i==5) w -= width()/50;
     146            if (i!=0 && i!=5) h -= textSize/2;
     147            renderText(w, h, QString(str.str().c_str()));
     148            value += (max - min)/5;
     149        }
     150
     151/*
     152        str.str("");
     153        str << min << unitsText;
     154        int fontWidth = textSize;
     155        if (textSize > 12) fontWidth-=3; else fontWidth -= 2;
     156        //height of min ?
     157        int hmin = (min - min)*pixelSpan;
     158        hmin = height() - hmin;
     159        renderText(width() - (width()/25) - fontWidth*str.str().size(), hmin, QString(str.str().c_str()));
     160        str.str("");
     161        str << max << unitsText;
     162        int hmax = (max - min)*pixelSpan;
     163        hmax = height() - hmax;
     164        renderText(width() - (width()/25) - fontWidth*str.str().size(), hmax, QString(str.str().c_str()));
     165*/
     166        glPopMatrix();
     167
     168        textSize = (int)(600*14/600);
     169        setFont(QFont("Times", textSize));
     170    }
    78171    void QCameraWidget::drawPatches()
    79172    {
    80         glLineWidth(2.0f);
     173        glLineWidth(3.0f);
    81174        glColor3fv(patchesCoulour);
    82175         glBegin(GL_LINES);
  • trunk/FACT++/gui/QCameraWidget.h

    r11941 r11985  
    4141    void Reset();
    4242    void drawCamera(bool alsoWire);
     43    void DrawCameraText();
    4344    void drawPatches();
    4445     void SetEnable(int idx, bool b);
Note: See TracChangeset for help on using the changeset viewer.