Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 973)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 974)
@@ -14,5 +14,5 @@
 #include "MCerPhotEvt.h"
 
-#define kITEMS_LEGEND 25
+#define kItemsLegend 25
 
 ClassImp(MCamDisplay);
@@ -33,6 +33,11 @@
     //
     fNumPixels = geom->GetNumPixels();
+    fRange     = (Int_t)geom->GetMaxRadius();
+
     fPixels    = new TClonesArray("MHexagon", fNumPixels);
 
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
     for (UInt_t i=0; i<fNumPixels; i++)
         new ((*fPixels)[i]) MHexagon((*geom)[i]);
@@ -47,20 +52,23 @@
     // 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++)
-    {
-        const Int_t y = il*40;
-
-        TBox  *newbox = new ((*fLegend)[il])  TBox (650, y-500, 700, y-460);
-        TText *newtxt = new ((*fLegText)[il]) TText(720, y-480, text);
-
-        const Float_t lvl = 50. / kITEMS_LEGEND * il;
+    fLegend  = new TClonesArray("TBox",  kItemsLegend);
+    fLegText = new TClonesArray("TText", kItemsLegend);
+
+    for (Int_t i = 0; i<kItemsLegend; i++)
+    {
+        //const Int_t y = il*40;
+
+        //
+        // Construct gui elements of legend. Use new-operator with placement
+        //
+        //TBox  *newbox = new ((*fLegend)[il])  TBox (650, y-500, 700, y-460);
+        //TText *newtxt = new ((*fLegText)[il]) TText(720, y-480, text);
+
+        TBox  *newbox = new ((*fLegend)[i])  TBox;
+        TText *newtxt = new ((*fLegText)[i]) TText;
+
+        const Float_t lvl = 50. / kItemsLegend * i;
 
         newbox->SetFillColor(GetColor(lvl));
-
-        sprintf(text, "%5.1f", lvl);
 
         newtxt->SetTextSize(0.025);
@@ -75,4 +83,6 @@
 {
     delete fPixels;
+    delete fLegend;
+    delete fLegText;
 }
 
@@ -86,5 +96,5 @@
     //
     if (!gPad)
-        fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 650, 500);
+        fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 750, 600);
     else
     {
@@ -94,9 +104,31 @@
 
     //
+    // FIXME: This class should be a TPad, so that it is informed if the
+    // ratio between height and size changes!
+    //
+    const Float_t ratio = (Float_t)gPad->GetWw()/gPad->GetWh();
+
+    //
+    // The recommended size ratio is 5:4
+    //
+    Int_t x, y;
+
+    if (ratio > 5./4.)
+    {
+        x = (UInt_t)((ratio-1)*3*fRange);
+        y = fRange;
+    }
+    else
+    {
+        x = 3*fRange/2;
+        y = (UInt_t)(fRange/ratio);
+    }
+
+    //
     // Setup the correct environment
     //
     gStyle->SetPalette(1, 0);
 
-    gPad->Range(-600, -600, 900, 600);
+    gPad->Range(-fRange, -y, x, y);
     gPad->SetFillColor(22);
 
@@ -111,8 +143,22 @@
     // draw legend
     //
-    for (Int_t i=0; i<kITEMS_LEGEND; i++)
-    {
-        GetBox(i)->Draw();
-        GetText(i)->Draw();
+    const Float_t H = 0.9*fRange;
+    const Float_t h = 2./kItemsLegend;
+
+    const Float_t w = fRange/sqrt(fNumPixels);
+
+    for (Int_t i=0; i<kItemsLegend; i++)
+    {
+        TBox *box = GetBox(i);
+        box->SetX1(fRange);
+        box->SetX2(fRange+w);
+        box->SetY1(H*( i   *h - 1.));
+        box->SetY2(H*((i+1)*h - 1.));
+        box->Draw();
+
+        TText *txt = GetText(i);
+        txt->SetX(fRange+1.5*w);
+        txt->SetY(H*((i+0.5)*h - 1.));
+        txt->Draw();
     }
 }
@@ -153,5 +199,5 @@
     for (Int_t i=0; i<entries; i++)
     {
-        MCerPhotPix &pix = (*event)[i];
+        const MCerPhotPix &pix = (*event)[i];
 
         if (!pix.IsPixelUsed())
@@ -188,5 +234,5 @@
     for (Int_t i=0 ; i<entries; i++)
     {
-        MCerPhotPix &pix = (*event)[i];
+        const MCerPhotPix &pix = (*event)[i];
 
         SetPixColor(pix);
@@ -253,7 +299,7 @@
     char text[10];
 
-    for (Int_t il=0; il < kITEMS_LEGEND; il++)
-    {
-        const Float_t val = fMinPhe + (Float_t)il/kITEMS_LEGEND * (fMaxPhe-fMinPhe) ;
+    for (Int_t il=0; il < kItemsLegend; il++)
+    {
+        const Float_t val = fMinPhe + (Float_t)il/kItemsLegend * (fMaxPhe-fMinPhe) ;
 
         sprintf(text, "%5.1f", val);
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 973)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 974)
@@ -32,4 +32,6 @@
 
     UInt_t         fNumPixels;
+    Int_t          fRange;
+
     TClonesArray  *fPixels;
 
@@ -45,5 +47,5 @@
     TText *GetText(Int_t i) { return (TText*)fLegText->At(i); }
 
-    void SetPixColor(MCerPhotPix &pix)
+    void SetPixColor(const MCerPhotPix &pix)
     {
         (*this)[pix.GetPixId()].SetFillColor( GetColor(pix.GetNumPhotons()));
Index: trunk/MagicSoft/Mars/mgui/MGeomCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGeomCam.cc	(revision 973)
+++ trunk/MagicSoft/Mars/mgui/MGeomCam.cc	(revision 974)
@@ -47,10 +47,10 @@
 //
 MGeomCam::MGeomCam(UInt_t npix, const char *name, const char *title)
+    : fNumPixels(npix)
 {
     *fName  = name  ? name  : "MGeomCam";
     *fTitle = title ? title : "Storage container for  a camera geometry";
 
-    fNumPixels = npix;
-    fPixels    = new TObjArray(npix);
+    fPixels = new TObjArray(npix);
 
     //
@@ -61,4 +61,23 @@
     for (UInt_t i=0; i<npix; i++)
         (*fPixels)[i] = new MGeomPix;
+}
+
+void MGeomCam::CalcMaxRadius()
+{
+    fMaxRadius = 0;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeomPix &pix = (*this)[i];
+
+        const Float_t x = pix.GetX();
+        const Float_t y = pix.GetY();
+        const Float_t r = pix.GetR();
+
+        const Float_t maxr = sqrt(x*x+y*y) + r;
+
+        if (maxr>fMaxRadius)
+            fMaxRadius = maxr;
+    }
 }
 
Index: trunk/MagicSoft/Mars/mgui/MGeomCam.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MGeomCam.h	(revision 973)
+++ trunk/MagicSoft/Mars/mgui/MGeomCam.h	(revision 974)
@@ -18,6 +18,11 @@
 {
 private:
-    UInt_t     fNumPixels;  // Number of pixels in this camera
-    TObjArray *fPixels;     // Array of singel pixels storing the geometry
+    UInt_t   fNumPixels;  // Number of pixels in this camera
+    Float_t  fMaxRadius;  // maximum radius of the camera
+
+    TObjArray *fPixels;         // Array of singel pixels storing the geometry
+
+protected:
+    void CalcMaxRadius();
 
 public:
@@ -27,5 +32,6 @@
     virtual ~MGeomCam() { delete fPixels; }
 
-    UInt_t GetNumPixels() const { return fNumPixels; }
+    UInt_t  GetNumPixels() const { return fNumPixels; }
+    Float_t GetMaxRadius() const { return fMaxRadius; }
 
     MGeomPix &operator[](Int_t i)       { return *(MGeomPix*)fPixels->At(i); }
