Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 958)
+++ trunk/MagicSoft/Mars/Changelog	(revision 959)
@@ -1,3 +1,76 @@
                                                                   -*-*- END -*-*-
+
+ 2001/10/02: Thomas Bretz
+
+   * mbase/MClone.[h,cc],
+     meventdisp/MGCamDisplay.[h,cc],
+     meventdisp/MGEvtDisplay.[h,cc],
+     mmain/MCameraDisplay.[h,cc]:
+     - added
+     
+   * macros/readMagic.C:
+     - fixed a  "'->' and '.' mixed bug"
+     
+   * manalysis/MCT1ReadAscii.cc:
+     - added initialisation of fIn
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - made IsPixelExisting const
+     - made IsPixelCore const
+     - made IsPixelUsed const
+     - made GetNumPhotons[Min,Max] const
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MClone
+     
+   * mbase/MEvtLoop.[h,cc], mbase/MParList.[h,cc], mbase/MTaskList.[h,cc]:
+     - added SetOwner-support
+     
+   * mdatacheck/DataCheckLinkDef.h, mdatacheck/Makefile:
+     - removed MShowSpect
+     - removed MViewAdcSpect
+     
+   * mdatacheck/MDumpEvtHeader.cc:
+     - added missing descriptions
+     
+   * mdatacheck/MGDisplayAdc.[h,cc]:
+     - small changes
+     
+   * meventdisp/EvtDispLinkDef.h:
+     - added MGEvtDisplay
+     - added MGCamDisplay
+     
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - derived from MGEvtDisplay
+     - most of the code moved to MGEvtDisplay to support MGCamDisplay, too
+     
+   * meventdisp/Makefile:
+     - added MGCamDisplay
+     
+   * mgui/MCamDisplay.[h,cc]:
+     - cleaned
+     - reorganized
+     
+   * mgui/MHexagon.cc:
+     - added missing descriptions
+     
+   * mhist/MHFadcPix.cc:
+     - reorganized some code in the constructor which creates the 'names'
+     
+   * mhist/MHHillas.cc, mhist/MHMcCollectionArea.cc, 
+     mhist/MHMcEnergy.cc, mhist/MHStarMap.cc:
+     - Draw-function supports a default canvas now
+   
+   * mmain/MDataCheck.cc:
+     - added/rorganized comments
+     - removed usage of MViewAdcSpectra
+     
+   * mmain/MMars.[h,cc]:
+     - added new "Camera Display" Button
+     
+   * mmain/MainLinkDef.h, mmain/Makefile:
+     - added MCameraDisplay
+
+
 
  2001/09/28: Thomas Bretz
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 958)
+++ trunk/MagicSoft/Mars/Makefile	(revision 959)
@@ -36,4 +36,5 @@
 #
 SUBDIRS = mmain       \
+          mmc         \
           mgui        \
 	  manalysis   \
@@ -44,6 +45,5 @@
           mhist       \
           mfilter     \
-          mraw        \
-          mmc
+          mraw
 
 LIBRARIES = $(SUBDIRS:=.a)
Index: trunk/MagicSoft/Mars/macros/readMagic.C
===================================================================
--- trunk/MagicSoft/Mars/macros/readMagic.C	(revision 958)
+++ trunk/MagicSoft/Mars/macros/readMagic.C	(revision 959)
@@ -33,8 +33,8 @@
     MTaskList     tlist;
 
-    plist->AddToList(&geomcam);
-    plist->AddToList(&pedest);
-    plist->AddToList(&hillas);
-    plist->AddToList(&tlist);
+    plist.AddToList(&geomcam);
+    plist.AddToList(&pedest);
+    plist.AddToList(&hillas);
+    plist.AddToList(&tlist);
 
     MReadTree    read("Events", "oscar_protons.root");
@@ -54,5 +54,5 @@
         return;
 
-    MCerPhotEvt &phevt = *(MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
+    MCerPhotEvt &phevt = *(MCerPhotEvt*)plist.FindObject("MCerPhotEvt");
 
     MCamDisplay display(&geomcam);
Index: trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc	(revision 958)
+++ trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc	(revision 959)
@@ -62,5 +62,6 @@
 MCT1ReadAscii::MCT1ReadAscii(const char *fname,
 			     const char *name, 
-			     const char *title)
+                             const char *title)
+    : fIn(NULL)
 {
     *fName  = name  ? name  : "MCT1ReadAscii";
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 958)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 959)
@@ -116,5 +116,5 @@
 // Checks if in the pixel list is an entry with pixel id
 //
-Bool_t MCerPhotEvt::IsPixelExisting(Int_t id)
+Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
 {
     const Int_t entries = fPixels->GetEntries();
@@ -123,8 +123,8 @@
     {
         if (id == (*this)[il].GetPixId())
-            return kTRUE ;
-    }
-
-    return kFALSE ;
+            return kTRUE;
+    }
+
+    return kFALSE;
 } 
 
@@ -133,17 +133,17 @@
 //   Checks if in the pixel list is an entry with pixel id
 //
-Bool_t MCerPhotEvt::IsPixelUsed(Int_t id)
-{
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t il=0; il<entries; il++ )
+Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t il=0; il<entries; il++)
     {
         MCerPhotPix &pix = (*this)[il];
 
         if (id == pix.GetPixId() && pix.IsPixelUsed())
-            return kTRUE ;
-    }
-
-    return kFALSE ;
+            return kTRUE;
+    }
+
+    return kFALSE;
 } 
 
@@ -152,17 +152,17 @@
 //   Checks if in the pixel list is an entry with pixel id
 //
-Bool_t MCerPhotEvt::IsPixelCore(Int_t id)
-{
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t il=0; il<entries; il++ )
+Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t il=0; il<entries; il++)
     {
         MCerPhotPix &pix = (*this)[il];
 
-        if ( id == pix.GetPixId() && pix.IsCorePixel())
-            return kTRUE ;
+        if (id == pix.GetPixId() && pix.IsCorePixel())
+            return kTRUE;
     } 
 
-    return kFALSE ;
+    return kFALSE;
 } 
 
@@ -171,13 +171,13 @@
 // get the minimum number of photons of all valid pixels in the list
 //
-Float_t MCerPhotEvt::GetNumPhotonsMin()
+Float_t MCerPhotEvt::GetNumPhotonsMin() const
 {
     if (fNumPixels <= 0)
-        return -5. ;
+        return -5.;
 
     Float_t minval = (*this)[0].GetNumPhotons();
 
     Float_t testval;
-    for (UInt_t i=1 ; i<fNumPixels; i++ )
+    for (UInt_t i=1; i<fNumPixels; i++)
     {
         testval = (*this)[i].GetNumPhotons();
@@ -194,5 +194,5 @@
 // get the maximum number of photons of all valid pixels in the list
 //
-Float_t MCerPhotEvt::GetNumPhotonsMax()
+Float_t MCerPhotEvt::GetNumPhotonsMax() const
 {
     if (fNumPixels <= 0)
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 958)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 959)
@@ -33,10 +33,10 @@
     void Print(Option_t *opt=NULL);
 
-    Bool_t  IsPixelExisting( Int_t id );
-    Bool_t  IsPixelUsed    ( Int_t id );
-    Bool_t  IsPixelCore    ( Int_t id );
+    Bool_t  IsPixelExisting(Int_t id) const;
+    Bool_t  IsPixelUsed    (Int_t id) const;
+    Bool_t  IsPixelCore    (Int_t id) const;
 
-    Float_t GetNumPhotonsMin();
-    Float_t GetNumPhotonsMax();
+    Float_t GetNumPhotonsMin() const;
+    Float_t GetNumPhotonsMax() const;
 
     MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->At(i)); }
Index: trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 959)
@@ -31,4 +31,6 @@
 #pragma link C++ class MInputStreamID;
 
+#pragma link C++ class MClone;
+
 #pragma link C++ class MReadTree;
 #pragma link C++ class MWriteFile;
Index: trunk/MagicSoft/Mars/mbase/MClone.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 959)
+++ trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 959)
@@ -0,0 +1,126 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  07/2001 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MClone.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MClone);
+
+// --------------------------------------------------------------------------
+//
+// Initializes name and title of the object. It is called by all
+// constructors.
+//
+void MClone::Init(const char *name, const char *title)
+{
+    *fName  = name  ? name  : "MClone";
+    *fTitle = title ? title : "Task to clone a parameter container for later usage";
+
+    fClone        = NULL;
+    fParContainer = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+MClone::MClone(const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainerName = par;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+MClone::MClone(const MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fParContainer = par;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MClone::~MClone()
+{
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks the parameter list for the existance of the parameter container. If
+// the name of it was given in the constructor. It checks also for the
+// existance of the histogram container in the parameter list if a name was
+// given. If it is not available it tried to create a histogram container
+// with the same type as the given object name.
+//
+Bool_t MClone::PreProcess(MParList *pList)
+{
+    if (!fParContainer)
+    {
+        fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+        if (!fParContainer)
+        {
+            *fLog << dbginf << fParContainerName << " not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
+}
+
+void MClone::Clear(Option_t *)
+{
+    if (!fClone)
+        return;
+
+    delete fClone;
+    fClone = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills the data from the parameter conatiner into the histogram container
+//
+Bool_t MClone::Process()
+{
+    Clear();
+
+    fClone = fParContainer->Clone();
+
+    return kTRUE;
+} 
+
Index: trunk/MagicSoft/Mars/mbase/MClone.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.h	(revision 959)
+++ trunk/MagicSoft/Mars/mbase/MClone.h	(revision 959)
@@ -0,0 +1,40 @@
+#ifndef MCLONE_H
+#define MCLONE_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MTASK_H
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MClone : public MTask
+{
+private:
+    const MParContainer *fParContainer;
+    TString fParContainerName;
+
+    TObject* fClone;
+
+    void Init(const char *name, const char *title);
+
+public:
+    MClone(const char *par,          const char *name=NULL, const char *title=NULL);
+    MClone(const MParContainer *par, const char *name=NULL, const char *title=NULL);
+    ~MClone();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    TObject *GetClone() const { return fClone; }
+
+    void Clear(Option_t *opt=NULL);
+
+    ClassDef(MClone, 0) // Task to fill the Hillas parameters into histograms
+};
+    
+#endif
+
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 959)
@@ -81,4 +81,16 @@
 MEvtLoop::~MEvtLoop()
 {
+    if (TestBit(kIsOwner) && fParList)
+        delete fParList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  if you set the Eventloop as owner the destructor of the given parameter
+//  list is calles by the destructor of MEvtLoop, otherwise not.
+//
+inline void MEvtLoop::SetOwner(Bool_t enable=kTRUE)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
 }
 
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 959)
@@ -27,9 +27,14 @@
     MTaskList *fTaskList;
 
+    enum { kIsOwner = BIT(14) };
+
 public:
     MEvtLoop();
     virtual ~MEvtLoop();
 
-    void SetParList(MParList *p)  { fParList = p; }
+    void SetParList(MParList *p)        { fParList = p; }
+    MParList *GetParList() const        { return fParList; }
+
+    void SetOwner(Bool_t enable=kTRUE);
 
     Bool_t PreProcess(const char *tlist="MTaskList");
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 959)
@@ -81,4 +81,25 @@
 // --------------------------------------------------------------------------
 //
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+MParList::~MParList()
+{
+    if (TestBit(kIsOwner))
+        fContainer.SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+inline void MParList::SetOwner(Bool_t enable=kTRUE)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+// --------------------------------------------------------------------------
+//
 //  Set the logging streamer of the parameter list and all contained
 //  parameter containers
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 959)
@@ -32,11 +32,11 @@
     static TString GetObjectName(const char *classname, const char *objname);
 
+    enum { kIsOwner = BIT(14) };
+
 public:
     MParList(const char *name=NULL, const char *title=NULL);
     MParList(MParList &ts);
 
-    ~MParList()
-    {
-    }
+    ~MParList();
 
     Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL);
@@ -57,4 +57,6 @@
     void SetReadyToSave(Bool_t flag=kTRUE);
 
+    void SetOwner(Bool_t enable=kTRUE);
+
     void Print(Option_t *t = NULL);
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 959)
@@ -80,4 +80,26 @@
 // --------------------------------------------------------------------------
 //
+//  If the 'IsOwner' bit is set (via SetOwner()) all tasks are deleted
+//  by the destructor
+//
+MTaskList::~MTaskList()
+{
+    if (TestBit(kIsOwner))
+        fTasks.SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+inline void MTaskList::SetOwner(Bool_t enable=kTRUE)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+
+// --------------------------------------------------------------------------
+//
 //  Set the logging stream for the all tasks in the list and the tasklist
 //  itself.
@@ -169,4 +191,23 @@
 // --------------------------------------------------------------------------
 //
+//  Find an object in the list.
+//  'name' is the name of the object you are searching for.
+//
+TObject *MTaskList::FindObject(const char *name) const
+{
+    return fTasks.FindObject(name);
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the object is in the list or not
+//
+TObject *MTaskList::FindObject(TObject *obj) const
+{
+    return fTasks.FindObject(obj);
+}
+
+// --------------------------------------------------------------------------
+//
 // do pre processing (before eventloop) of all tasks in the task-list
 //
@@ -187,5 +228,5 @@
     // loop over all tasks for preproccesing
     //
-    while ( (task=(MTask*)Next()) )
+    while ((task=(MTask*)Next()))
     {
         *fLog << task->GetName() << "... " << flush;
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 959)
@@ -27,12 +27,18 @@
     MParList      *fParList;
 
+    enum { kIsOwner = BIT(14) };
+
 public:
     MTaskList(const char *name=NULL, const char *title=NULL);
+    MTaskList(MTaskList &ts);
 
-    MTaskList(MTaskList &ts);
+    ~MTaskList();
 
     void SetLogStream(MLog *log);
 
     Bool_t AddToList(MTask *task, const char *tType="All", MTask *where = NULL);
+
+    TObject *FindObject(const char *name) const;
+    TObject *FindObject(TObject *obj) const;
 
     Bool_t PreProcess(MParList *pList);
@@ -41,4 +47,5 @@
 
     void Print(Option_t *opt = "");
+    void SetOwner(Bool_t enable=kTRUE);
 
     ClassDef(MTaskList, 0)	//collection of tasks to be performed in the eventloop
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 958)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 959)
@@ -49,4 +49,5 @@
            MLog.cc \
            MHtml.cc \
+           MClone.cc \
            MLogManip.cc
 
Index: trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 958)
+++ trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 959)
@@ -5,6 +5,6 @@
 #pragma link off all functions;
 
