00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4Picture.h"
00015
00016 #include "Riostream.h"
00017 #include "TClass.h"
00018 #include "TObjArray.h"
00019 #include "TObjString.h"
00020 #include "TVirtualPad.h"
00021 #include "TFrame.h"
00022 #include "TList.h"
00023 #include "TPad.h"
00024 #include "TCanvas.h"
00025 #include "TH1.h"
00026 #include "TGraph.h"
00027 #include "THStack.h"
00028 #include "TStyle.h"
00029 #include "TText.h"
00030 #include "TDatime.h"
00031 #include "TArrayL.h"
00032 #include "TAttLine.h"
00033 #include "TAttFill.h"
00034 #include "TAttMarker.h"
00035 #include "TPaveStats.h"
00036 #if ROOT_VERSION_CODE > ROOT_VERSION(5,9,0)
00037 #include "TBufferXML.h"
00038 #endif
00039 enum OptionsIdentifiers {
00040 op_RangeXMin = 1,
00041 op_RangeXMax = 2,
00042 op_RangeYMin = 3,
00043 op_RangeYMax = 4,
00044
00045 op_LineColor = 5,
00046 op_LineStyle = 6,
00047 op_LineWidth = 7,
00048
00049 op_FillColor = 8,
00050 op_FillStyle = 9,
00051
00052 op_MarkerColor = 10,
00053 op_MarkerSize = 11,
00054 op_MarkerStyle = 12,
00055
00056 op_LogScaleX = 13,
00057 op_LogScaleY = 14,
00058 op_LogScaleZ = 15,
00059
00060 op_TitleTime = 16,
00061 op_TitleDate = 17,
00062 op_TitleItem = 18,
00063
00064 op_HisStatsX1 = 19,
00065 op_HisStatsY1 = 20,
00066 op_HisStatsX2 = 21,
00067 op_HisStatsY2 = 22,
00068
00069
00070
00071 op_HisStats = 24,
00072 op_HisTitle = 25,
00073 op_LegendDraw = 26,
00074 op_Crosshair = 27,
00075 op_AutoScale = 28,
00076 op_Superimpose = 29,
00077 op_ContentModified = 30,
00078 op_PadModified = 31,
00079
00080 op_RangeZMin = 32,
00081 op_RangeZMax = 33,
00082
00083 op_FullDim = 34,
00084 op_FullXMin = 35,
00085 op_FullXMax = 36,
00086 op_FullYMin = 37,
00087 op_FullYMax = 38,
00088 op_FullZMin = 39,
00089 op_FullZMax = 40,
00090 op_AxisX = 41,
00091 op_AxisY = 53,
00092 op_AxisZ = 65,
00093 op_Pad = 77,
00094 op_HisStatsOpt = 85,
00095 op_HisStatsFit = 86,
00096 op_RebinX = 87,
00097 op_RebinY = 88,
00098
00099 op_TitleX1 = 89,
00100 op_TitleY1 = 90,
00101 op_TitleX2 = 91,
00102 op_TitleY2 = 92,
00103 op_TitleTextSz = 93,
00104
00105 op_ObjsBound = 0x4000,
00106
00107 op_Style = op_ObjsBound,
00108 op_Draw = op_ObjsBound+1,
00109 op_HisStatsOptF = op_ObjsBound+2,
00110 op_HisStatsFitF = op_ObjsBound+3
00111
00112 };
00113
00114 TGo4Picture::TGo4Picture() :
00115 TNamed(),
00116 fiNDivX(1),
00117 fiNDivY(1),
00118 fiPosX(0),
00119 fiPosY(0),
00120 fxNames(0),
00121 fxObjects(0),
00122 fxSubPictures(0),
00123 fiOptSize(0),
00124 fxOptIndex(),
00125 fxOptValue(),
00126 fxOptObjects(0),
00127 fxSpecialObjects(0),
00128 fiLastIndex(0)
00129 {
00130 }
00131
00132 TGo4Picture::TGo4Picture(const char* name, const char* title, Int_t ndivy, Int_t ndivx) :
00133 TNamed(name, title),
00134 fiNDivX(1),
00135 fiNDivY(1),
00136 fiPosX(0),
00137 fiPosY(0),
00138 fxNames(0),
00139 fxObjects(0),
00140 fxSubPictures(0),
00141 fiOptSize(0),
00142 fxOptIndex(),
00143 fxOptValue(),
00144 fxOptObjects(0),
00145 fxSpecialObjects(0),
00146 fiLastIndex(0)
00147 {
00148 SetDivision(ndivy, ndivx);
00149 }
00150
00151 TGo4Picture::TGo4Picture(TGo4Picture& picture) :
00152 TNamed(),
00153 fiNDivX(1),
00154 fiNDivY(1),
00155 fiPosX(0),
00156 fiPosY(0),
00157 fxNames(0),
00158 fxObjects(0),
00159 fxSubPictures(0),
00160 fiOptSize(0),
00161 fxOptIndex(),
00162 fxOptValue(),
00163 fxOptObjects(0),
00164 fxSpecialObjects(0),
00165 fiLastIndex(0)
00166 {
00167 UpdateFrom(&picture);
00168 }
00169
00170 TGo4Picture::~TGo4Picture()
00171 {
00172 if (fxNames!=0) delete fxNames;
00173 if (fxObjects) delete fxObjects;
00174 if (fxSubPictures!=0) delete fxSubPictures;
00175 if (fxOptObjects!=0) delete fxOptObjects;
00176 if (fxSpecialObjects) delete fxSpecialObjects;
00177 }
00178
00179 void TGo4Picture::SetDrawHeader(Bool_t draw)
00180 {
00181 SetTitleTime(draw);
00182 SetTitleDate(draw);
00183 }
00184
00185 Bool_t TGo4Picture::IsDrawHeader()
00186 {
00187 return IsTitleTime() && IsTitleDate();
00188 }
00189
00190 void TGo4Picture::SetDivision(Int_t ndivy, Int_t ndivx)
00191 {
00192 if (ndivx<1) fiNDivX = 1; else fiNDivX = ndivx;
00193 if (ndivy<1) fiNDivY = 1; else fiNDivY = ndivy;
00194 }
00195
00196 TGo4Picture* TGo4Picture::FindPic(Int_t posy, Int_t posx)
00197 {
00198 if (fxSubPictures==0) return 0; if (posx<0) posx=0; else if(posx>=GetDivX()) posx = GetDivX()-1;
00199 if (posy<0) posy=0; else if(posy>=GetDivY()) posy = GetDivY()-1;
00200 for (Int_t n=0;n<=fxSubPictures->GetLast();n++) {
00201 TGo4Picture* sub = dynamic_cast<TGo4Picture*> (fxSubPictures->At(n));
00202 if (sub!=0)
00203 if (sub->CheckPosition(posy,posx)) return sub;
00204 }
00205 return 0;
00206 }
00207
00208 TGo4Picture* TGo4Picture::Pic(Int_t posy, Int_t posx)
00209 {
00210 if (!IsDivided()) return this;
00211 if (posx<0) posx=0; else if(posx>=GetDivX()) posx = GetDivX()-1;
00212 if (posy<0) posy=0; else if(posy>=GetDivY()) posy = GetDivY()-1;
00213 TGo4Picture* sub = FindPic(posy, posx);
00214 if (sub!=0) return sub;
00215 sub = new TGo4Picture("Sub", "Sub picture");
00216 sub->SetPosition(posy, posx);
00217 if (fxSubPictures==0) {
00218 fxSubPictures = new TObjArray();
00219 fxSubPictures->SetOwner(kTRUE);
00220 }
00221 fxSubPictures->Add(sub);
00222 return sub;
00223 }
00224
00225 void TGo4Picture::SetLinesDivision(Int_t numlines, const Int_t* numbers)
00226 {
00227 SetDivision(numlines,1);
00228 for (Int_t n=0;n<numlines;n++)
00229 if (numbers[n]>1) Pic(n,0)->SetDivision(1,numbers[n]);
00230 }
00231
00232 void TGo4Picture::SetLinesDivision(Int_t numlines,
00233 Int_t n0, Int_t n1, Int_t n2, Int_t n3, Int_t n4,
00234 Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9)
00235 {
00236 const Int_t numbers[10] = { n0, n1, n2, n3, n4, n5, n6, n7, n8, n9};
00237 SetLinesDivision(numlines, numbers);
00238 }
00239
00240 TGo4Picture* TGo4Picture::LPic(Int_t nline, Int_t ncol)
00241 {
00242 if (!IsDivided()) return this;
00243 TGo4Picture* sub = Pic(nline, 0);
00244 if (sub==0) return 0;
00245 if (sub->IsDivided()) return sub->Pic(0,ncol);
00246 else return sub;
00247 }
00248
00249 void TGo4Picture::SetPosition(Int_t posy, Int_t posx)
00250 {
00251 fiPosX = posx; fiPosY = posy;
00252 }
00253
00254 Bool_t TGo4Picture::CheckPosition(Int_t posy, Int_t posx)
00255 {
00256 return (fiPosX == posx) && (fiPosY == posy);
00257 }
00258
00259 void TGo4Picture::AddH1(TH1* histo, Option_t* DrawOption)
00260 {
00261 AddObject(histo, DrawOption);
00262 }
00263
00264 void TGo4Picture::AddH1(Int_t posy, Int_t posx, TH1* histo, Option_t* DrawOption)
00265 {
00266 AddObject(posy, posx, histo, DrawOption);
00267 }
00268
00269 void TGo4Picture::AddHStack(THStack* st, Option_t* DrawOption)
00270 {
00271 AddObject(st, DrawOption);
00272 }
00273
00274 void TGo4Picture::AddHStack(Int_t posy, Int_t posx, THStack* st, Option_t* DrawOption)
00275 {
00276 AddObject(posy, posx, st, DrawOption);
00277 }
00278
00279 void TGo4Picture::AddGraph(TGraph* gr, Option_t* DrawOption)
00280 {
00281 AddObject(gr, DrawOption);
00282 }
00283
00284 void TGo4Picture::AddGraph(Int_t posy, Int_t posx, TGraph* gr, Option_t* DrawOption)
00285 {
00286 AddObject(posy, posx, gr, DrawOption);
00287 }
00288
00289 void TGo4Picture::AddCondition(TNamed* cond)
00290 {
00291 AddObject(cond);
00292 }
00293
00294 void TGo4Picture::AddCondition(Int_t posy, Int_t posx, TNamed* cond)
00295 {
00296 AddObject(posy, posx, cond);
00297 }
00298
00299 void TGo4Picture::AddObjName(const char* name, Option_t* DrawOption)
00300 {
00301 if (name==0) return;
00302 if (fxNames==0) {
00303 fxNames = new TObjArray();
00304 fxNames->SetOwner(kTRUE);
00305 }
00306 fxNames->Add(new TObjString(name));
00307 SetDrawOption(DrawOption, fxNames->GetLast());
00308
00309
00310
00311 fiLastIndex = fxNames->GetLast();
00312 }
00313
00314 void TGo4Picture::AddObjName(Int_t posy, Int_t posx, const char* name, Option_t* DrawOption)
00315 {
00316 if (name!=0)
00317 Pic(posy,posx)->AddObjName(name, DrawOption);
00318 }
00319
00320 void TGo4Picture::ClearObjNames(Bool_t recursive)
00321 {
00322 if (fxNames!=0) {
00323 delete fxNames;
00324 fxNames = 0;
00325 }
00326 fiLastIndex = 0;
00327 if (recursive && fxSubPictures)
00328 for (Int_t n=0;n<=fxSubPictures->GetLast();n++) {
00329 TGo4Picture* sub = dynamic_cast<TGo4Picture*> (fxSubPictures->At(n));
00330 if (sub) sub->ClearObjNames(recursive);
00331 }
00332 }
00333
00334 Int_t TGo4Picture::GetNumObjNames()
00335 {
00336 return (fxNames==0) ? 0 : fxNames->GetLast()+1;
00337 }
00338
00339 Bool_t TGo4Picture::IsObjNames()
00340 {
00341 if (GetNumObjNames()>0) return kTRUE;
00342
00343 if (fxSubPictures)
00344 for (Int_t n=0;n<=fxSubPictures->GetLast();n++) {
00345 TGo4Picture* sub = dynamic_cast<TGo4Picture*> (fxSubPictures->At(n));
00346 if (sub && sub->IsObjNames()) return kTRUE;
00347 }
00348 return kFALSE;
00349 }
00350
00351 const char* TGo4Picture::GetObjName(Int_t n)
00352 {
00353 if ((fxNames==0) || (n<0) || (n>fxNames->GetLast())) return 0;
00354 TObjString* str = dynamic_cast<TObjString*> (fxNames->At(n));
00355 if (str!=0) return str->String().Data();
00356 else return 0;
00357 }
00358
00359 void TGo4Picture::AddObject(TObject* obj, Option_t* DrawOption)
00360 {
00361 if (obj!=0)
00362 AddObjName(obj->GetName(), DrawOption);
00363 }
00364
00365 void TGo4Picture::AddObject(Int_t posy, Int_t posx, TObject* obj, Option_t* DrawOption)
00366 {
00367 if (obj!=0)
00368 AddObjName(posy, posx, obj->GetName(), DrawOption);
00369 }
00370
00371 void TGo4Picture::SetRangeX(Double_t min, Double_t max)
00372 {
00373 SetOptionD(PictureIndex, op_RangeXMin, min);
00374 SetOptionD(PictureIndex, op_RangeXMax, max);
00375 }
00376
00377 Bool_t TGo4Picture::GetRangeX(Double_t& min, Double_t& max)
00378 {
00379 min = 0.; max = 0;
00380 return GetOptionD(PictureIndex, op_RangeXMin, min) &&
00381 GetOptionD(PictureIndex, op_RangeXMax, max);
00382 }
00383
00384 void TGo4Picture::ClearRangeX()
00385 {
00386 ClearOption(PictureIndex, op_RangeXMin);
00387 ClearOption(PictureIndex, op_RangeXMax);
00388 }
00389
00390 void TGo4Picture::SetRangeY(Double_t min, Double_t max)
00391 {
00392 SetOptionD(PictureIndex, op_RangeYMin, min);
00393 SetOptionD(PictureIndex, op_RangeYMax, max);
00394 }
00395
00396 Bool_t TGo4Picture::GetRangeY(Double_t& min, Double_t& max)
00397 {
00398 min = 0.; max = 0;
00399 return GetOptionD(PictureIndex, op_RangeYMin, min) &&
00400 GetOptionD(PictureIndex, op_RangeYMax, max);
00401 }
00402
00403 void TGo4Picture::ClearRangeY()
00404 {
00405 ClearOption(PictureIndex, op_RangeYMin);
00406 ClearOption(PictureIndex, op_RangeYMax);
00407 }
00408
00409 void TGo4Picture::SetRangeZ(Double_t min, Double_t max)
00410 {
00411 SetOptionD(PictureIndex, op_RangeZMin, min);
00412 SetOptionD(PictureIndex, op_RangeZMax, max);
00413 }
00414
00415 Bool_t TGo4Picture::GetRangeZ(Double_t& min, Double_t& max)
00416 {
00417 min = 0.; max = 0;
00418 return GetOptionD(PictureIndex, op_RangeZMin, min) &&
00419 GetOptionD(PictureIndex, op_RangeZMax, max);
00420 }
00421
00422 void TGo4Picture::ClearRangeZ()
00423 {
00424 ClearOption(PictureIndex, op_RangeZMin);
00425 ClearOption(PictureIndex, op_RangeZMax);
00426 }
00427
00428 void TGo4Picture::SetRange(Int_t naxis, Double_t min, Double_t max)
00429 {
00430 switch (naxis) {
00431 case 0: SetRangeX(min, max); break;
00432 case 1: SetRangeY(min, max); break;
00433 case 2: SetRangeZ(min, max); break;
00434 }
00435 }
00436
00437 Bool_t TGo4Picture::GetRange(Int_t naxis, Double_t& min, Double_t& max)
00438 {
00439 switch (naxis) {
00440 case 0: return GetRangeX(min, max); break;
00441 case 1: return GetRangeY(min, max); break;
00442 case 2: return GetRangeZ(min, max); break;
00443 }
00444 return kFALSE;
00445 }
00446
00447 void TGo4Picture::ClearRange(Int_t naxis)
00448 {
00449 switch (naxis) {
00450 case 0: ClearRangeX(); break;
00451 case 1: ClearRangeY(); break;
00452 case 2: ClearRangeZ(); break;
00453 default:
00454 ClearRangeX();
00455 ClearRangeY();
00456 ClearRangeZ();
00457 break;
00458 }
00459 }
00460
00461 void TGo4Picture::SetLogScale(Int_t nscale, Int_t zn)
00462 {
00463 Int_t typ;
00464 switch (nscale) {
00465 case 1: typ = op_LogScaleY; break;
00466 case 2: typ = op_LogScaleZ; break;
00467 default: typ = op_LogScaleX;
00468 }
00469 SetOption(PictureIndex, typ, zn);
00470 }
00471
00472 Int_t TGo4Picture::GetLogScale(Int_t nscale)
00473 {
00474 Int_t typ;
00475 switch (nscale) {
00476 case 1: typ = op_LogScaleY; break;
00477 case 2: typ = op_LogScaleZ; break;
00478 default: typ = op_LogScaleX;
00479 }
00480 Long_t zn;
00481 if (GetOption(PictureIndex, typ, zn)) return zn;
00482 else return 0;
00483 }
00484
00485 void TGo4Picture::GetLogScales(TVirtualPad* pad)
00486 {
00487 if (pad == 0) return;
00488 Long_t zn;
00489 if (GetOption(PictureIndex, op_LogScaleX, zn)) pad->SetLogx(zn);
00490 if (GetOption(PictureIndex, op_LogScaleY, zn)) pad->SetLogy(zn);
00491 if (GetOption(PictureIndex, op_LogScaleZ, zn)) pad->SetLogz(zn);
00492 }
00493
00494 void TGo4Picture::ClearLogScales()
00495 {
00496 ClearOption(PictureIndex, op_LogScaleX);
00497 ClearOption(PictureIndex, op_LogScaleY);
00498 ClearOption(PictureIndex, op_LogScaleZ);
00499 }
00500
00501 void TGo4Picture::SetLineAtt(Color_t color, Style_t style, Width_t width, Int_t index)
00502 {
00503 CheckIndex(index);
00504 SetOption(index, op_LineColor, color);
00505 SetOption(index, op_LineStyle, style);
00506 SetOption(index, op_LineWidth, width);
00507 }
00508
00509 void TGo4Picture::SetLineAtt(TAttLine* line, Int_t index)
00510 {
00511 if (line==0) return;
00512 CheckIndex(index);
00513 SetOption(index, op_LineColor, line->GetLineColor());
00514 SetOption(index, op_LineStyle, line->GetLineStyle());
00515 SetOption(index, op_LineWidth, line->GetLineWidth());
00516 }
00517
00518 Bool_t TGo4Picture::GetLineAtt(TAttLine* line, Int_t index)
00519 {
00520 if (line==0) return kFALSE;
00521 CheckIndex(index);
00522 Long_t color = -111, style=-111, width=-111;
00523 if (GetOption(index, op_LineColor, color)) line->SetLineColor(color);
00524 if (GetOption(index, op_LineStyle, style)) line->SetLineStyle(style);
00525 if (GetOption(index, op_LineWidth, width)) line->SetLineWidth(width);
00526 return (color!=-111) && (style!=-111) && (width!=-111);
00527 }
00528
00529 void TGo4Picture::ClearLineAtt(Int_t index)
00530 {
00531 CheckIndex(index);
00532 ClearOption(index, op_LineColor);
00533 ClearOption(index, op_LineStyle);
00534 ClearOption(index, op_LineWidth);
00535 }
00536
00537 void TGo4Picture::SetFillAtt(Color_t color, Style_t style, Int_t index)
00538 {
00539 CheckIndex(index);
00540 SetOption(index, op_FillColor, color);
00541 SetOption(index, op_FillStyle, style);
00542 }
00543
00544 void TGo4Picture::SetFillAtt(TAttFill* fill, Int_t index)
00545 {
00546 if (fill==0) return;
00547 CheckIndex(index);
00548 SetOption(index, op_FillColor, fill->GetFillColor());
00549 SetOption(index, op_FillStyle, fill->GetFillStyle());
00550 }
00551
00552 Bool_t TGo4Picture::GetFillAtt(TAttFill* fill, Int_t index)
00553 {
00554 if (fill==0) return kFALSE;
00555 CheckIndex(index);
00556 Long_t color = -111, style = -111;
00557 if (GetOption(index, op_FillColor, color)) fill->SetFillColor(color);
00558 if (GetOption(index, op_FillStyle, style)) fill->SetFillStyle(style);
00559 return (color!=-111) && (style!=-111);
00560 }
00561
00562 void TGo4Picture::ClearFillAtt(Int_t index)
00563 {
00564 CheckIndex(index);
00565 ClearOption(index, op_FillColor);
00566 ClearOption(index, op_FillStyle);
00567 }
00568
00569 void TGo4Picture::SetMarkerAtt(Color_t color, Size_t size, Style_t style, Int_t index)
00570 {
00571 CheckIndex(index);
00572 SetOption(index, op_MarkerColor, color);
00573 SetOption(index, op_MarkerSize, int(size));
00574 SetOption(index, op_MarkerStyle, style);
00575 }
00576
00577 void TGo4Picture::SetMarkerAtt(TAttMarker* marker, Int_t index)
00578 {
00579 if (marker==0) return;
00580 CheckIndex(index);
00581 SetOption(index, op_MarkerColor, marker->GetMarkerColor());
00582 SetOption(index, op_MarkerSize, int(marker->GetMarkerSize()));
00583 SetOption(index, op_MarkerStyle, marker->GetMarkerStyle());
00584 }
00585
00586 Bool_t TGo4Picture::GetMarkerAtt(TAttMarker* marker, Int_t index)
00587 {
00588 if (marker==0) return kFALSE;
00589 CheckIndex(index);
00590 Long_t color=-111, size=-111, style=-111;
00591 if (GetOption(index, op_MarkerColor, color)) marker->SetMarkerColor(color);
00592 if (GetOption(index, op_MarkerSize, size)) marker->SetMarkerSize(size);
00593 if (GetOption(index, op_MarkerStyle, style)) marker->SetMarkerStyle(style);
00594 return (color!=-111) && (size!=-111) && (style!=-111);
00595 }
00596
00597 void TGo4Picture::ClearMarkerAtt(Int_t index)
00598 {
00599 CheckIndex(index);
00600 ClearOption(index, op_MarkerColor);
00601 ClearOption(index, op_MarkerSize);
00602 ClearOption(index, op_MarkerStyle);
00603 }
00604
00605 void TGo4Picture::SetRebinX(Int_t ngroupx, Int_t index)
00606 {
00607 CheckIndex(index);
00608 if (ngroupx>0) SetOption(index, op_RebinX, ngroupx);
00609 else ClearOption(index, op_RebinX);
00610 }
00611
00612 void TGo4Picture::SetRebinY(Int_t ngroupy, Int_t index)
00613 {
00614 CheckIndex(index);
00615 if (ngroupy>0) SetOption(index, op_RebinY, ngroupy);
00616 else ClearOption(index, op_RebinY);
00617 }
00618
00619 Int_t TGo4Picture::GetRebinX(Int_t index)
00620 {
00621 CheckIndex(index);
00622 Long_t ngroupx = 0;
00623 if (!GetOption(index, op_RebinX, ngroupx)) ngroupx = 0;
00624 return ngroupx;
00625 }
00626
00627 Int_t TGo4Picture::GetRebinY(Int_t index)
00628 {
00629 CheckIndex(index);
00630 Long_t ngroupy = 0;
00631 if (!GetOption(index, op_RebinY, ngroupy)) ngroupy = 0;
00632 return ngroupy;
00633 }
00634
00635 void TGo4Picture::ClearRebin(Int_t index)
00636 {
00637 CheckIndex(index);
00638 ClearOption(index, op_RebinX);
00639 ClearOption(index, op_RebinY);
00640 }
00641
00642 void TGo4Picture::GetDrawAttributes(TObject* obj, Int_t index)
00643 {
00644 if (obj==0) return;
00645 CheckIndex(index);
00646
00647 GetLineAtt((TAttLine*) Cast(obj, TAttLine::Class()), index);
00648 GetFillAtt((TAttFill*) Cast(obj, TAttFill::Class()), index);
00649 GetMarkerAtt((TAttMarker*) Cast(obj, TAttMarker::Class()), index);
00650 GetH1Att((TH1*) Cast(obj, TH1::Class()), index);
00651 GetPadAtt((TPad*) Cast(obj, TPad::Class()), index);
00652 }
00653
00654 void TGo4Picture::SetDrawAttributes(TObject* obj, Int_t index)
00655 {
00656 if (obj==0) return;
00657 CheckIndex(index);
00658
00659 SetLineAtt((TAttLine*) Cast(obj, TAttLine::Class()), index);
00660 SetFillAtt((TAttFill*) Cast(obj, TAttFill::Class()), index);
00661 SetMarkerAtt((TAttMarker*) Cast(obj, TAttMarker::Class()), index);
00662 SetH1Att((TH1*) Cast(obj, TH1::Class()), index);
00663 SetPadAtt((TPad*) Cast(obj, TPad::Class()), index);
00664 }
00665
00666 void TGo4Picture::SetH1Att(TH1* h1, Int_t index)
00667 {
00668 if (h1==0) return;
00669 CheckIndex(index);
00670 SetAxisAtt(0, h1->GetXaxis(), index);
00671 SetAxisAtt(1, h1->GetYaxis(), index);
00672 SetAxisAtt(2, h1->GetZaxis(), index);
00673 }
00674
00675 void TGo4Picture::GetH1Att(TH1* h1, Int_t index)
00676 {
00677 if (h1==0) return;
00678 CheckIndex(index);
00679 GetAxisAtt(0, h1->GetXaxis(), index);
00680 GetAxisAtt(1, h1->GetYaxis(), index);
00681 GetAxisAtt(2, h1->GetZaxis(), index);
00682 }
00683
00684 void TGo4Picture::SetAxisLabelFontSize(Int_t naxis, Float_t LabelSize, Int_t index)
00685 {
00686 if ((naxis<0) || (naxis>2)) return;
00687 CheckIndex(index);
00688 Int_t op = op_AxisX;
00689 if (naxis==1) op = op_AxisY; else
00690 if (naxis==2) op = op_AxisZ;
00691
00692 SetOptionF(index, op+4, LabelSize);
00693
00694 }
00695
00696 void TGo4Picture::SetAxisTitleFontSize(Int_t naxis, Float_t TitleSize, Int_t index)
00697 {
00698 if ((naxis<0) || (naxis>2)) return;
00699 CheckIndex(index);
00700 Int_t op = op_AxisX;
00701 if (naxis==1) op = op_AxisY; else
00702 if (naxis==2) op = op_AxisZ;
00703
00704 SetOptionF(index, op+10, TitleSize);
00705 }
00706
00707 void TGo4Picture::SetAxisAtt(Int_t naxis,
00708 Color_t AxisColor,
00709 Color_t LabelColor,
00710 Style_t LabelFont,
00711 Float_t LabelOffset,
00712 Float_t LabelSize,
00713 Int_t Ndivisions,
00714 Float_t TickLength,
00715 Color_t TitleColor,
00716 Style_t TitleFont,
00717 Float_t TitleOffset,
00718 Float_t TitleSize,
00719 Bool_t decimals,
00720 const char* ticks,
00721 Int_t bits,
00722 Int_t index)
00723 {
00724 if ((naxis<0) || (naxis>2)) return;
00725 CheckIndex(index);
00726 Int_t op = op_AxisX;
00727 if (naxis==1) op = op_AxisY; else
00728 if (naxis==2) op = op_AxisZ;
00729
00730 SetOption (index, op+0, AxisColor);
00731 SetOption (index, op+1, LabelColor);
00732 SetOption (index, op+2, LabelFont);
00733 SetOptionF(index, op+3, LabelOffset);
00734 SetOptionF(index, op+4, LabelSize);
00735 SetOption (index, op+5, Ndivisions);
00736 SetOptionF(index, op+6, TickLength);
00737 SetOption (index, op+7, TitleColor);
00738 SetOption (index, op+8, TitleFont);
00739 SetOptionF(index, op+9, TitleOffset);
00740 SetOptionF(index, op+10, TitleSize);
00741
00742 if (decimals) bits = bits | 1;
00743 if (ticks!=0) {
00744 if (strchr(ticks,'+')!=0) bits = bits | 2;
00745 if (strchr(ticks,'-')!=0) bits = bits | 4;
00746 }
00747 SetOption (index, op+11, bits);
00748 }
00749
00750 void TGo4Picture::SetAxisAtt(Int_t naxis, TAxis* axis, Int_t index)
00751 {
00752 if (axis!=0)
00753 SetAxisAtt(naxis,
00754 axis->GetAxisColor(),
00755 axis->GetLabelColor(),
00756 axis->GetLabelFont(),
00757 axis->GetLabelOffset(),
00758 axis->GetLabelSize(),
00759 axis->GetNdivisions(),
00760 axis->GetTickLength(),
00761 axis->GetTitleColor(),
00762 axis->GetTitleFont(),
00763 axis->GetTitleOffset(),
00764 axis->GetTitleSize(),
00765 axis->GetDecimals(),
00766 axis->GetTicks(),
00767 axis->TestBits(0x0ff0),
00768 index);
00769 }
00770
00771 void TGo4Picture::GetAxisAtt(Int_t naxis, TAxis* axis, Int_t index)
00772 {
00773 if ((axis==0) || (naxis<0) || (naxis>2)) return;
00774 CheckIndex(index);
00775 Int_t op = op_AxisX;
00776 if (naxis==1) op = op_AxisY; else
00777 if (naxis==2) op = op_AxisZ;
00778
00779 Long_t lv;
00780 Float_t fv;
00781 if (GetOption (index, op+0, lv)) axis->SetAxisColor(lv);
00782 if (GetOption (index, op+1, lv)) axis->SetLabelColor(lv);
00783 if (GetOption (index, op+2, lv)) axis->SetLabelFont(lv);
00784 if (GetOptionF(index, op+3, fv)) axis->SetLabelOffset(fv);
00785 if (GetOptionF(index, op+4, fv)) axis->SetLabelSize(fv);
00786 if (GetOption (index, op+5, lv)) axis->SetNdivisions(lv);
00787 if (GetOptionF(index, op+6, fv)) axis->SetTickLength(fv);
00788 if (GetOption (index, op+7, lv)) axis->SetTitleColor(lv);
00789 if (GetOption (index, op+8, lv)) axis->SetTitleFont(lv);
00790 if (GetOptionF(index, op+9, fv)) axis->SetTitleOffset(fv);
00791 if (GetOptionF(index, op+10, fv)) axis->SetTitleSize(fv);
00792 if (GetOption (index, op+11, lv)) {
00793 axis->SetDecimals((lv & 1) != 0);
00794 TString ticks;
00795 if ((lv & 2) != 0) ticks+="+";
00796 if ((lv & 4) != 0) ticks+="-";
00797 axis->SetTicks(ticks.Data());
00798 for(int n=9;n<24;n++) {
00799 if (n==13) continue;
00800 Int_t mask = BIT(n);
00801 axis->SetBit(mask, (lv & mask) != 0);
00802 }
00803 }
00804 }
00805
00806 void TGo4Picture::SetPadAtt(Int_t BorderMode,
00807 Int_t BorderSize,
00808 Int_t Gridx,
00809 Int_t Gridy,
00810 Double_t Phi,
00811 Double_t Theta,
00812 Int_t Tickx,
00813 Int_t Ticky,
00814 Int_t index)
00815 {
00816 CheckIndex(index);
00817 SetOption (index, op_Pad+ 0, BorderMode);
00818 SetOption (index, op_Pad+ 1, BorderSize);
00819 SetOption (index, op_Pad+ 2, Gridx);
00820 SetOption (index, op_Pad+ 3, Gridy);
00821 SetOptionD(index, op_Pad+ 4, Phi);
00822 SetOptionD(index, op_Pad+ 5, Theta);
00823 SetOption (index, op_Pad+ 6, Tickx);
00824 SetOption (index, op_Pad+ 7, Ticky);
00825 }
00826
00827 void TGo4Picture::SetPadAtt(TPad* pad, Int_t index)
00828 {
00829 if (pad==0) return;
00830 CheckIndex(index);
00831 SetPadAtt(pad->GetBorderMode(),
00832 pad->GetBorderSize(),
00833 pad->GetGridx(),
00834 pad->GetGridy(),
00835 pad->GetPhi(),
00836 pad->GetTheta(),
00837 pad->GetTickx(),
00838 pad->GetTicky(),
00839 index);
00840 SetDrawAttributes(pad->GetFrame(), index);
00841 }
00842
00843 void TGo4Picture::GetPadAtt(TPad* pad, Int_t index)
00844 {
00845 if (pad==0) return;
00846 CheckIndex(index);
00847
00848 Long_t lv;
00849 Double_t dv;
00850 if (GetOption (index, op_Pad+ 0, lv)) pad->SetBorderMode(lv);
00851 if (GetOption (index, op_Pad+ 1, lv)) pad->SetBorderSize(lv);
00852 if (GetOption (index, op_Pad+ 2, lv)) pad->SetGridx(lv);
00853 if (GetOption (index, op_Pad+ 3, lv)) pad->SetGridy(lv);
00854 if (GetOptionD(index, op_Pad+ 4, dv)) pad->SetPhi(dv);
00855 if (GetOptionD(index, op_Pad+ 5, dv)) pad->SetTheta(dv);
00856 if (GetOption (index, op_Pad+ 6, lv)) pad->SetTickx(lv);
00857 if (GetOption (index, op_Pad+ 7, lv)) pad->SetTicky(lv);
00858 GetDrawAttributes(pad->GetFrame(), index);
00859 }
00860
00861 void* TGo4Picture::Cast(TObject* obj, TClass* cl)
00862 {
00863 if ((obj==0) || (cl==0)) return 0;
00864 Int_t shift = obj->IsA()->GetBaseClassOffset(cl);
00865 if (shift<0) return 0;
00866 return (char*) obj + shift;
00867 }
00868
00869 void TGo4Picture::SetHisStats(Bool_t on)
00870 {
00871 SetOption(PictureIndex, op_HisStats, on ? 1 : 0);
00872 }
00873
00874 Bool_t TGo4Picture::IsHisStats() const
00875 {
00876 Long_t zn = kTRUE;
00877 GetOption(PictureIndex, op_HisStats, zn);
00878 return zn!=0;
00879 }
00880
00881 void TGo4Picture::SetStatsAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
00882 Int_t optstat, const char* statformat,
00883 Int_t optfit, const char* fitformat)
00884 {
00885 SetOptionD(PictureIndex, op_HisStatsX1, x1);
00886 SetOptionD(PictureIndex, op_HisStatsY1, y1);
00887 SetOptionD(PictureIndex, op_HisStatsX2, x2);
00888 SetOptionD(PictureIndex, op_HisStatsY2, y2);
00889
00890 SetOption(PictureIndex, op_HisStatsOpt, optstat);
00891 SetStrOption(PictureIndex, op_HisStatsOptF, statformat);
00892 SetOption(PictureIndex, op_HisStatsFit, optfit);
00893 SetStrOption(PictureIndex, op_HisStatsFitF, fitformat);
00894 }
00895
00896 void TGo4Picture::SetStatsAttr(TPaveStats* stats)
00897 {
00898 if (stats!=0)
00899 SetStatsAttr(stats->GetX1NDC(), stats->GetY1NDC(),
00900 stats->GetX2NDC(), stats->GetY2NDC(),
00901 stats->GetOptStat(), stats->GetStatFormat(),
00902 stats->GetOptFit(), stats->GetFitFormat());
00903 }
00904
00905 Bool_t TGo4Picture::GetStatsAttr(TPaveStats* stats)
00906 {
00907 if (stats==0) return kFALSE;
00908
00909 Double_t x1, y1, x2, y2;
00910 if (GetOptionD(PictureIndex, op_HisStatsX1, x1) &&
00911 GetOptionD(PictureIndex, op_HisStatsY1, y1) &&
00912 GetOptionD(PictureIndex, op_HisStatsX2, x2) &&
00913 GetOptionD(PictureIndex, op_HisStatsY2, y2)) {
00914 stats->SetX1NDC(x1);
00915 stats->SetY1NDC(y1);
00916 stats->SetX2NDC(x2);
00917 stats->SetY2NDC(y2);
00918 stats->ConvertNDCtoPad();
00919 }
00920
00921 Long_t optstat, optfit;
00922 if (GetOption(PictureIndex, op_HisStatsOpt, optstat))
00923 stats->SetOptStat(optstat);
00924
00925 if (GetOption(PictureIndex, op_HisStatsFit, optfit))
00926 stats->SetOptFit(optfit);
00927
00928 const char* fmtstat = GetStrOption(PictureIndex, op_HisStatsOptF);
00929 if (fmtstat!=0) stats->SetStatFormat(fmtstat);
00930
00931 const char* fmtfit = GetStrOption(PictureIndex, op_HisStatsFitF);
00932 if (fmtfit!=0) stats->SetFitFormat(fmtfit);
00933
00934 return kTRUE;
00935 }
00936
00937 void TGo4Picture::SetHisTitle(bool on)
00938 {
00939 SetOption(PictureIndex, op_HisTitle, on ? 1 : 0);
00940 }
00941
00942 Bool_t TGo4Picture::IsHisTitle() const
00943 {
00944 Long_t zn = kTRUE;
00945 GetOption(PictureIndex, op_HisTitle, zn);
00946 return zn!=0;
00947 }
00948
00949 void TGo4Picture::SetTitleAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t textsize)
00950 {
00951 SetOptionD(PictureIndex, op_TitleX1, x1);
00952 SetOptionD(PictureIndex, op_TitleY1, y1);
00953 SetOptionD(PictureIndex, op_TitleX2, x2);
00954 SetOptionD(PictureIndex, op_TitleY2, y2);
00955
00956 if (textsize!=0.)
00957 SetOptionD(PictureIndex, op_TitleTextSz, textsize);
00958 }
00959
00960 void TGo4Picture::SetTitleAttr(TPaveText* titl)
00961 {
00962 if (titl!=0) {
00963 SetTitleAttr(titl->GetX1NDC(), titl->GetY1NDC(),
00964 titl->GetX2NDC(), titl->GetY2NDC(),
00965 titl->GetTextSize());
00966 }
00967 }
00968
00969 Bool_t TGo4Picture::HasTitleAttr()
00970 {
00971 return (FindOptPos(PictureIndex, op_TitleX1)>=0) &&
00972 (FindOptPos(PictureIndex, op_TitleX2)>=0) &&
00973 (FindOptPos(PictureIndex, op_TitleY1)>=0) &&
00974 (FindOptPos(PictureIndex, op_TitleY2)>=0);
00975 }
00976
00977
00978 Bool_t TGo4Picture::GetTitleAttr(TPaveText* titl)
00979 {
00980 if (titl==0) return kFALSE;
00981
00982 Double_t x1, y1, x2, y2, sz(0.);
00983 if (GetOptionD(PictureIndex, op_TitleX1, x1) &&
00984 GetOptionD(PictureIndex, op_TitleY1, y1) &&
00985 GetOptionD(PictureIndex, op_TitleX2, x2) &&
00986 GetOptionD(PictureIndex, op_TitleY2, y2)) {
00987 titl->SetX1NDC(x1);
00988 titl->SetY1NDC(y1);
00989 titl->SetX2NDC(x2);
00990 titl->SetY2NDC(y2);
00991 titl->ConvertNDCtoPad();
00992 }
00993
00994 if (GetOptionD(PictureIndex, op_TitleTextSz, sz))
00995 titl->SetTextSize(sz);
00996 else
00997 titl->SetTextSize(0);
00998
00999 return kTRUE;
01000 }
01001
01002
01003 void TGo4Picture::SetTitleTime(Bool_t on)
01004 {
01005 SetOption(PictureIndex, op_TitleTime, on ? 1 : 0);
01006 }
01007
01008 Bool_t TGo4Picture::IsTitleTime() const
01009 {
01010 Long_t zn = kTRUE;
01011 GetOption(PictureIndex, op_TitleTime, zn);
01012 return zn!=0;
01013 }
01014
01015 void TGo4Picture::SetTitleDate(Bool_t on)
01016 {
01017 SetOption(PictureIndex, op_TitleDate, on ? 1 : 0);
01018 }
01019
01020 Bool_t TGo4Picture::IsTitleDate() const
01021 {
01022 Long_t zn = kFALSE;
01023 GetOption(PictureIndex, op_TitleDate, zn);
01024 return zn!=0;
01025 }
01026
01027 void TGo4Picture::SetTitleItem(Bool_t on)
01028 {
01029 SetOption(PictureIndex, op_TitleItem, on ? 1 : 0);
01030 }
01031
01032 Bool_t TGo4Picture::IsTitleItem() const
01033 {
01034 Long_t zn = kFALSE;
01035 GetOption(PictureIndex, op_TitleItem, zn);
01036 return zn!=0;
01037 }
01038
01039 void TGo4Picture::SetLegendDraw(bool on)
01040 {
01041 SetOption(PictureIndex, op_LegendDraw, on ? 1 : 0);
01042 }
01043
01044 bool TGo4Picture::IsLegendDraw() const
01045 {
01046 Long_t zn = kTRUE;
01047 GetOption(PictureIndex, op_LegendDraw, zn);
01048 return zn!=0;
01049 }
01050
01051 void TGo4Picture::SetCrosshair(bool on)
01052 {
01053 SetOption(PictureIndex, op_Crosshair, on ? 1 : 0);
01054 }
01055
01056 bool TGo4Picture::IsCrosshair() const
01057 {
01058 Long_t zn = kFALSE;
01059 GetOption(PictureIndex, op_Crosshair, zn);
01060 return zn!=0;
01061 }
01062
01063 void TGo4Picture::SetAutoScale(bool on)
01064 {
01065 SetOption(PictureIndex, op_AutoScale, on ? 1 : 0);
01066 }
01067
01068 bool TGo4Picture::IsAutoScale() const
01069 {
01070 Long_t zn = kTRUE;
01071 GetOption(PictureIndex, op_AutoScale, zn);
01072 return zn!=0;
01073 }
01074
01075 void TGo4Picture::SetSuperimpose(bool on)
01076 {
01077 SetOption(PictureIndex, op_Superimpose, on ? 1 : 0);
01078 }
01079
01080 bool TGo4Picture::IsSuperimpose() const
01081 {
01082 Long_t zn = kFALSE;
01083 GetOption(PictureIndex, op_Superimpose, zn);
01084 return zn!=0;
01085 }
01086
01087 void TGo4Picture::SetContentModified(bool on)
01088 {
01089 SetOption(PictureIndex, op_ContentModified, on ? 1 : 0);
01090 }
01091
01092 bool TGo4Picture::IsContentModified() const
01093 {
01094 Long_t zn = kFALSE;
01095 GetOption(PictureIndex, op_ContentModified, zn);
01096 return zn!=0;
01097 }
01098
01099 void TGo4Picture::SetPadModified(bool on)
01100 {
01101 SetOption(PictureIndex, op_PadModified, on ? 1 : 0);
01102 }
01103
01104 bool TGo4Picture::IsPadModified() const
01105 {
01106 Long_t zn = kFALSE;
01107 GetOption(PictureIndex, op_PadModified, zn);
01108 return zn!=0;
01109 }
01110
01111 void TGo4Picture::ChangeDrawOption(Int_t kind, Int_t value)
01112 {
01113 switch(kind) {
01114 case 0: break;
01115 case 1: break;
01116 case 2: break;
01117 case 3: SetLogScale(0, value); break;
01118 case 4: SetLogScale(1, value); break;
01119 case 5: SetLogScale(2, value); break;
01120 case 6: SetHisStats(value!=0); break;
01121 case 7: SetHisTitle(value!=0); break;
01122 case 8: SetLegendDraw(value!=0); break;
01123 case 9: SetCrosshair(value!=0); break;
01124 case 10: {
01125 Int_t numdim = GetFullRangeDim();
01126 SetAutoScale(value!=0);
01127 Double_t min, max;
01128 if (!IsAutoScale()) {
01129 if ((numdim==1) && !GetRange(1, min, max)) {
01130 GetFullRange(1, min, max);
01131 SetRange(1, min, max);
01132 } else
01133 if ((numdim==2) && !GetRange(1, min, max)) {
01134 GetFullRange(2, min, max);
01135 SetRange(2, min, max);
01136 }
01137 }
01138 break;
01139 }
01140 case 11: SetSuperimpose(value!=0); break;
01141 case 12: SetTitleTime(value!=0); break;
01142 case 13: SetTitleDate(value!=0); break;
01143 case 14: SetTitleItem(value!=0); break;
01144 }
01145 SetPadModified();
01146 }
01147
01148
01149 void TGo4Picture::SetFullRangeDim(Int_t ndim)
01150 {
01151 SetOption(PictureIndex, op_FullDim, ndim);
01152 }
01153
01154 Int_t TGo4Picture::GetFullRangeDim() const
01155 {
01156 Long_t zn = 0;
01157 GetOption(PictureIndex, op_FullDim, zn);
01158 return zn;
01159 }
01160
01161 void TGo4Picture::SetFullRange(Int_t naxis, Double_t min, Double_t max)
01162 {
01163 Int_t op;
01164 switch (naxis) {
01165 case 1: op = op_FullYMin; break;
01166 case 2: op = op_FullZMin; break;
01167 default: op = op_FullXMin; break;
01168 }
01169 SetOptionD(PictureIndex, op, min);
01170 SetOptionD(PictureIndex, op+1, max);
01171 }
01172
01173 Bool_t TGo4Picture::GetFullRange(Int_t naxis, Double_t& min, Double_t& max)
01174 {
01175 Int_t op;
01176 switch (naxis) {
01177 case 1: op = op_FullYMin; break;
01178 case 2: op = op_FullZMin; break;
01179 default: op = op_FullXMin; break;
01180 }
01181 return GetOptionD(PictureIndex, op, min) && GetOptionD(PictureIndex, op+1, max);
01182 }
01183
01184 void TGo4Picture::ClearFullRange(Int_t naxis)
01185 {
01186 if (naxis<0) {
01187 for(int n=0;n<3;n++)
01188 ClearFullRange(n);
01189 ClearOption(PictureIndex, op_FullDim);
01190 }
01191 Int_t op;
01192 switch (naxis) {
01193 case 1: op = op_FullYMin; break;
01194 case 2: op = op_FullZMin; break;
01195 default: op = op_FullXMin; break;
01196 }
01197 ClearOption(PictureIndex, op);
01198 ClearOption(PictureIndex, op+1);
01199 }
01200
01201 void TGo4Picture::UpdateFrom(TGo4Picture* source, TClass* selectedobjclass)
01202 {
01203 if (source==0) return;
01204 Clear();
01205
01206 SetName(source->GetName());
01207 SetTitle(source->GetTitle());
01208
01209 fiNDivX = source->fiNDivX;
01210 fiNDivY = source->fiNDivY;
01211 fiPosX = source->fiPosX;
01212 fiPosY = source->fiPosY;
01213
01214 for (Int_t n=0; n<source->GetNumObjNames();n++)
01215 AddObjName(source->GetObjName(n));
01216
01217 if (source->GetSpecialObjects()!=0)
01218 fxSpecialObjects = (TList*) source->GetSpecialObjects()->Clone();
01219
01220 CopyOptionsFrom(source);
01221
01222 if (source->fxSubPictures!=0) {
01223 fxSubPictures = new TObjArray();
01224 fxSubPictures->SetOwner(kTRUE);
01225 for (Int_t n=0;n<=source->fxSubPictures->GetLast();n++) {
01226 TGo4Picture* sub = dynamic_cast<TGo4Picture*> (source->fxSubPictures->At(n));
01227 if (sub!=0) {
01228 TGo4Picture* newsub = new TGo4Picture;
01229 newsub->UpdateFrom(sub, selectedobjclass);
01230 fxSubPictures->Add(newsub);
01231 }
01232 }
01233 }
01234 }
01235
01236 void TGo4Picture::CopyOptionsFrom(TGo4Picture* source)
01237 {
01238 fiOptSize = source->fiOptSize;
01239 source->fxOptIndex.Copy(fxOptIndex);
01240 source->fxOptValue.Copy(fxOptValue);
01241 if (fxOptObjects!=0) delete fxOptObjects;
01242 fxOptObjects = 0;
01243 if (source->fxOptObjects)
01244 fxOptObjects = (TObjArray*) source->fxOptObjects->Clone();
01245 }
01246
01247
01248 void TGo4Picture::Clear(Option_t* option)
01249 {
01250 fiNDivX = 1;
01251 fiNDivY = 1;
01252 fiPosX = 0;
01253 fiPosY = 0;
01254 if (fxNames!=0) { delete fxNames; fxNames = 0; }
01255 if (fxSubPictures!=0) { delete fxSubPictures; fxSubPictures = 0; }
01256 fiLastIndex = 0;
01257 fiOptSize = 0;
01258 fxOptIndex.Set(0);
01259 fxOptValue.Set(0);
01260 if (fxOptObjects!=0) { delete fxOptObjects; fxOptObjects = 0; }
01261 }
01262
01263 Int_t TGo4Picture::FindOptPos(Short_t index, Short_t typ) const
01264 {
01265 Long_t zn = index + 1 + (typ << 16);
01266 for (Int_t i=0;i<fiOptSize;i++)
01267 if (fxOptIndex[i]==zn) return i;
01268 return -1;
01269 }
01270
01271 Int_t TGo4Picture::ExtendOptPos(Short_t index, Short_t typ)
01272 {
01273 Long_t zn = index + 1 + (typ << 16);
01274 if (fxOptIndex.GetSize()==fiOptSize) {
01275 fxOptIndex.Set(fiOptSize+8);
01276 fxOptValue.Set(fiOptSize+8);
01277 }
01278 fxOptIndex[fiOptSize] = zn;
01279 fiOptSize++;
01280 return fiOptSize-1;
01281 }
01282
01283 void TGo4Picture::SetOption(Short_t index, Short_t typ, Long_t value)
01284 {
01285 if (typ>=op_ObjsBound) return;
01286 Int_t pos = FindOptPos(index,typ);
01287 if (pos<0) pos = ExtendOptPos(index, typ);
01288 fxOptValue[pos] = value;
01289 }
01290
01291 Bool_t TGo4Picture::GetOption(Short_t index, Short_t typ, Long_t& value) const
01292 {
01293 if (typ>=op_ObjsBound) return kFALSE;
01294 Int_t pos = FindOptPos(index, typ);
01295 if (pos<0) return kFALSE;
01296 value = fxOptValue[pos];
01297 return kTRUE;
01298 }
01299
01300 Long_t TGo4Picture::GetI(Short_t index, Short_t typ, Long_t def) const
01301 {
01302 Long_t value = 0;
01303 if (!GetOption(index, typ, value)) return def;
01304 return value;
01305 }
01306
01307 void TGo4Picture::SetOptionF(Short_t index, Short_t typ, Float_t value)
01308 {
01309 Long_t buf;
01310 if (sizeof(Long_t)==sizeof(Float_t))
01311 memcpy(&buf, &value, sizeof(Long_t));
01312 else {
01313 Double_t v(value);
01314 memcpy(&buf, &v, sizeof(Long_t));
01315 }
01316 SetOption(index, typ, buf);
01317 }
01318
01319 Bool_t TGo4Picture::GetOptionF(Short_t index, Short_t typ, Float_t& value)
01320 {
01321 Long_t buf;
01322 Bool_t res = GetOption(index, typ, buf);
01323
01324 if (res){
01325 if (sizeof(Long_t)==sizeof(Float_t))
01326 memcpy(&value, &buf, sizeof(Long_t));
01327 else {
01328 Double_t v;
01329 memcpy(&v, &buf, sizeof(Long_t));
01330 value = v;
01331 }
01332 }
01333 return res;
01334 }
01335
01336 void TGo4Picture::SetOptionD(Short_t index, Short_t typ, Double_t value)
01337 {
01338 Long_t buf;
01339 if (sizeof(Long_t)==sizeof(Float_t)) {
01340 Float_t v(value);
01341 memcpy(&buf, &v, sizeof(Long_t));
01342 } else
01343 memcpy(&buf, &value, sizeof(Long_t));
01344 SetOption(index, typ, buf);
01345 }
01346
01347 Bool_t TGo4Picture::GetOptionD(Short_t index, Short_t typ, Double_t& value)
01348 {
01349 Long_t buf;
01350 Bool_t res = GetOption(index, typ, buf);
01351
01352 if (res){
01353 if (sizeof(Long_t)==sizeof(Float_t)) {
01354 Float_t v;
01355 memcpy(&v, &buf, sizeof(Long_t));
01356 value = v;
01357 } else
01358 memcpy(&value, &buf, sizeof(Long_t));
01359 }
01360 return res;
01361 }
01362
01363 Double_t TGo4Picture::GetD(Short_t index, Short_t typ, Double_t def)
01364 {
01365 Double_t value;
01366 if (!GetOptionD(index, typ, value)) return def;
01367 return value;
01368 }
01369
01370
01371 void TGo4Picture::SetObjOption(Short_t index, Short_t typ, TObject* obj)
01372 {
01373 if (obj==0) return;
01374 if (typ<op_ObjsBound) { delete obj; return; }
01375 Int_t pos = FindOptPos(index, typ);
01376 if (pos>=0) {
01377 TObject* old = fxOptObjects->RemoveAt(fxOptValue[pos]);
01378 delete old;
01379 fxOptObjects->AddAt(obj, fxOptValue[pos]);
01380 } else {
01381 pos = ExtendOptPos(index, typ);
01382 if (fxOptObjects==0) {
01383 fxOptObjects = new TObjArray();
01384 fxOptObjects->SetOwner(kTRUE);
01385 }
01386 fxOptObjects->Add(obj);
01387 fxOptValue[pos] = fxOptObjects->GetLast();
01388 }
01389 }
01390
01391 TObject* TGo4Picture::GetObjOption(Short_t index, Short_t typ)
01392 {
01393 if (typ<op_ObjsBound) return 0;
01394 Int_t pos = FindOptPos(index, typ);
01395 if (pos<0) return 0;
01396 return fxOptObjects->At(fxOptValue[pos]);
01397 }
01398
01399 void TGo4Picture::SetStrOption(Short_t index, Short_t typ, const char* value)
01400 {
01401 if (value==0) return;
01402 SetObjOption(index, typ, new TObjString(value));
01403 }
01404
01405 const char* TGo4Picture::GetStrOption(Short_t index, Short_t typ, const char* defvalue)
01406 {
01407 TObjString* ostr = dynamic_cast<TObjString*> (GetObjOption(index, typ));
01408 if (ostr==0) return defvalue;
01409 return ostr->String().Data();
01410 }
01411
01412 void TGo4Picture::SetDrawOption(Option_t* option, Int_t index)
01413 {
01414 CheckIndex(index);
01415 if (option==0) ClearOption(index, op_Draw);
01416 else SetStrOption(index, op_Draw, option);
01417 }
01418
01419 Option_t* TGo4Picture::GetDrawOption(Int_t index)
01420 {
01421 CheckIndex(index);
01422 return (Option_t*) GetStrOption(index, op_Draw);
01423 }
01424
01425 void TGo4Picture::SetStyle(TStyle* style, Int_t index)
01426 {
01427 if (style==0) return;
01428 CheckIndex(index);
01429 SetObjOption(index, op_Style, new TStyle(*style));
01430 }
01431
01432 TStyle* TGo4Picture::FindStyle(Int_t index)
01433 {
01434 CheckIndex(index);
01435 Int_t pos = FindOptPos(index, op_Style);
01436 if (pos<0) return 0;
01437 return dynamic_cast<TStyle*> (GetObjOption(index, op_Style));
01438 }
01439
01440 TStyle* TGo4Picture::GetStyle(Int_t index)
01441 {
01442 CheckIndex(index);
01443 TStyle* style = FindStyle(index);
01444 if (style==0) {
01445 style = new TStyle(*gStyle);
01446 SetObjOption(index, op_Style, style);
01447 }
01448 return style;
01449 }
01450
01451 void TGo4Picture::ClearOption(Short_t index, Short_t typ)
01452 {
01453 ClearOption(FindOptPos(index,typ));
01454 }
01455
01456 void TGo4Picture::ClearOption(Int_t pos)
01457 {
01458 if (pos<0) return;
01459 Int_t bnd = op_ObjsBound << 16;
01460
01461 if (fxOptIndex[pos]>=bnd) {
01462 for (Int_t i=0;i<fiOptSize;i++)
01463 if (fxOptIndex[i]>=bnd)
01464 if (fxOptValue[i]>fxOptValue[pos]) fxOptValue[i]-=1;
01465 TObject* obj = fxOptObjects->RemoveAt(fxOptValue[pos]);
01466 delete obj;
01467 fxOptObjects->Compress();
01468 if (fxOptObjects->GetLast()<0) {
01469 delete fxOptObjects;
01470 fxOptObjects = 0;
01471 }
01472 }
01473
01474 for (Int_t i=pos;i<fiOptSize-1;i++) {
01475 fxOptIndex[i] = fxOptIndex[i+1];
01476 fxOptValue[i] = fxOptValue[i+1];
01477 }
01478 fiOptSize--;
01479 }
01480
01481 void TGo4Picture::CheckIndex(Int_t& index)
01482 {
01483 if(index==UndefIndex){
01484 if (fiLastIndex>=PictureIndex) index = fiLastIndex;
01485 else index = PictureIndex;
01486 }
01487 }
01488
01489 void TGo4Picture::ClearAllOptions(Short_t index)
01490 {
01491 if (index<0) {
01492 fxOptIndex.Set(0);
01493 fxOptValue.Set(0);
01494 if (fxOptObjects) {
01495 delete fxOptObjects;
01496 fxOptObjects = 0;
01497 }
01498 } else {
01499 Int_t pos = 0;
01500 while (pos<fiOptSize)
01501 if ((fxOptIndex[pos] & 0x7fff)==index+1) ClearOption(pos);
01502 else pos++;
01503 }
01504 }
01505
01506 Int_t TGo4Picture::GetObjAttIndex(TObject* obj)
01507 {
01508 if (obj==0) return UndefIndex;
01509 for (Int_t n=0;n<GetNumObjNames();n++)
01510 if (strcmp(GetObjName(n),obj->GetName())==0) return n;
01511 return UndefIndex;
01512 }
01513
01514 void TGo4Picture::DrawPic(TVirtualPad* pad)
01515 {
01516 if (pad==0) return;
01517 double txt_y = 0.9;
01518 if (IsDivided()) {
01519 pad->Divide(GetDivX(), GetDivY());
01520 for(Int_t posx=0; posx<GetDivX(); posx++)
01521 for(Int_t posy=0; posy<GetDivY(); posy++) {
01522 TGo4Picture* sub = FindPic(posy,posx);
01523 if (sub) sub->DrawPic(pad->GetPad(posy*GetDivX() + posx + 1));
01524 }
01525 } else
01526 for (Int_t indx=0;indx<GetNumObjNames();indx++) {
01527 TString str = "Obj: ";
01528 str += GetObjName(indx);
01529 const char* opt = GetDrawOption(indx);
01530 if ((opt==0) && (indx==0))
01531 opt = GetDrawOption(PictureIndex);
01532 if (opt!=0) {
01533 str += " Opt: ";
01534 str += opt;
01535 }
01536 TText* txt = new TText(0.1, txt_y, str.Data());
01537 pad->cd();
01538 txt->Draw();
01539 if (GetNumObjNames()<8) txt_y -= 0.1;
01540 else txt_y -= 0.8/GetNumObjNames();
01541 }
01542 }
01543
01544 void TGo4Picture::Draw(Option_t* option)
01545 {
01546 TCanvas* c = 0;
01547 if (gPad==0) {
01548 c = new TCanvas();
01549 c->cd();
01550 } else {
01551 c = gPad->GetCanvas();
01552 c->Clear();
01553 c->cd();
01554 }
01555 if (c==0) return;
01556
01557 if (IsDrawHeader()) {
01558 TString txt = c->GetName();
01559 txt += " Pic: ";
01560 txt += GetName();
01561 if (strcmp(GetName(), GetTitle())!=0) {
01562 txt += " Title: ";
01563 txt += GetTitle();
01564 }
01565 c->SetTitle(txt.Data());
01566 }
01567
01568 DrawPic(c);
01569 }
01570
01571 void TGo4Picture::PrintPic(int shift, Bool_t showopt)
01572 {
01573 for (int n=0;n<shift;n++) cout << ' ';
01574 if (IsDivided()) {
01575 cout << "Divided numx:" << GetDivX() << " numy:" << GetDivY() << endl;
01576 for(Int_t posx=0; posx<GetDivX(); posx++)
01577 for(Int_t posy=0; posy<GetDivY(); posy++) {
01578 for (int n=0;n<shift+2;n++) cout << ' ';
01579 cout << "subpic x:" << posx << " y:" << posy << endl;
01580 TGo4Picture* sub = FindPic(posy,posx);
01581 if (sub) sub->PrintPic(shift+4, showopt);
01582 }
01583 } else {
01584 cout << "Objects:" << endl;
01585 for (Int_t num=0; num<GetNumObjNames(); num++) {
01586 const char* objname = GetObjName(num);
01587 for (int n=0;n<shift+2;n++) cout << ' ';
01588 cout << objname;
01589
01590 Option_t* drawopt = GetDrawOption(num);
01591 if (drawopt) cout << " opt: " << drawopt;
01592 cout << endl;
01593 }
01594 if (!showopt) return;
01595 for (int n=0;n<shift;n++) cout << ' ';
01596 cout << "Options:" << endl;
01597 for (Int_t nop=0;nop<fiOptSize;nop++) {
01598 Int_t indx = (fxOptIndex[nop] & 0x00ff);
01599 Int_t op = fxOptIndex[nop] >> 16;
01600 for (int n=0;n<shift+2;n++) cout << ' ';
01601 cout << indx << " " << op << " " << fxOptValue[nop] << endl;
01602 }
01603 }
01604 }
01605
01606 void TGo4Picture::Print(Option_t* option) const
01607 {
01608 cout << "Picture " << GetName() << endl;
01609 ((TGo4Picture*)this)->PrintPic(2, (strstr(option,"attr")!=0));
01610 }
01611
01612 void TGo4Picture::AddSubPicture(TGo4Picture* pic)
01613 {
01614 if (pic == 0) return;
01615 if (fxSubPictures==0) {
01616 fxSubPictures = new TObjArray();
01617 fxSubPictures->SetOwner(kTRUE);
01618 }
01619 fxSubPictures->Add(pic);
01620 }
01621
01622 void TGo4Picture::AddSpecialObject(TObject* obj, Option_t* drawopt)
01623 {
01624 if (fxSpecialObjects==0) {
01625 fxSpecialObjects = new TList;
01626 fxSpecialObjects->SetOwner(kTRUE);
01627 }
01628
01629 fxSpecialObjects->Add(obj, drawopt);
01630 }
01631
01632 void TGo4Picture::AddSpecialObjectXml(const char* xmlcode, Option_t* drawopt)
01633 {
01634 #if ROOT_VERSION_CODE > ROOT_VERSION(5,9,0)
01635 TObject* obj = TBufferXML::ConvertFromXML(xmlcode);
01636 if (obj!=0) AddSpecialObject(obj, drawopt);
01637 #endif
01638 }
01639
01640 Long_t TGo4Picture::GetTotalSize()
01641 {
01642 Long_t sz = IsA()->Size();
01643
01644 if (fxNames) {
01645 sz += TObjArray::Class()->Size() + fxNames->GetSize() * sizeof(void*);
01646 for (int n=0;n<=fxNames->GetLast();n++) {
01647 TObjString* str = (TObjString*) fxNames->At(n);
01648 if (str) sz += str->IsA()->Size() + str->GetString().Length();
01649 }
01650 }
01651
01652 if (fxSubPictures)
01653 sz += TObjArray::Class()->Size() + fxSubPictures->GetSize() * sizeof(void*);
01654
01655 if (fxOptObjects) {
01656 sz += TObjArray::Class()->Size() + fxOptObjects->GetSize() * sizeof(void*);
01657 for (int n=0;n<=fxOptObjects->GetLast();n++) {
01658 TObject* obj = fxOptObjects->At(n);
01659 if (obj) sz += obj->IsA()->Size();
01660 }
01661 }
01662
01663 if (fxSpecialObjects) {
01664 sz += TList::Class()->Size();
01665 TListIter iter(fxSpecialObjects);
01666 TObject* obj = 0;
01667
01668 while ((obj = iter()) != 0)
01669 sz += sizeof(TObjLink) + obj->IsA()->Size();
01670 }
01671
01672 sz += fxOptIndex.GetSize() * sizeof(Long_t);
01673 sz += fxOptValue.GetSize() * sizeof(Long_t);
01674
01675 if (IsDivided())
01676 for(int ny=0;ny<GetDivY();ny++)
01677 for(int nx=0;nx<GetDivX();nx++)
01678 sz += Pic(ny,nx)->GetTotalSize();
01679
01680 return sz;
01681 }
01682
01683
01684 #if ROOT_VERSION_CODE > ROOT_VERSION(5,11,6)
01685 void TGo4Picture::SavePrimitive(ostream& fs, Option_t*)
01686 #else
01687 void TGo4Picture::SavePrimitive(ofstream& fs, Option_t*)
01688 #endif
01689 {
01690 fs << "TGo4Picture *" << GetName() << " = new TGo4Picture(\"" << GetName()
01691 << "\", \"" << GetTitle() << "\");" << endl;
01692 TString name = GetName();
01693 name+="->";
01694
01695 fs << name << "SetCrosshair(" << (IsCrosshair() ? "true" : "false") << ");" << endl;
01696
01697 MakeScript(fs, name.Data());
01698 }
01699
01700 void TGo4Picture::MakeAxisScript(ostream& fs, const char* name, Int_t index, Int_t naxis)
01701 {
01702 if ((naxis<0) || (naxis>2)) return;
01703 const char* axisname = "X";
01704 Int_t op = op_AxisX;
01705 if (naxis==1) { op = op_AxisY; axisname = "Y"; } else
01706 if (naxis==2) { op = op_AxisZ; axisname = "Z"; }
01707
01708 Long_t lv;
01709 Float_t fv;
01710 if (!GetOption (index, op+0, lv)) return;
01711
01712 fs << name << "SetAxisAtt(" << naxis << ", ";
01713 fs << lv << ", ";
01714 if (!GetOption (index, op+1, lv)) lv = gStyle->GetLabelColor(axisname);
01715 fs << lv << ", ";
01716 if (!GetOption (index, op+2, lv)) lv = gStyle->GetLabelFont(axisname);
01717 fs << lv << ", ";
01718 if (!GetOptionF(index, op+3, fv)) fv = gStyle->GetLabelOffset(axisname);
01719 fs << fv << ", ";
01720 if (!GetOptionF(index, op+4, fv)) fv = gStyle->GetLabelSize(axisname);
01721 fs << fv << ", ";
01722 if (!GetOption (index, op+5, lv)) lv = gStyle->GetNdivisions(axisname);
01723 fs << lv << ", ";
01724 if (!GetOptionF(index, op+6, fv)) fv = gStyle->GetTickLength(axisname);
01725 fs << fv << ", ";
01726 if (!GetOption (index, op+7, lv)) lv = gStyle->GetTitleColor(axisname);
01727 fs << lv << ", ";
01728 if (!GetOption (index, op+8, lv)) lv = gStyle->GetTitleFont(axisname);
01729 fs << lv << ", ";
01730 if (!GetOptionF(index, op+9, fv)) fv = gStyle->GetTitleOffset(axisname);
01731 fs << fv << ", ";
01732 if (!GetOptionF(index, op+10, fv)) fv = gStyle->GetTitleSize(axisname);
01733 fs << fv << ", ";
01734
01735 if (GetOption (index, op+11, lv)) {
01736 if ((lv & 1) != 0) fs << "kTRUE, ";
01737 else fs << "kFALSE, ";
01738 TString ticks;
01739 if ((lv & 2) != 0) ticks+="+";
01740 if ((lv & 4) != 0) ticks+="-";
01741 fs << "\"" << ticks <<"\", ";
01742 fs << (lv & 0x0ff0) << ", ";
01743 } else
01744 fs << "kTRUE, \"+\", 0, ";
01745
01746 fs << index << ");" << endl;
01747 }
01748
01749 void TGo4Picture::MakeScript(ostream& fs, const char* name)
01750 {
01751 for(Int_t naxis=0;naxis<3;naxis++)
01752 if (GetLogScale(naxis)>0)
01753 fs << name << "SetLogScale(" << naxis << ", 1);" << endl;
01754
01755 Double_t min, max;
01756 if (GetRangeX(min, max))
01757 fs << name << "SetRangeX(" << min << ", " << max << ");" << endl;
01758 if (GetRangeY(min, max))
01759 fs << name << "SetRangeY(" << min << ", " << max << ");" << endl;
01760 if (GetRangeZ(min, max))
01761 fs << name << "SetRangeZ(" << min << ", " << max << ");" << endl;
01762
01763 TAttLine latt;
01764 TAttFill fatt;
01765 TAttMarker matt;
01766
01767 if (GetLineAtt(&latt,PictureIndex))
01768 fs << name << "SetLineAtt("
01769 << latt.GetLineColor() << ", "
01770 << latt.GetLineStyle() << ", "
01771 << latt.GetLineWidth() << ", " << PictureIndex << ");" << endl;
01772 if (GetFillAtt(&fatt, PictureIndex))
01773 fs << name << "SetFillAtt("
01774 << fatt.GetFillColor() << ", "
01775 << fatt.GetFillStyle() << ", " << PictureIndex << ");" << endl;
01776 if (GetMarkerAtt(&matt, PictureIndex))
01777 fs << name << "SetMarkerAtt("
01778 << matt.GetMarkerColor() << ", "
01779 << matt.GetMarkerSize() << ", "
01780 << matt.GetMarkerStyle()<< ", " << PictureIndex << ");" << endl;
01781
01782 fs << name << "SetHisStats(" << (IsHisStats() ? "true" : "false") << ");" << endl;
01783
01784 if (IsHisStats() && (FindOptPos(PictureIndex, op_HisStatsX1) >= 0)) {
01785 fs << name << "SetStatsAttr("
01786 << GetD(PictureIndex, op_HisStatsX1, gStyle->GetStatX()-gStyle->GetStatW()) << ", "
01787 << GetD(PictureIndex, op_HisStatsY1, gStyle->GetStatY()-gStyle->GetStatH()) << ", "
01788 << GetD(PictureIndex, op_HisStatsX2, gStyle->GetStatX()) << ", "
01789 << GetD(PictureIndex, op_HisStatsY2, gStyle->GetStatY()) << ", "
01790 << GetI(PictureIndex, op_HisStatsOpt, 1111) << ", \""
01791 << GetStrOption(PictureIndex, op_HisStatsOptF, "6.4g") << "\", "
01792 << GetI(PictureIndex, op_HisStatsFit, 111) << ", \""
01793 << GetStrOption(PictureIndex, op_HisStatsFitF, "5.4g") << "\");" << endl;
01794 }
01795
01796 fs << name << "SetHisTitle(" << (IsHisTitle() ? "true" : "false") << ");" << endl;
01797 if (HasTitleAttr()) {
01798 fs << name << "SetTitleAttr("
01799 << GetD(PictureIndex, op_TitleX1, gStyle->GetTitleX()-gStyle->GetTitleW()) << ", "
01800 << GetD(PictureIndex, op_TitleY1, gStyle->GetTitleY()-gStyle->GetTitleH()) << ", "
01801 << GetD(PictureIndex, op_TitleX2, gStyle->GetTitleX()) << ", "
01802 << GetD(PictureIndex, op_TitleY2, gStyle->GetTitleY());
01803
01804 Double_t sz(0.);
01805 if (GetOptionD(PictureIndex, op_TitleTextSz, sz))
01806 fs << ", " << sz;
01807
01808 fs << ");" << endl;
01809
01810 fs << name << "SetTitleTime(" << (IsTitleTime() ? "true" : "false") << ");" << endl;
01811 fs << name << "SetTitleDate(" << (IsTitleDate() ? "true" : "false") << ");" << endl;
01812 fs << name << "SetTitleItem(" << (IsTitleItem() ? "true" : "false") << ");" << endl;
01813 }
01814
01815 fs << name << "SetAutoScale(" << (IsAutoScale() ? "true" : "false") << ");" << endl;
01816
01817 if (IsSuperimpose()) {
01818 fs << name << "SetSuperimpose(true);" << endl;
01819 fs << name << "SetLegendDraw(" << (IsLegendDraw() ? "true" : "false") << ");" << endl;
01820 }
01821
01822 Long_t lv;
01823 Double_t dv;
01824 fs << name << "SetPadAtt(";
01825 if (!GetOption (PictureIndex, op_Pad+ 0, lv)) lv = gStyle->GetPadBorderMode();
01826 fs << lv << ", ";
01827 if (!GetOption (PictureIndex, op_Pad+ 1, lv)) lv = gStyle->GetPadBorderSize();
01828 fs << lv << ", ";
01829 if (!GetOption (PictureIndex, op_Pad+ 2, lv)) lv = gStyle->GetPadGridX();
01830 fs << lv << ", ";
01831 if (!GetOption (PictureIndex, op_Pad+ 3, lv)) lv = gStyle->GetPadGridY();
01832 fs << lv << ", ";
01833 if (!GetOptionD(PictureIndex, op_Pad+ 4, dv)) dv = 0.;
01834 fs << dv << ", ";
01835 if (!GetOptionD(PictureIndex, op_Pad+ 5, dv)) dv = 0.;
01836 fs << dv << ", ";
01837 if (!GetOption (PictureIndex, op_Pad+ 6, lv)) lv = gStyle->GetPadTickX();
01838 fs << lv << ", ";
01839 if (!GetOption (PictureIndex, op_Pad+ 7, lv)) lv = gStyle->GetPadTickY();
01840 fs << lv << ");" << endl;
01841
01842 const char* drawopt = GetDrawOption(PictureIndex);
01843 if (drawopt!=0)
01844 fs << name << "SetDrawOption(\"" << drawopt << "\", " << PictureIndex << ");" << endl;
01845
01846 for(Int_t indx=0;indx<GetNumObjNames();indx++) {
01847 const char* objname = GetObjName(indx);
01848 const char* objopt = GetDrawOption(indx);
01849
01850 fs << name << "AddObjName(\"" << objname << "\"";
01851 if (objopt!=0) fs << ", \"" << objopt << "\"";
01852 fs << ");" << endl;
01853 if (GetLineAtt(&latt,indx))
01854 fs << name << "SetLineAtt("
01855 << latt.GetLineColor() << ", "
01856 << latt.GetLineStyle() << ", "
01857 << latt.GetLineWidth() << ", " << indx << ");" << endl;
01858 if (GetFillAtt(&fatt, indx))
01859 fs << name << "SetFillAtt("
01860 << fatt.GetFillColor() << ", "
01861 << fatt.GetFillStyle() << ", " << indx << ");" << endl;
01862 if (GetMarkerAtt(&matt, indx))
01863 fs << name << "SetMarkerAtt("
01864 << matt.GetMarkerColor() << ", "
01865 << matt.GetMarkerSize() << ", "
01866 << matt.GetMarkerStyle() << ", " << indx << ");" << endl;
01867
01868 MakeAxisScript(fs, name, indx, 0);
01869 MakeAxisScript(fs, name, indx, 1);
01870 MakeAxisScript(fs, name, indx, 2);
01871
01872 if (GetRebinX(indx)>0)
01873 fs << name << "SetRebinX(" << GetRebinX(indx) << ", " << indx << ");" << endl;
01874
01875 if (GetRebinY(indx)>0)
01876 fs << name << "SetRebinY(" << GetRebinY(indx) << ", " << indx << ");" << endl;
01877 }
01878
01879 #if ROOT_VERSION_CODE > ROOT_VERSION(5,9,0)
01880 TListIter iter(fxSpecialObjects);
01881 TObject* obj = 0;
01882 while ((obj=iter())!=0) {
01883
01884 TString xmlbuf = TBufferXML::ConvertToXML(obj);
01885
01886 TString buf = xmlbuf;
01887 Int_t len = 0;
01888 do {
01889 len = buf.Length();
01890 buf.ReplaceAll("\n ","\n");
01891 } while (len!=buf.Length());
01892
01893 buf.ReplaceAll("\n"," ");
01894 buf.ReplaceAll("\"","\\\"");
01895
01896 buf.Prepend("\"");
01897 buf.Append("\"");
01898
01899 if (buf.Length()>950) {
01900 fs << "TString sbuf = \"\";" << endl;
01901 const char* pos = xmlbuf.Data();
01902 while (*pos!=0) {
01903 const char* lastpos = pos;
01904 while ((*pos !=0) && (*pos!='\n')) pos++;
01905 TString subbuf(lastpos, pos-lastpos);
01906 subbuf.ReplaceAll("\"","\\\"");
01907 fs << "TGo4Picture::Add(sbuf,\"" << subbuf << "\");" << endl;
01908 if (*pos==0) break;
01909 pos++;
01910 }
01911 buf = "sbuf";
01912 }
01913
01914 fs << name << "AddSpecialObjectXml(" << buf;
01915
01916 Option_t* opt = iter.GetOption();
01917
01918 if ((opt!=0) && (*opt!=0))
01919 fs << ", \"" << opt << "\"";
01920 fs << ");" << endl;
01921 }
01922 #endif
01923
01924 if (IsDivided()) {
01925 fs << name << "SetDivision(" << GetDivY() << ", " << GetDivX() << ");" << endl;
01926 for(int ny=0;ny<GetDivY();ny++)
01927 for(int nx=0;nx<GetDivX();nx++) {
01928 TString subname = name;
01929 subname+="Pic(";
01930 subname+=ny;
01931 subname+=",";
01932 subname+=nx;
01933 subname+=")->";
01934 Pic(ny,nx)->MakeScript(fs, subname.Data());
01935 }
01936 }
01937 }
01938
01939