Index: trunk/MagicSoft/Mars/mtools/MagicCivilization.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicCivilization.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicCivilization.cc	(revision 9369)
@@ -2,5 +2,5 @@
 !
 ! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * This file is part of CheObs, the Modular 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.
@@ -9,5 +9,5 @@
 ! * 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
+! * provided that the above copyright notice appears in all copies and
 ! * that both that copyright notice and this permission notice appear
 ! * in supporting documentation. It is provided "as is" without express
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Author(s): Thomas Bretz,  7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: CheObs Software Development, 2000-2009
 !
 !
@@ -65,5 +65,5 @@
 #include <TInterpreter.h>
 
-#include "MHexagon.h"
+#include "MH.h"
 
 #include "MGeomPix.h"
@@ -80,20 +80,5 @@
         return;
 
-    fPixels->Delete();
-
-    delete fPixels;
-
     delete fGeomCam;
-}
-
-// ------------------------------------------------------------------------
-//
-// Draw all pixels of the camera
-//  (means apend all pixelobjects to the current pad)
-//
-void MagicCivilization::DrawHexagons()
-{
-    for (UInt_t i=0; i<fNumPixels; i++)
-        (*this)[i].Draw();
 }
 
@@ -111,5 +96,5 @@
     ct1 = !ct1;
 
-    DrawHexagons();
+    AppendPad();
 }
 
@@ -117,10 +102,4 @@
 {
     Free();
-
-    //
-    //  Reset the display geometry
-    //
-    fW=0;
-    fH=0;
 
     //
@@ -135,16 +114,5 @@
     fRange     = fGeomCam->GetMaxRadius();
 
-    //
-    // Construct all hexagons. Use new-operator with placement
-    //
-    fPixels = new TClonesArray("MHexagon", fNumPixels);
-
-    for (UInt_t i=0; i<fNumPixels; i++)
-    {
-        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        h.SetBit(kNoContextMenu|kCannotPick);
-#endif
-    }
+    fColors.Set(fNumPixels);
 }
 
@@ -154,5 +122,5 @@
 //
 MagicCivilization::MagicCivilization(Byte_t lim, UShort_t init)
-    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim), fW(0), fH(0)
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim)
 {
     SetNewCamera(new MGeomCamMagic);
@@ -179,10 +147,4 @@
     fTimer.TurnOff();
     Free();
-
-    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
-    {
-        fDrawingPad->RecursiveRemove(this);
-        delete fDrawingPad;
-    }
 }
 
@@ -195,40 +157,23 @@
 void MagicCivilization::Paint(Option_t *opt)
 {
-    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
-    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
-
-    //
-    // Check for a change in width or height, and make sure, that the
-    // first call also sets the range
-    //
-    if (w*fH == h*fW && fW && fH)
-        return;
-
-    //
-    // Calculate aspect ratio (5/4=1.25 recommended)
-    //
-    const Double_t ratio = (Double_t)w/h;
-
-    Float_t x;
-    Float_t y;
-
-    if (ratio>1.0)
-    {
-        x = fRange*(ratio*2-1);
-        y = fRange;
-    }
-    else
-    {
-        x = fRange;
-        y = fRange/ratio;
-    }
-
-    fH = h;
-    fW = w;
-
-    //
-    // Set new range
-    //
-    fDrawingPad->Range(-fRange, -y, x, y);
+    const Float_t r = fGeomCam->GetMaxRadius();
+
+    MH::SetPadRange(-r, -r, r, r*1.1);
+
+    TAttLine line;
+    TAttFill fill;
+
+    // FIXME:
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeom &pix = (*fGeomCam)[i];
+
+        fill.SetFillColor(fColors[i]);
+        pix.PaintPrimitive(line, fill);
+    }
+ /*
+    for (int i=0; i<6; i++)
+        fText[i]->Paint();
+        */
 }
 
@@ -266,8 +211,10 @@
     fStep = 0;
 
+    fColors.Reset();
+
     Update();
 
-    fDrawingPad->Modified();
-    fDrawingPad->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
@@ -284,10 +231,8 @@
     // if no canvas is yet existing to draw into, create a new one
     //
-    /*TCanvas *c =*/ new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800);
-    //c->ToggleEventStatus();
-
-    fDrawingPad = gPad;
-    fDrawingPad->SetBorderMode(0);
-    fDrawingPad->SetFillColor(22);
+    new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800);
+
+    gPad->SetBorderMode(0);
+    gPad->SetFillColor(22);
 
     //
@@ -296,9 +241,4 @@
     //
     AppendPad(option);
-
-    //
-    // Reset the game pad
-    //
-    DrawHexagons();
 
     fCivilization.SetTextAlign(23);   // centered/bottom
@@ -349,5 +289,5 @@
         fAuto = !fAuto;
         Update();
-        fDrawingPad->Update();
+        gPad->Update();
         return;
 
@@ -395,5 +335,5 @@
     for (int i=0; i<fNumPixels; i++)
     {
-        MGeomPix &pix = (*fGeomCam)[i];
+        MGeom &pix = (*fGeomCam)[i];
 
         Byte_t cnt=0;
@@ -411,11 +351,10 @@
     for (int i=0; i<fNumPixels; i++)
     {
-        MGeomPix &pix = (*fGeomCam)[i];
-        MHexagon &hex = (*this)[i];
+        MGeom &pix = (*fGeomCam)[i];
 
         if (pix.TestBit(kHasCreation))
         {
             pix.SetBit(kHasFlag);
-            hex.SetFillColor(kBlack);
+            fColors[i] = kBlack;
             fNumCivilizations++;
         }
@@ -423,5 +362,5 @@
         {
             pix.ResetBit(kHasFlag);
-            hex.SetFillColor(kBackground);
+            fColors[i] = kBackground;
         }
         pix.ResetBit(kHasCreation);
@@ -435,5 +374,5 @@
     Update();
 
-    fDrawingPad->Update();
+    gPad->Update();
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mtools/MagicCivilization.h
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicCivilization.h	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicCivilization.h	(revision 9369)
@@ -14,4 +14,7 @@
 #ifndef ROOT_TClonesArray
 #include <TClonesArray.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
 #endif
 
@@ -50,15 +53,8 @@
     TText     fCivilization;    // TText showing the numbers of pixels and bombs
 
-    UInt_t    fW;               // Width of canvas
-    UInt_t    fH;               // Height of canvas
-
-    TClonesArray *fPixels;      // array of all hexagons
-    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
-
-    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+    TArrayI fColors;
 
     void   Update();
     void   Free();
-    void   DrawHexagons();
     void   SetNewCamera(MGeomCam *);
 
Index: trunk/MagicSoft/Mars/mtools/MagicDomino.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicDomino.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicDomino.cc	(revision 9369)
@@ -2,5 +2,5 @@
 !
 ! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * This file is part of CheObs, the Modular 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.
@@ -9,5 +9,5 @@
 ! * 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
+! * provided that the above copyright notice appears in all copies and
 ! * that both that copyright notice and this permission notice appear
 ! * in supporting documentation. It is provided "as is" without express
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Thomas Bretz,  7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2008
+!   Copyright: CheObs Software Development, 2000-2009
 !
 !
@@ -68,5 +68,5 @@
 #include <TInterpreter.h>
 
-#include "MHexagon.h"
+#include "MH.h"
 
 #include "MGeomPix.h"
@@ -87,20 +87,5 @@
         return;
 
-    fPixels->Delete();
-
-    delete fPixels;
-
     delete fGeomCam;
-}
-
-// ------------------------------------------------------------------------
-//
-// Draw all pixels of the camera
-//  (means apend all pixelobjects to the current pad)
-//
-void MagicDomino::DrawHexagons()
-{
-    for (UInt_t i=0; i<fNumPixels; i++)
-        (*this)[i].Draw();
 }
 
@@ -123,5 +108,5 @@
 
     Reset();
-    DrawHexagons();
+    AppendPad();
 }
 
