Index: /trunk/FACT++/gui/BasicGlCamera.cc
===================================================================
--- /trunk/FACT++/gui/BasicGlCamera.cc	(revision 12011)
+++ /trunk/FACT++/gui/BasicGlCamera.cc	(revision 12012)
@@ -6,4 +6,18 @@
 #include <sstream>
 #include "src/tools.h"
+
+const PixelMapEntry PixelMap::empty = { 0, 0, 0, 0, 0, 0 };
+
+//static variables
+PixelMap BasicGlCamera::fPixelMap;
+GLfloat BasicGlCamera::pixelsCoords[MAX_NUM_PIXELS][3];
+PixelsNeighbors BasicGlCamera::neighbors[MAX_NUM_PIXELS];
+int BasicGlCamera::hardwareMapping[NPIX];
+GLfloat BasicGlCamera::verticesList[NPIX*6][2];
+vector<edge> BasicGlCamera::patchesIndices[160];
+int BasicGlCamera::verticesIndices[NPIX][6];
+int BasicGlCamera::pixelsPatch[NPIX];
+int BasicGlCamera::softwareMapping[NPIX];
+int BasicGlCamera::patches[160][9];
 
 //Coordinates of an hexagon of radius 1 and center 0
@@ -51,5 +65,5 @@
         calculatePixelsCoords();
 
-        ifstream fin2("MasterList-v3.txt");
+/*        ifstream fin2("MasterList-v3.txt");
         if (!fin2.is_open())
         {
@@ -80,13 +94,7 @@
 
             l++;
-        }
-//        GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3];
-//        for (int i=0;i<1440;i++)
-//            for (int j=0;j<3;j++)
-//                tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j];
-//        for (int i=0;i<1440;i++)
-//            for (int j=0;j<3;j++)
-//                pixelsCoords[i][j] = tempPixelsCoords[i][j];
+        }*/
         buildVerticesList();
+/*
        ifstream fin1("Trigger-Patches.txt");
        if (!fin1.is_open())
@@ -125,5 +133,5 @@
 
         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] = 0;     rr[2] = 0;    rr[3] = 1.0f;  rr[4] = 0.85f;
@@ -136,5 +144,4 @@
         for (int i=0;i<NPIX;i++)
             fData[i] = (double)i;///1.44;//(double)(i)/(double)(ACTUAL_NUM_PIXELS);
-
 
         setFont(QFont("Arial", 8));
@@ -257,9 +264,44 @@
         connect(this, SIGNAL(signalUpdateCamera()),
                 this, SLOT(timedUpdate()));
-
-
     }
     BasicGlCamera::~BasicGlCamera()
     {
+    }
+    void BasicGlCamera::assignPixelMap(PixelMap& map)
+    {
+        fPixelMap = map;
+        for (auto i=fPixelMap.begin();i!=fPixelMap.end(); i++)
+        {
+            hardwareMapping[i->index] = i->hw();
+            softwareMapping[i->hw()] = i->index;
+        }
+    }
+    void BasicGlCamera::assignTriggerPatchesMap(vector<int>& pa)
+    {
+        vector<vector<int> > intervec;
+        intervec.resize(160);
+        int i=0;
+        for (auto it=pa.begin(); it != pa.end(); it++)
+        {
+            intervec[*it].push_back(hardwareMapping[i]);
+            i++;
+        }
+        for (i=0;i<160;i++)
+        {
+            for (int j=0;j<9;j++)
+            {
+                patches[i][j] = intervec[i][j];
+            }
+        }
+
+        //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++)
+            updateNeighbors(i);
+
+        buildPatchesIndices();
     }
     void BasicGlCamera::setPatchColor(int id, float color[3])
@@ -870,4 +912,6 @@
     void BasicGlCamera::calculatePixelsCoords()
     {
+        if (pixelsCoords[0][1] >= 0.299999 && pixelsCoords[0][1] <= 0.300001)
+            return;
         pixelsCoords[0][0] = 0;
         pixelsCoords[0][1] = 0.3;
@@ -884,5 +928,4 @@
         for (int i=2;i<MAX_NUM_PIXELS;i++)
         {
- //           cout << "i " << i << endl;
             toSide = fromSide-1;
             if (toSide < 0)
Index: /trunk/FACT++/gui/BasicGlCamera.h
===================================================================
--- /trunk/FACT++/gui/BasicGlCamera.h	(revision 12011)
+++ /trunk/FACT++/gui/BasicGlCamera.h	(revision 12012)
@@ -18,4 +18,6 @@
 
 #include <set>
+
+#include "src/PixelMap.h"
 
 using namespace std;
@@ -55,4 +57,6 @@
     int64_t fMax;
 
+    static PixelMap fPixelMap;
+
     bool pixelColorUpToDate;
 
@@ -76,4 +80,6 @@
     void SetAutoRefresh(bool on);
     void updateCamera();
+    void assignPixelMap(PixelMap& );
+    void assignTriggerPatchesMap(vector<int>& );
 
     float ss[5];// = {0.00, 0.25, 0.5, 0.75, 1.00};
@@ -122,14 +128,14 @@
 
  //   bool recalcColorPlease;
-    GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
-     PixelsNeighbors neighbors[MAX_NUM_PIXELS];
-     int hardwareMapping[NPIX];
+    static GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
+    static PixelsNeighbors neighbors[MAX_NUM_PIXELS];
+    static int hardwareMapping[NPIX];
     GLfloat pixelsColor[NPIX][3];
-    GLfloat verticesList[NPIX*6][2];
-    vector<edge> patchesIndices[160];
-    int verticesIndices[NPIX][6];
-    int pixelsPatch[NPIX];
-    int softwareMapping[NPIX];
-    int patches[160][9];
+    static  GLfloat verticesList[NPIX*6][2];
+    static vector<edge> patchesIndices[160];
+    static int verticesIndices[NPIX][6];
+    static int pixelsPatch[NPIX];
+    static int softwareMapping[NPIX];
+    static int patches[160][9];
     float shownSizex;
     float shownSizey;
