00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TGO4PICTURE_H
00015 #define TGO4PICTURE_H
00016
00017 #include "TNamed.h"
00018 #include "TArrayL.h"
00019 #include "TArrayF.h"
00020 #include "Riostream.h"
00021 #include "RVersion.h"
00022 #include "Gtypes.h"
00023
00024 class TVirtualPad;
00025 class TPad;
00026 class TObjArray;
00027 class TAttLine;
00028 class TAttFill;
00029 class TAttMarker;
00030 class TStyle;
00031 class TString;
00032 class TAxis;
00033 class TH1;
00034 class THStack;
00035 class TGraph;
00036 class TPaveStats;
00037 class TPaveText;
00038 class TList;
00039
00040 class TGo4Picture : public TNamed {
00041 public:
00042 enum Indexes { UndefIndex = -2, PictureIndex = -1 };
00043
00044 TGo4Picture();
00045 TGo4Picture(const char* name, const char* title, Int_t ndivy = 1, Int_t ndivx = 1);
00046 virtual ~TGo4Picture();
00047
00048
00049
00050 void SetDrawHeader(Bool_t draw = kTRUE);
00051 Bool_t IsDrawHeader();
00052
00053
00054
00055 void SetDivision(Int_t ndivy, Int_t ndivx);
00056 Int_t GetDivX() { return fiNDivX; }
00057 Int_t GetDivY() { return fiNDivY; }
00058 Bool_t IsDivided() { return (GetDivX()!=1) || (GetDivY()!=1); }
00059
00060 TGo4Picture& operator()(int posy, int posx) { return *Pic(posy,posx); }
00061 TGo4Picture* Pic(Int_t posy, Int_t posx);
00062 TGo4Picture* FindPic(Int_t posy, Int_t posx);
00063
00064
00065
00066 void SetLinesDivision(Int_t numlines, const Int_t* numbers);
00067 void SetLinesDivision(Int_t numlines, Int_t n0=1, Int_t n1=1, Int_t n2=1, Int_t n3=1, Int_t n4=1,
00068 Int_t n5=1, Int_t n6=1, Int_t n7=1, Int_t n8=1, Int_t n9=1);
00069 TGo4Picture* LPic(Int_t nline, Int_t ncol);
00070
00071
00072 void AddH1(TH1* histo, Option_t* DrawOption = 0);
00073 void AddH1(Int_t posy, Int_t posx, TH1* histo, Option_t* DrawOption = 0);
00074
00075
00076 void AddHStack(THStack* st, Option_t* DrawOption = 0);
00077 void AddHStack(Int_t posy, Int_t posx, THStack* st, Option_t* DrawOption = 0);
00078
00079
00080 void AddGraph(TGraph* gr, Option_t* DrawOption = 0);
00081 void AddGraph(Int_t posy, Int_t posx, TGraph* gr, Option_t* DrawOption = 0);
00082
00083
00084 void AddCondition(TNamed* cond = 0);
00085 void AddCondition(Int_t posy, Int_t posx, TNamed* cond = 0);
00086
00087
00088 void ClearObjNames(Bool_t recursive = kFALSE);
00089
00090
00091 void SetRangeX(Double_t min, Double_t max);
00092 Bool_t GetRangeX(Double_t& min, Double_t& max);
00093 void ClearRangeX();
00094 void SetRangeY(Double_t min, Double_t max);
00095 Bool_t GetRangeY(Double_t& min, Double_t& max);
00096 void ClearRangeY();
00097 void SetRangeZ(Double_t min, Double_t max);
00098 Bool_t GetRangeZ(Double_t& min, Double_t& max);
00099 void ClearRangeZ();
00100
00101
00102 void SetLogScale(Int_t nscale = 0, Int_t zn = 1);
00103 Int_t GetLogScale(Int_t nscale = 0);
00104 void GetLogScales(TVirtualPad* pad);
00105 void ClearLogScales();
00106
00107
00108 void SetSelectedIndex(Int_t index = PictureIndex) { fiLastIndex = index; }
00109
00110
00111 void SetLineAtt(Color_t color, Style_t style, Width_t width, Int_t index = UndefIndex);
00112 void SetLineAtt(TAttLine* line, Int_t index = UndefIndex);
00113 Bool_t GetLineAtt(TAttLine* line, Int_t index = UndefIndex);
00114 void ClearLineAtt(Int_t index = UndefIndex);
00115
00116
00117 void SetFillAtt(Color_t color, Style_t style, Int_t index = UndefIndex);
00118 void SetFillAtt(TAttFill* fill, Int_t index = UndefIndex);
00119 Bool_t GetFillAtt(TAttFill* fill, Int_t index = UndefIndex);
00120 void ClearFillAtt(Int_t index = UndefIndex);
00121
00122
00123 void SetMarkerAtt(Color_t color, Size_t size, Style_t style, Int_t index = UndefIndex);
00124 void SetMarkerAtt(TAttMarker* marker, Int_t index = UndefIndex);
00125 Bool_t GetMarkerAtt(TAttMarker* marker, Int_t index = UndefIndex);
00126 void ClearMarkerAtt(Int_t index = UndefIndex);
00127
00128
00129 void SetRebinX(Int_t ngroupx, Int_t index = UndefIndex);
00130 void SetRebinY(Int_t ngroupy, Int_t index = UndefIndex);
00131 Int_t GetRebinX(Int_t index = UndefIndex);
00132 Int_t GetRebinY(Int_t index = UndefIndex);
00133 void ClearRebin(Int_t index = UndefIndex);
00134
00135
00136 void SetDrawAttributes(TObject* obj, Int_t index = UndefIndex);
00137
00138 void GetDrawAttributes(TObject* obj, Int_t index = UndefIndex);
00139
00140
00141 virtual void SetDrawOption(Option_t* option = "")
00142 {
00143 SetDrawOption(option, UndefIndex);
00144 }
00145
00146 virtual void SetDrawOption(Option_t* option, Int_t index);
00147
00148 virtual Option_t* GetDrawOption()
00149 {
00150 return GetDrawOption(UndefIndex);
00151 }
00152
00153 virtual Option_t* GetDrawOption(Int_t index);
00154
00155
00156 void SetHisStats(Bool_t on);
00157 Bool_t IsHisStats() const;
00158
00159 void SetStatsAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
00160 Int_t optstat = 1111, const char* statformat = "6.4g",
00161 Int_t optfit = 1111, const char* fitformat = "5.4g");
00162 void SetStatsAttr(TPaveStats* stats);
00163 Bool_t GetStatsAttr(TPaveStats* stats);
00164
00165 void SetHisTitle(bool on);
00166 Bool_t IsHisTitle() const;
00167
00168 void SetTitleAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t textsize = 0.);
00169 void SetTitleAttr(TPaveText* titl);
00170 Bool_t HasTitleAttr();
00171 Bool_t GetTitleAttr(TPaveText* titl);
00172
00173 void SetTitleTime(Bool_t on = kTRUE);
00174 Bool_t IsTitleTime() const;
00175
00176 void SetTitleDate(Bool_t on = kTRUE);
00177 Bool_t IsTitleDate() const;
00178
00179 void SetTitleItem(Bool_t on = kTRUE);
00180 Bool_t IsTitleItem() const;
00181
00182 void SetLegendDraw(bool on);
00183 bool IsLegendDraw() const;
00184
00185 void SetCrosshair(bool on);
00186 bool IsCrosshair() const;
00187
00188 void SetAutoScale(bool on);
00189 bool IsAutoScale() const;
00190
00191 void SetSuperimpose(bool on);
00192 bool IsSuperimpose() const;
00193
00194 virtual void Draw(Option_t* option = "");
00195
00196 virtual void Clear(Option_t* option = "");
00197
00198 virtual void Print(Option_t* option = "") const;
00199
00200 #ifndef __CINT__
00201
00202 #if ROOT_VERSION_CODE > ROOT_VERSION(5,11,6)
00203 virtual void SavePrimitive(std::ostream& fs, Option_t* = "");
00204 #else
00205 virtual void SavePrimitive(std::ofstream& fs, Option_t* = "");
00206 #endif
00207
00208 #endif
00209
00210
00211
00212
00213 void AddObjName(const char* name, Option_t* DrawOption = 0);
00214 void AddObjName(Int_t posy, Int_t posx, const char* name, Option_t* DrawOption = 0);
00215
00216
00217 void AddObject(TObject* obj, Option_t* DrawOption = 0);
00218 void AddObject(Int_t posy, Int_t posx, TObject* obj, Option_t* DrawOption = 0);
00219
00220 void Reset() {}
00221
00222
00223 void UpdateFrom(TGo4Picture* source, TClass* selectedobjclass = 0);
00224 void CopyOptionsFrom(TGo4Picture* source);
00225
00226 Int_t GetNumObjNames();
00227 const char* GetObjName(Int_t n);
00228 Bool_t IsObjNames();
00229
00230
00231
00232
00233 void AddSpecialObject(TObject* obj, Option_t* drawopt = 0);
00234 void AddSpecialObjectXml(const char* xmlcode, Option_t* drawopt = 0);
00235 TList* GetSpecialObjects() const { return fxSpecialObjects; }
00236
00237
00238 void SetStyle(TStyle* style, Int_t index = UndefIndex);
00239 TStyle* FindStyle(Int_t index = UndefIndex);
00240 TStyle* GetStyle(Int_t index = UndefIndex);
00241
00242
00243 void SetAxisLabelFontSize(Int_t naxis, Float_t LabelSize, Int_t index = UndefIndex);
00244 void SetAxisTitleFontSize(Int_t naxis, Float_t TitleSize, Int_t index = UndefIndex);
00245 void SetAxisAtt(Int_t naxis,
00246 Color_t AxisColor,
00247 Color_t LabelColor,
00248 Style_t LabelFont,
00249 Float_t LabelOffset,
00250 Float_t LabelSize,
00251 Int_t Ndivisions,
00252 Float_t TickLength,
00253 Color_t TitleColor,
00254 Style_t TitleFont,
00255 Float_t TitleOffset,
00256 Float_t TitleSize,
00257 Bool_t decimals,
00258 const char* ticks,
00259 Int_t bits,
00260 Int_t index = UndefIndex);
00261
00262
00263 void SetXAxisAttTime(Bool_t timedisplay, const char* format, Int_t index = UndefIndex);
00264
00265 Bool_t IsXAxisTimeDisplay();
00266
00267 void SetXAxisTimeDisplay(Bool_t on);
00268
00269 void SetXAxisTimeFormat(const char* format);
00270
00271 const char* GetXAxisTimeFormat();
00272
00273 void SetPadAtt(Int_t BorderMode,
00274 Int_t BorderSize,
00275 Int_t Gridx,
00276 Int_t Gridy,
00277 Double_t Phi,
00278 Double_t Theta,
00279 Int_t Tickx,
00280 Int_t Ticky,
00281 Int_t index = PictureIndex);
00282
00283
00284
00285 void SetContentModified(bool on = true);
00286 bool IsContentModified() const;
00287
00288 void SetPadModified(bool on = true);
00289 bool IsPadModified() const;
00290
00291 void SetFullRangeDim(Int_t ndim);
00292 Int_t GetFullRangeDim() const;
00293 void SetFullRange(Int_t naxis, Double_t min, Double_t max);
00294 Bool_t GetFullRange(Int_t naxis, Double_t& min, Double_t& max);
00295 void ClearFullRange(Int_t naxis = -1);
00296
00297 void SetRange(Int_t naxis, Double_t min, Double_t max);
00298 Bool_t GetRange(Int_t naxis, Double_t& min, Double_t& max);
00299 void ClearRange(Int_t naxis = -1);
00300
00301 void ChangeDrawOption(Int_t kind, Int_t value);
00302
00304 Long_t GetTotalSize();
00305
00306 static void Add(TString& s, const char* buf) { s+=buf; }
00307
00308 protected:
00309 TGo4Picture(TGo4Picture& picture);
00310 void AddSubPicture(TGo4Picture* pic);
00311
00312 Int_t GetObjAttIndex(TObject* obj);
00313
00314 void SetPosition(Int_t posy, Int_t posx);
00315 Bool_t CheckPosition(Int_t posy, Int_t posx);
00316
00317 Int_t FindOptPos(Short_t index, Short_t typ) const;
00318 Int_t ExtendOptPos(Short_t index, Short_t typ);
00319
00320 void SetOption(Short_t index, Short_t typ, Long_t value);
00321 Bool_t GetOption(Short_t index, Short_t typ, Long_t& value) const;
00322 Long_t GetI(Short_t index, Short_t typ, Long_t def = 0) const;
00323
00324 void SetOptionF(Short_t index, Short_t typ, Float_t value);
00325 Bool_t GetOptionF(Short_t index, Short_t typ, Float_t& value);
00326
00327 void SetOptionD(Short_t index, Short_t typ, Double_t value);
00328 Bool_t GetOptionD(Short_t index, Short_t typ, Double_t& value);
00329 Double_t GetD(Short_t index, Short_t typ, Double_t def = 0.);
00330
00331 void SetObjOption(Short_t index, Short_t typ, TObject* obj);
00332 TObject* GetObjOption(Short_t index, Short_t typ);
00333
00334 void SetStrOption(Short_t index, Short_t typ, const char* value);
00335 const char* GetStrOption(Short_t index, Short_t typ, const char* defvalue = 0);
00336
00337 void ClearOption(Short_t index, Short_t typ);
00338 void ClearOption(Int_t pos);
00339 void ClearAllOptions(Short_t index = UndefIndex);
00340
00341 void* Cast(TObject* obj, TClass* cl);
00342
00343 void CheckIndex(Int_t& index);
00344
00345 void DrawPic(TVirtualPad* pad);
00346
00347 void PrintPic(int shift, Bool_t showopt);
00348
00349 void SetH1Att(TH1* h1, Int_t index = UndefIndex);
00350 void GetH1Att(TH1* h1, Int_t index = UndefIndex);
00351 void SetAxisAtt(Int_t naxis, TAxis* axis, Int_t index = UndefIndex);
00352 void GetAxisAtt(Int_t naxis, TAxis* axis, Int_t index = UndefIndex);
00353 void SetPadAtt(TPad* pad, Int_t index = UndefIndex);
00354 void GetPadAtt(TPad* pad, Int_t index = UndefIndex);
00355
00356 void MakeScript(std::ostream& fs, const char* name);
00357
00358 void MakeAxisScript(std::ostream& fs, const char* name, Int_t indx, Int_t naxis);
00359
00360 private:
00361 Int_t fiNDivX;
00362 Int_t fiNDivY;
00363
00364 Int_t fiPosX;
00365 Int_t fiPosY;
00366
00367 TObjArray* fxNames;
00368
00369 TObjArray* fxObjects;
00370
00371 TObjArray* fxSubPictures;
00372
00373 Int_t fiOptSize;
00374 TArrayL fxOptIndex;
00375 TArrayL fxOptValue;
00376 TObjArray* fxOptObjects;
00377
00378 TList* fxSpecialObjects;
00379
00380 Int_t fiLastIndex;
00381
00382 ClassDef(TGo4Picture, 3)
00383 };
00384
00385 #endif //TGO4PICTURE_H
00386
00387