@@ -133,10 +118,4 @@
 {
     Free();
-
-    //
-    //  Reset the display geometry
-    //
-    fW=0;
-    fH=0;
 
     //
@@ -151,48 +130,31 @@
     fRange     = fGeomCam->GetMaxRadius();
 
-    //
-    // Construct all hexagons. Use new-operator with placement
-    //
-    fPixels = new TClonesArray("MHexagon", fNumPixels);
-
+    fColors.Set(fNumPixels);
+}
+
+// ------------------------------------------------------------------------
+//
+// remove the pixel numbers in the tile from the pad
+//
+void MagicDomino::RemoveNumbers()
+{
+    for (int i=0; i<6; i++)
+        fText[i]->SetText(0, 0, "");
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/restart the game
+//
+void MagicDomino::Reset()
+{
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+        fColors[i] = kBackground;
+        (*fGeomCam)[i].ResetBit(kUserBits);
+    }
+
+
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        h.SetBit(kNoContextMenu|kCannotPick);
-#endif
-    }
-}
-
-// ------------------------------------------------------------------------
-//
-// remove the pixel numbers in the tile from the pad
-//
-void MagicDomino::RemoveNumbers()
-{
-    for (int i=0; i<6; i++)
-        if (fText[i])
-        {
-            delete fText[i];
-            fText[i] = NULL;
-        }
-}
-
-// ------------------------------------------------------------------------
-//
-// Reset/restart the game
-//
-void MagicDomino::Reset()
-{
-    for (UInt_t i=0; i<fNumPixels; i++)
-    {
-        MHexagon &h = (*this)[i];
-        h.SetFillColor(kBackground);
-        h.ResetBit(kUserBits);
-    }
-
-
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-    fDrawingPad->SetBit(kNoContextMenu);
     SetBit(kNoContextMenu);
 #endif
@@ -205,5 +167,5 @@
 
 
-    fDrawingPad->SetFillColor(22);
+    gPad->SetFillColor(22);
 
     fNumPixel = -1;
@@ -218,5 +180,10 @@
 void MagicDomino::Init()
 {
-    memset(fText, 0, sizeof(fText));
+    for (int i=0; i<6; i++)
+    {
+        fText[i] = new TText(0, 0, "");
+        fText[i]->SetTextFont(122);
+        fText[i]->SetTextAlign(22);   // centered/centered
+    }
 
     //
@@ -260,11 +227,4 @@
 
     RemoveNumbers();
-
-    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
-    {
-        fDrawingPad->RecursiveRemove(this);
-        delete fDrawingPad;
-    }
-
 }
 
@@ -277,40 +237,22 @@
 void MagicDomino::Paint(Option_t *opt)
 {
-    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
-    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
-
-    //
-    // Check for a change in width or height, and make sure, that the
-    // first call also sets the range
-    //
-    if (w*fH == h*fW && fW && fH)
-        return;
-
-    //
-    // Calculate aspect ratio (5/4=1.25 recommended)
-    //
-    const Double_t ratio = (Double_t)w/h;
-
-    Float_t x;
-    Float_t y;
-
-    if (ratio>1.0)
-    {
-        x = fRange*(ratio*2-1);
-        y = fRange;
-    }
-    else
-    {
-        x = fRange;
-        y = fRange/ratio;
-    }
-
-    fH = h;
-    fW = w;
-
-    //
-    // Set new range
-    //
-    fDrawingPad->Range(-fRange, -y, x, y);
+    const Float_t r = fGeomCam->GetMaxRadius();
+
+    MH::SetPadRange(-r, -r, r, r*1.1);
+
+    TAttLine line;
+    TAttFill fill;
+
+    // FIXME:
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeom &pix = (*fGeomCam)[i];
+
+        fill.SetFillColor(fColors[i]);
+        pix.PaintPrimitive(line, fill);
+    }
+
+    for (int i=0; i<6; i++)
+        fText[i]->Paint();
 }
 
@@ -327,9 +269,7 @@
     // if no canvas is yet existing to draw into, create a new one
     //
-    /*TCanvas *c =*/ new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800);
-    //c->ToggleEventStatus();
-
-    fDrawingPad = gPad;
-    fDrawingPad->SetBorderMode(0);
+    new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800);
+
+    gPad->SetBorderMode(0);
 
     //
@@ -343,13 +283,4 @@
     //
     Reset();
-    DrawHexagons();
-
-    /*
-     TPave *p = new TPave(-0.66*fRange, 0.895*fRange, 0.66*fRange, 0.995*fRange, 4, "br");
-     p->ConvertNDCtoPad();
-     p->SetFillColor(12);
-     p->SetBit(kCanDelete);
-     p->Draw();
-     */
 
     fDomino.SetTextAlign(23);   // centered/bottom
@@ -408,8 +339,8 @@
     if (fNumPixel>=0)
     {
-        const MGeomPix &pix=(*fGeomCam)[fNumPixel];
-        (*this)[fNumPixel].ResetBit(kIsTile);
+        MGeom &pix=(*fGeomCam)[fNumPixel];
+        pix.ResetBit(kIsTile);
         for (int i=0; i<pix.GetNumNeighbors(); i++)
-            (*this)[pix.GetNeighbor(i)].ResetBit(kIsTile);
+            (*fGeomCam)[pix.GetNeighbor(i)].ResetBit(kIsTile);
 
         fPoints += pix.GetNumNeighbors();
@@ -425,5 +356,5 @@
     Update();
 
-    fDrawingPad->Update();
+    gPad->Update();
 }
 
@@ -444,9 +375,9 @@
 
     Int_t cnt=0;
-    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    const MGeom &pix1=(*fGeomCam)[fNumPixel];
     for (int i=0; i<pix1.GetNumNeighbors(); i++)
     {
         const Int_t idx1 = pix1.GetNeighbor(i);
-        const MGeomPix &pix2 = (*fGeomCam)[idx1];
+        const MGeom &pix2 = (*fGeomCam)[idx1];
 
         Byte_t ignored = 0;
@@ -454,8 +385,8 @@
         for (int j=0; j<pix2.GetNumNeighbors(); j++)
         {
-            const Int_t    idx2 = pix2.GetNeighbor(j);
-            const MHexagon &hex = (*this)[idx2];
-
-            if (hex.TestBit(kIsTile) || hex.GetFillColor()==kBackground)
+            const Int_t idx2 = pix2.GetNeighbor(j);
+            const MGeom &hex = (*fGeomCam)[idx2];
+
+            if (hex.TestBit(kIsTile) || fColors[idx2]==kBackground)
             {
                 ignored++;
@@ -463,5 +394,5 @@
             }
 
-            if (hex.GetFillColor()==(*this)[idx1].GetFillColor())
+            if (fColors[idx2]==fColors[idx1])
                 found++;
         }
@@ -487,13 +418,12 @@
     fDomino.SetTextColor(kBlue);
 
-    fDrawingPad->SetFillColor(kRed);
+    gPad->SetFillColor(kRed);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     fDone->SetBit(kNoContextMenu|kCannotPick);
-    fDrawingPad->ResetBit(kNoContextMenu);
     ResetBit(kNoContextMenu);
 #endif
 
-    fDrawingPad->Modified();
-    fDrawingPad->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
@@ -572,6 +502,6 @@
     Update();
 
-    fDrawingPad->Modified();
-    fDrawingPad->Update();
+    gPad->Modified();
+    gPad->Update();
 }
 
@@ -585,17 +515,15 @@
         return;
 
-    MagicDomino &This = *this;
-
     RemoveNumbers();
 
