pdftron::PDF::Rect Class Reference

Rect is a utility class used to manipulate PDF rectangle objects (refer to section 3.8.3 of the PDF Reference Manual). More...

#include <Rect.h>

List of all members.

Public Member Functions

 Rect ()
 Rect default constructor.
 Rect (SDF::Obj rect)
 Create a Rect and initialize it using given Cos/SDF rectangle Array object.
 Rect (double x1, double y1, double x2, double y2)
 Create a Rect and initialize it using specified parameters.
 Rect (const Rect &rect)
Rectoperator= (const Rect &rect)
void Attach (SDF::Obj rect)
 Attach the Cos/SDF object to the Rect.
bool Update (SDF::Obj rect=NULL)
 Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.
void Get (double &out_x1, double &out_y1, double &out_x2, double &out_y2) const
 Get the coordinates of the rectangle.
void Set (double x1, double y1, double x2, double y2)
 Set the coordinates of the rectangle.
double Width () const
 
Returns:
rectangle's width

double Height () const
 
Returns:
rectangle's height

bool Contains (double x, double y) const
 Determines if the specified point is contained within the rectangular region defined by this Rectangle.
bool IntersectRect (const Rect &rect1, const Rect &rect2)
 Makes a Rect equal to the intersection of two existing rectangles.
void Normalize ()
 Normalizes the rectangle to the one with lower-left and upper-right corners.
double GetX1 ()
 
Returns:
The horizontal value of lower-left point.

double GetY1 ()
 
Returns:
The vertical value of lower-left point.

double GetX2 ()
 
Returns:
The horizontal value of upper-right point.

double GetY2 ()
 
Returns:
The vertical value of upper-right point.

void SetX1 (double x1)
 Set the horizontal value of lower-left point.
void SetY1 (double y1)
 Set the vertical value of lower-left point.
void SetX2 (double x2)
 Set the horizontal value of upper-right point.
void SetY2 (double y2)
 Set the vertical value of upper-right point.


Detailed Description

Rect is a utility class used to manipulate PDF rectangle objects (refer to section 3.8.3 of the PDF Reference Manual).

Rect can be associated with a SDF/Cos rectangle array using Rect(Obj*) constructor or later using Rect::Attach(Obj*) or Rect::Update(Obj*) methods.

Rect keeps a local cache for rectangle points so it is necessary to call Rect::Update() method if the changes to the Rect should be saved in the attached Cos/SDF array.

Note:
- Although rectangles are conventionally specified by their lower-left and upper-right corners, it is acceptable to specify any two diagonally opposite corners.

Constructor & Destructor Documentation

pdftron::PDF::Rect::Rect (  ) 

Rect default constructor.

pdftron::PDF::Rect::Rect ( SDF::Obj  rect  ) 

Create a Rect and initialize it using given Cos/SDF rectangle Array object.

The rect is attached to this object.

pdftron::PDF::Rect::Rect ( double  x1,
double  y1,
double  x2,
double  y2 
)

Create a Rect and initialize it using specified parameters.

The rect is not attached to any Cos/SDF object.

pdftron::PDF::Rect::Rect ( const Rect rect  ) 


Member Function Documentation

Rect& pdftron::PDF::Rect::operator= ( const Rect rect  ) 

void pdftron::PDF::Rect::Attach ( SDF::Obj  rect  ) 

Attach the Cos/SDF object to the Rect.

Parameters:
rect - underlying Cos/SDF object. Must be an SDF::Array with four SDF::Number elements.

bool pdftron::PDF::Rect::Update ( SDF::Obj  rect = NULL  ) 

Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.

Parameters:
rect - an optional parameter indicating a SDF array that should be updated and attached to this Rect. If parameter rect is NULL or is omitted, update is performed on previously attached Cos/SDF rectangle.
Returns:
true if the attached Cos/SDF rectangle array was successfully updated, false otherwise.

void pdftron::PDF::Rect::Get ( double &  out_x1,
double &  out_y1,
double &  out_x2,
double &  out_y2 
) const

Get the coordinates of the rectangle.

void pdftron::PDF::Rect::Set ( double  x1,
double  y1,
double  x2,
double  y2 
)

Set the coordinates of the rectangle.

double pdftron::PDF::Rect::Width (  )  const

Returns:
rectangle's width

double pdftron::PDF::Rect::Height (  )  const

Returns:
rectangle's height

bool pdftron::PDF::Rect::Contains ( double  x,
double  y 
) const

Determines if the specified point is contained within the rectangular region defined by this Rectangle.

Returns:
true is the point is in the rectangle, false otherwise.

bool pdftron::PDF::Rect::IntersectRect ( const Rect rect1,
const Rect rect2 
)

Makes a Rect equal to the intersection of two existing rectangles.

Parameters:
rect1 - A Rect object that contains a source rectangle.
rect2 - A Rect object that contains a source rectangle.
Returns:
true if the intersection is not empty; 0 if the intersection is empty.
Note:
The intersection is the largest rectangle contained in both existing rectangles.

void pdftron::PDF::Rect::Normalize (  ) 

Normalizes the rectangle to the one with lower-left and upper-right corners.

Note:
Although rectangles are conventionally specified by their lower-left and upper-right corners, it is acceptable to specify any two diagonally opposite corners.

double pdftron::PDF::Rect::GetX1 (  ) 

Returns:
The horizontal value of lower-left point.

double pdftron::PDF::Rect::GetY1 (  ) 

Returns:
The vertical value of lower-left point.

double pdftron::PDF::Rect::GetX2 (  ) 

Returns:
The horizontal value of upper-right point.

double pdftron::PDF::Rect::GetY2 (  ) 

Returns:
The vertical value of upper-right point.

void pdftron::PDF::Rect::SetX1 ( double  x1  ) 

Set the horizontal value of lower-left point.

void pdftron::PDF::Rect::SetY1 ( double  y1  ) 

Set the vertical value of lower-left point.

void pdftron::PDF::Rect::SetX2 ( double  x2  ) 

Set the horizontal value of upper-right point.

void pdftron::PDF::Rect::SetY2 ( double  y2  ) 

Set the vertical value of upper-right point.


© 2002-2008 PDFTron Systems Inc.