-#pragma link C++ class MShowSpect;
-#pragma link C++ class MViewAdcSpectra;
+//#pragma link C++ class MShowSpect;
+//#pragma link C++ class MViewAdcSpectra;
 #pragma link C++ class MDumpEvtHeader;
 
Index: trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 959)
@@ -24,4 +24,20 @@
 \* ======================================================================== */
 
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MDumpEvtHeader
+//
+//  Print out some event header information to the screen. This maybe useful
+//  if you are not sure what the events in the file conatins or you
+//  want to check for the contents.
+//
+//  Input Containers:
+//   MRawEvtHeader, MRawEvtData
+//
+//  Output Containers:
+//   -/-
+//
+//////////////////////////////////////////////////////////////////////////////
+
 #include "MDumpEvtHeader.h"
 
@@ -33,6 +49,13 @@
 #include "MRawEvtPixelIter.h"
 
-ClassImp(MDumpEvtHeader)
+ClassImp(MDumpEvtHeader);
 
+// --------------------------------------------------------------------------
+//
+// Preprocessing of class. Check for the two container which should
+// get printed by the Process-function: MRawEvtHeader and MRawEvtData.
+// If one of the two doesn't exist (input containers) stop processing of
+// data.
+//
 Bool_t MDumpEvtHeader::PreProcess (MParList *pList)
 {
@@ -54,15 +77,20 @@
 } 
 
+// --------------------------------------------------------------------------
+//
+// Print out information of the actual event (header) and print the
+// pixel ID's of all pixels in this event.
+//
 Bool_t MDumpEvtHeader::Process()
 {
-  fRawEvtHeader->Print();
+    fRawEvtHeader->Print();
 
-  MRawEvtPixelIter pixel(fRawEvtData);
+    MRawEvtPixelIter pixel(fRawEvtData);
 
-  while (pixel.Next())
-      *fLog << " " << pixel.GetPixelId();
+    while (pixel.Next())
+        *fLog << " " << pixel.GetPixelId();
 
-  *fLog << endl;
-  
-  return kTRUE;
-} 
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 959)
@@ -66,5 +66,5 @@
     fHistoList = new TGListBox (left, M_LIST_HISTO);
     fHistoList->Associate(this);
-    fHistoList->Resize(80, 405);
+    fHistoList->Resize(100, 405);
 
     fList->Add(fHistoList);
@@ -126,22 +126,24 @@
     // ---
 
-    TGLayoutHints *laybut1 = new TGLayoutHints(kLHintsNormal, 10, 10,  0, 10);
-    TGLayoutHints *laybut2 = new TGLayoutHints(kLHintsNormal, 10, 10, 10,  5);
+    TGLayoutHints *laybut1 = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10,  0, 10);
+    TGLayoutHints *laybut2 = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 10,  5);
+    TGLayoutHints *layslid = new TGLayoutHints(kLHintsCenterX|kLHintsTop);
 
     fList->Add(laybut1);
     fList->Add(laybut2);
-
-    mid->AddFrame(prev,   laybut1);
-    mid->AddFrame(fSlider);
-    mid->AddFrame(next,   laybut2);
-    mid->AddFrame(group,  laybut2);
+    fList->Add(layslid);
+
+    mid->AddFrame(prev,    laybut1);
+    mid->AddFrame(fSlider, layslid);
+    mid->AddFrame(next,    laybut2);
+    mid->AddFrame(group,   laybut2);
 
     //
     //    right part of top frame
     //
-    TGVerticalFrame *right = new TGVerticalFrame(frame, 60, 60, kFitWidth);
+    TGVerticalFrame *right = new TGVerticalFrame(frame, 100, 100, kFitWidth);
     fList->Add(right);
 
-    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("fECanv", right, 800, 400);
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("fECanv", right, 100, 100);
     fList->Add(canvas);
 
@@ -156,5 +158,5 @@
     fList->Add(reset);
 
-    TGLayoutHints *layreset = new TGLayoutHints(kLHintsCenterX|kLHintsTop,10, 10, 0, 10);
+    TGLayoutHints *layreset = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 0, 10);
     fList->Add(layreset);
 
@@ -211,6 +213,9 @@
                            UInt_t w, UInt_t h,
                            UInt_t options)
-: TGTransientFrame(p, main, w, h, options), fHists(histos), fHistoType(M_RADIO_HI)
-{
+: TGTransientFrame(p?p:gClient->GetRoot(), main?main:gClient->GetRoot(), w, h, options),
+  fHistoType(M_RADIO_LH)
+{
+    fHists = (MHFadcCam*)histos->Clone();
+
     fList = new TList;
     fList->SetOwner();
@@ -265,5 +270,5 @@
 
     MapWindow();
-    SetWMSizeHints(550, 550, 1000, 1000, 1, 1);
+    SetWMSizeHints(950, 500, 1000, 1000, 1, 1);
 }  
 
@@ -271,4 +276,5 @@
 { 
     delete fList;
+    delete fHists;
 }  
 
@@ -277,6 +283,5 @@
 void MGDisplayAdc::CloseWindow()
 {
-    // Got close message for this MainFrame. Calls parent CloseWindow()
-    // (which destroys the window) and terminate the application.
+    //
     // The close message is generated by the window manager when its close
     // window menu item is selected.
Index: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 958)
+++ trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 959)
@@ -41,7 +41,7 @@
 
     MGDisplayAdc(MHFadcCam *fHists ,
-                 const TGWindow *p, const TGWindow *main,
-                 UInt_t w, UInt_t h,
-                 UInt_t options = kMainFrame | kVerticalFrame );
+                 const TGWindow *p=NULL, const TGWindow *main=NULL,
+                 UInt_t w=800, UInt_t h=500,
+                 UInt_t options = kMainFrame|kVerticalFrame);
 
     ~MGDisplayAdc();
Index: trunk/MagicSoft/Mars/mdatacheck/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/Makefile	(revision 958)
+++ trunk/MagicSoft/Mars/mdatacheck/Makefile	(revision 959)
@@ -29,7 +29,5 @@
 
 SRCFILES = MDumpEvtHeader.cc \
-	   MGDisplayAdc.cc \
-	   MShowSpect.cc \
-	   MViewAdcSpectra.cc 
+	   MGDisplayAdc.cc
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/meventdisp/EvtDispLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/EvtDispLinkDef.h	(revision 958)
+++ trunk/MagicSoft/Mars/meventdisp/EvtDispLinkDef.h	(revision 959)
@@ -5,5 +5,8 @@
 #pragma link off all functions;
 
-#pragma link C++ class MGFadcDisp ;
+#pragma link C++ class MGEvtDisplay;
+
+#pragma link C++ class MGFadcDisp;
+#pragma link C++ class MGCamDisplay;
 
 #endif
