Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 12376)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 12390)
@@ -358,5 +358,4 @@
     if (!nRoi)
         return;
-
     float xZoom, yZoom;
     xZoom = yZoom = 1.0f;
@@ -387,24 +386,36 @@
 
     const int hw = hardwareMapping[selectedPixel];
-
+    const PixelMapEntry& mapEntry = fPixelMap.index(selectedPixel);
+    const int pixelIdInPatch = mapEntry.pixel();
+    const int patchId = mapEntry.patch();
+
+    if (selectedPixel != -1)
+    {
     for (int i=0;i<nRoi-1;i++)
     {
-#ifdef LOAD_RAW
-        glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
-                   bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+plusMe) /divideMe);
-        glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
-                   bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+plusMe) /divideMe);
-#else
-
-
         float d1 = eventData[nRoi*hw + i]+plusMe;
         float d2 = eventData[nRoi*hw + i+1]+plusMe;
         if (!finite(d1)) d1 = 20000;
         if (!finite(d2)) d2 = 20000;
-        glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
+        glVertex2f(bboxMin[0] + xRange*i/(float)(nRoi+nRoiTM),
                    bboxMin[1] + yRange*(d1) /divideMe);
-        glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
+        glVertex2f(bboxMin[0] + xRange*(i+1)/(float)(nRoi+nRoiTM),
                    bboxMin[1] + yRange*(d2) /divideMe);
-#endif
+    }
+
+    if (pixelIdInPatch == 8)//this channel has a time marker
+    {
+        for (int i=0;i<nRoiTM-1;i++)
+        {
+            float d1 = eventData[nRoi*1440 + nRoiTM*patchId + i] + plusMe;
+            float d2 = eventData[nRoi*1440 + nRoiTM*patchId + i+1] + plusMe;
+            if (!finite(d1)) d1 = 20000;
+            if (!finite(d2)) d2 = 20000;
+            glVertex2f(bboxMin[0] + xRange*(i+nRoi)/(float)(nRoi+nRoiTM),
+                       bboxMin[1] + yRange*(d1)/divideMe);
+            glVertex2f(bboxMin[0] + xRange*(i+1+nRoi)/(float)(nRoi+nRoiTM),
+                       bboxMin[1] + yRange*(d2) / divideMe);
+        }
+    }
     }
     glEnd();
@@ -473,5 +484,5 @@
     inputFile = NULL;
     eventData = NULL;
-    drawPatch = true;
+    drawPatch = false;
     drawImpulse = true;
     drawBlur = false;
@@ -528,4 +539,6 @@
 void RawDataViewer::paintGL()
 {
+    glFinish();
+    makeCurrent();
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glLoadIdentity();
@@ -547,5 +560,5 @@
         drawPatches();
     glTranslatef(0,0,0.1f);
-   if (!drawBlur)
+   if (!drawBlur && (selectedPixel != -1))
    {
         glLineWidth(1.0f);
@@ -576,10 +589,11 @@
     }
     lastPos = cEvent->pos();
-    setCorrectSlice(cEvent);
+    if (setCorrectSlice(cEvent))
+        return;
     int face = PixelAtPosition(cEvent->pos());
-    if (face != -1) {
+ //   if (face != -1) {
         selectedPixel = face;
         emit signalCurrentPixel(face);
-        }
+ //       }
     updateGL();
 }
@@ -589,8 +603,8 @@
  * clicked, and if so, which slice should be displayed
  ************************************************************/
-void RawDataViewer::setCorrectSlice(QMouseEvent* cEvent)
+bool RawDataViewer::setCorrectSlice(QMouseEvent* cEvent)
 {
     if (!drawImpulse)
-        return;
+        return false;
     float cx = (float)cEvent->x() * pixelSize - shownSizex/2;
     float cy = ((float)height()-(float)cEvent->y())*pixelSize - shownSizey/2;
@@ -599,7 +613,10 @@
         cy < bboxMin[1] ||
         cy > bboxMax[1])
-        return;
-    whichSlice = (cx - bboxMin[0])*nRoi/(bboxMax[0] - bboxMin[0]);
+        return false;
+    whichSlice = (cx - bboxMin[0])*(nRoi+nRoiTM)/(bboxMax[0] - bboxMin[0]);
+    if (whichSlice >= nRoi)
+        whichSlice = nRoi-1;
     emit signalCurrentSlice(whichSlice);
+    return true;
 }
 
@@ -721,7 +738,7 @@
         delete[] waveLetArray;
     }
