00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <stdlib.h>
00013 #include <string.h>
00014 #include <time.h>
00015 #include <math.h>
00016
00017 #include "Riostream.h"
00018 #include "TROOT.h"
00019 #include "TGaxis.h"
00020 #include "TVirtualPad.h"
00021 #include "TVirtualX.h"
00022 #include "TLine.h"
00023 #include "TLatex.h"
00024 #include "TStyle.h"
00025 #include "TF1.h"
00026 #include "TAxis.h"
00027 #include "THashList.h"
00028 #include "TObjString.h"
00029 #include "TMath.h"
00030 #include "THLimitsFinder.h"
00031 #include "TColor.h"
00032 #include "TClass.h"
00033 #include "TTimeStamp.h"
00034
00035 Int_t TGaxis::fgMaxDigits = 5;
00036 const Int_t kHori = BIT(9);
00037
00038 ClassImp(TGaxis)
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 TGaxis::TGaxis(): TLine(), TAttText(11,0,1,62,0.040)
00108 {
00109
00110
00111 fGridLength = 0.;
00112 fLabelOffset = 0.005;
00113 fLabelSize = 0.040;
00114 fLabelFont = 62;
00115 fLabelColor = 1;
00116 fTickSize = 0.030;
00117 fTitleOffset = 1;
00118 fTitleSize = fLabelSize;
00119 fChopt = "";
00120 fName = "";
00121 fTitle = "";
00122 fTimeFormat = "";
00123 fFunctionName= "";
00124 fFunction = 0;
00125 fAxis = 0;
00126 fNdiv = 0;
00127 fWmin = 0.;
00128 fWmax = 0.;
00129 }
00130
00131
00132
00133 TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
00134 Double_t wmin, Double_t wmax, Int_t ndiv, Option_t *chopt,
00135 Double_t gridlength)
00136 : TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
00137 {
00138
00139
00140
00141 fWmin = wmin;
00142 fWmax = wmax;
00143 fNdiv = ndiv;
00144 fGridLength = gridlength;
00145 fLabelOffset = 0.005;
00146 fLabelSize = 0.040;
00147 fLabelFont = 62;
00148 fLabelColor = 1;
00149 fTickSize = 0.030;
00150 fTitleOffset = 1;
00151 fTitleSize = fLabelSize;
00152 fChopt = chopt;
00153 fName = "";
00154 fTitle = "";
00155 fTimeFormat = "";
00156 fFunctionName= "";
00157 fFunction = 0;
00158 fAxis = 0;
00159 }
00160
00161
00162
00163 TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
00164 const char *funcname, Int_t ndiv, Option_t *chopt,
00165 Double_t gridlength)
00166 : TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
00167 {
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 fFunction = (TF1*)gROOT->GetFunction(funcname);
00211 if (!fFunction) {
00212 Error("TGaxis", "calling constructor with an unknown function: %s", funcname);
00213 fWmin = 0;
00214 fWmax = 1;
00215 } else {
00216 fWmin = fFunction->GetXmin();
00217 fWmax = fFunction->GetXmax();
00218 }
00219 fFunctionName= funcname;
00220 fNdiv = ndiv;
00221 fGridLength = gridlength;
00222 fLabelOffset = 0.005;
00223 fLabelSize = 0.040;
00224 fLabelFont = 62;
00225 fLabelColor = 1;
00226 fTickSize = 0.030;
00227 fTitleOffset = 1;
00228 fTitleSize = fLabelSize;
00229 fChopt = chopt;
00230 fName = "";
00231 fTitle = "";
00232 fTimeFormat = "";
00233 fAxis = 0;
00234 }
00235
00236
00237
00238 TGaxis::TGaxis(const TGaxis& ax) :
00239 TLine(ax),
00240 TAttText(ax),
00241 fWmin(ax.fWmin),
00242 fWmax(ax.fWmax),
00243 fGridLength(ax.fGridLength),
00244 fTickSize(ax.fTickSize),
00245 fLabelOffset(ax.fLabelOffset),
00246 fLabelSize(ax.fLabelSize),
00247 fTitleOffset(ax.fTitleOffset),
00248 fTitleSize(ax.fTitleSize),
00249 fNdiv(ax.fNdiv),
00250 fLabelColor(ax.fLabelColor),
00251 fLabelFont(ax.fLabelFont),
00252 fChopt(ax.fChopt),
00253 fName(ax.fName),
00254 fTitle(ax.fTitle),
00255 fTimeFormat(ax.fTimeFormat),
00256 fFunctionName(ax.fFunctionName),
00257 fFunction(ax.fFunction),
00258 fAxis(ax.fAxis)
00259 {
00260
00261 }
00262
00263
00264
00265 TGaxis& TGaxis::operator=(const TGaxis& ax)
00266 {
00267
00268
00269 if(this!=&ax) {
00270 TLine::operator=(ax);
00271 TAttText::operator=(ax);
00272 fWmin=ax.fWmin;
00273 fWmax=ax.fWmax;
00274 fGridLength=ax.fGridLength;
00275 fTickSize=ax.fTickSize;
00276 fLabelOffset=ax.fLabelOffset;
00277 fLabelSize=ax.fLabelSize;
00278 fTitleOffset=ax.fTitleOffset;
00279 fTitleSize=ax.fTitleSize;
00280 fNdiv=ax.fNdiv;
00281 fLabelColor=ax.fLabelColor;
00282 fLabelFont=ax.fLabelFont;
00283 fChopt=ax.fChopt;
00284 fName=ax.fName;
00285 fTitle=ax.fTitle;
00286 fTimeFormat=ax.fTimeFormat;
00287 fFunctionName=ax.fFunctionName;
00288 fFunction=ax.fFunction;
00289 fAxis=ax.fAxis;
00290 }
00291 return *this;
00292 }
00293
00294
00295
00296 TGaxis::~TGaxis()
00297 {
00298
00299 }
00300
00301
00302
00303 void TGaxis::CenterLabels(Bool_t center)
00304 {
00305
00306
00307
00308
00309 if (center) SetBit(TAxis::kCenterLabels);
00310 else ResetBit(TAxis::kCenterLabels);
00311 }
00312
00313
00314
00315 void TGaxis::CenterTitle(Bool_t center)
00316 {
00317
00318
00319
00320 if (center) SetBit(TAxis::kCenterTitle);
00321 else ResetBit(TAxis::kCenterTitle);
00322 }
00323
00324
00325
00326 void TGaxis::DrawAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
00327 Double_t wmin, Double_t wmax, Int_t ndiv, Option_t *chopt,
00328 Double_t gridlength)
00329 {
00330
00331
00332 TGaxis *newaxis = new TGaxis(xmin,ymin,xmax,ymax,wmin,wmax,ndiv,chopt,gridlength);
00333 newaxis->SetLineColor(fLineColor);
00334 newaxis->SetLineWidth(fLineWidth);
00335 newaxis->SetLineStyle(fLineStyle);
00336 newaxis->SetTextAlign(fTextAlign);
00337 newaxis->SetTextAngle(fTextAngle);
00338 newaxis->SetTextColor(fTextColor);
00339 newaxis->SetTextFont(fTextFont);
00340 newaxis->SetTextSize(fTextSize);
00341 newaxis->SetTitleSize(fTitleSize);
00342 newaxis->SetTitleOffset(fTitleOffset);
00343 newaxis->SetLabelFont(fLabelFont);
00344 newaxis->SetLabelColor(fLabelColor);
00345 newaxis->SetLabelSize(fLabelSize);
00346 newaxis->SetLabelOffset(fLabelOffset);
00347 newaxis->SetTickSize(fTickSize);
00348 newaxis->SetBit(kCanDelete);
00349 newaxis->SetTitle(GetTitle());
00350 newaxis->SetBit(TAxis::kCenterTitle,TestBit(TAxis::kCenterTitle));
00351 newaxis->AppendPad();
00352 }
00353
00354
00355
00356 Int_t TGaxis::GetMaxDigits()
00357 {
00358
00359
00360 return fgMaxDigits;
00361 }
00362
00363
00364
00365 void TGaxis::ImportAxisAttributes(TAxis *axis)
00366 {
00367
00368
00369 fAxis = axis;
00370 SetLineColor(axis->GetAxisColor());
00371 SetTextColor(axis->GetTitleColor());
00372 SetTextFont(axis->GetTitleFont());
00373 SetLabelColor(axis->GetLabelColor());
00374 SetLabelFont(axis->GetLabelFont());
00375 SetLabelSize(axis->GetLabelSize());
00376 SetLabelOffset(axis->GetLabelOffset());
00377 SetTickSize(axis->GetTickLength());
00378 SetTitle(axis->GetTitle());
00379 SetTitleOffset(axis->GetTitleOffset());
00380 SetTitleSize(axis->GetTitleSize());
00381 SetBit(TAxis::kCenterTitle, axis->TestBit(TAxis::kCenterTitle));
00382 SetBit(TAxis::kCenterLabels, axis->TestBit(TAxis::kCenterLabels));
00383 SetBit(TAxis::kRotateTitle, axis->TestBit(TAxis::kRotateTitle));
00384 SetBit(TAxis::kNoExponent, axis->TestBit(TAxis::kNoExponent));
00385 SetBit(TAxis::kTickPlus, axis->TestBit(TAxis::kTickPlus));
00386 SetBit(TAxis::kTickMinus, axis->TestBit(TAxis::kTickMinus));
00387 SetBit(TAxis::kMoreLogLabels, axis->TestBit(TAxis::kMoreLogLabels));
00388 if (axis->GetDecimals()) SetBit(TAxis::kDecimals);
00389 SetTimeFormat(axis->GetTimeFormat());
00390 }
00391
00392
00393
00394 void TGaxis::Paint(Option_t *)
00395 {
00396
00397
00398 Double_t wmin = fWmin;
00399 Double_t wmax = fWmax;
00400 Int_t ndiv = fNdiv;
00401
00402
00403 Double_t x1 = gPad->XtoPad(fX1);
00404 Double_t y1 = gPad->YtoPad(fY1);
00405 Double_t x2 = gPad->XtoPad(fX2);
00406 Double_t y2 = gPad->YtoPad(fY2);
00407
00408 PaintAxis(x1,y1,x2,y2,wmin,wmax,ndiv,fChopt.Data(),fGridLength);
00409 }
00410
00411
00412
00413 void TGaxis::PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
00414 Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt,
00415 Double_t gridlength, Bool_t drawGridOnly)
00416 {
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549 const char *where = "PaintAxis";
00550
00551 Double_t alfa, beta, ratio1, ratio2, grid_side;
00552 Double_t axis_lengthN = 0;
00553 Double_t axis_length0 = 0;
00554 Double_t axis_length1 = 0;
00555 Double_t axis_length;
00556 Double_t atick[3];
00557 Double_t tick_side;
00558 Double_t charheight;
00559 Double_t phil, phi, sinphi, cosphi, asinphi, acosphi;
00560 Double_t binLow = 0., binLow2 = 0., binLow3 = 0.;
00561 Double_t binHigh = 0., binHigh2 = 0., binHigh3 = 0.;
00562 Double_t binWidth = 0., binWidth2 = 0., binWidth3 = 0.;
00563 Double_t xpl1, xpl2, ypl1, ypl2;
00564 Double_t xtick = 0;
00565 Double_t xtick0, xtick1, dxtick=0;
00566 Double_t ytick, ytick0, ytick1;
00567 Double_t wlabel, dwlabel;
00568 Double_t xfactor, yfactor;
00569 Double_t xlabel, ylabel, dxlabel;
00570 Double_t xone, xtwo;
00571 Double_t rlab;
00572 Double_t x0, x1, y0, y1, xx0, xx1, yy0, yy1;
00573 xx0 = xx1 = yy0 = yy1 = 0;
00574 Double_t xxmin, xxmax, yymin, yymax;
00575 xxmin = xxmax = yymin = yymax = 0;
00576 Double_t xlside, xmside;
00577 Double_t ww, af, rne;
00578 Double_t xx, yy;
00579 Double_t xmnlog, x00, x11, h2, h2sav, axmul, y;
00580 Float_t chupxvsav, chupyvsav;
00581 Double_t rtxw, rtyw;
00582 Int_t nlabels, nticks, nticks0, nticks1;
00583 Int_t i, j, k, l, decade, ltick;
00584 Int_t mside, lside;
00585 Int_t nexe = 0;
00586 Int_t lnlen = 0;
00587 Int_t iexe, if1, if2, na, nf, ih1, ih2, nbinin, nch, kmod;
00588 Int_t optionLog,optionBlank,optionVert,optionPlus,optionMinus,optionUnlab,optionPara;
00589 Int_t optionDown,optionRight,optionLeft,optionCent,optionEqual,optionDecimals=0,optionDot;
00590 Int_t optionY,optionText,optionGrid,optionSize,optionNoopt,optionInt,optionM,optionUp,optionX;
00591 Int_t optionTime;
00592 Int_t first,last,labelnumber;
00593 Int_t xalign, yalign;
00594 Int_t nn1, nn2, nn3, n1a, n2a, n3a, nb2, nb3;
00595 Int_t nbins=10, n1aold, nn1old;
00596 n1aold = nn1old = 0;
00597 Int_t ndyn;
00598 Int_t nhilab = 0;
00599 Int_t idn;
00600 Bool_t flexe = 0;
00601 Bool_t flexpo,flexne;
00602 char *label;
00603 char *chtemp;
00604 char *coded;
00605 char chlabel[256];
00606 char kchtemp[256];
00607 char chcoded[8];
00608 TLine *linegrid;
00609 TString timeformat;
00610 time_t timelabel;
00611 Double_t timed, wTimeIni;
00612 struct tm* utctis;
00613 Double_t rangeOffset = 0;
00614
00615 Double_t epsilon = 1e-5;
00616 const Double_t kPI = TMath::Pi();
00617
00618
00619 Double_t rwmi = wmin;
00620 Double_t rwma = wmax;
00621 chtemp = &kchtemp[0];
00622 label = &chlabel[0];
00623 linegrid = 0;
00624
00625 fFunction = (TF1*)gROOT->GetFunction(fFunctionName.Data());
00626
00627 Bool_t noExponent = TestBit(TAxis::kNoExponent);
00628
00629
00630 Bool_t moreLogLabels = TestBit(TAxis::kMoreLogLabels);
00631
00632
00633
00634
00635 Double_t padh = gPad->GetWh()*gPad->GetAbsHNDC();
00636 Double_t rwxmin = gPad->GetX1();
00637 Double_t rwxmax = gPad->GetX2();
00638 Double_t rwymin = gPad->GetY1();
00639 Double_t rwymax = gPad->GetY2();
00640
00641 if(strchr(chopt,'G')) optionLog = 1; else optionLog = 0;
00642 if(strchr(chopt,'B')) optionBlank= 1; else optionBlank= 0;
00643 if(strchr(chopt,'V')) optionVert = 1; else optionVert = 0;
00644 if(strchr(chopt,'+')) optionPlus = 1; else optionPlus = 0;
00645 if(strchr(chopt,'-')) optionMinus= 1; else optionMinus= 0;
00646 if(strchr(chopt,'U')) optionUnlab= 1; else optionUnlab= 0;
00647 if(strchr(chopt,'P')) optionPara = 1; else optionPara = 0;
00648 if(strchr(chopt,'O')) optionDown = 1; else optionDown = 0;
00649 if(strchr(chopt,'R')) optionRight= 1; else optionRight= 0;
00650 if(strchr(chopt,'L')) optionLeft = 1; else optionLeft = 0;
00651 if(strchr(chopt,'C')) optionCent = 1; else optionCent = 0;
00652 if(strchr(chopt,'=')) optionEqual= 1; else optionEqual= 0;
00653 if(strchr(chopt,'Y')) optionY = 1; else optionY = 0;
00654 if(strchr(chopt,'T')) optionText = 1; else optionText = 0;
00655 if(strchr(chopt,'W')) optionGrid = 1; else optionGrid = 0;
00656 if(strchr(chopt,'S')) optionSize = 1; else optionSize = 0;
00657 if(strchr(chopt,'N')) optionNoopt= 1; else optionNoopt= 0;
00658 if(strchr(chopt,'I')) optionInt = 1; else optionInt = 0;
00659 if(strchr(chopt,'M')) optionM = 1; else optionM = 0;
00660 if(strchr(chopt,'0')) optionUp = 1; else optionUp = 0;
00661 if(strchr(chopt,'X')) optionX = 1; else optionX = 0;
00662 if(strchr(chopt,'t')) optionTime = 1; else optionTime = 0;
00663 if(strchr(chopt,'.')) optionDot = 1; else optionDot = 0;
00664 if (TestBit(TAxis::kTickPlus)) optionPlus = 2;
00665 if (TestBit(TAxis::kTickMinus)) optionMinus = 2;
00666 if (TestBit(TAxis::kCenterLabels)) optionM = 1;
00667 if (TestBit(TAxis::kDecimals)) optionDecimals = 1;
00668 if (!gStyle->GetStripDecimals()) optionDecimals = 1;
00669 if (fAxis) {
00670 if (fAxis->GetLabels()) {
00671 optionM = 1;
00672 optionText = 1;
00673 ndiv = fAxis->GetLast()-fAxis->GetFirst()+1;
00674 }
00675 }
00676 if (ndiv < 0) {
00677 Error(where, "Invalid number of divisions: %d",ndiv);
00678 return;
00679 }
00680
00681
00682
00683 if (optionGrid) {
00684 if (gridlength == 0) gridlength = 0.8;
00685 linegrid = new TLine();
00686 linegrid->SetLineColor(gStyle->GetGridColor());
00687 if (linegrid->GetLineColor() == 0) linegrid->SetLineColor(GetLineColor());
00688 linegrid->SetLineStyle(gStyle->GetGridStyle());
00689 linegrid->SetLineWidth(gStyle->GetGridWidth());
00690 }
00691
00692
00693
00694
00695 if (GetLabelOffset() > 1.1 ) optionUnlab = 1;
00696
00697
00698
00699 Int_t idF = fTimeFormat.Index("%F");
00700 if (idF>=0) {
00701 timeformat = fTimeFormat(0,idF);
00702 } else {
00703 timeformat = fTimeFormat;
00704 }
00705
00706
00707 Double_t timeoffset =0;
00708 if (optionTime) {
00709 if (idF>=0) {
00710 Int_t lnF = fTimeFormat.Length();
00711 TString stringtimeoffset = fTimeFormat(idF+2,lnF);
00712 Int_t year, mm, dd, hh, mi, ss;
00713 if (sscanf(stringtimeoffset.Data(), "%d-%d-%d %d:%d:%d", &year, &mm, &dd, &hh, &mi, &ss) == 6) {
00714 struct tm tp;
00715 struct tm* tptest;
00716 time_t timeoffsettest;
00717
00718 Int_t zoneoffset = TTimeStamp::GetZoneOffset();
00719
00720 zoneoffset /= 3600;
00721 tp.tm_year = year-1900;
00722 tp.tm_mon = mm-1;
00723 tp.tm_mday = dd;
00724 tp.tm_hour = hh - zoneoffset;
00725 tp.tm_min = mi;
00726 tp.tm_sec = ss;
00727 tp.tm_isdst = 1;
00728 timeoffset = mktime(&tp);
00729 if (timeoffset<0.) timeoffset=0.;
00730
00731 timeoffsettest = (time_t)((Long_t)timeoffset);
00732 tptest = gmtime(&timeoffsettest);
00733 timeoffset += timeoffsettest - mktime(tptest);
00734
00735 Int_t ids = stringtimeoffset.Index("s");
00736 if (ids >= 0) {
00737 Float_t dp;
00738 Int_t lns = stringtimeoffset.Length();
00739 TString sdp = stringtimeoffset(ids+1,lns);
00740 sscanf(sdp.Data(),"%g",&dp);
00741 timeoffset += dp;
00742 }
00743
00744 if (stringtimeoffset.Index("GMT")>=0) optionTime =2;
00745 } else {
00746 Error(where, "Time offset has not the right format");
00747 }
00748 } else {
00749 timeoffset = gStyle->GetTimeOffset();
00750 }
00751 wmin += timeoffset - (int)(timeoffset);
00752 wmax += timeoffset - (int)(timeoffset);
00753
00754 struct tm* tp0;
00755 time_t timetp = (time_t)((Long_t)(timeoffset));
00756 Double_t range = wmax - wmin;
00757 Long_t rangeBase = 60;
00758 if (range>60) rangeBase = 60*20;
00759 if (range>3600) rangeBase = 3600*20;
00760 if (range>86400) rangeBase = 86400*20;
00761 if (range>2419200) rangeBase = 31556736;
00762 rangeOffset = (Double_t) ((Long_t)(timeoffset)%rangeBase);
00763 if (range>31536000) {
00764 tp0 = gmtime(&timetp);
00765 tp0->tm_mon = 0;
00766 tp0->tm_mday = 1;
00767 tp0->tm_hour = 0;
00768 tp0->tm_min = 0;
00769 tp0->tm_sec = 0;
00770 tp0->tm_isdst = 1;
00771 rangeBase = (timetp-mktime(tp0));
00772 rangeOffset = (Double_t) (rangeBase);
00773 }
00774 wmax += rangeOffset;
00775 wmin += rangeOffset;
00776 }
00777
00778
00779 n1a = ndiv%100;
00780 n2a = (ndiv%10000 - n1a)/100;
00781 n3a = ndiv/10000;
00782 nn3 = TMath::Max(n3a,1);
00783 nn2 = TMath::Max(n2a,1)*nn3;
00784 nn1 = TMath::Max(n1a,1)*nn2+1;
00785 nticks= nn1;
00786
00787
00788
00789
00790
00791
00792
00793 if (wmin == wmax || ndiv == 0 || n1a <= 1 || optionLog) {
00794 optionNoopt = 1;
00795 optionInt = 0;
00796 }
00797
00798
00799 if ( (wmax-wmin) < 1 && optionInt) {
00800 Error(where, "option I not available");
00801 optionInt = 0;
00802 }
00803 if (!optionNoopt || optionInt ) {
00804
00805
00806
00807
00808
00809 THLimitsFinder::Optimize(wmin,wmax,n1a,binLow,binHigh,nbins,binWidth,fChopt.Data());
00810 if (optionInt) {
00811 if (binLow != Double_t(int(binLow)) || binWidth != Double_t(int(binWidth))) {
00812 AdjustBinSize(wmin,wmax,n1a,binLow,binHigh,nbins,binWidth);
00813 }
00814 }
00815 if ((wmin-binLow) > epsilon) { binLow += binWidth; nbins--; }
00816 if ((binHigh-wmax) > epsilon) { binHigh -= binWidth; nbins--; }
00817 if (xmax == xmin) {
00818 rtyw = (ymax-ymin)/(wmax-wmin);
00819 xxmin = xmin;
00820 xxmax = xmax;
00821 yymin = rtyw*(binLow-wmin) + ymin;
00822 yymax = rtyw*(binHigh-wmin) + ymin;
00823 }
00824 else {
00825 rtxw = (xmax-xmin)/(wmax-wmin);
00826 xxmin = rtxw*(binLow-wmin) + xmin;
00827 xxmax = rtxw*(binHigh-wmin) + xmin;
00828 if (ymax == ymin) {
00829 yymin = ymin;
00830 yymax = ymax;
00831 }
00832 else {
00833 alfa = (ymax-ymin)/(xmax-xmin);
00834 beta = (ymin*xmax-ymax*xmin)/(xmax-xmin);
00835 yymin = alfa*xxmin + beta;
00836 yymax = alfa*xxmax + beta;
00837 }
00838 }
00839 if (fFunction) {
00840 yymin = ymin;
00841 yymax = ymax;
00842 xxmin = xmin;
00843 xxmax = xmax;
00844 } else {
00845 wmin = binLow;
00846 wmax = binHigh;
00847 }
00848
00849
00850 nb2 = n2a;
00851 if (!optionNoopt && n2a > 1 && binWidth > 0) {
00852 THLimitsFinder::Optimize(wmin,wmin+binWidth,n2a,binLow2,binHigh2,nb2,binWidth2,fChopt.Data());
00853 }
00854
00855
00856 nb3 = n3a;
00857 if (!optionNoopt && n3a > 1 && binWidth2 > 0) {
00858 THLimitsFinder::Optimize(binLow2,binLow2+binWidth2,n3a,binLow3,binHigh3,nb3,binWidth3,fChopt.Data());
00859 }
00860 n1aold = n1a;
00861 nn1old = nn1;
00862 n1a = nbins;
00863 nn3 = TMath::Max(nb3,1);
00864 nn2 = TMath::Max(nb2,1)*nn3;
00865 nn1 = TMath::Max(n1a,1)*nn2+1;
00866 nticks = nn1;
00867 }
00868
00869
00870
00871 ratio1 = 1/(rwxmax-rwxmin);
00872 ratio2 = 1/(rwymax-rwymin);
00873 x0 = ratio1*(xmin-rwxmin);
00874 x1 = ratio1*(xmax-rwxmin);
00875 y0 = ratio2*(ymin-rwymin);
00876 y1 = ratio2*(ymax-rwymin);
00877 if (!optionNoopt || optionInt ) {
00878 xx0 = ratio1*(xxmin-rwxmin);
00879 xx1 = ratio1*(xxmax-rwxmin);
00880 yy0 = ratio2*(yymin-rwymin);
00881 yy1 = ratio2*(yymax-rwymin);
00882 }
00883
00884 if ((x0 == x1) && (y0 == y1)) {
00885 Error(where, "length of axis is 0");
00886 return;
00887 }
00888
00889
00890 if (optionX) {
00891 ndiv = n1a;
00892 return;
00893 }
00894
00895 Int_t maxDigits = 5;
00896 if (fAxis) maxDigits = fgMaxDigits;
00897
00898 TLine *lineaxis = new TLine();
00899 TLatex *textaxis = new TLatex();
00900 lineaxis->SetLineColor(GetLineColor());
00901 lineaxis->SetLineStyle(1);
00902 lineaxis->SetLineWidth(GetLineWidth());
00903 textaxis->SetTextColor(GetTextColor());
00904 textaxis->SetTextFont(GetTextFont());
00905
00906 if (!gPad->IsBatch()) {
00907 gVirtualX->GetCharacterUp(chupxvsav, chupyvsav);
00908 gVirtualX->SetClipOFF(gPad->GetCanvasID());
00909 }
00910
00911
00912 axis_length = TMath::Sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
00913 if (axis_length == 0) {
00914 Error(where, "length of axis is 0");
00915 goto L210;
00916 }
00917 if (!optionNoopt || optionInt) {
00918 axis_lengthN = TMath::Sqrt((xx1-xx0)*(xx1-xx0)+(yy1-yy0)*(yy1-yy0));
00919 axis_length0 = TMath::Sqrt((xx0-x0)*(xx0-x0)+(yy0-y0)*(yy0-y0));
00920 axis_length1 = TMath::Sqrt((x1-xx1)*(x1-xx1)+(y1-yy1)*(y1-yy1));
00921 if (axis_lengthN < epsilon) {
00922 optionNoopt = 1;
00923 optionInt = 0;
00924 wmin = rwmi;
00925 wmax = rwma;
00926 n1a = n1aold;
00927 nn1 = nn1old;
00928 nticks = nn1;
00929 if (optionTime) {
00930 wmin += timeoffset - (int)(timeoffset) + rangeOffset;
00931 wmax += timeoffset - (int)(timeoffset) + rangeOffset;
00932 }
00933 }
00934 }
00935
00936 if (x0 == x1) {
00937 phi = 0.5*kPI;
00938 phil = phi;
00939 } else {
00940 phi = TMath::ATan2((y1-y0),(x1-x0));
00941 Int_t px0 = gPad->UtoPixel(x0);
00942 Int_t py0 = gPad->VtoPixel(y0);
00943 Int_t px1 = gPad->UtoPixel(x1);
00944 Int_t py1 = gPad->VtoPixel(y1);
00945 if (x0 < x1) phil = TMath::ATan2(Double_t(py0-py1), Double_t(px1-px0));
00946 else phil = TMath::ATan2(Double_t(py1-py0), Double_t(px0-px1));
00947 }
00948 cosphi = TMath::Cos(phi);
00949 sinphi = TMath::Sin(phi);
00950 acosphi = TMath::Abs(cosphi);
00951 asinphi = TMath::Abs(sinphi);
00952 if (acosphi <= epsilon) { acosphi = 0; cosphi = 0; }
00953 if (asinphi <= epsilon) { asinphi = 0; sinphi = 0; }
00954
00955
00956
00957
00958
00959
00960 mside=1;
00961 if (x0 == x1 && y1 > y0) mside = -1;
00962 if (optionPlus) mside = 1;
00963 if (optionMinus) mside = -1;
00964 if (optionPlus && optionMinus) mside = 0;
00965 xmside = mside;
00966 lside = -mside;
00967 if (optionEqual) lside = mside;
00968 if (optionPlus && optionMinus) {
00969 lside = -1;
00970 if (optionEqual) lside=1;
00971 }
00972 xlside = lside;
00973
00974
00975 if(xmside >= 0) tick_side = 1;
00976 else tick_side = -1;
00977 if (optionSize) atick[0] = tick_side*axis_length*fTickSize;
00978 else atick[0] = tick_side*axis_length*0.03;
00979
00980 atick[1] = 0.5*atick[0];
00981 atick[2] = 0.5*atick[1];
00982
00983
00984 if ((x0 == x1) && (y1 > y0)) grid_side =-1;
00985 else grid_side = 1;
00986
00987
00988 if(fFunction) {
00989 rwmi = fFunction->Eval(wmin);
00990 rwma = fFunction->Eval(wmax);
00991 if(rwmi > rwma) {
00992 Double_t t = rwma;
00993 rwma = rwmi;
00994 rwmi = t;
00995 }
00996 }
00997
00998
00999 if (!optionBlank) {
01000 xpl1 = x0;
01001 xpl2 = x1;
01002 ypl1 = y0;
01003 ypl2 = y1;
01004 lineaxis->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01005 }
01006
01007
01008 if (!drawGridOnly && strlen(GetTitle())) {
01009 textaxis->SetTextSize (GetTitleSize());
01010 charheight = GetTitleSize();
01011 if ((GetTextFont() % 10) > 2) {
01012 charheight = charheight/gPad->GetWh();
01013 }
01014 Double_t toffset = GetTitleOffset();
01015
01016 if (x1 == x0) ylabel = xlside*1.6*charheight*toffset;
01017 else ylabel = xlside*1.3*charheight*toffset;
01018 if (y1 == y0) ylabel = xlside*1.6*charheight*toffset;
01019 Double_t axispos;
01020 if (TestBit(TAxis::kCenterTitle)) axispos = 0.5*axis_length;
01021 else axispos = axis_length;
01022 if (TestBit(TAxis::kRotateTitle)) {
01023 if (x1 >= x0) {
01024 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
01025 else textaxis->SetTextAlign(12);
01026 Rotate(axispos,ylabel,cosphi,sinphi,x0,y0,xpl1,ypl1);
01027 } else {
01028 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
01029 else textaxis->SetTextAlign(32);
01030 Rotate(axispos,ylabel,cosphi,sinphi,x0,y0,xpl1,ypl1);
01031 }
01032 textaxis->PaintLatex(gPad->GetX1() + xpl1*(gPad->GetX2() - gPad->GetX1()),
01033 gPad->GetY1() + ypl1*(gPad->GetY2() - gPad->GetY1()),
01034 phil=(kPI+phil)*180/kPI,
01035 GetTitleSize(),
01036 GetTitle());
01037 } else {
01038 if (x1 >= x0) {
01039 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
01040 else textaxis->SetTextAlign(32);
01041 Rotate(axispos,ylabel,cosphi,sinphi,x0,y0,xpl1,ypl1);
01042 } else {
01043 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
01044 else textaxis->SetTextAlign(12);
01045 Rotate(axispos,ylabel,cosphi,sinphi,x0,y0,xpl1,ypl1);
01046 }
01047 textaxis->PaintLatex(gPad->GetX1() + xpl1*(gPad->GetX2() - gPad->GetX1()),
01048 gPad->GetY1() + ypl1*(gPad->GetY2() - gPad->GetY1()),
01049 phil*180/kPI,
01050 GetTitleSize(),
01051 GetTitle());
01052 }
01053 }
01054
01055
01056
01057 if (ndiv == 0)goto L210;
01058 if (wmin == wmax) {
01059 Error(where, "wmin (%f) == wmax (%f)", wmin, wmax);
01060 goto L210;
01061 }
01062
01063
01064
01065
01066
01067
01068 charheight = GetLabelSize();
01069 if (optionText && GetLabelFont()%10 != 3) charheight *= 0.66666;
01070 textaxis->SetTextFont(GetLabelFont());
01071 if ((GetLabelFont()%10 < 2) && optionLog)
01072 textaxis->SetTextFont((Int_t)(GetLabelFont()/10)*10+2);
01073 textaxis->SetTextColor(GetLabelColor());
01074 textaxis->SetTextSize (charheight);
01075 textaxis->SetTextAngle(GetTextAngle());
01076 if (GetLabelFont()%10 > 2) {
01077 charheight /= padh;
01078 }
01079 if (!optionUp && !optionDown && !optionY && !optionUnlab) {
01080 if (!drawGridOnly && optionText && ((ymin == ymax) || (xmin == xmax))) {
01081 textaxis->SetTextAlign(32);
01082 optionText = 2;
01083 Int_t nl = fAxis->GetLast()-fAxis->GetFirst()+1;
01084 Double_t angle = 0;
01085 for (i=fAxis->GetFirst(); i<=fAxis->GetLast(); i++) {
01086 textaxis->SetText(0,0,fAxis->GetBinLabel(i));
01087 if (textaxis->GetXsize() < (xmax-xmin)/nl) continue;
01088 angle = -20;
01089 break;
01090 }
01091 for (i=fAxis->GetFirst(); i<=fAxis->GetLast(); i++) {
01092 if ((!strcmp(fAxis->GetName(),"xaxis") && !gPad->TestBit(kHori))
01093 ||(!strcmp(fAxis->GetName(),"yaxis") && gPad->TestBit(kHori))) {
01094 if (nl > 50) angle = 90;
01095 if (fAxis->TestBit(TAxis::kLabelsHori)) angle = 0;
01096 if (fAxis->TestBit(TAxis::kLabelsVert)) angle = 90;
01097 if (fAxis->TestBit(TAxis::kLabelsUp)) angle = 20;
01098 if (fAxis->TestBit(TAxis::kLabelsDown)) angle =-20;
01099 if (angle == 0) textaxis->SetTextAlign(23);
01100 if (angle == -20) textaxis->SetTextAlign(12);
01101 Double_t s = -3;
01102 if (ymin == gPad->GetUymax()) {
01103 if (angle == 0) textaxis->SetTextAlign(21);
01104 s = 3;
01105 }
01106 textaxis->PaintLatex(fAxis->GetBinCenter(i),
01107 ymin + s*fAxis->GetLabelOffset()*(gPad->GetUymax()-gPad->GetUymin()),
01108 angle,
01109 textaxis->GetTextSize(),
01110 fAxis->GetBinLabel(i));
01111 } else if ((!strcmp(fAxis->GetName(),"yaxis") && !gPad->TestBit(kHori))
01112 || (!strcmp(fAxis->GetName(),"xaxis") && gPad->TestBit(kHori))) {
01113 Double_t s = -3;
01114 if (xmin == gPad->GetUxmax()) {
01115 textaxis->SetTextAlign(12);
01116 s = 3;
01117 }
01118 textaxis->PaintLatex(xmin + s*fAxis->GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin()),
01119 fAxis->GetBinCenter(i),
01120 0,
01121 textaxis->GetTextSize(),
01122 fAxis->GetBinLabel(i));
01123 } else {
01124 textaxis->PaintLatex(xmin - 3*fAxis->GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin()),
01125 ymin +(i-0.5)*(ymax-ymin)/nl,
01126 0,
01127 textaxis->GetTextSize(),
01128 fAxis->GetBinLabel(i));
01129 }
01130 }
01131 }
01132 }
01133
01134
01135 if (!gPad->IsBatch()) {
01136 if (cosphi > 0) gVirtualX->SetCharacterUp(-sinphi,cosphi);
01137 else gVirtualX->SetCharacterUp(sinphi,-cosphi);
01138 if (x0 == x1) gVirtualX->SetCharacterUp(0,1);
01139 if (optionVert) gVirtualX->SetCharacterUp(0,1);
01140 if (optionPara) gVirtualX->SetCharacterUp(-sinphi,cosphi);
01141 if (optionDown) gVirtualX->SetCharacterUp(cosphi,sinphi);
01142 }
01143
01144
01145 xalign = 2;
01146 yalign = 1;
01147 if (x0 == x1) xalign = 3;
01148 if (y0 != y1) yalign = 2;
01149 if (optionCent) xalign = 2;
01150 if (optionRight) xalign = 3;
01151 if (optionLeft) xalign = 1;
01152 if (TMath::Abs(cosphi) > 0.9) {
01153 xalign = 2;
01154 } else {
01155 if (cosphi*sinphi > 0) xalign = 1;
01156 if (cosphi*sinphi < 0) xalign = 3;
01157 }
01158 textaxis->SetTextAlign(10*xalign+yalign);
01159
01160
01161 if (x0 == x1) {
01162 if (optionPlus && !optionMinus) {
01163 if (optionEqual) ylabel = fLabelOffset/2 + atick[0];
01164 else ylabel = -fLabelOffset;
01165 } else {
01166 ylabel = fLabelOffset;
01167 if (lside < 0) ylabel += atick[0];
01168 }
01169 } else if (y0 == y1) {
01170 if (optionMinus && !optionPlus) {
01171 if ((GetLabelFont() % 10) == 3 ) {
01172 ylabel = fLabelOffset+0.5*
01173 ((gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY((Int_t)fLabelSize))/
01174 (gPad->GetY2() - gPad->GetY1()));
01175 } else {
01176 ylabel = fLabelOffset+0.5*fLabelSize;
01177 }
01178 ylabel += TMath::Abs(atick[0]);
01179 } else {
01180 ylabel = -fLabelOffset;
01181 if (mside <= 0) ylabel -= TMath::Abs(atick[0]);
01182 }
01183 if (optionLog) ylabel -= 0.5*charheight;
01184 } else {
01185 if (mside+lside >= 0) ylabel = fLabelOffset;
01186 else ylabel = -fLabelOffset;
01187 }
01188 if (optionText) ylabel /= 2;
01189
01190
01191 if (!optionLog) {
01192 if (ndiv) {
01193 if (fFunction) {
01194 dxtick=(binHigh-binLow)/Double_t(nticks-1);
01195 } else {
01196 if (optionNoopt && !optionInt) dxtick=axis_length/Double_t(nticks-1);
01197 else dxtick=axis_lengthN/Double_t(nticks-1);
01198 }
01199 for (k=0;k<nticks; k++) {
01200 ltick = 2;
01201 if (k%nn3 == 0) ltick = 1;
01202 if (k%nn2 == 0) ltick = 0;
01203 if (fFunction) {
01204 Double_t xf = binLow+Double_t(k)*dxtick;
01205 Double_t zz = fFunction->Eval(xf)-rwmi;
01206 xtick = zz* axis_length / TMath::Abs(rwma-rwmi);
01207 } else {
01208 xtick = Double_t(k)*dxtick;
01209 }
01210 ytick = 0;
01211 if (!mside) ytick -= atick[ltick];
01212 if ( optionNoopt && !optionInt) {
01213 Rotate(xtick,ytick,cosphi,sinphi,x0,y0,xpl2,ypl2);
01214 Rotate(xtick,atick[ltick],cosphi,sinphi,x0,y0,xpl1,ypl1);
01215 }
01216 else {
01217 Rotate(xtick,ytick,cosphi,sinphi,xx0,yy0,xpl2,ypl2);
01218 Rotate(xtick,atick[ltick],cosphi,sinphi,xx0,yy0,xpl1,ypl1);
01219 }
01220 if (optionVert) {
01221 if ((x0 != x1) && (y0 != y1)) {
01222 if (mside) {
01223 xpl1 = xpl2;
01224 if (cosphi > 0) ypl1 = ypl2 + atick[ltick];
01225 else ypl1 = ypl2 - atick[ltick];
01226 }
01227 else {
01228 xpl1 = 0.5*(xpl1 + xpl2);
01229 xpl2 = xpl1;
01230 ypl1 = 0.5*(ypl1 + ypl2) + atick[ltick];
01231 ypl2 = 0.5*(ypl1 + ypl2) - atick[ltick];
01232 }
01233 }
01234 }
01235 if (!drawGridOnly) lineaxis->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01236
01237 if (optionGrid) {
01238 if (ltick == 0) {
01239 if (optionNoopt && !optionInt) {
01240 Rotate(xtick,0,cosphi,sinphi,x0,y0 ,xpl2,ypl2);
01241 Rotate(xtick,grid_side*gridlength ,cosphi,sinphi,x0,y0 ,xpl1,ypl1);
01242 }
01243 else {
01244 Rotate(xtick,0,cosphi ,sinphi,xx0,yy0 ,xpl2,ypl2);
01245 Rotate(xtick,grid_side*gridlength ,cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
01246 }
01247 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01248 }
01249 }
01250 }
01251 xtick0 = 0;
01252 xtick1 = xtick;
01253
01254 if (fFunction) axis_length0 = binLow-wmin;
01255 if ((!optionNoopt || optionInt) && axis_length0) {
01256 nticks0 = Int_t(axis_length0/dxtick);
01257 if (nticks0 > 1000) nticks0 = 1000;
01258 for (k=0; k<=nticks0; k++) {
01259 ltick = 2;
01260 if (k%nn3 == 0) ltick = 1;
01261 if (k%nn2 == 0) ltick = 0;
01262 ytick0 = 0;
01263 if (!mside) ytick0 -= atick[ltick];
01264 if (fFunction) {
01265 xtick0 = (fFunction->Eval(binLow - Double_t(k)*dxtick)-rwmi)
01266 * axis_length / TMath::Abs(rwma-rwmi);
01267 }
01268 Rotate(xtick0,ytick0,cosphi,sinphi,xx0,yy0 ,xpl2,ypl2);
01269 Rotate(xtick0,atick[ltick],cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
01270 if (optionVert) {
01271 if ((x0 != x1) && (y0 != y1)) {
01272 if (mside) {
01273 xpl1 = xpl2;
01274 if (cosphi > 0) ypl1 = ypl2 + atick[ltick];
01275 else ypl1 = ypl2 - atick[ltick];
01276 }
01277 else {
01278 xpl1 = 0.5*(xpl1 + xpl2);
01279 xpl2 = xpl1;
01280 ypl1 = 0.5*(ypl1 + ypl2) + atick[ltick];
01281 ypl2 = 0.5*(ypl1 + ypl2) - atick[ltick];
01282 }
01283 }
01284 }
01285 if (!drawGridOnly) lineaxis->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01286
01287 if (optionGrid) {
01288 if (ltick == 0) {
01289 Rotate(xtick0,0,cosphi,sinphi,xx0,yy0,xpl2,ypl2);
01290 Rotate(xtick0,grid_side*gridlength ,cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
01291 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01292 }
01293 }
01294 xtick0 -= dxtick;
01295 }
01296 }
01297
01298 if (fFunction) axis_length1 = wmax-binHigh;
01299 if ((!optionNoopt || optionInt) && axis_length1) {
01300 nticks1 = int(axis_length1/dxtick);
01301 if (nticks1 > 1000) nticks1 = 1000;
01302 for (k=0; k<=nticks1; k++) {
01303 ltick = 2;
01304 if (k%nn3 == 0) ltick = 1;
01305 if (k%nn2 == 0) ltick = 0;
01306 ytick1 = 0;
01307 if (!mside) ytick1 -= atick[ltick];
01308 if (fFunction) {
01309 xtick1 = (fFunction->Eval(binHigh + Double_t(k)*dxtick)-rwmi)
01310 * axis_length / TMath::Abs(rwma-rwmi);
01311 }
01312 Rotate(xtick1,ytick1,cosphi,sinphi,xx0,yy0 ,xpl2,ypl2);
01313 Rotate(xtick1,atick[ltick],cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
01314 if (optionVert) {
01315 if ((x0 != x1) && (y0 != y1)) {
01316 if (mside) {
01317 xpl1 = xpl2;
01318 if (cosphi > 0) ypl1 = ypl2 + atick[ltick];
01319 else ypl1 = ypl2 - atick[ltick];
01320 }
01321 else {
01322 xpl1 = 0.5*(xpl1 + xpl2);
01323 xpl2 = xpl1;
01324 ypl1 = 0.5*(ypl1 + ypl2) + atick[ltick];
01325 ypl2 = 0.5*(ypl1 + ypl2) - atick[ltick];
01326 }
01327 }
01328 }
01329 if (!drawGridOnly) lineaxis->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01330 if (optionGrid) {
01331 if (ltick == 0) {
01332 Rotate(xtick1,0,cosphi,sinphi,xx0,yy0 ,xpl2,ypl2);
01333 Rotate(xtick1,grid_side*gridlength,cosphi,sinphi,xx0,yy0,xpl1,ypl1);
01334 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01335 }
01336 }
01337 xtick1 += dxtick;
01338 }
01339 }
01340 }
01341 }
01342
01343
01344 if (!drawGridOnly && !optionUnlab) {
01345 if (!optionLog) {
01346 if (n1a) {
01347
01348 if ((wmin == wmax) || (ndiv == 0)) {
01349 Error(where, "wmin (%f) == wmax (%f), or ndiv == 0", wmin, wmax);
01350 goto L210;
01351 }
01352 wlabel = wmin;
01353 dwlabel = (wmax-wmin)/Double_t(n1a);
01354 if (optionNoopt && !optionInt) dxlabel = axis_length/Double_t(n1a);
01355 else dxlabel = axis_lengthN/Double_t(n1a);
01356
01357 if (!optionText && !optionTime) {
01358
01359
01360
01361
01362 flexe = kFALSE;
01363 nexe = 0;
01364 flexpo = kFALSE;
01365 flexne = kFALSE;
01366 ww = TMath::Max(TMath::Abs(wmin),TMath::Abs(wmax));
01367
01368
01369
01370
01371 Double_t xmicros = 0.00099;
01372 if (maxDigits) xmicros = TMath::Power(10,-maxDigits);
01373 if (!noExponent && (TMath::Abs(wmax-wmin)/Double_t(n1a)) < xmicros) {
01374 af = TMath::Log10(ww) + epsilon;
01375 if (af < 0) {
01376 flexe = kTRUE;
01377 nexe = int(af);
01378 iexe = TMath::Abs(nexe);
01379 if (iexe%3 == 1) iexe += 2;
01380 else if(iexe%3 == 2) iexe += 1;
01381 if (nexe < 0) nexe = -iexe;
01382 else nexe = iexe;
01383 wlabel = wlabel*TMath::Power(10,iexe);
01384 dwlabel = dwlabel*TMath::Power(10,iexe);
01385 if1 = maxDigits;
01386 if2 = maxDigits-2;
01387 goto L110;
01388 }
01389 }
01390 if (ww >= 1) af = TMath::Log10(ww);
01391 else af = TMath::Log10(ww*0.0001);
01392 af += epsilon;
01393 nf = Int_t(af)+1;
01394 if (!noExponent && nf > maxDigits) flexpo = kTRUE;
01395 if (!noExponent && nf < -maxDigits) flexne = kTRUE;
01396
01397
01398
01399 if (flexpo) {
01400 flexe = kTRUE;
01401 while (1) {
01402 nexe++;
01403 ww /= 10;
01404 wlabel /= 10;
01405 dwlabel /= 10;
01406 if (nexe%3 == 0 && ww <= TMath::Power(10,maxDigits-1)) break;
01407 }
01408 }
01409
01410 if (flexne) {
01411 flexe = kTRUE;
01412 rne = 1/TMath::Power(10,maxDigits-2);
01413 while (1) {
01414 nexe--;
01415 ww *= 10;
01416 wlabel *= 10;
01417 dwlabel *= 10;
01418 if (nexe%3 == 0 && ww >= rne) break;
01419 }
01420 }
01421
01422 na = 0;
01423 for (i=maxDigits-1; i>0; i--) {
01424 if (TMath::Abs(ww) < TMath::Power(10,i)) na = maxDigits-i;
01425 }
01426 ndyn = n1a;
01427 while (ndyn) {
01428 Double_t wdyn = TMath::Abs((wmax-wmin)/ndyn);
01429 if (wdyn <= 0.999 && na < maxDigits-2) {
01430 na++;
01431 ndyn /= 10;
01432 }
01433 else break;
01434 }
01435
01436 if2 = na;
01437 if1 = TMath::Max(nf+na,maxDigits)+1;
01438 L110:
01439 if (TMath::Min(wmin,wmax) < 0)if1 = if1+1;
01440 if1 = TMath::Min(if1,32);
01441
01442
01443 while (dwlabel < TMath::Power(10,-if2)) {
01444 if1++;
01445 if2++;
01446 }
01447 coded = &chcoded[0];
01448 if (if1 > 14) if1=14;
01449 if (if2 > 14) if2=14;
01450 if (if2) snprintf(coded,8,"%%%d.%df",if1,if2);
01451 else snprintf(coded,8,"%%%d.%df",if1+1,1);
01452 }
01453
01454
01455
01456 snprintf(chtemp,256,"%g",dwlabel);
01457 Int_t ndecimals = 0;
01458 if (optionDecimals) {
01459 char *dot = strchr(chtemp,'.');
01460 if (dot) {
01461 ndecimals = chtemp + strlen(chtemp) -dot;
01462 } else {
01463 char *exp;
01464 exp = strstr(chtemp,"e-");
01465 if (exp) {
01466 sscanf(&exp[2],"%d",&ndecimals);
01467 ndecimals++;
01468 }
01469 }
01470 }
01471 if (optionM) nlabels = n1a-1;
01472 else nlabels = n1a;
01473 wTimeIni = wlabel;
01474 for ( k=0; k<=nlabels; k++) {
01475 if (fFunction) {
01476 Double_t xf = binLow+Double_t(k*nn2)*dxtick;
01477 Double_t zz = fFunction->Eval(xf)-rwmi;
01478 wlabel = xf;
01479 xlabel = zz* axis_length / TMath::Abs(rwma-rwmi);
01480 } else {
01481 xlabel = dxlabel*k;
01482 }
01483 if (optionM) xlabel += 0.5*dxlabel;
01484
01485 if (!optionText && !optionTime) {
01486 snprintf(label,256,&chcoded[0],wlabel);
01487 label[28] = 0;
01488 wlabel += dwlabel;
01489
01490 LabelsLimits(label,first,last);
01491
01492 if (label[first] == '.') {
01493 strncpy(chtemp, "0",256);
01494 strlcat(chtemp, &label[first],256);
01495 strncpy(label, chtemp,256);
01496 first = 1; last = strlen(label);
01497 }
01498 if (label[first] == '-' && label[first+1] == '.') {
01499 strncpy(chtemp, "-0",256);
01500 strlcat(chtemp, &label[first+1],256);
01501 strncpy(label, chtemp, 256);
01502 first = 1; last = strlen(label);
01503 }
01504
01505
01506 if (ndecimals) {
01507 char *adot = strchr(label,'.');
01508 if (adot) adot[ndecimals] = 0;
01509 } else {
01510 while (label[last] == '0') { label[last] = 0; last--;}
01511 }
01512
01513
01514 if (label[last] == '.') {
01515 if (!optionDot) { label[last] = 0; last--;}
01516 }
01517
01518
01519 if (last-first == 1 && label[first] == '-'
01520 && label[last] == '0') {
01521 strncpy(label, "0", 256);
01522 label[last] = 0;
01523 }
01524 }
01525
01526
01527
01528 if (optionTime) {
01529 timed = wlabel + (int)(timeoffset) - rangeOffset;
01530 timelabel = (time_t)((Long_t)(timed));
01531 if (optionTime == 1) {
01532 utctis = localtime(&timelabel);
01533 } else {
01534 utctis = gmtime(&timelabel);
01535 }
01536 TString timeformattmp;
01537 if (timeformat.Length() < 220) timeformattmp = timeformat;
01538 else timeformattmp = "#splitline{Format}{too long}";
01539
01540
01541 if (dwlabel<0.9) {
01542 double tmpdb;
01543 int tmplast;
01544 snprintf(label, 256, "%%S%7.5f", modf(timed,&tmpdb));
01545 tmplast = strlen(label)-1;
01546
01547
01548 while (label[tmplast] == '0') {
01549 label[tmplast] = 0; tmplast--;
01550 }
01551
01552 timeformattmp.ReplaceAll("%S",label);
01553
01554 timeformattmp.ReplaceAll("%S0.","%Ss");
01555
01556 }
01557
01558 strftime(label, 256, timeformattmp.Data(), utctis);
01559 strncpy(chtemp, &label[0], 256);
01560 first = 0; last=strlen(label)-1;
01561 wlabel = wTimeIni + (k+1)*dwlabel;
01562 }
01563
01564
01565
01566 if (optionNoopt && !optionInt)
01567 Rotate (xlabel,ylabel,cosphi,sinphi,x0,y0,xx,yy);
01568 else Rotate (xlabel,ylabel,cosphi,sinphi,xx0,yy0,xx,yy);
01569 if (y0 == y1 && !optionDown && !optionUp) {
01570 yy -= 0.80*charheight;
01571 }
01572 if (optionVert) {
01573 if (x0 != x1 && y0 != y1) {
01574 if (optionNoopt && !optionInt)
01575 Rotate (xlabel,0,cosphi,sinphi,x0,y0,xx,yy);
01576 else Rotate (xlabel,0,cosphi,sinphi,xx0,yy0,xx,yy);
01577 if (cosphi > 0 ) yy += ylabel;
01578 if (cosphi < 0 ) yy -= ylabel;
01579 }
01580 }
01581 if (!optionY || (x0 == x1)) {
01582 if (!optionText) {
01583 if (first > last) strncpy(chtemp, " ", 256);
01584 else strncpy(chtemp, &label[first], 256);
01585 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
01586 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
01587 0,
01588 textaxis->GetTextSize(),
01589 chtemp);
01590 }
01591 else {
01592 if (optionText == 1) textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
01593 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
01594 0,
01595 textaxis->GetTextSize(),
01596 fAxis->GetBinLabel(k+fAxis->GetFirst()));
01597 }
01598 }
01599 else {
01600
01601
01602 if (!optionText) lnlen = last-first+1;
01603 else {
01604 if (k+1 > nhilab) lnlen = 0;
01605 }
01606 for ( l=1; l<=lnlen; l++) {
01607 if (!optionText) *chtemp = label[first+l-2];
01608 else {
01609 if (lnlen == 0) strncpy(chtemp, " ", 256);
01610 else strncpy(chtemp, "1", 256);
01611 }
01612 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
01613 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
01614 0,
01615 textaxis->GetTextSize(),
01616 chtemp);
01617 yy -= charheight*1.3;
01618 }
01619 }
01620 }
01621
01622
01623
01624 if (flexe && !optionText && nexe) {
01625 snprintf(label,256,"#times10^{%d}", nexe);
01626 if (x0 != x1) { xfactor = x1-x0+0.1*charheight; yfactor = 0; }
01627 else { xfactor = y1-y0+0.1*charheight; yfactor = 0; }
01628 Rotate (xfactor,yfactor,cosphi,sinphi,x0,y0,xx,yy);
01629 textaxis->SetTextAlign(11);
01630 if (GetLabelFont()%10 < 2)
01631 textaxis->SetTextFont((Int_t)(GetLabelFont()/10)*10+2);
01632 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
01633 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
01634 0,
01635 textaxis->GetTextSize(),
01636 label);
01637 }
01638 }
01639 }
01640 }
01641
01642
01643
01644 if (optionLog && ndiv) {
01645 UInt_t xi1=0,xi2,wi,yi1=0,yi2,hi;
01646 Bool_t firstintlab = kTRUE, overlap = kFALSE;
01647 if ((wmin == wmax) || (ndiv == 0)) {
01648 Error(where, "wmin (%f) == wmax (%f), or ndiv == 0", wmin, wmax);
01649 goto L210;
01650 }
01651 if (wmin <= 0) {
01652 Error(where, "negative logarithmic axis");
01653 goto L210;
01654 }
01655 if (wmax <= 0) {
01656 Error(where, "negative logarithmic axis");
01657 goto L210;
01658 }
01659 xmnlog = TMath::Log10(wmin);
01660 if (xmnlog > 0) xmnlog += 1.E-6;
01661 else xmnlog -= 1.E-6;
01662 x00 = 0;
01663 x11 = axis_length;
01664 h2 = TMath::Log10(wmax);
01665 h2sav = h2;
01666 if (h2 > 0) h2 += 1.E-6;
01667 else h2 -= 1.E-6;
01668 ih1 = int(xmnlog);
01669 ih2 = 1+int(h2);
01670 nbinin = ih2-ih1+1;
01671 axmul = (x11-x00)/(h2sav-xmnlog);
01672
01673
01674 decade = ih1-2;
01675 labelnumber = ih1;
01676 if ( xmnlog > 0 && (xmnlog-Double_t(ih1) > 0) ) labelnumber++;
01677 for (j=1; j<=nbinin; j++) {
01678
01679
01680 firstintlab = kTRUE, overlap = kFALSE;
01681 decade++;
01682 if (x0 == x1 && j == 1) ylabel += charheight*0.33;
01683 if (y0 == y1 && j == 1) ylabel -= charheight*0.65;
01684 xone = x00+axmul*(Double_t(decade)-xmnlog);
01685
01686 if (j < 0) printf("j=%d\n",j);
01687 if (x00 > xone) goto L160;
01688 if ((xone-x11)>epsilon) break;
01689 xtwo = xone;
01690 y = 0;
01691 if (!mside) y -= atick[0];
01692 Rotate(xone,y,cosphi,sinphi,x0,y0,xpl2,ypl2);
01693 Rotate(xtwo,atick[0],cosphi,sinphi,x0,y0,xpl1,ypl1);
01694 if (optionVert) {
01695 if ((x0 != x1) && (y0 != y1)) {
01696 if (mside) {
01697 xpl1=xpl2;
01698 if (cosphi > 0) ypl1 = ypl2 + atick[0];
01699 else ypl1 = ypl2 - atick[0];
01700 }
01701 else {
01702 xpl1 = 0.5*(xpl1 + xpl2);
01703 xpl2 = xpl1;
01704 ypl1 = 0.5*(ypl1 + ypl2) + atick[0];
01705 ypl2 = 0.5*(ypl1 + ypl2) - atick[0];
01706 }
01707 }
01708 }
01709 if (!drawGridOnly) lineaxis->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01710
01711 if (optionGrid) {
01712 Rotate(xone,0,cosphi,sinphi,x0,y0,xpl2,ypl2);
01713 Rotate(xone,grid_side*gridlength,cosphi,sinphi,x0,y0,xpl1,ypl1);
01714 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01715 }
01716
01717 if (!drawGridOnly && !optionUnlab) {
01718
01719
01720 if (noExponent) {
01721 rlab = TMath::Power(10,labelnumber);
01722 snprintf(label,256, "%f", rlab);
01723 LabelsLimits(label,first,last);
01724 while (last > first) {
01725 if (label[last] != '0') break;
01726 label[last] = 0;
01727 last--;
01728 }
01729 if (label[last] == '.') {label[last] = 0; last--;}
01730 } else {
01731 snprintf(label,256, "%d", labelnumber);
01732 LabelsLimits(label,first,last);
01733 }
01734 Rotate (xone,ylabel,cosphi,sinphi,x0,y0,xx,yy);
01735 if ((x0 == x1) && !optionPara) {
01736 if (lside < 0) {
01737 if (mside < 0) {
01738 if (labelnumber == 0) nch=1;
01739 else nch=2;
01740 xx += nch*charheight;
01741 } else {
01742 xx += 0.25*charheight;
01743 }
01744 }
01745 xx += 0.25*charheight;
01746 }
01747 if ((y0 == y1) && !optionDown && !optionUp) {
01748 if (noExponent) yy += 0.33*charheight;
01749 }
01750 if (n1a == 0)goto L210;
01751 kmod = nbinin/n1a;
01752 if (kmod == 0) kmod=1000000;
01753 if ((nbinin <= n1a) || (j == 1) || (j == nbinin) || ((nbinin > n1a)
01754 && (j%kmod == 0))) {
01755 if (labelnumber == 0) {
01756 textaxis->PaintTextNDC(xx,yy,"1");
01757 } else if (labelnumber == 1) {
01758 textaxis->PaintTextNDC(xx,yy,"10");
01759 } else {
01760 if (noExponent) {
01761 textaxis->PaintTextNDC(xx,yy,&label[first]);
01762 } else {
01763 snprintf(chtemp,256, "10^{%d}", labelnumber);
01764 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
01765 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
01766 0, textaxis->GetTextSize(), chtemp);
01767
01768 }
01769 }
01770 }
01771 labelnumber++;
01772 }
01773 L160:
01774 for (k=2;k<10;k++) {
01775
01776
01777 xone = x00+axmul*(TMath::Log10(Double_t(k))+Double_t(decade)-xmnlog);
01778 if (x00 > xone) continue;
01779 if (xone > x11) goto L200;
01780 y = 0;
01781 if (!mside) y -= atick[1];
01782 xtwo = xone;
01783 Rotate(xone,y,cosphi,sinphi,x0,y0,xpl2,ypl2);
01784 Rotate(xtwo,atick[1],cosphi,sinphi,x0,y0,xpl1,ypl1);
01785 if (optionVert) {
01786 if ((x0 != x1) && (y0 != y1)) {
01787 if (mside) {
01788 xpl1 = xpl2;
01789 if (cosphi > 0) ypl1 = ypl2 + atick[1];
01790 else ypl1 = ypl2 - atick[1];
01791 }
01792 else {
01793 xpl1 = 0.5*(xpl1+xpl2);
01794 xpl2 = xpl1;
01795 ypl1 = 0.5*(ypl1+ypl2) + atick[1];
01796 ypl2 = 0.5*(ypl1+ypl2) - atick[1];
01797 }
01798 }
01799 }
01800 idn = n1a*2;
01801 if ((nbinin <= idn) || ((nbinin > idn) && (k == 5))) {
01802 if (!drawGridOnly) lineaxis->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01803
01804
01805
01806 if (moreLogLabels && !optionUnlab && !drawGridOnly && !overlap) {
01807 if (noExponent) {
01808 rlab = Double_t(k)*TMath::Power(10,labelnumber-1);
01809 snprintf(chtemp,256, "%g", rlab);
01810 } else {
01811 if (labelnumber-1 == 0) {
01812 snprintf(chtemp,256, "%d", k);
01813 } else if (labelnumber-1 == 1) {
01814 snprintf(chtemp,256, "%d", 10*k);
01815 } else {
01816 snprintf(chtemp,256, "%d#times10^{%d}", k, labelnumber-1);
01817 }
01818 }
01819 Rotate (xone,ylabel,cosphi,sinphi,x0,y0,xx,yy);
01820 if ((x0 == x1) && !optionPara) {
01821 if (lside < 0) {
01822 if (mside < 0) {
01823 if (labelnumber == 0) nch=1;
01824 else nch=2;
01825 xx += nch*charheight;
01826 } else {
01827 if (labelnumber >= 0) xx += 0.25*charheight;
01828 else xx += 0.50*charheight;
01829 }
01830 }
01831 xx += 0.25*charheight;
01832 }
01833 if ((y0 == y1) && !optionDown && !optionUp) {
01834 if (noExponent) yy += 0.33*charheight;
01835 }
01836 if (optionVert) {
01837 if ((x0 != x1) && (y0 != y1)) {
01838 Rotate(xone,ylabel,cosphi,sinphi,x0,y0,xx,yy);
01839 if (cosphi > 0) yy += ylabel;
01840 else yy -= ylabel;
01841 }
01842 }
01843 textaxis->SetTitle(chtemp);
01844 Double_t u = gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1());
01845 Double_t v = gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1());
01846 if (firstintlab) {
01847 textaxis->GetBoundingBox(wi, hi); wi=(UInt_t)(wi*1.3); hi*=(UInt_t)(hi*1.3);
01848 xi1 = gPad->XtoAbsPixel(u);
01849 yi1 = gPad->YtoAbsPixel(v);
01850 firstintlab = kFALSE;
01851 textaxis->PaintLatex(u,v,0,textaxis->GetTextSize(),chtemp);
01852 } else {
01853 xi2 = gPad->XtoAbsPixel(u);
01854 yi2 = gPad->YtoAbsPixel(v);
01855 if ((x0 == x1 && yi1-hi <= yi2) || (y0 == y1 && xi1+wi >= xi2)){
01856 overlap = kTRUE;
01857 } else {
01858 xi1 = xi2;
01859 yi1 = yi2;
01860 textaxis->GetBoundingBox(wi, hi); wi=(UInt_t)(wi*1.3); hi*=(UInt_t)(hi*1.3);
01861 textaxis->PaintLatex(u,v,0,textaxis->GetTextSize(),chtemp);
01862 }
01863 }
01864 }
01865
01866
01867 if (optionGrid && nbinin <= 5 && ndiv > 100) {
01868 Rotate(xone,0,cosphi,sinphi,x0,y0,xpl2, ypl2);
01869 Rotate(xone,grid_side*gridlength,cosphi,sinphi,x0,y0, xpl1,ypl1);
01870 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
01871 }
01872 }
01873 }
01874 }
01875 L200:
01876 Int_t kuku=0; if (kuku) { }
01877 }
01878
01879
01880 L210:
01881 delete lineaxis;
01882 delete linegrid;
01883 delete textaxis;
01884 }
01885
01886
01887
01888 void TGaxis::AdjustBinSize(Double_t A1, Double_t A2, Int_t nold
01889 ,Double_t &binLow, Double_t &binHigh, Int_t &nbins, Double_t &binWidth)
01890 {
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903 binWidth = TMath::Abs(A2-A1)/Double_t(nold);
01904 if (binWidth <= 1) { binWidth = 1; binLow = int(A1); }
01905 else {
01906 Int_t width = int(binWidth/5) + 1;
01907 binWidth = 5*width;
01908 binLow = int(A1/binWidth)*binWidth;
01909
01910
01911
01912
01913 if (A1 < 0) {
01914 for (Int_t ic=0; ic<1000; ic++) {
01915 Double_t rbl = binLow/binWidth;
01916 Int_t ibl = int(binLow/binWidth);
01917 if ( (rbl-ibl) == 0 || ic > width) { binLow -= 5; break;}
01918 }
01919 }
01920 }
01921 binHigh = int(A2);
01922 nbins = 0;
01923 Double_t xb = binLow;
01924 while (xb <= binHigh) {
01925 xb += binWidth;
01926 nbins++;
01927 }
01928 binHigh = xb - binWidth;
01929 }
01930
01931
01932
01933 void TGaxis::LabelsLimits(const char *label, Int_t &first, Int_t &last)
01934 {
01935
01936
01937 last = strlen(label)-1;
01938 for (Int_t i=0; i<=last; i++) {
01939 if (strchr("1234567890-+.", label[i]) ) { first = i; return; }
01940 }
01941 Error("LabelsLimits", "attempt to draw a blank label");
01942 }
01943
01944
01945
01946 void TGaxis::Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI
01947 ,Double_t XT, Double_t YT, Double_t &U, Double_t &V)
01948 {
01949
01950
01951 U = CFI*X-SFI*Y+XT;
01952 V = SFI*X+CFI*Y+YT;
01953 }
01954
01955
01956
01957 void TGaxis::SavePrimitive(ostream &out, Option_t * )
01958 {
01959
01960
01961 char quote = '"';
01962 if (gROOT->ClassSaved(TGaxis::Class())) {
01963 out<<" ";
01964 } else {
01965 out<<" TGaxis *";
01966 }
01967 out<<"gaxis = new TGaxis("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
01968 <<","<<fWmin<<","<<fWmax<<","<<fNdiv<<","<<quote<<fChopt.Data()<<quote<<");"<<endl;
01969 out<<" gaxis->SetLabelOffset("<<GetLabelOffset()<<");"<<endl;
01970 out<<" gaxis->SetLabelSize("<<GetLabelSize()<<");"<<endl;
01971 out<<" gaxis->SetTickSize("<<GetTickSize()<<");"<<endl;
01972 out<<" gaxis->SetGridLength("<<GetGridLength()<<");"<<endl;
01973 out<<" gaxis->SetTitleOffset("<<GetTitleOffset()<<");"<<endl;
01974 out<<" gaxis->SetTitleSize("<<GetTitleSize()<<");"<<endl;
01975 out<<" gaxis->SetTitleColor("<<GetTextColor()<<");"<<endl;
01976 out<<" gaxis->SetTitleFont("<<GetTextFont()<<");"<<endl;
01977
01978 if (strlen(GetName())) {
01979 out<<" gaxis->SetName("<<quote<<GetName()<<quote<<");"<<endl;
01980 }
01981 if (strlen(GetTitle())) {
01982 out<<" gaxis->SetTitle("<<quote<<GetTitle()<<quote<<");"<<endl;
01983 }
01984
01985 if (fLabelColor != 1) {
01986 if (fLabelColor > 228) {
01987 TColor::SaveColor(out, fLabelColor);
01988 out<<" gaxis->SetLabelColor(ci);" << endl;
01989 } else
01990 out<<" gaxis->SetLabelColor("<<GetLabelColor()<<");"<<endl;
01991 }
01992 if (fLineColor != 1) {
01993 if (fLineColor > 228) {
01994 TColor::SaveColor(out, fLineColor);
01995 out<<" gaxis->SetLineColor(ci);" << endl;
01996 } else
01997 out<<" gaxis->SetLineColor("<<GetLineColor()<<");"<<endl;
01998 }
01999 if (fLineStyle != 1) {
02000 out<<" gaxis->SetLineStyle("<<GetLineStyle()<<");"<<endl;
02001 }
02002 if (fLineWidth != 1) {
02003 out<<" gaxis->SetLineWidth("<<GetLineWidth()<<");"<<endl;
02004 }
02005 if (fLabelFont != 62) {
02006 out<<" gaxis->SetLabelFont("<<GetLabelFont()<<");"<<endl;
02007 }
02008 if (TestBit(TAxis::kMoreLogLabels)) {
02009 out<<" gaxis->SetMoreLogLabels();"<<endl;
02010 }
02011 if (TestBit(TAxis::kNoExponent)) {
02012 out<<" gaxis->SetNoExponent();"<<endl;
02013 }
02014
02015 out<<" gaxis->Draw();"<<endl;
02016 }
02017
02018
02019
02020 void TGaxis::SetDecimals(Bool_t dot)
02021 {
02022
02023
02024
02025
02026
02027
02028
02029 if (dot) SetBit(TAxis::kDecimals);
02030 else ResetBit(TAxis::kDecimals);
02031 }
02032
02033
02034
02035 void TGaxis::SetFunction(const char *funcname)
02036 {
02037
02038
02039 fFunctionName = funcname;
02040 if (strlen(funcname) == 0) {
02041 fFunction = 0;
02042 return;
02043 }
02044 fFunction = (TF1*)gROOT->GetFunction(funcname);
02045 if (!fFunction) {
02046 Error("SetFunction", "unknown function: %s", funcname);
02047 } else {
02048 fWmin = fFunction->GetXmin();
02049 fWmax = fFunction->GetXmax();
02050 }
02051 }
02052
02053
02054
02055 void TGaxis::SetMaxDigits(Int_t maxd)
02056 {
02057
02058
02059
02060
02061
02062
02063
02064
02065 fgMaxDigits = maxd;
02066 if (maxd < 1) fgMaxDigits = 1;
02067 }
02068
02069
02070
02071 void TGaxis::SetName(const char *name)
02072 {
02073
02074
02075 fName = name;
02076 }
02077
02078
02079
02080 void TGaxis::SetMoreLogLabels(Bool_t more)
02081 {
02082
02083
02084
02085
02086
02087 if (more) SetBit(TAxis::kMoreLogLabels);
02088 else ResetBit(TAxis::kMoreLogLabels);
02089 }
02090
02091
02092
02093 void TGaxis::SetNoExponent(Bool_t noExponent)
02094 {
02095
02096
02097
02098
02099
02100 if (noExponent) SetBit(TAxis::kNoExponent);
02101 else ResetBit(TAxis::kNoExponent);
02102 }
02103
02104
02105
02106 void TGaxis::SetOption(Option_t *option)
02107 {
02108
02109
02110 fChopt = option;
02111 }
02112
02113
02114
02115 void TGaxis::SetTitle(const char *title)
02116 {
02117
02118
02119 fTitle = title;
02120 }
02121
02122
02123
02124 void TGaxis::SetTimeFormat(const char *tformat)
02125 {
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144 TString timeformat = tformat;
02145
02146 if (timeformat.Index("%F")>=0 || timeformat.IsNull()) {
02147 fTimeFormat = timeformat;
02148 return;
02149 }
02150
02151 Int_t idF = fTimeFormat.Index("%F");
02152 if (idF>=0) {
02153 Int_t lnF = fTimeFormat.Length();
02154 TString stringtimeoffset = fTimeFormat(idF,lnF);
02155 fTimeFormat = tformat;
02156 fTimeFormat.Append(stringtimeoffset);
02157 } else {
02158 fTimeFormat = tformat;
02159 SetTimeOffset(gStyle->GetTimeOffset());
02160 }
02161 }
02162
02163
02164
02165 void TGaxis::SetTimeOffset(Double_t toffset, Option_t *option)
02166 {
02167
02168
02169
02170 TString opt = option;
02171 opt.ToLower();
02172
02173 Bool_t gmt = kFALSE;
02174 if (opt.Contains("gmt")) gmt = kTRUE;
02175
02176 char tmp[20];
02177 time_t timeoff;
02178 struct tm* utctis;
02179 Int_t idF = fTimeFormat.Index("%F");
02180 if (idF>=0) fTimeFormat.Remove(idF);
02181 fTimeFormat.Append("%F");
02182
02183 timeoff = (time_t)((Long_t)(toffset));
02184 utctis = gmtime(&timeoff);
02185
02186 strftime(tmp,20,"%Y-%m-%d %H:%M:%S",utctis);
02187 fTimeFormat.Append(tmp);
02188
02189
02190 Double_t ds = toffset-(Int_t)toffset;
02191 if(ds!= 0) {
02192 snprintf(tmp,20,"s%g",ds);
02193 fTimeFormat.Append(tmp);
02194 }
02195
02196
02197 if (gmt) fTimeFormat.Append(" GMT");
02198 }
02199
02200
02201
02202 void TGaxis::Streamer(TBuffer &R__b)
02203 {
02204
02205
02206 if (R__b.IsReading()) {
02207 UInt_t R__s, R__c;
02208 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
02209 if (R__v > 3) {
02210 R__b.ReadClassBuffer(TGaxis::Class(), this, R__v, R__s, R__c);
02211 return;
02212 }
02213
02214 TLine::Streamer(R__b);
02215 TAttText::Streamer(R__b);
02216 R__b >> fNdiv;
02217 R__b >> fWmin;
02218 R__b >> fWmax;
02219 R__b >> fGridLength;
02220 R__b >> fTickSize;
02221 R__b >> fLabelOffset;
02222 R__b >> fLabelSize;
02223 R__b >> fTitleOffset;
02224 R__b >> fTitleSize;
02225 R__b >> fLabelFont;
02226 if (R__v > 2) {
02227 R__b >> fLabelColor;
02228 }
02229 fChopt.Streamer(R__b);
02230 fName.Streamer(R__b);
02231 fTitle.Streamer(R__b);
02232 fTimeFormat.Streamer(R__b);
02233 if (R__v > 1) {
02234 fFunctionName.Streamer(R__b);
02235 fFunction = (TF1*)gROOT->GetFunction(fFunctionName.Data());
02236 }
02237 R__b.CheckByteCount(R__s, R__c, TGaxis::IsA());
02238
02239
02240 } else {
02241 R__b.WriteClassBuffer(TGaxis::Class(),this);
02242 }
02243 }