GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Picture.cxx
Go to the documentation of this file.
1 // $Id: TGo4Picture.cxx 3061 2021-03-12 15:13:42Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4Picture.h"
15 
16 #include "RConfigure.h"
17 #include "TClass.h"
18 #include "TObjArray.h"
19 #include "TObjString.h"
20 #include "TVirtualPad.h"
21 #include "TFrame.h"
22 #include "TList.h"
23 #include "TCanvas.h"
24 #include "TH1.h"
25 #include "TGraph.h"
26 #include "THStack.h"
27 #include "TStyle.h"
28 #include "TText.h"
29 #include "TDatime.h"
30 #include "TArrayL.h"
31 #include "TAttLine.h"
32 #include "TAttFill.h"
33 #include "TAttMarker.h"
34 #include "TPaveStats.h"
35 #include "TBufferXML.h"
36 
42 
46 
49 
53 
57 
61 
66 
67 // op_PicHeader = 23,
68 
77 
80 
81  op_FullDim = 34,
88  op_AxisX = 41, // 12 parameters
89  op_AxisY = 53, // 12 parameters
90  op_AxisZ = 65, // 12 parameters
91  op_Pad = 77, // 8 parameters
94  op_RebinX = 87,
95  op_RebinY = 88,
96 
97  op_TitleX1 = 89,
98  op_TitleY1 = 90,
99  op_TitleX2 = 91,
102 
104 
109 
111  op_AutoZoom = 100,
112 
114  //op_TimeAxisXFmt= 201, // must be larger han op_ObjsBound for SetStrOption?
115  // check reason for this later JAM
116 
117  op_XYRatioOne = 300, // JAM2016: 1:1 coordinate ratio
118  op_DefaultRatio = 301, // temporary used to reset ratio to default
119 
120  op_ObjsBound = 0x4000,
121 
127 
128 };
129 
131  TNamed(),
132  fiNDivX(1),
133  fiNDivY(1),
134  fiPosX(0),
135  fiPosY(0),
136  fxNames(0),
137  fxObjects(0),
138  fxSubPictures(0),
139  fiOptSize(0),
140  fxOptIndex(),
141  fxOptValue(),
142  fxOptObjects(0),
143  fxSpecialObjects(0),
144  fiLastIndex(0)
145 {
146 }
147 
148 TGo4Picture::TGo4Picture(const char* name, const char* title, Int_t ndivy, Int_t ndivx) :
149  TNamed(name, title),
150  fiNDivX(1),
151  fiNDivY(1),
152  fiPosX(0),
153  fiPosY(0),
154  fxNames(0),
155  fxObjects(0),
156  fxSubPictures(0),
157  fiOptSize(0),
158  fxOptIndex(),
159  fxOptValue(),
160  fxOptObjects(0),
161  fxSpecialObjects(0),
162  fiLastIndex(0)
163 {
164  SetDivision(ndivy, ndivx);
165 }
166 
168  TNamed(),
169  fiNDivX(1),
170  fiNDivY(1),
171  fiPosX(0),
172  fiPosY(0),
173  fxNames(0),
174  fxObjects(0),
175  fxSubPictures(0),
176  fiOptSize(0),
177  fxOptIndex(),
178  fxOptValue(),
179  fxOptObjects(0),
180  fxSpecialObjects(0),
181  fiLastIndex(0)
182 {
183  UpdateFrom(&picture);
184 }
185 
187 {
188  if (fxNames) { delete fxNames; fxNames = 0; }
189  if (fxObjects) { delete fxObjects; fxObjects = 0; }
190  if (fxSubPictures) { delete fxSubPictures; fxSubPictures = 0; }
191  if (fxOptObjects) { delete fxOptObjects; fxOptObjects = 0; }
193 }
194 
195 void TGo4Picture::SetDrawHeader(Bool_t draw)
196 {
197  SetTitleTime(draw);
198  SetTitleDate(draw);
199 }
200 
202 {
203  return IsTitleTime() && IsTitleDate();
204 }
205 
206 void TGo4Picture::SetDivision(Int_t ndivy, Int_t ndivx)
207 {
208  if (ndivx<1) fiNDivX = 1; else fiNDivX = ndivx;
209  if (ndivy<1) fiNDivY = 1; else fiNDivY = ndivy;
210 }
211 
212 TGo4Picture* TGo4Picture::FindPic(Int_t posy, Int_t posx)
213 {
214  if (fxSubPictures==0) return 0;
215  if (posx<0) posx=0; else { if(posx>=GetDivX()) posx = GetDivX()-1; }
216  if (posy<0) posy=0; else { if(posy>=GetDivY()) posy = GetDivY()-1; }
217  for (Int_t n=0;n<=fxSubPictures->GetLast();n++) {
218  TGo4Picture* sub = dynamic_cast<TGo4Picture*> (fxSubPictures->At(n));
219  if (sub!=0)
220  if (sub->CheckPosition(posy,posx)) return sub;
221  }
222  return 0;
223 }
224 
225 TGo4Picture* TGo4Picture::Pic(Int_t posy, Int_t posx)
226 {
227  if (!IsDivided()) return this;
228  if (posx<0) posx=0; else if(posx>=GetDivX()) posx = GetDivX()-1;
229  if (posy<0) posy=0; else if(posy>=GetDivY()) posy = GetDivY()-1;
230  TGo4Picture* sub = FindPic(posy, posx);
231  if (sub!=0) return sub;
232  sub = new TGo4Picture("Sub", "Sub picture");
233  sub->SetPosition(posy, posx);
234  if (fxSubPictures==0) {
235  fxSubPictures = new TObjArray();
236  fxSubPictures->SetOwner(kTRUE);
237  }
238  fxSubPictures->Add(sub);
239  return sub;
240 }
241 
242 void TGo4Picture::SetLinesDivision(Int_t numlines, const Int_t* numbers)
243 {
244  SetDivision(numlines,1);
245  for (Int_t n=0;n<numlines;n++)
246  if (numbers[n]>1) Pic(n,0)->SetDivision(1,numbers[n]);
247 }
248 
249 void TGo4Picture::SetLinesDivision(Int_t numlines,
250  Int_t n0, Int_t n1, Int_t n2, Int_t n3, Int_t n4,
251  Int_t n5, Int_t n6, Int_t n7, Int_t n8, Int_t n9)
252 {
253  const Int_t numbers[10] = { n0, n1, n2, n3, n4, n5, n6, n7, n8, n9};
254  SetLinesDivision(numlines, numbers);
255 }
256 
257 TGo4Picture* TGo4Picture::LPic(Int_t nline, Int_t ncol)
258 {
259  if (!IsDivided()) return this;
260  TGo4Picture* sub = Pic(nline, 0);
261  if (sub==0) return 0;
262  if (sub->IsDivided()) return sub->Pic(0,ncol);
263  else return sub;
264 }
265 
266 void TGo4Picture::SetPosition(Int_t posy, Int_t posx)
267 {
268  fiPosX = posx; fiPosY = posy;
269 }
270 
271 Bool_t TGo4Picture::CheckPosition(Int_t posy, Int_t posx) const
272 {
273  return (fiPosX == posx) && (fiPosY == posy);
274 }
275 
276 void TGo4Picture::AddH1(TH1* histo, Option_t* DrawOption)
277 {
278  AddObject(histo, DrawOption);
279 }
280 
281 void TGo4Picture::AddH1(Int_t posy, Int_t posx, TH1* histo, Option_t* DrawOption)
282 {
283  AddObject(posy, posx, histo, DrawOption);
284 }
285 
286 void TGo4Picture::AddHStack(THStack* st, Option_t* DrawOption)
287 {
288  AddObject(st, DrawOption);
289 }
290 
291 void TGo4Picture::AddHStack(Int_t posy, Int_t posx, THStack* st, Option_t* DrawOption)
292 {
293  AddObject(posy, posx, st, DrawOption);
294 }
295 
296 void TGo4Picture::AddGraph(TGraph* gr, Option_t* DrawOption)
297 {
298  AddObject(gr, DrawOption);
299 }
300 
301 void TGo4Picture::AddGraph(Int_t posy, Int_t posx, TGraph* gr, Option_t* DrawOption)
302 {
303  AddObject(posy, posx, gr, DrawOption);
304 }
305 
306 void TGo4Picture::AddCondition(TNamed* cond)
307 {
308  AddObject(cond);
309 }
310 
311 void TGo4Picture::AddCondition(Int_t posy, Int_t posx, TNamed* cond)
312 {
313  AddObject(posy, posx, cond);
314 }
315 
316 void TGo4Picture::AddObjName(const char* name, Option_t* DrawOption)
317 {
318  if (name==0) return;
319  if (fxNames==0) {
320  fxNames = new TObjArray();
321  fxNames->SetOwner(kTRUE);
322  }
323  fxNames->Add(new TObjString(name));
324  SetDrawOption(DrawOption, fxNames->GetLast());
325 // if ((DrawOption!=0) && (*DrawOption!=0))
326 // SetDrawOption(DrawOption, PictureIndex);
327 
328  fiLastIndex = fxNames->GetLast();
329 }
330 
331 void TGo4Picture::AddObjName(Int_t posy, Int_t posx, const char* name, Option_t* DrawOption)
332 {
333  if (name!=0)
334  Pic(posy,posx)->AddObjName(name, DrawOption);
335 }
336 
337 void TGo4Picture::ClearObjNames(Bool_t recursive)
338 {
339  if (fxNames!=0) {
340  delete fxNames;
341  fxNames = 0;
342  }
343  fiLastIndex = 0;
344  if (recursive && fxSubPictures)
345  for (Int_t n=0;n<=fxSubPictures->GetLast();n++) {
346  TGo4Picture* sub = dynamic_cast<TGo4Picture*> (fxSubPictures->At(n));
347  if (sub) sub->ClearObjNames(recursive);
348  }
349 }
350 
352 {
353  return (fxNames==0) ? 0 : fxNames->GetLast()+1;
354 }
355 
357 {
358  if (GetNumObjNames()>0) return kTRUE;
359 
360  if (fxSubPictures)
361  for (Int_t n=0;n<=fxSubPictures->GetLast();n++) {
362  TGo4Picture* sub = dynamic_cast<TGo4Picture*> (fxSubPictures->At(n));
363  if (sub && sub->IsObjNames()) return kTRUE;
364  }
365  return kFALSE;
366 }
367 
368 const char* TGo4Picture::GetObjName(Int_t n)
369 {
370  if ((fxNames==0) || (n<0) || (n>fxNames->GetLast())) return 0;
371  TObjString* str = dynamic_cast<TObjString*> (fxNames->At(n));
372  if (str!=0) return str->String().Data();
373  else return 0;
374 }
375 
376 void TGo4Picture::AddObject(TObject* obj, Option_t* DrawOption)
377 {
378  if (obj!=0)
379  AddObjName(obj->GetName(), DrawOption);
380 }
381 
382 void TGo4Picture::AddObject(Int_t posy, Int_t posx, TObject* obj, Option_t* DrawOption)
383 {
384  if (obj!=0)
385  AddObjName(posy, posx, obj->GetName(), DrawOption);
386 }
387 
388 void TGo4Picture::SetRangeX(Double_t min, Double_t max)
389 {
392 }
393 
394 Bool_t TGo4Picture::GetRangeX(Double_t& min, Double_t& max) const
395 {
396  min = 0.; max = 0;
397  return GetOptionD(PictureIndex, op_RangeXMin, min) &&
399 }
400 
402 {
405 }
406 
407 void TGo4Picture::SetRangeY(Double_t min, Double_t max)
408 {
411 }
412 
413 Bool_t TGo4Picture::GetRangeY(Double_t& min, Double_t& max) const
414 {
415  min = 0.; max = 0;
416  return GetOptionD(PictureIndex, op_RangeYMin, min) &&
418 }
419 
421 {
424 }
425 
426 void TGo4Picture::SetRangeZ(Double_t min, Double_t max)
427 {
430 }
431 
432 Bool_t TGo4Picture::GetRangeZ(Double_t& min, Double_t& max) const
433 {
434  min = 0.; max = 0;
435  return GetOptionD(PictureIndex, op_RangeZMin, min) &&
437 }
438 
440 {
443 }
444 
445 void TGo4Picture::SetRange(Int_t naxis, Double_t min, Double_t max)
446 {
447  switch (naxis) {
448  case 0: SetRangeX(min, max); break;
449  case 1: SetRangeY(min, max); break;
450  case 2: SetRangeZ(min, max); break;
451  }
452 }
453 
454 Bool_t TGo4Picture::GetRange(Int_t naxis, Double_t& min, Double_t& max) const
455 {
456  switch (naxis) {
457  case 0: return GetRangeX(min, max);
458  case 1: return GetRangeY(min, max);
459  case 2: return GetRangeZ(min, max);
460  }
461  return kFALSE;
462 }
463 
464 void TGo4Picture::ClearRange(Int_t naxis)
465 {
466  switch (naxis) {
467  case 0: ClearRangeX(); break;
468  case 1: ClearRangeY(); break;
469  case 2: ClearRangeZ(); break;
470  default:
471  ClearRangeX();
472  ClearRangeY();
473  ClearRangeZ();
474  break;
475  }
476 }
477 
478 void TGo4Picture::SetLogScale(Int_t nscale, Int_t zn)
479 {
480  Int_t typ;
481  switch (nscale) {
482  case 1: typ = op_LogScaleY; break;
483  case 2: typ = op_LogScaleZ; break;
484  default: typ = op_LogScaleX;
485  }
486  SetOption(PictureIndex, typ, zn);
487 }
488 
489 Int_t TGo4Picture::GetLogScale(Int_t nscale)
490 {
491  Int_t typ;
492  switch (nscale) {
493  case 1: typ = op_LogScaleY; break;
494  case 2: typ = op_LogScaleZ; break;
495  default: typ = op_LogScaleX;
496  }
497  Long_t zn;
498  if (GetOption(PictureIndex, typ, zn)) return zn;
499  else return 0;
500 }
501 
502 void TGo4Picture::GetLogScales(TVirtualPad* pad)
503 {
504  if (pad == 0) return;
505  Long_t zn;
506  if (GetOption(PictureIndex, op_LogScaleX, zn)) pad->SetLogx(zn);
507  if (GetOption(PictureIndex, op_LogScaleY, zn)) pad->SetLogy(zn);
508  if (GetOption(PictureIndex, op_LogScaleZ, zn)) pad->SetLogz(zn);
509 }
510 
512 {
516 }
517 
518 void TGo4Picture::SetLineAtt(Color_t color, Style_t style, Width_t width, Int_t index)
519 {
520  CheckIndex(index);
521  SetOption(index, op_LineColor, color);
522  SetOption(index, op_LineStyle, style);
523  SetOption(index, op_LineWidth, width);
524 }
525 
526 void TGo4Picture::SetLineAtt(TAttLine* line, Int_t index)
527 {
528  if (line==0) return;
529  CheckIndex(index);
530  SetOption(index, op_LineColor, line->GetLineColor());
531  SetOption(index, op_LineStyle, line->GetLineStyle());
532  SetOption(index, op_LineWidth, line->GetLineWidth());
533 }
534 
535 Bool_t TGo4Picture::GetLineAtt(TAttLine* line, Int_t index)
536 {
537  if (line==0) return kFALSE;
538  CheckIndex(index);
539  Long_t color = -111, style=-111, width=-111;
540  if (GetOption(index, op_LineColor, color)) line->SetLineColor(color);
541  if (GetOption(index, op_LineStyle, style)) line->SetLineStyle(style);
542  if (GetOption(index, op_LineWidth, width)) line->SetLineWidth(width);
543  return (color!=-111) && (style!=-111) && (width!=-111);
544 }
545 
546 void TGo4Picture::ClearLineAtt(Int_t index)
547 {
548  CheckIndex(index);
549  ClearOption(index, op_LineColor);
550  ClearOption(index, op_LineStyle);
551  ClearOption(index, op_LineWidth);
552 }
553 
554 void TGo4Picture::SetFillAtt(Color_t color, Style_t style, Int_t index)
555 {
556  CheckIndex(index);
557  SetOption(index, op_FillColor, color);
558  SetOption(index, op_FillStyle, style);
559 }
560 
561 void TGo4Picture::SetFillAtt(TAttFill* fill, Int_t index)
562 {
563  if (fill==0) return;
564  CheckIndex(index);
565  SetOption(index, op_FillColor, fill->GetFillColor());
566  SetOption(index, op_FillStyle, fill->GetFillStyle());
567 }
568 
569 Bool_t TGo4Picture::GetFillAtt(TAttFill* fill, Int_t index)
570 {
571  if (fill==0) return kFALSE;
572  CheckIndex(index);
573  Long_t color = -111, style = -111;
574  if (GetOption(index, op_FillColor, color)) fill->SetFillColor(color);
575  if (GetOption(index, op_FillStyle, style)) fill->SetFillStyle(style);
576  return (color!=-111) && (style!=-111);
577 }
578 
579 void TGo4Picture::ClearFillAtt(Int_t index)
580 {
581  CheckIndex(index);
582  ClearOption(index, op_FillColor);
583  ClearOption(index, op_FillStyle);
584 }
585 
586 void TGo4Picture::SetMarkerAtt(Color_t color, Size_t size, Style_t style, Int_t index)
587 {
588  CheckIndex(index);
589  SetOption(index, op_MarkerColor, color);
590  SetOption(index, op_MarkerSize, int(size));
591  SetOption(index, op_MarkerStyle, style);
592 }
593 
594 void TGo4Picture::SetMarkerAtt(TAttMarker* marker, Int_t index)
595 {
596  if (marker==0) return;
597  CheckIndex(index);
598  SetOption(index, op_MarkerColor, marker->GetMarkerColor());
599  SetOption(index, op_MarkerSize, int(marker->GetMarkerSize()));
600  SetOption(index, op_MarkerStyle, marker->GetMarkerStyle());
601 }
602 
603 Bool_t TGo4Picture::GetMarkerAtt(TAttMarker* marker, Int_t index)
604 {
605  if (marker==0) return kFALSE;
606  CheckIndex(index);
607  Long_t color=-111, size=-111, style=-111;
608  if (GetOption(index, op_MarkerColor, color)) marker->SetMarkerColor(color);
609  if (GetOption(index, op_MarkerSize, size)) marker->SetMarkerSize(size);
610  if (GetOption(index, op_MarkerStyle, style)) marker->SetMarkerStyle(style);
611  return (color!=-111) && (size!=-111) && (style!=-111);
612 }
613 
615 {
616  CheckIndex(index);
617  ClearOption(index, op_MarkerColor);
618  ClearOption(index, op_MarkerSize);
619  ClearOption(index, op_MarkerStyle);
620 }
621 
622 void TGo4Picture::SetRebinX(Int_t ngroupx, Int_t index)
623 {
624  CheckIndex(index);
625  if (ngroupx>0) SetOption(index, op_RebinX, ngroupx);
626  else ClearOption(index, op_RebinX);
627 }
628 
629 void TGo4Picture::SetRebinY(Int_t ngroupy, Int_t index)
630 {
631  CheckIndex(index);
632  if (ngroupy>0) SetOption(index, op_RebinY, ngroupy);
633  else ClearOption(index, op_RebinY);
634 }
635 
636 Int_t TGo4Picture::GetRebinX(Int_t index)
637 {
638  CheckIndex(index);
639  Long_t ngroupx = 0;
640  if (!GetOption(index, op_RebinX, ngroupx)) ngroupx = 0;
641  return ngroupx;
642 }
643 
644 Int_t TGo4Picture::GetRebinY(Int_t index)
645 {
646  CheckIndex(index);
647  Long_t ngroupy = 0;
648  if (!GetOption(index, op_RebinY, ngroupy)) ngroupy = 0;
649  return ngroupy;
650 }
651 
652 void TGo4Picture::ClearRebin(Int_t index)
653 {
654  CheckIndex(index);
655  ClearOption(index, op_RebinX);
656  ClearOption(index, op_RebinY);
657 }
658 
659 void TGo4Picture::GetDrawAttributes(TObject* obj, Int_t index)
660 {
661  if (obj==0) return;
662  CheckIndex(index);
663  GetLineAtt((TAttLine*) Cast(obj, TAttLine::Class()), index);
664  GetFillAtt((TAttFill*) Cast(obj, TAttFill::Class()), index);
665  GetMarkerAtt((TAttMarker*) Cast(obj, TAttMarker::Class()), index);
666  GetH1Att((TH1*) Cast(obj, TH1::Class()), index);
667  GetPadAtt((TPad*) Cast(obj, TPad::Class()), index);
668 }
669 
670 void TGo4Picture::SetDrawAttributes(TObject* obj, Int_t index)
671 {
672  if (obj==0) return;
673  CheckIndex(index);
674  SetLineAtt((TAttLine*) Cast(obj, TAttLine::Class()), index);
675  SetFillAtt((TAttFill*) Cast(obj, TAttFill::Class()), index);
676  SetMarkerAtt((TAttMarker*) Cast(obj, TAttMarker::Class()), index);
677  SetH1Att((TH1*) Cast(obj, TH1::Class()), index);
678  SetPadAtt((TPad*) Cast(obj, TPad::Class()), index);
679 }
680 
681 void TGo4Picture::SetH1Att(TH1* h1, Int_t index)
682 {
683  if (h1==0) return;
684  CheckIndex(index);
685  SetAxisAtt(0, h1->GetXaxis(), index);
686  SetAxisAtt(1, h1->GetYaxis(), index);
687  SetAxisAtt(2, h1->GetZaxis(), index);
688 }
689 
690 void TGo4Picture::GetH1Att(TH1* h1, Int_t index)
691 {
692  if (h1==0) return;
693  CheckIndex(index);
694  GetAxisAtt(0, h1->GetXaxis(), index);
695  GetAxisAtt(1, h1->GetYaxis(), index);
696  GetAxisAtt(2, h1->GetZaxis(), index);
697 }
698 
699 void TGo4Picture::SetAxisLabelFontSize(Int_t naxis, Float_t LabelSize, Int_t index)
700 {
701  if ((naxis<0) || (naxis>2)) return;
702  CheckIndex(index);
703  Int_t op = op_AxisX;
704  if (naxis==1) op = op_AxisY; else
705  if (naxis==2) op = op_AxisZ;
706 
707  SetOptionF(index, op+4, LabelSize);
708 
709 }
710 
711 void TGo4Picture::SetAxisTitleFontSize(Int_t naxis, Float_t TitleSize, Int_t index)
712 {
713  if ((naxis<0) || (naxis>2)) return;
714  CheckIndex(index);
715  Int_t op = op_AxisX;
716  if (naxis==1) op = op_AxisY; else
717  if (naxis==2) op = op_AxisZ;
718 
719  SetOptionF(index, op+10, TitleSize);
720 }
721 
722 void TGo4Picture::SetXAxisAttTime(Bool_t timedisplay, const char* format, Int_t index)
723 {
724  CheckIndex(index);
725  SetOption (index, op_TimeAxisX, timedisplay);
726  SetStrOption(index, op_TimeAxisXFmt, format);
727 }
728 
730 {
732 }
733 
734 void TGo4Picture::SetXAxisTimeFormat(const char* format)
735 {
737 }
738 
740 {
741  Long_t value=0;
743  return value;
744 }
745 
747 {
748  return GetStrOption(PictureIndex, op_TimeAxisXFmt , "%H:%M:%S");
749 }
750 
752 {
754 }
755 
757 {
758  Long_t value=0;
760  return value;
761 }
762 
763 //void TGo4Picture::SetDefaultRatio(Bool_t on)
764 //{
765 // SetOption (PictureIndex, op_DefaultRatio, on);
766 //}
767 //
768 //Bool_t TGo4Picture::CheckDefaultRatio()
769 //{
770 // Long_t value=0;
771 // GetOption(PictureIndex, op_DefaultRatio, value);
772 // return value;
773 //}
774 
775 
776 void TGo4Picture::SetAxisAtt(Int_t naxis,
777  Color_t AxisColor,
778  Color_t LabelColor,
779  Style_t LabelFont,
780  Float_t LabelOffset,
781  Float_t LabelSize,
782  Int_t Ndivisions,
783  Float_t TickLength,
784  Color_t TitleColor,
785  Style_t TitleFont,
786  Float_t TitleOffset,
787  Float_t TitleSize,
788  Bool_t decimals,
789  const char* ticks,
790  Int_t bits,
791  Int_t index)
792 {
793  if ((naxis<0) || (naxis>2)) return;
794  CheckIndex(index);
795  Int_t op = op_AxisX;
796  if (naxis==1) op = op_AxisY; else
797  if (naxis==2) op = op_AxisZ;
798 
799  SetOption (index, op+0, AxisColor);
800  SetOption (index, op+1, LabelColor);
801  SetOption (index, op+2, LabelFont);
802  SetOptionF(index, op+3, LabelOffset);
803  SetOptionF(index, op+4, LabelSize);
804  SetOption (index, op+5, Ndivisions);
805  SetOptionF(index, op+6, TickLength);
806  SetOption (index, op+7, TitleColor);
807  SetOption (index, op+8, TitleFont);
808  SetOptionF(index, op+9, TitleOffset);
809  SetOptionF(index, op+10, TitleSize);
810  // copy all user defined bits
811  if (decimals) bits = bits | 1;
812  if (ticks!=0) {
813  if (strchr(ticks,'+')!=0) bits = bits | 2;
814  if (strchr(ticks,'-')!=0) bits = bits | 4;
815  }
816  SetOption (index, op+11, bits);
817 }
818 
819 void TGo4Picture::SetAxisAtt(Int_t naxis, TAxis* axis, Int_t index)
820 {
821  if (axis!=0)
822  SetAxisAtt(naxis,
823  axis->GetAxisColor(),
824  axis->GetLabelColor(),
825  axis->GetLabelFont(),
826  axis->GetLabelOffset(),
827  axis->GetLabelSize(),
828  axis->GetNdivisions(),
829  axis->GetTickLength(),
830  axis->GetTitleColor(),
831  axis->GetTitleFont(),
832  axis->GetTitleOffset(),
833  axis->GetTitleSize(),
834  axis->GetDecimals(),
835  axis->GetTicks(),
836  axis->TestBits(0x0ff0),
837  index);
838  if(naxis==0)
839  {
840  // support time format only for x axis for the moment
841  SetXAxisAttTime(axis->GetTimeDisplay(), axis->GetTimeFormat(), index);
842  }
843 }
844 
845 void TGo4Picture::GetAxisAtt(Int_t naxis, TAxis* axis, Int_t index)
846 {
847  if ((axis==0) || (naxis<0) || (naxis>2)) return;
848  CheckIndex(index);
849  Int_t op = op_AxisX;
850  if (naxis==1) op = op_AxisY; else
851  if (naxis==2) op = op_AxisZ;
852 
853  Long_t lv;
854  Float_t fv;
855  if (GetOption (index, op+0, lv)) axis->SetAxisColor(lv);
856  if (GetOption (index, op+1, lv)) axis->SetLabelColor(lv);
857  if (GetOption (index, op+2, lv)) axis->SetLabelFont(lv);
858  if (GetOptionF(index, op+3, fv)) axis->SetLabelOffset(fv);
859  if (GetOptionF(index, op+4, fv)) axis->SetLabelSize(fv);
860  if (GetOption (index, op+5, lv)) axis->SetNdivisions(lv);
861  if (GetOptionF(index, op+6, fv)) axis->SetTickLength(fv);
862  if (GetOption (index, op+7, lv)) axis->SetTitleColor(lv);
863  if (GetOption (index, op+8, lv)) axis->SetTitleFont(lv);
864  if (GetOptionF(index, op+9, fv)) axis->SetTitleOffset(fv);
865  if (GetOptionF(index, op+10, fv)) axis->SetTitleSize(fv);
866  if (GetOption (index, op+11, lv)) {
867  axis->SetDecimals((lv & 1) != 0);
868  TString ticks;
869  if ((lv & 2) != 0) ticks+="+";
870  if ((lv & 4) != 0) ticks+="-";
871  axis->SetTicks(ticks.Data());
872  for(int n=9;n<24;n++) {
873  if (n==13) continue;
874  Int_t mask = BIT(n);
875  axis->SetBit(mask, (lv & mask) != 0);
876  }
877  }
878 
879  if(naxis==0)
880  {
881  // time format x axis
882  if (GetOption (index, op_TimeAxisX, lv)) axis->SetTimeDisplay(lv);
883  axis->SetTimeFormat(GetStrOption(index, op_TimeAxisXFmt , "%H:%M:%S"));
884  }
885 
886 }
887 
888 void TGo4Picture::SetPadAtt(Int_t BorderMode,
889  Int_t BorderSize,
890  Int_t Gridx,
891  Int_t Gridy,
892  Double_t Phi,
893  Double_t Theta,
894  Int_t Tickx,
895  Int_t Ticky,
896  Int_t index)
897 {
898  CheckIndex(index);
899  SetOption (index, op_Pad+ 0, BorderMode);
900  SetOption (index, op_Pad+ 1, BorderSize);
901  SetOption (index, op_Pad+ 2, Gridx);
902  SetOption (index, op_Pad+ 3, Gridy);
903  SetOptionD(index, op_Pad+ 4, Phi);
904  SetOptionD(index, op_Pad+ 5, Theta);
905  SetOption (index, op_Pad+ 6, Tickx);
906  SetOption (index, op_Pad+ 7, Ticky);
907 }
908 
909 void TGo4Picture::SetPadAtt(TPad* pad, Int_t index)
910 {
911  if (pad==0) return;
912  CheckIndex(index);
913  SetPadAtt(pad->GetBorderMode(),
914  pad->GetBorderSize(),
915  pad->GetGridx(),
916  pad->GetGridy(),
917  pad->GetPhi(),
918  pad->GetTheta(),
919  pad->GetTickx(),
920  pad->GetTicky(),
921  index);
922  SetDrawAttributes(pad->GetFrame(), index);
923 }
924 
925 void TGo4Picture::GetPadAtt(TPad* pad, Int_t index)
926 {
927  if (pad==0) return;
928  CheckIndex(index);
929 
930  Long_t lv;
931  Double_t dv;
932  if (GetOption (index, op_Pad+ 0, lv)) pad->SetBorderMode(lv);
933  if (GetOption (index, op_Pad+ 1, lv)) pad->SetBorderSize(lv);
934  if (GetOption (index, op_Pad+ 2, lv)) pad->SetGridx(lv);
935  if (GetOption (index, op_Pad+ 3, lv)) pad->SetGridy(lv);
936  if (GetOptionD(index, op_Pad+ 4, dv)) pad->SetPhi(dv);
937  if (GetOptionD(index, op_Pad+ 5, dv)) pad->SetTheta(dv);
938  if (GetOption (index, op_Pad+ 6, lv)) pad->SetTickx(lv);
939  if (GetOption (index, op_Pad+ 7, lv)) pad->SetTicky(lv);
940  GetDrawAttributes(pad->GetFrame(), index);
941 }
942 
943 void* TGo4Picture::Cast(TObject* obj, TClass* cl)
944 {
945  if ((obj==0) || (cl==0)) return 0;
946  Int_t shift = obj->IsA()->GetBaseClassOffset(cl);
947  if (shift<0) return 0;
948  return (char*) obj + shift;
949 }
950 
951 void TGo4Picture::SetFrameAttr(Double_t left, Double_t top, Double_t right, Double_t bottom)
952 {
957 }
958 
960 {
961  if (pad==0) return;
962 
963  if ((TMath::Abs( pad->GetLeftMargin() - gStyle->GetPadLeftMargin()) > 0.001) ||
964  (TMath::Abs( pad->GetTopMargin() - gStyle->GetPadTopMargin()) > 0.001) ||
965  (TMath::Abs( pad->GetRightMargin() - gStyle->GetPadRightMargin()) > 0.001) ||
966  (TMath::Abs( pad->GetBottomMargin() - gStyle->GetPadBottomMargin()) > 0.001))
967  SetFrameAttr(pad->GetLeftMargin(), pad->GetTopMargin(), pad->GetRightMargin(), pad->GetBottomMargin());
968 }
969 
970 Bool_t TGo4Picture::GetFrameAttr(TPad* pad)
971 {
972  if (pad==0) return kFALSE;
973 
974  Double_t v;
975  if (GetOptionD(PictureIndex, op_FrameLeft, v)) pad->SetLeftMargin(v);
976  if (GetOptionD(PictureIndex, op_FrameTop, v)) pad->SetTopMargin(v);
977  if (GetOptionD(PictureIndex, op_FrameRight, v)) pad->SetRightMargin(v);
978  if (GetOptionD(PictureIndex, op_FrameBottom, v)) pad->SetBottomMargin(v);
979  return kTRUE;
980 }
981 
983 {
984  SetOption(PictureIndex, op_HisStats, on ? 1 : 0);
985 }
986 
988 {
989  Long_t zn = kTRUE;
991  return zn!=0;
992 }
993 
994 void TGo4Picture::SetStatsAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
995  Int_t optstat, const char* statformat,
996  Int_t optfit, const char* fitformat)
997 {
1002 
1007 }
1008 
1009 void TGo4Picture::SetStatsAttr(TPaveStats* stats)
1010 {
1011  if (stats!=0)
1012  SetStatsAttr(stats->GetX1NDC(), stats->GetY1NDC(),
1013  stats->GetX2NDC(), stats->GetY2NDC(),
1014  stats->GetOptStat(), stats->GetStatFormat(),
1015  stats->GetOptFit(), stats->GetFitFormat());
1016 }
1017 
1018 Bool_t TGo4Picture::GetStatsAttr(TPaveStats* stats)
1019 {
1020  if (stats==0) return kFALSE;
1021 
1022  Double_t x1, y1, x2, y2;
1027  stats->SetX1NDC(x1);
1028  stats->SetY1NDC(y1);
1029  stats->SetX2NDC(x2);
1030  stats->SetY2NDC(y2);
1031  stats->ConvertNDCtoPad();
1032  }
1033 
1034  Long_t optstat, optfit;
1035  if (GetOption(PictureIndex, op_HisStatsOpt, optstat))
1036  stats->SetOptStat(optstat);
1037 
1038  if (GetOption(PictureIndex, op_HisStatsFit, optfit))
1039  stats->SetOptFit(optfit);
1040 
1041  const char* fmtstat = GetStrOption(PictureIndex, op_HisStatsOptF);
1042  if (fmtstat!=0) stats->SetStatFormat(fmtstat);
1043 
1044  const char* fmtfit = GetStrOption(PictureIndex, op_HisStatsFitF);
1045  if (fmtfit!=0) stats->SetFitFormat(fmtfit);
1046 
1047  return kTRUE;
1048 }
1049 
1051 {
1053 }
1054 
1056 {
1057  Long_t nlvl = 0;
1059  return nlvl;
1060 }
1061 
1063 {
1064  SetOption(PictureIndex, op_HisTitle, on ? 1 : 0);
1065 }
1066 
1068 {
1069  Long_t zn = 1;
1071  return zn != 0;
1072 }
1073 
1074 void TGo4Picture::SetTitleAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t textsize)
1075 {
1080 
1081  if (textsize!=0.)
1083 }
1084 
1085 void TGo4Picture::SetTitleAttr(TPaveText* titl)
1086 {
1087  if (titl!=0) {
1088  SetTitleAttr(titl->GetX1NDC(), titl->GetY1NDC(),
1089  titl->GetX2NDC(), titl->GetY2NDC(),
1090  titl->GetTextSize());
1091  }
1092 }
1093 
1095 {
1096  return (FindOptPos(PictureIndex, op_TitleX1)>=0) &&
1100 }
1101 
1102 Bool_t TGo4Picture::GetTitleAttr(TPaveText* titl)
1103 {
1104  if (titl==0) return kFALSE;
1105 
1106  Double_t x1, y1, x2, y2, sz(0.);
1107  if (GetOptionD(PictureIndex, op_TitleX1, x1) &&
1111  titl->SetX1NDC(x1);
1112  titl->SetY1NDC(y1);
1113  titl->SetX2NDC(x2);
1114  titl->SetY2NDC(y2);
1115  titl->ConvertNDCtoPad();
1116  }
1117 
1119  titl->SetTextSize(sz);
1120  else
1121  titl->SetTextSize(0);
1122 
1123  return kTRUE;
1124 }
1125 
1127 {
1128  SetOption(PictureIndex, op_TitleTime, on ? 1 : 0);
1129 }
1130 
1132 {
1133  Long_t zn = kTRUE;
1135  return zn!=0;
1136 }
1137 
1139 {
1140  SetOption(PictureIndex, op_TitleDate, on ? 1 : 0);
1141 }
1142 
1144 {
1145  Long_t zn = 0;
1147  return zn!=0;
1148 }
1149 
1151 {
1152  SetOption(PictureIndex, op_TitleItem, on ? 1 : 0);
1153 }
1154 
1156 {
1157  Long_t zn = 0;
1159  return zn!=0;
1160 }
1161 
1163 {
1164  SetOption(PictureIndex, op_LegendDraw, on ? 1 : 0);
1165 }
1166 
1168 {
1169  Long_t zn = kTRUE;
1171  return zn!=0;
1172 }
1173 
1175 {
1176  SetOption(PictureIndex, op_Crosshair, on ? 1 : 0);
1177 }
1178 
1180 {
1181  Long_t zn = 0;
1183  return zn!=0;
1184 }
1185 
1187 {
1188  SetOption(PictureIndex, op_AutoScale, on ? 1 : 0);
1189 }
1190 
1192 {
1193  Long_t zn = kTRUE;
1195  return zn!=0;
1196 }
1197 
1199 {
1200  SetOption(PictureIndex, op_Superimpose, on ? 1 : 0);
1201 }
1202 
1204 {
1205  Long_t zn = 0;
1207  return zn!=0;
1208 }
1209 
1211 {
1212  SetOption(PictureIndex, op_ApplyToAll, on ? 1 : 0);
1213 }
1214 
1216 {
1217  Long_t zn = 0;
1219  return zn!=0;
1220 }
1221 
1223 {
1224  SetOption(PictureIndex, op_AutoZoom, on ? 1 : 0);
1225 }
1226 
1228 {
1229  Long_t zn = 0;
1231  return zn!=0;
1232 }
1233 
1235 {
1237 }
1238 
1240 {
1241  Long_t zn = 0;
1243  return zn!=0;
1244 }
1245 
1247 {
1248  SetOption(PictureIndex, op_PadModified, on ? 1 : 0);
1249 }
1250 
1252 {
1253  Long_t zn = 0;
1255  return zn!=0;
1256 }
1257 
1258 void TGo4Picture::ChangeDrawOption(Int_t kind, Int_t value)
1259 {
1260  switch(kind) {
1261  case 0: break;
1262  case 1: break;
1263  case 2: break;
1264  case 3: SetLogScale(0, value); break;
1265  case 4: SetLogScale(1, value); break;
1266  case 5: SetLogScale(2, value); break;
1267  case 6: SetHisStats(value!=0); break;
1268  case 7: SetHisTitle(value!=0); break;
1269  case 8: SetLegendDraw(value!=0); break;
1270  case 9: SetCrosshair(value!=0); break;
1271  case 10: {
1272  Int_t numdim = GetFullRangeDim();
1273  SetAutoScale(value!=0);
1274  Double_t min, max;
1275  if (!IsAutoScale()) { // keep current selection if not autosacle
1276  if ((numdim==1) && !GetRange(1, min, max)) {
1277  GetFullRange(1, min, max);
1278  SetRange(1, min, max);
1279  } else
1280  if ((numdim==2) && !GetRange(1, min, max)) {
1281  GetFullRange(2, min, max);
1282  SetRange(2, min, max);
1283  }
1284  }
1285  break;
1286  }
1287  case 11: SetSuperimpose(value!=0); break;
1288  case 12: SetTitleTime(value!=0); break;
1289  case 13: SetTitleDate(value!=0); break;
1290  case 14: SetTitleItem(value!=0); break;
1291  case 15: SetXAxisTimeDisplay(value!=0); break;
1292  case 17:
1293  SetXYRatioOne(value!=0);
1294  //if (value==0) SetDefaultRatio(true); //
1295  break;
1296  case 18: SetHisContour(value); break;
1297 
1298  }
1299  SetPadModified();
1300 }
1301 
1302 
1304 {
1306 }
1307 
1309 {
1310  Long_t zn = 0;
1312  return zn;
1313 }
1314 
1315 void TGo4Picture::SetFullRange(Int_t naxis, Double_t min, Double_t max)
1316 {
1317  Int_t op;
1318  switch (naxis) {
1319  case 1: op = op_FullYMin; break;
1320  case 2: op = op_FullZMin; break;
1321  default: op = op_FullXMin; break;
1322  }
1323  SetOptionD(PictureIndex, op, min);
1324  SetOptionD(PictureIndex, op+1, max);
1325 }
1326 
1327 Bool_t TGo4Picture::GetFullRange(Int_t naxis, Double_t& min, Double_t& max)
1328 {
1329  Int_t op;
1330  switch (naxis) {
1331  case 1: op = op_FullYMin; break;
1332  case 2: op = op_FullZMin; break;
1333  default: op = op_FullXMin; break;
1334  }
1335  return GetOptionD(PictureIndex, op, min) && GetOptionD(PictureIndex, op+1, max);
1336 }
1337 
1339 {
1340  if (naxis<0) {
1341  for(int n=0;n<3;n++)
1342  ClearFullRange(n);
1344  }
1345  Int_t op;
1346  switch (naxis) {
1347  case 1: op = op_FullYMin; break;
1348  case 2: op = op_FullZMin; break;
1349  default: op = op_FullXMin; break;
1350  }
1352  ClearOption(PictureIndex, op+1);
1353 }
1354 
1355 void TGo4Picture::UpdateFrom(TGo4Picture* source, TClass* selectedobjclass)
1356 {
1357  if (source==0) return;
1358  Clear();
1359 
1360  SetName(source->GetName());
1361  SetTitle(source->GetTitle());
1362 
1363  fiNDivX = source->fiNDivX;
1364  fiNDivY = source->fiNDivY;
1365  fiPosX = source->fiPosX;
1366  fiPosY = source->fiPosY;
1367 
1368  for (Int_t n=0; n<source->GetNumObjNames();n++)
1369  AddObjName(source->GetObjName(n));
1370 
1371  if (source->GetSpecialObjects()!=0)
1372  fxSpecialObjects = (TList*) source->GetSpecialObjects()->Clone();
1373 
1374  CopyOptionsFrom(source);
1375 
1376  if (source->fxSubPictures!=0) {
1377  fxSubPictures = new TObjArray();
1378  fxSubPictures->SetOwner(kTRUE);
1379  for (Int_t n=0;n<=source->fxSubPictures->GetLast();n++) {
1380  TGo4Picture* sub = dynamic_cast<TGo4Picture*> (source->fxSubPictures->At(n));
1381  if (sub!=0) {
1382  TGo4Picture* newsub = new TGo4Picture;
1383  newsub->UpdateFrom(sub, selectedobjclass);
1384  fxSubPictures->Add(newsub);
1385  }
1386  }
1387  }
1388 }
1389 
1391 {
1392  fiOptSize = source->fiOptSize;
1393  source->fxOptIndex.Copy(fxOptIndex);
1394  source->fxOptValue.Copy(fxOptValue);
1395  if (fxOptObjects!=0) delete fxOptObjects;
1396  fxOptObjects = 0;
1397  if (source->fxOptObjects)
1398  fxOptObjects = (TObjArray*) source->fxOptObjects->Clone();
1399 }
1400 
1401 
1402 void TGo4Picture::Clear(Option_t* option)
1403 {
1404  fiNDivX = 1;
1405  fiNDivY = 1;
1406  fiPosX = 0;
1407  fiPosY = 0;
1408  if (fxNames!=0) { delete fxNames; fxNames = 0; }
1409  if (fxSubPictures!=0) { delete fxSubPictures; fxSubPictures = 0; }
1410  fiLastIndex = 0;
1411  fiOptSize = 0;
1412  fxOptIndex.Set(0);
1413  fxOptValue.Set(0);
1414  if (fxOptObjects!=0) { delete fxOptObjects; fxOptObjects = 0; }
1415 }
1416 
1417 Int_t TGo4Picture::FindOptPos(Short_t index, Short_t typ) const
1418 {
1419  Long_t zn = index + 1 + (typ << 16);
1420  for (Int_t i=0;i<fiOptSize;i++)
1421  if (fxOptIndex[i]==zn) return i;
1422  return -1;
1423 }
1424 
1425 Int_t TGo4Picture::ExtendOptPos(Short_t index, Short_t typ)
1426 {
1427  Long_t zn = index + 1 + (typ << 16);
1428  if (fxOptIndex.GetSize()==fiOptSize) {
1429  fxOptIndex.Set(fiOptSize+8);
1430  fxOptValue.Set(fiOptSize+8);
1431  }
1432  fxOptIndex[fiOptSize] = zn;
1433  fiOptSize++;
1434  return fiOptSize-1;
1435 }
1436 
1437 void TGo4Picture::SetOption(Short_t index, Short_t typ, Long_t value)
1438 {
1439  if (typ>=op_ObjsBound) return;
1440  Int_t pos = FindOptPos(index,typ);
1441  if (pos<0) pos = ExtendOptPos(index, typ);
1442  fxOptValue[pos] = value;
1443 }
1444 
1445 Bool_t TGo4Picture::GetOption(Short_t index, Short_t typ, Long_t& value) const
1446 {
1447  if (typ>=op_ObjsBound) return kFALSE;
1448  Int_t pos = FindOptPos(index, typ);
1449  if (pos<0) return kFALSE;
1450  value = fxOptValue[pos];
1451  return kTRUE;
1452 }
1453 
1454 Long_t TGo4Picture::GetI(Short_t index, Short_t typ, Long_t def) const
1455 {
1456  Long_t value = 0;
1457  if (!GetOption(index, typ, value)) return def;
1458  return value;
1459 }
1460 
1461 void TGo4Picture::SetOptionF(Short_t index, Short_t typ, Float_t value)
1462 {
1463  Long_t buf;
1464 
1465 #ifdef R__B64
1466  Double_t v(value);
1467  memcpy(&buf, &v, sizeof(Long_t));
1468 #else
1469  memcpy(&buf, &value, sizeof(Long_t));
1470 #endif
1471  SetOption(index, typ, buf);
1472 }
1473 
1474 Bool_t TGo4Picture::GetOptionF(Short_t index, Short_t typ, Float_t& value) const
1475 {
1476  Long_t buf;
1477  Bool_t res = GetOption(index, typ, buf);
1478 
1479  if (res) {
1480 #ifdef R__B64
1481  Double_t v;
1482  memcpy(&v, &buf, sizeof(Long_t));
1483  value = v;
1484 #else
1485  memcpy(&value, &buf, sizeof(Long_t));
1486 #endif
1487  }
1488  return res;
1489 }
1490 
1491 void TGo4Picture::SetOptionD(Short_t index, Short_t typ, Double_t value)
1492 {
1493  Long_t buf;
1494 #ifdef R__B64
1495  memcpy(&buf, &value, sizeof(Long_t));
1496 #else
1497  Float_t v(value);
1498  memcpy(&buf, &v, sizeof(Long_t));
1499 #endif
1500  SetOption(index, typ, buf);
1501 }
1502 
1503 Bool_t TGo4Picture::GetOptionD(Short_t index, Short_t typ, Double_t& value) const
1504 {
1505  Long_t buf;
1506  Bool_t res = GetOption(index, typ, buf);
1507 
1508  if (res) {
1509 #ifdef R__B64
1510  memcpy(&value, &buf, sizeof(Long_t));
1511 #else
1512  Float_t v;
1513  memcpy(&v, &buf, sizeof(Long_t));
1514  value = v;
1515 #endif
1516  }
1517  return res;
1518 }
1519 
1520 Double_t TGo4Picture::GetD(Short_t index, Short_t typ, Double_t def) const
1521 {
1522  Double_t value;
1523  if (!GetOptionD(index, typ, value)) return def;
1524  return value;
1525 }
1526 
1527 void TGo4Picture::SetObjOption(Short_t index, Short_t typ, TObject* obj)
1528 {
1529  if (obj==0) return;
1530  if (typ<op_ObjsBound) { delete obj; return; }
1531  Int_t pos = FindOptPos(index, typ);
1532  if (pos>=0) {
1533  TObject* old = fxOptObjects->RemoveAt(fxOptValue[pos]);
1534  delete old;
1535  fxOptObjects->AddAt(obj, fxOptValue[pos]);
1536  } else {
1537  pos = ExtendOptPos(index, typ);
1538  if (fxOptObjects==0) {
1539  fxOptObjects = new TObjArray();
1540  fxOptObjects->SetOwner(kTRUE);
1541  }
1542  fxOptObjects->Add(obj);
1543  fxOptValue[pos] = fxOptObjects->GetLast();
1544  }
1545 }
1546 
1547 TObject* TGo4Picture::GetObjOption(Short_t index, Short_t typ) const
1548 {
1549  if (typ<op_ObjsBound) return 0;
1550  Int_t pos = FindOptPos(index, typ);
1551  if (pos<0) return 0;
1552  return fxOptObjects->At(fxOptValue[pos]);
1553 }
1554 
1555 void TGo4Picture::SetStrOption(Short_t index, Short_t typ, const char* value)
1556 {
1557  if (value==0) return;
1558  SetObjOption(index, typ, new TObjString(value));
1559 }
1560 
1561 const char* TGo4Picture::GetStrOption(Short_t index, Short_t typ, const char *defvalue) const
1562 {
1563  TObjString *ostr = dynamic_cast<TObjString*> (GetObjOption(index, typ));
1564  if (!ostr) return defvalue;
1565  return ostr->String().Data();
1566 }
1567 
1568 void TGo4Picture::SetDrawOption(Option_t* option, Int_t index)
1569 {
1570  CheckIndex(index);
1571  if (option==0) ClearOption(index, op_Draw);
1572  else SetStrOption(index, op_Draw, option);
1573 }
1574 
1575 Option_t* TGo4Picture::GetDrawOption(Int_t index) const
1576 {
1577  CheckIndex(index);
1578  return (Option_t*) GetStrOption(index, op_Draw);
1579 }
1580 
1581 void TGo4Picture::SetStyle(TStyle* style, Int_t index)
1582 {
1583  if (style==0) return;
1584  CheckIndex(index);
1585  SetObjOption(index, op_Style, new TStyle(*style));
1586 }
1587 
1588 TStyle* TGo4Picture::FindStyle(Int_t index)
1589 {
1590  CheckIndex(index);
1591  Int_t pos = FindOptPos(index, op_Style);
1592  if (pos<0) return 0;
1593  return dynamic_cast<TStyle*> (GetObjOption(index, op_Style));
1594 }
1595 
1596 TStyle* TGo4Picture::GetStyle(Int_t index)
1597 {
1598  CheckIndex(index);
1599  TStyle* style = FindStyle(index);
1600  if (style==0) {
1601  style = new TStyle(*gStyle);
1602  SetObjOption(index, op_Style, style);
1603  }
1604  return style;
1605 }
1606 
1607 void TGo4Picture::ClearOption(Short_t index, Short_t typ)
1608 {
1609  ClearOption(FindOptPos(index,typ));
1610 }
1611 
1613 {
1614  if (pos<0) return;
1615  Int_t bnd = op_ObjsBound << 16;
1616 
1617  if (fxOptIndex[pos]>=bnd) {
1618  for (Int_t i=0;i<fiOptSize;i++)
1619  if (fxOptIndex[i]>=bnd)
1620  if (fxOptValue[i]>fxOptValue[pos]) fxOptValue[i]-=1;
1621  TObject* obj = fxOptObjects->RemoveAt(fxOptValue[pos]);
1622  delete obj;
1623  fxOptObjects->Compress();
1624  if (fxOptObjects->GetLast()<0) {
1625  delete fxOptObjects;
1626  fxOptObjects = 0;
1627  }
1628  }
1629 
1630  for (Int_t i=pos;i<fiOptSize-1;i++) {
1631  fxOptIndex[i] = fxOptIndex[i+1];
1632  fxOptValue[i] = fxOptValue[i+1];
1633  }
1634  fiOptSize--;
1635 }
1636 
1637 void TGo4Picture::CheckIndex(Int_t &index) const
1638 {
1639  if (index == UndefIndex) {
1640  if (fiLastIndex >= PictureIndex)
1641  index = fiLastIndex;
1642  else
1643  index = PictureIndex;
1644  }
1645 }
1646 
1647 void TGo4Picture::ClearAllOptions(Short_t index)
1648 {
1649  if (index<0) {
1650  fxOptIndex.Set(0);
1651  fxOptValue.Set(0);
1652  if (fxOptObjects) {
1653  delete fxOptObjects;
1654  fxOptObjects = 0;
1655  }
1656  } else {
1657  Int_t pos = 0;
1658  while (pos<fiOptSize)
1659  if ((fxOptIndex[pos] & 0x7fff)==index+1) ClearOption(pos);
1660  else pos++;
1661  }
1662 }
1663 
1664 Int_t TGo4Picture::GetObjAttIndex(TObject* obj)
1665 {
1666  if (obj==0) return UndefIndex;
1667  for (Int_t n=0;n<GetNumObjNames();n++)
1668  if (strcmp(GetObjName(n),obj->GetName())==0) return n;
1669  return UndefIndex;
1670 }
1671 
1672 void TGo4Picture::DrawPic(TVirtualPad* pad)
1673 {
1674  if (pad==0) return;
1675  double txt_y = 0.9;
1676  if (IsDivided()) {
1677  pad->Divide(GetDivX(), GetDivY());
1678  for(Int_t posx=0; posx<GetDivX(); posx++)
1679  for(Int_t posy=0; posy<GetDivY(); posy++) {
1680  TGo4Picture* sub = FindPic(posy,posx);
1681  if (sub) sub->DrawPic(pad->GetPad(posy*GetDivX() + posx + 1));
1682  }
1683  } else
1684  for (Int_t indx=0;indx<GetNumObjNames();indx++) {
1685  TString str = "Obj: ";
1686  str += GetObjName(indx);
1687  const char* opt = GetDrawOption(indx);
1688  if ((opt==0) && (indx==0))
1689  opt = GetDrawOption(PictureIndex);
1690  if (opt!=0) {
1691  str += " Opt: ";
1692  str += opt;
1693  }
1694  Int_t numobj = GetNumObjNames();
1695  TText* txt = new TText(0.1, txt_y, str.Data());
1696  pad->cd();
1697  txt->Draw();
1698  if (numobj < 8) txt_y -= 0.1;
1699  else txt_y -= 0.8/numobj;
1700  }
1701 }
1702 
1703 void TGo4Picture::Draw(Option_t* option)
1704 {
1705  TCanvas* c = 0;
1706  if (gPad==0) {
1707  c = new TCanvas();
1708  c->cd();
1709  } else {
1710  c = gPad->GetCanvas();
1711  c->Clear();
1712  c->cd();
1713  }
1714  if (c==0) return;
1715 
1716  if (IsDrawHeader()) {
1717  TString txt = c->GetName();
1718  txt += " Pic: ";
1719  txt += GetName();
1720  if (strcmp(GetName(), GetTitle())!=0) {
1721  txt += " Title: ";
1722  txt += GetTitle();
1723  }
1724  c->SetTitle(txt.Data());
1725  }
1726 
1727  DrawPic(c);
1728 }
1729 
1730 void TGo4Picture::PrintPic(int shift, Bool_t showopt)
1731 {
1732  for (int n=0;n<shift;n++) std::cout << ' ';
1733  if (IsDivided()) {
1734  std::cout << "Divided numx:" << GetDivX() << " numy:" << GetDivY() << std::endl;
1735  for(Int_t posx=0; posx<GetDivX(); posx++)
1736  for(Int_t posy=0; posy<GetDivY(); posy++) {
1737  for (int n=0;n<shift+2;n++) std::cout << ' ';
1738  std::cout << "subpic x:" << posx << " y:" << posy << std::endl;
1739  TGo4Picture* sub = FindPic(posy,posx);
1740  if (sub) sub->PrintPic(shift+4, showopt);
1741  }
1742  } else {
1743  std::cout << "Objects:" << std::endl;
1744  for (Int_t num=0; num<GetNumObjNames(); num++) {
1745  const char* objname = GetObjName(num);
1746  for (int n=0;n<shift+2;n++) std::cout << ' ';
1747  std::cout << objname;
1748 
1749  Option_t* drawopt = GetDrawOption(num);
1750  if (drawopt) std::cout << " opt: " << drawopt;
1751  std::cout << std::endl;
1752  }
1753  if (!showopt) return;
1754  for (int n=0;n<shift;n++) std::cout << ' ';
1755  std::cout << "Options:" << std::endl;
1756  for (Int_t nop=0;nop<fiOptSize;nop++) {
1757  Int_t indx = (fxOptIndex[nop] & 0x00ff);
1758  Int_t op = fxOptIndex[nop] >> 16;
1759  for (int n=0;n<shift+2;n++) std::cout << ' ';
1760  std::cout << indx << " " << op << " " << fxOptValue[nop] << std::endl;
1761  }
1762  }
1763 }
1764 
1765 void TGo4Picture::Print(Option_t* option) const
1766 {
1767  std::cout << "Picture " << GetName() << std::endl;
1768  ((TGo4Picture*)this)->PrintPic(2, (strstr(option,"attr")!=0));
1769 }
1770 
1772 {
1773  if (pic == 0) return;
1774  if (fxSubPictures==0) {
1775  fxSubPictures = new TObjArray();
1776  fxSubPictures->SetOwner(kTRUE);
1777  }
1778  fxSubPictures->Add(pic);
1779 }
1780 
1781 void TGo4Picture::AddSpecialObject(TObject* obj, Option_t* drawopt)
1782 {
1783  if (fxSpecialObjects==0) {
1784  fxSpecialObjects = new TList;
1785  fxSpecialObjects->SetOwner(kTRUE);
1786  }
1787 
1788  fxSpecialObjects->Add(obj, drawopt);
1789 }
1790 
1791 void TGo4Picture::AddSpecialObjectXml(const char* xmlcode, Option_t* drawopt)
1792 {
1793  TObject* obj = TBufferXML::ConvertFromXML(xmlcode);
1794  if (obj) AddSpecialObject(obj, drawopt);
1795 }
1796 
1798 {
1799  Long_t sz = IsA()->Size();
1800 
1801  if (fxNames) {
1802  sz += TObjArray::Class()->Size() + fxNames->GetSize() * sizeof(void*);
1803  for (int n=0;n<=fxNames->GetLast();n++) {
1804  TObjString* str = (TObjString*) fxNames->At(n);
1805  if (str) sz += str->IsA()->Size() + str->GetString().Length();
1806  }
1807  }
1808 
1809  if (fxSubPictures)
1810  sz += TObjArray::Class()->Size() + fxSubPictures->GetSize() * sizeof(void*);
1811 
1812  if (fxOptObjects) {
1813  sz += TObjArray::Class()->Size() + fxOptObjects->GetSize() * sizeof(void*);
1814  for (int n=0;n<=fxOptObjects->GetLast();n++) {
1815  TObject* obj = fxOptObjects->At(n);
1816  if (obj) sz += obj->IsA()->Size();
1817  }
1818  }
1819 
1820  if (fxSpecialObjects) {
1821  sz += TList::Class()->Size();
1822  TListIter iter(fxSpecialObjects);
1823  TObject* obj = 0;
1824 
1825  while ((obj = iter()) != 0)
1826  sz += sizeof(TObjLink) + obj->IsA()->Size();
1827  }
1828 
1829  sz += fxOptIndex.GetSize() * sizeof(Long_t);
1830  sz += fxOptValue.GetSize() * sizeof(Long_t);
1831 
1832  if (IsDivided())
1833  for(int ny=0;ny<GetDivY();ny++)
1834  for(int nx=0;nx<GetDivX();nx++)
1835  sz += Pic(ny,nx)->GetTotalSize();
1836 
1837  return sz;
1838 }
1839 
1840 
1841 void TGo4Picture::SavePrimitive(std::ostream& fs, Option_t*)
1842 {
1843  fs << "TGo4Picture *" << GetName() << " = new TGo4Picture(\"" << GetName()
1844  << "\", \"" << GetTitle() << "\");" << std::endl;
1845  TString name = GetName();
1846  name+="->";
1847 
1848  fs << name << "SetCrosshair(" << (IsCrosshair() ? "true" : "false") << ");" << std::endl;
1849 
1850  MakeScript(fs, name.Data());
1851 }
1852 
1853 void TGo4Picture::MakeAxisScript(std::ostream& fs, const char* name, Int_t index, Int_t naxis)
1854 {
1855  if ((naxis<0) || (naxis>2)) return;
1856  const char* axisname = "X";
1857  Int_t op = op_AxisX;
1858  if (naxis==1) { op = op_AxisY; axisname = "Y"; } else
1859  if (naxis==2) { op = op_AxisZ; axisname = "Z"; }
1860 
1861  Long_t lv;
1862  Float_t fv;
1863  if (!GetOption (index, op+0, lv)) return;
1864 
1865  fs << name << "SetAxisAtt(" << naxis << ", ";
1866  fs << lv << ", ";
1867  if (!GetOption (index, op+1, lv)) lv = gStyle->GetLabelColor(axisname);
1868  fs << lv << ", ";
1869  if (!GetOption (index, op+2, lv)) lv = gStyle->GetLabelFont(axisname);
1870  fs << lv << ", ";
1871  if (!GetOptionF(index, op+3, fv)) fv = gStyle->GetLabelOffset(axisname);
1872  fs << fv << ", ";
1873  if (!GetOptionF(index, op+4, fv)) fv = gStyle->GetLabelSize(axisname);
1874  fs << fv << ", ";
1875  if (!GetOption (index, op+5, lv)) lv = gStyle->GetNdivisions(axisname);
1876  fs << lv << ", ";
1877  if (!GetOptionF(index, op+6, fv)) fv = gStyle->GetTickLength(axisname);
1878  fs << fv << ", ";
1879  if (!GetOption (index, op+7, lv)) lv = gStyle->GetTitleColor(axisname);
1880  fs << lv << ", ";
1881  if (!GetOption (index, op+8, lv)) lv = gStyle->GetTitleFont(axisname);
1882  fs << lv << ", ";
1883  if (!GetOptionF(index, op+9, fv)) fv = gStyle->GetTitleOffset(axisname);
1884  fs << fv << ", ";
1885  if (!GetOptionF(index, op+10, fv)) fv = gStyle->GetTitleSize(axisname);
1886  fs << fv << ", ";
1887 
1888  if (GetOption (index, op+11, lv)) {
1889  if ((lv & 1) != 0) fs << "kTRUE, ";
1890  else fs << "kFALSE, ";
1891  TString ticks;
1892  if ((lv & 2) != 0) ticks+="+";
1893  if ((lv & 4) != 0) ticks+="-";
1894  fs << "\"" << ticks <<"\", ";
1895  fs << (lv & 0x0ff0) << ", ";
1896  } else
1897  fs << "kTRUE, \"+\", 0, ";
1898 
1899  fs << index << ");" << std::endl;
1900 
1901  // TODO: add this to script
1902 // note: take this attribute independent of displayed object
1903 // this is necessary to correctly restore TGraph axis
1904 //SetXAxisAttTime(axis->GetTimeDisplay(), axis->GetTimeFormat(), index);
1905 // if (naxis==0)
1906 // {
1907 // Bool_t tdisp=kFALSE;
1908 // if (GetOption (index, op_TimeAxisX, lv) && lv) tdisp=kTRUE;
1909 // TString format=GetStrOption(index, op_TimeAxisXFmt , "%H:%M:%S");
1910 // fs << name << "SetXAxisAttTime(";
1911 // fs << tdisp << ", ";
1912 // fs << "\"" << format.Data()<< "\"" <<", ";
1913 // //fs << index << ");" << std::endl; // does not work?
1914 // fs << PictureIndex << ");" << std::endl; // this works
1915 // }
1916 
1917 }
1918 
1919 void TGo4Picture::MakeScript(std::ostream& fs, const char* name)
1920 {
1921  for(Int_t naxis=0;naxis<3;naxis++)
1922  if (GetLogScale(naxis)>0)
1923  fs << name << "SetLogScale(" << naxis << ", 1);" << std::endl;
1924 
1925  Double_t min, max;
1926  if (GetRangeX(min, max))
1927  fs << name << "SetRangeX(" << min << ", " << max << ");" << std::endl;
1928  if (GetRangeY(min, max))
1929  fs << name << "SetRangeY(" << min << ", " << max << ");" << std::endl;
1930  if (GetRangeZ(min, max))
1931  fs << name << "SetRangeZ(" << min << ", " << max << ");" << std::endl;
1932 
1933  Double_t v1,v2,v3,v4;
1934  if (GetOptionD(PictureIndex, op_FrameLeft, v1) &&
1938  fs << name << "SetFrameAttr(" << v1 << ", " << v2 << ", " << v3 << ", " << v4 << ");" << std::endl;
1939 
1940 
1941  TAttLine latt;
1942  TAttFill fatt;
1943  TAttMarker matt;
1944 
1945  if (GetLineAtt(&latt,PictureIndex))
1946  fs << name << "SetLineAtt("
1947  << latt.GetLineColor() << ", "
1948  << latt.GetLineStyle() << ", "
1949  << latt.GetLineWidth() << ", " << PictureIndex << ");" << std::endl;
1950  if (GetFillAtt(&fatt, PictureIndex))
1951  fs << name << "SetFillAtt("
1952  << fatt.GetFillColor() << ", "
1953  << fatt.GetFillStyle() << ", " << PictureIndex << ");" << std::endl;
1954  if (GetMarkerAtt(&matt, PictureIndex))
1955  fs << name << "SetMarkerAtt("
1956  << matt.GetMarkerColor() << ", "
1957  << matt.GetMarkerSize() << ", "
1958  << matt.GetMarkerStyle()<< ", " << PictureIndex << ");" << std::endl;
1959 
1960  fs << name << "SetHisStats(" << (IsHisStats() ? "true" : "false") << ");" << std::endl;
1961 
1962  if (IsHisStats() && (FindOptPos(PictureIndex, op_HisStatsX1) >= 0)) {
1963  fs << name << "SetStatsAttr("
1964  << GetD(PictureIndex, op_HisStatsX1, gStyle->GetStatX()-gStyle->GetStatW()) << ", "
1965  << GetD(PictureIndex, op_HisStatsY1, gStyle->GetStatY()-gStyle->GetStatH()) << ", "
1966  << GetD(PictureIndex, op_HisStatsX2, gStyle->GetStatX()) << ", "
1967  << GetD(PictureIndex, op_HisStatsY2, gStyle->GetStatY()) << ", "
1968  << GetI(PictureIndex, op_HisStatsOpt, 1111) << ", \""
1969  << GetStrOption(PictureIndex, op_HisStatsOptF, "6.4g") << "\", "
1970  << GetI(PictureIndex, op_HisStatsFit, 111) << ", \""
1971  << GetStrOption(PictureIndex, op_HisStatsFitF, "5.4g") << "\");" << std::endl;
1972  }
1973 
1974  fs << name << "SetHisTitle(" << (IsHisTitle() ? "true" : "false") << ");" << std::endl;
1975  if (HasTitleAttr()) {
1976  fs << name << "SetTitleAttr("
1977  << GetD(PictureIndex, op_TitleX1, gStyle->GetTitleX()-gStyle->GetTitleW()) << ", "
1978  << GetD(PictureIndex, op_TitleY1, gStyle->GetTitleY()-gStyle->GetTitleH()) << ", "
1979  << GetD(PictureIndex, op_TitleX2, gStyle->GetTitleX()) << ", "
1980  << GetD(PictureIndex, op_TitleY2, gStyle->GetTitleY());
1981 
1982  Double_t sz(0.);
1984  fs << ", " << sz;
1985 
1986  fs << ");" << std::endl;
1987 
1988  fs << name << "SetTitleTime(" << (IsTitleTime() ? "true" : "false") << ");" << std::endl;
1989  fs << name << "SetTitleDate(" << (IsTitleDate() ? "true" : "false") << ");" << std::endl;
1990  fs << name << "SetTitleItem(" << (IsTitleItem() ? "true" : "false") << ");" << std::endl;
1991  }
1992 
1993  Int_t nlvl = GetHisContour();
1994  if (nlvl>0) fs << name << "SetHisContour(" << nlvl << ");" << std::endl;
1995 
1996  fs << name << "SetAutoScale(" << (IsAutoScale() ? "true" : "false") << ");" << std::endl;
1997 
1998  if (IsSuperimpose()) {
1999  fs << name << "SetSuperimpose(true);" << std::endl;
2000  fs << name << "SetLegendDraw(" << (IsLegendDraw() ? "true" : "false") << ");" << std::endl;
2001  }
2002 
2003  fs << name << "SetApplyToAll(" << (IsApplyToAll() ? "true" : "false") << ");" << std::endl;
2004  fs << name << "SetAutoZoom(" << (IsAutoZoom() ? "true" : "false") << ");" << std::endl;
2005 
2006  // JAM2016 add 1:1 coordinate ratio property:
2007  fs << name << "SetXYRatioOne(" << (IsXYRatioOne() ? "true" : "false") << ");" << std::endl;
2008 
2009 
2010  Long_t lv;
2011  Double_t dv;
2012  fs << name << "SetPadAtt(";
2013  if (!GetOption (PictureIndex, op_Pad+ 0, lv)) lv = gStyle->GetPadBorderMode();
2014  fs << lv << ", ";
2015  if (!GetOption (PictureIndex, op_Pad+ 1, lv)) lv = gStyle->GetPadBorderSize();
2016  fs << lv << ", ";
2017  if (!GetOption (PictureIndex, op_Pad+ 2, lv)) lv = gStyle->GetPadGridX();
2018  fs << lv << ", ";
2019  if (!GetOption (PictureIndex, op_Pad+ 3, lv)) lv = gStyle->GetPadGridY();
2020  fs << lv << ", ";
2021  if (!GetOptionD(PictureIndex, op_Pad+ 4, dv)) dv = 0.;
2022  fs << dv << ", ";
2023  if (!GetOptionD(PictureIndex, op_Pad+ 5, dv)) dv = 0.;
2024  fs << dv << ", ";
2025  if (!GetOption (PictureIndex, op_Pad+ 6, lv)) lv = gStyle->GetPadTickX();
2026  fs << lv << ", ";
2027  if (!GetOption (PictureIndex, op_Pad+ 7, lv)) lv = gStyle->GetPadTickY();
2028  fs << lv << ");" << std::endl;
2029 
2030  const char* drawopt = GetDrawOption(PictureIndex);
2031  if (drawopt!=0)
2032  fs << name << "SetDrawOption(\"" << drawopt << "\", " << PictureIndex << ");" << std::endl;
2033 
2034  // export x axis time attribute independent of objects. needed for TGraph pads
2035  Bool_t tdisp=kFALSE;
2036  if (GetOption (PictureIndex, op_TimeAxisX, lv) && lv) tdisp=kTRUE;
2037  TString format=GetStrOption(PictureIndex, op_TimeAxisXFmt , "%H:%M:%S");
2038  fs << name << "SetXAxisAttTime(";
2039  fs << tdisp << ", ";
2040  fs << "\"" << format.Data()<< "\"" <<", ";
2041  fs << PictureIndex << ");" << std::endl;
2042 
2043 
2044  for(Int_t indx=0;indx<GetNumObjNames();indx++) {
2045  const char* objname = GetObjName(indx);
2046  const char* objopt = GetDrawOption(indx);
2047 
2048  fs << name << "AddObjName(\"" << objname << "\"";
2049  if (objopt!=0) fs << ", \"" << objopt << "\"";
2050  fs << ");" << std::endl;
2051  if (GetLineAtt(&latt,indx))
2052  fs << name << "SetLineAtt("
2053  << latt.GetLineColor() << ", "
2054  << latt.GetLineStyle() << ", "
2055  << latt.GetLineWidth() << ", " << indx << ");" << std::endl;
2056  if (GetFillAtt(&fatt, indx))
2057  fs << name << "SetFillAtt("
2058  << fatt.GetFillColor() << ", "
2059  << fatt.GetFillStyle() << ", " << indx << ");" << std::endl;
2060  if (GetMarkerAtt(&matt, indx))
2061  fs << name << "SetMarkerAtt("
2062  << matt.GetMarkerColor() << ", "
2063  << matt.GetMarkerSize() << ", "
2064  << matt.GetMarkerStyle() << ", " << indx << ");" << std::endl;
2065 
2066  MakeAxisScript(fs, name, indx, 0);
2067  MakeAxisScript(fs, name, indx, 1);
2068  MakeAxisScript(fs, name, indx, 2);
2069 
2070  if (GetRebinX(indx)>0)
2071  fs << name << "SetRebinX(" << GetRebinX(indx) << ", " << indx << ");" << std::endl;
2072 
2073  if (GetRebinY(indx)>0)
2074  fs << name << "SetRebinY(" << GetRebinY(indx) << ", " << indx << ");" << std::endl;
2075  }
2076 
2077  TListIter iter(fxSpecialObjects);
2078  TObject* obj = 0;
2079  while ((obj=iter())!=0) {
2080 
2081  TString xmlbuf = TBufferXML::ConvertToXML(obj);
2082 
2083  TString buf = xmlbuf;
2084  Int_t len = 0;
2085  do {
2086  len = buf.Length();
2087  buf.ReplaceAll("\n ","\n");
2088  } while (len!=buf.Length());
2089 
2090  buf.ReplaceAll("\n"," ");
2091  buf.ReplaceAll("\"","\\\"");
2092 
2093  buf.Prepend("\"");
2094  buf.Append("\"");
2095 
2096  if (buf.Length()>950) {
2097  fs << "TString sbuf = \"\";" << std::endl;
2098  const char* pos = xmlbuf.Data();
2099  while (*pos!=0) {
2100  const char* lastpos = pos;
2101  while ((*pos !=0) && (*pos!='\n')) pos++;
2102  TString subbuf(lastpos, pos-lastpos);
2103  subbuf.ReplaceAll("\"","\\\"");
2104  fs << "TGo4Picture::Add(sbuf,\"" << subbuf << "\");" << std::endl;
2105  if (*pos==0) break;
2106  pos++;
2107  }
2108  buf = "sbuf";
2109  }
2110 
2111  fs << name << "AddSpecialObjectXml(" << buf;
2112 
2113  Option_t* opt = iter.GetOption();
2114 
2115  if ((opt!=0) && (*opt!=0))
2116  fs << ", \"" << opt << "\"";
2117  fs << ");" << std::endl;
2118  }
2119 
2120  if (IsDivided()) {
2121  fs << name << "SetDivision(" << GetDivY() << ", " << GetDivX() << ");" << std::endl;
2122  for(int ny=0;ny<GetDivY();ny++)
2123  for(int nx=0;nx<GetDivX();nx++) {
2124  TString subname = name;
2125  subname+="Pic(";
2126  subname+=ny;
2127  subname+=",";
2128  subname+=nx;
2129  subname+=")->";
2130  Pic(ny,nx)->MakeScript(fs, subname.Data());
2131  }
2132  }
2133 }
void SetStyle(TStyle *style, Int_t index=UndefIndex)
void SetRange(Int_t naxis, Double_t min, Double_t max)
void SetTitleTime(Bool_t on=kTRUE)
void ClearOption(Short_t index, Short_t typ)
void SetHisContour(Int_t nlvl)
bool IsContentModified() const
Int_t GetDivX()
Definition: TGo4Picture.h:54
const char * GetXAxisTimeFormat()
OptionsIdentifiers
Definition: TGo4Picture.cxx:37
Bool_t GetFillAtt(TAttFill *fill, Int_t index=UndefIndex)
Bool_t CheckPosition(Int_t posy, Int_t posx) const
Int_t GetNumObjNames()
void AddH1(TH1 *histo, Option_t *DrawOption=0)
void SetAutoZoom(bool on)
void UpdateFrom(TGo4Picture *source, TClass *selectedobjclass=0)
void AddObjName(const char *name, Option_t *DrawOption=0)
void SetPosition(Int_t posy, Int_t posx)
Int_t fiNDivY
Definition: TGo4Picture.h:374
Int_t fiPosX
Definition: TGo4Picture.h:376
virtual void SavePrimitive(std::ostream &fs, Option_t *="")
TObjArray * fxSubPictures
Definition: TGo4Picture.h:383
TArrayL fxOptIndex
Definition: TGo4Picture.h:386
Bool_t IsDivided()
Definition: TGo4Picture.h:56
Int_t GetLogScale(Int_t nscale=0)
void SetRangeY(Double_t min, Double_t max)
void SetCrosshair(bool on)
void SetDrawHeader(Bool_t draw=kTRUE)
Int_t FindOptPos(Short_t index, Short_t typ) const
void SetObjOption(Short_t index, Short_t typ, TObject *obj)
void GetAxisAtt(Int_t naxis, TAxis *axis, Int_t index=UndefIndex)
void GetPadAtt(TPad *pad, Int_t index=UndefIndex)
void CopyOptionsFrom(TGo4Picture *source)
const char * GetObjName(Int_t n)
TStyle * FindStyle(Int_t index=UndefIndex)
Double_t GetD(Short_t index, Short_t typ, Double_t def=0.) const
bool IsAutoScale() const
virtual void Draw(Option_t *option="")
Bool_t IsHisStats() const
TList * fxSpecialObjects
Definition: TGo4Picture.h:390
Bool_t GetTitleAttr(TPaveText *titl)
void SetStrOption(Short_t index, Short_t typ, const char *value)
void AddSpecialObjectXml(const char *xmlcode, Option_t *drawopt=0)
void PrintPic(int shift, Bool_t showopt)
Bool_t GetRange(Int_t naxis, Double_t &min, Double_t &max) const
Bool_t GetFullRange(Int_t naxis, Double_t &min, Double_t &max)
void ClearLogScales()
void ClearAllOptions(Short_t index=UndefIndex)
Int_t GetRebinY(Int_t index=UndefIndex)
void SetAxisAtt(Int_t naxis, Color_t AxisColor, Color_t LabelColor, Style_t LabelFont, Float_t LabelOffset, Float_t LabelSize, Int_t Ndivisions, Float_t TickLength, Color_t TitleColor, Style_t TitleFont, Float_t TitleOffset, Float_t TitleSize, Bool_t decimals, const char *ticks, Int_t bits, Int_t index=UndefIndex)
void GetH1Att(TH1 *h1, Int_t index=UndefIndex)
TObjArray * fxObjects
Definition: TGo4Picture.h:381
void ClearFillAtt(Int_t index=UndefIndex)
void SetOptionD(Short_t index, Short_t typ, Double_t value)
void SetHisTitle(bool on)
Bool_t IsXYRatioOne()
virtual Option_t * GetDrawOption() const
Definition: TGo4Picture.h:146
void SetAxisTitleFontSize(Int_t naxis, Float_t TitleSize, Int_t index=UndefIndex)
Bool_t GetOptionD(Short_t index, Short_t typ, Double_t &value) const
void SetTitleItem(Bool_t on=kTRUE)
void SetAxisLabelFontSize(Int_t naxis, Float_t LabelSize, Int_t index=UndefIndex)
void * Cast(TObject *obj, TClass *cl)
void SetXAxisTimeFormat(const char *format)
void ChangeDrawOption(Int_t kind, Int_t value)
void ClearLineAtt(Int_t index=UndefIndex)
void DrawPic(TVirtualPad *pad)
const char * GetStrOption(Short_t index, Short_t typ, const char *defvalue=0) const
TGo4Picture * Pic(Int_t posy, Int_t posx)
Int_t fiOptSize
Definition: TGo4Picture.h:385
bool IsAutoZoom() const
Bool_t GetStatsAttr(TPaveStats *stats)
bool IsApplyToAll() const
void SetApplyToAll(bool on)
void ClearRebin(Int_t index=UndefIndex)
void AddHStack(THStack *st, Option_t *DrawOption=0)
void SetFullRangeDim(Int_t ndim)
Bool_t HasTitleAttr()
void SetPadAtt(Int_t BorderMode, Int_t BorderSize, Int_t Gridx, Int_t Gridy, Double_t Phi, Double_t Theta, Int_t Tickx, Int_t Ticky, Int_t index=PictureIndex)
void SetDivision(Int_t ndivy, Int_t ndivx)
TObjArray * fxNames
Definition: TGo4Picture.h:379
virtual void Clear(Option_t *option="")
TObject * GetObjOption(Short_t index, Short_t typ) const
void SetStatsAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t optstat=1111, const char *statformat="6.4g", Int_t optfit=1111, const char *fitformat="5.4g")
void SetH1Att(TH1 *h1, Int_t index=UndefIndex)
void AddObject(TObject *obj, Option_t *DrawOption=0)
Int_t fiLastIndex
Definition: TGo4Picture.h:392
void SetXAxisTimeDisplay(Bool_t on)
TObjArray * fxOptObjects
Definition: TGo4Picture.h:388
void SetRebinY(Int_t ngroupy, Int_t index=UndefIndex)
void AddSubPicture(TGo4Picture *pic)
bool IsCrosshair() const
void SetXYRatioOne(Bool_t on)
void GetLogScales(TVirtualPad *pad)
void CheckIndex(Int_t &index) const
void SetLogScale(Int_t nscale=0, Int_t zn=1)
Bool_t GetFrameAttr(TPad *pad)
bool IsSuperimpose() const
Bool_t GetOptionF(Short_t index, Short_t typ, Float_t &value) const
Bool_t GetOption(Short_t index, Short_t typ, Long_t &value) const
void AddGraph(TGraph *gr, Option_t *DrawOption=0)
virtual ~TGo4Picture()
void SetOptionF(Short_t index, Short_t typ, Float_t value)
void SetLegendDraw(bool on)
Int_t GetObjAttIndex(TObject *obj)
Bool_t IsXAxisTimeDisplay()
bool IsPadModified() const
Bool_t GetRangeZ(Double_t &min, Double_t &max) const
Int_t ExtendOptPos(Short_t index, Short_t typ)
Long_t GetTotalSize()
Long_t GetI(Short_t index, Short_t typ, Long_t def=0) const
Int_t GetDivY()
Definition: TGo4Picture.h:55
void ClearMarkerAtt(Int_t index=UndefIndex)
void AddCondition(TNamed *cond=0)
void SetOption(Short_t index, Short_t typ, Long_t value)
Int_t GetHisContour() const
void SetLineAtt(Color_t color, Style_t style, Width_t width, Int_t index=UndefIndex)
void ClearRangeY()
TGo4Picture * FindPic(Int_t posy, Int_t posx)
TArrayL fxOptValue
Definition: TGo4Picture.h:387
void SetHisStats(Bool_t on)
void SetLinesDivision(Int_t numlines, const Int_t *numbers)
Bool_t GetRangeY(Double_t &min, Double_t &max) const
Bool_t IsObjNames()
void ClearRangeX()
void SetMarkerAtt(Color_t color, Size_t size, Style_t style, Int_t index=UndefIndex)
Int_t fiNDivX
Definition: TGo4Picture.h:373
void SetFullRange(Int_t naxis, Double_t min, Double_t max)
void SetRangeX(Double_t min, Double_t max)
void MakeAxisScript(std::ostream &fs, const char *name, Int_t indx, Int_t naxis)
void SetFrameAttr(Double_t left, Double_t top, Double_t right, Double_t bottom)
void SetFillAtt(Color_t color, Style_t style, Int_t index=UndefIndex)
void ClearObjNames(Bool_t recursive=kFALSE)
void ClearRangeZ()
Int_t fiPosY
Definition: TGo4Picture.h:377
Bool_t IsHisTitle() const
bool IsLegendDraw() const
Bool_t IsDrawHeader()
void GetDrawAttributes(TObject *obj, Int_t index=UndefIndex)
void SetSuperimpose(bool on)
void SetRangeZ(Double_t min, Double_t max)
Bool_t IsTitleDate() const
Bool_t GetMarkerAtt(TAttMarker *marker, Int_t index=UndefIndex)
void SetDrawAttributes(TObject *obj, Int_t index=UndefIndex)
void SetPadModified(bool on=true)
void ClearFullRange(Int_t naxis=-1)
TStyle * GetStyle(Int_t index=UndefIndex)
Bool_t GetRangeX(Double_t &min, Double_t &max) const
void SetAutoScale(bool on)
void MakeScript(std::ostream &fs, const char *name)
Int_t GetRebinX(Int_t index=UndefIndex)
Int_t GetFullRangeDim() const
Bool_t GetLineAtt(TAttLine *line, Int_t index=UndefIndex)
void SetContentModified(bool on=true)
void AddSpecialObject(TObject *obj, Option_t *drawopt=0)
Bool_t IsTitleItem() const
Bool_t IsTitleTime() const
virtual void Print(Option_t *option="") const
void SetTitleDate(Bool_t on=kTRUE)
void SetRebinX(Int_t ngroupx, Int_t index=UndefIndex)
virtual void SetDrawOption(Option_t *option="")
Definition: TGo4Picture.h:139
TGo4Picture * LPic(Int_t nline, Int_t ncol)
void ClearRange(Int_t naxis=-1)
void SetXAxisAttTime(Bool_t timedisplay, const char *format, Int_t index=UndefIndex)
void SetTitleAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t textsize=0.)
TList * GetSpecialObjects() const
Definition: TGo4Picture.h:240