Changeset 7893 for trunk/MagicSoft/Mars
- Timestamp:
- 08/19/06 22:42:34 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/tutorials/calendar.rc
r7892 r7893 18 18 19 19 # define descriptions for your images 20 01.Text: All File types supported by TASImage are supported 21 02.Text: 22 03.Text: 23 04.Text: 24 05.Text: 25 06.Text: 20 01.Text: All File types supported by TASImage are supported. 21 02.Text: Please try to use the context menu on the small boxes. 22 03.Text: Choose SetDefaultLayout from the context menu. 23 04.Text: Play around with th eoptions in the context menu. 24 05.Text: Parts of the context menu are sensitive to the mouse position. 25 06.Text: To create a postscript file of your calendar change the macro. 26 26 07.Text: 27 27 08.Text: -
trunk/MagicSoft/Mars/mtools/MCalendar.cc
r7451 r7893 81 81 // 82 82 // The contents of each pave in your calendar. 83 // Contents: Date Day Holiday Easter Birthday 84 // 85 // You can setup the contents by their names individually. The possible 86 // Style is defined by a TLatex object. For more details see TLatex or 87 // MEnv::GetAttText. 83 // Contents: Date Day Week Holiday Birthday 84 // 85 // There are NO predefined content-strings. All the names given here 86 // are completely artificial. You could also call them just A and B. 87 // If you setup them correctly they might still behave like Date and Day. 88 // This also means that you can define as many of them as you want. 89 // 90 // You can setup the contents by their names individually (eg. Holiday). 91 // The possible Style is defined by a TLatex object. For more details 92 // see TLatex or MEnv::GetAttText. 88 93 // 89 94 // To setup the position in the pave use: … … 101 106 // Holiday.Format: %a 102 107 // 103 // Contents for which a format was setup are build using MTime::GetStringFmt. 104 // Contents without a format set are searched in the holiday resource. 108 // Contents for which a format was setup are compiled by using 109 // MTime::GetStringFmt. 110 // Contents without a format set (by eg. Holiday.Format) are searched in 111 // the holiday resource file: 105 112 // 106 113 // For the 1.1. and 25.12. the setup could be: … … 108 115 // Holiday.12/25: Christmas 109 116 // 110 // If the contents name is "Easter" the search is done relative to Easter:111 // Easter.-1: Easter Saturday112 // Easter.0: Easter113 // Easter.1: Easter Monday114 // 115 // In addition to this you can overwrite the thisdefault for the active117 // Holidays with respect to Easter are given as 118 // Holiday.-1: Easter Saturday 119 // Holiday.0: Easter 120 // Holiday.1: Easter Monday 121 // 122 // In addition to this you can overwrite the default for the active 116 123 // and/or inactivedays by: 117 124 // Date.Active.{PaveStyle} … … 146 153 // change the Layout. For more details see section "Resource Files" 147 154 // 148 // void ResetLayout() 149 // Remove everything from the layout 155 // void ResetLayout(num) 156 // Remove everything from the layout. num is the number of default blocks 157 // (corresponding to NumBlocks). A value smaller or equal 0 will leave 158 // the number of block unchanged (which is the default from the 159 // context menu) 150 160 // 151 161 // void ResetHolidays() 152 162 // remove all holidays. 153 163 // 154 // void SetDefaultLayout() 155 // set the layout to the default layout 164 // void SetDefaultLayout(num) 165 // set the layout to the default layout. num is the number of displayed 166 // blocks (corresponding to NumBlocks). A value smaller or equal 0 will 167 // leave the number of block unchanged (which is the default from the 168 // context menu) 156 169 // 157 170 // void SetDefaultHolidays() … … 185 198 // void SetEaster(Float_t FontSize=0.13, Int_t Color=kBlue) 186 199 // set the current position in the pave to a holiday with name 187 // "Holiday", "Birthday" or "Easter". The holidays are read from the200 // "Holiday", "Birthday". The holidays are read from the 188 201 // holiday resource file. For more details see section "Resource files" 189 202 // … … 191 204 // void AddBirthday(const char *text) 192 205 // void AddEaster(const char *text) 193 // Add a holiday ("Holiday.mm/dd", "Birthday.mm/dd" or " Easter.%d")206 // Add a holiday ("Holiday.mm/dd", "Birthday.mm/dd" or "Holiday.%d") 194 207 // for the current date (for easter the offset to easter is used instead) 195 208 // to the holiday resources. … … 239 252 240 253 #include <TStyle.h> 254 #include <TArrow.h> 241 255 #include <TLatex.h> 256 #include <TMarker.h> 242 257 #include <TArrayD.h> 243 258 #include <TCanvas.h> … … 246 261 #include <TASImage.h> 247 262 #include <TPaveText.h> 263 #include <THashList.h> 248 264 249 265 #include "MEnv.h" … … 359 375 def.SetLineStyle(kSolid); 360 376 def.SetLineColor(kBlack); 361 def.SetLineWidth( 1);377 def.SetLineWidth(0); 362 378 def.SetFillColor(18); 363 379 def.SetFillStyle(1001); … … 486 502 487 503 env.SetValue("Orientation", fOrientation); 504 env.SetValue("Rotation", fRotation); 488 505 489 506 env.SetValue("Moon.Graf.Align", fMoonAlignGraf); … … 532 549 const TString name = fname ? fname : fEnv->GetName(); 533 550 534 ResetLayout( );551 ResetLayout(2); 535 552 536 553 delete fEnv; … … 541 558 542 559 fOrientation = fEnv->GetValue("Orientation", fOrientation); 560 fRotation = fEnv->GetValue("Rotation", fOrientation); 543 561 544 562 fMoonAlignGraf = fEnv->GetValue("Moon.Graf.Align", fMoonAlignGraf); … … 576 594 // Reset the layout (remove everything) 577 595 // 578 void MCalendar::ResetLayout() 596 // num is the number of default blocks (corresponding to NumBlocks). 597 // A value smaller or equal 0 will leave the number of block unchanged 598 // (which is the default) 599 // 600 void MCalendar::ResetLayout(Int_t num) 579 601 { 580 602 fOrientation = kFALSE; 603 fRotation = kFALSE; 581 604 582 605 fFirstDay = 1; 583 fNumBlocks = 2; 606 607 if (num>0) 608 fNumBlocks = num; 584 609 585 610 fMoonAlignGraf = 0; … … 621 646 ResetHolidays(); 622 647 623 fEnvHolidays->SetValue(" Easter.0","Easter");648 fEnvHolidays->SetValue("Holiday.0", "Easter"); 624 649 fEnvHolidays->SetValue("Holiday.01/01", "New Year"); 625 650 fEnvHolidays->SetValue("Holiday.12/25", "Christmas"); … … 631 656 // Set the layout to the default layout 632 657 // 633 void MCalendar::SetDefaultLayout() 634 { 635 ResetLayout(); 658 // num is the number of default blocks (corresponding to NumBlocks). 659 // A value smaller or equal 0 will leave the number of block unchanged 660 // (which is the default) 661 // 662 void MCalendar::SetDefaultLayout(Int_t num) 663 { 664 ResetLayout(num); 636 665 637 666 fMoonAlignGraf = 11; 638 667 fMoonAlignText = 11; 639 668 640 fEnv->SetValue("Contents", "Day Date Holiday Birthday Easter"); 641 642 fEnv->SetValue("Day.TextAlign", "top left"); 643 fEnv->SetValue("Day.Format", "%e"); 644 645 fEnv->SetValue("Date.TextAlign", "bottom right"); 646 fEnv->SetValue("Date.Format", "%a"); 647 648 fEnv->SetValue("Holiday.TextAlign", "center"); 649 fEnv->SetValue("Holiday.TextSize", 0.13); 650 fEnv->SetValue("Holiday.TextColor", kBlue); 651 652 fEnv->SetValue("Birthday.TextAlign", "center"); 653 fEnv->SetValue("Birthday.TextSize", 0.13); 654 fEnv->SetValue("Birthday.TextColor", kBlue); 655 656 fEnv->SetValue("Easter.TextAlign", "center"); 657 fEnv->SetValue("Easter.TextSize", 0.13); 658 fEnv->SetValue("Easter.TextColor", kBlue); 669 fEnv->SetValue("Contents", "Day Date Week Holiday Birthday"); 670 671 fEnv->SetValue("Day.TextAlign", "top left"); 672 fEnv->SetValue("Day.Format", "%e"); 673 674 fEnv->SetValue("Date.TextAlign", "bottom right"); 675 fEnv->SetValue("Date.Format", "%a"); 676 677 fEnv->SetValue("Week.TextAlign", "top right"); 678 fEnv->SetValue("Week.Format", "KW%V"); 679 fEnv->SetValue("Week.TextSize", 0.1); 680 fEnv->SetValue("Week.Restriction", 1); 681 fEnv->SetValue("Week.Active.TextColor", "Grey8"); 682 683 fEnv->SetValue("Holiday.TextAlign", "center"); 684 fEnv->SetValue("Holiday.TextSize", 0.13); 685 fEnv->SetValue("Holiday.TextColor", kBlue); 686 687 fEnv->SetValue("Birthday.TextAlign", "center"); 688 fEnv->SetValue("Birthday.TextSize", 0.13); 689 fEnv->SetValue("Birthday.TextColor", kBlue); 690 691 // fEnv->SetValue("Easter.TextAlign", "center"); 692 // fEnv->SetValue("Easter.TextSize", 0.13); 693 // fEnv->SetValue("Easter.TextColor", kBlue); 659 694 660 695 fEnv->SetValue("Date.Active.0.TextColor", kRed); 661 696 662 fEnv->SetValue("Date.Active.TextFont", 22);663 fEnv->SetValue("Day.Active.TextFont", 22);664 fEnv->SetValue("Date.Inactive.TextFont", 132);665 fEnv->SetValue("Day.Inactive.TextFont", 132);697 fEnv->SetValue("Date.Active.TextFont", 22); 698 fEnv->SetValue("Day.Active.TextFont", 22); 699 fEnv->SetValue("Date.Inactive.TextFont", 132); 700 fEnv->SetValue("Day.Inactive.TextFont", 132); 666 701 667 702 // fEnv->SetValue("Date.Inactive.LineStyle", kDashed); … … 683 718 //fUpdate = kFALSE; 684 719 685 SetDefaultLayout( );720 SetDefaultLayout(2); 686 721 SetDefaultHolidays(); 687 722 … … 731 766 Int_t MCalendar::Rotate(Int_t align, Bool_t fwd) const 732 767 { 733 if ( !fOrientation)768 if (fOrientation==fRotation) 734 769 return align; 735 770 736 static const Int_t a[4] = { 11, 31, 33, 13 };737 static const Int_t b[4] = { 11, 13, 33, 31 };771 static const Int_t b[4] = { 11, 31, 33, 13 }; 772 static const Int_t a[4] = { 11, 13, 33, 31 }; 738 773 739 774 const Int_t *c = fwd ? a :b; … … 780 815 */ 781 816 782 const Double_t scale = fOrientation ? x[1]-x[0] : y[1]-y[0];783 const Double_t phi = fOrientation ?90 : 0;817 const Double_t scale = fOrientation ? x[1]-x[0] : y[1]-y[0]; 818 const Double_t phi = fOrientation!=fRotation ? -90 : 0; 784 819 785 820 Convert2Latex(str); … … 787 822 tex.SetTextAlign(align); 788 823 tex.PaintLatex(p[0], p[1], phi, att.GetTextSize()*scale, str); 824 } 825 826 //--------------------------------------------------------------------------- 827 // 828 // Paint a clock as a symbol for summer-/wintertime 829 // 830 void MCalendar::PaintClock(Double_t x[2], Double_t y[2], Double_t r[2], Int_t fill, char dir) 831 { 832 Double_t k[2] = { (x[0]+x[1])/2, (y[0]+y[1])/2 }; 833 834 TEllipse e(k[0], k[1], r[0]*2.5, r[1]*2.5, 30, 360, 0); 835 e.SetLineColor(kBlack); 836 e.SetLineStyle(kSolid); 837 e.SetFillColor(fill); 838 e.Paint(); 839 840 TMarker m; 841 m.SetMarkerStyle(kFullDotSmall); 842 for (int i=2; i<12; i++) 843 m.PaintMarker(k[0]+r[0]*2*cos(TMath::TwoPi()*i/12), 844 k[1]+r[1]*2*sin(TMath::TwoPi()*i/12)); 845 846 TArrow a(k[0]+r[0]*3, k[1], k[0]+r[0]*2.7, k[1]+r[1]*1.5, r[1]/2); 847 a.Paint(dir=='-'?"->":"<-"); 789 848 } 790 849 … … 796 855 // of the MTime. 797 856 // 798 // If the name is "Easter" the format of the resource searched for is799 // Easter.o800 // while o is the offset from Easter (eg. Easter.-5, Easter.0 or Easter.22)801 //802 857 TString MCalendar::GetHoliday(const TObject &o, const MTime &tm) 803 858 { … … 811 866 TString env(o.GetName()); 812 867 813 const TString post = env=="Easter" ? 814 Form(".%d", (Int_t)tm.GetMjd()-easter) : 815 Form(".%02d/%02d", tm.Month(), tm.Day()); 816 817 return fEnvHolidays->GetValue(env+post, ""); 818 } 819 820 //#include <iostream> 868 const TString post1 = Form(".%d", (Int_t)tm.GetMjd()-easter); 869 const TString post2 = Form(".%02d/%02d", tm.Month(), tm.Day()); 870 871 TString rc; 872 for (int i=0; i<7; i++) 873 { 874 MTime tx(tm.GetMjd()+i); 875 const TString post3 = Form(".%02d/%02d-%d", tx.Month(), tx.Day(), (7-tm.WeekDay())%7); 876 rc = fEnvHolidays->GetValue(env+post3, rc); 877 } 878 879 rc = fEnvHolidays->GetValue(env+post1, rc); 880 rc = fEnvHolidays->GetValue(env+post2, rc); 881 /* 882 if (fLanguage=="de_DE") 883 { 884 MTime t; 885 t.Set(fYear, 5, 14); 886 t.SetMjd(t.GetMjd()-t.WeekDay()); 887 888 if ((Int_t)t.GetMjd() == easter + 49) 889 t.SetMjd(t.GetMjd()-7); 890 891 if ((Int_t)tm.GetMjd()==(Int_t)t.GetMjd()) 892 return "Muttertag"; 893 } 894 895 */ 896 return rc; 897 } 898 821 899 void MCalendar::Paint(Option_t *o) 822 900 { … … 830 908 831 909 // How should this be done? 832 fOrientation = gPad->PixeltoX(1)>-gPad->PixeltoY(1);910 //fOrientation = gPad->PixeltoX(1)>-gPad->PixeltoY(1); 833 911 834 912 MTime t; … … 870 948 pave.Paint(pave.GetOption()); 871 949 950 Double_t r[2] = { 951 fMoonRadius*ratio[0], 952 fMoonRadius*ratio[1] 953 }; 954 872 955 // ---------- Paint Text ---------- 873 956 const TString contents = fEnv->GetValue("Contents", ""); … … 881 964 latex.SetName(o->GetName()); 882 965 966 const TString res = fEnv->GetValue(Form("%s.Restriction", o->GetName()), "0123456"); 967 if (res.First('0'+tm.WeekDay())<0) 968 continue; 969 883 970 GetLatex(latex, active, day); 884 971 885 972 const TString text = GetHoliday(latex, tm); 973 974 if (text=="T+" || text=="T-") 975 { 976 PaintClock(x, y, r, pave.GetFillColor(), text[1]); 977 continue; 978 } 886 979 887 980 if (!text.IsNull()) 888 981 PaintLatex(latex, latex.GetTextAlign(), x, y, ratio, text); 889 890 982 } 891 983 … … 893 985 894 986 // ---------- Paint Moon Phase ----------- 895 Double_t r[2] = {896 fMoonRadius*ratio[0],897 fMoonRadius*ratio[1]898 };987 //Double_t r[2] = { 988 // fMoonRadius*ratio[0], 989 // fMoonRadius*ratio[1] 990 //}; 899 991 Double_t m[2] = { 900 992 fMarginX*ratio[0] + r[0], … … 909 1001 // location, the text is a discrete number and it is 910 1002 // switched to continous. 911 const Float_t phi = fOrientation ? 90 : 0; 912 const Int_t dx = fOrientation; 913 const Int_t dy = (fOrientation+1)%2; 1003 const Bool_t rot = fOrientation!=fRotation; 1004 const Float_t phi = rot ? -90 : 0; 1005 const Int_t dx = rot; 1006 const Int_t dy = (rot+1)%2; 914 1007 const Bool_t cont = fMoonTextType==0 || fMoonTextCont; 915 1008 if (fMoonAlignGraf) … … 918 1011 919 1012 if (fMoonAlignGraf==fMoonAlignText && cont && fMoonAlignGraf==22) 920 p[dy] += m[dy]/2;1013 p[dy] += rot ? -m[dy]/2 : m[dy]/2; 921 1014 922 1015 TEllipse e(p[0], p[1], r[0], r[1], -90+phi, 90+phi, 0); … … 937 1030 const Double_t R = tm.GetMoonPhase()<0.5 ? 1-tm.GetMoonPhase() : tm.GetMoonPhase(); 938 1031 const Double_t r0 = 1.0-TMath::Sqrt(2.0-2.0*R); 939 if ( fOrientation)1032 if (rot) 940 1033 e.SetR2(r[1]*r0); // bug in PaintEllipse! 941 1034 else … … 957 1050 if (fMoonAlignGraf==fMoonAlignText && cont) 958 1051 { 1052 if (rot) 1053 { 1054 m[dx] = -m[dx]; 1055 m[dy] = -m[dy]; 1056 } 1057 959 1058 switch (fMoonAlignGraf/10) 960 1059 { … … 998 1097 Bool_t MCalendar::GetBox(Int_t n, Double_t x[2], Double_t y[2], Double_t *ratio) 999 1098 { 1000 const Int_t maxrows =28/(7*fNumBlocks) + 1;1099 //const Int_t maxrows = 6; //28/(7*fNumBlocks) + 1; 1001 1100 const Float_t addrows = 0; 1101 1102 Int_t maxrows; 1103 switch(fNumBlocks) 1104 { 1105 case 0: 1106 case 1: maxrows=6; break; 1107 case 2: maxrows=3; break; 1108 case 3: maxrows=2; break; 1109 case 4: maxrows=2; break; 1110 default: maxrows=1; break; 1111 } 1002 1112 1003 1113 const Float_t ratio0 = -gPad->PixeltoX(1)/gPad->PixeltoY(1); … … 1011 1121 const Float_t blockx = fOrientation ? fBlockSpace/ratio0 : fBlockSpace*ratio0; 1012 1122 1013 const Float_t w = (0.9 8-cellx*(7*fNumBlocks-1)-(fNumBlocks-1)*blockx)/(fNumBlocks*7);1014 const Float_t h = (0.9 8-celly*(maxrows-1)/*-blockspacey*/)/(maxrows+addrows);1123 const Float_t w = (0.99-cellx*(7*fNumBlocks-1)-(fNumBlocks-1)*blockx)/(fNumBlocks*7); 1124 const Float_t h = (0.99-celly*(maxrows-1)/*-blockspacey*/)/(maxrows+addrows); 1015 1125 1016 1126 … … 1020 1130 const Int_t col = ix/7; 1021 1131 1022 const Double_t p0 = 0.0 1- col*(cellx - blockx);1132 const Double_t p0 = 0.005 - col*(cellx - blockx); 1023 1133 1024 1134 TArrayD a(2), b(2); … … 1027 1137 a[1] = p0 + ix*(cellx + w) + w; 1028 1138 1029 b[0] = 0.99 - iy*(celly + h) - h;1030 b[1] = 0.99 - iy*(celly + h);1139 b[0] = 0.995 - iy*(celly + h) - h; 1140 b[1] = 0.995 - iy*(celly + h); 1031 1141 1032 1142 if (ratio) … … 1038 1148 if (fOrientation) 1039 1149 { 1040 x[0] = 1-b[1];1041 x[1] = 1-b[0];1150 x[0] = b[0]; 1151 x[1] = b[1]; 1042 1152 y[0] = a[0]; 1043 1153 y[1] = a[1]; … … 1050 1160 y[1] = b[1]; 1051 1161 } 1162 1163 if (fOrientation) 1164 { 1165 TArrayD d(2,y); 1166 y[0] = 1-d[1]; 1167 y[1] = 1-d[0]; 1168 } 1169 1170 if (fRotation) 1171 { 1172 TArrayD d(2,x); 1173 x[0] = 1-d[1]; 1174 x[1] = 1-d[0]; 1175 } 1176 1052 1177 return ix==0 && iy>0; 1053 1178 } … … 1198 1323 const Int_t easter = (Int_t)MTime::GetEaster(fYear).GetMjd(); 1199 1324 1200 const TString str = Form(" Easter.%d", (Int_t)t.GetMjd()-easter);1325 const TString str = Form("Holiday.%d", (Int_t)t.GetMjd()-easter); 1201 1326 1202 1327 fEnvHolidays->SetValue(str, text); … … 1247 1372 // DrawImage cd()'s to the new pad. 1248 1373 // 1249 TASImage *MCalendar::DrawImage(const TASImage &img, Float_t x1, Float_t y1, Float_t x2, Float_t y2 ) const1250 { 1251 TPad *pad=new TPad("Img", "Image", x1, y1, x2, y2);1374 TASImage *MCalendar::DrawImage(const TASImage &img, Float_t x1, Float_t y1, Float_t x2, Float_t y2, Bool_t rot) const 1375 { 1376 TPad *pad=new TPad("Img", "Image", x1, y1, x2, y2); 1252 1377 pad->SetBorderMode(0); 1253 1378 pad->SetFillColor(gPad?gPad->GetFillColor():kWhite); … … 1269 1394 pad->Update(); 1270 1395 1271 const Int_t w = clone->GetScaledWidth();1272 const Int_t h = clone->GetScaledHeight();1396 const Int_t wi = clone->GetScaledWidth(); 1397 const Int_t hi = clone->GetScaledHeight(); 1273 1398 1274 1399 TCanvas *c = pad->GetCanvas(); 1275 1400 1276 const Float_t ml = (1-c->PixeltoX(w))/2; 1277 const Float_t mb = (1+c->PixeltoY(h))/2; 1278 1279 pad->SetPad(ml, 2*mb, 1-ml, 1); 1401 const Float_t x = (x1+x2)/2; 1402 const Float_t y = (y1+y2)/2; 1403 1404 Float_t w = TMath::Abs(x2-x1)/2; 1405 Float_t h = TMath::Abs(y2-y1)/2; 1406 1407 const Float_t ri = TMath::Abs(c->PixeltoX(wi)/c->PixeltoY(hi)); 1408 const Float_t rp = TMath::Abs(w/h); 1409 1410 if (ri>rp) 1411 h = w/ri; 1412 else 1413 w = h*ri; 1414 1415 pad->SetPad(x-w, y-h, x+w, y+h); 1416 pad->SetFixedAspectRatio(); 1280 1417 1281 1418 return clone; … … 1311 1448 // of deleting it) 1312 1449 // 1313 TASImage *MCalendar::GetImage(TEnv *env )1450 TASImage *MCalendar::GetImage(TEnv *env, const char *pwd) 1314 1451 { 1315 1452 if (!env) … … 1322 1459 ConvertUTF8(fStrMonth, kFALSE); 1323 1460 1461 const TString path(pwd); 1462 1324 1463 TString file = env->GetValue(fStrMonth, ""); 1325 1464 if (!file.Strip(TString::kBoth).IsNull()) 1326 return ReturnFile( file);1465 return ReturnFile(path+file); 1327 1466 1328 1467 file = env->GetValue(fStrMonth3, ""); 1329 1468 if (!file.Strip(TString::kBoth).IsNull()) 1330 return ReturnFile( file);1469 return ReturnFile(path+file); 1331 1470 1332 1471 file = env->GetValue(Form("%02d", fMonth), ""); 1333 1472 if (!file.Strip(TString::kBoth).IsNull()) 1334 return ReturnFile( file);1473 return ReturnFile(path+file); 1335 1474 1336 1475 return NULL; … … 1401 1540 1402 1541 TASImage *MCalendar::DrawTTF(Float_t x1, Float_t x2, Float_t y1, Float_t y2, 1403 const char *text, Int_t size, const char *font)1542 const char *text, Float_t sz, const char *font) 1404 1543 { 1405 1544 const char *file = GetTTFontPath(font); … … 1407 1546 return NULL; 1408 1547 1548 const Int_t size = TMath::Nint(sz*941); 1549 1409 1550 TTF::SetTextFont(file); 1551 TTF::SetTextSize(size); 1410 1552 1411 1553 delete file; 1412 1554 1413 TTF::SetRotationMatrix(0); 1414 TTF::SetTextSize(size); 1415 TTF::PrepareString(text); 1416 TTF::LayoutGlyphs(); 1555 UInt_t wi, hi;; 1556 TTF::GetTextExtent(wi, hi, (char*)text); 1417 1557 1418 1558 const FT_BBox &box = TTF::GetBox(); 1419 1420 TASImage img(3*box.xMax/2, 3*box.yMax/2); 1559 //cout << hi-box.yMax << " " << wi << " "<< (float)size/hi << endl; 1560 //wi = wi;//TMath::Nint((float)wi*(size+hi-box.yMax)/size); 1561 //wi += TMath::Nint(((float)size/hi-1)*wi); 1562 1563 const UInt_t add = size-box.yMax; 1564 1565 wi += size*(hi+add)/hi; 1566 hi += add; 1567 // wi += size*(hi+size-box.yMax)/hi; 1568 // hi += size-box.yMax; 1569 1570 TASImage img(wi, hi); 1421 1571 img.FillRectangle(); 1572 1573 Double_t x = (x1+x2)/2; 1574 Double_t y = (y1+y2)/2; 1575 1576 Double_t w = gPad->PixeltoX(wi)/2; 1577 Double_t h = gPad->PixeltoY(hi)/2; 1422 1578 1423 1579 // gROOT->GetColor(kBlack)->AsHexString() 1424 1580 DrawDate(img, 0, 0, text, size, "#00000000", font); 1425 return DrawImage(img, x1, y1, x2, y2); 1426 } 1581 return DrawImage(img, x-w, y-h, x+w, y+h); 1582 } 1583 1584 /* 1585 void MCalendar::Update() 1586 { 1587 cout << "Update" << endl; 1588 fUpdate=kTRUE; 1589 } 1590 1591 void MCalendar::Selected(TVirtualPad *pad,TObject *o,Int_t event) 1592 { 1593 if (event==kButton1Down && pad) 1594 { 1595 pad->cd(); 1596 fAlign = GetAlign(); 1597 fActive = GetDate().Month()==fMonth; 1598 fEnv->GetAttLine(fActive?"Date.Active":"Date.Inactive", *this); 1599 fEnv->GetAttLine(Form(fActive?"Date.Active.%d":"Date.Inactive.%d", fDay), *this); 1600 } 1601 1602 cout << "SetModel " << gPad << " " << pad << " " << o << " " << event << endl; 1603 //Picked(fSelectedPad, fSelected, fEvent); // emit signal 1604 1605 } 1606 1607 void MCalendar::SetAttributes() 1608 { 1609 if (!gPad) 1610 return; 1611 1612 TAttLine::SetLineAttributes(); 1613 1614 cout << "gPad " << gPad << endl; 1615 1616 fAlign = GetAlign(); 1617 fActive = GetDate().Month()==fMonth; 1618 fDay = GetDate().WeekDay(); 1619 1620 fEnv->GetAttLine(fActive?"Date.Active":"Date.Inactive", *this); 1621 fEnv->GetAttLine(Form(fActive?"Date.Active.%d":"Date.Inactive.%d", fDay), *this); 1622 1623 TQObject::Connect("TCanvas", "Selected(TVirtualPad*,TObject*,Int_t)", 1624 "MCalendar", this, "Selected(TVirtualPad*,TObject*,Int_t)"); 1625 1626 TQObject::Connect("TGedPatternSelect", "PatternSelected(Style_t)", "MCalendar", this, "Update()"); 1627 TQObject::Connect("TGColorSelect", "ColorSelected(Pixel_t)", "MCalendar", this, "Update()"); 1628 TQObject::Connect("TGListBox", "Selected(Int_t)", "MCalendar", this, "Update()"); 1629 } 1630 */ 1631 -
trunk/MagicSoft/Mars/mtools/MCalendar.h
r7451 r7893 14 14 #include <Gtypes.h> 15 15 #endif 16 17 /* 18 #include <TAttLine.h> 19 #include <TAttFill.h> 20 #include <TAttText.h> 21 */ 16 22 17 23 class TEnv; … … 26 32 class MTime; 27 33 28 class MCalendar : public TObject 34 class MCalendar : public TObject//, public TAttLine, public TAttText, public TAttFill 29 35 { 30 36 private: 37 /* 38 enum { 39 kMoonPhase, 40 kMoonPeriod, 41 kMagicPeriod 42 };*/ 43 44 /* 45 Int_t fAlign; 46 Bool_t fActive; 47 Bool_t fUpdate; 48 Int_t fDay; 49 */ 31 50 MEnv *fEnv; 32 51 MEnv *fEnvHolidays; 33 52 34 53 Bool_t fOrientation; 54 Bool_t fRotation; 35 55 36 56 Int_t fYear; … … 78 98 // Paint text 79 99 void PaintLatex(TAttText &att, Int_t align, Double_t x[2], Double_t y[2], Double_t ratio[2], /*Double_t height,*/ TString str); 100 void PaintClock(Double_t x[2], Double_t y[2], Double_t r[2], Int_t fill, char dir); 80 101 81 102 // GUI interactions … … 105 126 Float_t GetMoonRadius() const { return fMoonRadius; } 106 127 TString GetStringFmt(const char *fmt="%B", Int_t day=1, Int_t h=12, Int_t m=0, Int_t s=0) const; 128 Bool_t IsRotated() const { return fRotation; } 129 Bool_t IsVertical() const { return fOrientation; } 107 130 108 131 … … 113 136 void SetLayout(Byte_t NumberOfBlocks, Double_t MarginX, Double_t MarginY, Double_t CellSpace, Double_t BlockSpace) { fNumBlocks=NumberOfBlocks, fMarginX=MarginX; fMarginY=MarginY; fCellSpace=CellSpace; fBlockSpace=BlockSpace; } //*MENU* *ARGS={NumberOfBlocks=>fNumBlocks,MarginX=>fMarginX,MarginY=>fMarginY,CellSpace=>fCellSpace,BlockSpace=>fBlockSpace} 114 137 115 void ResetLayout(); //*MENU 138 void ResetLayout(Int_t num); 139 void ResetLayout() { ResetLayout(-1); } //*MENU 116 140 void ResetHolidays(); //*MENU 117 141 118 void SetDefaultLayout(); //*MENU 142 void SetDefaultLayout(Int_t num); 143 void SetDefaultLayout() { SetDefaultLayout(-1); } //*MENU 119 144 void SetDefaultHolidays(); //*MENU 120 145 … … 141 166 142 167 // void ToggleOrientation() { fOrientation = !fOrientation; } //*MENU 168 void SetRotated(Bool_t b=kTRUE) { fRotation = b; } // *TOGGLE* *GETTER=IsRotated 169 void SetVertical(Bool_t b=kTRUE) { fOrientation = b; } // *TOGGLE* *GETTER=IsVertical 143 170 144 171 void PrintEnv() const; //*MENU … … 146 173 void RemoveEnv(const char *VariableName) const;//*MENU 147 174 148 149 175 void SetMoonGraf(Int_t Align, Float_t Radius) { fMoonAlignGraf=Align; fMoonRadius=Radius; } //*MENU* *ARGS={Align>=fMoonAlignGraf,Radius=>fMoonRadius} 150 176 void SetMoonText(Int_t Align, Int_t Type, Int_t Continous) { fMoonAlignText=Align; fMoonTextType=Type; fMoonTextCont=Continous; } //*MENU* *ARGS={Align>=fMoonAlignText,Type=>fMoonTextType,Continous=>fMoonTextCont} 151 177 152 178 // Calendar sheet interface 153 TASImage *DrawImage(const TASImage &img, Float_t x1, Float_t y1, Float_t x2, Float_t y2 ) const;154 TASImage *GetImage(TEnv *env=NULL );179 TASImage *DrawImage(const TASImage &img, Float_t x1, Float_t y1, Float_t x2, Float_t y2, Bool_t rot=kFALSE) const; 180 TASImage *GetImage(TEnv *env=NULL, const char *path=""); 155 181 void DrawLatex(Float_t x, Float_t y, const char *text, const TAttText &att); 156 182 void DrawDate(Float_t x, Float_t y, const char *text, const TAttText &att) … … 168 194 } 169 195 TASImage *DrawTTF(Float_t x1, Float_t x2, Float_t y1, Float_t y2, 170 const char *text, Int_t size, const char *font);196 const char *text, Float_t size, const char *font); 171 197 TASImage *DrawTTFDate(Float_t x1, Float_t x2, Float_t y1, Float_t y2, 172 const char *text, Int_t size, const char *font)198 const char *text, Float_t size, const char *font) 173 199 { 174 200 return DrawTTF(x1, y1, x2, y2, GetStringFmt(text), size, font); … … 183 209 void Paint(Option_t *o=""); 184 210 211 /* 212 void Update(); 213 void SetLineAttributes() {} 214 void SetFillAttributes() {} 215 void SetTextAttributes() {} 216 void SetTextAngle(Float_t) {} 217 void Selected(TVirtualPad*,TObject*,Int_t); 218 */ 219 //void SetAttributes(); //*MENU 220 185 221 ClassDef(MCalendar, 1) 186 222 };
Note:
See TracChangeset
for help on using the changeset viewer.