Index: trunk/FACT++/gui/BasicGlCamera.h
===================================================================
--- trunk/FACT++/gui/BasicGlCamera.h	(revision 11866)
+++ trunk/FACT++/gui/BasicGlCamera.h	(revision 11874)
@@ -73,4 +73,5 @@
     float shownSizex;
     float shownSizey;
+    float pixelSize;
 private:
     void updateNeighbors(int currentPixel);
@@ -82,5 +83,4 @@
     float hexTolerance;
     float viewSize;
-    float pixelSize;
     GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
     PixelsNeighbors neighbors[MAX_NUM_PIXELS];
Index: trunk/FACT++/gui/QCameraWidget.cc
===================================================================
--- trunk/FACT++/gui/QCameraWidget.cc	(revision 11866)
+++ trunk/FACT++/gui/QCameraWidget.cc	(revision 11874)
@@ -14,7 +14,128 @@
         fMax = -1;
         lastFace = -1;
+        unitsText = "";
+        titleText = "This is a title";
+        dataText = "";
+        logScale = false;
+        cameraRotation = 0;
         CalculatePixelsColor();
 
-    }
+        setFont(QFont("Arial", 8));
+        int buttonShift=0;
+        scaleLabel = new QLabel("Scale", this);
+//        buttonShift += scaleLabel->height();
+
+        linearButton = new QRadioButton("Linear", this);
+        linearButton->move(scaleLabel->width(), buttonShift);
+        buttonShift += linearButton->height();
+
+        logButton = new QRadioButton("Log", this);
+        logButton->move(scaleLabel->width(), buttonShift);
+        buttonShift += logButton->height()*1.1f;
+
+        colorPaletteLabel = new QLabel("Colour\nPalette", this);
+        colorPaletteLabel->move(0, buttonShift);
+ //       buttonShift += colorPaletteLabel->height();
+
+        regularPaletteButton = new QRadioButton("Regular", this);
+        regularPaletteButton->move(colorPaletteLabel->width(), buttonShift);
+        buttonShift += regularPaletteButton->height();
+
+        prettyPaletteButton = new QRadioButton("Pretty", this);
+        prettyPaletteButton->move(colorPaletteLabel->width(), buttonShift);
+        buttonShift += prettyPaletteButton->height();
+
+        greyScalePaletteButton = new QRadioButton("Grey Scale", this);
+        greyScalePaletteButton->move(colorPaletteLabel->width(), buttonShift);
+        buttonShift += greyScalePaletteButton->height();
+
+        glowingPaletteButton = new QRadioButton("Glowing", this);
+        glowingPaletteButton->move(colorPaletteLabel->width(), buttonShift);
+        buttonShift += glowingPaletteButton->height()*1.1f;
+
+        rotationLabel = new QLabel("Camera\nRotation", this);
+        rotationLabel->move(0, buttonShift);
+ //       buttonShift += rotationLabel->height();
+
+        zeroRotationButton = new QRadioButton("0°", this);
+        zeroRotationButton->move(rotationLabel->width(), buttonShift);
+        buttonShift += zeroRotationButton->height();
+
+        minus90RotationButton = new QRadioButton("-90°", this);
+        minus90RotationButton->move(rotationLabel->width(), buttonShift);
+        buttonShift += minus90RotationButton->height();
+
+        plus90Rotationbutton = new QRadioButton("+90°", this);
+        plus90Rotationbutton->move(rotationLabel->width(), buttonShift);
+
+
+        scaleGroup = new QButtonGroup(pparent);
+        colorGroup = new QButtonGroup(pparent);
+        rotationGroup = new QButtonGroup(pparent);
+        scaleGroup->addButton(linearButton);
+        scaleGroup->addButton(logButton);
+        colorGroup->addButton(regularPaletteButton);
+        colorGroup->addButton(prettyPaletteButton);
+        colorGroup->addButton(greyScalePaletteButton);
+        colorGroup->addButton(glowingPaletteButton);
+        rotationGroup->addButton(zeroRotationButton);
+        rotationGroup->addButton(minus90RotationButton);
+        rotationGroup->addButton(plus90Rotationbutton);
+
+        linearButton->setChecked(true);
+        regularPaletteButton->setChecked(true);
+        zeroRotationButton->setChecked(true);
+
+//        linearButton->palette.setColor();
+
+        linearButton->setAutoFillBackground(true);
+        logButton->setAutoFillBackground(true);
+        regularPaletteButton->setAutoFillBackground(true);
+        prettyPaletteButton->setAutoFillBackground(true);
+        greyScalePaletteButton->setAutoFillBackground(true);
+        glowingPaletteButton->setAutoFillBackground(true);
+        zeroRotationButton->setAutoFillBackground(true);
+        minus90RotationButton->setAutoFillBackground(true);
+        plus90Rotationbutton->setAutoFillBackground(true);
+        scaleLabel->setAutoFillBackground(true);
+        colorPaletteLabel->setAutoFillBackground(true);
+        rotationLabel->setAutoFillBackground(true);
+
+        linearButton->hide();
+        logButton->hide();
+        regularPaletteButton->hide();
+        prettyPaletteButton->hide();
+        greyScalePaletteButton->hide();
+        glowingPaletteButton->hide();
+        zeroRotationButton->hide();
+        minus90RotationButton->hide();
+        plus90Rotationbutton->hide();
+        scaleLabel->hide();
+        colorPaletteLabel->hide();
+        rotationLabel->hide();
+
+        connect(linearButton, SIGNAL(toggled(bool)),
+                 this, SLOT(linearScalePlease(bool)));
+        connect(logButton, SIGNAL(toggled(bool)),
+                 this, SLOT(logScalePlease(bool)));
+        connect(regularPaletteButton, SIGNAL(toggled(bool)),
+                 this, SLOT(regularPalettePlease(bool)));
+        connect(prettyPaletteButton, SIGNAL(toggled(bool)),
+                 this, SLOT(prettyPalettePlease(bool)));
+        connect(greyScalePaletteButton, SIGNAL(toggled(bool)),
+                 this, SLOT(greyScalePalettePlease(bool)));
+        connect(glowingPaletteButton, SIGNAL(toggled(bool)),
+                 this, SLOT(glowingPalettePlease(bool)));
+        connect(zeroRotationButton, SIGNAL(toggled(bool)),
+                 this, SLOT(zeroRotationPlease(bool)));
+        connect(minus90RotationButton, SIGNAL(toggled(bool)),
+                 this, SLOT(plus90RotationPlease(bool)));
+        connect(plus90Rotationbutton, SIGNAL(toggled(bool)),
+                 this, SLOT(minus90RotationPlease(bool)));
+
+
+
+   }
+
     void QCameraWidget::paintGL()
     {
@@ -23,4 +144,14 @@
 
          glTranslatef(0,-0.44,0);
+         glRotatef(cameraRotation, 0,0,-1);
+         if (cameraRotation == 90)
+         {
+             glTranslatef(-0.45,-0.45,0);
+  //           cout << "correction" << endl;
+         }
+         if (cameraRotation == -90)
+         {
+             glTranslatef(0.45,-0.45,0);
+         }
          glScalef(1.5, 1.5, 1.5);
          drawCamera(true);
@@ -32,4 +163,9 @@
 
         DrawCameraText();
+
+        DrawScale();
+
+//        if (linearButton->isVisible())
+//            repaintInterface();
     }
     void QCameraWidget::drawCamera(bool alsoWire)
