All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pdftron::PDF::Rect Class Reference

#include <Rect.h>

+ Inheritance diagram for pdftron::PDF::Rect:

Public Member Functions

 Rect ()
 
 Rect (SDF::Obj rect)
 
 Rect (double x1, double y1, double x2, double y2)
 
 Rect (const Rect &rect)
 
Rectoperator= (const Rect &rect)
 
void Attach (SDF::Obj obj)
 
bool Update (SDF::Obj obj=NULL)
 
void Get (double &out_x1, double &out_y1, double &out_x2, double &out_y2) const
 
void Set (double x1, double y1, double x2, double y2)
 
double Width () const
 
double Height () const
 
bool Contains (double x, double y) const
 
bool IntersectRect (const Rect &rect1, const Rect &rect2)
 
void Normalize ()
 
void Inflate (double amount)
 
void Inflate (double x, double y)
 
double GetX1 () const
 
double GetY1 () const
 
double GetX2 () const
 
double GetY2 () const
 
void SetX1 (double x1)
 
void SetY1 (double y1)
 
void SetX2 (double x2)
 
void SetY2 (double y2)
 

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.

Definition at line 28 of file Rect.h.

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.

Parameters
x1The left-most position of the rect.
y1The bottom-most position of the rect.
x2The right-most position of the rect.
y2The top-most position of the rect.
Returns
a Rect (rectangle) object The rect is not attached to any Cos/SDF object.
pdftron::PDF::Rect::Rect ( const Rect rect)

Member Function Documentation

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

Attach the Cos/SDF object to the Rect.

Parameters
obj- underlying Cos/SDF object. Must be an SDF::Array with four SDF::Number elements.
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

Parameters
xhorizontal x value of the point to check
yvertical y value of the point to check
Returns
true is the point is in the rectangle, 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

double pdftron::PDF::Rect::GetX1 ( ) const
Returns
The horizontal value of lower-left point.
double pdftron::PDF::Rect::GetX2 ( ) const
Returns
The horizontal value of upper-right point.
double pdftron::PDF::Rect::GetY1 ( ) const
Returns
The vertical value of lower-left point.
double pdftron::PDF::Rect::GetY2 ( ) const
Returns
The vertical value of upper-right point.
double pdftron::PDF::Rect::Height ( ) const
Returns
rectangle's height
void pdftron::PDF::Rect::Inflate ( double  amount)

Expands the rectangle by the specified size, in all directions.

Parameters
amountSpecifies the amount to increase the rectangle in all directions.
void pdftron::PDF::Rect::Inflate ( double  x,
double  y 
)

Expands the rectangle by the specified size, in all directions.

Parameters
xSpecifies the amount to increase the rectangle's Left (x1) and Right (x2) properties.
ySpecifies the amount to increase the rectangle's Top (y1) and Bottom (y2) properties.
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 ( )

Arrange the points in the rectangle so that the first point is the lower-left corner and the second point is the upper-right corner of the rectangle.

Note
Although rectangles are conventionally specified by their lower-left and upper-right corners, it is acceptable to specify any two diagonally opposite corners.
Rect& pdftron::PDF::Rect::operator= ( const Rect rect)
void pdftron::PDF::Rect::Set ( double  x1,
double  y1,
double  x2,
double  y2 
)

Set the coordinates of the rectangle

Parameters
x1The left-most position of the rect.
y1The bottom-most position of the rect.
x2The right-most position of the rect.
y2The top-most position of the rect. The rect is not attached to any Cos/SDF object.
void pdftron::PDF::Rect::SetX1 ( double  x1)

Set the horizontal value of lower-left point.

Parameters
x1The left-most position of the rect.
void pdftron::PDF::Rect::SetX2 ( double  x2)

Set the horizontal value of upper-right point.

Parameters
x2The right-most position of the rect.
void pdftron::PDF::Rect::SetY1 ( double  y1)

Set the vertical value of lower-left point.

Parameters
y1The bottom-most position of the rect.
void pdftron::PDF::Rect::SetY2 ( double  y2)

Set the vertical value of upper-right point.

Parameters
y2The top-most position of the rect.
bool pdftron::PDF::Rect::Update ( SDF::Obj  obj = NULL)

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

Parameters
obj- 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.
double pdftron::PDF::Rect::Width ( ) const
Returns
rectangle's width

The documentation for this class was generated from the following file: