Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 11932)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 11933)
@@ -960,5 +960,5 @@
     int16_t* origTheWayIWant = new int16_t[1024*1440];
 
-    for (int i=0;i<300;i++)//nRows;i++)
+    for (int i=0;i<nRows;i++)
     {
         cout << '\r' <<  "Doing row " << i << " of " << nRows;
@@ -989,4 +989,5 @@
         while (j%1440 != 0)// < totalNumSamples)
         {
+            cout << "Copying the remaining of the data" << endl;
             int lastRun = 1;
             while (lastRun < 1440 - j%1440)//totalNumSamples-j)
@@ -1023,4 +1024,12 @@
     if (!*calibInputFile)
     {
+        delete calibInputFile;
+        calibInputFile = NULL;
+        return;
+    }
+
+    if (calibInputFile->HasKey("NROI"))
+    {
+        cout << "Looks like you're trying to load a regular raw data file as DRS calib. aborting." << endl;
         delete calibInputFile;
         calibInputFile = NULL;
@@ -1339,5 +1348,8 @@
 void UIConnector::nextSlicePlease()
 {
-    viewer->nextSlice();
+    if (playEventsRadio->isChecked ())
+        viewer->eventStepping(true);
+    else
+        viewer->nextSlice();
 }
 /************************************************************
@@ -1621,4 +1633,6 @@
 void UIConnector::currentSliceHasChanged(int slice)
 {
+    if (!viewer->nRoi)
+        return;
     ostringstream str;
 //    str << "Displaying Slice " << slice;
@@ -2321,8 +2335,9 @@
     }
 
-    int min = 10000; //real min = -2048
-    int max = -10000; //real max = 2047
+    int min = 100000; //real min = -2048, int_16 = -32768 to 32767
+    int max = -100000; //real max = 2047
     long average = 0;
-    int numSamples = 0;
+    long numSamples = 0;
+    int errorDetected = -1;
     for (int i=start;i<end;i++)
     {
@@ -2330,14 +2345,26 @@
         {
             int cValue = viewer->eventData[i*viewer->nRoi+j];
-            if (cValue > max)
+            if (cValue > max && cValue < 32767)
                 max = cValue;
-            if (cValue < min)
+            if (cValue < min && cValue > -32768)
                min = cValue;
-            average+=cValue;
-            numSamples++;
+            if (cValue < 32767 && cValue > -32768)
+            {
+                average+=cValue;
+                numSamples++;
+            }
+            else
+            {
+                errorDetected = i;
+            }
+//            numSamples++;
         }
     }
     average /= numSamples;
-
+    if (errorDetected != -1)
+    {
+        cout << "Overflow detected at pixel " << errorDetected << " (at least)" << endl;
+    }
+//    cout << "min: " << min << " max: " << max << " average: " << average << endl;
     double minRange = (double)(min+(VALUES_SPAN/2))/(double)VALUES_SPAN;
     double maxRange = (double)(max+(VALUES_SPAN/2))/(double)VALUES_SPAN;
@@ -2501,10 +2528,11 @@
 
 
-    QObject::connect(myUi.eventsMinusButton, SIGNAL(clicked()),
-                     canvas, SLOT(minusEvent()));
-    QObject::connect(myUi.eventsPlusButton, SIGNAL(clicked()),
-                     canvas, SLOT(plusEvent()));
-    QObject::connect(myUi.eventsStepBox, SIGNAL(valueChanged(int)),
-                     canvas, SLOT(setEventStep(int)));
+//    QObject::connect(myUi.eventsMinusButton, SIGNAL(clicked()),
+//                     canvas, SLOT(minusEvent()));
+//    QObject::connect(myUi.eventsPlusButton, SIGNAL(clicked()),
+//                     canvas, SLOT(plusEvent()));
+//    QObject::connect(myUi.eventsStepBox, SIGNAL(valueChanged(int)),
+//                     canvas, SLOT(setEventStep(int)));
+
     myUi.colorRange0->setValue(canvas->ss[0]);
     myUi.colorRange1->setValue(canvas->ss[1]);
@@ -2551,4 +2579,5 @@
     connector.currentPixelScale = myUi.currentPixelScale;
     connector.entireCameraScale = myUi.entireCameraScale;
+    connector.playEventsRadio = myUi.playEventsRadio;
 
     connector.extraInfoLabel = myUi.extraInfoLabel;
@@ -2572,8 +2601,16 @@
     connector.initHistograms();
 
-    QObject::connect(myUi.slicesPlusPlusButton, SIGNAL(clicked()),
-                    &connector, SLOT(slicesPlusPlus()));
-    QObject::connect(myUi.slicesMinusMinusButton, SIGNAL(clicked()),
-                     &connector, SLOT(slicesMinusMinus()));
+    QButtonGroup scaleGroup(canvas);// = new QButtonGroup(canvas);
+    QButtonGroup animateGroup(canvas);// = new QButtonGroup(canvas);
+    scaleGroup.addButton(myUi.currentPixelScale);
+    scaleGroup.addButton(myUi.entireCameraScale);
+    animateGroup.addButton(myUi.playEventsRadio);
+    animateGroup.addButton(myUi.playSlicesRadio);
+    myUi.entireCameraScale->setChecked(true);
+//    QObject::connect(myUi.slicesPlusPlusButton, SIGNAL(clicked()),
+//                    &connector, SLOT(slicesPlusPlus()));
+//    QObject::connect(myUi.slicesMinusMinusButton, SIGNAL(clicked()),
+//                     &connector, SLOT(slicesMinusMinus()));
+
     QObject::connect(myUi.autoScaleColor, SIGNAL(clicked()),
                      &connector, SLOT(autoScalePressed()));
Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 11932)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 11933)
@@ -308,4 +308,5 @@
     QRadioButton* currentPixelScale;
     QRadioButton* entireCameraScale;
+    QRadioButton* playEventsRadio;
 
     QDoubleSpinBox* range0;
Index: /trunk/FACT++/gui/RawEventsViewer/viewer.ui
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/viewer.ui	(revision 11932)
+++ /trunk/FACT++/gui/RawEventsViewer/viewer.ui	(revision 11933)
@@ -769,4 +769,14 @@
        <layout class="QHBoxLayout" name="horizontalLayout">
         <item>
+         <widget class="QPushButton" name="playPauseButton">
+          <property name="toolTip">
+           <string>Play/Pause events animation</string>
+          </property>
+          <property name="text">
+           <string>Play/Pause</string>
+          </property>
+         </widget>
+        </item>
+        <item>
          <widget class="QLabel" name="label_24">
           <property name="text">
@@ -794,54 +804,4 @@
           <property name="value">
            <double>100.000000000000000</double>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-      <item row="1" column="8">
-       <layout class="QHBoxLayout" name="horizontalLayout_4">
-        <item>
-         <widget class="QLabel" name="label_2">
-          <property name="text">
-           <string>Events stepping</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="eventsMinusButton">
-          <property name="toolTip">
-           <string>Step backwards in events</string>
-          </property>
-          <property name="text">
-           <string>-</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QSpinBox" name="eventsStepBox">
-          <property name="toolTip">
-           <string>Number of events to skip at each step</string>
-          </property>
-          <property name="minimum">
-           <number>1</number>
-          </property>
-          <property name="maximum">
-           <number>9999</number>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="eventsPlusButton">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="toolTip">
-           <string>Step forward in events</string>
-          </property>
-          <property name="text">
-           <string>+</string>
           </property>
          </widget>
@@ -952,30 +912,7 @@
        <layout class="QHBoxLayout" name="horizontalLayout_5">
         <item>
-         <widget class="QPushButton" name="slicesMinusMinusButton">
-          <property name="toolTip">
-           <string>Step backward one slice</string>
-          </property>
+         <widget class="QRadioButton" name="playEventsRadio">
           <property name="text">
-           <string>Slice--</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="playPauseButton">
-          <property name="toolTip">
-           <string>Play/Pause events animation</string>
-          </property>
-          <property name="text">
-           <string>Play/Pause</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="slicesPlusPlusButton">
-          <property name="toolTip">
-           <string>Step forward one slice</string>
-          </property>
-          <property name="text">
-           <string>Slice++</string>
+           <string>play Events</string>
           </property>
          </widget>
@@ -1013,4 +950,18 @@
         </property>
        </widget>
+      </item>
+      <item row="1" column="8">
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <widget class="QRadioButton" name="playSlicesRadio">
+          <property name="text">
+           <string>play Slices</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
      </layout>
