Index: trunk/MagicSoft/Mars/mgui/GuiLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 2173)
+++ trunk/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 2178)
@@ -6,4 +6,5 @@
 
 #pragma link C++ class MHexagon+;
+#pragma link C++ class MCamEvent+;
 #pragma link C++ class MCamDisplay+;
 
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 2173)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 2178)
@@ -63,4 +63,5 @@
 
 #include "MCurrents.h"
+#include "MCamEvent.h"
 
 #include "MImgCleanStd.h"
@@ -91,4 +92,6 @@
     fMinimum = 0;
     fMaximum = 1;
+
+    fNotify = new TList;
 }
 
@@ -101,4 +104,6 @@
 {
     fGeomCam = (MGeomCam*)geom->Clone(); 
+
+    fNotify = new TList;
 
     //
@@ -211,4 +216,6 @@
 
     delete fGeomCam;
+
+    delete fNotify;
 }
 
@@ -228,5 +235,11 @@
     pad->SetBorderMode(0);
     pad->SetFillColor(16);
-
+    //pad->Modified();
+    /*
+    pad->Divide(1,1);
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetFillColor(16);
+*/
     AppendPad("");
 }
@@ -240,13 +253,31 @@
     const float ratio = 1.15;
 
-    const float w = gPad->GetWw();
-    const float h = gPad->GetWh()*ratio;
-
+    //
+    // Calculate width and height of the current pad in pixels
+    //
+    Float_t w = gPad->GetWw();
+    Float_t h = gPad->GetWh()*ratio;
+
+    //
+    // This prevents the pad from resizing itself wrongly
+    //
+    if (gPad->GetMother() != gPad)
+    {
+        w *= gPad->GetMother()->GetAbsWNDC();
+        h *= gPad->GetMother()->GetAbsHNDC();
+    }
+
+    //
+    // Set Range (coordinate system) of pad
+    //
     gPad->Range(-fRange, -fRange, (2*ratio-1)*fRange, fRange);
 
+    //
+    // Resize Pad to given ratio
+    //
     if (h<w)
-        gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 0.9999999);
+        gPad->SetPad((1.-h/w)/2, 0, (h/w+1.)/2, 1);
     else
-        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2);
+        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1.)/2);
 }
 
@@ -271,4 +302,6 @@
     }
 
+    if (fMinimum==FLT_MAX && fMaximum==-FLT_MAX)
+        fMinimum = fMaximum = 0;
     if (fMinimum==fMaximum)
         fMaximum = fMinimum + 1;
@@ -282,5 +315,4 @@
         else
             (*this)[i].SetFillColor(10);
-
     }
 }
@@ -314,6 +346,6 @@
 
     // Paint primitives (pixels, color legend, photons, ...)
-    { fPixels->ForEach(TObject, Paint)(); }
-    { fLegend->ForEach(TObject, Paint)(); }
+    { fPixels->ForEach( TObject, Paint)(); }
+    { fLegend->ForEach( TObject, Paint)(); }
     { fLegText->ForEach(TObject, Paint)(); }
     { fPhotons->ForEach(TObject, Paint)(); }
@@ -445,113 +477,32 @@
 // ------------------------------------------------------------------------
 //
