- Timestamp:
- 12/12/05 12:23:59 (19 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7448 r7450 18 18 19 19 -*-*- END OF LINE -*-*- 20 2005/12/12 Thomas Bretz 21 22 * mbase/MEnv.[h,cc]: 23 - added new Setter functions 24 - added a Clone function (TEnv cannot be streamed) 25 - added a data member to store the filename because fRcName cannot 26 be accessed 27 28 * mbase/MTime.[h,cc]: 29 - added Getter DayofYear() 30 - added Getter Week() 31 - added Getter IsLeapYear() 32 33 * mjobs/MDataSet.cc: 34 - simplified reading the catlog file by using TString::Tokenize 35 36 37 20 38 2005/12/06 Daniela Dorner 21 39 -
trunk/MagicSoft/Mars/mbase/MEnv.cc
r7442 r7450 39 39 #include <TPave.h> 40 40 #include <TAttText.h> 41 //#include <TAttFill.h>42 //#include <TAttLine.h>43 41 #include <TAttMarker.h> 44 42 … … 50 48 using namespace std; 51 49 50 //--------------------------------------------------------------------------- 51 // 52 // Compile str+post and make sure that in between there is a unique dot. 53 // 54 TString MEnv::Compile(TString str, const char *post) const 55 { 56 if (!str.IsNull() && !str.EndsWith(".")) 57 str += "."; 58 59 str += post; 60 61 return str; 62 } 63 64 //--------------------------------------------------------------------------- 65 // 66 // Get the value from the table and remember the value as checked 67 // 52 68 Int_t MEnv::GetValue(const char *name, Int_t dflt) 53 69 { … … 57 73 } 58 74 75 //--------------------------------------------------------------------------- 76 // 77 // Get the value from the table and remember the value as checked 78 // 59 79 Double_t MEnv::GetValue(const char *name, Double_t dflt) 60 80 { … … 64 84 } 65 85 86 //--------------------------------------------------------------------------- 87 // 88 // Get the value from the table and remember the value as checked 89 // 66 90 const char *MEnv::GetValue(const char *name, const char *dflt) 67 91 { … … 71 95 } 72 96 97 //--------------------------------------------------------------------------- 98 // 99 // TEnv doen't have a streamer --> cannot be cloned 100 // --> we have to clone it ourself 101 // 102 TObject *MEnv::Clone(const char *newname) const 103 { 104 MEnv *env = new MEnv("/dev/null"); 105 env->fName = fName; 106 env->AddEnv(*this); 107 return env; 108 } 109 110 //--------------------------------------------------------------------------- 111 // 112 // Interprete fill style: Hollow, Solid, Hatch, 0%-100% 113 // If no text style is detected the value is converted to an integer. 114 // 73 115 Int_t MEnv::GetFillStyle(const char *name, Int_t dftl) 74 116 { … … 90 132 } 91 133 92 Int_t MEnv::GetColor(const char *name, Int_t dftl) 134 //--------------------------------------------------------------------------- 135 // 136 // Interprete line style: Solid, Dashed, Dotted, DashDotted 137 // If no line style is detected the value is converted to an integer. 138 // 139 Int_t MEnv::GetLineStyle(const char *name, Int_t dftl) 93 140 { 94 141 TString str = GetValue(name, ""); 95 96 142 str = str.Strip(TString::kBoth); 97 143 if (str.IsNull()) … … 102 148 switch (str.Hash()) 103 149 { 104 case (unsigned)-1926423925/*2368543371*/: return kWhite; 105 case 1814927399: return kBlack; 106 case 7496964: return kRed; 107 case (unsigned)-1397860222/*2897107074*/: return kGreen; 108 case 1702194402: return kBlue; 109 case (unsigned)-1920149414/* 2374817882*/: return kYellow; 110 case (unsigned)-1400748595/*2894218701*/: return kMagenta; 111 case 1851881955: return kCyan; 150 case 764279305: return kSolid; 151 case 241979881: return kDashed; 152 case (unsigned)-1903324694: return kDotted; 153 case 1124931659: return kDashDotted; 154 } 155 156 return str.Atoi(); 157 } 158 159 //--------------------------------------------------------------------------- 160 // 161 // Interprete alignment: Top, Right, Left, Bottom, Center, tr, cc, bl, ... 162 // If no text align is detected the value is converted to an integer. 163 // 164 // eg. 165 // Top Right 166 // Bottom Center 167 // Center 168 // tr 169 // br 170 // cr 171 // 172 Int_t MEnv::GetAlign(const char *name, Int_t dftl) 173 { 174 TString str = GetValue(name, ""); 175 str = str.Strip(TString::kBoth); 176 if (str.IsNull()) 177 return dftl; 178 179 str.ToLower(); 180 181 switch (str.Hash()) 182 { 183 case 29746: return 33; // tr 184 case 25379: return 22; // cc 185 case 25132: return 11; // bl 186 187 case 25388: return 12; // cl 188 case 25394: return 32; // cr 189 190 case 29731: return 23; // tc 191 case 25123: return 32; // bc 192 193 case 29740: return 13; // tl 194 case 25138: return 13; // br 195 } 196 197 Int_t align = 0; 198 if (str.Contains("right", TString::kIgnoreCase)) 199 align += 3; 200 if (str.Contains("left", TString::kIgnoreCase)) 201 align += 1; 202 if (str.Contains("bottom", TString::kIgnoreCase)) 203 align += 10; 204 if (str.Contains("top", TString::kIgnoreCase)) 205 align += 30; 206 207 if (str.Contains("center", TString::kIgnoreCase)) 208 { 209 if (align==0) 210 return 22; 211 if (align/10==0) 212 return align+20; 213 if (align%10==0) 214 return align+2; 215 } 216 217 return align>0 ? align : str.Atoi(); 218 } 219 220 //--------------------------------------------------------------------------- 221 // 222 // Interprete color: Black, White, Red, Green, Blue, Yellow, Magenta, 223 // Cyan, Gray1-5, Grey1-5. 224 // If no text color is detected the value is converted to an integer. 225 // 226 // eg. 227 // Red 228 // Light Red 229 // Dark Red 230 // 231 Int_t MEnv::GetColor(const char *name, Int_t dftl) 232 { 233 TString str = GetValue(name, ""); 234 235 str = str.Strip(TString::kBoth); 236 if (str.IsNull()) 237 return dftl; 238 239 str.ToLower(); 240 241 Int_t offset=0; 242 if (str.Contains("dark")) 243 { 244 str.ReplaceAll("dark", ""); 245 str = str.Strip(TString::kBoth); 246 offset = 100; 247 } 248 if (str.Contains("light")) 249 { 250 str.ReplaceAll("light", ""); 251 str = str.Strip(TString::kBoth); 252 offset = 150; 253 } 254 255 switch (str.Hash()) 256 { 257 case (unsigned)-1926423925/*2368543371*/: return kWhite+offset; 258 case 1814927399: return kBlack+offset; 259 case 7496964: return kRed+offset; 260 case (unsigned)-1397860222/*2897107074*/: return kGreen+offset; 261 case 1702194402: return kBlue+offset; 262 case (unsigned)-1920149414/* 2374817882*/: return kYellow+offset; 263 case (unsigned)-1400748595/*2894218701*/: return kMagenta+offset; 264 case 1851881955: return kCyan+offset; 112 265 case 749623518: return 18; // grey1 113 266 case 749623517: return 17; // grey2 … … 124 277 } 125 278 126 TString MEnv::Compile(TString str, const char *post) const 127 { 128 if (!str.IsNull() && !str.EndsWith(".")) 129 str += "."; 130 131 str += post; 132 133 return str; 134 } 135 279 //--------------------------------------------------------------------------- 280 // 281 // As possible convert the color col into a text string which can be 282 // interpreted by GetColor before setting the resource value 283 // 284 void MEnv::SetColor(const char *name, Int_t col) 285 { 286 TString val; 287 288 if (col>99 && col<101+kCyan) 289 { 290 val = "Dark "; 291 col -= 100; 292 } 293 if (col>150 && col<151+kCyan) 294 { 295 val = "Light "; 296 col -= 150; 297 } 298 299 switch (col) 300 { 301 case kWhite: val += "White"; break; 302 case kBlack: val += "Black"; break; 303 case kRed: val += "Red"; break; 304 case kGreen: val += "Green"; break; 305 case kBlue: val += "Blue"; break; 306 case kYellow: val += "Yellow"; break; 307 case kMagenta: val += "Magenta"; break; 308 case kCyan: val += "Cyan"; break; 309 case 18: val += "White"; break; 310 case 17: val += "White"; break; 311 case 16: val += "White"; break; 312 case 15: val += "White"; break; 313 case 14: val += "White"; break; 314 } 315 316 if (val.IsNull()) 317 val += col; 318 319 SetValue(name, val); 320 } 321 322 //--------------------------------------------------------------------------- 323 // 324 // As possible convert the alignment align into a text string which can be 325 // interpreted by GetAlign before setting the resource value 326 // 327 void MEnv::SetAlign(const char *name, Int_t align) 328 { 329 TString val; 330 if (align==22) 331 { 332 SetValue(name, "Center"); 333 return; 334 } 335 336 switch (align%10) 337 { 338 case 1: val += "Left"; break; 339 case 2: val += "Center"; break; 340 case 3: val += "Right"; break; 341 } 342 343 switch (align/10) 344 { 345 case 1: val += "Bottom"; break; 346 case 2: val += "Center"; break; 347 case 3: val += "Top"; break; 348 } 349 350 SetValue(name, val); 351 } 352 353 //--------------------------------------------------------------------------- 354 // 355 // As possible convert the fill style style into a text string which can be 356 // interpreted by GetFillStyle before setting the resource value 357 // 358 void MEnv::SetFillStyle(const char *name, Int_t style) 359 { 360 TString val; 361 362 if (style>3999 && style<4101) 363 val = Form("%d%%", style-4000); 364 365 switch (style) 366 { 367 case 0: val = "Hollow"; break; 368 case 1001: val = "Solid"; break; 369 case 2001: val = "Hatch"; break; 370 } 371 372 if (val.IsNull()) 373 val += style; 374 375 SetValue(name, val); 376 } 377 378 //--------------------------------------------------------------------------- 379 // 380 // As possible convert the line style style into a text string which can be 381 // interpreted by GetLineStyle before setting the resource value 382 // 383 void MEnv::SetLineStyle(const char *name, Int_t style) 384 { 385 TString val; 386 switch (style) 387 { 388 case kSolid: val = "Solid"; break; 389 case kDashed: val = "Dashed"; break; 390 case kDotted: val = "Dotted"; break; 391 case kDashDotted: val = "DashDotted"; break; 392 } 393 394 if (val.IsNull()) 395 val += style; 396 397 SetValue(name, val); 398 } 399 400 //--------------------------------------------------------------------------- 401 // 402 // As possible convert the marker style style into a text string which can be 403 // interpreted by GetLineStyle before setting the resource value 404 // 405 void MEnv::SetMarkerStyle(const char *name, Int_t style) 406 { 407 TString val; 408 switch (style) 409 { 410 case kDot: val = "dot"; 411 case kPlus: val = "plus"; 412 case kCircle: val = "circle"; 413 case kMultiply: val = "multiply"; 414 case kFullDotSmall: val = "fulldotsmall"; 415 case kFullDotMedium: val = "fulldotmedium"; 416 case kFullDotLarge: val = "fulldotlarge"; 417 case kOpenTriangleDown: val = "opentriangledown"; 418 case kFullCross: val = "fullcross"; 419 case kFullCircle: val = "fullcircle"; 420 case kFullSquare: val = "fullsquare"; 421 case kFullTriangleDown: val = "fulltriangledown"; 422 case kOpenCircle: val = "opencircle"; 423 case kOpenSquare: val = "opensquare"; 424 case kOpenTriangleUp: val = "opentriangleup"; 425 case kOpenDiamond: val = "opendiamond"; 426 case kOpenCross: val = "opencross"; 427 case kFullStar: val = "fullstar"; 428 case kOpenStar: val = "openstar"; 429 } 430 431 if (val.IsNull()) 432 val += style; 433 434 SetValue(name, val); 435 } 436 437 //--------------------------------------------------------------------------- 438 // 439 // Get the attributed from a TAttLine (if dftl is given use it as default) 440 // name.LineColor <see also GetColor> 441 // name.LineStyle 442 // name.LineWidth 443 // For more details on the meaning see TAttLine 444 // 136 445 void MEnv::GetAttLine(const char *name, TAttLine &line, TAttLine *dftl) 137 446 { … … 144 453 145 454 const Color_t col = GetColor(color, dftl->GetLineColor()); 146 const Style_t sty = Get Value(style, dftl->GetLineStyle());455 const Style_t sty = GetLineStyle(style, dftl->GetLineStyle()); 147 456 const Style_t wid = GetValue(width, dftl->GetLineWidth()); 148 457 … … 152 461 } 153 462 463 //--------------------------------------------------------------------------- 464 // 465 // Get the attributed from a TAttText (if dftl is given use it as default) 466 // name.TextColor <see also GetColor> 467 // name.TextAlign <see also GetAlign> 468 // name.TextAngle 469 // name.TextFont 470 // name.TextSize 471 // For more details on the meaning see TAttText 472 // 154 473 void MEnv::GetAttText(const char *name, TAttText &text, TAttText *dftl) 155 474 { … … 164 483 165 484 const Color_t col = GetColor(color, dftl->GetTextColor()); 166 const Short_t ali = Get Value(align, dftl->GetTextAlign());485 const Short_t ali = GetAlign(align, dftl->GetTextAlign()); 167 486 const Float_t ang = GetValue(angle, dftl->GetTextAngle()); 168 487 const Font_t fon = GetValue(font, dftl->GetTextFont()); … … 176 495 } 177 496 497 //--------------------------------------------------------------------------- 498 // 499 // Get the attributed from a TAttFill (if dftl is given use it as default) 500 // name.FillColor <see also GetColor> 501 // name.FillStyle <see also GetFillStyle> 502 // For more details on the meaning see TAttFill 503 // 178 504 void MEnv::GetAttFill(const char *name, TAttFill &fill, TAttFill *dftl) 179 505 { … … 191 517 } 192 518 519 //--------------------------------------------------------------------------- 520 // 521 // Get the attributed from a TAttMarker (if dftl is given use it as default) 522 // name.MarkerColor <see also GetColor> 523 // name.MarkerStyle 524 // name.MarkerSize 525 // For more details on the meaning see TAttMarker 526 // 193 527 void MEnv::GetAttMarker(const char *name, TAttMarker &marker, TAttMarker *dftl) 194 528 { … … 209 543 } 210 544 545 //--------------------------------------------------------------------------- 546 // 547 // Get the attributed from a TPave (if dftl is given use it as default) 548 // name.CornerRadius 549 // name.BorderSize 550 // name.Option 551 // Also all resources from TAttLine and TAttFill are supported. 552 // 553 // For your conveinience: If the CornerRadius is greater than 0 "arc" is 554 // added to the options. If it is equal or less than 0 "arc" is removed 555 // from the options. 556 // 557 // For more details on the meaning see TPave 558 // 211 559 void MEnv::GetAttPave(const char *str, TPave &pave, TPave *dftl) 212 560 { … … 248 596 } 249 597 598 //--------------------------------------------------------------------------- 599 // 600 // Get the attributed for the TObject obj. Use dftl for default attributes 601 // if given. 602 // 603 // There is support for: 604 // TPave <see GetAttPave> 605 // TAttLine <see GetAttLine> 606 // TAttText <see GetAttText> 607 // TAttFill <see GetAttFill> 608 // TAttMarker <see GetAttMarker> 609 // 250 610 void MEnv::GetAttributes(const char *name, TObject *obj, TObject *dftl) 251 611 { … … 263 623 //TAttTextEditor *line = dynamic_cast<TAttTextEditor*>(obj); 264 624 265 TPave *pave = dynamic_cast<TPave*>(/*(TAttLine*)*/obj); 266 TAttLine *line = dynamic_cast<TAttLine*>(/*(TAttLine*)*/obj); 267 TAttText *text = dynamic_cast<TAttText*>(/*(TAttText*)*/obj); 268 TAttFill *fill = dynamic_cast<TAttFill*>(/*(TAttFill*)*/obj); 269 TAttMarker *mark = dynamic_cast<TAttMarker*>(/*(TAttMarker*)*/obj); 270 271 cout << line << " " << text << " " << fill << " " << mark << endl; 625 TPave *pave = dynamic_cast<TPave*>(obj); 626 TAttLine *line = dynamic_cast<TAttLine*>(obj); 627 TAttText *text = dynamic_cast<TAttText*>(obj); 628 TAttFill *fill = dynamic_cast<TAttFill*>(obj); 629 TAttMarker *mark = dynamic_cast<TAttMarker*>(obj); 272 630 273 631 if (pave) … … 278 636 279 637 if (line) 280 GetAttLine(name, *line, dynamic_cast<TAttLine*>( /*(TAttLine*)*/dftl));638 GetAttLine(name, *line, dynamic_cast<TAttLine*>(dftl)); 281 639 if (text) 282 GetAttText(name, *text, dynamic_cast<TAttText*>( /*(TAttText*)*/dftl));640 GetAttText(name, *text, dynamic_cast<TAttText*>(dftl)); 283 641 if (fill) 284 GetAttFill(name, *fill, dynamic_cast<TAttFill*>( /*(TAttFill*)*/dftl));642 GetAttFill(name, *fill, dynamic_cast<TAttFill*>(dftl)); 285 643 if (mark) 286 GetAttMarker(name, *mark, dynamic_cast<TAttMarker*>(/*(TAttMarker*)*/dftl)); 287 } 288 644 GetAttMarker(name, *mark, dynamic_cast<TAttMarker*>(dftl)); 645 } 646 647 //--------------------------------------------------------------------------- 648 // 649 // Set the resources from a TAttLine: 650 // name.LineColor <see also SetColor> 651 // name.LineStyle 652 // name.LineWidth 653 // 654 void MEnv::SetAttLine(const char *name, const TAttLine &line) 655 { 656 const TString color = Compile(name, "LineColor"); 657 const TString style = Compile(name, "LineStyle"); 658 const TString width = Compile(name, "LineWidth"); 659 660 SetColor(color, line.GetLineColor()); 661 SetLineStyle(style, line.GetLineStyle()); 662 SetValue(width, line.GetLineWidth()); 663 } 664 665 //--------------------------------------------------------------------------- 666 // 667 // Set the resources from a TAttText: 668 // name.TextColor <see also SetColor> 669 // name.TextAlign <see also SetAlign> 670 // name.TextAngle 671 // name.TextFont 672 // name.TextSize 673 // 674 void MEnv::SetAttText(const char *name, const TAttText &text) 675 { 676 const TString color = Compile(name, "TextColor"); 677 const TString align = Compile(name, "TextAlign"); 678 const TString angle = Compile(name, "TextAngle"); 679 const TString font = Compile(name, "TextFont"); 680 const TString size = Compile(name, "TextSize"); 681 682 SetColor(color, text.GetTextColor()); 683 SetAlign(align, text.GetTextAlign()); 684 SetValue(angle, text.GetTextAngle()); 685 SetValue(font, text.GetTextFont()); 686 SetValue(size, text.GetTextSize()); 687 } 688 689 //--------------------------------------------------------------------------- 690 // 691 // Set the resources from a TAttFill: 692 // name.FillColor <see also SetColor> 693 // name.FillStyle <see also SetFillStyle> 694 // 695 void MEnv::SetAttFill(const char *name, const TAttFill &fill) 696 { 697 const TString color = Compile(name, "FillColor"); 698 const TString style = Compile(name, "FillStyle"); 699 700 SetColor(color, fill.GetFillColor()); 701 SetFillStyle(style, fill.GetFillStyle()); 702 } 703 704 //--------------------------------------------------------------------------- 705 // 706 // Set the resources from a TAttMarker: 707 // name.MarkerColor <see also SetColor> 708 // name.MarkerStyle 709 // name.MarkerSize 710 // 711 void MEnv::SetAttMarker(const char *name, const TAttMarker &marker) 712 { 713 const TString color = Compile(name, "MarkerColor"); 714 const TString style = Compile(name, "MarkerStyle"); 715 const TString size = Compile(name, "MarkerSize"); 716 717 SetColor(color, marker.GetMarkerColor()); 718 SetMarkerStyle(style, marker.GetMarkerStyle()); 719 SetValue(size, marker.GetMarkerSize()); 720 } 721 722 //--------------------------------------------------------------------------- 723 // 724 // Set the resources from a TPave: 725 // name.CornerRadius 726 // name.BorderSize 727 // name.Option 728 // Also all resources from TAttLine and TAttFill are supported. 729 // 730 void MEnv::SetAttPave(const char *str, const TPave &pave) 731 { 732 const TString name(str); 733 734 SetAttLine(name, pave); 735 SetAttFill(name, pave); 736 737 const TString corner = Compile(name, "CornerRadius"); 738 const TString border = Compile(name, "BorderSize"); 739 const TString option = Compile(name, "Option"); 740 741 SetValue(corner, const_cast<TPave&>(pave).GetCornerRadius()); 742 SetValue(border, const_cast<TPave&>(pave).GetBorderSize()); 743 SetValue(option, pave.GetOption()); 744 } 745 746 //--------------------------------------------------------------------------- 747 // 748 // Set the attributed for the TObject obj. 749 // 750 // There is support for: 751 // TPave <see SetAttPave> 752 // TAttLine <see SetAttLine> 753 // TAttText <see SetAttText> 754 // TAttFill <see SetAttFill> 755 // TAttMarker <see SetAttMarker> 756 // 757 void MEnv::SetAttributes(const char *name, const TObject *obj) 758 { 759 const TPave *pave = dynamic_cast<const TPave*>(obj); 760 const TAttLine *line = dynamic_cast<const TAttLine*>(obj); 761 const TAttText *text = dynamic_cast<const TAttText*>(obj); 762 const TAttFill *fill = dynamic_cast<const TAttFill*>(obj); 763 const TAttMarker *mark = dynamic_cast<const TAttMarker*>(obj); 764 765 if (pave) 766 { 767 SetAttPave(name, *pave); 768 return; 769 } 770 771 if (line) 772 SetAttLine(name, *line); 773 if (text) 774 SetAttText(name, *text); 775 if (fill) 776 SetAttFill(name, *fill); 777 if (mark) 778 SetAttMarker(name, *mark); 779 } 780 781 //--------------------------------------------------------------------------- 782 // 783 // Add all values from TEnv env the this MEnv. To not overwrite existing 784 // values set overwrite to kFALSE 785 // 786 void MEnv::AddEnv(const TEnv &env, Bool_t overwrite) 787 { 788 if (!GetTable() || !env.GetTable()) 789 return; 790 791 TIter Next(env.GetTable()); 792 793 TEnvRec *er; 794 while ((er = (TEnvRec*)Next())) 795 { 796 if (overwrite || !Defined(er->GetName())) 797 SetValue(er->GetName(), er->GetValue(), er->GetLevel(), er->GetType()); 798 } 799 } 800 801 //--------------------------------------------------------------------------- 802 // 803 // Print resources which have never been touched (for debugging) 804 // 289 805 void MEnv::PrintUntouched() const 290 806 { -
trunk/MagicSoft/Mars/mbase/MEnv.h
r7442 r7450 21 21 TOrdCollection fChecked; 22 22 23 TString fName; // A workaround! 24 23 25 TString Compile(TString str, const char *post) const; 24 26 25 27 public: 26 MEnv(const char *name="") : TEnv(name) { fChecked.SetOwner(); } 28 MEnv(const char *name="") : TEnv(name), fName(name) { fChecked.SetOwner(); } 29 30 TObject *Clone(const char *newname="") const; 27 31 28 32 Int_t GetValue(const char *name, Int_t dflt); … … 30 34 const char *GetValue(const char *name, const char *dflt); 31 35 36 const char *GetName() const { return fName; } 37 32 38 Int_t GetColor(const char *name, Int_t dftl); 39 Int_t GetAlign(const char *name, Int_t dftl); 33 40 Int_t GetFillStyle(const char *name, Int_t dftl); 41 Int_t GetLineStyle(const char *name, Int_t dftl); 34 42 35 43 void GetAttributes(const char *name, TObject *obj, TObject *dftl=0); … … 40 48 void GetAttPave(const char *name, TPave &pave, TPave *dftl=0); 41 49 50 void SetColor(const char *name, Int_t col); 51 void SetAlign(const char *name, Int_t align); 52 void SetFillStyle(const char *name, Int_t style); 53 void SetLineStyle(const char *name, Int_t style); 54 void SetMarkerStyle(const char *name, Int_t style); 55 56 void SetAttributes(const char *name, const TObject *obj); 57 void SetAttLine(const char *name, const TAttLine &line); 58 void SetAttText(const char *name, const TAttText &text); 59 void SetAttFill(const char *name, const TAttFill &fill); 60 void SetAttMarker(const char *name, const TAttMarker &marker); 61 void SetAttPave(const char *name, const TPave &pave); 62 63 void AddEnv(const TEnv &env, Bool_t overwrite=kTRUE); 64 42 65 void PrintUntouched() const; 43 66 -
trunk/MagicSoft/Mars/mbase/MTime.cc
r7442 r7450 460 460 461 461 return fmod(sum, 1)*TMath::TwoPi();//+TMath::TwoPi(); 462 } 463 464 // -------------------------------------------------------------------------- 465 // 466 // Get the day of the year represented by day, month and year. 467 // Valid return values range between 1 and 366, where January 1 = 1. 468 // 469 UInt_t MTime::DayOfYear() const 470 { 471 MTime jan1st; 472 jan1st.Set(Year(), 1, 1); 473 474 const Double_t newyear = TMath::Floor(jan1st.GetMjd()); 475 const Double_t mjd = TMath::Floor(GetMjd()); 476 477 return TMath::Nint(mjd-newyear)+1; 478 } 479 480 // -------------------------------------------------------------------------- 481 // 482 // Get the week of the year. Valid week values are between 1 and 53. 483 // 54 is returned if the day belongs to Week=1 of the next year, 484 // 0 if it belongs to the Week=53 and -1 if it belongs to the Week=52 485 // of the last year (In this case there is no week 53!) 486 // 487 Int_t MTime::Week() const 488 { 489 static const Int_t kFrSaSo = BIT(kFriday) | BIT(kSaturday) | BIT(kSunday); 490 static const Int_t kTuWeTh = BIT(kTuesday) | BIT(kWednesday) | BIT(kThursday); 491 492 MTime t; 493 t.Set(Year(), 1, 1); 494 495 // The weekday of Jan 1st. 496 const Int_t day1st = 1<<t.WeekDay(); 497 498 // The number of weeks since the first Monday in the year 499 Int_t week = (DayOfYear()-1 + (t.WeekDay()+6)%7) / 7 + 1; 500 501 // Correct the week number if the year has started with Fr, Sa or So 502 if (day1st & kFrSaSo) 503 week--; 504 505 // If the week number is 53 it might already belong to the next year 506 if (week == 53) 507 { 508 t.Set(Year()+1, 1, 1); 509 510 const Int_t daynext = 1<<t.WeekDay(); 511 return daynext&kTuWeTh ? 54 : 53; 512 } 513 514 // If the week number is 53 it might still belong to the last year 515 if (week == 0) 516 { 517 t.Set(Year()-1, 1, 1); 518 519 const Int_t dayprev = 1<<t.WeekDay(); 520 return !(dayprev&kFrSaSo) && (day1st&kFrSaSo) ? 0 : -1; 521 } 522 523 return week; 524 } 525 526 // -------------------------------------------------------------------------- 527 // 528 // Is the given year a leap year. 529 // The calendar year is 365 days long, unless the year is exactly divisible 530 // by 4, in which case an extra day is added to February to make the year 531 // 366 days long. If the year is the last year of a century, eg. 1700, 1800, 532 // 1900, 2000, then it is only a leap year if it is exactly divisible by 533 // 400. Therefore, 1900 wasn't a leap year but 2000 was. The reason for 534 // these rules is to bring the average length of the calendar year into 535 // line with the length of the Earth's orbit around the Sun, so that the 536 // seasons always occur during the same months each year. 537 // 538 Bool_t MTime::IsLeapYear() const 539 { 540 const UInt_t y = Year(); 541 return (y%4==0) && !((y%100==0) && (y%400>0)); 462 542 } 463 543 -
trunk/MagicSoft/Mars/mbase/MTime.h
r7432 r7450 29 29 static const UInt_t kHour; // [ms] one hour 30 30 static const UInt_t kDay; // [ms] one day 31 32 enum { 33 kSunday, kMonday, kTuesday, kWednesday, kThursday, kFriday, kSaturday 34 }; 31 35 32 36 private: … … 120 124 UInt_t Min() const { Byte_t h, m, s; GetTime(h,m,s); return m; } 121 125 UInt_t Sec() const { Byte_t h, m, s; GetTime(h,m,s); return s; } 126 UInt_t DayOfYear() const; 127 Int_t Week() const; 122 128 123 129 Bool_t IsMidnight() const { return (Long_t)fTime==0 && fNanoSec==0; } 130 Bool_t IsLeapYear() const; 124 131 125 132 // I/O functions
Note:
See TracChangeset
for help on using the changeset viewer.