Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 729)
+++ trunk/MagicSoft/Mars/Changelog	(revision 730)
@@ -5,4 +5,8 @@
  * mgui/MGeomPix.cc:
    - fixed a small error in SetNeighbors (thanks to Oscar)
+   
+ * mgui/MGFadcDisp.[h,cc]:
+   - Fixed many small errors which caused the display to display nonsens
+     in some situations
 
 
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 729)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 730)
@@ -273,57 +273,45 @@
        
 
-void MGFadcDisp::CreatePixelList() {
-  //
-  //   after a new event is read in one has to update
-  //   the list of pixels in the fPixelList (TGListBox)
-  //
-  const Int_t redraw = fPixelList->GetSelected() ;
-  
-  MRawEvtPixelIter fPixelIter( fEvtData );
-
-  //
-  //   put the selection of the last event in memory
-  //
-  fPixelList->RemoveEntries(0, fPixelIter.GetNumPixels()) ;
-
-  while ( fPixelIter.Next() )
+void MGFadcDisp::CreatePixelList(Int_t lastsel)
+{
+    //
+    //   after a new event is read in one has to update
+    //   the list of pixels in the fPixelList (TGListBox)
+    //
+
+    //
+    //   put the selection of the last event in memory
+    //
+    MRawEvtPixelIter pixel(fEvtData);
+    while (pixel.Next())
     {
         char wortdummy[100] ;
-        //      cout << fPixelIter.GetPixelId() << endl ;
-        sprintf( wortdummy, "%d", fPixelIter.GetPixelId() ) ;
-
-        fPixelList->AddEntry( wortdummy, fPixelIter.GetNumEntry()) ;
+        sprintf(wortdummy, "%d", pixel.GetPixelId());
+        fPixelList->AddEntry(wortdummy, pixel.GetPixelId());
     }
 
-  fPixelList->MapSubwindows() ; 
-  fPixelList->Layout() ; 
-
-  // check if the pixel from last event also occurs in this event
-
-  fPixelIter.Reset() ; 
-
-  while ( fPixelIter.Next() )
-  {
-      if (fPixelIter.GetPixelId() != redraw )
-          continue;
-
-      fCan->Clear() ;
-      fCan->cd() ;
-
-      char wortdummy[100] ;
-      sprintf(wortdummy, "GRAPH%d", redraw ) ;
-      fEvtData->Draw(wortdummy) ;
-
-      fCan->Modified() ;
-      fCan->Update() ;
-
-      fPixelList->Select(redraw, kTRUE) ;
-      return;
-  }
-
-  fCan->Clear() ;
-  fCan->cd() ;
-  fCan->Modified() ;
-  fCan->Update() ;
+    fPixelList->MapSubwindows();
+    fPixelList->Layout();
+
+    //
+    // check if the pixel from last event also occurs in this event
+    //
+    fCan->Clear() ;
+    fCan->cd() ;
+
+    if (lastsel<0 || !pixel.Jump(lastsel))
+    {
+        pixel.Reset();
+        lastsel=pixel.GetPixelId();
+
+    }
+
+    char wortdummy[100] ;
+    sprintf(wortdummy, "GRAPH%d", lastsel);
+    fEvtData->Draw(wortdummy);
+    fPixelList->Select(lastsel, kTRUE);
+
+    fCan->Modified();
+    fCan->Update();
 }
 
@@ -355,10 +343,15 @@
     else
     {
-        fReadTree->SetEventNum(iEvt) ;
-        fReadTree->GetEvent() ;
-        CreatePixelList() ;
+        const Int_t lastsel = fPixelList->GetSelected();
+
+        fPixelList->RemoveEntries(0, fEvtData->GetNumPixels());
+
+        fReadTree->SetEventNum(iEvt);
+        fReadTree->GetEvent();
+
+        CreatePixelList(lastsel);
     }
 
-    UpdateEventCounter() ;
+    UpdateEventCounter();
 }
 
@@ -416,7 +409,7 @@
 	    {
 	    case M_PIXELLIST:
-	      sprintf(wortdummy, "GRAPH%d",fPixelList->GetSelected() ) ; 
-
-	      fCan->Clear() ; 
+	      sprintf(wortdummy, "GRAPH%d", fPixelList->GetSelected());
+
+	      fCan->Clear() ;
 	      fCan->cd() ; 
 
@@ -438,10 +431,9 @@
             break ;
 
-	case kTE_ENTER:
-	  sprintf(wortdummy, "%s",  fTxtEvtNr->GetText()) ; 
-	  cout << wortdummy<< endl  ; 
-	  cout << atoi(wortdummy) << endl ; 
-	  
-	  ReadinEvent( atoi(wortdummy) ) ; 
+        case kTE_ENTER:
+            {
+                const char *txt = fTxtEvtNr->GetText();
+                ReadinEvent(atoi(txt));
+            }
 	  break; 
 	}
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 729)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 730)
@@ -112,5 +112,5 @@
   void CloseWindow() ; 
 
-  void CreatePixelList() ; 
+  void CreatePixelList(Int_t lastsel=-1) ;
   void UpdateEventCounter() ; 
   void ReadinEvent(UInt_t iEvt) ;
