Index: trunk/FACT++/gui/BasicGlCamera.cc
===================================================================
--- trunk/FACT++/gui/BasicGlCamera.cc	(revision 11859)
+++ trunk/FACT++/gui/BasicGlCamera.cc	(revision 11861)
@@ -89,13 +89,14 @@
             l++;
         }
-        buildPatchesIndices();
 
         for (int i=0;i<1440;i++)
             updateNeighbors(i);
 
+        buildPatchesIndices();
+
         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] =        rr[2] = 0;    rr[3] = 1.0f;  rr[4] = 0.85f;
+        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] =       bb[3] = 0;     bb[4] = 0.85f;
+        bb[0] = 0.15; bb[1] = 1;     bb[2] = 0;    bb[3] = 0;     bb[4] = 0.85f;
 
         fPixelStride = 1;
@@ -103,5 +104,5 @@
         fData.resize(1440);
         for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
-            fData[i] = (double)i/1.44;//(double)(i)/(double)(ACTUAL_NUM_PIXELS);
+            fData[i] = (double)i;///1.44;//(double)(i)/(double)(ACTUAL_NUM_PIXELS);
     }
     BasicGlCamera::~BasicGlCamera()
@@ -172,5 +173,4 @@
         for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
         {
-
             color = float(fData[i*fPixelStride+fcSlice]);// + ]eventData[nRoi*i + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
             int index = 0;
@@ -209,4 +209,13 @@
     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;
@@ -426,5 +435,5 @@
         numVertices = 0;
          GLfloat cVertex[2];
-         for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+         for (int i=0;i<NPIX;i++)
          {
              for (int j=0;j<6;j++)
@@ -452,5 +461,5 @@
              }
          }
-         for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+         for (int i=0;i<NPIX;i++)
          {
              for (int j=0;j<6;j++)
@@ -476,4 +485,5 @@
         vector<edge>::iterator it;
         bool erased = false;
+//        patchesIndices.resize(NTMARK);
         for (int i=0;i<NTMARK;i++)//for all patches
         {
@@ -510,4 +520,13 @@
             }
         }
-    }
-
+//        for (int i=0;i<NTMARK;i++)
+//        {
+//            cout << ".....................patch " << i << " size: " << patchesIndices[i].size() << endl;
+//            for (unsigned int j=0;j<patchesIndices[i].size();j++)
+//            {
+//               if (patchesIndices[i][j].first < 0 || patchesIndices[i][j].first > 3013)
+//                cout << patchesIndices[i][j].first << " and " << patchesIndices[i][j].second << " and " << j << endl;
+//            }
+//        }
+    }
+
Index: trunk/FACT++/gui/BasicGlCamera.h
===================================================================
--- trunk/FACT++/gui/BasicGlCamera.h	(revision 11859)
+++ trunk/FACT++/gui/BasicGlCamera.h	(revision 11861)
@@ -64,5 +64,8 @@
     float bb[5];// = {0.15, 1.00, 0.00, 0.00, 0.85};
  //   bool recalcColorPlease;
-    GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
+    GLfloat pixelsColor[NPIX][3];
+    GLfloat verticesList[NPIX*6][2];
+    vector<edge> patchesIndices[160];
+    int verticesIndices[NPIX][6];
 private:
     void updateNeighbors(int currentPixel);
@@ -80,11 +83,8 @@
     PixelsNeighbors neighbors[MAX_NUM_PIXELS];
 
-    GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
 
-    int hardwareMapping[1440];
-    int softwareMapping[1440];
+    int hardwareMapping[NPIX];
+    int softwareMapping[NPIX];
     int patches[160][9];
-    vector<edge> patchesIndices[160];
-    int verticesIndices[ACTUAL_NUM_PIXELS][6];
     int numVertices;
 
Index: trunk/FACT++/gui/QCameraWidget.cc
===================================================================
--- trunk/FACT++/gui/QCameraWidget.cc	(revision 11859)
+++ trunk/FACT++/gui/QCameraWidget.cc	(revision 11861)
@@ -133,4 +133,5 @@
          double dmin = fData[0];
           double dmax = fData[0];
+          if (fMin < 0 && fMax < 0)
           for (int i=0;i<1440;i++)
           {
@@ -144,13 +145,23 @@
           for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
            {
+               if (fData[i] < dmin)
+               {
+                   pixelsColor[i][0] = pixelsColor[i][1] = pixelsColor[i][2] = 0;
+                   continue;
+               }
+               if (fData[i] > dmax)
+               {
+                   pixelsColor[i][0] = pixelsColor[i][1] = pixelsColor[i][2] = 1;
+                   continue;
+               }
                color = float((fData[i]-dmin)/(dmax-dmin));
                if (!fEnable[i])
                    color = 0;
                int index = 0;
-               while (ss[index] < color)
+               while (ss[index] < color && index < 4)
                    index++;
                index--;
                if (index < 0) index = 0;
-               if (index > 3) index = 3;
+//               if (index > 3) index = 3;
                float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
                if (weight0 > 1.0f) weight0 = 1.0f;
