File indexing completed on 2025-09-18 09:34:03
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 Add(TObject *obj, Option_t *opt = "", Bool_t modified = kTRUE) override;
0172 void AddFirst(TObject *obj, Option_t *opt = "", Bool_t modified = kTRUE) override;
0173 void AddExec(const char *name, const char *command) override;
0174 virtual void AutoExec();
0175 void Browse(TBrowser *b) override;
0176 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;
0177 TVirtualPad *cd(Int_t subpadnumber=0) override;
0178 void Clear(Option_t *option="") override;
0179 virtual Int_t Clip(Float_t *x, Float_t *y, Float_t xclipl, Float_t yclipb, Float_t xclipr, Float_t yclipt);
0180 Int_t Clip(Double_t *x, Double_t *y, Double_t xclipl, Double_t yclipb, Double_t xclipr, Double_t yclipt) override;
0181 virtual Int_t ClippingCode(Double_t x, Double_t y, Double_t xcl1, Double_t ycl1, Double_t xcl2, Double_t ycl2);
0182 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);
0183 void Close(Option_t *option="") override;
0184 virtual void Closed() { Emit("Closed()"); }
0185 void CopyPixmap() override;
0186 void CopyPixmaps() override;
0187 void DeleteExec(const char *name) override;
0188 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;
0189 virtual void DivideSquare(Int_t n, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0);
0190 void Draw(Option_t *option="") override;
0191 void DrawClassObject(const TObject *obj, Option_t *option="") override;
0192 static void DrawColorTable();
0193 virtual void DrawCrosshair();
0194 TH1F *DrawFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, const char *title="") override;
0195 void ExecuteEventAxis(Int_t event, Int_t px, Int_t py, TAxis *axis) override;
0196 TObject *FindObject(const char *name) const override;
0197 TObject *FindObject(const TObject *obj) const override;
0198 void UseCurrentStyle() override;
0199 Short_t GetBorderMode() const override { return fBorderMode;}
0200 Short_t GetBorderSize() const override { return fBorderSize;}
0201 Int_t GetCrosshair() const;
0202 Int_t GetCanvasID() const override;
0203 TCanvasImp *GetCanvasImp() const override;
0204 TFrame *GetFrame() override;
0205 Int_t GetEvent() const override;
0206 Int_t GetEventX() const override;
0207 Int_t GetEventY() const override;
0208 Color_t GetHighLightColor() const override;
0209 void GetRange(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) override;
0210 void GetRangeAxis(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) override;
0211 void GetPadPar(Double_t &xlow, Double_t &ylow, Double_t &xup, Double_t &yup) override;
0212 Double_t GetXlowNDC() const override { return fXlowNDC; }
0213 Double_t GetYlowNDC() const override { return fYlowNDC; }
0214
0215 Double_t GetWNDC() const override { return fWNDC; }
0216
0217 Double_t GetHNDC() const override { return fHNDC; }
0218 UInt_t GetWw() const override;
0219 UInt_t GetWh() const override;
0220 Double_t GetAbsXlowNDC() const override { return fAbsXlowNDC; }
0221 Double_t GetAbsYlowNDC() const override { return fAbsYlowNDC; }
0222 Double_t GetAbsWNDC() const override { return fAbsWNDC; }
0223 Double_t GetAbsHNDC() const override { return fAbsHNDC; }
0224 Double_t GetAspectRatio() const override { return fAspectRatio; }
0225 Double_t GetPhi() const override { return fPhi; }
0226 Double_t GetTheta() const override { return fTheta; }
0227
0228 Double_t GetUxmin() const override { return fUxmin; }
0229
0230 Double_t GetUymin() const override { return fUymin; }
0231
0232 Double_t GetUxmax() const override { return fUxmax; }
0233
0234 Double_t GetUymax() const override { return fUymax; }
0235 Bool_t GetGridx() const override { return fGridx; }
0236 Bool_t GetGridy() const override { return fGridy; }
0237 Int_t GetNumber() const override { return fNumber; }
0238 Int_t GetTickx() const override { return fTickx; }
0239 Int_t GetTicky() const override { return fTicky; }
0240 Double_t GetX1() const override { return fX1; }
0241 Double_t GetX2() const override { return fX2; }
0242 Double_t GetY1() const override { return fY1; }
0243 Double_t GetY2() const override { return fY2; }
0244 static Int_t GetMaxPickDistance();
0245 TList *GetListOfPrimitives() const override { return fPrimitives; }
0246 TList *GetListOfExecs() const override { return fExecs; }
0247 TObject *GetPrimitive(const char *name) const override;
0248 TObject *GetSelected() const override;
0249 TVirtualPad *GetPad(Int_t subpadnumber) const override;
0250 TObject *GetPadPointer() const override { return fPadPointer; }
0251 TVirtualPad *GetPadSave() const override;
0252 TVirtualPad *GetSelectedPad() const override;
0253 Int_t GetGLDevice() override;
0254 TView *GetView() const override { return fView; }
0255 TObject *GetView3D() const override { return fPadView3D; }
0256 Int_t GetLogx() const override { return fLogx; }
0257 Int_t GetLogy() const override { return fLogy; }
0258 Int_t GetLogz() const override { return fLogz; }
0259 TVirtualPad *GetMother() const override { return fMother; }
0260 const char *GetName() const override { return fName.Data(); }
0261 const char *GetTitle() const override { return fTitle.Data(); }
0262 TCanvas *GetCanvas() const override { return fCanvas; }
0263 TVirtualPad *GetVirtCanvas() const override;
0264 TVirtualPadPainter *GetPainter() override;
0265 Int_t GetPadPaint() const override { return fPadPaint; }
0266 Int_t GetPixmapID() const override { return fPixmapID; }
0267 ULong_t Hash() const override { return fName.Hash(); }
0268 Bool_t HasCrosshair() const override;
0269 void HighLight(Color_t col=kRed, Bool_t set=kTRUE) override;
0270 Bool_t HasFixedAspectRatio() const override { return fFixedAspectRatio; }
0271 Bool_t IsBatch() const override;
0272 Bool_t IsEditable() const override { return fEditable; }
0273 Bool_t IsFolder() const override { return kTRUE; }
0274 Bool_t IsModified() const override { return fModified; }
0275 Bool_t IsRetained() const override;
0276 Bool_t IsVertical() const override { return !TestBit(kHori); }
0277 Bool_t IsWeb() const override;
0278 void ls(Option_t *option="") const override;
0279 void Modified(Bool_t flag=true) override;
0280 void ModifiedUpdate() override;
0281 Bool_t OpaqueMoving() const override;
0282 Bool_t OpaqueResizing() const override;
0283 Double_t PadtoX(Double_t x) const override;
0284 Double_t PadtoY(Double_t y) const override;
0285 void Paint(Option_t *option="") override;
0286 void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="") override;
0287 void PaintFillArea(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
0288 void PaintFillArea(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0289 void PaintFillAreaNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0290 void PaintFillAreaHatches(Int_t n, Double_t *x, Double_t *y, Int_t FillStyle);
0291 void PaintHatches(Double_t dy, Double_t angle, Int_t nn, Double_t *xx, Double_t *yy);
0292 void PaintPadFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override;
0293 void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
0294 void PaintLineNDC(Double_t u1, Double_t v1,Double_t u2, Double_t v2) override;
0295 void PaintLine3D(Float_t *p1, Float_t *p2) override;
0296 void PaintLine3D(Double_t *p1, Double_t *p2) override;
0297 void PaintPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
0298 void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0299 void PaintPolyLine3D(Int_t n, Double_t *p) override;
0300 void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0301 void PaintPolyMarker(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
0302 void PaintPolyMarker(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
0303 void PaintModified() override;
0304 void PaintText(Double_t x, Double_t y, const char *text) override;
0305 void PaintText(Double_t x, Double_t y, const wchar_t *text) override;
0306 void PaintTextNDC(Double_t u, Double_t v, const char *text) override;
0307 void PaintTextNDC(Double_t u, Double_t v, const wchar_t *text) override;
0308 virtual TPad *Pick(Int_t px, Int_t py, TObjLink *&pickobj);
0309 Double_t PixeltoX(Int_t px) override;
0310 Double_t PixeltoY(Int_t py) override;
0311 virtual void PixeltoXY(Int_t xpixel, Int_t ypixel, Double_t &x, Double_t &y);
0312 void Pop() override;
0313 void Print(const char *filename="") const override;
0314 void Print(const char *filename, Option_t *option) override;
0315 void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
0316 virtual void RangeChanged() { Emit("RangeChanged()"); }
0317 void RangeAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override;
0318 void RecursiveRemove(TObject *obj) override;
0319 TObject *Remove(TObject *obj, Bool_t modified = kTRUE) override;
0320 void RedrawAxis(Option_t *option="") override;
0321 void ResetView3D(TObject *view=nullptr) override { fPadView3D=view; }
0322 void ResizePad(Option_t *option="") override;
0323 virtual void Resized() { Emit("Resized()"); }
0324 void SaveAs(const char *filename="",Option_t *option="") const override;
0325 void SetBorderMode(Short_t bordermode) override { fBorderMode = bordermode; Modified(); }
0326 void SetBorderSize(Short_t bordersize) override { fBorderSize = bordersize; Modified(); }
0327 void SetCanvas(TCanvas *c) override { fCanvas = c; }
0328 void SetCanvasSize(UInt_t ww, UInt_t wh) override;
0329 void SetCrosshair(Int_t crhair=1) override;
0330 void SetCursor(ECursor cursor) override;
0331 void SetDoubleBuffer(Int_t mode=1) override;
0332 void SetDrawOption(Option_t * = "") override {}
0333 void SetEditable(Bool_t mode=kTRUE) override;
0334 void SetFixedAspectRatio(Bool_t fixed = kTRUE) override;
0335 void SetGrid(Int_t valuex = 1, Int_t valuey = 1) override { fGridx = valuex; fGridy = valuey; Modified(); }
0336 void SetGridx(Int_t value = 1) override { fGridx = value; Modified(); }
0337 void SetGridy(Int_t value = 1) override { fGridy = value; Modified(); }
0338 void SetFillStyle(Style_t fstyle) override;
0339 void SetLogx(Int_t value = 1) override;
0340 void SetLogy(Int_t value = 1) override;
0341 void SetLogz(Int_t value = 1) override;
0342 virtual void SetNumber(Int_t number) { fNumber = number; }
0343 void SetPad(const char *name, const char *title,
0344 Double_t xlow, Double_t ylow, Double_t xup,
0345 Double_t yup, Color_t color=35,
0346 Short_t bordersize=5, Short_t bordermode=-1) override;
0347 void SetPad(Double_t xlow, Double_t ylow, Double_t xup, Double_t yup) override;
0348 void SetAttFillPS(Color_t color, Style_t style) override;
0349 void SetAttLinePS(Color_t color, Style_t style, Width_t lwidth) override;
0350 void SetAttMarkerPS(Color_t color, Style_t style, Size_t msize) override;
0351 void SetAttTextPS(Int_t align, Float_t angle, Color_t color, Style_t font, Float_t tsize) override;
0352 static void SetMaxPickDistance(Int_t maxPick=5);
0353 void SetName(const char *name) override { fName = name; }
0354 void SetSelected(TObject *obj) override;
0355 void SetTicks(Int_t valuex = 1, Int_t valuey = 1) override { fTickx = valuex; fTicky = valuey; Modified(); }
0356 void SetTickx(Int_t value = 1) override { fTickx = value; Modified(); }
0357 void SetTicky(Int_t value = 1) override { fTicky = value; Modified(); }
0358 void SetTitle(const char *title="") override { fTitle = title; }
0359 void SetTheta(Double_t theta=30) override { fTheta = theta; Modified(); }
0360 void SetPhi(Double_t phi=30) override { fPhi = phi; Modified(); }
0361 void SetToolTipText(const char *text, Long_t delayms = 1000) override;
0362 void SetVertical(Bool_t vert=kTRUE) override;
0363 void SetView(TView *view = nullptr) override;
0364 void SetViewer3D(TVirtualViewer3D *viewer3d) override { fViewer3D = viewer3d; }
0365
0366 virtual void SetGLDevice(Int_t dev) {fGLDevice = dev;}
0367 void SetCopyGLDevice(Bool_t copy) override { fCopyGLDevice = copy; }
0368
0369 void ShowGuidelines(TObject *object, const Int_t event, const char mode = 'i', const bool cling = true) override;
0370 void Update() override;
0371 void UpdateAsync() override;
0372
0373 Int_t UtoAbsPixel(Double_t u) const override;
0374 Int_t VtoAbsPixel(Double_t v) const override;
0375 Int_t UtoPixel(Double_t u) const override;
0376 Int_t VtoPixel(Double_t v) const override;
0377 TObject *WaitPrimitive(const char *pname="", const char *emode="") override;
0378 Int_t XtoAbsPixel(Double_t x) const override;
0379 Int_t YtoAbsPixel(Double_t y) const override;
0380 Double_t XtoPad(Double_t x) const override;
0381 Double_t YtoPad(Double_t y) const override;
0382 Int_t XtoPixel(Double_t x) const override;
0383 Int_t YtoPixel(Double_t y) const override;
0384 virtual void XYtoAbsPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const;
0385 virtual void XYtoPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const;
0386
0387 TObject *CreateToolTip(const TBox *b, const char *text, Long_t delayms) override;
0388 void DeleteToolTip(TObject *tip) override;
0389 void ResetToolTip(TObject *tip) override;
0390 void CloseToolTip(TObject *tip) override;
0391
0392 Int_t IncrementPaletteColor(Int_t i, TString opt) override;
0393 Int_t NextPaletteColor() override;
0394
0395 void DrawCollideGrid();
0396 Bool_t PlaceBox(TObject *o, Double_t w, Double_t h, Double_t &xl, Double_t &yb, Option_t* option = "lb") override;
0397
0398 virtual void x3d(Option_t *type="");
0399
0400 TVirtualViewer3D *GetViewer3D(Option_t * type = "") override;
0401 Bool_t HasViewer3D() const override { return fViewer3D != nullptr; }
0402 void ReleaseViewer3D(Option_t * type = "") override;
0403
0404 Rectangle_t GetBBox() override;
0405 TPoint GetBBoxCenter() override;
0406 void SetBBoxCenter(const TPoint &p) override;
0407 void SetBBoxCenterX(const Int_t x) override;
0408 void SetBBoxCenterY(const Int_t y) override;
0409 void SetBBoxX1(const Int_t x) override;
0410 void SetBBoxX2(const Int_t x) override;
0411 void SetBBoxY1(const Int_t y) override;
0412 void SetBBoxY2(const Int_t y) override;
0413
0414 virtual void RecordPave(const TObject *obj);
0415 virtual void RecordLatex(const TObject *obj);
0416 virtual void EventPave() { Emit("EventPave()"); }
0417 virtual void StartEditing() { Emit("StartEditing()"); }
0418
0419 ClassDefOverride(TPad,13)
0420 };
0421
0422 #endif
0423