Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1384)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1390)
@@ -35,4 +35,5 @@
 #include <math.h>
 #include <fstream.h>
+#include <iostream.h>
 
 #include <TClonesArray.h>
@@ -41,4 +42,5 @@
 #include <TBox.h>
 #include <TText.h>
+#include <TButton.h>
 
 #include "MHexagon.h"
@@ -50,5 +52,5 @@
 #include "MCerPhotEvt.h"
 
-#define kItemsLegend 25 // see SetPalette(1,0)
+#define kItemsLegend 50 // see SetPalette(1,0)
 
 ClassImp(MCamDisplay);
@@ -86,7 +88,7 @@
     //
 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
-    gStyle->SetPalette(1, 0);
+    SetPalette(1, 0);
 #else
-    gStyle->SetPalette(51, 0);
+    SetPalette(51, 0);
 #endif
 
@@ -102,7 +104,5 @@
         TText *newtxt = new ((*fLegText)[i]) TText;
 
-        const Float_t lvl = 50. / kItemsLegend * i;
-
-        newbox->SetFillColor(GetColor(lvl));
+        newbox->SetFillColor(fColors[i]);
 
         newtxt->SetTextSize(0.025);
@@ -186,4 +186,103 @@
     //
     gPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+//  With this function you can change the color palette. For more
+// information see TStyle::SetPalette. Only palettes with 50 colors
+// are allowed.
+// In addition you can use SetPalette(52, 0) to create an inverse
+// deep blue sea palette
+//
+void MCamDisplay::SetPalette(Int_t ncolors, Int_t *colors)
+{
+    //
+    // If not enough colors are specified skip this.
+    //
+    if (ncolors>1 && ncolors<50)
+    {
+        cout << "MCamDisplay::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl;
+        return;
+    }
+
+    //
+    // If ncolors==52 create a reversed deep blue sea palette
+    //
+    if (ncolors==52)
+    {
+        gStyle->SetPalette(51, NULL);
+        Int_t c[50];
+        for (int i=0; i<50; i++)
+            c[49-i] = gStyle->GetColorPalette(i);
+        gStyle->SetPalette(50, c);
+    }
+    else
+        gStyle->SetPalette(ncolors, colors);
+
+    if (fDrawingPad)
+    {
+        //
+        // Set the colors of the legend
+        //
+        for (int i=0; i<kItemsLegend; i++)
+        {
+            Int_t col = GetBox(i)->GetFillColor();
+
+            //
+            // Make sure, that the legend is already colored
+            //
+            if (col==10 || col==22)
+                continue;
+            GetBox(i)->SetFillColor(gStyle->GetColorPalette(i));
+        }
+
+        //
+        // Change the colors of the pixels
+        //
+        for (unsigned int i=0; i<fNumPixels; i++)
+        {
+            //
+            // Get the old color index and check whether it is
+            // background or transparent
+            //
+            Int_t col = (*this)[i].GetFillColor();
+            if (col==10 || col==22)
+                continue;
+
+            //
+            // Search for the color index (level) in the color table
+            //
+            int idx;
+            for (idx=0; idx<kItemsLegend; idx++)
+                if (col==fColors[idx])
+                    break;
+            //
+            // Should not happen
+            //
+            if (idx==kItemsLegend)
+            {
+                cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl;
+                continue;
+            }
+
+            //
+            // Convert the old color index (level) into the new one
+            //
+            (*this)[i].SetFillColor(gStyle->GetColorPalette(idx));
+        }
+
+        //
+        // Update the pad on the screen
+        //
+        fDrawingPad->Modified();
+        fDrawingPad->Update();
+    }
+
+    //
+    // Store the color palette used for a leter reverse lookup
+    //
+    for (int i=0; i<kItemsLegend; i++)
+        fColors[i] = gStyle->GetColorPalette(i);
 }
 
@@ -226,12 +325,22 @@
 
     //
+    // Create and draw the buttons which allows changing the
+    // color palette of the display
+    //
+    TButton *but;
+    char txt[100];
+    sprintf(txt, "((MCamDisplay*)%p)->SetPalette(1,0);", this);
+    but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99);
+    but->Draw();
+    sprintf(txt, "((MCamDisplay*)%p)->SetPalette(51,0);", this);
+    but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99);
+    but->Draw();
+    sprintf(txt, "((MCamDisplay*)%p)->SetPalette(52,0);", this);
+    but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99);
+    but->Draw();
+
+    //
     // Setup the correct environment
     //
-#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
-    gStyle->SetPalette(1, 0);
-#else
-    gStyle->SetPalette(51, 0);
-#endif
-
     gPad->SetFillColor(22);
 
@@ -241,8 +350,11 @@
     //
     for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        (*this)[i].SetFillColor(22);
         (*this)[i].Draw();
-
-    //
-    // draw legend
+    }
+
+    //
+    // initialize and draw legend
     //
     const Float_t H = 0.9*fRange;
@@ -258,4 +370,5 @@
         box->SetY1(H*( i   *h - 1.));
         box->SetY2(H*((i+1)*h - 1.));
+        box->SetFillColor(22);
         box->Draw();
 
@@ -305,4 +418,7 @@
 
     fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
 
     //
@@ -374,11 +490,11 @@
     //   first treat the over- and under-flows
     //
-    const Int_t maxcolidx = 49;
+    const Int_t maxcolidx = kItemsLegend-1;
 
     if (val >= fMaxPhe)
-        return gStyle->GetColorPalette(maxcolidx);
+        return fColors[maxcolidx];
 
     if (val <= fMinPhe)
-        return gStyle->GetColorPalette(0);
+        return fColors[0];
 
     //
@@ -388,5 +504,5 @@
     const Int_t   colidx = (Int_t)(ratio*maxcolidx + .5);
 
-    return gStyle->GetColorPalette(colidx);
+    return fColors[colidx];
 }
 
@@ -400,5 +516,5 @@
     char text[10];
 
-    for (Int_t i=0; i<kItemsLegend; i++)
+    for (Int_t i=0; i<kItemsLegend; i+=3)
     {
         const Float_t val = fMinPhe + (Float_t)i/kItemsLegend * (fMaxPhe-fMinPhe) ;
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1384)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1390)
@@ -30,4 +30,6 @@
     Float_t        fMinPhe;      // The minimal number of Phe
     Float_t        fMaxPhe;      // The maximum number of Phe
+
+    Int_t          fColors[50];
 
     TClonesArray  *fPixels;      // array of all hexagons
@@ -64,4 +66,6 @@
     void SavePrimitive(ofstream &out, Option_t *);
 
+    void SetPalette(Int_t ncolors, Int_t *colors);
+
     ClassDef(MCamDisplay, 0) // Displays the magic camera
 };