@@ -71,6 +207,65 @@
         fBold.assign(1440, false);
     }
+    void QCameraWidget::toggleInterfaceDisplay()
+    {
+        if (linearButton->isVisible())
+        {
+            linearButton->hide();
+            logButton->hide();
+            regularPaletteButton->hide();
+            prettyPaletteButton->hide();
+            greyScalePaletteButton->hide();
+            glowingPaletteButton->hide();
+            zeroRotationButton->hide();
+            minus90RotationButton->hide();
+            plus90Rotationbutton->hide();
+            scaleLabel->hide();
+            colorPaletteLabel->hide();
+            rotationLabel->hide();
+        }
+        else
+        {
+            linearButton->show();
+            logButton->show();
+            regularPaletteButton->show();
+            prettyPaletteButton->show();
+            greyScalePaletteButton->show();
+            glowingPaletteButton->show();
+            zeroRotationButton->show();
+            minus90RotationButton->show();
+            plus90Rotationbutton->show();
+            scaleLabel->show();
+            colorPaletteLabel->show();
+            rotationLabel->show();
+        }
+    }
+    void QCameraWidget::repaintInterface()
+    {
+        return;
+        setFont(QFont("Arial", 10));
+ //       glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+        linearButton->render(this);
+        logButton->render(this);
+        regularPaletteButton->render(this);
+        prettyPaletteButton->render(this);
+        greyScalePaletteButton->render(this);
+        glowingPaletteButton->render(this);
+        zeroRotationButton->render(this);
+        minus90RotationButton->render(this);
+        plus90Rotationbutton->render(this);
+ //       scaleLabel->repaint();
+        colorPaletteLabel->render(this);
+        rotationLabel->render(this);
+
+        scaleLabel->render(this);
+  //       cout << scaleLabel->autoFillBackground() << endl;
+    }
     void QCameraWidget::mousePressEvent(QMouseEvent *cEvent)
     {
+        if (cEvent->pos().x() > width()-(width()/50.f))
+        {
+            toggleInterfaceDisplay();
+            return;
+        }
         int face = PixelAtPosition(cEvent->pos());
         if (face != -1) {
@@ -180,4 +375,10 @@
                }
                color = float((fData[i]-dmin)/(dmax-dmin));
+               if (logScale)
+               {
+                   color *= 9;
+                   color += 1;
+                   color = log(color);
+               }
                if (!fEnable[i])
                    color = 0;
@@ -196,4 +397,5 @@
           }
           CalculatePatchColor();
