TPoint.h

Go to the documentation of this file.
00001 /* @(#)root/base:$Id: TPoint.h 22539 2008-03-08 14:36:37Z rdm $ */
00002 
00003 /*************************************************************************
00004  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #ifndef ROOT_TPoint
00012 #define ROOT_TPoint
00013 
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TPoint                                                               //
00018 //                                                                      //
00019 // TPoint implements a 2D screen (device) point (see also TPoints).     //
00020 //                                                                      //
00021 // Don't add in dictionary since that will add a virtual table pointer  //
00022 // and that will destroy the data layout of an array of TPoint's which  //
00023 // should match the layout of an array of XPoint's (so no extra copying //
00024 // needs to be done in the X11 drawing routines).                       //
00025 //                                                                      //
00026 //////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef ROOT_Rtypes
00029 #include "Rtypes.h"
00030 #endif
00031 
00032 
00033 class TPoint {
00034 
00035 public:    // for easy access
00036 #if !defined(WIN32) && !defined(G__WIN32)
00037    SCoord_t    fX;         //X device coordinate
00038    SCoord_t    fY;         //Y device coordinate
00039 #else
00040    long        fX;         //X device coordinate
00041    long        fY;         //Y device coordinate
00042 #endif
00043 
00044 public:
00045    TPoint() : fX(0), fY(0) { }
00046    TPoint(SCoord_t xy) : fX(xy), fY(xy) { }
00047    TPoint(SCoord_t x, SCoord_t y) : fX(x), fY(y) { }
00048    ~TPoint() { }
00049    SCoord_t    GetX() const { return (SCoord_t)fX; }
00050    SCoord_t    GetY() const { return (SCoord_t)fY; }
00051    void        SetX(SCoord_t x) { fX = x; }
00052    void        SetY(SCoord_t y) { fY = y; }
00053 
00054    TPoint& operator=(const TPoint& p) { fX = p.fX; fY = p.fY; return *this; }
00055    friend bool operator==(const TPoint& p1, const TPoint& p2);
00056    friend bool operator!=(const TPoint& p1, const TPoint& p2);
00057 };
00058 
00059 inline bool operator==(const TPoint& p1, const TPoint& p2)
00060 {
00061    return p1.fX == p2.fX && p1.fY == p2.fY;
00062 }
00063 
00064 inline bool operator!=(const TPoint& p1, const TPoint& p2)
00065 {
00066    return p1.fX != p2.fX || p1.fY != p2.fY;
00067 }
00068 
00069 #endif

Generated on Tue Jul 5 14:10:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1