Index: /trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 1425)
+++ /trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 1426)
@@ -22,5 +22,4 @@
 
 #pragma link C++ class MHadroness+;
-#pragma link C++ class MHadronessRuleCalc+;
 
 #pragma link C++ class MCompProbCalc+;
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1425)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1426)
@@ -126,6 +126,10 @@
     // delete fGeomCam;
 
-    //    if (fIsAllocated)
-    //        delete fDrawingPad;
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this &&
+        fIsAllocated)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
 }
 
Index: /trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1425)
+++ /trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1426)
@@ -57,7 +57,4 @@
     ~MCamDisplay();
 
-    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
-    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
-
     void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; }
     void DrawPhotNum(const MCerPhotEvt *event);
@@ -65,7 +62,9 @@
     void DrawPixelNumbers();
 
-    virtual void Reset();
-    virtual void Draw(Option_t *option="");
-    virtual void SavePrimitive(ofstream &out, Option_t *);
+    virtual void  Reset();
+    virtual void  Draw(Option_t *option="");
+    virtual void  SavePrimitive(ofstream &out, Option_t *);
+    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
+    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
 
     void SetPalette(Int_t ncolors, Int_t *colors);
Index: /trunk/MagicSoft/Mars/mgui/MHexagon.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 1425)
+++ /trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 1426)
@@ -121,25 +121,28 @@
     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 x = TMath::Abs(px-pxhex);
+    const Double_t y = TMath::Abs(py-pyhex);
+
+    const Double_t disthex = TMath::Sqrt(x*x + y*y);
 
     if (disthex==0)
         return 0;
 
-    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 cosa = x / disthex;
+    const Double_t sina = y / disthex;
+
+    //
+    // comput the distance of hexagon center 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)));
+    const Int_t pxborder = gPad->XtoAbsPixel(fX + dx);
+    const Int_t pyborder = gPad->YtoAbsPixel(fY + dy);
+
+    const Double_t bx = pxhex-pxborder;
+    const Double_t by = pyhex-pyborder;
+
+    const Double_t distborder = TMath::Sqrt(bx*bx + by*by);
 
     //
@@ -147,5 +150,5 @@
     //  here in the first implementation is just circle inside
     //
-    return distborder < disthex ? 999999 : 0;
+    return distborder < disthex ? (int)(disthex-distborder+1) : 0;
 }
 
Index: /trunk/MagicSoft/Mars/mgui/MineSweeper.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MineSweeper.cc	(revision 1425)
+++ /trunk/MagicSoft/Mars/mgui/MineSweeper.cc	(revision 1426)
@@ -206,6 +206,9 @@
         delete fDone;
 
-    //    if (fIsAllocated)
-    //        delete fDrawingPad;
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
 }
 