-// Call this function to fill the number of photo electron into the
-// camera.
-//
-void MCamDisplay::FillPhotNum(const MCerPhotEvt &event)
+// Call this function to fill the currents
+//
+void MCamDisplay::Fill(const MCamEvent &event, Int_t type)
 {
     Reset();
 
-    const Int_t entries = event.GetNumPixels();
-
-    for (Int_t i=0; i<entries; i++)
-    {
-        const MCerPhotPix &pix = event[i];
-        if (!pix.IsPixelUsed())
-            continue;
-
-        const Int_t id = pix.GetPixId();
-
-        fData[id] = pix.GetNumPhotons()*fGeomCam->GetPixRatio(id);
-        (*this)[id].SetBit(kIsUsed);
-    }
-}
-
-// ------------------------------------------------------------------------
-//
-// Call this function to fill the number of photo electron into the
-// camera.
-//
-void MCamDisplay::FillPedestals(const MPedestalCam &event)
+    // FIXME: Security check missing!
+    for (UInt_t idx=0; idx<fNumPixels; idx++)
+    {
+        fData[idx] = 0;
+        if (event.GetPixelContent(fData[idx], idx, fGeomCam->GetPixRatio(idx), type))
+            (*this)[idx].SetBit(kIsUsed);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to fill the currents
+//
+void MCamDisplay::Fill(const TArrayF &event, Bool_t ispos)
 {
     Reset();
 
-    const Int_t entries = event.GetSize();
-    for (Int_t i=0; i<entries; i++)
-    {
-        fData[i] = event[i].GetMean()*fGeomCam->GetPixRatio(i);
-        (*this)[i].SetBit(kIsUsed);
-    }
-}
-
-// ------------------------------------------------------------------------
-//
-// Call this function to fill the error of number of photo electron
-// into the camera.
-//
-void MCamDisplay::FillErrorPhot(const MCerPhotEvt &event)
-{
-    Reset();
-
-    const Int_t entries = event.GetNumPixels();
-
-    for (Int_t i=0; i<entries; i++)
-    {
-        const MCerPhotPix &pix = event[i];
-        if (!pix.IsPixelUsed())
-            continue;
-
-        const Int_t id = pix.GetPixId();
-
-        fData[id] = pix.GetErrorPhot()*sqrt(fGeomCam->GetPixRatio(id));
-        (*this)[id].SetBit(kIsUsed);
-    }
-}
-
-// ------------------------------------------------------------------------
-//
-// Call this function to fill the ratio of the number of photons
-// divided by its error
-//
-void MCamDisplay::FillRatio(const MCerPhotEvt &event)
-{
-    Reset();
-
-    const Int_t entries = event.GetNumPixels();
-
-    for (Int_t i=0; i<entries; i++)
-    {
-        const MCerPhotPix &pix = event[i];
-
-        if (!pix.IsPixelUsed())
-            continue;
-
-        const Int_t id = pix.GetPixId();
-
-        const Float_t  entry = pix.GetNumPhotons();
-        const Float_t  noise = pix.GetErrorPhot();
-        const Double_t ratio = TMath::Sqrt(fGeomCam->GetPixRatio(id));
-
-        fData[id] = entry*ratio/noise;
-        (*this)[id].SetBit(kIsUsed);
-    }
-}
-
-// ------------------------------------------------------------------------
-//
-// Call this function to fill the currents
-//
-void MCamDisplay::FillCurrents(const MCurrents &event)
-{
-    Reset();
-
-    // FIXME: Security check missing!
-    for (UInt_t i=0; i<fNumPixels; i++)
-    {
-        if (event[i]<=0)
-            continue;
-
-        (*this)[i].SetBit(kIsUsed);
-        fData[i] = event[i];
-    }
+    fData = event;
+
+    for (UInt_t idx=0; idx<fNumPixels; idx++)
+        if (!ispos || fData[idx]>0)
+            (*this)[idx].SetBit(kIsUsed);
 }
 
@@ -562,5 +513,5 @@
 void MCamDisplay::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2)
 {
-    FillRatio(event);
+    Fill(event, 2);
 
     for (UInt_t i=0; i<fNumPixels; i++)
@@ -793,4 +744,17 @@
 }
 
+Int_t MCamDisplay::GetPixelIndex(Int_t px, Int_t py) const
+{
+    UInt_t i;
+    for (i=0; i<fNumPixels; i++)
+    {
+        if ((*fPixels)[i]->DistancetoPrimitive(px, py)>0)
+            continue;
+
+        return i;
+    }
+    return -1;
+}
+
 // ------------------------------------------------------------------------
 //
@@ -800,15 +764,37 @@
 char *MCamDisplay::GetObjectInfo(Int_t px, Int_t py) const
 {
-    static char info[64];
-
-    UInt_t i;
-    for (i=0; i<fNumPixels; i++)
-    {
-        if ((*fPixels)[i]->DistancetoPrimitive(px, py)>0)
-            continue;
-
-        sprintf(info, "Pixel Id: %d", i);
-        return info;
-    }
-    return TObject::GetObjectInfo(px, py);
-}
+    static char info[128];
+
+    const Int_t idx=GetPixelIndex(px, py);
+
+    if (idx<0)
+        return TObject::GetObjectInfo(px, py);
+
+    sprintf(info, "Software Pixel Index: %d (Hardware Id=%d)", idx, idx+1);
+    return info;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MCamDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    //if (event==kMouseMotion && fStatusBar)
+    //    fStatusBar->SetText(GetObjectInfo(px, py), 0);
+    if (event!=kButton1Down)
+        return;
+
+    const Int_t idx = GetPixelIndex(px, py);
+    if (idx<0)
+        return;
+
+    cout << "Software Pixel Index: " << idx << endl;
+    cout << "Hardware Pixel Id:    " << idx+1 << endl;
+    cout << "Contents:             " << fData[idx] << endl;
+
+    //fNotify->Print();
+    if (fNotify->GetSize()>0)
+        new TCanvas;
+    fNotify->ForEach(MCamEvent, DrawPixelContent)(idx);
+}
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 2173)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 2178)
@@ -22,9 +22,11 @@
 class TText;
 class TArrow;
