Index: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
===================================================================
--- trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 11902)
+++ trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc	(revision 11907)
@@ -5,4 +5,5 @@
  *      Author: lyard
  */
+
 
 #include "RawEventsViewer.h"
@@ -603,5 +604,12 @@
         delete inputFile;
     }
+    try {
     inputFile = new fits(file);
+    }
+    catch (std::runtime_error e)
+    {
+        cout << "Something went wrong while loading fits. aborting: " << e.what() << endl;
+        return;
+    }
     if (!*inputFile)
     {
@@ -635,7 +643,14 @@
     for (vector<string>::const_iterator it=entriesToCheck.begin(); it != entriesToCheck.end(); it++)
     {
+        try {
         if (!inputFile->HasKey(*it)){
             cout << *it << " missing. Aborting load..." << endl;
             return;}
+        }
+        catch (std::runtime_error e)
+        {
+            cout << e.what() << endl;
+            return;
+        }
     }
     nRows = inputFile->GetInt("NAXIS2");
@@ -779,4 +794,5 @@
         return;
     inputFile->GetRow(rowNum);
+//    cout << "Getting row " << rowNum << endl;
     for (int i=0;i<(1440+160)*nRoi;i++)
         eventData[i] = (float)rawEventData[i];
@@ -841,4 +857,6 @@
 UIConnector::UIConnector(QWidget*)
 {
+    updateSpinnerDisplay = true;
+
     timer.setInterval(10.0);
     QObject::connect(&timer, SIGNAL(timeout()),
@@ -1169,6 +1187,8 @@
 {
     ostringstream str;
-    str << "File loaded: " << currentFile << "\n";
-    str << "Calibration file loaded: " << currentCalibFile << "\n";
+
+    //extract the file name only (no path) from the full name
+    str << "File: " << currentFile.substr(currentFile.find_last_of("//")+1, currentFile.size()) << "\n";
+    str << "Calibration: " << currentCalibFile.substr(currentCalibFile.find_last_of("//")+1, currentCalibFile.size()) << "\n";
 //    fileLoadedLabel->setText(QString(str.str().c_str()));
 //    str.str("");
@@ -1177,4 +1197,7 @@
 //    str.str("");
     str << "Number of Events: " << viewer->nRows << "\n";
+
+    eventNumberBox->setMaximum(viewer->nRows-1);
+
     str << "Number of Slices: " << viewer->nRoi << "\n";// << "/1024";
 //    numberOfSlicesLabel->setText(QString(str.str().c_str()));
@@ -1226,11 +1249,12 @@
 {
     ostringstream str;
-    str << "Displaying Slice " << slice;
-    QString qstr(str.str().c_str());
-    emit updateCurrentSliceDisplay(qstr);
+//    str << "Displaying Slice " << slice;
+//    QString qstr(str.str().c_str());
+    if (updateSpinnerDisplay)
+        emit updateCurrentSliceDisplay(slice);
 
     str.str("");
     str << "Current Pixel val.: " << viewer->eventData[viewer->nRoi*viewer->selectedPixel + viewer->whichSlice];
-    qstr = qstr.fromStdString(str.str());
+    QString qstr = qstr.fromStdString(str.str());
     emit updateCurrentPixelSliceValue(qstr);
 
@@ -1241,15 +1265,41 @@
 double xval[4096];
 double yval[4096];
-
+void UIConnector::eventChangedFromSpinner(int cEvent)
+{
+//    cout << "Here " << updateSpinnerDisplay << endl;
+    if (!updateSpinnerDisplay)
+        return;
+    updateSpinnerDisplay = false;
+//    currentEventHasChanged(cEvent);
+    viewer->rowNum = cEvent - viewer->eventStep;
+    viewer->eventStepping(true);
+    updateSpinnerDisplay = true;
+
+//    viewer->updateGL();
+}
+void UIConnector::sliceChangedFromSpinner(int cSlice)
+{
+    updateSpinnerDisplay = false;
+    currentSliceHasChanged(cSlice);
+    updateSpinnerDisplay = true;
+    viewer->whichSlice = cSlice;
+    viewer->updateGL();
+}
 void UIConnector::currentEventHasChanged(int cEvent)
 {
     ostringstream str;
-    str << "Displaying Event " << cEvent;
-    QString qstr(str.str().c_str());
-    emit updateCurrentEventDisplay(qstr);
-    //retrieve the data that we want to display
+//    str << "Displaying Event " << cEvent;
+//    QString qstr(str.str().c_str());
+//    emit updateCurrentEventDisplay(qstr);
+    if (updateSpinnerDisplay)
+    {
+        updateSpinnerDisplay = false;
+        emit updateCurrentEventDisplay(viewer->rowNum);
+        updateSpinnerDisplay = true;
+    }
+        //retrieve the data that we want to display
     str.str("");
     str << "PC Time: " << viewer->pcTime;
-    qstr = qstr.fromStdString(str.str());
+    QString qstr = qstr.fromStdString(str.str());
     emit updateCurrentPCTime(qstr);
 
@@ -2032,4 +2082,6 @@
     connector.patchIDBox = myUi.patchIDBox;
 
+    connector.eventNumberBox = myUi.displayingEventBox;
+
     connector.range0 = myUi.colorRange0;
     connector.range1 = myUi.colorRange1;
@@ -2157,8 +2209,17 @@
                      &connector, SLOT(currentEventHasChanged(int)));
 
-    QObject::connect(&connector, SIGNAL(updateCurrentSliceDisplay(QString)),
-                     myUi.displayingSliceLabel, SLOT(setText(const QString)));
-    QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(QString)),
-                     myUi.displayingEventLabel, SLOT(setText(const QString)));
+    QObject::connect(&connector, SIGNAL(updateCurrentSliceDisplay(int)),
+                     myUi.displayingSliceBox, SLOT(setValue(int)));
+
+    QObject::connect(myUi.displayingSliceBox, SIGNAL(valueChanged(int)),
+                    &connector, SLOT(sliceChangedFromSpinner(int)));
+    QObject::connect(myUi.displayingEventBox, SIGNAL(valueChanged(int)),
+                    &connector, SLOT(eventChangedFromSpinner(int)));
+
+//    QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(QString)),
+//                     myUi.displayingEventLabel, SLOT(setText(const QString)));
+    QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(int)),
+                     myUi.displayingEventBox, SLOT(setValue(int)));
+
     QObject::connect(&connector, SIGNAL(updateCurrentPCTime(QString)),
                      myUi.PCTimeLabel, SLOT(setText(const QString)));
