Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4080)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4081)
@@ -45,8 +45,8 @@
    * msignal/MArrivalTimeCam.cc
      - introduced functin GetHiGainSaturation() in MArrivalTimePix.h
-     - added type in GetPixelContent() whihc asks for Hi-Gain saturation
+     - added type in GetPixelContent() which asks for Hi-Gain saturation
        and return the hi-gain time or the low-gain time, correspondingly.
 
-   * mbase/ MGMap.cc
+   * mbase/MGMap.cc
      - fixed two bugs which did not complile under gcc 3.3.x introduced
        by TB.
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 4080)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc	(revision 4081)
@@ -128,5 +128,5 @@
 
 #include "MTime.h"
-//#include "MString.h"
+#include "MString.h"
 #include "MAstro.h"
 #include "MAstroSky2Local.h"
@@ -179,5 +179,5 @@
     fList.SetOwner();
     fMapG.SetOwner();
-    fToolTip = new TGToolTip(0, "", 0);
+    fToolTip = gROOT->IsBatch() || !gClient ? 0 : new TGToolTip(0, "", 0);
 }
 
@@ -203,6 +203,9 @@
         delete fObservatory;
 
-    fToolTip->Hide();
-    delete fToolTip;
+    if (fToolTip)
+    {
+        fToolTip->Hide();
+        delete fToolTip;
+    }
 }
 
@@ -726,7 +729,8 @@
 // simultaneously.
 //