+class TGStatusBar;
 
 class MGeomCam;
 class MHexagon;
+class MCurrents;
+class MCamEvent;
 class MRflEvtData;
-class MCurrents;
 class MCerPhotEvt;
 class MCerPhotPix;
@@ -60,4 +62,8 @@
     Float_t        fMaximum;
 
+    TList         *fNotify;
+
+    //TGStatusBar   *fStatusBar;
+
     TBox  *GetBox(Int_t i)  { return (TBox*) fLegend->At(i); }
 
@@ -71,4 +77,6 @@
     void  SetPalette();
 
+    Int_t GetPixelIndex(Int_t px, Int_t py) const;
+
     enum {
         kIsUsed = BIT(14)
@@ -81,13 +89,11 @@
 
     void  SetAutoScale(Bool_t input=kTRUE); // *MENU*
-    void  FillPhotNum(const MCerPhotEvt &event);
-    void  FillRatio(const MCerPhotEvt &event);
+
+    void  ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);
+    void  FillRflEvent(const MRflEvtData &event);
     void  FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2);
-    void  FillErrorPhot(const MCerPhotEvt &event);
     void  FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean);
-    void  FillPedestals(const MPedestalCam &event);
-    void  FillRflEvent(const MRflEvtData &event);
-    void  FillCurrents(const MCurrents &event);
-    void  ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);
+    void  Fill(const MCamEvent &event, Int_t type=0);
+    void  Fill(const TArrayF &event, Bool_t ispos=kTRUE);
 
     void  DrawPixelNumbers();
@@ -99,5 +105,5 @@
     Int_t DistancetoPrimitive(Int_t px, Int_t py);
     char *GetObjectInfo(Int_t px, Int_t py) const;
-    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
 
     void  SetPalette(Int_t ncolors, Int_t *colors);
@@ -111,4 +117,8 @@
     void  SetMinimum(Float_t m); // *MENU*
     void  SetMaximum(Float_t m); // *MENU*
+
+    void  AddNotify(const MCamEvent &event) { fNotify->Add((TObject*)(&event)); }
+
+    //void SetStatusBar(TGStatusBar *bar) { fStatusBar = bar; }
 
     ClassDef(MCamDisplay, 0) // Displays the magic camera
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.cc	(revision 2178)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.cc	(revision 2178)
@@ -0,0 +1,32 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MCamEvent                                                                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MCamEvent.h"
+
+ClassImp(MCamEvent);
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 2178)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 2178)
@@ -0,0 +1,27 @@
+#ifndef MARS_MCamEvent
+#define MARS_MCamEvent
+
+//////////////////////////////////////////////////////////////
+//
+//   MCamEvent
+//
+//   A Hexagon for the MAGIC event display
+//
+//////////////////////////////////////////////////////////////
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomCam;
+
+class MCamEvent : public MParContainer
+{
+public:
+    virtual Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const = 0;
+    virtual void   DrawPixelContent(Int_t num) const = 0;
+
+    ClassDef(MCamEvent, 0)    // A hexagon for MAGIC
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mgui/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mgui/Makefile	(revision 2173)
+++ trunk/MagicSoft/Mars/mgui/Makefile	(revision 2178)
@@ -23,5 +23,5 @@
 #
 INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist \
-	   -I../mreflector
+	   -I../mreflector -I../mraw
 
 #------------------------------------------------------------------------------
@@ -30,5 +30,6 @@
 
 SRCFILES = MHexagon.cc \
-           MCamDisplay.cc 
+	   MCamEvent.cc \
+           MCamDisplay.cc
 
 SRCS    = $(SRCFILES)