-    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
-    This[fNumPixel].SetFillColor(fOldColors[6]);
-    This[fNumPixel].ResetBit(kIsTile);
+    MGeom &pix1=(*fGeomCam)[fNumPixel];
+    fColors[fNumPixel] = fOldColors[6];
+    pix1.ResetBit(kIsTile);
     for (int i=0; i<pix1.GetNumNeighbors(); i++)
     {
         Int_t idx = pix1.GetNeighbor(i);
 
-        This[idx].SetFillColor(fOldColors[i]);
-        This[idx].ResetBit(kIsTile);
+        fColors[idx] = fOldColors[i];
+        (*fGeomCam)[idx].ResetBit(kIsTile);
     }
 }
@@ -609,6 +537,4 @@
     if (fNumPixel<0)
         return;
-
-    MagicDomino &This = *this;
 
     Int_t indices[6];
@@ -617,13 +543,13 @@
     RemoveNumbers();
 
-    const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
-    fOldColors[6] = This[fNumPixel].GetFillColor();
-    This[fNumPixel].SetFillColor(kBlack);
-    This[fNumPixel].SetBit(kIsTile);
+    MGeom &pix2=(*fGeomCam)[fNumPixel];
+    fOldColors[6] = fColors[fNumPixel];
+    fColors[fNumPixel] = kBlack;
+    pix2.SetBit(kIsTile);
     for (int i=0; i<pix2.GetNumNeighbors(); i++)
     {
         Int_t idx = pix2.GetNeighbor(i);
 
-        fOldColors[i] = This[idx].GetFillColor();
+        fOldColors[i] = fColors[idx];
 
         int j=0;
@@ -631,15 +557,14 @@
             j++;
 
-        This[idx].SetFillColor(fNewColors[(j+fPosition)%6]);
-        This[idx].SetBit(kIsTile);
+        MGeom &pix = (*fGeomCam)[idx];
+
+        fColors[idx] = fNewColors[(j+fPosition)%6];
+        pix.SetBit(kIsTile);
 
         TString num;
         num += idx;
 
-        fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
-        fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
-        fText[i]->SetTextFont(122);
-        fText[i]->SetTextAlign(22);   // centered/centered
-        fText[i]->Draw();
+        fText[i]->SetText(pix.GetX(), pix.GetY(), num);
+        fText[i]->SetTextSize(0.3*pix.GetT()/fGeomCam->GetMaxRadius());
     }
 }
@@ -659,5 +584,5 @@
     Update();
 
-    fDrawingPad->Update();
+    gPad->Update();
 }
 
@@ -668,5 +593,5 @@
 Short_t MagicDomino::AnalysePixel(Int_t dir)
 {
-    const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
+    const MGeom &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
 
     Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
@@ -674,5 +599,5 @@
     for (int i=0; i<pix.GetNumNeighbors(); i++)
     {
-        MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
+        MGeom &next = (*fGeomCam)[pix.GetNeighbor(i)];
         fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
     }
@@ -714,5 +639,5 @@
 void MagicDomino::GetSortedNeighbors(Int_t indices[6])
 {
-    const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
+    const MGeom &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
 
     Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
@@ -720,5 +645,5 @@
     for (int i=0; i<pix.GetNumNeighbors(); i++)
     {
-        MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
+        MGeom &next = (*fGeomCam)[pix.GetNeighbor(i)];
         fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
     }
Index: trunk/MagicSoft/Mars/mtools/MagicDomino.h
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicDomino.h	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicDomino.h	(revision 9369)
@@ -11,4 +11,7 @@
 #ifndef ROOT_TClonesArray
 #include <TClonesArray.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
 #endif
 
@@ -59,11 +62,5 @@
     TText    *fDone;            // game over text
 
-    UInt_t    fW;               // Width of canvas
-    UInt_t    fH;               // Height of canvas
-
-    TClonesArray *fPixels;      // array of all hexagons
-    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
-
-    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+    TArrayI fColors;
 
     Bool_t  CheckTile();
@@ -77,5 +74,4 @@
     void    Done();
     void    RemoveNumbers();
-    void    DrawHexagons();
     void    SetNewCamera(MGeomCam *);
     void    ChangePixel(Int_t add);
Index: trunk/MagicSoft/Mars/mtools/MagicJam.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicJam.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicJam.cc	(revision 9369)
@@ -2,5 +2,5 @@
 !
 ! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * This file is part of CheObs, the Modular 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.
@@ -9,5 +9,5 @@
 ! * 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
+! * provided that the above copyright notice appears in all copies and
 ! * that both that copyright notice and this permission notice appear
 ! * in supporting documentation. It is provided "as is" without express
@@ -141,6 +141,9 @@
             Float_t x0 = TMath::Odd(y) ? x-0.25 : x+0.25;
 
-            cam[x + y*fWidth].Set(x0-dx, (y-dy)*0.866, 1);
-        }
+            cam.SetAt(x + y*fWidth, MGeomPix(x0-dx, (y-dy)*0.866, 1));
+        }
+
+
+    cam.InitGeometry();
 
     SetGeometry(cam);
@@ -442,8 +445,8 @@
 
         TVirtualPad *p = dynamic_cast<TVirtualPad*>(o);
-        if (p && p->GetPad(1))
-        {
-            p->GetPad(1)->Modified();
-            p->GetPad(1)->Update();
+        if (p)
+        {
+            p->Modified();
+            p->Update();
         }
     }
@@ -508,5 +511,5 @@
     const Int_t newval = fBinEntries[idx+1]+1;
 
-    const MGeomPix &gpix = (*fGeomCam)[idx];
+    const MGeom &gpix = (*fGeomCam)[idx];
     const Int_t n = gpix.GetNumNeighbors();
 
@@ -721,5 +724,5 @@
         dy += y;
 
-        cam[i].Set(dx, dy*0.866);
+        cam.SetAt(i, MGeomPix(dx, dy*0.866));
     }
 
Index: trunk/MagicSoft/Mars/mtools/MagicReversi.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicReversi.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicReversi.cc	(revision 9369)
@@ -2,5 +2,5 @@
 !
 ! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * This file is part of CheObs, the Modular 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.
@@ -9,5 +9,5 @@
 ! * 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
+! * provided that the above copyright notice appears in all copies and
 ! * that both that copyright notice and this permission notice appear
 ! * in supporting documentation. It is provided "as is" without express
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Thomas Bretz,  3/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: CheObs Software Development, 2000-2009
 !
 !
@@ -62,5 +62,5 @@
 #include <TInterpreter.h>
 
-#include "MHexagon.h"
+#include "MH.h"
 
 #include "MGeomPix.h"
@@ -88,5 +88,4 @@
         return;
 
-    fPixels->Delete();
     fText->Delete();
     fFlags->Delete();
@@ -94,5 +93,4 @@
     delete fText;
     delete fFlags;
-    delete fPixels;
 
     delete fGeomCam;
@@ -113,5 +111,4 @@
 
     Reset();
-    DrawHexagons();
 }
 
@@ -119,10 +116,4 @@
 {
     Free();
-
-    //
-    //  Reset the display geometry
-    //
-    fW=0;
-    fH=0;
 
     //
@@ -144,22 +135,17 @@
     fText   = new TClonesArray("TText",    fNumPixels);
     fFlags  = new TClonesArray("TMarker",  fNumPixels);
-    fPixels = new TClonesArray("MHexagon", fNumPixels);
+    fColors.Set(fNumPixels);
 
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        h.SetBit(kNoContextMenu|kCannotPick);
-#endif
+        const MGeom &pix = (*fGeomCam)[i];
 
         TText &t = *new ((*fText)[i]) TText;
         t.SetTextFont(122);
         t.SetTextAlign(22);   // centered/centered
-        t.SetTextSize(0.3*h.GetD()/fRange);
+        t.SetTextSize(0.3*pix.GetT()/fRange);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
         t.SetBit(kNoContextMenu|kCannotPick);
 #endif
-
-        const MGeomPix &pix = (*fGeomCam)[i];
 
         TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
@@ -170,4 +156,5 @@
 }
 