-    eventData = new float[(1440+160)*nRoi];
-
-    rawEventData = new int16_t[(1440+160)*nRoi];
+    eventData = new float[1440*nRoi + 160*nRoiTM];//(1440+160)*nRoi];
+
+    rawEventData = new int16_t[1440*nRoi + 160*nRoiTM];//(1440+160)*nRoi];
     waveLetArray = new int16_t[1024*1440];
     try
@@ -1107,5 +1124,5 @@
 void RawDataViewer::ApplyCalibration()
 {
-    for (int i=0;i<(1440+160)*nRoi;i++)
+    for (int i=0;i<1440*nRoi + 160*nRoiTM;i++)//(1440+160)*nRoi;i++)
         eventData[i] = (float)rawEventData[i];
 
@@ -1114,4 +1131,5 @@
         fDrsCalib.Apply(eventData, rawEventData, startPix, nRoi);
         DrsCalibrate::RemoveSpikes(eventData, nRoi);
+        //TODO apply calibration to the Time markers
     }
 
@@ -1190,6 +1208,6 @@
 void RawDataViewer::setCurrentPixel(int pix)
 {
-    if (pix == -1)
-        return;
+ //   if (pix == -1)
+ //       return;
     selectedPixel = pix;
     if (isVisible())
@@ -1215,4 +1233,6 @@
 ///        {
     int j = selectedPixel;
+    if (j == -1)
+        return;
             for (int i=0;i<nRoi;i++)
             {
@@ -1532,5 +1552,11 @@
     if (!GLWindow->nRoi)
         return;
-
+    if (GLWindow->selectedPixel == -1)
+    {
+        ostringstream str;
+        str << " Current Pixel val.: --";
+        currentPixelValue->setText(QString(str.str().c_str()));
+        return;
+    }
     const int idx =
         GLWindow->nRoi*GLWindow->hardwareMapping[GLWindow->selectedPixel]
@@ -1575,4 +1601,8 @@
 
 //    GLWindow->updateGL();
+}
+void UIConnector::on_slicesPerSecValue_valueChanged(double value)
+{
+    timer.setInterval(1000.0/value);
 }
 void UIConnector::on_displayingSliceBox_valueChanged(int cSlice)
@@ -2083,6 +2113,10 @@
 {
     GLWindow_2->fWhite = pixel;
-    GLWindow_2->fWhitePatch = GLWindow_2->pixelsPatch[pixel];
-
+    if (pixel != -1)
+        GLWindow_2->fWhitePatch = GLWindow_2->pixelsPatch[pixel];
+    else
+        GLWindow_2->fWhitePatch = -1;
+    if (pixel == -1)
+        return;
 
     pixel = GLWindow->hardwareMapping[pixel];
@@ -2195,4 +2229,9 @@
         start = GLWindow->selectedPixel;
         end   = GLWindow->selectedPixel+1;
+        if (end == 0)
+        {
+            start = 0;
+            end = 1440;
+        }
     }
 
Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 12376)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 12390)
@@ -113,5 +113,5 @@
 //    void skipPixels(int start, int howMany);
 //    void calculatePixelsCoords();
-    void setCorrectSlice(QMouseEvent* event);
+    bool setCorrectSlice(QMouseEvent* event);
     void eventStepping(bool plus);
 //    void buildVerticesList();
@@ -261,4 +261,6 @@
     void on_blueValue4_valueChanged(double);
 
+    void on_slicesPerSecValue_valueChanged(double);
+
     void pixelChanged(int);
 
Index: trunk/FACT++/gui/RawEventsViewer/viewer.ui
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/viewer.ui	(revision 12376)
+++ trunk/FACT++/gui/RawEventsViewer/viewer.ui	(revision 12390)
@@ -7,6 +7,6 @@
     <x>0</x>
     <y>0</y>
-    <width>1133</width>
-    <height>1017</height>
+    <width>984</width>
+    <height>894</height>
    </rect>
   </property>
@@ -245,4 +245,15 @@
         <item>
          <widget class="QLabel" name="extraInfoLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="font">
+           <font>
+            <pointsize>8</pointsize>
+           </font>
+          </property>
           <property name="text">
            <string>File loaded: none
@@ -269,4 +280,7 @@
 NB Evts Bad:
 </string>
+          </property>
+          <property name="scaledContents">
+           <bool>false</bool>
           </property>
           <property name="wordWrap">
@@ -893,5 +907,5 @@
         </property>
         <property name="checked">
-         <bool>true</bool>
+         <bool>false</bool>
         </property>
         <property name="tristate">
