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