+/*
 // ------------------------------------------------------------------------
 //
@@ -180,4 +167,5 @@
         (*this)[i].Draw();
 }
+*/
 
 void MagicReversi::Init()
@@ -201,5 +189,5 @@
 //
 MagicReversi::MagicReversi()
-    : fGeomCam(NULL), fDone(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+    : fGeomCam(NULL), fDone(NULL)
 {
     SetNewCamera(new MGeomCamMagic);
@@ -209,5 +197,5 @@
 
 MagicReversi::MagicReversi(const MGeomCam &geom)
-    : fGeomCam(NULL), fDone(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+    : fGeomCam(NULL), fDone(NULL)
 {
     SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
@@ -229,10 +217,4 @@
     if (fDone)
         delete fDone;
-
-    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
-    {
-        fDrawingPad->RecursiveRemove(this);
-        delete fDrawingPad;
-    }
 }
 
@@ -245,48 +227,29 @@
 void MagicReversi::Paint(Option_t *opt)
 {
-    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
-    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
-
-    //
-    // Check for a change in width or height, and make sure, that the
-    // first call also sets the range
-    //
-    if (w*fH == h*fW && fW && fH)
-        return;
-
-    //
-    // Calculate aspect ratio (5/4=1.25 recommended)
-    //
-    const Double_t ratio = (Double_t)w/h;
-
-    Float_t x;
-    Float_t y;
-
-    if (ratio>1.0)
-    {
-        x = fRange*(ratio*2-1);
-        y = fRange;
-    }
-    else
-    {
-        x = fRange;
-        y = fRange/ratio;
-    }
-
-    fH = h;
-    fW = w;
-
-    //
-    // Set new range
-    //
-    fDrawingPad->Range(-fRange, -y, x, y);
-
-    //
-    // Adopt absolute sized of markers to relative range
-    //
+    const Float_t r = fGeomCam->GetMaxRadius();
+
+    MH::SetPadRange(-r, -r, r, r*1.1);
+
+    TAttLine line;
+    TAttFill fill;
+
+    // FIXME:
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
+        const MGeom &pix = (*fGeomCam)[i];
+
+        fill.SetFillColor(fColors[i]);
+        pix.PaintPrimitive(line, fill);
+
+        //
+        // Adopt absolute sized of markers to relative range
+        //
+        Float_t r = (*fGeomCam)[i].GetT()*gPad->XtoAbsPixel(1)/325;
         GetFlag(i)->SetMarkerSize(20.0*r/fRange);
+
+        if (pix.TestBit(kHasFlag))
+            GetFlag(i)->Paint();
+
+        GetText(i)->Paint();
     }
 }
@@ -301,24 +264,11 @@
 void MagicReversi::Draw(Option_t *option)
 {
-    // root 3.02:
-    // gPad->SetFixedAspectRatio()
-
-    if (fDrawingPad)
-        return;
-
     //
     // if no canvas is yet existing to draw into, create a new one
     //
     if (!gPad)
-    {
-        /*TCanvas *c =*/ new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800);
-        //c->ToggleEventStatus();
-        fIsAllocated = kTRUE;
-    }
-    else
-        fIsAllocated = kFALSE;
-
-    fDrawingPad = gPad;
-    fDrawingPad->SetBorderMode(0);
+        new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800);
+
+    gPad->SetBorderMode(0);
 
     //
@@ -347,5 +297,4 @@
     //
     Reset();
-    DrawHexagons();
 }
 
@@ -411,11 +360,9 @@
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        Remove(GetText(i));
-        Remove(GetFlag(i));
-
-        (*this)[i].SetFillColor(kEmpty);
+        fColors[i] = kEmpty;
         (*fGeomCam)[i].ResetBit(kUserBits);
 
         GetFlag(i)->SetMarkerColor(kBlack);
+        GetText(i)->SetText(0, 0, "");
     }
 
@@ -427,5 +374,5 @@
     for (int i=1; i<5*fNumUsers; i++)
     {
-        (*this)[i-1].SetFillColor(i%fNumUsers+kRed);
+        fColors[i-1] = i%fNumUsers+kRed;
         fUsrPts[i%fNumUsers]++;
     }
@@ -433,8 +380,7 @@
     Update();
 
-    fDrawingPad->SetFillColor(22);
+    gPad->SetFillColor(22);
 
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-    fDrawingPad->SetBit(kNoContextMenu);
     SetBit(kNoContextMenu);
 #endif
@@ -468,15 +414,9 @@
     fDone->Draw();
 
-    fDrawingPad->SetFillColor(winner+kRed);
+    gPad->SetFillColor(winner+kRed);
 
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-    fDrawingPad->ResetBit(kNoContextMenu);
     ResetBit(kNoContextMenu);
 #endif
-}
-
-void MagicReversi::Remove(TObject *obj)
-{
-    fDrawingPad->RecursiveRemove(obj);
 }
 
@@ -495,8 +435,8 @@
         {
             idx = fGeomCam->GetNeighbor(idx, dir);
-            if (idx<0 || (*this)[idx].GetFillColor()==kEmpty)
+            if (idx<0 || fColors[idx]==kEmpty)
                 break;
 
-            if ((*this)[idx].GetFillColor()==col)
+            if (fColors[idx]==col)
             {
                 if (length!=0)
@@ -523,8 +463,8 @@
                 idx = fGeomCam->GetNeighbor(idx, dir);
 
-                fUsrPts[(*this)[idx].GetFillColor()-kRed]--;
+                fUsrPts[fColors[idx]-kRed]--;
                 fUsrPts[fNumUser]++;
 
-                (*this)[idx].SetFillColor(col);
+                fColors[idx] = col;
             }
     }
@@ -536,5 +476,5 @@
 {
     for (unsigned int i=0; i<fNumPixels; i++)
-        if ((*this)[i].GetFillColor()==kEmpty && Flip(i, kFALSE))
+        if (fColors[i]==kEmpty && Flip(i, kFALSE))
             return kTRUE;
     return kFALSE;
@@ -557,6 +497,6 @@
     {
         Done();
-        fDrawingPad->Modified();
-        fDrawingPad->Update();
+        gPad->Modified();
+        gPad->Update();
         return;
     }
@@ -564,5 +504,5 @@
     UInt_t idx;
     for (idx=0; idx<fNumPixels; idx++)
-        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+        if ((*fGeomCam)[idx].DistancetoPrimitive(px, py)<=0)
             break;
 
@@ -570,5 +510,5 @@
         return;
 
-    if (event==kButton1Down && (*this)[idx].GetFillColor()==kEmpty)
+    if (event==kButton1Down && fColors[idx]==kEmpty)
     {
         if (!Flip(idx, kTRUE))
@@ -577,5 +517,5 @@
         fUsrPts[fNumUser]++;
 
-        (*this)[idx].SetFillColor(kRed+fNumUser);
+        fColors[idx] = kRed+fNumUser;
 
         Int_t start = fNumUser;
@@ -600,4 +540,4 @@
     }
 
-    fDrawingPad->Modified();
-}
+    gPad->Modified();
+}
Index: trunk/MagicSoft/Mars/mtools/MagicReversi.h
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicReversi.h	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicReversi.h	(revision 9369)
@@ -7,4 +7,7 @@
 #ifndef ROOT_TClonesArray
 #include <TClonesArray.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
 #endif
 
@@ -24,15 +27,11 @@
     Float_t        fRange;         // the range in millimeters of the present geometry
 
