Logo ROOT   6.18/05
Reference Guide
TGDimension.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 02/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGDimension
13#define ROOT_TGDimension
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TGDimension, TGPosition, TGLongPosition, TGInsets and TGRectangle //
18// //
19// Several small geometry classes that implement dimensions //
20// (width and height), positions (x and y), insets and rectangles. //
21// They are trivial and their members are public. //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include "TObject.h"
26
28public:
29 UInt_t fWidth; // width
30 UInt_t fHeight; // height
31
34 ~TGDimension() = default;
35
37 { return ((fWidth == b.fWidth) && (fHeight == b.fHeight)); }
39 { return TGDimension(fWidth - b.fWidth, fHeight - b.fHeight); }
41 { return TGDimension(fWidth + b.fWidth, fHeight + b.fHeight); }
42};
43
44
46public:
47 Int_t fX; // x position
48 Int_t fY; // y position
49
50 TGPosition(): fX(0), fY(0) { }
51 TGPosition(Int_t xc, Int_t yc): fX(xc), fY(yc) { }
52 ~TGPosition() = default;
53
55 { return ((fX == b.fX) && (fY == b.fY)); }
57 { return TGPosition(fX - b.fX, fY - b.fY); }
59 { return TGPosition(fX + b.fX, fY + b.fY); }
60};
61
62
64public:
65 Long_t fX; // x position
66 Long_t fY; // y position
67
68 TGLongPosition(): fX(0), fY(0) { }
69 TGLongPosition(Long_t xc, Long_t yc): fX(xc), fY(yc) { }
70 ~TGLongPosition() = default;
71
73 { return ((fX == b.fX) && (fY == b.fY)); }
75 { return TGLongPosition(fX - b.fX, fY - b.fY); }
77 { return TGLongPosition(fX + b.fX, fY + b.fY); }
78};
79
80
81class TGInsets {
82public:
83 Int_t fL; // left
84 Int_t fR; // right
85 Int_t fT; // top
86 Int_t fB; // bottom
87
88 TGInsets(): fL(0), fR(0), fT(0), fB(0) { }
89 TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt):
90 fL(lf), fR(rg), fT(tp), fB(bt) { }
91 ~TGInsets() = default;
92
93 Bool_t operator==(const TGInsets &in) const
94 { return ((fL == in.fL) && (fR == in.fR) && (fT == in.fT) && (fB == in.fB)); }
95};
96
97
99public:
100 Int_t fX; // x position
101 Int_t fY; // y position
102 UInt_t fW; // width
103 UInt_t fH; // height
104
105 // constructors
106 TGRectangle(): fX(0), fY(0), fW(0), fH(0) { Empty(); }
108 fX(rx), fY(ry), fW(rw), fH(rh) { }
110 fX(p.fX), fY(p.fY), fW(d.fWidth), fH(d.fHeight) { }
111 ~TGRectangle() = default;
112
113 // methods
115 { return ((px >= fX) && (px < fX + (Int_t) fW) &&
116 (py >= fY) && (py < fY + (Int_t) fH)); }
117 Bool_t Contains(const TGPosition &p) const
118 { return ((p.fX >= fX) && (p.fX < fX + (Int_t) fW) &&
119 (p.fY >= fY) && (p.fY < fY + (Int_t) fH)); }
121 { return ((fX <= r.fX + (Int_t) r.fW - 1) && (fX + (Int_t) fW - 1 >= r.fX) &&
122 (fY <= r.fY + (Int_t) r.fH - 1) && (fY + (Int_t) fH - 1 >= r.fY)); }
123 Int_t Area() const
124 { return (fW * fH); }
126 { return TGDimension(fW, fH); }
128 { return TGPosition(fX, fY); }
130 { return TGPosition(fX + (Int_t) fW - 1, fY + (Int_t) fH - 1); }
131 void Merge(const TGRectangle &r);
132 void Empty() { fX = fY = 0; fW = fH = 0; }
133 Bool_t IsEmpty() const { return ((fW == 0) && (fH == 0)); }
134};
135
136#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
Bool_t operator==(const TGDimension &b) const
Definition: TGDimension.h:36
~TGDimension()=default
TGDimension operator+(const TGDimension &b) const
Definition: TGDimension.h:40
TGDimension(UInt_t width, UInt_t height)
Definition: TGDimension.h:33
TGDimension operator-(const TGDimension &b) const
Definition: TGDimension.h:38
UInt_t fHeight
Definition: TGDimension.h:30
UInt_t fWidth
Definition: TGDimension.h:29
~TGInsets()=default
Int_t fR
Definition: TGDimension.h:84
Bool_t operator==(const TGInsets &in) const
Definition: TGDimension.h:93
Int_t fL
Definition: TGDimension.h:83
Int_t fB
Definition: TGDimension.h:86
TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt)
Definition: TGDimension.h:89
Int_t fT
Definition: TGDimension.h:85
Bool_t operator==(const TGLongPosition &b) const
Definition: TGDimension.h:72
~TGLongPosition()=default
TGLongPosition(Long_t xc, Long_t yc)
Definition: TGDimension.h:69
TGLongPosition operator-(const TGLongPosition &b) const
Definition: TGDimension.h:74
TGLongPosition operator+(const TGLongPosition &b) const
Definition: TGDimension.h:76
~TGPosition()=default
TGPosition(Int_t xc, Int_t yc)
Definition: TGDimension.h:51
TGPosition operator-(const TGPosition &b) const
Definition: TGDimension.h:56
TGPosition operator+(const TGPosition &b) const
Definition: TGDimension.h:58
Bool_t operator==(const TGPosition &b) const
Definition: TGDimension.h:54
Int_t fY
Definition: TGDimension.h:48
Int_t fX
Definition: TGDimension.h:47
~TGRectangle()=default
Bool_t IsEmpty() const
Definition: TGDimension.h:133
Bool_t Contains(const TGPosition &p) const
Definition: TGDimension.h:117
void Empty()
Definition: TGDimension.h:132
TGRectangle(const TGPosition &p, const TGDimension &d)
Definition: TGDimension.h:109
TGPosition LeftTop() const
Definition: TGDimension.h:127
Bool_t Intersects(const TGRectangle &r) const
Definition: TGDimension.h:120
Bool_t Contains(Int_t px, Int_t py) const
Definition: TGDimension.h:114
TGDimension Size() const
Definition: TGDimension.h:125
TGRectangle(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh)
Definition: TGDimension.h:107
void Merge(const TGRectangle &r)
Definition: TGDimension.cxx:42
Int_t Area() const
Definition: TGDimension.h:123
TGPosition RightBottom() const
Definition: TGDimension.h:129