GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Picture.cxx
Go to the documentation of this file.
1 // $Id: TGo4Picture.cxx 3424 2021-12-21 10:43:49Z 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  fiNDivX = (ndivx < 1) ? 1 : ndivx;
209  fiNDivY = (ndivy < 1) ? 1 : 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)
1088  SetTitleAttr(titl->GetX1NDC(), titl->GetY1NDC(),
1089  titl->GetX2NDC(), titl->GetY2NDC(),
1090  titl->GetTextSize());
1091 }
1092 
1094 {
1095  return (FindOptPos(PictureIndex, op_TitleX1)>=0) &&
1099 }
1100 
1101 Bool_t TGo4Picture::GetTitleAttr(TPaveText* titl)
1102 {
1103  if (titl==0) return kFALSE;
1104 
1105  Double_t x1, y1, x2, y2, sz(0.);
1106  if (GetOptionD(PictureIndex, op_TitleX1, x1) &&
1110  titl->SetX1NDC(x1);
1111  titl->SetY1NDC(y1);
1112  titl->SetX2NDC(x2);
1113  titl->SetY2NDC(y2);
1114  titl->ConvertNDCtoPad();
1115  }
1116 
1118  titl->SetTextSize(sz);
1119  else
1120  titl->SetTextSize(0);
1121 
1122  return kTRUE;
1123 }
1124 
1126 {
1127  SetOption(PictureIndex, op_TitleTime, on ? 1 : 0);
1128 }
1129 
1131 {
1132  Long_t zn = kTRUE;
1134  return zn!=0;
1135 }
1136 
1138 {
1139  SetOption(PictureIndex, op_TitleDate, on ? 1 : 0);
1140 }
1141 
1143 {
1144  Long_t zn = 0;
1146  return zn!=0;
1147 }
1148 
1150 {
1151  SetOption(PictureIndex, op_TitleItem, on ? 1 : 0);
1152 }
1153 
1155 {
1156  Long_t zn = 0;
1158  return zn!=0;
1159 }
1160 
1162 {
1163  SetOption(PictureIndex, op_LegendDraw, on ? 1 : 0);
1164 }
1165 
1167 {
1168  Long_t zn = kTRUE;
1170  return zn!=0;
1171 }
1172 
1174 {
1175  SetOption(PictureIndex, op_Crosshair, on ? 1 : 0);
1176 }
1177 
1179 {
1180  Long_t zn = 0;
1182  return zn!=0;
1183 }
1184 
1186 {
1187  SetOption(PictureIndex, op_AutoScale, on ? 1 : 0);
1188 }
1189 
1191 {
1192  Long_t zn = kTRUE;
1194  return zn!=0;
1195 }
1196 
1198 {
1199  SetOption(PictureIndex, op_Superimpose, on ? 1 : 0);
1200 }
1201 
1203 {
1204  Long_t zn = 0;
1206  return zn!=0;
1207 }
1208 
1210 {
1211  SetOption(PictureIndex, op_ApplyToAll, on ? 1 : 0);
1212 }
1213 
1215 {
1216  Long_t zn = 0;
1218  return zn!=0;
1219 }
1220 
1222 {
1223  SetOption(PictureIndex, op_AutoZoom, on ? 1 : 0);
1224 }
1225 
1227 {
1228  Long_t zn = 0;
1230  return zn!=0;
1231 }
1232 
1234 {
1236 }
1237 
1239 {
1240  Long_t zn = 0;
1242  return zn!=0;
1243 }
1244 
1246 {
1247  SetOption(PictureIndex, op_PadModified, on ? 1 : 0);
1248 }
1249 
1251 {
1252  Long_t zn = 0;
1254  return zn!=0;
1255 }
1256 
1257 void TGo4Picture::ChangeDrawOption(Int_t kind, Int_t value)
1258 {
1259  switch(kind) {
1260  case 0: break;
1261  case 1: break;
1262  case 2: break;
1263  case 3: SetLogScale(0, value); break;
1264  case 4: SetLogScale(1, value); break;
1265  case 5: SetLogScale(2, value); break;
1266  case 6: SetHisStats(value!=0); break;
1267  case 7: SetHisTitle(value!=0); break;
1268  case 8: SetLegendDraw(value!=0); break;
1269  case 9: SetCrosshair(value!=0); break;
1270  case 10: {
1271  Int_t numdim = GetFullRangeDim();
1272  SetAutoScale(value!=0);
1273  Double_t min, max;
1274  if (!IsAutoScale()) { // keep current selection if not autosacle
1275  if ((numdim==1) && !GetRange(1, min, max)) {
1276  GetFullRange(1, min, max);
1277  SetRange(1, min, max);
1278  } else
1279  if ((numdim==2) && !GetRange(1, min, max)) {
1280  GetFullRange(2, min, max);
1281  SetRange(2, min, max);
1282  }
1283  }
1284  break;
1285  }
1286  case 11: SetSuperimpose(value!=0); break;
1287  case 12: SetTitleTime(value!=0); break;
1288  case 13: SetTitleDate(value!=0); break;
1289  case 14: SetTitleItem(value!=0); break;
1290  case 15: SetXAxisTimeDisplay(value!=0); break;
1291  case 17:
1292  SetXYRatioOne(value!=0);
1293  //if (value==0) SetDefaultRatio(true); //
1294  break;
1295  case 18: SetHisContour(value); break;
1296 
1297  }
1298  SetPadModified();
1299 }
1300 
1302 {
1304 }
1305 
1307 {
1308  Long_t zn = 0;
1310  return zn;
1311 }
1312 
1313 void TGo4Picture::SetFullRange(Int_t naxis, Double_t min, Double_t max)
1314 {
1315  Int_t op;
1316  switch (naxis) {
1317  case 1: op = op_FullYMin; break;
1318  case 2: op = op_FullZMin; break;
1319  default: op = op_FullXMin; break;
1320  }
1321  SetOptionD(PictureIndex, op, min);
1322  SetOptionD(PictureIndex, op+1, max);
1323 }
1324 
1325 Bool_t TGo4Picture::GetFullRange(Int_t naxis, Double_t& min, Double_t& max)
1326 {
1327  Int_t op;
1328  switch (naxis) {
1329  case 1: op = op_FullYMin; break;
1330  case 2: op = op_FullZMin; break;
1331  default: op = op_FullXMin; break;
1332  }
1333  return GetOptionD(PictureIndex, op, min) && GetOptionD(PictureIndex, op+1, max);
1334 }
1335 
1337 {
1338  if (naxis < 0) {
1339  for (int n = 0; n < 3; n++)
1340  ClearFullRange(n);
1342  }
1343  Int_t op;
1344  switch (naxis) {
1345  case 1: op = op_FullYMin; break;
1346  case 2: op = op_FullZMin; break;
1347  default: op = op_FullXMin; break;
1348  }
1350  ClearOption(PictureIndex, op+1);
1351 }
1352 
1353 void TGo4Picture::UpdateFrom(TGo4Picture* source, TClass* selectedobjclass)
1354 {
1355  if (source==0) return;
1356  Clear();
1357 
1358  SetName(source->GetName());
1359  SetTitle(source->GetTitle());
1360 
1361  fiNDivX = source->fiNDivX;
1362  fiNDivY = source->fiNDivY;
1363  fiPosX = source->fiPosX;
1364  fiPosY = source->fiPosY;
1365 
1366  for (Int_t n=0; n<source->GetNumObjNames();n++)
1367  AddObjName(source->GetObjName(n));
1368 
1369  if (source->GetSpecialObjects()!=0)
1370  fxSpecialObjects = (TList*) source->GetSpecialObjects()->Clone();
1371 
1372  CopyOptionsFrom(source);
1373 
1374  if (source->fxSubPictures != 0) {
1375  fxSubPictures = new TObjArray();
1376  fxSubPictures->SetOwner(kTRUE);
1377  for (Int_t n = 0; n <= source->fxSubPictures->GetLast(); n++) {
1378  TGo4Picture *sub =
1379  dynamic_cast<TGo4Picture*>(source->fxSubPictures->At(n));
1380  if (sub != 0) {
1381  TGo4Picture *newsub = new TGo4Picture;
1382  newsub->UpdateFrom(sub, selectedobjclass);
1383  fxSubPictures->Add(newsub);
1384  }
1385  }
1386  }
1387 }
1388 
1390 {
1391  fiOptSize = source->fiOptSize;
1392  source->fxOptIndex.Copy(fxOptIndex);
1393  source->fxOptValue.Copy(fxOptValue);
1394  if (fxOptObjects!=0) delete fxOptObjects;
1395  fxOptObjects = 0;
1396  if (source->fxOptObjects)
1397  fxOptObjects = (TObjArray*) source->fxOptObjects->Clone();
1398 }
1399 
1400 
1401 void TGo4Picture::Clear(Option_t* option)
1402 {
1403  fiNDivX = 1;
1404  fiNDivY = 1;
1405  fiPosX = 0;
1406  fiPosY = 0;
1407  if (fxNames!=0) { delete fxNames; fxNames = 0; }
1408  if (fxSubPictures!=0) { delete fxSubPictures; fxSubPictures = 0; }
1409  fiLastIndex = 0;
1410  fiOptSize = 0;
1411  fxOptIndex.Set(0);
1412  fxOptValue.Set(0);
1413  if (fxOptObjects!=0) { delete fxOptObjects; fxOptObjects = 0; }
1414 }
1415 
1416 Int_t TGo4Picture::FindOptPos(Short_t index, Short_t typ) const
1417 {
1418  Long_t zn = index + 1 + (typ << 16);
1419  for (Int_t i=0;i<fiOptSize;i++)
1420  if (fxOptIndex[i]==zn) return i;
1421  return -1;
1422 }
1423 
1424 Int_t TGo4Picture::ExtendOptPos(Short_t index, Short_t typ)
1425 {
1426  Long_t zn = index + 1 + (typ << 16);
1427  if (fxOptIndex.GetSize()==fiOptSize) {
1428  fxOptIndex.Set(fiOptSize+8);
1429  fxOptValue.Set(fiOptSize+8);
1430  }
1431  fxOptIndex[fiOptSize] = zn;
1432  fiOptSize++;
1433  return fiOptSize-1;
1434 }
1435 
1436 void TGo4Picture::SetOption(Short_t index, Short_t typ, Long_t value)
1437 {
1438  if (typ>=op_ObjsBound) return;
1439  Int_t pos = FindOptPos(index,typ);
1440  if (pos<0) pos = ExtendOptPos(index, typ);
1441  fxOptValue[pos] = value;
1442 }
1443 
1444 Bool_t TGo4Picture::GetOption(Short_t index, Short_t typ, Long_t& value) const
1445 {
1446  if (typ>=op_ObjsBound) return kFALSE;
1447  Int_t pos = FindOptPos(index, typ);
1448  if (pos<0) return kFALSE;
1449  value = fxOptValue[pos];
1450  return kTRUE;
1451 }
1452 
1453 Long_t TGo4Picture::GetI(Short_t index, Short_t typ, Long_t def) const
1454 {
1455  Long_t value = 0;
1456  if (!GetOption(index, typ, value)) return def;
1457  return value;
1458 }
1459 
1460 void TGo4Picture::SetOptionF(Short_t index, Short_t typ, Float_t value)
1461 {
1462  Long_t buf;
1463 
1464 #ifdef R__B64
1465  Double_t v(value);
1466  memcpy(&buf, &v, sizeof(Long_t));
1467 #else
1468  memcpy(&buf, &value, sizeof(Long_t));
1469 #endif
1470  SetOption(index, typ, buf);
1471 }
1472 
1473 Bool_t TGo4Picture::GetOptionF(Short_t index, Short_t typ, Float_t& value) const
1474 {
1475  Long_t buf;
1476  Bool_t res = GetOption(index, typ, buf);
1477 
1478  if (res) {
1479 #ifdef R__B64
1480  Double_t v;
1481  memcpy(&v, &buf, sizeof(Long_t));
1482  value = v;
1483 #else
1484  memcpy(&value, &buf, sizeof(Long_t));
1485 #endif
1486  }
1487  return res;
1488 }
1489 
1490 void TGo4Picture::SetOptionD(Short_t index, Short_t typ, Double_t value)
1491 {
1492  Long_t buf;
1493 #ifdef R__B64
1494  memcpy(&buf, &value, sizeof(Long_t));
1495 #else
1496  Float_t v(value);
1497  memcpy(&buf, &v, sizeof(Long_t));
1498 #endif
1499  SetOption(index, typ, buf);
1500 }
1501 
1502 Bool_t TGo4Picture::GetOptionD(Short_t index, Short_t typ, Double_t& value) const
1503 {
1504  Long_t buf;
1505  Bool_t res = GetOption(index, typ, buf);
1506 
1507  if (res) {
1508 #ifdef R__B64
1509  memcpy(&value, &buf, sizeof(Long_t));
1510 #else
1511  Float_t v;
1512  memcpy(&v, &buf, sizeof(Long_t));
1513  value = v;
1514 #endif
1515  }
1516  return res;
1517 }
1518 
1519 Double_t TGo4Picture::GetD(Short_t index, Short_t typ, Double_t def) const
1520 {
1521  Double_t value;
1522  if (!GetOptionD(index, typ, value)) return def;
1523  return value;
1524 }
1525 
1526 void TGo4Picture::SetObjOption(Short_t index, Short_t typ, TObject* obj)
1527 {
1528  if (obj==0) return;
1529  if (typ<op_ObjsBound) { delete obj; return; }
1530  Int_t pos = FindOptPos(index, typ);
1531  if (pos>=0) {
1532  TObject* old = fxOptObjects->RemoveAt(fxOptValue[pos]);
1533  delete old;
1534  fxOptObjects->AddAt(obj, fxOptValue[pos]);
1535  } else {
1536  pos = ExtendOptPos(index, typ);
1537  if (fxOptObjects==0) {
1538  fxOptObjects = new TObjArray();
1539  fxOptObjects->SetOwner(kTRUE);
1540  }
1541  fxOptObjects->Add(obj);
1542  fxOptValue[pos] = fxOptObjects->GetLast();
1543  }
1544 }
1545 
1546 TObject* TGo4Picture::GetObjOption(Short_t index, Short_t typ) const
1547 {
1548  if (typ < op_ObjsBound) return 0;
1549  Int_t pos = FindOptPos(index, typ);
1550  if (pos < 0) return 0;
1551  return fxOptObjects->At(fxOptValue[pos]);
1552 }
1553 
1554 void TGo4Picture::SetStrOption(Short_t index, Short_t typ, const char* value)
1555 {
1556  if (value==0) return;
1557  SetObjOption(index, typ, new TObjString(value));
1558 }
1559 
1560 const char* TGo4Picture::GetStrOption(Short_t index, Short_t typ, const char *defvalue) const
1561 {
1562  TObjString *ostr = dynamic_cast<TObjString*> (GetObjOption(index, typ));
1563  if (!ostr) return defvalue;
1564  return ostr->String().Data();
1565 }
1566 
1567 void TGo4Picture::SetDrawOption(Option_t* option, Int_t index)
1568 {
1569  CheckIndex(index);
1570  if (option==0) ClearOption(index, op_Draw);
1571  else SetStrOption(index, op_Draw, option);
1572 }
1573 
1574 Option_t* TGo4Picture::GetDrawOption(Int_t index) const
1575 {
1576  CheckIndex(index);
1577  return (Option_t*) GetStrOption(index, op_Draw);
1578 }
1579 
1580 void TGo4Picture::SetStyle(TStyle* style, Int_t index)
1581 {
1582  if (style==0) return;
1583  CheckIndex(index);
1584  SetObjOption(index, op_Style, new TStyle(*style));
1585 }
1586 
1587 TStyle* TGo4Picture::FindStyle(Int_t index)
1588 {
1589  CheckIndex(index);
1590  Int_t pos = FindOptPos(index, op_Style);
1591  if (pos<0) return 0;
1592  return dynamic_cast<TStyle*> (GetObjOption(index, op_Style));
1593 }
1594 
1595 TStyle* TGo4Picture::GetStyle(Int_t index)
1596 {
1597  CheckIndex(index);
1598  TStyle* style = FindStyle(index);
1599  if (style==0) {
1600  style = new TStyle(*gStyle);
1601  SetObjOption(index, op_Style, style);
1602  }
1603  return style;
1604 }
1605 
1606 void TGo4Picture::ClearOption(Short_t index, Short_t typ)
1607 {
1608  ClearOption(FindOptPos(index,typ));
1609 }
1610 
1612 {
1613  if (pos<0) return;
1614  Int_t bnd = op_ObjsBound << 16;
1615 
1616  if (fxOptIndex[pos]>=bnd) {
1617  for (Int_t i=0;i<fiOptSize;i++)
1618  if (fxOptIndex[i]>=bnd)
1619  if (fxOptValue[i]>fxOptValue[pos]) fxOptValue[i]-=1;
1620  TObject* obj = fxOptObjects->RemoveAt(fxOptValue[pos]);
1621  delete obj;
1622  fxOptObjects->Compress();
1623  if (fxOptObjects->GetLast()<0) {
1624  delete fxOptObjects;
1625  fxOptObjects = 0;
1626  }
1627  }
1628 
1629  for (Int_t i=pos;i<fiOptSize-1;i++) {
1630  fxOptIndex[i] = fxOptIndex[i+1];
1631  fxOptValue[i] = fxOptValue[i+1];
1632  }
1633  fiOptSize--;
1634 }
1635 
1636 void TGo4Picture::CheckIndex(Int_t &index) const
1637 {
1638  if (index == UndefIndex) {
1639  if (fiLastIndex >= PictureIndex)
1640  index = fiLastIndex;
1641  else
1642  index = PictureIndex;
1643  }
1644 }
1645 
1646 void TGo4Picture::ClearAllOptions(Short_t index)
1647 {
1648  if (index<0) {
1649  fxOptIndex.Set(0);
1650  fxOptValue.Set(0);
1651  if (fxOptObjects) {
1652  delete fxOptObjects;
1653  fxOptObjects = 0;
1654  }
1655  } else {
1656  Int_t pos = 0;
1657  while (pos<fiOptSize)
1658  if ((fxOptIndex[pos] & 0x7fff)==index+1) ClearOption(pos);
1659  else pos++;
1660  }
1661 }
1662 
1663 Int_t TGo4Picture::GetObjAttIndex(TObject* obj)
1664 {
1665  if (obj==0) return UndefIndex;
1666  for (Int_t n=0;n<GetNumObjNames();n++)
1667  if (strcmp(GetObjName(n),obj->GetName())==0) return n;
1668  return UndefIndex;
1669 }
1670 
1671 void TGo4Picture::DrawPic(TVirtualPad* pad)
1672 {
1673  if (pad==0) return;
1674  double txt_y = 0.9;
1675  if (IsDivided()) {
1676  pad->Divide(GetDivX(), GetDivY());
1677  for(Int_t posx=0; posx<GetDivX(); posx++)
1678  for(Int_t posy=0; posy<GetDivY(); posy++) {
1679  TGo4Picture* sub = FindPic(posy,posx);
1680  if (sub) sub->DrawPic(pad->GetPad(posy*GetDivX() + posx + 1));
1681  }
1682  } else
1683  for (Int_t indx=0;indx<GetNumObjNames();indx++) {
1684  TString str = "Obj: ";
1685  str += GetObjName(indx);
1686  const char* opt = GetDrawOption(indx);
1687  if ((opt==0) && (indx==0))
1688  opt = GetDrawOption(PictureIndex);
1689  if (opt!=0) {
1690  str += " Opt: ";
1691  str += opt;
1692  }
1693  Int_t numobj = GetNumObjNames();
1694  TText* txt = new TText(0.1, txt_y, str.Data());
1695  pad->cd();
1696  txt->Draw();
1697  if (numobj < 8) txt_y -= 0.1;
1698  else txt_y -= 0.8/numobj;
1699  }
1700 }
1701 
1702 void TGo4Picture::Draw(Option_t* option)
1703 {
1704  TCanvas* c = 0;
1705  if (gPad==0) {
1706  c = new TCanvas();
1707  c->cd();
1708  } else {
1709  c = gPad->GetCanvas();
1710  c->Clear();
1711  c->cd();
1712  }
1713  if (c==0) return;
1714 
1715  if (IsDrawHeader()) {
1716  TString txt = c->GetName();
1717  txt += " Pic: ";
1718  txt += GetName();
1719  if (strcmp(GetName(), GetTitle())!=0) {
1720  txt += " Title: ";
1721  txt += GetTitle();
1722  }
1723  c->SetTitle(txt.Data());
1724  }
1725 
1726  DrawPic(c);
1727 }
1728 
1729 void TGo4Picture::PrintPic(int shift, Bool_t showopt)
1730 {
1731  for (int n=0;n<shift;n++) std::cout << ' ';
1732  if (IsDivided()) {
1733  std::cout << "Divided numx:" << GetDivX() << " numy:" << GetDivY() << std::endl;
1734  for(Int_t posx=0; posx<GetDivX(); posx++)
1735  for(Int_t posy=0; posy<GetDivY(); posy++) {
1736  for (int n=0;n<shift+2;n++) std::cout << ' ';
1737  std::cout << "subpic x:" << posx << " y:" << posy << std::endl;
1738  TGo4Picture* sub = FindPic(posy,posx);
1739  if (sub) sub->PrintPic(shift+4, showopt);
1740  }
1741  } else {
1742  std::cout << "Objects:" << std::endl;
1743  for (Int_t num=0; num<GetNumObjNames(); num++) {
1744  const char* objname = GetObjName(num);
1745  for (int n=0;n<shift+2;n++) std::cout << ' ';
1746  std::cout << objname;
1747 
1748  Option_t* drawopt = GetDrawOption(num);
1749  if (drawopt) std::cout << " opt: " << drawopt;
1750  std::cout << std::endl;
1751  }
1752  if (!showopt) return;
1753  for (int n=0;n<shift;n++) std::cout << ' ';
1754  std::cout << "Options:" << std::endl;
1755  for (Int_t nop=0;nop<fiOptSize;nop++) {
1756  Int_t indx = (fxOptIndex[nop] & 0x00ff);
1757  Int_t op = fxOptIndex[nop] >> 16;
1758  for (int n=0;n<shift+2;n++) std::cout << ' ';
1759  std::cout << indx << " " << op << " " << fxOptValue[nop] << std::endl;
1760  }
1761  }
1762 }
1763 
1764 void TGo4Picture::Print(Option_t* option) const
1765 {
1766  std::cout << "Picture " << GetName() << std::endl;
1767  ((TGo4Picture*)this)->PrintPic(2, (strstr(option,"attr")!=0));
1768 }
1769 
1771 {
1772  if (pic == 0) return;
1773  if (fxSubPictures==0) {
1774  fxSubPictures = new TObjArray();
1775  fxSubPictures->SetOwner(kTRUE);
1776  }
1777  fxSubPictures->Add(pic);
1778 }
1779 
1780 void TGo4Picture::AddSpecialObject(TObject* obj, Option_t* drawopt)
1781 {
1782  if (fxSpecialObjects==0) {
1783  fxSpecialObjects = new TList;
1784  fxSpecialObjects->SetOwner(kTRUE);
1785  }
1786 
1787  fxSpecialObjects->Add(obj, drawopt);
1788 }
1789 
1790 void TGo4Picture::AddSpecialObjectXml(const char* xmlcode, Option_t* drawopt)
1791 {
1792  TObject* obj = TBufferXML::ConvertFromXML(xmlcode);
1793  if (obj) AddSpecialObject(obj, drawopt);
1794 }
1795 
1797 {
1798  Long_t sz = IsA()->Size();
1799 
1800  if (fxNames) {
1801  sz += TObjArray::Class()->Size() + fxNames->GetSize() * sizeof(void*);
1802  for (int n=0;n<=fxNames->GetLast();n++) {
1803  TObjString* str = (TObjString*) fxNames->At(n);
1804  if (str) sz += str->IsA()->Size() + str->GetString().Length();
1805  }
1806  }
1807 
1808  if (fxSubPictures)
1809  sz += TObjArray::Class()->Size() + fxSubPictures->GetSize() * sizeof(void*);
1810 
1811  if (fxOptObjects) {
1812  sz += TObjArray::Class()->Size() + fxOptObjects->GetSize() * sizeof(void*);
1813  for (int n=0;n<=fxOptObjects->GetLast();n++) {
1814  TObject* obj = fxOptObjects->At(n);
1815  if (obj) sz += obj->IsA()->Size();
1816  }
1817  }
1818 
1819  if (fxSpecialObjects) {
1820  sz += TList::Class()->Size();
1821  TListIter iter(fxSpecialObjects);
1822  TObject* obj = 0;
1823 
1824  while ((obj = iter()) != 0)
1825  sz += sizeof(TObjLink) + obj->IsA()->Size();
1826  }
1827 
1828  sz += fxOptIndex.GetSize() * sizeof(Long_t);
1829  sz += fxOptValue.GetSize() * sizeof(Long_t);
1830 
1831  if (IsDivided())
1832  for(int ny=0;ny<GetDivY();ny++)
1833  for(int nx=0;nx<GetDivX();nx++)
1834  sz += Pic(ny,nx)->GetTotalSize();
1835 
1836  return sz;
1837 }
1838 
1839 
1840 void TGo4Picture::SavePrimitive(std::ostream& fs, Option_t*)
1841 {
1842  fs << "TGo4Picture *" << GetName() << " = new TGo4Picture(\"" << GetName()
1843  << "\", \"" << GetTitle() << "\");" << std::endl;
1844  TString name = GetName();
1845  name+="->";
1846 
1847  fs << name << "SetCrosshair(" << (IsCrosshair() ? "true" : "false") << ");" << std::endl;
1848 
1849  MakeScript(fs, name.Data());
1850 }
1851 
1852 void TGo4Picture::MakeAxisScript(std::ostream& fs, const char* name, Int_t index, Int_t naxis)
1853 {
1854  if ((naxis<0) || (naxis>2)) return;
1855  const char* axisname = "X";
1856  Int_t op = op_AxisX;
1857  if (naxis==1) { op = op_AxisY; axisname = "Y"; } else
1858  if (naxis==2) { op = op_AxisZ; axisname = "Z"; }
1859 
1860  Long_t lv;
1861  Float_t fv;
1862  if (!GetOption (index, op+0, lv)) return;
1863 
1864  fs << name << "SetAxisAtt(" << naxis << ", ";
1865  fs << lv << ", ";
1866  if (!GetOption (index, op+1, lv)) lv = gStyle->GetLabelColor(axisname);
1867  fs << lv << ", ";
1868  if (!GetOption (index, op+2, lv)) lv = gStyle->GetLabelFont(axisname);
1869  fs << lv << ", ";
1870  if (!GetOptionF(index, op+3, fv)) fv = gStyle->GetLabelOffset(axisname);
1871  fs << fv << ", ";
1872  if (!GetOptionF(index, op+4, fv)) fv = gStyle->GetLabelSize(axisname);
1873  fs << fv << ", ";
1874  if (!GetOption (index, op+5, lv)) lv = gStyle->GetNdivisions(axisname);
1875  fs << lv << ", ";
1876  if (!GetOptionF(index, op+6, fv)) fv = gStyle->GetTickLength(axisname);
1877  fs << fv << ", ";
1878  if (!GetOption (index, op+7, lv)) lv = gStyle->GetTitleColor(axisname);
1879  fs << lv << ", ";
1880  if (!GetOption (index, op+8, lv)) lv = gStyle->GetTitleFont(axisname);
1881  fs << lv << ", ";
1882  if (!GetOptionF(index, op+9, fv)) fv = gStyle->GetTitleOffset(axisname);
1883  fs << fv << ", ";
1884  if (!GetOptionF(index, op+10, fv)) fv = gStyle->GetTitleSize(axisname);
1885  fs << fv << ", ";
1886 
1887  if (GetOption (index, op+11, lv)) {
1888  if ((lv & 1) != 0) fs << "kTRUE, ";
1889  else fs << "kFALSE, ";
1890  TString ticks;
1891  if ((lv & 2) != 0) ticks+="+";
1892  if ((lv & 4) != 0) ticks+="-";
1893  fs << "\"" << ticks <<"\", ";
1894  fs << (lv & 0x0ff0) << ", ";
1895  } else
1896  fs << "kTRUE, \"+\", 0, ";
1897 
1898  fs << index << ");" << std::endl;
1899 
1900  // TODO: add this to script
1901 // note: take this attribute independent of displayed object
1902 // this is necessary to correctly restore TGraph axis
1903 //SetXAxisAttTime(axis->GetTimeDisplay(), axis->GetTimeFormat(), index);
1904 // if (naxis==0)
1905 // {
1906 // Bool_t tdisp=kFALSE;
1907 // if (GetOption (index, op_TimeAxisX, lv) && lv) tdisp=kTRUE;
1908 // TString format=GetStrOption(index, op_TimeAxisXFmt , "%H:%M:%S");
1909 // fs << name << "SetXAxisAttTime(";
1910 // fs << tdisp << ", ";
1911 // fs << "\"" << format.Data()<< "\"" <<", ";
1912 // //fs << index << ");" << std::endl; // does not work?
1913 // fs << PictureIndex << ");" << std::endl; // this works
1914 // }
1915 
1916 }
1917 
1918 void TGo4Picture::MakeScript(std::ostream& fs, const char* name)
1919 {
1920  for(Int_t naxis=0;naxis<3;naxis++)
1921  if (GetLogScale(naxis)>0)
1922  fs << name << "SetLogScale(" << naxis << ", 1);" << std::endl;
1923 
1924  Double_t min, max;
1925  if (GetRangeX(min, max))
1926  fs << name << "SetRangeX(" << min << ", " << max << ");" << std::endl;
1927  if (GetRangeY(min, max))
1928  fs << name << "SetRangeY(" << min << ", " << max << ");" << std::endl;
1929  if (GetRangeZ(min, max))
1930  fs << name << "SetRangeZ(" << min << ", " << max << ");" << std::endl;
1931 
1932  Double_t v1,v2,v3,v4;
1933  if (GetOptionD(PictureIndex, op_FrameLeft, v1) &&
1937  fs << name << "SetFrameAttr(" << v1 << ", " << v2 << ", " << v3 << ", " << v4 << ");" << std::endl;
1938 
1939 
1940  TAttLine latt;
1941  TAttFill fatt;
1942  TAttMarker matt;
1943 
1944  if (GetLineAtt(&latt,PictureIndex))
1945  fs << name << "SetLineAtt("
1946  << latt.GetLineColor() << ", "
1947  << latt.GetLineStyle() << ", "
1948  << latt.GetLineWidth() << ", " << PictureIndex << ");" << std::endl;
1949  if (GetFillAtt(&fatt, PictureIndex))
1950  fs << name << "SetFillAtt("
1951  << fatt.GetFillColor() << ", "
1952  << fatt.GetFillStyle() << ", " << PictureIndex << ");" << std::endl;
1953  if (GetMarkerAtt(&matt, PictureIndex))
1954  fs << name << "SetMarkerAtt("
1955  << matt.GetMarkerColor() << ", "
1956  << matt.GetMarkerSize() << ", "
1957  << matt.GetMarkerStyle()<< ", " << PictureIndex << ");" << std::endl;
1958 
1959  fs << name << "SetHisStats(" << (IsHisStats() ? "true" : "false") << ");" << std::endl;
1960 
1961  if (IsHisStats() && (FindOptPos(PictureIndex, op_HisStatsX1) >= 0)) {
1962  fs << name << "SetStatsAttr("
1963  << GetD(PictureIndex, op_HisStatsX1, gStyle->GetStatX()-gStyle->GetStatW()) << ", "
1964  << GetD(PictureIndex, op_HisStatsY1, gStyle->GetStatY()-gStyle->GetStatH()) << ", "
1965  << GetD(PictureIndex, op_HisStatsX2, gStyle->GetStatX()) << ", "
1966  << GetD(PictureIndex, op_HisStatsY2, gStyle->GetStatY()) << ", "
1967  << GetI(PictureIndex, op_HisStatsOpt, 1111) << ", \""
1968  << GetStrOption(PictureIndex, op_HisStatsOptF, "6.4g") << "\", "
1969  << GetI(PictureIndex, op_HisStatsFit, 111) << ", \""
1970  << GetStrOption(PictureIndex, op_HisStatsFitF, "5.4g") << "\");" << std::endl;
1971  }
1972 
1973  fs << name << "SetHisTitle(" << (IsHisTitle() ? "true" : "false") << ");" << std::endl;
1974  if (HasTitleAttr()) {
1975  fs << name << "SetTitleAttr("
1976  << GetD(PictureIndex, op_TitleX1, gStyle->GetTitleX()-gStyle->GetTitleW()) << ", "
1977  << GetD(PictureIndex, op_TitleY1, gStyle->GetTitleY()-gStyle->GetTitleH()) << ", "
1978  << GetD(PictureIndex, op_TitleX2, gStyle->GetTitleX()) << ", "
1979  << GetD(PictureIndex, op_TitleY2, gStyle->GetTitleY());
1980 
1981  Double_t sz(0.);
1983  fs << ", " << sz;
1984 
1985  fs << ");" << std::endl;
1986 
1987  fs << name << "SetTitleTime(" << (IsTitleTime() ? "true" : "false") << ");" << std::endl;
1988  fs << name << "SetTitleDate(" << (IsTitleDate() ? "true" : "false") << ");" << std::endl;
1989  fs << name << "SetTitleItem(" << (IsTitleItem() ? "true" : "false") << ");" << std::endl;
1990  }
1991 
1992  Int_t nlvl = GetHisContour();
1993  if (nlvl>0) fs << name << "SetHisContour(" << nlvl << ");" << std::endl;
1994 
1995  fs << name << "SetAutoScale(" << (IsAutoScale() ? "true" : "false") << ");" << std::endl;
1996 
1997  if (IsSuperimpose()) {
1998  fs << name << "SetSuperimpose(true);" << std::endl;
1999  fs << name << "SetLegendDraw(" << (IsLegendDraw() ? "true" : "false") << ");" << std::endl;
2000  }
2001 
2002  fs << name << "SetApplyToAll(" << (IsApplyToAll() ? "true" : "false") << ");" << std::endl;
2003  fs << name << "SetAutoZoom(" << (IsAutoZoom() ? "true" : "false") << ");" << std::endl;
2004 
2005  // JAM2016 add 1:1 coordinate ratio property:
2006  fs << name << "SetXYRatioOne(" << (IsXYRatioOne() ? "true" : "false") << ");" << std::endl;
2007 
2008 
2009  Long_t lv;
2010  Double_t dv;
2011  fs << name << "SetPadAtt(";
2012  if (!GetOption (PictureIndex, op_Pad+ 0, lv)) lv = gStyle->GetPadBorderMode();
2013  fs << lv << ", ";
2014  if (!GetOption (PictureIndex, op_Pad+ 1, lv)) lv = gStyle->GetPadBorderSize();
2015  fs << lv << ", ";
2016  if (!GetOption (PictureIndex, op_Pad+ 2, lv)) lv = gStyle->GetPadGridX();
2017  fs << lv << ", ";
2018  if (!GetOption (PictureIndex, op_Pad+ 3, lv)) lv = gStyle->GetPadGridY();
2019  fs << lv << ", ";
2020  if (!GetOptionD(PictureIndex, op_Pad+ 4, dv)) dv = 0.;
2021  fs << dv << ", ";
2022  if (!GetOptionD(PictureIndex, op_Pad+ 5, dv)) dv = 0.;
2023  fs << dv << ", ";
2024  if (!GetOption (PictureIndex, op_Pad+ 6, lv)) lv = gStyle->GetPadTickX();
2025  fs << lv << ", ";
2026  if (!GetOption (PictureIndex, op_Pad+ 7, lv)) lv = gStyle->GetPadTickY();
2027  fs << lv << ");" << std::endl;
2028 
2029  const char* drawopt = GetDrawOption(PictureIndex);
2030  if (drawopt!=0)
2031  fs << name << "SetDrawOption(\"" << drawopt << "\", " << PictureIndex << ");" << std::endl;
2032 
2033  // export x axis time attribute independent of objects. needed for TGraph pads
2034  Bool_t tdisp=kFALSE;
2035  if (GetOption (PictureIndex, op_TimeAxisX, lv) && lv) tdisp=kTRUE;
2036  TString format=GetStrOption(PictureIndex, op_TimeAxisXFmt , "%H:%M:%S");
2037  fs << name << "SetXAxisAttTime(";
2038  fs << tdisp << ", ";
2039  fs << "\"" << format.Data()<< "\"" <<", ";
2040  fs << PictureIndex << ");" << std::endl;
2041 
2042 
2043  for(Int_t indx=0;indx<GetNumObjNames();indx++) {
2044  const char* objname = GetObjName(indx);
2045  const char* objopt = GetDrawOption(indx);
2046 
2047  fs << name << "AddObjName(\"" << objname << "\"";
2048  if (objopt!=0) fs << ", \"" << objopt << "\"";
2049  fs << ");" << std::endl;
2050  if (GetLineAtt(&latt,indx))
2051  fs << name << "SetLineAtt("
2052  << latt.GetLineColor() << ", "
2053  << latt.GetLineStyle() << ", "
2054  << latt.GetLineWidth() << ", " << indx << ");" << std::endl;
2055  if (GetFillAtt(&fatt, indx))
2056  fs << name << "SetFillAtt("
2057  << fatt.GetFillColor() << ", "
2058  << fatt.GetFillStyle() << ", " << indx << ");" << std::endl;
2059  if (GetMarkerAtt(&matt, indx))
2060  fs << name << "SetMarkerAtt("
2061  << matt.GetMarkerColor() << ", "
2062  << matt.GetMarkerSize() << ", "
2063  << matt.GetMarkerStyle() << ", " << indx << ");" << std::endl;
2064 
2065  MakeAxisScript(fs, name, indx, 0);
2066  MakeAxisScript(fs, name, indx, 1);
2067  MakeAxisScript(fs, name, indx, 2);
2068 
2069  if (GetRebinX(indx)>0)
2070  fs << name << "SetRebinX(" << GetRebinX(indx) << ", " << indx << ");" << std::endl;
2071 
2072  if (GetRebinY(indx)>0)
2073  fs << name << "SetRebinY(" << GetRebinY(indx) << ", " << indx << ");" << std::endl;
2074  }
2075 
2076  TListIter iter(fxSpecialObjects);
2077  TObject* obj = 0;
2078  while ((obj=iter())!=0) {
2079 
2080  TString xmlbuf = TBufferXML::ConvertToXML(obj);
2081 
2082  TString buf = xmlbuf;
2083  Int_t len = 0;
2084  do {
2085  len = buf.Length();
2086  buf.ReplaceAll("\n ","\n");
2087  } while (len!=buf.Length());
2088 
2089  buf.ReplaceAll("\n"," ");
2090  buf.ReplaceAll("\"","\\\"");
2091 
2092  buf.Prepend("\"");
2093  buf.Append("\"");
2094 
2095  if (buf.Length()>950) {
2096  fs << "TString sbuf = \"\";" << std::endl;
2097  const char* pos = xmlbuf.Data();
2098  while (*pos!=0) {
2099  const char* lastpos = pos;
2100  while ((*pos !=0) && (*pos!='\n')) pos++;
2101  TString subbuf(lastpos, pos-lastpos);
2102  subbuf.ReplaceAll("\"","\\\"");
2103  fs << "TGo4Picture::Add(sbuf,\"" << subbuf << "\");" << std::endl;
2104  if (*pos==0) break;
2105  pos++;
2106  }
2107  buf = "sbuf";
2108  }
2109 
2110  fs << name << "AddSpecialObjectXml(" << buf;
2111 
2112  Option_t* opt = iter.GetOption();
2113 
2114  if ((opt!=0) && (*opt!=0))
2115  fs << ", \"" << opt << "\"";
2116  fs << ");" << std::endl;
2117  }
2118 
2119  if (IsDivided()) {
2120  fs << name << "SetDivision(" << GetDivY() << ", " << GetDivX() << ");" << std::endl;
2121  for(int ny=0;ny<GetDivY();ny++)
2122  for(int nx=0;nx<GetDivX();nx++) {
2123  TString subname = name;
2124  subname+="Pic(";
2125  subname+=ny;
2126  subname+=",";
2127  subname+=nx;
2128  subname+=")->";
2129  Pic(ny,nx)->MakeScript(fs, subname.Data());
2130  }
2131  }
2132 }
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:373
Int_t fiPosX
Definition: TGo4Picture.h:375
virtual void SavePrimitive(std::ostream &fs, Option_t *="")
TObjArray * fxSubPictures
Definition: TGo4Picture.h:382
TArrayL fxOptIndex
Definition: TGo4Picture.h:385
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:389
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:380
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:384
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:378
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:391
void SetXAxisTimeDisplay(Bool_t on)
TObjArray * fxOptObjects
Definition: TGo4Picture.h:387
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:386
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:372
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:376
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