-    TClonesArray  *fPixels;        // array of all hexagons
     TClonesArray  *fText;          // array of all texts
     TClonesArray  *fFlags;         // array of all texts
 
+    TArrayI fColors;
+
     TText         *fDone;          // TText showing the 'Game over'
     TText         *fUsrTxt[6];     // TText showing the numbers of pixels and bombs
-
-    UInt_t         fW;             // Width of canvas
-    UInt_t         fH;             // Height of canvas
-    TVirtualPad   *fDrawingPad;    // pad in which we are drawing
-    Bool_t         fIsAllocated;
 
     Int_t          fNumUsers;
@@ -49,14 +48,10 @@
     };
 
-    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
-
     TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
     TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
 
-    void  Remove(TObject *);
     void  Done();
     void  Update();
     void  SetNewCamera(MGeomCam *);
-    void  DrawHexagons();
     void  Free();
     void  Init();
Index: trunk/MagicSoft/Mars/mtools/MagicShow.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicShow.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicShow.cc	(revision 9369)
@@ -64,5 +64,5 @@
 #include <TInterpreter.h>
 
-#include "MHexagon.h"
+#include "MH.h"
 
 #include "MGeomPix.h"
@@ -83,25 +83,5 @@
         return;
 
-    fPixels->Delete();
-
-    delete fPixels;
-
     delete fGeomCam;
-}
-
-// ------------------------------------------------------------------------
-//
-// Draw all pixels of the camera
-//  (means apend all pixelobjects to the current pad)
-//
-void MagicShow::DrawHexagons()
-{
-    for (UInt_t i=0; i<fNumPixels; i++)
-    {
-        MHexagon &h = (*this)[i];
-
-        h.SetFillColor(kBackground);
-        h.Draw();
-    }
 }
 
@@ -123,5 +103,11 @@
     ct1 = !ct1;
 
-    DrawHexagons();
+    Update();
+
+    fColors.Reset();
+
+    // FIXME: Reset all texts
+
+    AppendPad();
 }
 
@@ -133,10 +119,4 @@
 {
     Free();
-
-    //
-    //  Reset the display geometry
-    //
-    fW=0;
-    fH=0;
 
     //
@@ -151,24 +131,19 @@
     fRange     = fGeomCam->GetMaxRadius();
 
-    fNumPixel  = fNumPixels-1;
-
-    //
-    // Construct all hexagons. Use new-operator with placement
-    //
-    fPixels = new TClonesArray("MHexagon", fNumPixels);
-
-    for (UInt_t i=0; i<fNumPixels; i++)
-    {
-        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        h.SetBit(kNoContextMenu|kCannotPick);
-#endif
-    }
+    fNumPixel  = 0;//fNumPixels-1;
+
+    fColors.Set(fNumPixels);
+
+    for (int i=0; i<6; i++)
+    {
+        fText[i] = new TText(0, 0, "");
+        fText[i]->SetTextFont(122);
+        fText[i]->SetTextAlign(22);   // centered/centered
+    }
+
 }
 
 void MagicShow::Init()
 {
-    memset(fText, 0, sizeof(fText));
-
     //
     // Make sure, that the object is destroyed when the canvas/pad is
@@ -189,5 +164,5 @@
 //
 MagicShow::MagicShow()
-    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE), fW(0), fH(0)
+    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE)
 {
     SetNewCamera(new MGeomCamMagic);
@@ -200,5 +175,5 @@
 //
 MagicShow::MagicShow(const MGeomCam &geom)
-    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE), fW(0), fH(0)
+    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE)
 {
     SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
@@ -215,12 +190,5 @@
 
     for (int i=0; i<6; i++)
-        if (fText[i])
-            delete fText[i];
-
-    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
-    {
-        fDrawingPad->RecursiveRemove(this);
-        delete fDrawingPad;
-    }
+        delete fText[i];
 }
 
@@ -233,40 +201,22 @@
 void MagicShow::Paint(Option_t *opt)
 {
-    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
-    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
-
-    //
-    // Check for a change in width or height, and make sure, that the
-    // first call also sets the range
-    //
-    if (w*fH == h*fW && fW && fH)
-        return;
-
-    //
-    // Calculate aspect ratio (5/4=1.25 recommended)
-    //
-    const Double_t ratio = (Double_t)w/h;
-
-    Float_t x;
-    Float_t y;
-
-    if (ratio>1.0)
-    {
-        x = fRange*(ratio*2-1);
-        y = fRange;
-    }
-    else
-    {
-        x = fRange;
-        y = fRange/ratio;
-    }
-
-    fH = h;
-    fW = w;
-
-    //
-    // Set new range
-    //
-    fDrawingPad->Range(-fRange, -y, x, y);
+    const Float_t r = fGeomCam->GetMaxRadius();
+
+    MH::SetPadRange(-r, -r, r, r*1.1);
+
+    TAttLine line;
+    TAttFill fill;
+
+    // FIXME:
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeom &pix = (*fGeomCam)[i];
+
+        fill.SetFillColor(fColors[i]);
+        pix.PaintPrimitive(line, fill);
+    }
+
+    for (int i=0; i<6; i++)
+        fText[i]->Paint();
 }
 
@@ -283,10 +233,8 @@
     // if no canvas is yet existing to draw into, create a new one
     //
-    /*TCanvas *c =*/ new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800);
-    //c->ToggleEventStatus();
-
-    fDrawingPad = gPad;
-    fDrawingPad->SetBorderMode(0);
-    fDrawingPad->SetFillColor(22);
+    new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800);
+
+    gPad->SetBorderMode(0);
+    gPad->SetFillColor(22);
 
     //
@@ -295,9 +243,4 @@
     //
     AppendPad(option);
-
-    //
-    // Reset the game pad
-    //
-    DrawHexagons();
 
     fShow.SetTextAlign(23);   // centered/bottom
@@ -339,5 +282,5 @@
         fAuto = !fAuto;
         Update();
-        fDrawingPad->Update();
+        gPad->Update();
         return;
 
@@ -382,16 +325,14 @@
 void MagicShow::ChangePixel(Int_t add)
 {
-    MagicShow &This = *this;
-
-    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
-    This[fNumPixel].SetFillColor(kBackground);
+    const MGeom &pix1=(*fGeomCam)[fNumPixel];
+
+    fColors[fNumPixel] = kBackground;
     for (int i=0; i<pix1.GetNumNeighbors(); i++)
     {
-        This[pix1.GetNeighbor(i)].SetFillColor(kBackground);
-        if (!fText[i])
+        fColors[pix1.GetNeighbor(i)] = kBackground;
+        if (TString(fText[i]->GetTitle()).IsNull())
             continue;
 
-        delete fText[i];
-        fText[i] = NULL;
+        fText[i]->SetText(0, 0, "");
     }
 
@@ -403,25 +344,26 @@
         fNumPixel = fNumPixels-1;
 
-    const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
-    This[fNumPixel].SetFillColor(kBlue);
+    const MGeom &pix2=(*fGeomCam)[fNumPixel];
+
+    fColors[fNumPixel] = kBlue;
+
     for (int i=0; i<pix2.GetNumNeighbors(); i++)
     {
         Int_t idx = pix2.GetNeighbor(i);
 
-        This[idx].SetFillColor(kMagenta);
+        fColors[idx] = kMagenta;
 
         TString num;
         num += idx;
 
-        fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
-        fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
-        fText[i]->SetTextFont(122);
-        fText[i]->SetTextAlign(22);   // centered/centered
-        fText[i]->Draw();
+        const MGeom &pix=(*fGeomCam)[idx];
+
+        fText[i]->SetText(pix.GetX(), pix.GetY(), num);
+        fText[i]->SetTextSize(0.3*pix.GetT()/fGeomCam->GetMaxRadius());
     }
 
     Update();
 
-    fDrawingPad->Update();
+    gPad->Update();
 }
 
