File indexing completed on 2025-01-18 10:12:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TPad
0013 #define ROOT_TPad
0014
0015 #include "TVirtualPad.h"
0016 #include "TAttBBox2D.h"
0017 #include <vector>
0018
0019 class TVirtualViewer3D;
0020 class TVirtualPadPainter;
0021 class TBrowser;
0022 class TBox;
0023 class TLegend;
0024 class TArrow;
0025 class TPoint;
0026 class TWebCanvas;
0027
0028 class TPad : public TVirtualPad, public TAttBBox2D {
0029
0030 friend class TWebCanvas;
0031
0032 private:
0033 TObject *fTip{nullptr};
0034
0035 protected:
0036 Double_t fX1;
0037 Double_t fY1;
0038 Double_t fX2;
0039 Double_t fY2;
0040
0041 Double_t fXtoAbsPixelk;
0042 Double_t fXtoPixelk;
0043 Double_t fXtoPixel;
0044 Double_t fYtoAbsPixelk;
0045 Double_t fYtoPixelk;
0046 Double_t fYtoPixel;
0047
0048 Double_t fUtoAbsPixelk;
0049 Double_t fUtoPixelk;
0050 Double_t fUtoPixel;
0051 Double_t fVtoAbsPixelk;
0052 Double_t fVtoPixelk;
0053 Double_t fVtoPixel;
0054
0055 Double_t fAbsPixeltoXk;
0056 Double_t fPixeltoXk;
0057 Double_t fPixeltoX;
0058 Double_t fAbsPixeltoYk;
0059 Double_t fPixeltoYk;
0060 Double_t fPixeltoY;
0061
0062 Double_t fXlowNDC;
0063 Double_t fYlowNDC;
0064 Double_t fXUpNDC;
0065 Double_t fYUpNDC;
0066 Double_t fWNDC;
0067 Double_t fHNDC;
0068
0069 Double_t fAbsXlowNDC;
0070 Double_t fAbsYlowNDC;
0071 Double_t fAbsWNDC;
0072 Double_t fAbsHNDC;
0073
0074 Double_t fUxmin;
0075 Double_t fUymin;
0076 Double_t fUxmax;
0077 Double_t fUymax;
0078
0079 Double_t fTheta;
0080 Double_t fPhi;
0081
0082 Double_t fAspectRatio;
0083
0084 Int_t fPixmapID;
0085 Int_t fGLDevice;
0086 Bool_t fCopyGLDevice;
0087 Bool_t fEmbeddedGL;
0088 Int_t fNumber;
0089 Int_t fTickx;
0090 Int_t fTicky;
0091 Int_t fLogx;
0092 Int_t fLogy;
0093 Int_t fLogz;
0094 Int_t fPadPaint;
0095 Int_t fCrosshair;
0096 Int_t fCrosshairPos;
0097 Short_t fBorderSize;
0098 Short_t fBorderMode;
0099 Bool_t fModified;
0100 Bool_t fGridx;
0101 Bool_t fGridy;
0102 Bool_t fAbsCoord;
0103 Bool_t fEditable;
0104 Bool_t fFixedAspectRatio;
0105 TPad *fMother{nullptr};
0106 TCanvas *fCanvas{nullptr};
0107 TList *fPrimitives{nullptr};
0108 TList *fExecs{nullptr};
0109 TString fName;
0110 TString fTitle;
0111 TFrame *fFrame{nullptr};
0112 TView *fView{nullptr};
0113 TObject *fPadPointer{nullptr};
0114 TObject *fPadView3D{nullptr};
0115 static Int_t fgMaxPickDistance;
0116 Int_t fNumPaletteColor;
0117 Int_t fNextPaletteColor;
0118 std::vector<Bool_t> fCollideGrid;
0119 Int_t fCGnx;
0120 Int_t fCGny;
0121
0122
0123 TVirtualViewer3D *fViewer3D{nullptr};
0124
0125 void DestroyExternalViewer3D();
0126 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
0127 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0128 virtual void HideToolTip(Int_t event);
0129 void PaintBorder(Color_t color, Bool_t tops);
0130 void PaintBorderPS(Double_t xl,Double_t yl,Double_t xt,Double_t yt,Int_t bmode,Int_t bsize,Int_t dark,Int_t light) override;
0131 void PaintDate();
0132 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0133 void SetBatch(Bool_t batch=kTRUE) override;
0134
0135 private:
0136 TPad(const TPad &pad) = delete;
0137 TPad &operator=(const TPad &rhs) = delete;
0138
0139 void CopyBackgroundPixmap(Int_t x, Int_t y);
0140 void CopyBackgroundPixmaps(TPad *start, TPad *stop, Int_t x, Int_t y);
0141 void DrawDist(Rectangle_t aBBox, Rectangle_t bBBox, char mode);
0142
0143 Bool_t Collide(Int_t i, Int_t j, Int_t w, Int_t h);
0144 void FillCollideGrid(TObject *o);
0145 void FillCollideGridTBox(TObject *o);
0146 void FillCollideGridTFrame(TObject *o);
0147 void FillCollideGridTGraph(TObject *o);
0148 void FillCollideGridTH1(TObject *o);
0149 void LineNotFree(Int_t x1, Int_t x2, Int_t y1, Int_t y2);
0150
0151 public:
0152
0153 enum {
0154 kFraming = BIT(6),
0155 kHori = BIT(9),
0156 kClipFrame = BIT(10),
0157 kPrintingPS = BIT(11),
0158 kCannotMove = BIT(12),
0159 kClearAfterCR = BIT(14)
0160 };
0161
0162 TPad();
0163 TPad(const char *name, const char *title, Double_t xlow,
0164 Double_t ylow, Double_t xup, Double_t yup,
0165 Color_t color=-1, Short_t bordersize=-1, Short_t bordermode=-2);
0166 ~TPad() override;
0167 void AbsCoordinates(Bool_t set) override { fAbsCoord = set; }
0168 Double_t AbsPixeltoX(Int_t px) override { return fAbsPixeltoXk + px*fPixeltoX; }
0169 Double_t AbsPixeltoY(Int_t py) override { return fAbsPixeltoYk + py*fPixeltoY; }
0170 virtual void AbsPixeltoXY(Int_t xpixel, Int_t ypixel, Double_t &x, Double_t &y);
0171 void AddExec(const char *name, const char *command) override;
0172 virtual void AutoExec();
0173 void Browse(TBrowser *b) override;
0174 TLegend *BuildLegend(Double_t x1=0.3, Double_t y1=0.21, Double_t x2=0.3, Double_t y2=0.21, const char *title="", Option_t *option = "") override;
0175 TVirtualPad *cd(Int_t subpadnumber=0) override;
0176 void Clear(Option_t *option="") override;
0177 virtual Int_t Clip(Float_t *x, Float_t *y, Float_t xclipl, Float_t yclipb, Float_t xclipr, Float_t yclipt);
0178 Int_t Clip(Double_t *x, Double_t *y, Double_t xclipl, Double_t yclipb, Double_t xclipr, Double_t yclipt) override;
0179 virtual Int_t ClippingCode(Double_t x, Double_t y, Double_t xcl1, Double_t ycl1, Double_t xcl2, Double_t ycl2);
0180 virtual Int_t ClipPolygon(Int_t n, Double_t *x, Double_t *y, Int_t nn, Double_t *xc, Double_t *yc, Double_t xclipl, Double_t yclipb, Double_t xclipr, Double_t yclipt);
0181 void Close(Option_t *option="") override;
0182 virtual void Closed() { Emit("Closed()"); }
0183 void CopyPixmap() override;
0184 void CopyPixmaps() override;
0185 void DeleteExec(const char *name) override;
0186 void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override;
0187 virtual void DivideSquare(Int_t n, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0);
0188 void Draw(Option_t *option="") override;
0189 void DrawClassObject(const TObject *obj, Option_t *option="") override;
0190 static void DrawColorTable();
0191 virtual void DrawCrosshair();
0192 TH1F *DrawFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, const char *title="") override;
0193 void ExecuteEventAxis(Int_t event, Int_t px, Int_t py, TAxis *axis) override;
0194 TObject *FindObject(const char *name) const override;
0195 TObject *FindObject(const TObject *obj) const override;
0196 void UseCurrentStyle() override;
0197 Short_t GetBorderMode() const override { return fBorderMode;}
0198 Short_t GetBorderSize() const override { return fBorderSize;}
0199 Int_t GetCrosshair() const;
0200 Int_t GetCanvasID() const override;
0201 TCanvasImp *GetCanvasImp() const override;
0202 TFrame *GetFrame() override;
0203 Int_t GetEvent() const override;
0204 Int_t GetEventX() const override;
0205 Int_t GetEventY() const override;
0206 Color_t GetHighLightColor() const override;
0207 void GetRange(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) override;
0208 void GetRangeAxis(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) override;
0209 void GetPadPar(Double_t &xlow, Double_t &ylow, Double_t &xup, Double_t &yup) override;
0210 Double_t GetXlowNDC() const override { return fXlowNDC; }
0211 Double_t GetYlowNDC() const override { return fYlowNDC; }
0212
0213 Double_t GetWNDC() const override { return fWNDC; }
0214
0215 Double_t GetHNDC() const override { return fHNDC; }
0216 UInt_t GetWw() const override;
0217 UInt_t GetWh() const override;
0218 Double_t GetAbsXlowNDC() const override { return fAbsXlowNDC; }
0219 Double_t GetAbsYlowNDC() const override { return fAbsYlowNDC; }
0220 Double_t GetAbsWNDC() const override { return fAbsWNDC; }
0221 Double_t GetAbsHNDC() const override { return fAbsHNDC; }
0222 Double_t GetAspectRatio() const override { return fAspectRatio; }
0223 Double_t GetPhi() const override { return fPhi; }
0224 Double_t GetTheta() const override { return fTheta; }
0225
0226 Double_t GetUxmin() const override { return fUxmin; }
0227
0228 Double_t GetUymin() const override { return fUymin; }
0229
0230 Double_t GetUxmax() const override { return fUxmax; }
0231
0232 Double_t GetUymax() const override { return fUymax; }
0233 Bool_t GetGridx() const override { return fGridx; }
0234 Bool_t GetGridy() const override { return fGridy; }
0235 Int_t GetNumber() const override { return fNumber; }
0236 Int_t GetTickx() const override { return fTickx; }
0237 Int_t GetTicky() const override { return fTicky; }
0238 Double_t GetX1() const override { return fX1; }
0239 Double_t GetX2() const override { return fX2; }
0240 Double_t GetY1() const override { return fY1; }
0241 Double_t GetY2() const override { return fY2; }
0242 static Int_t GetMaxPickDistance();
0243 TList *GetListOfPrimitives() const override { return fPrimitives; }
0244 TList *GetListOfExecs() const override { return fExecs; }
0245 TObject *GetPrimitive(const char *name) const override;
0246 TObject *GetSelected() const override;
0247 TVirtualPad *GetPad(Int_t subpadnumber) const override;
0248 TObject *GetPadPointer() const override { return fPadPointer; }
0249 TVirtualPad *GetPadSave() const override;
0250 TVirtualPad *GetSelectedPad() const override;
0251 Int_t GetGLDevice() override;
0252 TView *GetView() const override { return fView; }
0253 TObject *GetView3D() const override { return fPadView3D; }
0254 Int_t GetLogx() const override { return fLogx; }
0255 Int_t GetLogy() const override { return fLogy; }
0256 Int_t GetLogz() const override { return fLogz; }
0257 TVirtualPad *GetMother() const override { return fMother; }
0258 const char *GetName() const override { return fName.Data(); }
0259 const char *GetTitle() const override { return fTitle.Data(); }
0260 TCanvas *GetCanvas() const override { return fCanvas; }
0261 TVirtualPad *GetVirtCanvas() const override;
0262 TVirtualPadPainter *GetPainter() override;
0263 Int_t GetPadPaint() const override { return fPadPaint; }
0264 Int_t GetPixmapID() const override { return fPixmapID; }
0265 ULong_t Hash() const override { return fName.Hash(); }
0266 Bool_t HasCrosshair() const override;
0267 void HighLight(Color_t col=kRed, Bool_t set=kTRUE) override;
0268 Bool_t HasFixedAspectRatio() const override { return fFixedAspectRatio; }
0269 Bool_t IsBatch() const override;
0270 Bool_t IsEditable() const override { return fEditable; }
0271 Bool_t IsFolder() const override { return kTRUE; }
0272 Bool_t IsModified() const override { return fModified; }
0273 Bool_t IsRetained() const override;
0274 Bool_t IsVertical() const override { return !TestBit(kHori); }
0275 Bool_t IsWeb() const override;
0276 void ls(Option_t *option="") const override;
0277 void Modified(Bool_t flag=true) override;
0278 void ModifiedUpdate() override;
0279 Bool_t OpaqueMoving() const override;
0280 Bool_t OpaqueResizing() const override;
0281 Double_t PadtoX(Double_t x) const override;
0282 Double_t PadtoY(Double_t y) const override;
0283 void Paint(Option_t *option="") override;
0284 void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="") override;
0285 void PaintFillArea(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
0286 void PaintFillArea(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0287 void PaintFillAreaNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0288 void PaintFillAreaHatches(Int_t n, Double_t *x, Double_t *y, Int_t FillStyle);
0289 void PaintHatches(Double_t dy, Double_t angle, Int_t nn, Double_t *xx, Double_t *yy);
0290 void PaintPadFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override;
0291 void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
0292 void PaintLineNDC(Double_t u1, Double_t v1,Double_t u2, Double_t v2) override;
0293 void PaintLine3D(Float_t *p1, Float_t *p2) override;
0294 void PaintLine3D(Double_t *p1, Double_t *p2) override;
0295 void PaintPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
0296 void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0297 void PaintPolyLine3D(Int_t n, Double_t *p) override;
0298 void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0299 void PaintPolyMarker(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
0300 void PaintPolyMarker(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0301 void PaintModified() override;
0302 void PaintText(Double_t x, Double_t y, const char *text) override;
0303 void PaintText(Double_t x, Double_t y, const wchar_t *text) override;
0304 void PaintTextNDC(Double_t u, Double_t v, const char *text) override;
0305 void PaintTextNDC(Double_t u, Double_t v, const wchar_t *text) override;
0306 virtual TPad *Pick(Int_t px, Int_t py, TObjLink *&pickobj);
0307 Double_t PixeltoX(Int_t px) override;
0308 Double_t PixeltoY(Int_t py) override;
0309 virtual void PixeltoXY(Int_t xpixel, Int_t ypixel, Double_t &x, Double_t &y);
0310 void Pop() override;
0311 void Print(const char *filename="") const override;
0312 void Print(const char *filename, Option_t *option) override;
0313 void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
0314 virtual void RangeChanged() { Emit("RangeChanged()"); }
0315 void RangeAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override;
0316 void RecursiveRemove(TObject *obj) override;
0317 void RedrawAxis(Option_t *option="") override;
0318 void ResetView3D(TObject *view=nullptr) override { fPadView3D=view; }
0319 void ResizePad(Option_t *option="") override;
0320 virtual void Resized() { Emit("Resized()"); }
0321 void SaveAs(const char *filename="",Option_t *option="") const override;
0322 void SetBorderMode(Short_t bordermode) override { fBorderMode = bordermode; Modified(); }
0323 void SetBorderSize(Short_t bordersize) override { fBorderSize = bordersize; Modified(); }
0324 void SetCanvas(TCanvas *c) override { fCanvas = c; }
0325 void SetCanvasSize(UInt_t ww, UInt_t wh) override;
0326 void SetCrosshair(Int_t crhair=1) override;
0327 void SetCursor(ECursor cursor) override;
0328 void SetDoubleBuffer(Int_t mode=1) override;
0329 void SetDrawOption(Option_t * = "") override {}
0330 void SetEditable(Bool_t mode=kTRUE) override;
0331 void SetFixedAspectRatio(Bool_t fixed = kTRUE) override;
0332 void SetGrid(Int_t valuex = 1, Int_t valuey = 1) override { fGridx = valuex; fGridy = valuey; Modified(); }
0333 void SetGridx(Int_t value = 1) override { fGridx = value; Modified(); }
0334 void SetGridy(Int_t value = 1) override { fGridy = value; Modified(); }
0335 void SetFillStyle(Style_t fstyle) override;
0336 void SetLogx(Int_t value = 1) override;
0337 void SetLogy(Int_t value = 1) override;
0338 void SetLogz(Int_t value = 1) override;
0339 virtual void SetNumber(Int_t number) { fNumber = number; }
0340 void SetPad(const char *name, const char *title,
0341 Double_t xlow, Double_t ylow, Double_t xup,
0342 Double_t yup, Color_t color=35,
0343 Short_t bordersize=5, Short_t bordermode=-1) override;
0344 void SetPad(Double_t xlow, Double_t ylow, Double_t xup, Double_t yup) override;
0345 void SetAttFillPS(Color_t color, Style_t style) override;
0346 void SetAttLinePS(Color_t color, Style_t style, Width_t lwidth) override;
0347 void SetAttMarkerPS(Color_t color, Style_t style, Size_t msize) override;
0348 void SetAttTextPS(Int_t align, Float_t angle, Color_t color, Style_t font, Float_t tsize) override;
0349 static void SetMaxPickDistance(Int_t maxPick=5);
0350 void SetName(const char *name) override { fName = name; }
0351 void SetSelected(TObject *obj) override;
0352 void SetTicks(Int_t valuex = 1, Int_t valuey = 1) override { fTickx = valuex; fTicky = valuey; Modified(); }
0353 void SetTickx(Int_t value = 1) override { fTickx = value; Modified(); }
0354 void SetTicky(Int_t value = 1) override { fTicky = value; Modified(); }
0355 void SetTitle(const char *title="") override { fTitle = title; }
0356 void SetTheta(Double_t theta=30) override { fTheta = theta; Modified(); }
0357 void SetPhi(Double_t phi=30) override { fPhi = phi; Modified(); }
0358 void SetToolTipText(const char *text, Long_t delayms = 1000) override;
0359 void SetVertical(Bool_t vert=kTRUE) override;
0360 void SetView(TView *view = nullptr) override;
0361 void SetViewer3D(TVirtualViewer3D *viewer3d) override { fViewer3D = viewer3d; }
0362
0363 virtual void SetGLDevice(Int_t dev) {fGLDevice = dev;}
0364 void SetCopyGLDevice(Bool_t copy) override { fCopyGLDevice = copy; }
0365
0366 void ShowGuidelines(TObject *object, const Int_t event, const char mode = 'i', const bool cling = true) override;
0367 void Update() override;
0368 void UpdateAsync() override;
0369
0370 Int_t UtoAbsPixel(Double_t u) const override;
0371 Int_t VtoAbsPixel(Double_t v) const override;
0372 Int_t UtoPixel(Double_t u) const override;
0373 Int_t VtoPixel(Double_t v) const override;
0374 TObject *WaitPrimitive(const char *pname="", const char *emode="") override;
0375 Int_t XtoAbsPixel(Double_t x) const override;
0376 Int_t YtoAbsPixel(Double_t y) const override;
0377 Double_t XtoPad(Double_t x) const override;
0378 Double_t YtoPad(Double_t y) const override;
0379 Int_t XtoPixel(Double_t x) const override;
0380 Int_t YtoPixel(Double_t y) const override;
0381 virtual void XYtoAbsPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const;
0382 virtual void XYtoPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const;
0383
0384 TObject *CreateToolTip(const TBox *b, const char *text, Long_t delayms) override;
0385 void DeleteToolTip(TObject *tip) override;
0386 void ResetToolTip(TObject *tip) override;
0387 void CloseToolTip(TObject *tip) override;
0388
0389 Int_t IncrementPaletteColor(Int_t i, TString opt) override;
0390 Int_t NextPaletteColor() override;
0391
0392 void DrawCollideGrid();
0393 Bool_t PlaceBox(TObject *o, Double_t w, Double_t h, Double_t &xl, Double_t &yb, Option_t* option = "lb") override;
0394
0395 virtual void x3d(Option_t *type="");
0396
0397 TVirtualViewer3D *GetViewer3D(Option_t * type = "") override;
0398 Bool_t HasViewer3D() const override { return fViewer3D != nullptr; }
0399 void ReleaseViewer3D(Option_t * type = "") override;
0400
0401 Rectangle_t GetBBox() override;
0402 TPoint GetBBoxCenter() override;
0403 void SetBBoxCenter(const TPoint &p) override;
0404 void SetBBoxCenterX(const Int_t x) override;
0405 void SetBBoxCenterY(const Int_t y) override;
0406 void SetBBoxX1(const Int_t x) override;
0407 void SetBBoxX2(const Int_t x) override;
0408 void SetBBoxY1(const Int_t y) override;
0409 void SetBBoxY2(const Int_t y) override;
0410
0411 virtual void RecordPave(const TObject *obj);
0412 virtual void RecordLatex(const TObject *obj);
0413 virtual void EventPave() { Emit("EventPave()"); }
0414 virtual void StartEditing() { Emit("StartEditing()"); }
0415
0416 ClassDefOverride(TPad,13)
0417 };
0418
0419 #endif
0420