-void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h)
-{
-    const char * o = "local mirrorx yellow *";
+void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h, Option_t *o)
+{
+    if (!o)
+        o = "local mirrorx yellow * =";
 
     if (TestBit(kHasChanged))
@@ -757,7 +761,6 @@
     const Double_t mag = -2.5*log10(v.Mag());
 
-    //MString str;
-    //str.Print("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag);
-    TString str(Form("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag));
+    MString str;
+    str.Print("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag);
     if (txt)
     {
@@ -898,5 +901,5 @@
 
     const TVector2 deg = va*TMath::RadToDeg();
-    /*
+
     MString txt;
     if (type==1)
@@ -904,10 +907,4 @@
     else
         txt.Print("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
-        */
-    TString txt;
-    if (type==1)
-        txt = Form("Ra=%.2fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(90-deg.Y()+270,180)-90);
-    else
-        txt = Form("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
 
     TMarker *tip=new TMarker(v0.X(), v0.Y(), kDot);
@@ -1317,10 +1314,10 @@
     {
     case kMouseMotion:
-        if (!fToolTip->IsMapped() && !str.IsNull())
+        if (fToolTip && !fToolTip->IsMapped() && !str.IsNull())
             ShowToolTip(px, py, str);
         break;
 
     case kMouseLeave:
-        if (fToolTip->IsMapped())
+        if (fToolTip && fToolTip->IsMapped())
             fToolTip->Hide();
         break;
Index: trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
===================================================================
--- trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 4080)
+++ trunk/MagicSoft/Mars/mastro/MAstroCatalog.h	(revision 4081)
@@ -181,5 +181,5 @@
 
     //void PaintImg(Int_t id=0, Option_t *o="");
-    void PaintImg(unsigned char *buf, int w=768, int h=576);
+    void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0);
     void Draw(Option_t *o="");
     void SetDrawOption(Option_t *option="")
Index: trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 4081)
@@ -21,4 +21,5 @@
 // Basic Tools
 #pragma link C++ class MMath+;
+#pragma link C++ class MString+;
 #pragma link C++ class MIter+;
 #pragma link C++ class MDirIter+;
Index: trunk/MagicSoft/Mars/mbase/MGMap.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGMap.cc	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/MGMap.cc	(revision 4081)
@@ -217,5 +217,5 @@
 // Convert root colors to arbitrary bitmap coordinates
 //
-Int_t MGMap::Color(int col)
+UChar_t MGMap::Color(int col)
 {
     switch (col)
@@ -234,8 +234,106 @@
 // --------------------------------------------------------------------------
 //
+// Draw a line into the buffer (size w*h) from (x1, y1) to (x2, y2) with
+// the color col and the line style style (default: solid)
+//
+void MGMap::DrawLine(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style)
+{
+    const Int_t    step = style==kSolid?1:3;
+    const Double_t len  = TMath::Hypot(x2-x1, y2-y1);
+    const Double_t dx   = (x2-x1)/len*step;
+    const Double_t dy   = (y2-y1)/len*step;
+
+    Double_t x = x1;
+    Double_t y = y1;
+
+    for (int i=0; i<len; i+=step)
+    {
+        x+= dx;
+        y+= dy;
+
+        const Int_t iy = (int)rint(y);
+        if (iy<0 || iy>=h)
+            continue;
+
+        const Int_t ix = (int)rint(x);
+        if (ix<0 || ix>=w)
+            continue;
+
+        buf[ix+iy*w] = col;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a box into the buffer (size w*h) from (x1, y1) to (x2, y2) with
+// the color col and the line style style (default: solid)
+//
+void MGMap::DrawBox(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style)
+{
+    DrawLine(buf, w, h, x1, y1, x2, y1, col, style);
+    DrawLine(buf, w, h, x1, y2, x2, y1, col, style);
+    DrawLine(buf, w, h, x1, y1, x1, y2, col, style);
+    DrawLine(buf, w, h, x2, y1, x2, y2, col, style);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a circle into the buffer (size w*h) around (x, y) with radius r and
+// the color col.
+//
+void MGMap::DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col)
+{
+    const Int_t n = (int)rint(sqrt(2.)*r*TMath::Pi()/2);
+    for (int i=0; i<n-1; i++)
+    {
+        const Double_t angle = TMath::TwoPi()*i/n;
+
+        const Double_t dx = r*cos(angle);
+        const Double_t dy = r*sin(angle);
+
+        const Int_t x1 = (int)rint(x+dx);
+        const Int_t x2 = (int)rint(x-dx);
+
+        const Int_t y1 = (int)rint(y+dy);
+        if (y1>=0 && y1<h)
+        {
+            if (x1>=0 && x1<w)
+                buf[x1+y1*w] = col;
+
+            if (x2>=0 && x2<w)
+                buf[x2+y1*w] = col;
+        }
+
+        const Int_t y2 = (int)rint(y-dy);
+        if (y2>=0 && y2<h)
+        {
+            if (x1>=0 && x1<w)
+                buf[x1+y2*w] = col;
+
+            if (x2>=0 && x2<w)
+                buf[x2+y2*w] = col;
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a dot into the buffer (size w*h) at (x, y) with color col.
+//
+void MGMap::DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col)
+{
+    const Int_t x1 = (int)rint(cx);
+    const Int_t y1 = (int)rint(cy);
+
+    if (x1>=0 && y1>=0 && x1<w && y1<h)
+        buf[x1+y1*w] = col;
+}
+
+// --------------------------------------------------------------------------
+//
 // Draw a line into the buffer. The TObject must be a TLine.
 // Currently only solid and non sloid line are supported.
 //
-void MGMap::DrawLine(TObject *o, unsigned char *buf, int w, int h, Double_t scale)
+void MGMap::DrawLine(TObject *o, UChar_t *buf, int w, int h, Double_t scale)
 {
     TLine *l = dynamic_cast<TLine*>(o);
@@ -243,29 +341,23 @@
         return;
 
-    Double_t x1 = 0.5*w-(l->GetX1()/scale);
-    Double_t x2 = 0.5*w-(l->GetX2()/scale);
-    Double_t y1 = 0.5*h-(l->GetY1()/scale);
-    Double_t y2 = 0.5*h-(l->GetY2()/scale);
-
-    Double_t len = TMath::Hypot(x2-x1, y2-y1);
-
-    Double_t x = x1;
-    Double_t y = y1;
-
-    Int_t step = l->GetLineStyle()==kSolid?1:3;
-
-    Double_t dx = (x2-x1)/len*step;
-    Double_t dy = (y2-y1)/len*step;
-
-    for (int i=0; i<len; i+=step)
-    {
-        x+= dx;
-        y+= dy;
-
-        if (x<0 || y<0 || x>w-1 || y>h-1)
-            continue;
-
-        buf[(int)x+(int)y*w] = Color(l->GetLineColor());
-    }
+    const Double_t x1 = 0.5*w-(l->GetX1()/scale);
+    const Double_t x2 = 0.5*w-(l->GetX2()/scale);
+    const Double_t y1 = 0.5*h-(l->GetY1()/scale);
+    const Double_t y2 = 0.5*h-(l->GetY2()/scale);
+
+    const Int_t col = Color(l->GetLineColor());
+    DrawLine(buf, w, h, x1, y1, x2, y2, col, l->GetLineStyle());
+}
+
+void MGMap::DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col)
+{
+    DrawLine(buf, w, h, cx-size, cy-size, cx+size, cy+size, col);
+    DrawLine(buf, w, h, cx+size, cy-size, cx-size, cy+size, col);
+}
+
+void MGMap::DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col)
+{
+    DrawLine(buf, w, h, cx-size, cy, cx+size, cy, col);
+    DrawLine(buf, w, h, cx, cy-size, cx, cy+size, col);
 }
 
@@ -275,5 +367,5 @@
 // Currently kCircle, kMultiply and KDot are supported.
 //
-void MGMap::DrawMarker(TObject *o, unsigned char *buf, int w, int h, Double_t scale)
+void MGMap::DrawMarker(TObject *o, UChar_t *buf, int w, int h, Double_t scale)
 {
     TMarker *m = dynamic_cast<TMarker*>(o);
@@ -289,43 +381,15 @@
     {
     case kCircle:
-        {
-            Int_t step = 32;
-
-            const Float_t l = (m->GetMarkerSize()*2)+1;
-            for (int i=0; i<step; i++)
-            {
-                const Double_t angle = i*TMath::TwoPi()/step;
-
-                const Double_t x1 = x+l*cos(angle);
-                const Double_t y1 = y+l*sin(angle);
-
-                if (x1<0 || y1<0 || x1>w-1 || y1>h-1)
-                    continue;
-
-                buf[(int)x1+(int)y1*w] = col;
-            }
-        }
+        DrawCircle(buf, w, h, x, y, m->GetMarkerSize()*2+1, col);
         break;
     case kDot:
-        if (x>=0 && y>=0 && x<w && y<h)
-            buf[(int)x+(int)y*w] = col;
-        break;
-
+        DrawDot(buf, w, h, x, y, col);
+        break;
     case kMultiply:
-        {
-            const Int_t l = (int)(m->GetMarkerSize()+1);
-
-            for (int i=-l; i<l+1; i++)
-            {
-                Double_t x1 = x+i;
-                Double_t y1 = y+i;
-                if (x1>=0 && y>=0 && x1<w && y<h)
-                    buf[(int)x1+(int)y*w] = col;
-                if (x>=0 && y1>=0 && x<w && y1<h)
-                    buf[(int)x+(int)y1*w] = col;
-            }
-        }
-        break;
-
+        DrawMultiply(buf, w, h, x, y, m->GetMarkerSize()*2+1, col);
+        break;
+    case kCross:
+        DrawCross(buf, w, h, x, y, m->GetMarkerSize()*2+1, col);
+        break;
     }
 }
@@ -345,10 +409,10 @@
 // --------------------------------------------------------------------------
 //
-// Paint all objects into a buffer of w*h unsigned chars. The scale
+// Paint all objects into a buffer of w*h UChar_ts. The scale
 // gives you the conversio factor to convert pad coordinates into
 // buffer pixels - it is the distance from the center of the buffer
 // to one of its edges.
 //
-void MGMap::Paint(unsigned char *buf, int w, int h, Float_t scale)
+void MGMap::Paint(UChar_t *buf, int w, int h, Float_t scale)
 {
     scale /= TMath::Hypot((float)w, (float)h)/2;
Index: trunk/MagicSoft/Mars/mbase/MGMap.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGMap.h	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/MGMap.h	(revision 4081)
@@ -36,11 +36,9 @@
 
     void     Paint(Option_t *o="");
-    void     Paint(unsigned char *buf, int w, int h, Float_t scale);
+    void     Paint(UChar_t *buf, int w, int h, Float_t scale);
     //void     Paint(Drawable_t id, Float_t scale);
 
-    Int_t    Color(int col);
-
-    void     DrawLine(TObject *o, unsigned char *buf, int w, int h, Double_t scale);
-    void     DrawMarker(TObject *o, unsigned char *buf, int w, int h, Double_t scale);
+    void     DrawLine(TObject *o, UChar_t *buf, int w, int h, Double_t scale);
+    void     DrawMarker(TObject *o, UChar_t *buf, int w, int h, Double_t scale);
 
     //void     EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
@@ -49,4 +47,12 @@
     Int_t    DistancetoPrimitive(Int_t px, Int_t py);
 
+    static UChar_t Color(int col);
+    static void    DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col);
+    static void    DrawLine(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style=1);
+    static void    DrawBox(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style=1);
+    static void    DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col);
+    static void    DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col);
+    static void    DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col);
+
     ClassDef(MGMap, 1) // Special TExMap supporting enhanced drawing and bitmap drawing
 };
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 4081)
@@ -66,4 +66,6 @@
 #include <TVirtualPad.h>  // gPad
 
+#include "MString.h"
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -197,5 +199,7 @@
     // point to a random memory segment, because the TString has gone.
     //
-    return fName==ClassName() ? ClassName() : Form("%s [%s]", fName.Data(), ClassName());
+    MString desc;
+    desc.Print("%s [%s]", fName.Data(), ClassName());
+    return fName==ClassName() ? ClassName() : desc.Data();
 }
 
Index: trunk/MagicSoft/Mars/mbase/MString.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MString.cc	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/MString.cc	(revision 4081)
@@ -54,4 +54,9 @@
 //  string.Print("MyString has %d bytes", 128);
 //
+// As a special feature the function returns the reference to the MString
+// so that you can directly work with it, eg.
+//
+//  string.Print("  MyString has %d bytes  ", 128).Strip(TString::kBoth);
+//
 MString &MString::Print(const char *fmt, ...)
 {
Index: trunk/MagicSoft/Mars/mbase/MString.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MString.h	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/MString.h	(revision 4081)
@@ -12,33 +12,7 @@
 {
 public:
-    MString &Print(const char *fmt, ...)
-    {
-        va_list ap;
-        va_start(ap, fmt);
+    MString &Print(const char *fmt, ...);
 
-        Int_t n=256;
-
-        char *ret=0;
-
-        while (1)
-        {
-            ret = new char[n+1];
-            Int_t sz = vsnprintf(ret, n, fmt, ap);
-            if (sz<=n)
-                break;
-
-            n *= 2;
-            delete [] ret;
-        };
-
-        va_end(ap);
-
-        *static_cast<TString*>(this) = ret;
-
-        delete [] ret;
-
-        return *this;
-    }
-    ClassDef(MString, 1)
+    ClassDef(MString, 1) // Tool to make Form() thread safe against other TStrings
 };
 
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 4080)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 4081)
@@ -20,4 +20,5 @@
 SRCFILES = MLogo.cc \
            MArgs.cc \
+           MString.cc \
            MMath.cc \
 	   MLog.cc \