Index: trunk/MagicSoft/Mars/mtools/MagicShow.h
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicShow.h	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicShow.h	(revision 9369)
@@ -14,4 +14,7 @@
 #ifndef ROOT_TClonesArray
 #include <TClonesArray.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
 #endif
 
@@ -45,15 +48,8 @@
     TText    *fText[6];         // ttext showing the pixel numbers of the neighbors
 
-    UInt_t    fW;               // Width of canvas
-    UInt_t    fH;               // Height of canvas
-
-    TClonesArray *fPixels;      // array of all hexagons
-    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
-
-    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+    TArrayI fColors;
 
     void   Update();
     void   Free();
-    void   DrawHexagons();
     void   SetNewCamera(MGeomCam *);
     void   ChangePixel(Int_t add);
Index: trunk/MagicSoft/Mars/mtools/MagicSnake.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicSnake.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicSnake.cc	(revision 9369)
@@ -2,5 +2,5 @@
 !
 ! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * This file is part of CheObs, the Modular 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.
@@ -9,5 +9,5 @@
 ! * 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
+! * provided that the above copyright notice appears in all copies and
 ! * that both that copyright notice and this permission notice appear
 ! * in supporting documentation. It is provided "as is" without express
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Thomas Bretz,  7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: CheObs Software Development, 2000-2009
 !
 !
@@ -63,5 +63,5 @@
 #include <TInterpreter.h>
 
-#include "MHexagon.h"
+#include "MH.h"
 
 #include "MGeomPix.h"
@@ -78,22 +78,7 @@
         return;
 
-    fPixels->Delete();
-
-    delete fPixels;
-
     delete fGeomCam;
 
     delete fArray;
-}
-
-// ------------------------------------------------------------------------
-//
-// Draw all pixels of the camera
-//  (means apend all pixelobjects to the current pad)
-//
-void MagicSnake::DrawHexagons()
-{
-    for (UInt_t i=0; i<fNumPixels; i++)
-        (*this)[i].Draw();
 }
 
@@ -115,5 +100,5 @@
 
     Reset();
-    DrawHexagons();
+    AppendPad();
 }
 
@@ -121,10 +106,4 @@
 {
     Free();
-
-    //
-    //  Reset the display geometry
-    //
-    fW=0;
-    fH=0;
 
     //
@@ -139,16 +118,5 @@
     fRange     = fGeomCam->GetMaxRadius();
 
-    //
-    // Construct all hexagons. Use new-operator with placement
-    //
-    fPixels = new TClonesArray("MHexagon", fNumPixels);
-
-    for (UInt_t i=0; i<fNumPixels; i++)
-    {
-        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        h.SetBit(kNoContextMenu|kCannotPick);
-#endif
-    }
+    fColors.Set(fNumPixels);
 }
 
@@ -175,5 +143,5 @@
 //
 MagicSnake::MagicSnake()
-    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL), fW(0), fH(0)
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL)
 {
     SetNewCamera(new MGeomCamMagic);
@@ -186,5 +154,5 @@
 //
 MagicSnake::MagicSnake(const MGeomCam &geom)
-    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL), fW(0), fH(0)
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL)
 {
     SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
@@ -203,8 +171,7 @@
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
         fPaused->SetBit(kNoContextMenu|kCannotPick);
-        fDrawingPad->ResetBit(kNoContextMenu);
         ResetBit(kNoContextMenu);
 #endif
-        fDrawingPad->Update();
+        //fDrawingPad->Update();
     }
 
@@ -215,5 +182,5 @@
     {
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        fDrawingPad->SetBit(kNoContextMenu);
+        //fDrawingPad->SetBit(kNoContextMenu);
         SetBit(kNoContextMenu);
 #endif
@@ -222,7 +189,5 @@
         return;
 
-    Remove(fPaused);
-
-    fDrawingPad->Update();
+    //fDrawingPad->Update();
 
     delete fPaused;
@@ -241,10 +206,10 @@
     if (fDone)
         delete fDone;
-
+/*
     if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
     {
         fDrawingPad->RecursiveRemove(this);
         delete fDrawingPad;
-    }
+    }*/
 }
 
@@ -257,40 +222,18 @@
 void MagicSnake::Paint(Option_t *opt)
 {
-    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
-    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
-
-    //
-    // Check for a change in width or height, and make sure, that the
-    // first call also sets the range
-    //
-    if (w*fH == h*fW && fW && fH)
-        return;
-
-    //
-    // Calculate aspect ratio (5/4=1.25 recommended)
-    //
-    const Double_t ratio = (Double_t)w/h;
-
-    Float_t x;
-    Float_t y;
-
-    if (ratio>1.0)
-    {
-        x = fRange*(ratio*2-1);
-        y = fRange;
-    }
-    else
-    {
-        x = fRange;
-        y = fRange/ratio;
-    }
-
-    fH = h;
-    fW = w;
-
-    //
-    // Set new range
-    //
-    fDrawingPad->Range(-fRange, -y, x, y);
+    const Float_t r = fGeomCam->GetMaxRadius();
+
+    MH::SetPadRange(-r, -r, r, r*1.1);
+
+    TAttLine line;
+    TAttFill fill;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeom &pix = (*fGeomCam)[i];
+
+        fill.SetFillColor(fColors[i]);
+        pix.PaintPrimitive(line, fill);
+    }
 }
 
@@ -307,9 +250,8 @@
     // if no canvas is yet existing to draw into, create a new one
     //
-    /*TCanvas *c =*/ new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800);
-    //c->ToggleEventStatus();
-
-    fDrawingPad = gPad;
-    fDrawingPad->SetBorderMode(0);
+    new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800);
+
+    //fDrawingPad = gPad;
+    gPad->SetBorderMode(0);
 
     //
@@ -323,5 +265,4 @@
     //
     Reset();
-    DrawHexagons();
 
     fShow.SetTextAlign(23);   // centered/bottom
@@ -355,5 +296,5 @@
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        (*this)[i].SetFillColor(kBackground);
+        fColors[i] = kBackground;
         (*fGeomCam)[i].ResetBit(kUserBits);
     }
@@ -372,8 +313,11 @@
 
         (*fGeomCam)[idx].SetBit(kHasBomb);
-        (*this)[idx].SetFillColor(kRed);
+        fColors[idx] = kRed;
     }
 
     fNumFood = fNumPixels/6;
+    // FIXME. gROOT->GetColor doesn't allow more than 100 colors!
+    if (fNumFood>46)
+        fNumFood=46;
 
     fArray = new Int_t[fNumFood+3];
@@ -395,5 +339,5 @@
 
         (*fGeomCam)[idx].SetBit(kHasFood);
-        (*this)[idx].SetFillColor(kGreen);
+        fColors[idx] = kGreen;
     }
 
@@ -409,11 +353,11 @@
         fTransport[i] = idx;
         (*fGeomCam)[idx].SetBit(kHasTransport);
-        (*this)[idx].SetFillColor(kYellow);
-    }
-
-    fDrawingPad->SetFillColor(22);
+        fColors[idx] = kYellow;
+    }
+
+    gPad->SetFillColor(22);
 
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-    fDrawingPad->SetBit(kNoContextMenu);
+    //fDrawingPad->SetBit(kNoContextMenu);
     SetBit(kNoContextMenu);
 #endif
@@ -435,15 +379,9 @@
     fDone->SetTextSize(0.05); // white
     fDone->Draw();
-    fDrawingPad->SetFillColor(col);
+    gPad->SetFillColor(col);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     fDone->SetBit(kNoContextMenu|kCannotPick);
-    fDrawingPad->ResetBit(kNoContextMenu);
     ResetBit(kNoContextMenu);
 #endif
