Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 8364)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 8398)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.101 2007-02-01 15:14:28 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.102 2007-04-12 11:47:19 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -22,5 +22,5 @@
 !   Author(s): Markus Gaug, 03/2004 <mailto:markus@ifae.es>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2007
 !
 !
@@ -1194,8 +1194,11 @@
     {
         gStyle->SetPalette(51, NULL);
-        TArrayI c(kItemsLegend);
-        for (int i=0; i<kItemsLegend; i++)
-            c[kItemsLegend-i-1] = gStyle->GetColorPalette(i);
-        gStyle->SetPalette(kItemsLegend, c.GetArray());
+
+        const Int_t n = GetContour()==0?50:GetContour();
+
+        TArrayI c(n);
+        for (int i=0; i<n; i++)
+            c[n-i-1] = gStyle->GetColorPalette(i);
+        gStyle->SetPalette(n, c.GetArray());
     }
     else
@@ -1721,5 +1724,7 @@
     //   first treat the over- and under-flows
     //
-    const Int_t maxcolidx = kItemsLegend-1;
+    const Int_t ncol = GetContour()==0?50:GetContour();
+
+    const Int_t maxcolidx = ncol-1;
 
     if (!TMath::Finite(val)) // FIXME: gLog!
@@ -1741,5 +1746,5 @@
         ratio = (val-min) / (max-min);
 
-    const Int_t colidx = (Int_t)(ratio*maxcolidx + .5);
+    const Int_t colidx = TMath::FloorNint(ratio*ncol);
     return gStyle->GetColorPalette(colidx);
 }
@@ -1796,5 +1801,7 @@
         const Float_t offset = hndc*range;
 
-        const Float_t h = 2./kItemsLegend;
+        const Int_t ncol = GetContour()==0 ? 50 : GetContour();
+
+        const Float_t h = 2./ncol;
         const Float_t w = range/sqrt((float)(fNcells-2));
 
@@ -1808,9 +1815,9 @@
 #endif
 
-        const Float_t step   = (islog && min>0 ? log10(max/min) : max-min) / kItemsLegend;
-        const Int_t   firsts = step*3 < 1e-8 ? 8 : (Int_t)floor(log10(step*3));
+        const Float_t step   = (islog && min>0 ? log10(max/min) : max-min);
+        const Int_t   firsts = step/48*3 < 1e-8 ? 8 : (Int_t)floor(log10(step/48*3));
         const TString opt    = Form("%%.%if", firsts>0 ? 0 : TMath::Abs(firsts));
-
-        for (Int_t i=0; i<kItemsLegend+1; i+=3)
+/*
+        for (Int_t i=0; i<ncol+1; i+=3)
         {
             Float_t val;
@@ -1822,7 +1829,12 @@
             //const bool dispexp = max-min>1.5 && fabs(val)>0.1 && fabs(val)<1e6;
             newtxt.PaintText(range+1.5*w, H*(i*h-1)-offset, Form(opt, val));
-        }
-
-        for (Int_t i=0; i<kItemsLegend; i++)
+            }
+            */
+        const MBinning bins(25, min, max, islog&&min>0?"log":"lin");
+
+        for (Int_t i=0; i<=25; i++)
+            newtxt.PaintText(range+1.5*w, H*(i*ncol/25*h-1)-offset, Form(opt, bins[i]));
+
+        for (Int_t i=0; i<ncol; i++)
         {
             newbox.SetFillColor(gStyle->GetColorPalette(i));
