Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGDimension.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   02/01/98
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_TGDimension
0013 #define ROOT_TGDimension
0014 
0015 
0016 #include "RtypesCore.h"
0017 
0018 class TGDimension {
0019 public:
0020    UInt_t  fWidth;       // width
0021    UInt_t  fHeight;      // height
0022 
0023    TGDimension(): fWidth(0), fHeight(0) { }
0024    TGDimension(UInt_t width, UInt_t height): fWidth(width), fHeight(height) { }
0025    ~TGDimension() = default;
0026 
0027    Bool_t operator==(const TGDimension &b) const
0028       { return ((fWidth == b.fWidth) && (fHeight == b.fHeight)); }
0029    TGDimension operator-(const TGDimension &b) const
0030       { return TGDimension(fWidth - b.fWidth, fHeight - b.fHeight); }
0031    TGDimension operator+(const TGDimension &b) const
0032       { return TGDimension(fWidth + b.fWidth, fHeight + b.fHeight); }
0033 };
0034 
0035 
0036 class TGPosition {
0037 public:
0038    Int_t  fX;         ///< x position
0039    Int_t  fY;         ///< y position
0040 
0041    TGPosition(): fX(0), fY(0) { }
0042    TGPosition(Int_t xc, Int_t yc): fX(xc), fY(yc) { }
0043    ~TGPosition() = default;
0044 
0045    Bool_t operator==(const TGPosition &b) const
0046       { return ((fX == b.fX) && (fY == b.fY)); }
0047    TGPosition operator-(const TGPosition &b) const
0048       { return TGPosition(fX - b.fX, fY - b.fY); }
0049    TGPosition operator+(const TGPosition &b) const
0050       { return TGPosition(fX + b.fX, fY + b.fY); }
0051 };
0052 
0053 
0054 class TGLongPosition {
0055 public:
0056    Long_t  fX;         ///< x position
0057    Long_t  fY;         ///< y position
0058 
0059    TGLongPosition(): fX(0), fY(0) { }
0060    TGLongPosition(Long_t xc, Long_t yc): fX(xc), fY(yc) { }
0061    ~TGLongPosition() = default;
0062 
0063    Bool_t operator==(const TGLongPosition &b) const
0064       { return ((fX == b.fX) && (fY == b.fY)); }
0065    TGLongPosition operator-(const TGLongPosition &b) const
0066       { return TGLongPosition(fX - b.fX, fY - b.fY); }
0067    TGLongPosition operator+(const TGLongPosition &b) const
0068       { return TGLongPosition(fX + b.fX, fY + b.fY); }
0069 };
0070 
0071 
0072 class TGInsets {
0073 public:
0074    Int_t  fL;    ///< left
0075    Int_t  fR;    ///< right
0076    Int_t  fT;    ///< top
0077    Int_t  fB;    ///< bottom
0078 
0079    TGInsets(): fL(0), fR(0), fT(0), fB(0) { }
0080    TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt):
0081       fL(lf), fR(rg), fT(tp), fB(bt) { }
0082    ~TGInsets() = default;
0083 
0084    Bool_t operator==(const TGInsets &in) const
0085       { return ((fL == in.fL) && (fR == in.fR) && (fT == in.fT) && (fB == in.fB)); }
0086 };
0087 
0088 
0089 class TGRectangle {
0090 public:
0091    Int_t         fX;    ///< x position
0092    Int_t         fY;    ///< y position
0093    UInt_t        fW;    ///< width
0094    UInt_t        fH;    ///< height
0095 
0096    // constructors
0097    TGRectangle(): fX(0), fY(0), fW(0), fH(0) { Empty(); }
0098    TGRectangle(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
0099                 fX(rx), fY(ry), fW(rw), fH(rh) { }
0100    TGRectangle(const TGPosition &p, const TGDimension &d):
0101                 fX(p.fX), fY(p.fY), fW(d.fWidth), fH(d.fHeight) { }
0102    ~TGRectangle() = default;
0103 
0104    // methods
0105    Bool_t Contains(Int_t px, Int_t py) const
0106                 { return ((px >= fX) && (px < fX + (Int_t) fW) &&
0107                           (py >= fY) && (py < fY + (Int_t) fH)); }
0108    Bool_t Contains(const TGPosition &p) const
0109                 { return ((p.fX >= fX) && (p.fX < fX + (Int_t) fW) &&
0110                           (p.fY >= fY) && (p.fY < fY + (Int_t) fH)); }
0111    Bool_t Intersects(const TGRectangle &r) const
0112                 { return ((fX <= r.fX + (Int_t) r.fW - 1) && (fX + (Int_t) fW - 1 >= r.fX) &&
0113                           (fY <= r.fY + (Int_t) r.fH - 1) && (fY + (Int_t) fH - 1 >= r.fY)); }
0114    Int_t Area() const
0115                 { return (fW * fH); }
0116    TGDimension Size() const
0117                 { return TGDimension(fW, fH); }
0118    TGPosition LeftTop() const
0119                 { return TGPosition(fX, fY); }
0120    TGPosition RightBottom() const
0121                 { return TGPosition(fX + (Int_t) fW - 1, fY + (Int_t) fH - 1); }
0122    void Merge(const TGRectangle &r);
0123    void Empty() { fX = fY = 0; fW = fH = 0; }
0124    Bool_t IsEmpty() const { return ((fW == 0) && (fH == 0)); }
0125 };
0126 
0127 #endif