-}
-
-void MagicSnake::Remove(TObject *obj)
-{
-    fDrawingPad->RecursiveRemove(obj);
 }
 
@@ -500,5 +438,5 @@
     if ((*fGeomCam)[newpix].TestBit(kHasTransport))
     {
-        (*this)[fArray[0]].SetFillColor(kBackground);
+        fColors[fArray[0]] = kBackground;
         (*fGeomCam)[fArray[0]].ResetBit(kHasWorm);
 
@@ -513,11 +451,13 @@
     if (!(*fGeomCam)[newpix].TestBit(kHasFood))
     {
-        MGeomPix &pix = (*fGeomCam)[fArray[0]];
+        MGeom &pix = (*fGeomCam)[fArray[0]];
 
         if (!pix.TestBit(kHasTransport))
+        {
             if (pix.TestBit(kHasDoor))
-                (*this)[fArray[0]].SetFillColor(kMagenta);
+                fColors[fArray[0]] = kMagenta;
             else
-                (*this)[fArray[0]].SetFillColor(kBackground);
+                fColors[fArray[0]] = kBackground;
+        }
 
         pix.ResetBit(kHasWorm);
@@ -538,5 +478,5 @@
             for (int i=1; i<7; i++)
             {
-                (*this)[i].SetFillColor(kMagenta);
+                fColors[i] = kMagenta;
                 (*fGeomCam)[i].SetBit(kHasDoor);
             }
@@ -552,5 +492,5 @@
         const Int_t idx = fArray[i];
 
-        MGeomPix &pix = (*fGeomCam)[idx];
+        MGeom &pix = (*fGeomCam)[idx];
 
         if (pix.TestBit(kHasTransport))
@@ -559,6 +499,5 @@
         pix.SetBit(kHasWorm);
 
-        Int_t color = 51+fLength-i;
-        (*this)[idx].SetFillColor(color);
+        fColors[idx] = 51+fLength-i;
     }
 }
@@ -568,5 +507,5 @@
     const Int_t first = fArray[fLength-1];
 
-    const MGeomPix &pix=(*fGeomCam)[first];
+    const MGeom &pix=(*fGeomCam)[first];
 
     Double_t dx = pix.GetX();
@@ -577,5 +516,5 @@
     {
         const Int_t     idx  = pix.GetNeighbor(i);
-        const MGeomPix &next = (*fGeomCam)[idx];
+        const MGeom &next = (*fGeomCam)[idx];
 
         const Double_t x = next.GetX();
@@ -596,5 +535,5 @@
         return -1;
 
-    const MGeomPix &np = (*fGeomCam)[newpix];
+    const MGeom &np = (*fGeomCam)[newpix];
 
     if (fNumFood==0 && np.TestBit(kHasDoor))
@@ -611,5 +550,5 @@
 
 Bool_t MagicSnake::HandleTimer(TTimer *timer)
-{
+{     
     if (fDone || fPaused)
         return kTRUE;
@@ -637,10 +576,6 @@
     Update();
 
-    //cout << "Update " << flush;
-
-    fDrawingPad->Modified();
-    fDrawingPad->Update();
-
-    //cout << "Done." << endl;
+    gPad->Modified();
+    gPad->Update();
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mtools/MagicSnake.h
===================================================================
--- trunk/MagicSoft/Mars/mtools/MagicSnake.h	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MagicSnake.h	(revision 9369)
@@ -14,4 +14,7 @@
 #ifndef ROOT_TClonesArray
 #include <TClonesArray.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
 #endif
 
@@ -60,17 +63,12 @@
     Float_t   fRange;           // the range in millimeters of the present geometry
 
+    TArrayI fColors;
+
     TText    *fDone;            // TText showing the 'Game over'
     TText    *fPaused;          // TText showing the 'Game over'
     TText     fShow;            // TText showing the numbers of pixels and bombs
 
-    UInt_t    fW;               // Width of canvas
-    UInt_t    fH;               // Height of canvas
-
-    TClonesArray  *fPixels;     // array of all hexagons
     TVirtualPad   *fDrawingPad; // pad in which we are drawing
 
-    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
-
-    void   Remove(TObject *);
     void   Done(TString, Int_t col);
     void   Step(Int_t newpix);
Index: trunk/MagicSoft/Mars/mtools/MineSweeper.cc
===================================================================
--- trunk/MagicSoft/Mars/mtools/MineSweeper.cc	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MineSweeper.cc	(revision 9369)
@@ -2,5 +2,5 @@
 !
 ! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * This file is part of CheObs, the Modular 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.
@@ -9,5 +9,5 @@
 ! * 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
+! * provided that the above copyright notice appears in all copies and
 ! * that both that copyright notice and this permission notice appear
 ! * in supporting documentation. It is provided "as is" without express
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Author(s): Thomas Bretz,  7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: CheObs Software Development, 2000-2009
 !
 !
@@ -57,5 +57,5 @@
 #include <TInterpreter.h>
 
-#include "MHexagon.h"
+#include "MH.h"
 
 #include "MGeomPix.h"
@@ -82,5 +82,4 @@
         return;
 
-    fPixels->Delete();
     fText->Delete();
     fFlags->Delete();
@@ -88,5 +87,4 @@
     delete fText;
     delete fFlags;
-    delete fPixels;
 
     delete fGeomCam;
@@ -107,5 +105,5 @@
 
     Reset();
-    DrawHexagons();
+    AppendPad();
 }
 
@@ -113,10 +111,4 @@
 {
     Free();
-
-    //
-    //  Reset the display geometry
-    //
-    fW=0;
-    fH=0;
 
     //
@@ -138,23 +130,19 @@
     fText   = new TClonesArray("TText",    fNumPixels);
     fFlags  = new TClonesArray("TMarker",  fNumPixels);
-    fPixels = new TClonesArray("MHexagon", fNumPixels);
+    fColors.Set(fNumPixels);
+    //fPixels = new TClonesArray("MHexagon", fNumPixels);
 
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-        h.SetBit(kNoContextMenu|kCannotPick);
-#endif
+        const MGeom &pix = (*fGeomCam)[i];
 
         TText &t = *new ((*fText)[i]) TText;
         t.SetTextFont(122);
         t.SetTextAlign(22);   // centered/centered
-        t.SetTextSize(0.3*h.GetD()/fRange);
+        t.SetTextSize(0.3*pix.GetT()/fRange);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
         t.SetBit(kNoContextMenu|kCannotPick);
 #endif
 
-        const MGeomPix &pix = (*fGeomCam)[i];
-
         TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
@@ -162,15 +150,4 @@
 #endif
     }
-}
-
-// ------------------------------------------------------------------------
-//
-// Draw all pixels of the camera
-//  (means apend all pixelobjects to the current pad)
-//
-void MineSweeper::DrawHexagons()
-{
-    for (UInt_t i=0; i<fNumPixels; i++)
-        (*this)[i].Draw();
 }
 
@@ -193,5 +170,5 @@
 //
 MineSweeper::MineSweeper()
-    : fGeomCam(NULL), fDone(NULL), fShow(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+    : fGeomCam(NULL), fDone(NULL), fShow(NULL)
 {
     SetNewCamera(new MGeomCamMagic);
@@ -200,5 +177,5 @@
 
 MineSweeper::MineSweeper(const MGeomCam &geom)
-    : fGeomCam(NULL), fDone(NULL), fShow(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+    : fGeomCam(NULL), fDone(NULL), fShow(NULL)
 {
     SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
@@ -218,10 +195,4 @@
     if (fDone)
         delete fDone;
-
-    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
-    {
-        fDrawingPad->RecursiveRemove(this);
-        delete fDrawingPad;
-    }
 }
 
@@ -234,48 +205,29 @@
 void MineSweeper::Paint(Option_t *opt)
 {
-    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
-    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
-
-    //
-    // Check for a change in width or height, and make sure, that the
-    // first call also sets the range
-    //
-    if (w*fH == h*fW && fW && fH)
-        return;
-
-    //
-    // Calculate aspect ratio (5/4=1.25 recommended)
-    //
-    const Double_t ratio = (Double_t)w/h;
-
-    Float_t x;
-    Float_t y;
-
-    if (ratio>1.0)
-    {
-        x = fRange*(ratio*2-1);
-        y = fRange;
-    }
-    else
-    {
-        x = fRange;
-        y = fRange/ratio;
-    }
-
-    fH = h;
-    fW = w;
-
-    //
-    // Set new range
-    //
-    fDrawingPad->Range(-fRange, -y, x, y);
-
-    //
-    // Adopt absolute sized of markers to relative range
-    //
+    const Float_t r = fGeomCam->GetMaxRadius();
+
+    MH::SetPadRange(-r, -r, r, r*1.1);
+
+    TAttLine line;
+    TAttFill fill;
+
+    // FIXME:
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
+        const MGeom &pix = (*fGeomCam)[i];
+
+        fill.SetFillColor(fColors[i]);
+        pix.PaintPrimitive(line, fill);
+
+        //
+        // Adopt absolute sized of markers to relative range
+        //
+        Float_t r = (*fGeomCam)[i].GetT()*gPad->XtoAbsPixel(1)/325;
         GetFlag(i)->SetMarkerSize(20.0*r/fRange);
+
+        if (pix.TestBit(kHasFlag))
+            GetFlag(i)->Paint();
+
+        GetText(i)->Paint();
     }
 }
@@ -293,21 +245,11 @@
     // gPad->SetFixedAspectRatio()
 
-    if (fDrawingPad)
-        return;
-
     //
     // if no canvas is yet existing to draw into, create a new one
     //
     if (!gPad)
-    {
-        /*TCanvas *c =*/ new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800);
-        //c->ToggleEventStatus();
-        fIsAllocated = kTRUE;
-    }
-    else
-        fIsAllocated = kFALSE;
-
-    fDrawingPad = gPad;
-    fDrawingPad->SetBorderMode(0);
+        new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800);
+
+    gPad->SetBorderMode(0);
 
     //
@@ -330,5 +272,4 @@
     //
     Reset();
-    DrawHexagons();
 }
 
