NLMISC::CRect Class Reference

#include <rect.h>


Detailed Description

This class describe an integer 2d rectangle.
Author:
Cyril Corvazier

Nevrax France

Date:
2000

Definition at line 43 of file rect.h.

Public Member Functions

sint32 bottom () const
 Return the higher Y coordinate of the box + 1.

 CRect (sint32 x, sint32 y)
 Constructor with a single 2d point. Build a rectangle with width and height = 0.

 CRect (sint32 x, sint32 y, uint32 width, uint32 height)
 Constructor with a 2d point, a width and a height.

 CRect ()
 default ctor

void extend (sint32 x, sint32 y)
 Extend the box for including the point which coordinates are passed in parameter.

sint32 getXCenter () const
 Compute the x center of the rectangle.

sint32 getYCenter () const
 Compute the y center of the rectangle.

sint32 left () const
 Return the lower X coordinate of the box.

sint32 right () const
 Return the higher X coordinate of the box + 1.

void set (sint32 x0, sint32 y0, sint32 x1, sint32 y1)
 Set from 2 2d points.

void setWH (sint32 x, sint32 y, uint32 width, uint32 height)
 Set from a 2d point, a width and a height.

sint32 top () const
 Return the lower Y coordinate of the box.


Data Fields

uint32 Height
 Height of the rect.

uint32 Width
 Width of the rect.

sint32 X
 Lower X coordinate of the rect.

sint32 Y
 Lower Y coordinate of the rect.


Constructor & Destructor Documentation

NLMISC::CRect::CRect  )  [inline]
 

default ctor

Definition at line 47 of file rect.h.

00047 {}

NLMISC::CRect::CRect sint32  x,
sint32  y,
uint32  width,
uint32  height
 

Constructor with a 2d point, a width and a height.

Definition at line 91 of file rect.cpp.

References height, setWH(), sint32, uint32, width, x, and y.

00092 {
00093         setWH(x, y, width, height);
00094 }

NLMISC::CRect::CRect sint32  x,
sint32  y
[inline]
 

Constructor with a single 2d point. Build a rectangle with width and height = 0.

Definition at line 53 of file rect.h.

References sint32, x, and y.

00054         {
00055                 X=x;
00056                 Y=y;
00057                 Width=0;
00058                 Height=0;
00059         }


Member Function Documentation

sint32 NLMISC::CRect::bottom  )  const [inline]
 

Return the higher Y coordinate of the box + 1.

Definition at line 89 of file rect.h.

References sint32.

Referenced by NL3D::CDriverGL::clipRect().

00090         {
00091                 return Y+(sint32)Height;
00092         }

void NLMISC::CRect::extend sint32  x,
sint32  y
 

Extend the box for including the point which coordinates are passed in parameter.

Definition at line 35 of file rect.cpp.

References sint32, uint32, x, and y.

00036 {
00037         if (x<X)
00038         {
00039                 Width+=(uint32)(X-x);
00040                 x=X;
00041         }
00042         else if (x>=(X+(sint32)Width))
00043                 Width=(uint32)(x-X+1);
00044         if (y<Y)
00045         {
00046                 Height+=(uint32)(Y-y);
00047                 y=Y;
00048         }
00049         else if (y>=(Y+(sint32)Height))
00050                 Height=(uint32)(y-Y+1);
00051 }

sint32 NLMISC::CRect::getXCenter  )  const [inline]
 

Compute the x center of the rectangle.

Definition at line 95 of file rect.h.

References sint32.

00096         {
00097                 return X+(sint32)(Width>>1);
00098         }

sint32 NLMISC::CRect::getYCenter  )  const [inline]
 

Compute the y center of the rectangle.

Definition at line 101 of file rect.h.

References sint32.

00102         {
00103                 return Y+(sint32)(Height>>1);
00104         }

sint32 NLMISC::CRect::left  )  const [inline]
 

Return the lower X coordinate of the box.

Definition at line 71 of file rect.h.

References sint32.

00072         {
00073                 return X;
00074         }

sint32 NLMISC::CRect::right  )  const [inline]
 

Return the higher X coordinate of the box + 1.

Definition at line 77 of file rect.h.

References sint32.

Referenced by NL3D::CDriverGL::clipRect().

00078         {
00079                 return X+(sint32)Width;
00080         }

void NLMISC::CRect::set sint32  x0,
sint32  y0,
sint32  x1,
sint32  y1
 

Set from 2 2d points.

Definition at line 65 of file rect.cpp.

References sint32.

Referenced by NL3D::CShapeBank::processWSUploadTexture(), and NL3D::CAsyncTextureManager::uploadTexturePart().

00066 {
00067         if (x0 < x1)
00068         {
00069                 X = x0;
00070                 Width = x1 - x0;
00071         }
00072         else
00073         {
00074                 X = x1;
00075                 Width = y0 - y1;
00076         }
00077 
00078         if (y0 < y1)
00079         {
00080                 Y = y0;
00081                 Height = y1 - y0;
00082         }
00083         else
00084         {
00085                 Y = y1;
00086                 Height = y0 - y1;
00087         }
00088 }

void NLMISC::CRect::setWH sint32  x,
sint32  y,
uint32  width,
uint32  height
 

Set from a 2d point, a width and a height.

Definition at line 55 of file rect.cpp.

References height, sint32, uint32, width, x, and y.

Referenced by CRect().

00056 {
00057         X=x;
00058         Y=y;
00059         Width=width;
00060         Height=height;
00061 }

sint32 NLMISC::CRect::top  )  const [inline]
 

Return the lower Y coordinate of the box.

Definition at line 83 of file rect.h.

References sint32.

00084         {
00085                 return Y;
00086         }


Field Documentation

uint32 NLMISC::CRect::Height
 

Height of the rect.

Definition at line 116 of file rect.h.

Referenced by NL3D::CDriverGL::clipRect(), NL3D::CDriverGL::fillBuffer(), NL3D::CDriverGL::getBuffer(), NL3D::CDriverGL::getBufferPart(), NL3D::CDriverGL::getZBuffer(), NL3D::CDriverGL::getZBufferPart(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().

uint32 NLMISC::CRect::Width
 

Width of the rect.

Definition at line 113 of file rect.h.

Referenced by NL3D::CDriverGL::clipRect(), NL3D::CDriverGL::fillBuffer(), NL3D::CDriverGL::getBuffer(), NL3D::CDriverGL::getBufferPart(), NL3D::CDriverGL::getZBuffer(), NL3D::CDriverGL::getZBufferPart(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().

sint32 NLMISC::CRect::X
 

Lower X coordinate of the rect.

Definition at line 107 of file rect.h.

Referenced by NL3D::CDriverGL::clipRect(), NL3D::CDriverGL::getBufferPart(), NL3D::CDriverGL::getZBufferPart(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().

sint32 NLMISC::CRect::Y
 

Lower Y coordinate of the rect.

Definition at line 110 of file rect.h.

Referenced by NL3D::CDriverGL::clipRect(), NL3D::CDriverGL::getBufferPart(), NL3D::CDriverGL::getZBufferPart(), NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverGL::uploadTexture().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:31:21 2004 for NeL by doxygen 1.3.6