Index: trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 959)
+++ trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 959)
@@ -0,0 +1,258 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  10/2001 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MGCamDisplay.h"
+
+#include <TList.h>                // TList
+#include <TGButton.h>             // TGPictureButton
+#include <TGButtonGroup.h>
+
+#include "MClone.h"
+#include "MHillas.h"
+#include "MEvtLoop.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MReadTree.h"
+#include "MCamDisplay.h"
+#include "MHillasCalc.h"
+#include "MPedestalCam.h"
+#include "MCerPhotCalc.h"
+#include "MImgCleanStd.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MGCamDisplay);
+
+enum
+{
+    M_RBUT_RAW    = 0x1000,
+    M_RBUT_CLEAN  = 0x1001,
+    M_CBUT_HILLAS = 0x1002
+};
+
+// --------------------------------------------------------------------------
+//
+//  Add Setup elements to GUI.
+//
+void MGCamDisplay::AddSetupElements()
+{
+    //
+    // Create gui elements for vertical frame
+    //
+    TGVButtonGroup *group = new TGVButtonGroup(fTab1);
+    fList->Add(group);
+
+    TGRadioButton *but1 = new TGRadioButton(group, "Raw Events",      M_RBUT_RAW);
+    TGRadioButton *but2 = new TGRadioButton(group, "Cleaned Events",  M_RBUT_CLEAN);
+    TGCheckButton *but3 = new TGCheckButton(fTab1, "Display Ellipse", M_CBUT_HILLAS);
+
+    but2->SetState(kButtonDown);
+    but3->SetState(kButtonDown);
+
+    fDisplayRaw    = kFALSE;
+    fDisplayHillas = kTRUE;
+
+    /*
+     FIXME: crashed the destructor
+
+     fList->Add(but1);
+     fList->Add(but2);
+     */
+
+    but1->Associate(this);
+    but2->Associate(this);
+    but3->Associate(this);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
+    fList->Add(laybut);
+
+    fTab1->AddFrame(group);
+    fTab1->AddFrame(but3, laybut);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Setup Task and parameter list for hillas calculation,
+//  preprocess tasks and read in first event (process)
+//
+MGeomCam *MGCamDisplay::SetupTaskList()
+{
+    MTaskList *tlist = GetTaskList();
+    MParList  *plist = GetParList();
+
+    MCerPhotCalc *ncalc = new MCerPhotCalc;
+    MClone       *clone = new MClone("MCerPhotEvt");
+    MImgCleanStd *clean = new MImgCleanStd;
+    MHillasCalc  *hcalc = new MHillasCalc;
+
+    tlist->AddToList(ncalc);
+    tlist->AddToList(clone);
+    tlist->AddToList(clean);
+    tlist->AddToList(hcalc);
+
+    MGeomCamMagic *geom   = new MGeomCamMagic;
+    MPedestalCam  *pedest = new MPedestalCam;
+
+    plist->AddToList(geom);
+    plist->AddToList(pedest);
+
+    fEvtLoop->PreProcess();
+    GetTaskList()->Process();
+
+    return geom;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor.
+//
+MGCamDisplay::MGCamDisplay(const char *filename,
+                           const TGWindow *p, const TGWindow *main,
+                           UInt_t w, UInt_t h)
+: MGEvtDisplay(filename, "Events", p, main, w, h), fDisplay(NULL)
+{
+    //
+    // Setup Task list for hillas calculation
+    //
+    MGeomCam *geom = SetupTaskList();
+
+    //
+    // Add missing setup elements to GUI
+    //
+    AddSetupElements();
+
+    //
+    // Show camera display for the actual geometry
+    //
+    fDisplay = new MCamDisplay(geom);
+    fDisplay->Draw();
+
+    fList->Add(fDisplay);
+
+    //
+    //   Map the window, set up the layout, etc.
+    //
+    SetWMSizeHints(450, 400, 1000, 1000, 10, 10 );      // set the smallest and biggest size of the Main frame
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Hillas Event Display");
+    SetIconName("Hillas");
+
+    UpdateDisplay();
+    UpdateNumOfEvts();
+    UpdateEventCounter();
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Update event display:
+//  dependent on the setup either the uncleaned or cleand data is shown
+//  together with the hillas ellipse or not.
+//
+void MGCamDisplay::UpdateDisplay()
+{
+    if (!fDisplay)
+        return;
+
+    const MParList *plist = fEvtLoop->GetParList();
+
+    //
+    // Show Hillas ellipse
+    //
+    MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
+
+    hillas->Print();
+    if (fDisplayHillas)
+        hillas->Draw();
+    else
+        hillas->Clear();
+
+    //
+    // Display the requested event. This does a Canvas update, too.
+    //
+    MCerPhotEvt *evt = NULL;
+    if (fDisplayRaw)
+    {
+        //
+        // Get a clone of MCerPhotEvt which is made before the image cleaning
+        //
+        const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
+        evt = (MCerPhotEvt*)clone->GetClone();
+    }
+    else
+    {
+        //
+        // Get MCerPhotEvt which containes the cleaned data
+        //
+        evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
+    }
+
+    fDisplay->DrawPhotNum(evt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the messages from the setup GUI elements.
+//
+Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    switch(GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch(GET_SUBMSG(msg))
+        {
+        case kCM_CHECKBUTTON:
+            switch (parm1)
+            {
+            case M_CBUT_HILLAS:
+                fDisplayHillas = !fDisplayHillas;
+                UpdateDisplay();
+                return kTRUE;
+            }
+            break;
+
+        case kCM_RADIOBUTTON:
+            switch (parm1)
+            {
+            case M_RBUT_RAW:
+                fDisplayRaw = kTRUE;
+                UpdateDisplay();
+                return kTRUE;
+
+            case M_RBUT_CLEAN:
+                fDisplayRaw = kFALSE;
+                UpdateDisplay();
+                return kTRUE;
+            }
+            break;
+        }
+        break;
+    }
+    return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
+}
+
Index: trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 959)
+++ trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 959)
@@ -0,0 +1,43 @@
+#ifndef MGCAMDISPLAY_H
+#define MGCAMDISPLAY_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MGEVTDISPLAY_H
+#include "MGEvtDisplay.h"
+#endif
+
+class TGListBox;
+
+class MGeomCam;
+class MCamDisplay;
+
+class MGCamDisplay : public MGEvtDisplay
+{
+private:
+    Bool_t fDisplayRaw;
+    Bool_t fDisplayHillas;
+
+    TGListBox   *fPixelList;
+    MCamDisplay *fDisplay;
+
+    void AddSetupElements();
+    void UpdateDisplay();
+
+    MGeomCam *SetupTaskList();
+
+public:
+    MGCamDisplay(const char *filename,
+                 const TGWindow *p, const TGWindow *main,
+                 UInt_t w, UInt_t h);
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MGCamDisplay, 0)
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 959)
+++ trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 959)
@@ -0,0 +1,488 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  10/2001 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MGEvtDisplay.h"
+
+#include <stdlib.h>               // atoi
+
+#include <TGTab.h>                // TGTab
+#include <TGLabel.h>              // TGLabel
+#include <TGButton.h>             // TGPictureButton
+#include <TGMsgBox.h>             // TGMsgBox
+#include <TGTextEntry.h>          // TGTextEntry
+#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
+
+#include <TG3DLine.h>             // TGHorizontal3DLine
+                                  // use TGSplitter instead for root<3.00
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+#include "MReadTree.h"
+
+ClassImp(MGEvtDisplay);
+
+enum MGCamDisplayCommand
+{
+    M_PREVEVT,
+    M_NEXTEVT,
+    M_EVTNUMBER,
+
+    M_PRINT,
+    M_CLOSE
+}; 
+
+// --------------------------------------------------------------------------
+//
+//  Return a pointer to the parameter list.
+//
+MParList *MGEvtDisplay::GetParList() const
+{
+    return fEvtLoop->GetParList();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return a pointer to the task list.
+//
+MTaskList *MGEvtDisplay::GetTaskList() const
+{
+    return (MTaskList*)GetParList()->FindObject("MTaskList");
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return a pointer to the reader task (MReadTree)
+//
+MReadTree *MGEvtDisplay::GetReader() const
+{
+    return (MReadTree*)GetTaskList()->FindObject("MReadTree");
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the top part of the frame: This is filename and treename display
+//
+void MGEvtDisplay::AddTopFramePart1(TGVerticalFrame *frame,
+                                    const char *filename,
+                                    const char *treename)
+{
+    //
+    //  --- the top1 part of the window ---
+    //
+    TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 300, 100);
+    fList->Add(top1);
+
+    //
+    // create gui elements
+    //
+    TGLabel *lfile = new TGLabel(top1, new TGString("File:"));
+    TGLabel *file  = new TGLabel(top1, new TGString(filename));
+    TGLabel *ltree = new TGLabel(top1, new TGString("Tree:"));
+    TGLabel *tree  = new TGLabel(top1, new TGString(treename));
+
+    fList->Add(lfile);
+    fList->Add(file);
+    fList->Add(ltree);
+    fList->Add(tree);
+
+    //
+    // layout and add gui elements in/to frame
+    //
+    TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
+    fList->Add(laystd);
+
+    top1->AddFrame(lfile, laystd);
+    top1->AddFrame(file,  laystd);
+    top1->AddFrame(ltree, laystd);
+    top1->AddFrame(tree,  laystd);
+
+    //
+    // layout and add frame
+    //
+    TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsTop);
+    fList->Add(laytop1);
+
+    frame->AddFrame(top1, laytop1);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Show the correct number of events
+//
+void MGEvtDisplay::UpdateNumOfEvts()
+{
+    char txt[100];
+    sprintf(txt, "out of %d Events", GetReader()->GetEntries());
+
+    fNumOfEvts->SetText(new TGString(txt));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the second part of the top frame: This are the event number controls
+//
+void MGEvtDisplay::AddTopFramePart2(TGVerticalFrame *frame)
+{
+    //
+    // --- the top2 part of the window ---
+    //
+    TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
+    fList->Add(top2);
+
+    //
+    // Create the gui elements
+    //
+    TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", M_PREVEVT);
+    prevevt->Associate(this);
+
+    TGLabel *evtnr = new TGLabel(top2, new TGString("Event: "));
+
+    fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), M_EVTNUMBER);
+    fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight());
+    fTxtEvtNr->Associate(this);
+
+    fNumOfEvts = new TGLabel(top2, "out of           Events.");
+
+    TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", M_NEXTEVT);
+    nextevt->Associate(this);
+
+    //
+    // Add gui elements to 'atotodel'
+    //
+    fList->Add(prevevt);
+    fList->Add(evtnr);
+    fList->Add(fTxtEvtNr);
+    fList->Add(fNumOfEvts);
+    fList->Add(nextevt);
+
+    //
+    // add the gui elements to the frame
+    //
+    TGLayoutHints *laystd    = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 10, 10, 10, 10);
+
+    fList->Add(laystd);
+
+    top2->AddFrame(prevevt,    laystd);
+    top2->AddFrame(evtnr,      laystd);
+    top2->AddFrame(fTxtEvtNr,  laystd);
+    top2->AddFrame(fNumOfEvts, laystd);
+    top2->AddFrame(nextevt,    laystd);
+
+    frame->AddFrame(top2, new TGLayoutHints(kLHintsCenterX));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the mid frame: This are the two tabs with the canvas in the right one
+//
+void MGEvtDisplay::AddMidFrame(TGHorizontalFrame *frame)
+{
+    //
+    // create tab control
+    //
+    TGTab *tabs = new TGTab(frame, 300, 300);
+
+    //
+    // Create Tab1
+    //
+    fTab1 = tabs->AddTab("Setup");
+
+    //
+    // Crete second gui elemet for tab1 (TGVertical Frame)
+    //
+    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 10, 10, 10, 10);
+    frame->AddFrame(tabs, laytabs);
+
+    //
+    // Create second part of frame
+    // 
+    TGTab *tabdisp = new TGTab(frame, 300, 300);
+
+    TGCompositeFrame *tab2 = tabdisp->AddTab("Event Display");
+
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("EventDisplay", tab2, 400, 400);
+
+    TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
+    tab2->AddFrame(canvas, laycanvas);
+
+    fCanvas = canvas->GetCanvas();
+
+    //
+    // Add second part to frame
+    //
+    TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
+    frame->AddFrame(tabdisp, laydisp);
+
+    //
+    // Now add all gui elements to 'autodel'-list
+    //
+    fList->Add(tabdisp);
+    fList->Add(canvas);
+    fList->Add(laycanvas);
+    fList->Add(laydisp);
+    fList->Add(laytabs);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the low frame: These are the buttons Print and Close
+//
+void MGEvtDisplay::AddLowFrame(TGHorizontalFrame *frame)
+{
+    TGTextButton *but1 = new TGTextButton(frame, "Print", M_PRINT);
+    TGTextButton *but2 = new TGTextButton(frame, "Close", M_CLOSE);
+
+    but1->Associate(this);
+    but2->Associate(this);
+
+    fList->Add(but1);
+    fList->Add(but2);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
+    fList->Add(laybut);
+
+    frame->AddFrame(but1, laybut);
+    frame->AddFrame(but2, laybut);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Create and setup all the three frames and build the window interieur
+//
+void MGEvtDisplay::AddFrames(const char *filename, const char *treename)
+{
+    //
+    // Create the frame elements and add gui elements to it
+    //
+    TGVerticalFrame *frametop = new TGVerticalFrame(this, 300, 100);
+    fList->Add(frametop);
+
+    AddTopFramePart1(frametop, filename, treename);
+    AddTopFramePart2(frametop);
+
+    TGLayoutHints *laytop  = new TGLayoutHints(kLHintsTop|kLHintsCenterX);
+    fList->Add(laytop);
+
+    // -----
+
+    TGHorizontalFrame *framemid = new TGHorizontalFrame(this, 300, 100);
+    fList->Add(framemid);
+
+    AddMidFrame(framemid);
+
+    TGLayoutHints *laymid  = new TGLayoutHints(kLHintsExpandY|kLHintsExpandX);
+    fList->Add(laymid);
+
+    //
+    // add frame elements to 'autodel'
+    //
+    TGHorizontal3DLine *line1 = new TGHorizontal3DLine(this);
+    TGHorizontal3DLine *line2   = new TGHorizontal3DLine(this);
+    fList->Add(line1);
+    fList->Add(line2);
+
+    TGLayoutHints *layline = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(layline);
+
+    // -----
+    TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 300, 100);
+    fList->Add(framelow);
+
+    AddLowFrame(framelow);
+
+    TGLayoutHints *laylow  = new TGLayoutHints(kLHintsTop);
+    fList->Add(laylow);
+
+    //
+    // Layout frame elements and add elements to frame
+    //
+    AddFrame(frametop, laytop);
+    AddFrame(line1,    layline);
+    AddFrame(framemid, laymid);
+    AddFrame(line2,    layline);
+    AddFrame(framelow, laylow);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor
+//
+MGEvtDisplay::MGEvtDisplay(const char *fname, const char *tname,
+                           const TGWindow *p, const TGWindow *main,
+                           UInt_t w, UInt_t h)
+    : TGTransientFrame(p, main, w, h)
+{
+    //
+    //  create an autodelete-list for the gui elements
+    //
+    fList = new TList;
+    fList->SetOwner();
+
+    //
+    // Setup an empty job, with a reader task only.
+    // All tasks and parameter containers are deleted automatically
+    // (via SetOwner())
+    //
+
+    MTaskList *tlist = new MTaskList;
+    tlist->SetOwner();
+
+    MReadTree *read = new MReadTree(tname, fname);
+    tlist->AddToList(read);
+
+    MParList *plist = new MParList();
+    plist->SetOwner();
+    plist->AddToList(tlist);
+
+    fEvtLoop = new MEvtLoop;
+    fEvtLoop->SetOwner();
+    fEvtLoop->SetParList(plist);
+
+    //
+    // Add all GUI elements and update the event counter
+    // 
+    AddFrames(fname, tname);
+    UpdateEventCounter();
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  Destructs the graphical members and the eventloop members
+//
+MGEvtDisplay::~MGEvtDisplay()
+{
+    delete fList;
+
+    fEvtLoop->PostProcess();
+    delete fEvtLoop;
+}
+
+// --------------------------------------------------------------------------
+//
+// The close message is generated by the window manager when its close
+// window menu item is selected.
+//
+void MGEvtDisplay::CloseWindow()
+{
+    delete this;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks if the event number is valid, and if so reads the new event
+//  and updates the display
+//
+void MGEvtDisplay::ReadinEvent(UInt_t iEvt)
+{
+    Int_t buttons = 4;
+    Int_t retval  = 0;
+
+    //  first check if the new event is in the range of possible events
+  
+    if (iEvt >= GetReader()->GetEntries())
+    {
+        new TGMsgBox(gClient->GetRoot(), this,
+                     "WARNING!",
+                     "The event number is out of range!!!",
+                     kMBIconExclamation, buttons, &retval);
+    }
+    else
+    {
+        GetReader()->SetEventNum(iEvt);
+
+        if (GetTaskList()->Process())
+            UpdateDisplay();
+    }
+
+    UpdateEventCounter();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Update the event counter
+//
+void MGEvtDisplay::UpdateEventCounter()
+{
+    char txt[256];
+
+    sprintf(txt, "%d", GetReader()->GetEventNum());
+
+    fTxtEvtNr->SetText(txt);
+}
+
+// --------------------------------------------------------------------------
+//
+//    ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+//
+// Processes information from all GUI items.
+// Selecting an item usually generates an event with 4 parameters.
+// The first two are packed into msg (first and second bytes).
+// The other two are parm1 and parm2.
+//
+Bool_t MGEvtDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    switch(GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch(GET_SUBMSG(msg))
+        {
+        case kCM_BUTTON:
+            switch (parm1)
+            {
+            case M_PREVEVT:
+                //
+                // '-2' is because MReadTree::Process increases the
+                // Event number by one - this is the natural behaviour
+                // after reading one event
+                //
+                ReadinEvent(GetReader()->GetEventNum()-2);
+                return kTRUE;
+
+            case M_NEXTEVT:
+                //
+                // '+0' is because MReadTree::Process increases the
+                // Event number by one - this is the natural behaviour
+                // after reading one event
+                //
+                ReadinEvent(GetReader()->GetEventNum());
+                return kTRUE;
+
+            case M_CLOSE:
+                CloseWindow();
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+        return kTRUE;
+
+    case kC_TEXTENTRY:
+        if (GET_SUBMSG(msg) == kTE_ENTER)
+            ReadinEvent(atoi(fTxtEvtNr->GetText()));
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h	(revision 959)
+++ trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.h	(revision 959)
@@ -0,0 +1,78 @@
+#ifndef MGEVTDISPLAY_H
+#define MGEVTDISPLAY_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class TList;
+class TCanvas;
+class TGLabel;
+class TGTextEntry;
+
+class MEvtLoop;
+class MParList;
+class MTaskList;
+class MReadTree;
+
+class MGEvtDisplay : public TGTransientFrame
+{
+private:
+    //
+    // GUI stuff
+    //
+    TGLabel     *fNumOfEvts;
+    TGTextEntry *fTxtEvtNr;
+
+    void AddTopFramePart1(TGVerticalFrame *frame,
+                          const char *filename,
+                          const char *treename);
+    void AddTopFramePart2(TGVerticalFrame *frame);
+    void AddMidFrame(TGHorizontalFrame *frame);
+    void AddLowFrame(TGHorizontalFrame *frame);
+
+    void AddFrames(const char *filename, const char *treename);
+
+    void ReadinEvent(UInt_t iEvt);
+
+protected:
+    TList     *fList;
+    MEvtLoop  *fEvtLoop;
+
+    TCanvas   *fCanvas;
+
+    TGCompositeFrame *fTab1;
+    TGCompositeFrame *fTab2;
+
+    TGVerticalFrame  *fMidFrame;
+
+    MParList  *GetParList() const;
+    MTaskList *GetTaskList() const;
+    MReadTree *GetReader() const;
+
+    void UpdateEventCounter();
+    void UpdateNumOfEvts();
+
+    virtual void UpdateDisplay() = 0;
+
+public:
+    MGEvtDisplay(const char *fname, const char *tname,
+                 const TGWindow *p, const TGWindow *main,
+                 UInt_t w, UInt_t h);
+
+    ~MGEvtDisplay();
+
+    void CloseWindow();
+
+    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MGEvtDisplay, 0)
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 958)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 959)
@@ -1,3 +1,3 @@
-/* ======================================================================== *\
+/*======================================================================== *\
 !
 ! *
@@ -16,6 +16,5 @@
 !
 !
-!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!   Author(s): Thomas Bretz  10/2001 (tbretz@uni-sw.gwdg.de)
 !
 !   Copyright: MAGIC Software Development, 2000-2001
@@ -44,5 +43,7 @@
                                   // use TGSplitter instead for root<3.00
 #include "MParList.h"
+#include "MTaskList.h"
 #include "MReadTree.h"
+#include "MEvtLoop.h"
 #include "MRawEvtData.h"
 #include "MRawEvtPixelIter.h"
@@ -52,150 +53,43 @@
 enum MGFadcDispCommand
 {
-    M_PIXELLIST = 4201,
-    M_PREVEVT,
-    M_NEXTEVT,
-    M_EVTNUMBER,
-
-    M_PREVPIXEL,
-    M_NEXTPIXEL,
-
-    M_PRINT,
-    M_CLOSE
-}; 
-
-void MGFadcDisp::AddTopFramePart1(TGVerticalFrame *frame,
-                                  const char *filename,
-                                  const char *treename)
-{
-    //
-    //  --- the top1 part of the window ---
-    //
-    TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 300, 100);
-    fList->Add(top1);
-
-    //
-    // create gui elements
-    //
-    TGLabel *lfile = new TGLabel(top1, new TGString("File:"));
-    TGLabel *file  = new TGLabel(top1, new TGString(filename));
-    TGLabel *ltree = new TGLabel(top1, new TGString("Tree:"));
-    TGLabel *tree  = new TGLabel(top1, new TGString(treename));
-
-    fList->Add(lfile);
-    fList->Add(file);
-    fList->Add(ltree);
-    fList->Add(tree);
-
-    //
-    // layout and add gui elements in/to frame
-    //
-    TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
-    fList->Add(laystd);
-
-    top1->AddFrame(lfile, laystd);
-    top1->AddFrame(file,  laystd);
-    top1->AddFrame(ltree, laystd);
-    top1->AddFrame(tree,  laystd);
-
-    //
-    // layout and add frame
-    //
-    TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsTop);
-    fList->Add(laytop1);
-
-    frame->AddFrame(top1, laytop1);
-}
-
-void MGFadcDisp::AddTopFramePart2(TGVerticalFrame *frame)
-{
-    //
-    // --- the top2 part of the window ---
-    //
-    TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
-    fList->Add(top2);
-
-    //
-    // Create the gui elements
-    //
-    TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", M_PREVEVT);
-    prevevt->Associate(this);
-
-    TGLabel *evtnr = new TGLabel(top2, new TGString("Event: "));
-
-    fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), M_EVTNUMBER);
-    fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight());
-    fTxtEvtNr->Associate(this);
-
-    char wortdummy[100];
-    sprintf(wortdummy, "out of %d Events", fReadTree->GetEntries());
-    TGLabel *totnr = new TGLabel(top2, new TGString(wortdummy));
-
-    TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", M_NEXTEVT);
-    nextevt->Associate(this);
-
-    //
-    // Add gui elements to 'atotodel'
-    //
-    fList->Add(prevevt);
-    fList->Add(evtnr);
-    fList->Add(fTxtEvtNr);
-    fList->Add(totnr);
-    fList->Add(nextevt);
-
-    //
-    // add the gui elements to the frame
-    //
-    TGLayoutHints *laystd    = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
-    TGLayoutHints *laytentry = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5);
-
-    fList->Add(laystd);
-    fList->Add(laytentry);
-
-    top2->AddFrame(prevevt,   laystd);
-    top2->AddFrame(evtnr,     laystd);
-    top2->AddFrame(fTxtEvtNr, laytentry);
-    top2->AddFrame(totnr,     laystd);
-    top2->AddFrame(nextevt,   laystd);
-
-    frame->AddFrame(top2, new TGLayoutHints(kLHintsCenterX));
-}
-
-void MGFadcDisp::AddMidFrame(TGHorizontalFrame *frame)
-{
-    //
-    // create tab control
-    //
-    TGTab *tabs = new TGTab(frame, 300, 300);
-
-    //
-    // Create Tab1
-    //
-    TGCompositeFrame *tab1 = tabs->AddTab("PixelList");
-    tab1->ChangeOptions(kHorizontalFrame);
+    M_PREVPIXEL = 0x1000,
+    M_NEXTPIXEL = 0x1001
+};
+
+// --------------------------------------------------------------------------
+//
+//  Add the missing GUI elements: These are the pixel number controls
+//
+void MGFadcDisp::AddSetupElements()
+{
+    fTab1->ChangeOptions(kHorizontalFrame);
 
     //
     // Create first gui element for tab1
     //
-    fPixelList = new TGListBox(tab1, M_PIXELLIST);
+    fPixelList = new TGListBox(fTab1, M_PIXELLIST);
     fPixelList->Associate(this);
     fPixelList->Resize(80, 230);
 
     TGLayoutHints *layplist = new TGLayoutHints(kLHintsExpandY|kLHintsLeft, 5, 5, 5, 5);
-    tab1->AddFrame(fPixelList, layplist);
-
-    //
-    // Crete second gui elemet for tab1 (TGVertical Frame)
-    //
-    TGVerticalFrame *mid1 = new TGVerticalFrame(tab1, 300, 100);
+    fTab1->AddFrame(fPixelList, layplist);
+
+    TGVerticalFrame *fMidFrame = new TGVerticalFrame(fTab1, 300, 100);
+    fList->Add(fMidFrame);
+
+    TGLayoutHints *laytab = new TGLayoutHints(kLHintsRight|kLHintsExpandY, 5, 5, 5, 5);
+    fList->Add(laytab);
+
+    fTab1->AddFrame(fMidFrame, laytab);
 
     //
     // Create gui elements for vertical frame
     //
-    TGTextButton *prevpix = new TGTextButton(mid1, "<< Prev Pixel", M_PREVPIXEL);
-    TGTextButton *nextpix = new TGTextButton(mid1, "Next Pixel >>", M_NEXTPIXEL);
+    TGTextButton *prevpix = new TGTextButton(fMidFrame, "<< Prev Pixel", M_PREVPIXEL);
+    TGTextButton *nextpix = new TGTextButton(fMidFrame, "Next Pixel >>", M_NEXTPIXEL);
     prevpix->Associate(this);
     nextpix->Associate(this);
 
-    TGVSlider *slider = new TGVSlider(mid1, 200, kSlider1|kScaleBoth);
+    TGVSlider *slider = new TGVSlider(fMidFrame, 200, kSlider1|kScaleBoth);
     slider->Associate(this);
     slider->SetRange(0, 576);
@@ -207,149 +101,28 @@
     TGLayoutHints *layslider = new TGLayoutHints(kLHintsCenterX|kLHintsExpandY);
 
-    mid1->AddFrame(prevpix, laybut);
-    mid1->AddFrame(slider,  layslider);
-    mid1->AddFrame(nextpix, laybut);
-
-    TGLayoutHints *laytab    = new TGLayoutHints(kLHintsRight|kLHintsExpandY, 5, 5, 5, 5);
-    tab1->AddFrame(mid1, laytab);
-
-    TGLayoutHints *laytabs   = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 10, 10, 10, 10);
-    frame->AddFrame(tabs, laytabs);
-
-    //
-    // Create second part of frame
-    // 
-    TGTab *tabdisp = new TGTab(frame, 300, 300);
-
-    TGCompositeFrame *tab2 = tabdisp->AddTab("Digital Scope");
-
-    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("Digi Scope", tab2, 400, 400);
-
-    TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
-    tab2->AddFrame(canvas, laycanvas);
-
-    fCanvas = canvas->GetCanvas();
-
-    //
-    // Add second part to frame
-    //
-    TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
-    frame->AddFrame(tabdisp, laydisp);
-
-    //
-    // Now add all gui elements to 'autodel'-list
-    //
-    fList->Add(tabdisp);
-    fList->Add(canvas);
-    fList->Add(laycanvas);
-    fList->Add(laydisp);
-    fList->Add(fPixelList);
-    fList->Add(layplist);
-    fList->Add(mid1);
-    fList->Add(prevpix);
-    fList->Add(laybut);
-    fList->Add(slider);
-    fList->Add(layslider);
-    fList->Add(nextpix);
-    fList->Add(laytab);
-    fList->Add(laytabs);
-
-}
-
-void MGFadcDisp::AddLowFrame(TGHorizontalFrame *frame)
-{
-    TGTextButton *but1 = new TGTextButton(frame, "Print", M_PRINT);
-    TGTextButton *but2 = new TGTextButton(frame, "Close", M_CLOSE);
-
-    but1->Associate(this);
-    but2->Associate(this);
-
-    fList->Add(but1);
-    fList->Add(but2);
-
-    TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
-    fList->Add(laybut);
-
-    frame->AddFrame(but1, laybut);
-    frame->AddFrame(but2, laybut);
-}
-
-void MGFadcDisp::CreateGui(const char *filename, const char *treename)
-{
-    //
-    // Create the frame elements and add gui elements to it
-    //
-    TGVerticalFrame *frametop = new TGVerticalFrame(this, 300, 100);
-    AddTopFramePart1(frametop, filename, treename);
-    AddTopFramePart2(frametop);
-
-    TGHorizontal3DLine *line1   = new TGHorizontal3DLine(this);
-
-    TGHorizontalFrame *framemid = new TGHorizontalFrame(this, 300, 100);
-    AddMidFrame(framemid);
-
-    TGHorizontal3DLine *line2   = new TGHorizontal3DLine(this);
-
-    TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 300, 100);
-    AddLowFrame(framelow);
-
-    //
-    // add frame elements to 'autodel'
-    //
-    fList->Add(frametop);
-    fList->Add(line1);
-    fList->Add(framemid);
-    fList->Add(line2);
-    fList->Add(framelow);
-
-    //
-    // Layout frame elements and add elements to frame
-    //
-    TGLayoutHints *laytop  = new TGLayoutHints(kLHintsTop|kLHintsCenterX);
-    TGLayoutHints *layline = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
-    TGLayoutHints *laymid  = new TGLayoutHints(kLHintsExpandY|kLHintsExpandX);
-    TGLayoutHints *laylow  = new TGLayoutHints(kLHintsTop);
-
-    fList->Add(laytop);
-    fList->Add(layline);
-    fList->Add(laymid);
-    fList->Add(laylow);
-
-    AddFrame(frametop, laytop);
-    AddFrame(line1,    layline);
-    AddFrame(framemid, laymid);
-    AddFrame(line2,    layline);
-    AddFrame(framelow, laylow);
-}
-
-void MGFadcDisp::SetupFileAccess(const char *filename, const char *treename)
-{
-    //
-    // Create the file access elements
-    //
-    fEvtData = new MRawEvtData();
-
-    pList = new MParList();
-    pList->AddToList(fEvtData);
-
-    fReadTree = new MReadTree(treename, filename);
-    fReadTree->PreProcess(pList);
-    fReadTree->GetEvent();
-}
-
+    fMidFrame->AddFrame(prevpix, laybut);
+    fMidFrame->AddFrame(slider,  layslider);
+    fMidFrame->AddFrame(nextpix, laybut);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor
+//
 MGFadcDisp::MGFadcDisp(char *filename, char *treename,
                        const TGWindow *p, const TGWindow *main,
                        UInt_t w, UInt_t h)
-    : TGTransientFrame(p, main, w, h)
-{
-
-    //
-    //  create an autodelete-list for the gui elements
-    //
-    fList = new TList;
-    fList->SetOwner();
-
-    SetupFileAccess(filename, treename);
-    CreateGui(filename, treename);
+    : MGEvtDisplay(filename, treename, p, main, w, h)
+{
+    //
+    // Add the missing GUI elements (pixellist, pixel number controls)
+    //
+    AddSetupElements();
+
+    //
+    // preprocess eventloop and read in first event (process)
+    //
+    fEvtLoop->PreProcess();
+    GetTaskList()->Process();
 
     //
@@ -362,60 +135,42 @@
     Layout();
 
-    SetWindowName("FadcDisplay");
-    SetIconName("FadcDisp");
+    SetWindowName("Fadc Event Display");
+    SetIconName("Fadc");
+
+    UpdateDisplay();
+    UpdateNumOfEvts();
+    UpdateEventCounter();
 
     MapWindow();
 
-    CreatePixelList();
-    UpdateEventCounter();
-}
-
-
-MGFadcDisp::~MGFadcDisp()
-{
-    //
-    // close the file
-    //
-    fReadTree->PostProcess();
-
-    delete fEvtData;
-    delete pList;
-
-    delete fReadTree;
-
-    //
-    //   destruct the graphical members
-    //
-    delete fList;
-}
-
-
-void MGFadcDisp::CloseWindow()
-{
-   // Got close message for this MainFrame. Calls parent CloseWindow()
-   // (which destroys the window) and terminate the application.
-   // The close message is generated by the window manager when its close
-   // window menu item is selected.
-
-    delete this;
-}
-       
-
+}
+
+// --------------------------------------------------------------------------
+//
+//  return pointer to event data
+//
+MRawEvtData *MGFadcDisp::GetEvent() const
+{
+    return (MRawEvtData*)GetParList()->FindObject("MRawEvtData");
+}
+
+// --------------------------------------------------------------------------
+//
+//   after a new event is read in one has to update
+//   the list of pixels in the fPixelList (TGListBox)
+//
 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)
-    //
+    MRawEvtData *data = GetEvent();
 
     //
     //   put the selection of the last event in memory
     //
-    MRawEvtPixelIter pixel(fEvtData);
+    MRawEvtPixelIter pixel(data);
     while (pixel.Next())
     {
-        char wortdummy[100];
-        sprintf(wortdummy, "%d", pixel.GetPixelId());
-        fPixelList->AddEntry(wortdummy, pixel.GetPixelId());
+        char txt[100];
+        sprintf(txt, "%d", pixel.GetPixelId());
+        fPixelList->AddEntry(txt, pixel.GetPixelId());
     }
 
@@ -433,10 +188,9 @@
         pixel.Reset();
         lastsel=pixel.GetPixelId();
-
     }
 
-    char wortdummy[100];
-    sprintf(wortdummy, "GRAPH%d", lastsel);
-    fEvtData->Draw(wortdummy);
+    char txt[100];
+    sprintf(txt, "GRAPH%d", lastsel);
+    data->Draw(txt);
     fPixelList->Select(lastsel, kTRUE);
 
@@ -445,54 +199,31 @@
 }
 
-void MGFadcDisp::UpdateEventCounter() 
-{
-    //     Update the event counter
-
-    char wortdummy[256];
-
-    sprintf(wortdummy, "%d", fReadTree->GetEventNum());
-
-    fTxtEvtNr->SetText(wortdummy);
-}
-
-void MGFadcDisp::ReadinEvent(UInt_t iEvt)
-{
-    Int_t buttons = 4;
-    Int_t retval  = 0;
-
-    //  first check if the new event is in the range of possible events
-  
-    if (iEvt >= fReadTree->GetEntries())
-    {
-        new TGMsgBox(fClient->GetRoot(), this,
-                     "WARNING!",
-                     "The event number is out of range!!!",
-                     kMBIconExclamation, buttons, &retval);
-    }
-    else
-    {
-        const Int_t lastsel = fPixelList->GetSelected();
-
-        fPixelList->RemoveEntries(0, fEvtData->GetNumPixels());
-
-        fReadTree->SetEventNum(iEvt);
-        fReadTree->GetEvent();
-
-        CreatePixelList(lastsel);
-    }
-
-    UpdateEventCounter();
-}
-
+// --------------------------------------------------------------------------
+//
+//  Update the contents of the canvas
+//
+void MGFadcDisp::UpdateDisplay()
+{
+    const Int_t lastsel = fPixelList->GetSelected();
+
+    fPixelList->RemoveEntries(0, GetEvent()->GetNumPixels());
+
+    CreatePixelList(lastsel);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Display another pixel
+//
 void MGFadcDisp::DisplayPix(UInt_t i)
 {
-    char wortdummy[256];
-
-    sprintf(wortdummy, "GRAPH%d", i);
+    MRawEvtData *data = GetEvent();
 
     fCanvas->Clear();
     fCanvas->cd();
 
-    fEvtData->Draw(wortdummy);
+    char txt[256];
+    sprintf(txt, "GRAPH%d", i);
+    data->Draw(txt);
 
     fCanvas->Modified();
@@ -502,21 +233,19 @@
     // FIXME: too complicated!
     //
-    fPixelList->RemoveEntries(0, fEvtData->GetNumPixels());
+    fPixelList->RemoveEntries(0, data->GetNumPixels());
     CreatePixelList(i);
 }
 
+// --------------------------------------------------------------------------
+//
+//    ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+//
+// Processes information from all GUI items.
+// Selecting an item usually generates an event with 4 parameters.
+// The first two are packed into msg (first and second bytes).
+// The other two are parm1 and parm2.
+//
 Bool_t MGFadcDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) 
 {
-    //------------------------------------------------------------------
-    //
-    //    ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
-    //
-    // Processes information from all GUI items.
-    // Selecting an item usually generates an event with 4 parameters.
-    // The first two are packed into msg (first and second bytes).
-    // The other two are parm1 and parm2.
-    //
-    //------------------------------------------------------------------
-
     switch(GET_MSG(msg))
     {
@@ -527,12 +256,4 @@
             switch (parm1)
             {
-            case M_PREVEVT:
-                ReadinEvent(fReadTree->GetEventNum()-1);
-                return kTRUE;
-
-            case M_NEXTEVT:
-                ReadinEvent(fReadTree->GetEventNum()+1);
-                return kTRUE;
-
             case M_PREVPIXEL:
                 DisplayPix(fPixelList->GetSelected()-1);
@@ -542,31 +263,17 @@
                 DisplayPix(fPixelList->GetSelected()+1);
                 return kTRUE;
-
-            case M_PRINT:
-                cout << "Sorry, not yet implemented!" << endl;
-                return kTRUE;
-
-            case M_CLOSE:
-                CloseWindow();
-                return kTRUE;
             }
-            return kTRUE;
+            break;
 
         case kCM_LISTBOX:
             if (parm1 != M_PIXELLIST)
-                return kTRUE;
+                break;
 
             DisplayPix(fPixelList->GetSelected());
             return kTRUE;
         }
-        return kTRUE;
-
-    case kC_TEXTENTRY:
-        if (GET_SUBMSG(msg) == kTE_ENTER)
-            ReadinEvent(atoi(fTxtEvtNr->GetText()));
-
-        return kTRUE;
+        break;
     }
 
-    return kTRUE;
-}
+    return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
+}
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 958)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 959)
@@ -6,49 +6,22 @@
 #endif
 
-#ifndef ROOT_TGFrame
-#include <TGFrame.h>
+#ifndef MGEVTDISPLAY_H
+#include "MGEvtDisplay.h"
 #endif
 
-class MParList;
-class MReadTree;
+class TGListBox;
 class MRawEvtData;
 
-class TList;
-class TCanvas;
-class TGListBox;
-class TGTextEntry;
-
-class MGFadcDisp : public TGTransientFrame
+class MGFadcDisp : public MGEvtDisplay
 {
 private:
-    //
-    // GUI stuff
-    //
-    TList       *fList;
-
-    TGTextEntry *fTxtEvtNr;
     TGListBox   *fPixelList;
 
-    TCanvas     *fCanvas;
+    void AddSetupElements();
+    void DisplayPix(UInt_t i);
+    void UpdateDisplay();
+    void CreatePixelList(Int_t lastsel=-1);
 
-    void AddTopFramePart1(TGVerticalFrame *frame,
-                          const char *filename,
-                          const char *treename);
-    void AddTopFramePart2(TGVerticalFrame *frame);
-    void AddMidFrame(TGHorizontalFrame *frame);
-    void AddLowFrame(TGHorizontalFrame *frame);
-
-    void CreateGui(const char *filename, const char *treename);
-    void SetupFileAccess(const char *filename, const char *treename);
-
-    //
-    // File Access stuff
-    //
-    MParList    *pList;
-    MRawEvtData *fEvtData;
-    MReadTree   *fReadTree;
-
-    void ReadinEvent(UInt_t iEvt);
-    void DisplayPix(UInt_t i);
+    MRawEvtData *GetEvent() const;
 
 public:
@@ -56,11 +29,4 @@
     MGFadcDisp(char *filename, char *treename,
                const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
-
-    ~MGFadcDisp();
-
-    void CloseWindow();
-
-    void CreatePixelList(Int_t lastsel=-1);
-    void UpdateEventCounter();
 
     virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
Index: trunk/MagicSoft/Mars/meventdisp/Makefile
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/Makefile	(revision 958)
+++ trunk/MagicSoft/Mars/meventdisp/Makefile	(revision 959)
@@ -22,5 +22,5 @@
 #  connect the include files defined in the config.mk file
 #
-INCLUDES = -I. -I../mbase -I../mraw
+INCLUDES = -I. -I../mbase -I../mraw -I../mgui -I../manalysis
 
 #------------------------------------------------------------------------------
@@ -28,5 +28,7 @@
 .SUFFIXES: .c .cc .cxx .h .hxx .o 
 
-SRCFILES = MGFadcDisp.cc
+SRCFILES = MGEvtDisplay.cc \
+	   MGFadcDisp.cc \
+	   MGCamDisplay.cc
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 959)
@@ -12,56 +12,58 @@
 #include "MGeomCam.h"
 
-#include "MCerPhotEvt.h" 
+#include "MCerPhotEvt.h"
 
 #define kITEMS_LEGEND 25
 
-ClassImp(MCamDisplay)
-
-MCamDisplay::MCamDisplay (MGeomCam *geom) : fAutoScale(kTRUE)
-{ 
-    // default constructor
-
+ClassImp(MCamDisplay);
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MCamDisplay::MCamDisplay(MGeomCam *geom) : fAutoScale(kTRUE)
+{
     //
     //    set the color palette
     //
-    gStyle->SetPalette(1,0) ;
+    gStyle->SetPalette(1, 0);
 
     //
     //  create the hexagons of the display
     //
-    fNumPixels = geom->GetNumPixels() ;
-    fPixels    = new TClonesArray("MHexagon", fNumPixels ) ;
-
-    for (UInt_t i=0; i< fNumPixels; i++ )
-        (*fPixels)[i] = new MHexagon((*geom)[i]) ;
+    fNumPixels = geom->GetNumPixels();
+    fPixels    = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*fPixels)[i] = new MHexagon((*geom)[i]);
 
     //
     // set the range to default
     //
-    fMinPhe  = -2.  ;
-    fMaxPhe  = 50. ;
+    fMinPhe = -2.;
+    fMaxPhe = 50.;
 
     //
     // set up the Legend
     //
-    fLegend  = new TClonesArray("TBox",  kITEMS_LEGEND ) ;
-    fLegText = new TClonesArray("TText", kITEMS_LEGEND ) ;
-
-    char text[10] ;
-    for ( Int_t il = 0 ; il < kITEMS_LEGEND ; il++ )
+    fLegend  = new TClonesArray("TBox",  kITEMS_LEGEND);
+    fLegText = new TClonesArray("TText", kITEMS_LEGEND);
+
+    char text[10];
+    for (Int_t il = 0; il<kITEMS_LEGEND; il++)
     {
         const Int_t y = il*40;
 
-        TBox  *newbox = new TBox (650, y-500, 700, y-460 );
-        TText *newtxt = new TText(720, y-480, text );
+        TBox  *newbox = new TBox (650, y-500, 700, y-460);
+        TText *newtxt = new TText(720, y-480, text);
 
         const Float_t lvl = 50. / kITEMS_LEGEND * il;
 
-        newbox->SetFillColor( GetColor(lvl) );
-
-        sprintf ( text, "%5.1f", lvl ) ;
-
-        newtxt->SetTextSize (0.025) ;
-        newtxt->SetTextAlign(12) ;
+        newbox->SetFillColor(GetColor(lvl));
+
+        sprintf(text, "%5.1f", lvl);
+
+        newtxt->SetTextSize(0.025);
+        newtxt->SetTextAlign(12);
 
         (*fLegend) [il] = newbox;
@@ -70,24 +72,36 @@
 }
 
-MCamDisplay::~MCamDisplay() 
-{ 
-    delete fPixels ;
-}
-
-
-void MCamDisplay::Init() 
-{ 
-    //
-    // Set the right colors
-    //
-    gStyle->SetPalette(1, 0) ;
-
+// ------------------------------------------------------------------------
+//
+//
+MCamDisplay::~MCamDisplay()
+{
+    delete fPixels;
+}
+
+// ------------------------------------------------------------------------
+//
+//
+void MCamDisplay::Draw(Option_t *option)
+{
     //
     // if no canvas is yet existing to draw into, create a new one
     //
-    if (!gPad) new TCanvas("display", "MAGIC display", 0, 0, 650, 500);
-
-    //
-    // draw all pixels of the camera
+    if (!gPad)
+        new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 650, 500);
+    else
+        gPad->Clear();
+
+    //
+    // Setup the correct environment
+    //
+    gStyle->SetPalette(1, 0);
+
+    gPad->Range(-600, -600, 900, 600);
+    gPad->SetFillColor(22);
+
+    //
+    // Draw all pixels of the camera
+    //  (means apend all pixelobjects to the current pad)
     //
     for (UInt_t i=0; i<fNumPixels; i++)
@@ -102,30 +116,10 @@
         GetText(i)->Draw();
     }
-} 
-
-
-void MCamDisplay::Draw(Option_t *option  ) 
-{
-  // 
-
-    //
-    //  check if there a pad exists, if not create one
-    //
-    if ( !gPad ) Init() ;
-
-    //
-    // set init values
-    //
-    gPad->Range (-600, -600, 900, 600) ;
-    gPad->SetFillColor(22) ;
-
-    //
-    // mark pad as modified and update screen
-    //
-    gPad->Modified() ;
-    gPad->Update() ;
-}  
-
-void MCamDisplay::DrawPhotNum( MCerPhotEvt *event)
+}
+
+// ------------------------------------------------------------------------
+//
+//
+void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event)
 {
 
@@ -134,5 +128,5 @@
     // determine the Pixel Id and the content
     //
-    Reset() ;
+    Reset();
 
     //
@@ -140,13 +134,13 @@
     //  each event
     //
-    if ( fAutoScale )
-    {
-        fMinPhe = event->GetNumPhotonsMin() ;
-        fMaxPhe = event->GetNumPhotonsMax() ;
+    if (fAutoScale)
+    {
+        fMinPhe = event->GetNumPhotonsMin();
+        fMaxPhe = event->GetNumPhotonsMax();
 
         if (fMaxPhe < 20.)
-            fMaxPhe = 20. ;
-
-        UpdateLegend() ;
+            fMaxPhe = 20.;
+
+        UpdateLegend();
     }
 
@@ -156,5 +150,5 @@
     const Int_t entries = event->GetNumPixels();
 
-    for (Int_t i=0 ; i<entries; i++ )
+    for (Int_t i=0; i<entries; i++)
     {
         MCerPhotPix &pix = (*event)[i];
@@ -167,15 +161,19 @@
 
     //
-    // update the picture
-    //
-    Draw() ;
-}  
-
-void MCamDisplay::DrawPhotErr( MCerPhotEvt *event)
+    // Update display physically
+    //
+    gPad->Modified();
+    gPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+//
+void MCamDisplay::DrawPhotErr(const MCerPhotEvt *event)
 {
     //
     // reset the all pixel colors to a default value
     //
-    Reset() ;
+    Reset();
 
     //
@@ -183,7 +181,7 @@
     // determine the Pixel Id and the content
     //
-    const Int_t entries = event->GetNumPixels() ;
-
-    for (Int_t i=0 ; i<entries; i++ )
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0 ; i<entries; i++)
     {
         MCerPhotPix &pix = (*event)[i];
@@ -193,42 +191,44 @@
 
     //
-    // update display
-    //
-    Draw() ;
-}  
-
-
-void MCamDisplay::Reset() 
-{
-    //
-    // reset the all pixel colors to a default value
-    //
-    for ( UInt_t i=0 ; i< fNumPixels ; i++ )
-        (*this)[i].SetFillColor(10) ;
+    // Update display physically
+    //
+    gPad->Modified();
+    gPad->Update();
+}
+
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MCamDisplay::Reset()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].SetFillColor(10);
 } 
 
+// ------------------------------------------------------------------------
+//
+//   Here we calculate the color index for the current value.
+//   The color index is defined with the class TStyle and the
+//   Color palette inside. We use the command gStyle->SetPalette(1,0)
+//   for the display. So we have to convert the value "wert" into
+//   a color index that fits the color palette.
+//   The range of the color palette is defined by the values fMinPhe
+//   and fMaxRange. Between this values we have 50 color index, starting
+//   with 0 up to 49.
+//
 Int_t MCamDisplay::GetColor(Float_t val)
 {
     //
-    //   Here we calculate the color index for the current value.
-    //   The color index is defined with the class TStyle and the
-    //   Color palette inside. We use the command gStyle->SetPalette(1,0)
-    //   for the display. So we have to convert the value "wert" into
-    //   a color index that fits the color palette.
-    //   The range of the color palette is defined by the values fMinPhe
-    //   and fMaxRange. Between this values we have 50 color index, starting
-    //   with 0 up to 49.
-    //
-
-    //
     //   first treat the over- and under-flows
     //
     const Float_t maxcolidx = 49.0;
 
-    if (val >= fMaxPhe )
+    if (val >= fMaxPhe)
         return gStyle->GetColorPalette(maxcolidx);
 
-    if (val <= fMinPhe )
-        return gStyle->GetColorPalette( 0 );
+    if (val <= fMinPhe)
+        return gStyle->GetColorPalette(0);
 
     //
@@ -236,17 +236,17 @@
     //
     const Float_t ratio  = (val-fMinPhe) / (fMaxPhe-fMinPhe);
-    const Int_t   colidx = (Int_t)(maxcolidx*ratio + .5) ;
-
-    return gStyle->GetColorPalette(colidx) ;
-}
-
-void MCamDisplay::UpdateLegend() 
-{
-    //
-    //    change the text on the legend according to the range of the
-    //    Display
-    //
-
-    char text[10] ;
+    const Int_t   colidx = (Int_t)(maxcolidx*ratio + .5);
+
+    return gStyle->GetColorPalette(colidx);
+}
+
+// ------------------------------------------------------------------------
+//
+//    change the text on the legend according to the range of the
+//    Display
+//
+void MCamDisplay::UpdateLegend()
+{
+    char text[10];
 
     for (Int_t il=0; il < kITEMS_LEGEND; il++)
@@ -258,5 +258,5 @@
         TText &txt = *GetText(il);
 
-        txt.SetText(txt.GetX(), txt.GetY(), text) ;
-    }
-}
+        txt.SetText(txt.GetX(), txt.GetY(), text);
+    }
+}
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 958)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 959)
@@ -27,23 +27,23 @@
 class MCamDisplay : public TObject
 {
- private: 
-     Bool_t         fAutoScale;   //  indicating the autoscale function
+private:
+    Bool_t         fAutoScale;   //  indicating the autoscale function
 
-     UInt_t         fNumPixels;
-     TClonesArray  *fPixels ;
+    UInt_t         fNumPixels;
+    TClonesArray  *fPixels;
 
-     Float_t        fMinPhe;      //  The minimal number of Phe
-     Float_t        fMaxPhe;      //  The maximum number of Phe
+    Float_t        fMinPhe;      //  The minimal number of Phe
+    Float_t        fMaxPhe;      //  The maximum number of Phe
 
-     TClonesArray  *fLegend;
-     TClonesArray  *fLegText;
+    TClonesArray  *fLegend;
+    TClonesArray  *fLegText;
 
-     TBox *GetBox(Int_t i)   { return (TBox*) fLegend->At(i); }
-     TText *GetText(Int_t i) { return (TText*)fLegText->At(i); }
+    TBox *GetBox(Int_t i)   { return (TBox*) fLegend->At(i); }
+    TText *GetText(Int_t i) { return (TText*)fLegText->At(i); }
 
-     void SetPixColor(MCerPhotPix &pix)
-     {
-         (*this)[pix.GetPixId()].SetFillColor( GetColor(pix.GetNumPhotons()));
-     }
+    void SetPixColor(MCerPhotPix &pix)
+    {
+        (*this)[pix.GetPixId()].SetFillColor( GetColor(pix.GetNumPhotons()));
+    }
 
 public:
@@ -51,12 +51,10 @@
     MCamDisplay (MGeomCam *geom);
 
-    ~MCamDisplay ();
+    ~MCamDisplay();
 
-    void Init();
+    void Draw(Option_t *option = "");
 
-    void Draw(Option_t *option = "" );
-
-    void DrawPhotNum( MCerPhotEvt *event);
-    void DrawPhotErr( MCerPhotEvt *event);
+    void DrawPhotNum(const MCerPhotEvt *event);
+    void DrawPhotErr(const MCerPhotEvt *event);
 
     void Reset();
@@ -64,9 +62,9 @@
     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
 
-    Int_t GetColor( Float_t wert );
+    Int_t GetColor(Float_t wert);
 
     void UpdateLegend();
 
-    void SetAutoScale (Bool_t input = kTRUE )
+    void SetAutoScale(Bool_t input = kTRUE)
     {
         fAutoScale = input;
Index: trunk/MagicSoft/Mars/mgui/MHexagon.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 959)
@@ -30,45 +30,64 @@
 #include "MHexagon.h"
 
+#include <iostream.h>
+
 #include <TVirtualPad.h>  // gPad
 
 #include "MGeomPix.h"     // GetX
 
-ClassImp(MHexagon) 
-
-MHexagon::MHexagon() 
-{
-  //   default constructor for MHexagon 
-
+ClassImp(MHexagon);
+
+// ------------------------------------------------------------------------
+//
+//   default constructor for MHexagon
+//
+MHexagon::MHexagon()
+{
+}
+
+// ------------------------------------------------------------------------
+//
+//    normal constructor for MHexagon
+//
+MHexagon::MHexagon(Float_t x, Float_t y, Float_t d)
+: TAttFill(0, 1001), fX(x), fY(y), fD(d)
+{
+}
+
+// ------------------------------------------------------------------------
+//
+//    normal constructor for MHexagon
+//
+MHexagon::MHexagon(MGeomPix &pix)
+: TAttFill(0, 1001)
+{
+    fX = pix.GetX();
+    fY = pix.GetY();
+    fD = pix.GetR();
+}
+
+// ------------------------------------------------------------------------
+//
+//    copy constructor for MHexagon
+//
+MHexagon::MHexagon(const MHexagon &hexagon)
+{
+    ((MHexagon&) hexagon).Copy(*this);
 } 
 
-MHexagon::MHexagon(Float_t x, Float_t y, Float_t d )
- : TAttFill(0, 1001), fX(x), fY(y), fD(d)
-{ 
-  //    normal constructor for MHexagon
-}
-
-MHexagon::MHexagon(MGeomPix &pix)
- : TAttFill(0, 1001)
-{
-  //    normal constructor for MHexagon
-   fX = pix.GetX();
-   fY = pix.GetY();
-   fD = pix.GetR();
-}
-
-MHexagon::MHexagon( const MHexagon &hexagon)
-{
-  //    copy constructor for MHexagon 
-  ((MHexagon&) hexagon).Copy(*this) ; 
-} 
-
+// ------------------------------------------------------------------------
+//
+//     default destructor for MHexagon
+//
 MHexagon::~MHexagon()
-{ 
-  //     default destructor for MHexagon
-}  
-
-void MHexagon::Copy( TObject &obj ) 
-{ 
-    //     copy this hexagon to hexagon
+{
+}
+
+// ------------------------------------------------------------------------
+//
+//     copy this hexagon to hexagon
+//
+void MHexagon::Copy(TObject &obj)
+{
     MHexagon &hex = (MHexagon&) obj;
 
@@ -77,144 +96,158 @@
     TAttFill::Copy(hex);
 
-    hex.fX = fX ;
-    hex.fY = fY ;
-    hex.fD = fD ;
-}
-Int_t MHexagon::DistancetoPrimitive( Int_t px, Int_t py )
-{
-    //   compute the distance of a point (px,py) to the Hexagon
-    //   this functions needed for graphical primitives, that
-    //   means without this function you are not able to interact
-    //   with the graphical primitive with the mouse!!!
-    //
-    //   All calcutations are running in pixel coordinates
-
-    //       compute the distance of the Point to the center of the Hexagon
-
-  const Int_t  pxhex = gPad->XtoAbsPixel( fX ) ;
-  const Int_t  pyhex = gPad->YtoAbsPixel( fY ) ; 
-
-  const Double_t DistPointHexagon = TMath::Sqrt( Double_t ((pxhex-px)*(pxhex-px) + (pyhex-py)*(pyhex-py))) ; 
-  const Double_t cosa = TMath::Abs(px-pxhex) / DistPointHexagon ; 
-  const Double_t sina = TMath::Abs(py-pyhex) / DistPointHexagon ; 
-
-  //       comput the distance to pixel border 
-  
-  const Double_t   dx = fD * cosa / 2 ; 
-  const Double_t   dy = fD * sina / 2 ; 
-  
-  const Double_t   xborder = fX + dx ; 
-  const Double_t   yborder = fY + dy ; 
-
-  const Int_t  pxborder = gPad->XtoAbsPixel( xborder ) ; 
-  const Int_t  pyborder = gPad->YtoAbsPixel( yborder ) ; 
-  
-  const Double_t DistBorderHexagon = TMath::Sqrt( Double_t ((pxborder-pxhex)*(pxborder-pxhex)+(pyborder-pyhex)*(pyborder-pyhex))) ;  
-  
- 
-  //       compute the distance from the border of Pixel  
-  //       here in the first implementation is just circle inside
-
-  return DistBorderHexagon <  DistPointHexagon ? 999999 : 0;
-} 
-
-void MHexagon::DrawHexagon( Float_t x, Float_t y, Float_t d )
+    hex.fX = fX;
+    hex.fY = fY;
+    hex.fD = fD;
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Hexagon
+// this functions needed for graphical primitives, that
+// means without this function you are not able to interact
+// with the graphical primitive with the mouse!!!
+//
+// All calcutations are running in pixel coordinates
+//
+Int_t MHexagon::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Int_t pxhex = gPad->XtoAbsPixel(fX);
+    const Int_t pyhex = gPad->YtoAbsPixel(fY);
+
+    const Double_t disthex = TMath::Sqrt((Double_t)((pxhex-px)*(pxhex-px) + (pyhex-py)*(pyhex-py)));
+
+    const Double_t cosa = TMath::Abs(px-pxhex) / disthex;
+    const Double_t sina = TMath::Abs(py-pyhex) / disthex;
+
+    //
+    // comput the distance to pixel border
+    //
+    const Double_t dx = fD * cosa / 2;
+    const Double_t dy = fD * sina / 2;
+
+    const Double_t xborder = fX + dx;
+    const Double_t yborder = fY + dy;
+
+    const Int_t pxborder = gPad->XtoAbsPixel(xborder);
+    const Int_t pyborder = gPad->YtoAbsPixel(yborder);
+
+    const Double_t distborder = TMath::Sqrt((Double_t)((pxborder-pxhex)*(pxborder-pxhex)+(pyborder-pyhex)*(pyborder-pyhex)));
+
+    //
+    //  compute the distance from the border of Pixel
+    //  here in the first implementation is just circle inside
+    //
+    return distborder < disthex ? 999999 : 0;
+}
+
+// ------------------------------------------------------------------------
+//
+//  Draw this ellipse with new coordinate
+//
+void MHexagon::DrawHexagon(Float_t x, Float_t y, Float_t d)
 { 
-  //   Draw this ellipse with new coordinate
-  
-  MHexagon *newhexagon = new MHexagon(x, y, d ) ; 
-  TAttLine::Copy(*newhexagon) ; 
-  TAttFill::Copy(*newhexagon) ; 
-
-  newhexagon->SetBit (kCanDelete) ; 
-  newhexagon->AppendPad() ; 
-} 
-
-void MHexagon::ExecuteEvent(Int_t event, Int_t px, Int_t py ) { 
-  //    This is the first test of implementing a clickable interface
-  //    for one pixel
-
-  switch ( event ) { 
-
-  case kButton1Down: 
-    
-    printf ("\n kButton1Down \n" ) ; 
-    SetFillColor(2) ;
-    gPad->Modified() ; 
-    break;     
-
-  case kButton1Double: 
-    SetFillColor(0) ;
-    gPad->Modified() ; 
-    break;     
-    //  case kMouseEnter:  
-    //     printf ("\n Mouse inside object \n" ) ; 
-    //     break; 
-  } 
-
-} 
-
-
-
-void MHexagon::ls( Option_t *)
-{
-  //     list this hexagon with its attributes
-  TROOT::IndentLevel() ; 
-  printf ("%s:  X= %f  Y= %f R= %f \n", GetName(), fX, fY, fD ) ;
-} 
-
-void MHexagon::Paint(Option_t * ) 
-{
-  //     paint this hexagon with its attribute
-
-  PaintHexagon(fX, fY, fD ) ; 
-} 
-
-
-void MHexagon::PaintHexagon (Float_t inX, Float_t inY, Float_t inD ) 
+    MHexagon *newhexagon = new MHexagon(x, y, d);
+
+    TAttLine::Copy(*newhexagon);
+    TAttFill::Copy(*newhexagon);
+
+    newhexagon->SetBit(kCanDelete);
+    newhexagon->AppendPad();
+}
+
+// ------------------------------------------------------------------------
+//
+//  This is the first test of implementing a clickable interface
+//  for one pixel
+//
+void MHexagon::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+
+    switch (event)
+    {
+    case kButton1Down:
+        cout << endl << "kButton1Down" << endl;
+        SetFillColor(2);
+        gPad->Modified();
+        break;
+
+    case kButton1Double:
+        SetFillColor(0);
+        gPad->Modified();
+        break;
+        //  case kMouseEnter:
+        //     printf ("\n Mouse inside object \n" ) ;
+        //     break;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  list this hexagon with its attributes
+//
+void MHexagon::ls(Option_t *)
+{
+    TROOT::IndentLevel();
+    Print();
+}
+
+// ------------------------------------------------------------------------
+//
+//  paint this hexagon with its attribute
+//
+void MHexagon::Paint(Option_t *)
+{
+    PaintHexagon(fX, fY, fD);
+}
+
+// ------------------------------------------------------------------------
+//
+//  draw this hexagon with the coordinates
+//
+void MHexagon::PaintHexagon(Float_t inX, Float_t inY, Float_t inD)
 { 
-  //      draw this hexagon with the coordinates
-
-  const Int_t np =  6 ; 
-  
-  const Float_t dx[np+1] = { .5   , 0.    , -.5   , -.5   , 0.    ,  .5   , .5    } ;
-  const Float_t dy[np+1] = { .2886,  .5772,  .2886, -.2886, -.5772, -.2886, .2886 } ;
-
-  static Float_t x[np+1], y[np+1] ; 
-  
-  TAttLine::Modify() ;    // Change line attributes only if neccessary
-  TAttFill::Modify() ;    // Change fill attributes only if neccessary
-    
-  //  calculate the positions of the pixel corners
-
-  for ( Int_t i=0; i<=np; i++ ) { 
-    x[i] = inX + dx[i]* inD ; 
-    y[i] = inY + dy[i]* inD ; 
-  } 
-
-  //   paint the pixel (hopefully) 
-  
-  if ( GetFillColor() ) gPad->PaintFillArea(np, x, y) ; 
-  if ( GetLineStyle() ) gPad->PaintPolyLine(np+1, x, y) ; 
-  
-} 
-
-void MHexagon::Print( Option_t * )
-{
-  //     print/dump this hexagon with its attributes
-  printf ("Ellipse:  X= %f  Y= %f R= %f ", fX, fY, fD ) ;
-  
-  if ( GetLineColor() != 1 ) printf (" Color=%d", GetLineColor() ) ; 
-  if ( GetLineStyle() != 1 ) printf (" Color=%d", GetLineStyle() ) ; 
-  if ( GetLineWidth() != 1 ) printf (" Color=%d", GetLineWidth() ) ;
-
-  if ( GetFillColor() != 0 ) printf (" FillColor=%d", GetFillColor() ) ; 
-
-  printf ("\n") ; 
-} 
-
-
-
-
-
-
+
+    const Int_t np = 6;
+
+    const Float_t dx[np+1] = { .5   , 0.    , -.5   , -.5   , 0.    ,  .5   , .5    };
+    const Float_t dy[np+1] = { .2886,  .5772,  .2886, -.2886, -.5772, -.2886, .2886 };
+
+    static Float_t x[np+1], y[np+1];
+
+    TAttLine::Modify();    // Change line attributes only if neccessary
+    TAttFill::Modify();    // Change fill attributes only if neccessary
+
+    //  calculate the positions of the pixel corners
+
+    for (Int_t i=0; i<=np; i++)
+    {
+        x[i] = inX + dx[i]* inD;
+        y[i] = inY + dy[i]* inD;
+    }
+
+    //   paint the pixel (hopefully)
+
+    if (GetFillColor())
+        gPad->PaintFillArea(np, x, y);
+
+    if (GetLineStyle())
+        gPad->PaintPolyLine(np+1, x, y);
+
+}
+
+// ------------------------------------------------------------------------
+//
+//  print/dump this hexagon with its attributes
+//
+void MHexagon::Print(Option_t *)
+{
+    cout << GetName() << ": X=" << fX << " Y=" << fY << "R=" << fD << endl;
+
+    cout << " Color="     << GetLineColor() << endl;
+    cout << " Style="     << GetLineStyle() << endl;
+    cout << " Width="     << GetLineWidth() << endl;
+    cout << " FillColor=" << GetFillColor() << endl;
+}
Index: trunk/MagicSoft/Mars/mhist/MHFadcPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFadcPix.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mhist/MHFadcPix.cc	(revision 959)
@@ -46,24 +46,20 @@
 {
     // FIXME! Set the right axis titles and ... and ...
-    Char_t tmp1[40]="hi";
-    Char_t tmp2[40]="hi gain Pixel";
+    Char_t tmp1[40];
+    Char_t tmp2[40];
 
-    if (pixid)
-    {
-        sprintf(tmp1, "%s%d",  tmp1, pixid);
-        sprintf(tmp2, "%s %d", tmp2, pixid);
-    }
+    //    if (pixid)
+    //    {
+    sprintf(tmp1, "HiGain%03d", pixid);
+    sprintf(tmp2, "Hi Gain Pixel #%d", pixid);
+    //    }
     fHistHi =  new TH1F(tmp1, tmp2, 256, 0, 255);
 
-
-    Char_t tmp3[40]="lo";
-    Char_t tmp4[40]="lo gain Pixel";
-
-    if (pixid)
-    {
-        sprintf(tmp3, "%s%d",  tmp3, pixid);
-        sprintf(tmp4, "%s %d", tmp4, pixid);
-    }
-    fHistLo =  new TH1F(tmp3, tmp4, 256, 0, 255);
+    //    if (pixid)
+    //    {
+    sprintf(tmp1, "LoGain%03d", pixid);
+    sprintf(tmp2, "Lo Gain Pixel #%d", pixid);
+    //    }
+    fHistLo = new TH1F(tmp2, tmp2, 256, 0, 255);
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 959)
@@ -132,25 +132,27 @@
 void MHHillas::Draw(Option_t *)
 {
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
 
-    //
-    // Fixme! Check for an existing canvas.
-    // And create one if no canvas exists only!
-    //
-    TCanvas *c = new TCanvas("Hillas", "Histograms of Hillas Parameters");
-    c->Divide(2,2);
+    //TCanvas *c = new TCanvas("Hillas", "Histograms of Hillas Parameters");
+    gPad->Divide(2,2);
 
-    c->cd(1);
+    gPad->cd(1);
     fAlpha->Draw();
 
-    c->cd(2);
+    gPad->cd(2);
     fLength->Draw();
 
-    c->cd(3);
+    gPad->cd(3);
     fDist->Draw();
 
-    c->cd(4);
+    gPad->cd(4);
     fWidth->Draw();
 
-    c->Modified();
-    c->Update();
+    gPad->Modified();
+    gPad->Update();
 }
Index: trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 959)
@@ -110,10 +110,17 @@
 void MHMcCollectionArea::DrawAll(Option_t* option)
 {
-    TCanvas *c=new TCanvas(fHistAll->GetName(), fHistAll->GetTitle());
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
+
+    //TCanvas *c=new TCanvas(fHistAll->GetName(), fHistAll->GetTitle());
 
     fHistAll->Draw(option);
 
-    c->Modified();
-    c->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
@@ -124,10 +131,17 @@
 void MHMcCollectionArea::DrawSel(Option_t* option)
 {
-    TCanvas *c=new TCanvas(fHistSel->GetName(), fHistSel->GetTitle());
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
+
+    //TCanvas *c=new TCanvas(fHistSel->GetName(), fHistSel->GetTitle());
 
     fHistSel->Draw(option);
 
-    c->Modified();
-    c->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
@@ -157,10 +171,16 @@
 void MHMcCollectionArea::Draw(Option_t* option)
 {
-    TCanvas *c=new TCanvas(fHistCol->GetName(), fHistCol->GetTitle());
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
+    //   TCanvas *c=new TCanvas(fHistCol->GetName(), fHistCol->GetTitle());
 
     fHistCol->Draw(option);
 
-    c->Modified();
-    c->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 959)
@@ -133,4 +133,9 @@
 }
 
+// ------------------------------------------------------------------------
+// 
+//  Helper function for Draw() and DrawClone() which adds some useful
+//  information to the plot.
+//
 void MHMcEnergy::DrawLegend() const
 {
@@ -157,5 +162,11 @@
 void MHMcEnergy::Draw(Option_t *option)
 {
-    TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
+    //TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle());
 
     fHist->Draw(option);
@@ -163,6 +174,6 @@
     DrawLegend();
 
-    c->Modified();
-    c->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 959)
@@ -196,5 +196,12 @@
 void MHStarMap::Draw(Option_t *)
 {
-    TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
+    if (!gPad)
+    {
+        if (!gROOT->GetMakeDefCanvas())
+            return;
+        (gROOT->GetMakeDefCanvas())();
+    }
+
+    // TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
 
     PrepareDrawing();
@@ -202,6 +209,6 @@
     fStarMap->Draw("colz");
 
-    c->Modified();
-    c->Update();
-}
-
+    gPad->Modified();
+    gPad->Update();
+}
+
Index: trunk/MagicSoft/Mars/mmain/MCameraDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MCameraDisplay.cc	(revision 959)
+++ trunk/MagicSoft/Mars/mmain/MCameraDisplay.cc	(revision 959)
@@ -0,0 +1,99 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MCameraDisplay.h"
+
+#include <TGButton.h>  // TGTextButton
+
+#include "MGCamDisplay.h"
+
+ClassImp(MCameraDisplay)
+
+enum {
+    M_BUTTON_DISP
+};
+
+// --------------------------------------------------------------------------
+//
+//  Create the 'Data Check' GUI Controls (Window) on the screen. To use it
+//  from within the interpreter you can call a Standard Version with
+//  'new MCameraDisplay()'
+//
+MCameraDisplay::MCameraDisplay(const TGWindow *main, const TGWindow *p,
+                       const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    TGTextButton *disp = new TGTextButton(fTop2, "Display Events", M_BUTTON_DISP);
+    fList->Add(disp);
+
+    disp->Associate(this);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    fTop2->AddFrame(disp, laybut);
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Camera Display Window");
+    SetIconName("Camera Dsiplay");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the GUI control events (here: mainly button clicks)
+//
+Bool_t MCameraDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case M_BUTTON_DISP:
+        if (!InputFileSelected())
+        {
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case M_BUTTON_DISP:
+            new MGCamDisplay(fInputFile,
+                             fClient->GetRoot(), this, 600, 500);
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: trunk/MagicSoft/Mars/mmain/MCameraDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MCameraDisplay.h	(revision 959)
+++ trunk/MagicSoft/Mars/mmain/MCameraDisplay.h	(revision 959)
@@ -0,0 +1,25 @@
+#ifndef MCAMERADISPLAY_H
+#define MCAMERADISPLAY_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+
+#ifndef MBROWSER_H
+#include "MBrowser.h"
+#endif
+
+class MCameraDisplay : public MBrowser
+{
+public:
+    MCameraDisplay(const TGWindow *main=NULL, const TGWindow *p=NULL,
+                   const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MCameraDisplay, 0) // GUI: The 'data-check' window.
+};
+
+#endif
+
+
Index: trunk/MagicSoft/Mars/mmain/MDataCheck.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MDataCheck.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mmain/MDataCheck.cc	(revision 959)
@@ -28,4 +28,15 @@
 #include <TGButton.h>  // TGTextButton
 
+// ---
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+#include "MReadTree.h"
+#include "MFillH.h"
+#include "MGDisplayAdc.h"
+
+// ---
+
 ClassImp(MDataCheck)
 
@@ -37,6 +48,12 @@
 };
 
+// --------------------------------------------------------------------------
+//
+//  Create the 'Data Check' GUI Controls (Window) on the screen. To use it
+//  from within the interpreter you can call a Standard Version with
+//  'new MDataCheck()'
+//
 MDataCheck::MDataCheck(const TGWindow *main, const TGWindow *p,
-                                 const UInt_t w, const UInt_t h)
+                       const UInt_t w, const UInt_t h)
 : MBrowser(main, p, w, h)
 {
@@ -75,6 +92,54 @@
 }
 
-// ======================================================================
+// --------------------------------------------------------------------------
+//
+//  Create the 'View Adc' GUI Controls (Window) on the screen.
+//  Therefor we have to process all data in a file and fill the corresponding
+//  histograms.
+//
+void MDataCheck::ViewAdcSpectra(Char_t *inputfile, Char_t *treeName)
+{
+    //
+    // create a (empty) list of parameters which can be used by the tasks
+    // and an (empty) list of tasks which should be executed
+    // connect them in the required way.
+    //
 
+    //
+    //   create the data containers for the raw data
+    //
+    MParList plist;
+
+    //
+    // set up the tasks for this job
+    //
+    MTaskList tasks;
+    plist.AddToList(&tasks);
+
+    MReadTree readin(treeName, inputfile);
+    tasks.AddToList(&readin);
+
+    MFillH fillspect("MRawEvtData", "MHFadcCam");
+    tasks.AddToList(&fillspect);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // start the loop running
+    //
+    if (!magic.Eventloop())
+        return;
+
+    new MGDisplayAdc((MHFadcCam*)plist.FindObject("MHFadcCam"));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the GUI control events (here: mainly button clicks)
+//
 Bool_t MDataCheck::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
 {
@@ -99,9 +164,9 @@
         {
         case M_BUTTON_PEDADC:
-            fViewAdc.AdcSpectra(fInputFile, "PedEvents");
+            ViewAdcSpectra(fInputFile, "PedEvents");
             return kTRUE;
 
         case M_BUTTON_CRADC:
-            fViewAdc.AdcSpectra(fInputFile, "Events");
+            ViewAdcSpectra(fInputFile, "Events");
             return kTRUE;
 
Index: trunk/MagicSoft/Mars/mmain/MDataCheck.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MDataCheck.h	(revision 958)
+++ trunk/MagicSoft/Mars/mmain/MDataCheck.h	(revision 959)
@@ -10,12 +10,8 @@
 #endif
 
-#ifndef MVIEWADCSPECTRA_H
-#include "MViewAdcSpectra.h"
-#endif
-
 class MDataCheck : public MBrowser
 {
 private:
-    MViewAdcSpectra fViewAdc;
+    void ViewAdcSpectra(Char_t *inputfile, Char_t *treeName);
 
 public:
Index: trunk/MagicSoft/Mars/mmain/MMars.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMars.cc	(revision 958)
+++ trunk/MagicSoft/Mars/mmain/MMars.cc	(revision 959)
@@ -34,25 +34,24 @@
 #include <TG3DLine.h>      // TGHorizontal3DLine
                            // use TGSplitter.h for root<3.00
-
 #include "MEvtDisp.h"
 #include "MAnalysis.h"
 #include "MDataCheck.h"
 #include "MMonteCarlo.h"
-
-#include "MGPrototyp.h"
+#include "MCameraDisplay.h"
 
 ClassImp(MMars)
 
 enum {
-  M_FILE_EXIT,
-  M_FILE_ABOUT,
-
-  M_PICTURE_MAGIC,
-  M_PICTURE_MARS,
-
-  M_BUTTON_EVTDISP,
-  M_BUTTON_DATACHECK,
-  M_BUTTON_ANALYSE,
-  M_BUTTON_MONTECARLO
+    M_FILE_EXIT,
+    M_FILE_ABOUT,
+
+    M_PICTURE_MAGIC,
+    M_PICTURE_MARS,
+
+    M_BUTTON_EVTDISP,
+    M_BUTTON_DATACHECK,
+    M_BUTTON_ANALYSE,
+    M_BUTTON_MONTECARLO,
+    M_BUTTON_CAMDISPLAY
 };
 
@@ -97,6 +96,6 @@
     mars->Associate(this);
 
-    TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft, 10., 10., 20., 10.);
-    TGLayoutHints *lay2 = new TGLayoutHints(kLHintsLeft, 10., 10., 10., 10.);
+    TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft,  10., 10., 20., 10.);
+    TGLayoutHints *lay2 = new TGLayoutHints(kLHintsRight, 10., 10., 10., 10.);
 
     fList->Add(lay1);
@@ -105,4 +104,28 @@
     top->AddFrame(magic, lay1);
     top->AddFrame(mars,  lay2);
+}
+
+void MMars::CreateTextButton(TGVerticalFrame *tab, const char *text,
+                             const UInt_t id, TGLayoutHints *hints) const
+{
+    //
+    // Create the button
+    //
+    TGTextButton *button = new TGTextButton(tab, text, id);
+
+    //
+    // Add button for 'auto-delete'
+    //
+    fList->Add(button);
+
+    //
+    // Send button events (meesages) to this object (s. ProcessMessage)
+    //
+    button->Associate(this);
+
+    //
+    // Add button with corresponding layout to containing frame
+    //
+    tab->AddFrame(button, hints);
 }
 
@@ -136,30 +159,17 @@
     tf->AddFrame(tab2, laytabx);
 
-    TGTextButton *evtdisp    = new TGTextButton(tab2, "EventDisplay", M_BUTTON_EVTDISP);
-    TGTextButton *datacheck  = new TGTextButton(tab2, "Data Check",   M_BUTTON_DATACHECK);
-    TGTextButton *analysis   = new TGTextButton(tab2, "Analysis",     M_BUTTON_ANALYSE);
-    TGTextButton *montecarlo = new TGTextButton(tab2, "MonteCarlo",   M_BUTTON_MONTECARLO);
-
-    fList->Add(evtdisp);
-    fList->Add(datacheck);
-    fList->Add(analysis);
-    fList->Add(montecarlo);
-
-    evtdisp   ->Associate(this);
-    datacheck ->Associate(this);
-    analysis  ->Associate(this);
-    montecarlo->Associate(this);
-
-    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX , 10, 10, 10, 10);
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 10, 10, 10, 10);
     fList->Add(laybut);
 
-    tab2->AddFrame(evtdisp,    laybut);
-    tab2->AddFrame(datacheck,  laybut);
-    tab2->AddFrame(analysis,   laybut);
-    tab2->AddFrame(montecarlo, laybut);
+    CreateTextButton(tab2, "Event Display",  M_BUTTON_EVTDISP,    laybut);
+    CreateTextButton(tab2, "Data Check",     M_BUTTON_DATACHECK,  laybut);
+    CreateTextButton(tab2, "Analysis",       M_BUTTON_ANALYSE,    laybut);
+    CreateTextButton(tab2, "Monte Carlo",    M_BUTTON_MONTECARLO, laybut);
+    CreateTextButton(tab2, "Camera Display", M_BUTTON_CAMDISPLAY, laybut);
 }
 
 MMars::MMars(/*const TGWindow *p,*/ UInt_t w, UInt_t h)
-  : TGMainFrame(gClient->GetRoot(), w, h)
+: TGMainFrame(gClient->GetRoot(), w, h)
+//: MBrowser (gClient->GetRoot(), gClient->GetRoot(), w, h)
 {
     //
@@ -196,8 +206,11 @@
     AddFrame(low,     layout);
 
+    //    CreateTopFrame(fTop2);
+    //    CreateBottomFrame(fTop3);
+
     //
     //   Map the window, set up the layout, etc.
     //
-    SetWMSizeHints(400, 380, 400, 380, 10, 10);  // set the smallest and biggest size of the Main frame
+    SetWMSizeHints(400, 410, 400, 410, 10, 10);  // set the smallest and biggest size of the Main frame
 
     MapSubwindows();
@@ -271,12 +284,17 @@
                 return kTRUE;
 
+            case M_BUTTON_CAMDISPLAY:
+                new MCameraDisplay(this);
+                return kTRUE;
+
             case M_PICTURE_MAGIC:
-                DisplWarning("Please open a Netscape to the MAGIC homepage");
+                DisplWarning("Please open a Netscape to the MAGIC homepage\n"
+                             "http://hegra1.mppmu.mpg.de/MAGICWeb/");
                 return kTRUE;
 
             case M_PICTURE_MARS:
-                DisplWarning("Please open a Netscape to the MARS homepage");
-                return kTRUE;
-
+                DisplWarning("Please open a Netscape to the MARS homepage\n"
+                             "http://magic.uni-sw.gwdg.de/mars/");
+                return kTRUE;
             }
 
Index: trunk/MagicSoft/Mars/mmain/MMars.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMars.h	(revision 958)
+++ trunk/MagicSoft/Mars/mmain/MMars.h	(revision 959)
@@ -10,5 +10,13 @@
 #endif
 
+/*
+ #ifndef MBROWSER_H
+ #include <MBrowser.h>
+ #endif
+ */
+
 class TList;
+class TGVerticalFrame;
+class TGLayoutHints;
 
 class MMars : public TGMainFrame
@@ -20,4 +28,7 @@
     const TGPicture *fPic1;
     const TGPicture *fPic2;
+
+    void CreateTextButton(TGVerticalFrame *tab, const char *text,
+                          const UInt_t id, TGLayoutHints *hints) const;
 
     void CreateMenuBar();
Index: trunk/MagicSoft/Mars/mmain/MainLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MainLinkDef.h	(revision 958)
+++ trunk/MagicSoft/Mars/mmain/MainLinkDef.h	(revision 959)
@@ -12,4 +12,5 @@
 #pragma link C++ class MDataCheck;
 #pragma link C++ class MMonteCarlo;
+#pragma link C++ class MCameraDisplay;
 
 #endif
Index: trunk/MagicSoft/Mars/mmain/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmain/Makefile	(revision 958)
+++ trunk/MagicSoft/Mars/mmain/Makefile	(revision 959)
@@ -34,4 +34,5 @@
            MAnalysis.cc \
 	   MMonteCarlo.cc \
+           MCameraDisplay.cc \
            MBrowser.cc
 