@@ -357,11 +298,9 @@
     for (UInt_t i=0; i<fNumPixels; i++)
     {
-        Remove(GetText(i));
-        Remove(GetFlag(i));
-
-        (*this)[i].SetFillColor(kHidden);
+        fColors[i] = kHidden;
         (*fGeomCam)[i].ResetBit(kUserBits);
 
         GetFlag(i)->SetMarkerColor(kBlack);
+        GetText(i)->SetText(0, 0, "");
     }
     Update(fNumBombs);
@@ -378,8 +317,8 @@
     }
 
-    fDrawingPad->SetFillColor(22);
-
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-    fDrawingPad->SetBit(kNoContextMenu);
+    gPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    gPad->SetBit(kNoContextMenu);
     SetBit(kNoContextMenu);
 #endif
@@ -391,5 +330,5 @@
         if ((*fGeomCam)[j].TestBit(kHasBomb))
         {
-            (*this)[j].SetFillColor(kBlack);
+            fColors[j] = kBlack;
             GetFlag(j)->SetMarkerColor(kWhite);
         }
@@ -404,8 +343,8 @@
     fDone->Draw();
 
-    fDrawingPad->SetFillColor(col);
-
-#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
-    fDrawingPad->ResetBit(kNoContextMenu);
+    gPad->SetFillColor(col);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    gPad->ResetBit(kNoContextMenu);
     ResetBit(kNoContextMenu);
 #endif
@@ -419,11 +358,8 @@
 void MineSweeper::OpenHexagon(Int_t idx)
 {
-    MGeomPix &pix=(*fGeomCam)[idx];
+    MGeom &pix=(*fGeomCam)[idx];
 
     if (pix.TestBit(kIsVisible))
         return;
-
-    if (pix.TestBit(kHasFlag))
-        Remove(GetFlag(idx));
 
     pix.SetBit(kIsVisible);
@@ -435,23 +371,18 @@
             cnt++;
 
-    (*this)[idx].SetFillColor(fColorBombs[cnt]);
-
+    fColors[idx] = fColorBombs[cnt];
+
+    TString str;
     if (cnt)
-    {
-        TText *txt = GetText(idx);
-        TString str;
         str += cnt;
-        txt->SetText(pix.GetX(), pix.GetY(), str);
-        txt->Draw();
-        return;
-    }
+
+    TText *txt = GetText(idx);
+    txt->SetText(pix.GetX(), pix.GetY(), str);
+
+    if (cnt)
+        return;
 
     for (int j=0; j<pix.GetNumNeighbors(); j++)
         OpenHexagon(pix.GetNeighbor(j));
-}
-
-void MineSweeper::Remove(TObject *obj)
-{
-    fDrawingPad->RecursiveRemove(obj);
 }
 
@@ -479,5 +410,5 @@
     UInt_t idx;
     for (idx=0; idx<fNumPixels; idx++)
-        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+        if ((*fGeomCam)[idx].DistancetoPrimitive(px, py)<=0)
             break;
 
@@ -485,5 +416,5 @@
         return;
 
-    MGeomPix &pix=(*fGeomCam)[idx];
+    MGeom &pix=(*fGeomCam)[idx];
 
     if (event==kButton1Double)
@@ -496,12 +427,5 @@
 
     if (event==kButton1Down && !pix.TestBit(kIsVisible))
-    {
-        if (pix.TestBit(kHasFlag))
-            Remove(GetFlag(idx));
-        else
-            GetFlag(idx)->Draw();
-
         pix.InvertBit(kHasFlag);
-    }
 
     UInt_t vis=fNumBombs;
@@ -520,5 +444,5 @@
         Done("Great! Congratulations, you did it!", kGreen);
 
-    fDrawingPad->Modified();
+    gPad->Modified();
 
     /*
Index: trunk/MagicSoft/Mars/mtools/MineSweeper.h
===================================================================
--- trunk/MagicSoft/Mars/mtools/MineSweeper.h	(revision 9312)
+++ trunk/MagicSoft/Mars/mtools/MineSweeper.h	(revision 9369)
@@ -8,4 +8,7 @@
 #include <TClonesArray.h>
 #endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
 
 class TText;
@@ -13,4 +16,5 @@
 class TVirtualPad;
 
+class MGeom;
 class MGeomCam;
 class MHexagon;
@@ -27,15 +31,11 @@
     Float_t        fRange;         // the range in millimeters of the present geometry
 
-    TClonesArray  *fPixels;        // array of all hexagons
     TClonesArray  *fText;          // array of all texts
     TClonesArray  *fFlags;         // array of all texts
 
+    TArrayI fColors;
+
     TText         *fDone;          // TText showing the 'Game over'
     TText         *fShow;          // TText showing the numbers of pixels and bombs
-
-    UInt_t         fW;             // Width of canvas
-    UInt_t         fH;             // Height of canvas
-    TVirtualPad   *fDrawingPad;    // pad in which we are drawing
-    Bool_t         fIsAllocated;
 
     enum
@@ -48,15 +48,12 @@
     };
 
-    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
-
     TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
     TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
 
-    void  Remove(TObject *);
     void  OpenHexagon(Int_t idx);
     void  Done(TString, Int_t);
     void  Update(Int_t);
     void  SetNewCamera(MGeomCam *);
-    void  DrawHexagons();
+    void  PaintPrimitives();
     void  Free();
     void  Init();