+          UpdateText();
           pixelColorUpToDate = true;
      }
@@ -219,9 +421,43 @@
              updateGL();
      }
+     void QCameraWidget::UpdateText()
+     {
+         ostringstream str;
+         float min, max, mean, rms, median;
+         min = max = fData[0];
+         mean = 0;
+         rms = 0;
+         median = 0;
+         set<float> medianSet;
+         for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+         {
+             if (fData[i] < min)
+                 min = fData[i];
+             if (fData[i] > max)
+                 max = fData[i];
+             mean += fData[i];
+             rms += fData[i]*fData[i];
+             medianSet.insert((float)(fData[i]));
+         }
+         mean /= ACTUAL_NUM_PIXELS;
+         rms /= ACTUAL_NUM_PIXELS;
+         rms = sqrt(rms);
+         set<float>::iterator it = medianSet.begin();
+         for (int i=0;i<(ACTUAL_NUM_PIXELS/2)-1;i++)
+             it++;
+         median = *it;
+         it++;
+         median += *it;
+         median /= 2;
+
+         str << "Min: " << min << " Max: " << max << " Mean: " << mean << " RMS: " << rms << " Median: " << median;
+         str << " Units: " << unitsText;
+         dataText = str.str();
+     }
      void QCameraWidget::DrawCameraText()
      {
          glPushMatrix();
          glLoadIdentity();
-         cout << width() << " " << height() << endl;
+//         cout << width() << " " << height() << endl;
          int textSize = (int)(height()*14/600);
          setFont(QFont("Times", textSize));
@@ -229,5 +465,145 @@
          float shiftx = 0.01f;//0.55f;
          float shifty = 0.01f;//0.65f;
-         renderText(-shownSizex/2.f + shiftx, -shownSizey/2.f + shifty, 0.f, QString("This is a first text that is scaled according to the drawing size"));
+         renderText(-shownSizex/2.f + shiftx, -shownSizey/2.f + shifty, 0.f, QString(dataText.c_str()));
+
+
+         int textLength = titleText.size();
+         renderText(-shownSizex/2.f + shiftx, shownSizey/2.f - textSize*pixelSize - shifty, 0.f, QString(titleText.c_str()));
+
          glPopMatrix();
      }
