Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7826)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7827)
@@ -18,4 +18,17 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2006/07/31 Thomas Bretz
+
+   * showplot.cc:
+     - added new options to write bmp and xml files
+     - added new options for the display size
+
+   * mbase/MStatusDisplay.[h,cc]:
+     - changed the constructor to allow starting with a different size
+     - added new member functions to change the display or canvas size
+     - fixed setting of sizes
+
+
+
  2006/07/30 Thomas Bretz
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7826)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7827)
@@ -8,4 +8,10 @@
    - general: Fixed some warnings thrown if more warnings are switched
      on in the compiler
+
+   - showplot: 
+     + batch mode creating of image files now works with root 5.12/00
+     + added support for writing bmp (though it never produces
+       bmp which can be read by programs like xv or gimp)
+     + added support for xml
 
    - merpp: didn't recognize files with the extension .raw.gz - fixed.
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 7826)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 7827)
@@ -339,4 +339,5 @@
     sizemenu->AddEntry("Fit to 1400x1050",  kSize1400);
     sizemenu->AddEntry("Fit to 1600x1200",  kSize1600);
+    sizemenu->AddEntry("Fit to &Desktop",   kSizeOptimum);
     sizemenu->Associate(this);
 
@@ -672,7 +673,12 @@
 //   always by deleting the corresponding object.
 //
+// You can give either width or height. (Set the value not given to -1)
+// The other value is calculated accordingly. If width and height are
+// given height is ignored. If width=height=0 an optimum size from
+// the desktop size is calculated.
+//
 // Update time default: 10s
 //
