Index: /trunk/FACT++/gui/BasicGlCamera.cc
===================================================================
--- /trunk/FACT++/gui/BasicGlCamera.cc	(revision 11864)
+++ /trunk/FACT++/gui/BasicGlCamera.cc	(revision 11865)
@@ -89,4 +89,9 @@
             l++;
         }
+
+        //now construct the correspondance between pixels and patches
+        for (int i=0;i<NTMARK;i++)
+            for (int j=0;j<9;j++)
+                pixelsPatch[softwareMapping[patches[i][j]]] = i;
 
         for (int i=0;i<1440;i++)
@@ -209,13 +214,4 @@
     void BasicGlCamera::drawPatches()
     {
-//        cout << "*************************DRAWING PATCHES**************************" << endl;
-//        for (int i=0;i<NTMARK;i++)
-//        {
-//            cout << ".....................patch " << i << endl;
-//            for (unsigned int j=0;patchesIndices[i].size();j++)
-//            {
-//                cout << patchesIndices[i][j].first << " and " << patchesIndices[i][j].second << endl;
-//            }
-//        }
         glLineWidth(2.0f);
         float backupRadius = hexRadius;
@@ -491,4 +487,6 @@
             for (int j=0;j<9;j++)//for all cells of the current patch
             {
+                if (softwareMapping[patches[i][j]] >= ACTUAL_NUM_PIXELS)
+                    continue;
                 for (int k=0;k<6;k++)//for all sides of the current cell
                 {
Index: /trunk/FACT++/gui/BasicGlCamera.h
===================================================================
--- /trunk/FACT++/gui/BasicGlCamera.h	(revision 11864)
+++ /trunk/FACT++/gui/BasicGlCamera.h	(revision 11865)
@@ -51,5 +51,5 @@
     virtual void mouseDoubleClickEvent(QMouseEvent *event);
     virtual void drawCamera(bool alsoWire);
-    void drawPatches();
+    virtual void drawPatches();
     int PixelAtPosition(const QPoint &pos);
     void drawHexagon(int index, bool solid);
@@ -68,4 +68,9 @@
     vector<edge> patchesIndices[160];
     int verticesIndices[NPIX][6];
+    int pixelsPatch[NPIX];
+    int softwareMapping[NPIX];
+    int patches[160][9];
+    float shownSizex;
+    float shownSizey;
 private:
     void updateNeighbors(int currentPixel);
@@ -78,6 +83,4 @@
     float viewSize;
     float pixelSize;
-    float shownSizex;
-    float shownSizey;
     GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
     PixelsNeighbors neighbors[MAX_NUM_PIXELS];
@@ -85,6 +88,4 @@
 
     int hardwareMapping[NPIX];
-    int softwareMapping[NPIX];
-    int patches[160][9];
     int numVertices;
 
Index: /trunk/FACT++/gui/QCameraWidget.cc
===================================================================
--- /trunk/FACT++/gui/QCameraWidget.cc	(revision 11864)
+++ /trunk/FACT++/gui/QCameraWidget.cc	(revision 11865)
@@ -6,4 +6,5 @@
     {
         fWhite = 0;
+        fWhitePatch = pixelsPatch[0];
         fBold.resize(1440);
         fEnable.resize(1440);
@@ -29,4 +30,6 @@
         glColor3f(1,1,1);
         drawHexagon(fWhite, false);
+
+        DrawCameraText();
     }
     void QCameraWidget::drawCamera(bool alsoWire)
@@ -49,4 +52,19 @@
         }
     }
+    void QCameraWidget::drawPatches()
+    {
+        glLineWidth(2.0f);
+        glColor3f(patchColour[0],patchColour[1],patchColour[2]);//0.5f, 0.5f, 0.3f);
+        glBegin(GL_LINES);
+//        for (int i=0;i<NTMARK;i++)
+//        {
+            for (unsigned int j=0;j<patchesIndices[fWhitePatch].size();j++)
+            {
+                glVertex2fv(verticesList[patchesIndices[fWhitePatch][j].first]);
+                glVertex2fv(verticesList[patchesIndices[fWhitePatch][j].second]);
+            }
+//        }
+        glEnd();
+    }
     void QCameraWidget::Reset()
     {
@@ -58,4 +76,6 @@
         if (face != -1) {
             fWhite = face;
+            fWhitePatch = pixelsPatch[fWhite];
+            CalculatePatchColor();
             emit signalCurrentPixel(face);
             updateGL();
@@ -75,4 +95,6 @@
         if (face != -1) {
             fWhite = face;
+            fWhitePatch = pixelsPatch[fWhite];
+            CalculatePatchColor();
             emit signalPixelDoubleClick(face);
             updateGL();
@@ -86,4 +108,6 @@
      {
          fWhite = idx;
+         fWhitePatch = pixelsPatch[fWhite];
+         CalculatePatchColor();
      }
      void QCameraWidget::SetEnable(int idx, bool b)
@@ -163,5 +187,4 @@
                index--;
                if (index < 0) index = 0;
-//               if (index > 3) index = 3;
                float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
                if (weight0 > 1.0f) weight0 = 1.0f;
@@ -172,5 +195,18 @@
                pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
           }
+          CalculatePatchColor();
           pixelColorUpToDate = true;
+     }
+     void QCameraWidget::CalculatePatchColor()
+     {
+         //calculate the patch contour color. let's use the anti-colour of the pixels
+         GLfloat averagePatchColour[3] = {0.0f,0.0f,0.0f};
+         for (int i=0;i<9;i++)
+             for (int j=0;j<3;j++)
+                 averagePatchColour[j] += pixelsColor[softwareMapping[patches[fWhitePatch][i]]][j];
+         for (int j=0;j<3;j++)
+             averagePatchColour[j] /= 9;
+         for (int j=0;j<3;j++)
+             patchColour[j] = 1.0f - averagePatchColour[j];
      }
      void QCameraWidget::SetData(const valarray<double> &ddata)
@@ -183,2 +219,15 @@
              updateGL();
      }
+     void QCameraWidget::DrawCameraText()
+     {
+         glPushMatrix();
+         glLoadIdentity();
+         cout << width() << " " << height() << endl;
+         int textSize = (int)(height()*14/600);
+         setFont(QFont("Times", textSize));
+         qglColor(QColor(255,223,127));
+         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"));
+         glPopMatrix();
+     }
Index: /trunk/FACT++/gui/QCameraWidget.h
===================================================================
--- /trunk/FACT++/gui/QCameraWidget.h	(revision 11864)
+++ /trunk/FACT++/gui/QCameraWidget.h	(revision 11865)
@@ -20,4 +20,5 @@
 
     int fWhite;
+    int fWhitePatch;
 
     int64_t fMin;
@@ -27,4 +28,6 @@
 
     bool pixelColorUpToDate;
+
+    GLfloat patchColour[3];
 
 public:
@@ -36,4 +39,5 @@
     void Reset();
     void drawCamera(bool alsoWire);
+    void drawPatches();
      void SetBold(int idx);
      void SetWhite(int idx);
@@ -57,4 +61,6 @@
 private:
      void CalculatePixelsColor();
+     void CalculatePatchColor();
+     void DrawCameraText();
 };
 