+     void QCameraWidget::DrawScale()
+     {
+         glPushMatrix();
+         glLoadIdentity();
+         glPushAttrib(GL_POLYGON_BIT);
+         glShadeModel(GL_SMOOTH);
+         glBegin(GL_QUADS);
+         float oneX = shownSizex/2.f - shownSizex/50.f;
+         float twoX = shownSizex/2.f;
+         float oneY = -shownSizey/2.f;
+         float twoY = -shownSizey/4.f;
+         float threeY = 0;
+         float fourY = shownSizey/4.f;
+         float fiveY = shownSizey/2.f;
+         glColor3f(rr[0], gg[0], bb[0]);
+         glVertex2f(oneX, oneY);
+         glVertex2f(twoX, oneY);
+         glColor3f(rr[1], gg[1], bb[1]);
+         glVertex2f(twoX, twoY);
+         glVertex2f(oneX, twoY);
+
+         glVertex2f(oneX, twoY);
+         glVertex2f(twoX, twoY);
+         glColor3f(rr[2], gg[2], bb[2]);
+         glVertex2f(twoX, threeY);
+         glVertex2f(oneX, threeY);
+
+         glVertex2f(oneX, threeY);
+         glVertex2f(twoX, threeY);
+         glColor3f(rr[3], gg[3], bb[3]);
+         glVertex2f(twoX, fourY);
+         glVertex2f(oneX, fourY);
+
+         glVertex2f(oneX, fourY);
+         glVertex2f(twoX, fourY);
+         glColor3f(rr[4], gg[4], bb[4]);
+         glVertex2f(twoX, fiveY);
+         glVertex2f(oneX, fiveY);
+
+         glEnd();
+         glPopAttrib();
+         glPopMatrix();
+     }
+     void QCameraWidget::setUnits(string& units)
+     {
+         unitsText = units;
+     }
+     void QCameraWidget::setTitle(string& title)
+     {
+         titleText = title;
+     }
+     void QCameraWidget::linearScalePlease(bool checked)
+     {
+         if (!checked) return;
+         logScale = false;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::logScalePlease(bool checked)
+     {
+         if (!checked) return;
+         logScale = true;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::regularPalettePlease(bool checked)
+     {
+         if (!checked) return;
+         ss[0] = 0;    ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
+         rr[0] = 0.15; rr[1] = 0;     rr[2] = 0;    rr[3] = 1.0f;  rr[4] = 0.85f;
+         gg[0] = 0.15; gg[1] = 0;     gg[2] = 1;    gg[3] = 0;     gg[4] = 0.85f;
+         bb[0] = 0.15; bb[1] = 1;     bb[2] = 0;    bb[3] = 0;     bb[4] = 0.85f;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::prettyPalettePlease(bool checked)
+     {
+         if (!checked) return;
+         ss[0] = 0.f;    ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
+         rr[0] = 0.f; rr[1] = 0.35f;     rr[2] = 0.85f;    rr[3] = 1.0f;  rr[4] = 1.f;
+         gg[0] = 0.f; gg[1] = 0.10f;     gg[2] = 0.20f;    gg[3] = 0.73f;     gg[4] = 1.f;
+         bb[0] = 0.f; bb[1] = 0.03f;     bb[2] = 0.06f;    bb[3] = 0.00f;     bb[4] = 1.f;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::greyScalePalettePlease(bool checked)
+     {
+         if (!checked) return;
+         ss[0] = 0;    ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
+         rr[0] = 0; rr[1] = 0.25f;     rr[2] = 0.5f;    rr[3] = 0.75f;  rr[4] = 1.0f;
+         gg[0] = 0; gg[1] = 0.25f;     gg[2] = 0.5f;    gg[3] = 0.75f;     gg[4] = 1.0f;
+         bb[0] = 0; bb[1] = 0.25f;     bb[2] = 0.5f;    bb[3] = 0.75f;     bb[4] = 1.0f;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::glowingPalettePlease(bool checked)
+     {
+         if (!checked) return;
+         ss[0] = 0;    ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
+         rr[0] = 0.15; rr[1] = 0.5;     rr[2] = 1.f;    rr[3] = 0.0f;  rr[4] = 1.f;
+         gg[0] = 0.15; gg[1] = 0.5;     gg[2] = 1.f;    gg[3] = 0.5f;     gg[4] = 0.5f;
+         bb[0] = 0.15; bb[1] = 0.5;     bb[2] = 1;      bb[3] = 1.f;     bb[4] = 0.f;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::zeroRotationPlease(bool checked)
+     {
+         if (!checked) return;
+         cameraRotation = 0;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::plus90RotationPlease(bool checked)
+     {
+         if (!checked) return;
+         cameraRotation = 90;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
+     void QCameraWidget::minus90RotationPlease(bool checked)
+     {
+         if (!checked) return;
+         cameraRotation = -90;
+         pixelColorUpToDate = false;
+         if (isVisible())
+             updateGL();
+     }
Index: trunk/FACT++/gui/QCameraWidget.h
===================================================================
--- trunk/FACT++/gui/QCameraWidget.h	(revision 11866)
+++ trunk/FACT++/gui/QCameraWidget.h	(revision 11874)
@@ -4,4 +4,9 @@
 #include "BasicGlCamera.h"
 #include <valarray>
+#include <set>
+
+#include <QtGui/QRadioButton>
+#include <QtGui/QLabel>
+#include <QtGui/QButtonGroup>
 
 using namespace std;
@@ -31,5 +36,11 @@
     GLfloat patchColour[3];
 
+    string dataText;
+    string unitsText;
+    string titleText;
+
 public:
+    void setUnits(string& units);
+    void setTitle(string& title);
     QCameraWidget(QWidget *pparent = 0);
     void paintGL();
@@ -54,4 +65,15 @@
      void SetData(const valarray<double> &ddata);
 
+public Q_SLOTS:
+        void linearScalePlease(bool);
+        void logScalePlease(bool);
+        void regularPalettePlease(bool);
+        void prettyPalettePlease(bool);
+        void greyScalePalettePlease(bool);
+        void glowingPalettePlease(bool);
+        void zeroRotationPlease(bool);
+        void plus90RotationPlease(bool);
+        void minus90RotationPlease(bool);
+
 Q_SIGNALS:
          void signalCurrentPixel(int pixel);
@@ -63,4 +85,26 @@
      void CalculatePatchColor();
      void DrawCameraText();
+     void UpdateText();
+     void DrawScale();
+     void toggleInterfaceDisplay();
+     void repaintInterface();
+     QRadioButton* linearButton;
+     QRadioButton* logButton;
+     QRadioButton* regularPaletteButton;
+     QRadioButton* prettyPaletteButton;
+     QRadioButton* greyScalePaletteButton;
+     QRadioButton* glowingPaletteButton;
+     QRadioButton* zeroRotationButton;
+     QRadioButton* minus90RotationButton;
+     QRadioButton* plus90Rotationbutton;
+     QLabel*       scaleLabel;
+     QLabel*       colorPaletteLabel;
+     QLabel*       rotationLabel;
+     QButtonGroup* scaleGroup;
+     QButtonGroup* colorGroup;
+     QButtonGroup* rotationGroup;
+
+     bool logScale;
+     int cameraRotation;
 };
 
