- Timestamp:
- 05/15/04 20:05:18 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4080 r4081 45 45 * msignal/MArrivalTimeCam.cc 46 46 - introduced functin GetHiGainSaturation() in MArrivalTimePix.h 47 - added type in GetPixelContent() whi hcasks for Hi-Gain saturation47 - added type in GetPixelContent() which asks for Hi-Gain saturation 48 48 and return the hi-gain time or the low-gain time, correspondingly. 49 49 50 * mbase/ 50 * mbase/MGMap.cc 51 51 - fixed two bugs which did not complile under gcc 3.3.x introduced 52 52 by TB. -
trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc
r4058 r4081 128 128 129 129 #include "MTime.h" 130 //#include "MString.h"130 #include "MString.h" 131 131 #include "MAstro.h" 132 132 #include "MAstroSky2Local.h" … … 179 179 fList.SetOwner(); 180 180 fMapG.SetOwner(); 181 fToolTip = new TGToolTip(0, "", 0);181 fToolTip = gROOT->IsBatch() || !gClient ? 0 : new TGToolTip(0, "", 0); 182 182 } 183 183 … … 203 203 delete fObservatory; 204 204 205 fToolTip->Hide(); 206 delete fToolTip; 205 if (fToolTip) 206 { 207 fToolTip->Hide(); 208 delete fToolTip; 209 } 207 210 } 208 211 … … 726 729 // simultaneously. 727 730 // 728 void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h) 729 { 730 const char * o = "local mirrorx yellow *"; 731 void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h, Option_t *o) 732 { 733 if (!o) 734 o = "local mirrorx yellow * ="; 731 735 732 736 if (TestBit(kHasChanged)) … … 757 761 const Double_t mag = -2.5*log10(v.Mag()); 758 762 759 //MString str; 760 //str.Print("%s: Ra=%.2fh Dec=%.1fd Mag=%.1f", v.GetName(), ra, dec, mag); 761 TString str(Form("%s: Ra=%.2fh Dec=%.1fd Mag=%.1f", v.GetName(), ra, dec, mag)); 763 MString str; 764 str.Print("%s: Ra=%.2fh Dec=%.1fd Mag=%.1f", v.GetName(), ra, dec, mag); 762 765 if (txt) 763 766 { … … 898 901 899 902 const TVector2 deg = va*TMath::RadToDeg(); 900 /* 903 901 904 MString txt; 902 905 if (type==1) … … 904 907 else 905 908 txt.Print("Zd=%.1fd Az=%.1fd", fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360)); 906 */907 TString txt;908 if (type==1)909 txt = Form("Ra=%.2fh Dec=%.1fd", fmod(deg.X()/15+48, 24), fmod(90-deg.Y()+270,180)-90);910 else911 txt = Form("Zd=%.1fd Az=%.1fd", fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));912 909 913 910 TMarker *tip=new TMarker(v0.X(), v0.Y(), kDot); … … 1317 1314 { 1318 1315 case kMouseMotion: 1319 if ( !fToolTip->IsMapped() && !str.IsNull())1316 if (fToolTip && !fToolTip->IsMapped() && !str.IsNull()) 1320 1317 ShowToolTip(px, py, str); 1321 1318 break; 1322 1319 1323 1320 case kMouseLeave: 1324 if (fToolTip ->IsMapped())1321 if (fToolTip && fToolTip->IsMapped()) 1325 1322 fToolTip->Hide(); 1326 1323 break; -
trunk/MagicSoft/Mars/mastro/MAstroCatalog.h
r4058 r4081 181 181 182 182 //void PaintImg(Int_t id=0, Option_t *o=""); 183 void PaintImg(unsigned char *buf, int w=768, int h=576 );183 void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0); 184 184 void Draw(Option_t *o=""); 185 185 void SetDrawOption(Option_t *option="") -
trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
r4058 r4081 21 21 // Basic Tools 22 22 #pragma link C++ class MMath+; 23 #pragma link C++ class MString+; 23 24 #pragma link C++ class MIter+; 24 25 #pragma link C++ class MDirIter+; -
trunk/MagicSoft/Mars/mbase/MGMap.cc
r4078 r4081 217 217 // Convert root colors to arbitrary bitmap coordinates 218 218 // 219 Int_t MGMap::Color(int col)219 UChar_t MGMap::Color(int col) 220 220 { 221 221 switch (col) … … 234 234 // -------------------------------------------------------------------------- 235 235 // 236 // Draw a line into the buffer (size w*h) from (x1, y1) to (x2, y2) with 237 // the color col and the line style style (default: solid) 238 // 239 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) 240 { 241 const Int_t step = style==kSolid?1:3; 242 const Double_t len = TMath::Hypot(x2-x1, y2-y1); 243 const Double_t dx = (x2-x1)/len*step; 244 const Double_t dy = (y2-y1)/len*step; 245 246 Double_t x = x1; 247 Double_t y = y1; 248 249 for (int i=0; i<len; i+=step) 250 { 251 x+= dx; 252 y+= dy; 253 254 const Int_t iy = (int)rint(y); 255 if (iy<0 || iy>=h) 256 continue; 257 258 const Int_t ix = (int)rint(x); 259 if (ix<0 || ix>=w) 260 continue; 261 262 buf[ix+iy*w] = col; 263 } 264 } 265 266 // -------------------------------------------------------------------------- 267 // 268 // Draw a box into the buffer (size w*h) from (x1, y1) to (x2, y2) with 269 // the color col and the line style style (default: solid) 270 // 271 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) 272 { 273 DrawLine(buf, w, h, x1, y1, x2, y1, col, style); 274 DrawLine(buf, w, h, x1, y2, x2, y1, col, style); 275 DrawLine(buf, w, h, x1, y1, x1, y2, col, style); 276 DrawLine(buf, w, h, x2, y1, x2, y2, col, style); 277 } 278 279 // -------------------------------------------------------------------------- 280 // 281 // Draw a circle into the buffer (size w*h) around (x, y) with radius r and 282 // the color col. 283 // 284 void MGMap::DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col) 285 { 286 const Int_t n = (int)rint(sqrt(2.)*r*TMath::Pi()/2); 287 for (int i=0; i<n-1; i++) 288 { 289 const Double_t angle = TMath::TwoPi()*i/n; 290 291 const Double_t dx = r*cos(angle); 292 const Double_t dy = r*sin(angle); 293 294 const Int_t x1 = (int)rint(x+dx); 295 const Int_t x2 = (int)rint(x-dx); 296 297 const Int_t y1 = (int)rint(y+dy); 298 if (y1>=0 && y1<h) 299 { 300 if (x1>=0 && x1<w) 301 buf[x1+y1*w] = col; 302 303 if (x2>=0 && x2<w) 304 buf[x2+y1*w] = col; 305 } 306 307 const Int_t y2 = (int)rint(y-dy); 308 if (y2>=0 && y2<h) 309 { 310 if (x1>=0 && x1<w) 311 buf[x1+y2*w] = col; 312 313 if (x2>=0 && x2<w) 314 buf[x2+y2*w] = col; 315 } 316 } 317 } 318 319 // -------------------------------------------------------------------------- 320 // 321 // Draw a dot into the buffer (size w*h) at (x, y) with color col. 322 // 323 void MGMap::DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col) 324 { 325 const Int_t x1 = (int)rint(cx); 326 const Int_t y1 = (int)rint(cy); 327 328 if (x1>=0 && y1>=0 && x1<w && y1<h) 329 buf[x1+y1*w] = col; 330 } 331 332 // -------------------------------------------------------------------------- 333 // 236 334 // Draw a line into the buffer. The TObject must be a TLine. 237 335 // Currently only solid and non sloid line are supported. 238 336 // 239 void MGMap::DrawLine(TObject *o, unsigned char*buf, int w, int h, Double_t scale)337 void MGMap::DrawLine(TObject *o, UChar_t *buf, int w, int h, Double_t scale) 240 338 { 241 339 TLine *l = dynamic_cast<TLine*>(o); … … 243 341 return; 244 342 245 Double_t x1 = 0.5*w-(l->GetX1()/scale); 246 Double_t x2 = 0.5*w-(l->GetX2()/scale); 247 Double_t y1 = 0.5*h-(l->GetY1()/scale); 248 Double_t y2 = 0.5*h-(l->GetY2()/scale); 249 250 Double_t len = TMath::Hypot(x2-x1, y2-y1); 251 252 Double_t x = x1; 253 Double_t y = y1; 254 255 Int_t step = l->GetLineStyle()==kSolid?1:3; 256 257 Double_t dx = (x2-x1)/len*step; 258 Double_t dy = (y2-y1)/len*step; 259 260 for (int i=0; i<len; i+=step) 261 { 262 x+= dx; 263 y+= dy; 264 265 if (x<0 || y<0 || x>w-1 || y>h-1) 266 continue; 267 268 buf[(int)x+(int)y*w] = Color(l->GetLineColor()); 269 } 343 const Double_t x1 = 0.5*w-(l->GetX1()/scale); 344 const Double_t x2 = 0.5*w-(l->GetX2()/scale); 345 const Double_t y1 = 0.5*h-(l->GetY1()/scale); 346 const Double_t y2 = 0.5*h-(l->GetY2()/scale); 347 348 const Int_t col = Color(l->GetLineColor()); 349 DrawLine(buf, w, h, x1, y1, x2, y2, col, l->GetLineStyle()); 350 } 351 352 void MGMap::DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col) 353 { 354 DrawLine(buf, w, h, cx-size, cy-size, cx+size, cy+size, col); 355 DrawLine(buf, w, h, cx+size, cy-size, cx-size, cy+size, col); 356 } 357 358 void MGMap::DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col) 359 { 360 DrawLine(buf, w, h, cx-size, cy, cx+size, cy, col); 361 DrawLine(buf, w, h, cx, cy-size, cx, cy+size, col); 270 362 } 271 363 … … 275 367 // Currently kCircle, kMultiply and KDot are supported. 276 368 // 277 void MGMap::DrawMarker(TObject *o, unsigned char*buf, int w, int h, Double_t scale)369 void MGMap::DrawMarker(TObject *o, UChar_t *buf, int w, int h, Double_t scale) 278 370 { 279 371 TMarker *m = dynamic_cast<TMarker*>(o); … … 289 381 { 290 382 case kCircle: 291 { 292 Int_t step = 32; 293 294 const Float_t l = (m->GetMarkerSize()*2)+1; 295 for (int i=0; i<step; i++) 296 { 297 const Double_t angle = i*TMath::TwoPi()/step; 298 299 const Double_t x1 = x+l*cos(angle); 300 const Double_t y1 = y+l*sin(angle); 301 302 if (x1<0 || y1<0 || x1>w-1 || y1>h-1) 303 continue; 304 305 buf[(int)x1+(int)y1*w] = col; 306 } 307 } 383 DrawCircle(buf, w, h, x, y, m->GetMarkerSize()*2+1, col); 308 384 break; 309 385 case kDot: 310 if (x>=0 && y>=0 && x<w && y<h) 311 buf[(int)x+(int)y*w] = col; 312 break; 313 386 DrawDot(buf, w, h, x, y, col); 387 break; 314 388 case kMultiply: 315 { 316 const Int_t l = (int)(m->GetMarkerSize()+1); 317 318 for (int i=-l; i<l+1; i++) 319 { 320 Double_t x1 = x+i; 321 Double_t y1 = y+i; 322 if (x1>=0 && y>=0 && x1<w && y<h) 323 buf[(int)x1+(int)y*w] = col; 324 if (x>=0 && y1>=0 && x<w && y1<h) 325 buf[(int)x+(int)y1*w] = col; 326 } 327 } 328 break; 329 389 DrawMultiply(buf, w, h, x, y, m->GetMarkerSize()*2+1, col); 390 break; 391 case kCross: 392 DrawCross(buf, w, h, x, y, m->GetMarkerSize()*2+1, col); 393 break; 330 394 } 331 395 } … … 345 409 // -------------------------------------------------------------------------- 346 410 // 347 // Paint all objects into a buffer of w*h unsigned chars. The scale411 // Paint all objects into a buffer of w*h UChar_ts. The scale 348 412 // gives you the conversio factor to convert pad coordinates into 349 413 // buffer pixels - it is the distance from the center of the buffer 350 414 // to one of its edges. 351 415 // 352 void MGMap::Paint( unsigned char*buf, int w, int h, Float_t scale)416 void MGMap::Paint(UChar_t *buf, int w, int h, Float_t scale) 353 417 { 354 418 scale /= TMath::Hypot((float)w, (float)h)/2; -
trunk/MagicSoft/Mars/mbase/MGMap.h
r4058 r4081 36 36 37 37 void Paint(Option_t *o=""); 38 void Paint( unsigned char*buf, int w, int h, Float_t scale);38 void Paint(UChar_t *buf, int w, int h, Float_t scale); 39 39 //void Paint(Drawable_t id, Float_t scale); 40 40 41 Int_t Color(int col); 42 43 void DrawLine(TObject *o, unsigned char *buf, int w, int h, Double_t scale); 44 void DrawMarker(TObject *o, unsigned char *buf, int w, int h, Double_t scale); 41 void DrawLine(TObject *o, UChar_t *buf, int w, int h, Double_t scale); 42 void DrawMarker(TObject *o, UChar_t *buf, int w, int h, Double_t scale); 45 43 46 44 //void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected); … … 49 47 Int_t DistancetoPrimitive(Int_t px, Int_t py); 50 48 49 static UChar_t Color(int col); 50 static void DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col); 51 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); 52 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); 53 static void DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col); 54 static void DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col); 55 static void DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col); 56 51 57 ClassDef(MGMap, 1) // Special TExMap supporting enhanced drawing and bitmap drawing 52 58 }; -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r3666 r4081 66 66 #include <TVirtualPad.h> // gPad 67 67 68 #include "MString.h" 69 68 70 #include "MLog.h" 69 71 #include "MLogManip.h" … … 197 199 // point to a random memory segment, because the TString has gone. 198 200 // 199 return fName==ClassName() ? ClassName() : Form("%s [%s]", fName.Data(), ClassName()); 201 MString desc; 202 desc.Print("%s [%s]", fName.Data(), ClassName()); 203 return fName==ClassName() ? ClassName() : desc.Data(); 200 204 } 201 205 -
trunk/MagicSoft/Mars/mbase/MString.cc
r4079 r4081 54 54 // string.Print("MyString has %d bytes", 128); 55 55 // 56 // As a special feature the function returns the reference to the MString 57 // so that you can directly work with it, eg. 58 // 59 // string.Print(" MyString has %d bytes ", 128).Strip(TString::kBoth); 60 // 56 61 MString &MString::Print(const char *fmt, ...) 57 62 { -
trunk/MagicSoft/Mars/mbase/MString.h
r4079 r4081 12 12 { 13 13 public: 14 MString &Print(const char *fmt, ...) 15 { 16 va_list ap; 17 va_start(ap, fmt); 14 MString &Print(const char *fmt, ...); 18 15 19 Int_t n=256; 20 21 char *ret=0; 22 23 while (1) 24 { 25 ret = new char[n+1]; 26 Int_t sz = vsnprintf(ret, n, fmt, ap); 27 if (sz<=n) 28 break; 29 30 n *= 2; 31 delete [] ret; 32 }; 33 34 va_end(ap); 35 36 *static_cast<TString*>(this) = ret; 37 38 delete [] ret; 39 40 return *this; 41 } 42 ClassDef(MString, 1) 16 ClassDef(MString, 1) // Tool to make Form() thread safe against other TStrings 43 17 }; 44 18 -
trunk/MagicSoft/Mars/mbase/Makefile
r4058 r4081 20 20 SRCFILES = MLogo.cc \ 21 21 MArgs.cc \ 22 MString.cc \ 22 23 MMath.cc \ 23 24 MLog.cc \
Note:
See TracChangeset
for help on using the changeset viewer.