-MStatusDisplay::MStatusDisplay(Long_t t)
+MStatusDisplay::MStatusDisplay(Int_t w, Int_t h, Long_t t)
 : TGMainFrame(NULL, 1, 1), fName("MStatusDisplay"), fLog(&gLog), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
 {
@@ -714,5 +720,8 @@
     // In newer root versions gClient!=NULL in batch mode!
     if (!gClient || !gClient->GetRoot() || gROOT->IsBatch()) // BATCH MODE
+    {
+        Resize(644, 484);
         return;
+    }
 
     AddMenuBar();
@@ -725,6 +734,12 @@
     // set the smallest and biggest size of the Main frame
     // and move it to its appearance position
-    SetWMSizeHints(572, 480, 2048, 1536, 1, 1);
-    MoveResize(rand()%100+572, rand()%100+480, 572, 480);
+    SetWMSizeHints(566, 476, 2048, 1536, 1, 1);
+    MoveResize(rand()%100+566, rand()%100+476, 566, 476);
+    if (h>0)
+        SetDisplayHeight(h);
+    if (w>0)
+        SetDisplayWidth(w);
+    if (w==0 && h==0)
+        SetOptimumSize();
 
     //
@@ -997,5 +1012,9 @@
     if (gROOT->IsBatch())
     {
-        TCanvas *c = new TCanvas(name, name);
+        // 4 = 2*default border width of a canvas
+        const UInt_t cw = GetWidth();
+        const UInt_t ch = 2*cw/3 + 25; // 25: Menu, etc
+
+        TCanvas *c = new TCanvas(name, name, -cw, ch);
         fBatch->Add(c);
         return *c;
@@ -1617,30 +1636,33 @@
         return kTRUE;
 
-    case kSize640:  
-        Resize(572, 480);
+    case kSize640:
+        SetDisplaySize(640, 480);
         return kTRUE;
     case kSize768:  
-        Resize(714, 576);
+        SetDisplaySize(768, 576);
         return kTRUE;
     case kSize800:  
-        Resize(750, 600);
+        SetDisplaySize(800, 600);
         return kTRUE;
     case kSize960:  
-        Resize(900, 700);
+        SetDisplaySize(960, 720);
         return kTRUE;
     case kSize1024: 
-        Resize(1000, 768);
+        SetDisplaySize(1024, 768);
         return kTRUE;
     case kSize1152:
-        Resize(1147, 864);
+        SetDisplaySize(1152, 864);
         return kTRUE;
     case kSize1280: 
-        Resize(1321, 980);
+        SetDisplaySize(1280, 1024);
         return kTRUE;
     case kSize1400:
-        Resize(1426, 1050);
+        SetDisplaySize(1400, 1050);
         return kTRUE;
     case kSize1600:
-        Resize(1550, 1400);
+        SetDisplaySize(1600, 1200);
+        return kTRUE;
+    case kSizeOptimum:
+        SetOptimumSize();
         return kTRUE;
 
@@ -2940,4 +2962,133 @@
 }
 
+// --------------------------------------------------------------------------
+//
+//  Change width of display. The height is calculated accordingly.
+//
+void MStatusDisplay::SetDisplayWidth(UInt_t dw)
+{
+    if (gROOT->IsBatch())
+    {
+        SetCanvasWidth(dw);
+        return;
+    }
+
+    // 4 == 2*default border with of canvas
+    dw -= 4;
+
+    // Difference between canvas size and display size
+    const UInt_t cw = GetWidth() -fTab->GetWidth();
+    const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight();
+
+    const UInt_t dh = TMath::Nint((dw - cw)/1.5 + ch);
+
+    Resize(dw, dh); // Set display size
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change height of display. The width is calculated accordingly.
+//
+void MStatusDisplay::SetDisplayHeight(UInt_t dh)
+{
+    if (gROOT->IsBatch())
+    {
+        SetCanvasHeight(dh);
+        return;
+    }
+
+    // 4 == 2*default border with of canvas
+    dh -= 4;
+
+    // Difference between canvas size and display size
+    const UInt_t cw = GetWidth() -fTab->GetWidth();
+    const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight();
+
+    const UInt_t dw = TMath::Nint((dh - ch)*1.5 + cw);
+
+    Resize(dw, dh); // Set display size
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change width of canvas. The height is calculated accordingly.
+//
+void MStatusDisplay::SetCanvasWidth(UInt_t w)
+{
+    // 4 == 2*default border with of canvas
+    w += 4;
+
+    if (gROOT->IsBatch())
+    {
+        Resize(w, 3*w/2);
+        return;
+    }
+
+    // Difference between canvas size and display size
+    const UInt_t cw = GetWidth() -fTab->GetWidth();
+    const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight();
+
+    const UInt_t h  = TMath::Nint(w/1.5 + ch);
+
+    Resize(w + cw, h); // Set display size
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change height of canvas. The width is calculated accordingly.
+//
+void MStatusDisplay::SetCanvasHeight(UInt_t h)
+{
+    // 4 == 2*default border with of canvas
+    h += 4;
+
+    if (gROOT->IsBatch())
+    {
+        Resize(2*h/3, h);
+        return;
+    }
+
+    // Difference between canvas size and display size
+    const UInt_t cw = GetWidth() -fTab->GetWidth();
+    const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight();
+
+    // 4 == 2*default border with of canvas
+    const UInt_t dw  = TMath::Nint((h+4)*1.5 + cw);
+
+    Resize(dw, h + ch); // Set display size
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate width and height of the display such that it fits into the
+// defined box.
+//
+void MStatusDisplay::SetDisplaySize(UInt_t w, UInt_t h)
+{
+    if (gROOT->IsBatch())
+        return;
+
+    SetDisplayHeight(h);
+
+    if (GetWidth()>w)
+        SetDisplayWidth(w);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate an optimum size for the display from the desktop size
+//
+void MStatusDisplay::SetOptimumSize()
+{
+    if (gROOT->IsBatch())
+        return;
+
+    const UInt_t w = TMath::Nint(0.95*gClient->GetDisplayWidth());
+    const UInt_t h = TMath::Nint(0.95*gClient->GetDisplayHeight());
+
+    SetDisplaySize(w, h);
+}
+
+
 Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt)
 {
@@ -2951,6 +3102,6 @@
     UInt_t h = evt->fHeight;
 
-    const Bool_t wchanged = w!=GetWidth();
-    const Bool_t hchanged = h!=GetHeight();
+    const Bool_t wchanged = w!=GetWidth()-fTab->GetWidth();
+    const Bool_t hchanged = h!=GetHeight()-fTab->GetHeight();
 
     if (!wchanged && !hchanged)
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 7826)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 7827)
@@ -59,5 +59,5 @@
         // kSize
         kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
-        kSize1280, kSize1400, kSize1600,
+        kSize1280, kSize1400, kSize1600, kSizeOptimum,
         // kLog
         kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
@@ -157,5 +157,5 @@
 
 public:
-     MStatusDisplay(Long_t t=1000);
+     MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000);
      virtual ~MStatusDisplay();
 
@@ -246,4 +246,14 @@
      Bool_t SaveLogAsPS(const char *name) const;
 
+     // Size options
+     void SetCanvasWidth(UInt_t w);
+     void SetCanvasHeight(UInt_t h);
+
+     void SetDisplayWidth(UInt_t w);
+     void SetDisplayHeight(UInt_t h);
+
+     void SetOptimumSize();
+     void SetDisplaySize(UInt_t w, UInt_t h);
+
      Int_t  SaveAs(Int_t num=-1);
      Int_t  Open(TString fname, const char *name="MStatusDisplay");
Index: trunk/MagicSoft/Mars/showplot.cc
===================================================================
--- trunk/MagicSoft/Mars/showplot.cc	(revision 7826)
+++ trunk/MagicSoft/Mars/showplot.cc	(revision 7827)
@@ -56,4 +56,12 @@
     gLog << "   --save-as-xpm[=filename]  Save plots as xpm files" << endl;
     gLog << "   --save-as-png[=filename]  Save plots as png files" << endl;
+    gLog << "   --save-as-bmp[=filename]  Save plots as bmp files" << endl;
+    gLog << "   --save-as-xml[=filename]  Save plots as xml files" << endl << endl;
+    gLog << " Size options:" << endl;
+    gLog << "   --display-width=w         Set width of display window to w" << endl;
+    gLog << "   --display-height=h        Set height of display window to h" << endl;
+    gLog << "   --canvas-width=w          Set width of canvas' contained by display to w" << endl;
+    gLog << "   --canvas-height=h         Set height of canvas' contained by display to h" << endl;
+    gLog << "   --auto-size               Determin optimum size (not available in batch mode)" << endl;
     gLog << endl;
     gLog << "   --version, -V             Show startup message with version number" << endl;
@@ -64,4 +72,7 @@
     gLog << " MStatusArrays are typically written by programs showing data" << endl;
     gLog << " check plots, like callisto." << endl << endl;
+    gLog << " Only the last size option given is taken into account." << endl;
+    gLog << " Width or height is set according to height or width." << endl << endl;
+    gLog << " In batch mode display width and height and auto-size is ignored." << endl;
     gLog << "Printing:" << endl;
     gLog << " For more details see MStatusDisplay::PrintPS" << endl << endl;
@@ -110,6 +121,20 @@
     const Bool_t kSaveAsXpm  = arg.HasOnlyAndRemove("--save-as-xpm")  || arg.Has("--save-as-xpm=");
     const Bool_t kSaveAsPng  = arg.HasOnlyAndRemove("--save-as-png")  || arg.Has("--save-as-png=");
+    const Bool_t kSaveAsBmp  = arg.HasOnlyAndRemove("--save-as-bmp")  || arg.Has("--save-as-bmp=");
+    const Bool_t kSaveAsXml  = arg.HasOnlyAndRemove("--save-as-xml")  || arg.Has("--save-as-xml=");
     const Bool_t kSaveAsRoot = arg.HasOnlyAndRemove("--save-as-root") || arg.Has("--save-as-root=");
     const Bool_t kSaveAsC    = arg.HasOnlyAndRemove("--save-as-C")    || arg.Has("--save-as-C=");
+
+    const Int_t  kCanvasWidth   = arg.GetIntAndRemove("--canvas-width=",   -1);
+    const Int_t  kCanvasHeight  = arg.GetIntAndRemove("--canvas-height=",  -1);
+
+    const Bool_t kAutoSize = arg.HasOnlyAndRemove("--auto-size");
+    Int_t  kDisplayWidth   = arg.GetIntAndRemove("--display-width=",  -1);
+    Int_t  kDisplayHeight  = arg.GetIntAndRemove("--display-height=", -1);
+    if (kAutoSize)
+    {
+        kDisplayWidth=0;
+        kDisplayHeight=0;
+    }
 
     TString kNamePrint = arg.GetStringAndRemove("--print=");
@@ -123,4 +148,6 @@
     TString kNameXpm   = arg.GetStringAndRemove("--save-as-xpm=");
     TString kNamePng   = arg.GetStringAndRemove("--save-as-png=");
+    TString kNameBmp   = arg.GetStringAndRemove("--save-as-bmp=");
+    TString kNameXml   = arg.GetStringAndRemove("--save-as-xml=");
     TString kNameRoot  = arg.GetStringAndRemove("--save-as-root=");
     TString kNameC     = arg.GetStringAndRemove("--save-as-C=");
@@ -203,4 +230,8 @@
     if (kNamePng.IsNull()  && kSaveAsPng)
         kNamePng = kInput;
+    if (kNameBmp.IsNull()  && kSaveAsBmp)
+        kNameBmp = kInput;
+    if (kNameXml.IsNull()  && kSaveAsXml)
+        kNameXml = kInput;
     if (kNameRoot.IsNull() && kSaveAsRoot)
         kNameRoot = kInput;
@@ -211,9 +242,14 @@
     // Update frequency by default = 1Hz
     //
-    MStatusDisplay *d = new MStatusDisplay;
+    MStatusDisplay *d = new MStatusDisplay(kDisplayWidth, kDisplayHeight);
 
     // From now on each 'Exit' means: Terminate the application
     d->SetTitle(kInput);
     d->SetWindowName(kInput);
+
+    if (kCanvasHeight>0)
+        d->SetCanvasHeight(kCanvasHeight);
+    if (kCanvasWidth>0)
+        d->SetCanvasWidth(kCanvasWidth);
 
     d->Open(kInput);
@@ -235,4 +271,8 @@
     if (kSaveAsPng)
         d->SaveAsPNG(kTab,  kNamePng);
+    if (kSaveAsBmp)
+        d->SaveAsBMP(kTab,  kNameBmp);
+    if (kSaveAsXml)
+        d->SaveAsXML(kTab,  kNameXml);
     if (kSaveAsRoot)
         d->SaveAsRoot(kTab, kNameRoot);
