Loading...
Searching...
No Matches
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)
Rect & | operator= (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

## ◆ Rect() [1/4]

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

Rect default constructor.

## ◆ Rect() [2/4]

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.

## ◆ Rect() [3/4]

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

Create a Rect and initialize it using specified parameters.

Parameters

  x1 | The left-most position of the rect.
  y1 | The bottom-most position of the rect.
  x2 | The right-most position of the rect.
  y2 | The top-most position of the rect.

Returns
  a Rect (rectangle) object The rect is not attached to any Cos/SDF object.

## ◆ Rect() [4/4]

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

## Member Function Documentation

## ◆ Attach()

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.

## ◆ Contains()

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

  x | horizontal x value of the point to check
  y | vertical y value of the point to check

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

## ◆ Get()

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

Get the coordinates of the rectangle

## ◆ GetX1()

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

Returns
  The horizontal value of lower-left point.

## ◆ GetX2()

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

Returns
  The horizontal value of upper-right point.

## ◆ GetY1()

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

Returns
  The vertical value of lower-left point.

## ◆ GetY2()

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

Returns
  The vertical value of upper-right point.

## ◆ Height()

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

Returns
  rectangle's height

## ◆ Inflate() [1/2]

void pdftron::PDF::Rect::Inflate | ( | double | amount | ) |

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

Parameters

  amount | Specifies the amount to increase the rectangle in all directions.

## ◆ Inflate() [2/2]

void pdftron::PDF::Rect::Inflate | ( | double | x,
|  | double | y )

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

Parameters

  x | Specifies the amount to increase the rectangle's Left (x1) and Right (x2) properties.
  y | Specifies the amount to increase the rectangle's Top (y1) and Bottom (y2) properties.

## ◆ IntersectRect()

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.

## ◆ Normalize()

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.

## ◆ operator=()

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

## ◆ Set()

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

Set the coordinates of the rectangle

Parameters

  x1 | The left-most position of the rect.
  y1 | The bottom-most position of the rect.
  x2 | The right-most position of the rect.
  y2 | The top-most position of the rect. The rect is not attached to any Cos/SDF object.

## ◆ SetX1()

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

Set the horizontal value of lower-left point.

Parameters

  x1 | The left-most position of the rect.

## ◆ SetX2()

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

Set the horizontal value of upper-right point.

Parameters

  x2 | The right-most position of the rect.

## ◆ SetY1()

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

Set the vertical value of lower-left point.

Parameters

  y1 | The bottom-most position of the rect.

## ◆ SetY2()

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

Set the vertical value of upper-right point.

Parameters

  y2 | The top-most position of the rect.

## ◆ Update()

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.

## ◆ Width()

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

Returns
  rectangle's width

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

- PDF/Rect.h