#ifndef __TMrbWdw_h__
#define __TMrbWdw_h__
#include "TObject.h"
#include "TNamed.h"
#include "TString.h"
#include "TLine.h"
#include "TAttText.h"
#include "TPad.h"
#include "TCutG.h"
#include "TH1.h"
#include "TSystem.h"
#include "TMrbNamedX.h"
#include "TMrbLofNamedX.h"
#include "TMrbVarWdwCommon.h"
class TMrbWindow: public TLine, public TAttText {
public:
TMrbWindow();
TMrbWindow(Double_t Xlower, Double_t Xupper);
~TMrbWindow();
inline void SetParent(TObject * Parent) { fParent = Parent; };
inline UInt_t GetType() const { return(GetUniqueID() & kVarOrWindow); };
inline UInt_t GetStatus() const { return(GetUniqueID() & kStatus); };
void Initialize();
virtual void Print(Option_t * Option = "") const;
void SetRange(Bool_t Flag = kTRUE) {
UInt_t wdwType = this->GetUniqueID();
if (Flag) wdwType |= kIsRangeChecked; else wdwType &= ~kIsRangeChecked;
this->SetUniqueID(wdwType);
};
inline Bool_t HasInitValues() const { return((GetUniqueID() & kHasInitValues) != 0); };
inline Bool_t IsRangeChecked() const { return((GetUniqueID() & kIsRangeChecked) != 0); };
Bool_t AddToHist(TObject * Histogram);
virtual void SetName(const Char_t * WdwName);
virtual const Text_t * GetName() const { return(fName.Data()); };
virtual Bool_t IsSortable() const { return kTRUE; }
virtual Int_t Compare(const TObject * Object) const {
if (this == Object) return(0);
return(fName.CompareTo(Object->GetName()));
};
virtual ULong_t Hash() const { return fName.Hash(); }
virtual void Draw(Option_t * Option = "");
virtual void Paint(Option_t * Option = "");
inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };
protected:
void SetInitialType(UInt_t WdwType);
protected:
TString fName;
TObject * fParent;
ClassDef(TMrbWindow, 1)
};
class TMrbWindowI: public TMrbWindow {
public:
TMrbWindowI() {};
TMrbWindowI(const Char_t * Name, Int_t Xlower = 0, Int_t Xupper = 0);
~TMrbWindowI() {};
inline Int_t Clip(Int_t Value) const {
if (this->IsRangeChecked()) {
if (Value < fLowerRange) return(fLowerRange);
else if (Value > fUpperRange) return(fUpperRange);
else return(Value);
} else return(Value);
};
void SetLowerLimit(Int_t Xlow);
void SetUpperLimit(Int_t Xup);
void Set(Int_t Xlow, Int_t Xup);
inline Bool_t IsInside(Int_t X) const { return(X >= (Int_t) (fX1) && X <= (Int_t) (fX2)); };
Int_t GetLowerLimit() const { return((Int_t) (fX1)); };
Int_t GetUpperLimit() const { return((Int_t) (fX2)); };
void Initialize() {
fX1 = (Double_t) this->Clip(fLowerInit);
fX2 = (Double_t) this->Clip(fUpperInit);
if (gPad) {
this->Paint();
gPad->Modified();
}
};
void SetRange(Int_t Xlower, Int_t Xupper) {
this->SetUniqueID(this->GetUniqueID() | kIsRangeChecked);
fLowerRange = Xlower;
fUpperRange = Xupper;
};
virtual void PaintLine(Double_t, Double_t, Double_t, Double_t);
virtual void Print(Option_t * Option = "") const;
inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };
protected:
Int_t fXlower;
Int_t fXupper;
Int_t fLowerInit;
Int_t fUpperInit;
Int_t fLowerRange;
Int_t fUpperRange;
ClassDef(TMrbWindowI, 1)
};
class TMrbWindowF: public TMrbWindow {
public:
TMrbWindowF() {};
TMrbWindowF(const Char_t * Name, Double_t Xlower = 0., Double_t Xupper = 0.);
~TMrbWindowF() {};
inline Double_t Clip(Double_t Value) const {
if (this->IsRangeChecked()) {
if (Value < fLowerRange) return(fLowerRange);
else if (Value > fUpperRange) return(fUpperRange);
else return(Value);
} else return(Value);
};
void SetLowerLimit(Double_t Xlow);
void SetUpperLimit(Double_t Xup);
void Set(Double_t Xlow, Double_t Xup);
Double_t GetLowerLimit() const { return(fX1); };
Double_t GetUpperLimit() const { return(fX2); };
inline Bool_t IsInside(Double_t X) const { return(X >= fX1 && X <= fX2); };
void Initialize() {
fX1 = this->Clip(fLowerInit);
fX2 = this->Clip(fUpperInit);
if (gPad) {
this->Paint();
gPad->Modified();
}
};
void SetRange(Double_t Xlower, Double_t Xupper) {
this->SetUniqueID(this->GetUniqueID() | kIsRangeChecked);
fLowerRange = Xlower;
fUpperRange = Xupper;
};
virtual void PaintLine(Double_t, Double_t, Double_t, Double_t);
virtual void Print(Option_t * Option = "") const;
inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };
protected:
Double_t fXlower;
Double_t fXupper;
Double_t fLowerInit;
Double_t fUpperInit;
Double_t fLowerRange;
Double_t fUpperRange;
ClassDef(TMrbWindowF, 1)
};
class TMrbWindow2D : public TCutG, public TAttText {
public:
TMrbWindow2D();
TMrbWindow2D(const Char_t * WdwName, Int_t N, Double_t * X = NULL, Double_t * Y = NULL);
TMrbWindow2D(TCutG Cut);
~TMrbWindow2D();
inline void SetParent(TObject * Parent) { fParent = Parent; };
virtual void Draw(Option_t * Option = "");
virtual void Print(Option_t * Option = "") const;
Double_t GetXtext() const { return(fXtext); }
Double_t GetYtext() const { return(fYtext); }
void SetXtext(Double_t Xt){ fXtext = Xt; }
void SetYtext(Double_t Yt){ fYtext = Yt; }
Bool_t AddToHist(TObject * Histogram);
inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };
protected:
void SetInitialType(UInt_t WdwType);
protected:
Double_t fXtext;
Double_t fYtext;
TObject *fParent;
ClassDef(TMrbWindow2D, 2)
};
class TMbsWindowI : public TMrbWindow {
public:
TMbsWindowI() {};
~TMbsWindowI() {};
protected:
Int_t fXlower;
Int_t fXupper;
Int_t fLowerInit;
Int_t fUpperInit;
Int_t fLowerRange;
Int_t fUpperRange;
ClassDef(TMbsWindowI, 1)
};
class TMbsWindowF : public TMrbWindow {
public:
TMbsWindowF() {};
~TMbsWindowF() {};
protected:
Float_t fXlower;
Float_t fXupper;
Float_t fLowerInit;
Float_t fUpperInit;
Float_t fLowerRange;
Float_t fUpperRange;
ClassDef(TMbsWindowF, 1)
};
class TMbsWindow2d : public TCutG, public TAttText {
public:
TMbsWindow2d(){};
~TMbsWindow2d();
virtual void Draw(Option_t * Option = "");
Float_t GetXtext() { return(fXtext); }
Float_t GetYtext() { return(fYtext); }
protected:
Float_t fXtext;
Float_t fYtext;
TObject *fParent;
ClassDef(TMbsWindow2d, 1)
};
#endif