Logo ROOT   6.19/01
Reference Guide
TPoint.h
Go to the documentation of this file.
1 /* @(#)root/base:$Id$ */
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOT_TPoint
12 #define ROOT_TPoint
13 
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TPoint //
18 // //
19 // TPoint implements a 2D screen (device) point (see also TPoints). //
20 // //
21 // Don't add in dictionary since that will add a virtual table pointer //
22 // and that will destroy the data layout of an array of TPoint's which //
23 // should match the layout of an array of XPoint's (so no extra copying //
24 // needs to be done in the X11 drawing routines). //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #include "Rtypes.h"
29 
30 
31 class TPoint {
32 
33 public: // for easy access
34 #if !defined(WIN32) && !defined(G__WIN32)
35  SCoord_t fX; //X device coordinate
36  SCoord_t fY; //Y device coordinate
37 #else
38  long fX; //X device coordinate
39  long fY; //Y device coordinate
40 #endif
41 
42 public:
43  TPoint() : fX(0), fY(0) { }
44  TPoint(SCoord_t xy) : fX(xy), fY(xy) { }
45  TPoint(SCoord_t x, SCoord_t y) : fX(x), fY(y) { }
46  SCoord_t GetX() const { return (SCoord_t)fX; }
47  SCoord_t GetY() const { return (SCoord_t)fY; }
48  void SetX(SCoord_t x) { fX = x; }
49  void SetY(SCoord_t y) { fY = y; }
50 
51  friend bool operator==(const TPoint& p1, const TPoint& p2);
52  friend bool operator!=(const TPoint& p1, const TPoint& p2);
53 };
54 
55 inline bool operator==(const TPoint& p1, const TPoint& p2)
56 {
57  return p1.fX == p2.fX && p1.fY == p2.fY;
58 }
59 
60 inline bool operator!=(const TPoint& p1, const TPoint& p2)
61 {
62  return p1.fX != p2.fX || p1.fY != p2.fY;
63 }
64 
65 #endif
TPoint(SCoord_t x, SCoord_t y)
Definition: TPoint.h:45
void SetX(SCoord_t x)
Definition: TPoint.h:48
friend bool operator!=(const TPoint &p1, const TPoint &p2)
Definition: TPoint.h:60
SCoord_t fX
Definition: TPoint.h:35
SCoord_t fY
Definition: TPoint.h:36
SCoord_t GetY() const
Definition: TPoint.h:47
SCoord_t GetX() const
Definition: TPoint.h:46
void SetY(SCoord_t y)
Definition: TPoint.h:49
Double_t x[n]
Definition: legend1.C:17
short SCoord_t
Definition: RtypesCore.h:80
Definition: TPoint.h:31
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
friend bool operator==(const TPoint &p1, const TPoint &p2)
Definition: TPoint.h:55
TPoint(SCoord_t xy)
Definition: TPoint.h:44
TPoint()
Definition: TPoint.h:43
bool operator!=(const TPoint &p1, const TPoint &p2)
Definition: TPoint.h:60
Double_t y[n]
Definition: legend1.C:17
bool operator==(const TPoint &p1, const TPoint &p2)
Definition: TPoint.h:55