Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:30:07

0001 // @(#)root/graf:$Id$
0002 // Author: Rene Brun   12/12/94
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TLine
0013 #define ROOT_TLine
0014 
0015 
0016 #include "TObject.h"
0017 #include "TAttLine.h"
0018 #include "TAttBBox2D.h"
0019 
0020 class TPoint;
0021 
0022 class TLine : public TObject, public TAttLine, public TAttBBox2D {
0023 
0024 protected:
0025    Double_t      fX1{0};           ///< X of 1st point
0026    Double_t      fY1{0};           ///< Y of 1st point
0027    Double_t      fX2{0};           ///< X of 2nd point
0028    Double_t      fY2{0};           ///< Y of 2nd point
0029 
0030 public:
0031    // TLine status bits
0032    enum {
0033       kLineNDC    = BIT(14), ///< Use NDC coordinates
0034       kVertical   = BIT(15), ///< Line is vertical
0035       kHorizontal = BIT(16)  ///< Line is horizontal
0036    };
0037 
0038    TLine() {}
0039    TLine(Double_t x1, Double_t y1, Double_t x2, Double_t  y2);
0040    TLine(const TLine &line);
0041    ~TLine() override = default;
0042 
0043    TLine &operator=(const TLine &src);
0044 
0045    void                 Copy(TObject &line) const override;
0046    Int_t                DistancetoPrimitive(Int_t px, Int_t py) override;
0047    virtual TLine       *DrawLine(Double_t x1, Double_t y1,Double_t x2, Double_t y2);
0048    virtual TLine       *DrawLineNDC(Double_t x1, Double_t y1,Double_t x2, Double_t y2);
0049    void                 ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0050    Double_t             GetX1() const {return fX1;}
0051    Double_t             GetX2() const {return fX2;}
0052    Double_t             GetY1() const {return fY1;}
0053    Double_t             GetY2() const {return fY2;}
0054    Double_t             GetSlope() const; 
0055    Double_t             GetYIntercept() const;
0056    Bool_t               IsHorizontal();
0057    Bool_t               IsVertical();
0058    void                 ls(Option_t *option="") const override;
0059    void                 Paint(Option_t *option="") override;
0060    virtual void         PaintLine(Double_t x1, Double_t y1,Double_t x2, Double_t  y2);
0061    virtual void         PaintLineNDC(Double_t u1, Double_t v1,Double_t u2, Double_t  v2);
0062    void                 Print(Option_t *option="") const override;
0063    void                 SavePrimitive(std::ostream &out, Option_t *option = "") override;
0064    virtual void         SetNDC(Bool_t isNDC=kTRUE);
0065    void                 SetHorizontal(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsHorizontal
0066    void                 SetVertical(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsVertical
0067    virtual void         SetX1(Double_t x1) {fX1=x1;}
0068    virtual void         SetX2(Double_t x2) {fX2=x2;}
0069    virtual void         SetY1(Double_t y1) {fY1=y1;}
0070    virtual void         SetY2(Double_t y2) {fY2=y2;}
0071    Rectangle_t          GetBBox() override;
0072    TPoint               GetBBoxCenter() override;
0073    void                 SetBBoxCenter(const TPoint &p) override;
0074    void                 SetBBoxCenterX(const Int_t x) override;
0075    void                 SetBBoxCenterY(const Int_t y) override;
0076    void                 SetBBoxX1(const Int_t x) override;
0077    void                 SetBBoxX2(const Int_t x) override;
0078    void                 SetBBoxY1(const Int_t y) override;
0079    void                 SetBBoxY2(const Int_t y) override;
0080 
0081    ClassDefOverride(TLine,3)  //A line segment
0082 };
0083 
0084 #endif