![]() | InDesign SDK 20.5 |
#include <PMRect.h>
Public Types | |
| enum | PointIndex { kInvalidPoint = -1, kFirstPoint = 0, kMiddleTop = 0, kLeftMiddle = 1, kMiddleBottom = 2, kRightMiddle = 3, kLeftTop = 4, kRightTop = 5, kRightBottom = 6, kLeftBottom = 7, kCenter = 8, kLastPoint = kCenter } |
| typedef base_type | data_type |
Public Member Functions | |
| constexpr | PMRect () noexcept |
| PMRect (const PMPoint &point) noexcept | |
| PMRect (const PMPoint &one_corner, const PMPoint &opposing_corner) noexcept | |
| PMRect (const PMReal &l, const PMReal &t, const PMReal &r, const PMReal &b) noexcept | |
| PMRect (const SysRect &r) noexcept | |
| PMRect (const dvacore::geom::RectT< float > &r) noexcept | |
| constexpr | PMRect (const PMRect &) noexcept=default |
| constexpr | PMRect (PMRect &&) noexcept=default |
| PMRect & | operator= (const PMRect &) noexcept=default |
| PMRect & | operator= (PMRect &&) noexcept=default |
| bool16 | IsEmpty () const noexcept |
| bool16 | IsCorner (PointIndex whichPoint) const noexcept |
| bool16 | IsMiddle (PointIndex whichPoint) const noexcept |
| bool16 | PointIn (const PMPoint &pt) const noexcept |
| bool16 | ContainsPoint (const PMPoint &pt) const noexcept |
| bool16 | RectIn (const PMRect &r) const noexcept |
| bool16 | ContainsRect (const PMRect &r) const noexcept |
| bool16 | ContainsRect (const PMRect &r, const PMMatrix &r_to_this_xform) const |
| PMReal | AspectRatio () const |
| PMReal | DistanceTo (const PMPoint &pt) const |
| const PMReal & | Left () const noexcept |
| PMReal & | Left () noexcept |
| void | Left (const PMReal &c) noexcept |
| const PMReal & | Top () const noexcept |
| PMReal & | Top () noexcept |
| void | Top (const PMReal &c) noexcept |
| const PMReal & | Right () const noexcept |
| PMReal & | Right () noexcept |
| void | Right (const PMReal &c) noexcept |
| const PMReal & | Bottom () const noexcept |
| PMReal & | Bottom () noexcept |
| void | Bottom (const PMReal &c) noexcept |
| PMPoint | LeftTop (void) const noexcept |
| void | LeftTop (const PMPoint &pt) noexcept |
| PMPoint | RightBottom (void) const noexcept |
| void | RightBottom (const PMPoint &pt) noexcept |
| PMPoint | RightTop (void) const noexcept |
| void | RightTop (const PMPoint &pt) noexcept |
| PMPoint | LeftBottom (void) const noexcept |
| void | LeftBottom (const PMPoint &pt) noexcept |
| PMReal | Height () const noexcept |
| PMReal | Width () const noexcept |
| PMPoint | Dimensions () const noexcept |
| void | SetHeight (const PMReal &height) |
| void | SetWidth (const PMReal &width) |
| void | SetDimensions (const PMReal &width, const PMReal &height) |
| PMReal | GetHCenter () const |
| PMReal | GetVCenter () const |
| PMPoint | GetCenter () const |
| PMPoint | GetPoint (PointIndex whichPoint) const |
| PointIndex | GetPointIndex (const PMPoint &aPoint) const |
| PMPoint | GetOppositePoint (PointIndex whichPoint) const |
| PointIndex | GetOppositePointIndex (PointIndex whichPoint) const |
| PMRect & | SetEmpty () noexcept |
| bool16 | Normalize () noexcept |
| PMRect & | Round () |
| PointIndex | MovePointTo (PointIndex whichPoint, const PMPoint &toPt) |
| PMRect & | MoveRel (const PMReal &dx, const PMReal &dy) |
| PMRect & | MoveRel (const PMPoint &point) |
| PMRect & | MoveTo (const PMReal &dx, const PMReal &dy) |
| PMRect & | MoveTo (const PMPoint &point) |
| PMRect & | CenterOn (const PMReal &dx, const PMReal &dy) |
| PMRect & | CenterOn (const PMPoint &point) |
| PMRect & | Inset (const PMReal &dx, const PMReal &dy) |
| bool16 | ConstrainTo (PMRect &constrainedRect) |
| void | Union (const PMRect &rhs) |
| void | Expand (const PMPoint &pt) |
| void | ReadWrite (IPMStream *iPMStream) |
Static Public Member Functions | |
| static int32 | PointIndexToIndex (PMRect::PointIndex ptIndex) |
| static PMRect::PointIndex | IndexToPointIndex (int32 index) |
Friends | |
| SysRect | ToSys (const PMRect &r) |
| dvacore::geom::RectT< float > | ToRectF32_ (const PMRect &r) |
| Int32Rect | ToInt32Rect_ (const PMRect &r) |
| bool16 | Intersect (const PMRect &r1, const PMRect &r2) |
| bool16 | Intersect_exact (const PMRect &r1, const PMRect &r2) |
| bool16 | Intersect (const PMRect &r1, const PMMatrix &xform, const PMRect &r2) |
| PMRect | MakeIntersect (const PMRect &r1, const PMMatrix &xform, const PMRect &r2) |
| bool16 | IntersectOrAbut (const PMRect &r1, const PMRect &r2) |
| bool16 | IntersectOrAbut_exact (const PMRect &r1, const PMRect &r2) |
| bool16 | IntersectOrAbut (const PMRect &r1, const PMMatrix &xform, const PMRect &r2) |
| PMRect | MakeIntersectOrAbut (const PMRect &r1, const PMMatrix &xform, const PMRect &r2) |
| PMRect | Intersection (const PMRect &r1, const PMRect &r2, const PMRect &emptyRect) |
| PMRect | IntersectionOrAbut (const PMRect &r1, const PMRect &r2, const PMRect &emptyRect) |
| PMRect | Union (const PMRect &r1, const PMRect &r2) |
| bool16 | UnionIsRect (const PMRect &r1, const PMRect &r2) |
| bool16 | operator== (const PMRect &a, const PMRect &b) noexcept |
| bool16 | operator!= (const PMRect &a, const PMRect &b) noexcept |
| bool16 | Intersect_ (const PMRect &r1, const PMMatrix &r1_to_r2_xform, const PMRect &r2, PMPoint *p) |
| bool16 | IntersectOrAbut_ (const PMRect &r1, const PMMatrix &r1_to_r2_xform, const PMRect &r2, PMPoint *p) |
| enum PMRect::PointIndex |
Point types in a PMRect
| inlinenoexcept |
Constructs an empty PMRect situated at origin. The resulting rectangle has its components all set to zero and has zero width and height.
| explicitnoexcept |
Constructs an empty PMRect situated at the specified point. The rectangle's left and right are set to point's X component, and its top and bottom are set to point's Y component.
| point | IN The point at which the rectangle is situated |
Constructs a PMRect with the specified opposing corners.
| one_corner | IN One corner of the rectangle |
| opposing_corner | IN The corner of the rectangle opposite one_corner |
Constructs a PMRect with the specified top-left and bottom-right. Note since the constructed rectangle is normalized, l and r can be passed in swapped, as can t and b.
| l | IN The left component for the rectangle |
| t | IN The top component for the rectangle |
| r | IN The right component for the rectangle |
| b | IN The bottom component for the rectangle |
| noexcept |
Constructs a PMRect based on the specified system rectangle.
| r | IN The system rectangle on which the rectangle is based |
| explicitnoexcept |
Constructs a PMRect based on the drover rectangle.
| r | IN The drover rectangle on which the rectangle is based |
| PMReal PMRect::AspectRatio | ( | ) | const |
Calculates the aspect ratio for the rectangle. The aspect ratio is calculated as the ratio of the rectangle's height to its width. If the rectangle is empty, zero is returned.
| inlinenoexcept |
Returns a const reference to the rectangle's bottom component.
| inlinenoexcept |
Returns a reference to the rectangle's bottom component.
| inlinenoexcept |
Sets the rectangle's bottom component.
| c | IN The rectangle's new bottom component |
| bool16 PMRect::ConstrainTo | ( | PMRect & | constrainedRect | ) |
Constrains the specified rectangle to the bounds of this rectangle.
| constrainedRect | IN/OUT The rectangle to be constrained |
| inlinenoexcept |
Determines whether the specified point falls within this rectangle or on its border. Unlike PointIn, ContainsPoint uses exact machine double comparisons, not fuzzy PMReal comparisons.
| pt | IN The point to test |
| inlinenoexcept |
Determines whether the passed in rectangle r is contained with 'this' rectangle. Unlike RectIn, ContainsRect uses exact machine double comparisons, not fuzzy PMReal comparisons.
| r | IN The rectangle to test |
Determines whether the passed in rectangle r when transformed by r_to_this_xform is contained with 'this' rectangle.
| r | IN The rectangle to test |
| r_to_this_xform | IN the matrix that brings r into the coordinate space of this |
| inlinenoexcept |
Returns the dimensions of the rectangle as a PMPoint.
NOTE: This assumes the rect is normalized.
Calculates the distance from the specified point to one of the rectangle's edges.
| pt | IN The point to test |
| void PMRect::Expand | ( | const PMPoint & | pt | ) |
Expands this rectangle so that it is large enough to contain the specified point. Identical to Union with a rectangle that encompasses the point.
| pt | IN The point used in the expansion |
| PMPoint PMRect::GetCenter | ( | ) | const |
Returns the center of the rectangle.
| PMReal PMRect::GetHCenter | ( | ) | const |
Returns the horizontal center of the rectangle.
| inline |
Retrieves the point opposite to the specified point in the rectangle.
| inline |
Retrieves the index of the point opposite the specified point in the rectangle.
| whichPoint | IN The index of the point whose opposite is to be returned |
| PMPoint PMRect::GetPoint | ( | PointIndex | whichPoint | ) | const |
Retrieves the specified point in the rectangle.
| PointIndex PMRect::GetPointIndex | ( | const PMPoint & | aPoint | ) | const |
Retrieves the point index for the specified point. If the point does not correspond to any of enumerated points, kInvalidPoint is returned.
| aPoint | IN The point to test |
| PMReal PMRect::GetVCenter | ( | ) | const |
Returns the vertical center of the rectangle.
| inlinenoexcept |
Returns the height of the rectangle.
NOTE: This assumes the rect is normalized.
| static |
Converts an integer into a PointIndex. Used internally in some hit-testing code. Probably not useful for third-party developers.
| index | IN The integer value to convert |
Contracts the rectangle by (dx, dy) on all sides. Positive values contract the rectangle, negative values enlarge it.
| dx | IN The amount by which the left and right components are adjusted |
| dy | IN The amount by which the top and bottom components are adjusted |
| inlinenoexcept |
Determines whether specified point index identifies a corner point.
| whichPoint | IN The point index to test |
| inlinenoexcept |
Determines whether rectangle is empty. A rectangle is empty if its left and right or top and bottom components are equal.
| inlinenoexcept |
Determines whether specified point index identifies a middle point.
| whichPoint | IN The point index to test |
| inlinenoexcept |
Returns a const reference to the rectangle's left component.
| inlinenoexcept |
Returns a reference to the rectangle's left component.
| inlinenoexcept |
Sets the rectangle's left component.
| c | IN The rectangle's new left component |
| inlinenoexcept |
Returns the rectangle's bottom-left point.
| inlinenoexcept |
Sets the rectangle's bottom-left point.
| pt | IN The rectangle's new bottom-left point |
| inlinenoexcept |
Returns the rectangle's top-left point.
| inlinenoexcept |
Sets the rectangle's top-left point.
| pt | IN The rectangle's new top-left point |
| PointIndex PMRect::MovePointTo | ( | PointIndex | whichPoint, |
| const PMPoint & | toPt | ||
| ) |
Moves the given point to the new location and returns the (possibly changed) index of the moved point.
NOTE: MidPoints will only move perpendicular to their side of the rectangle. Only the height or width will change, not both.
| whichPoint | IN The index of the point to move |
| toPt | IN The new location for the specified point |
| noexcept |
Normalizes this rectangle so that its right component is greater than its left, and its bottom greater than its top.
| inlinenoexcept |
Determines whether the specified point falls within this rectangle
| pt | IN The point to test |
| static |
Converts a PointIndex into an integer. Used internally in some hit-testing code. Probably not useful for third-party developers.
| ptIndex | IN The point index to convert |
| void PMRect::ReadWrite | ( | IPMStream * | iPMStream | ) |
Persists this rectangle to the specified stream
| iPMStream | IN The stream to which the rectangle's components are written |
| inlinenoexcept |
Determines whether the passed in rectangle r is contained with 'this' rectangle.
| r | IN The rectangle to test |
| inlinenoexcept |
Returns a const reference to the rectangle's right component.
| inlinenoexcept |
Returns a reference to the rectangle's right component.
| inlinenoexcept |
Sets the rectangle's right component.
| c | IN The rectangle's new right component |
| inlinenoexcept |
Returns the rectangle's bottom-right point.
| inlinenoexcept |
Sets the rectangle's bottom-right point.
| pt | IN The rectangle's new bottom-right point |
| inlinenoexcept |
Returns the rectangle's top-right point.
| inlinenoexcept |
Sets the rectangle's top-right point.
| pt | IN The rectangle's new top-right point |
| PMRect& PMRect::Round | ( | ) |
Adjusts the components of the rectangle by rounding them to the nearest integer value.
Sets the dimensions of the rectangle by adjusting its bottom and right components. The width and height are assumed to be positive.
| width | IN The new width for the rectangle |
| height | IN The new height for the rectangle |
| inlinenoexcept |
Makes the rectangle empty by setting its right and bottom components equal to its left and top components, respectively.
| void PMRect::SetHeight | ( | const PMReal & | height | ) |
Sets the height of the rectangle by adjusting its bottom component. The height is assumed to be positive.
| height | IN The new height for the rectangle |
| void PMRect::SetWidth | ( | const PMReal & | width | ) |
Sets the width of the rectangle by adjusting its right component. The width is assumed to be positive.
| width | IN The new width for the rectangle |
| inlinenoexcept |
Returns a const reference to the rectangle's top component.
| inlinenoexcept |
Returns a reference to the rectangle's top component.
| inlinenoexcept |
Sets the rectangle's top component.
| c | IN The rectangle's new top component |
| void PMRect::Union | ( | const PMRect & | rhs | ) |
Unions this rectangle with another. Note this member function differs from the friend Union(r1, r2) declared below in the behavior of rectangles with zero-area (those for which IsEmpty() returns true). This member function deliberately ignores any contribution from zero-area rectangles. So if rhs.IsEmpty(), then Union returns immediately with *this not modified. Otherwise if this->IsEmpty(), then rhs is copied to *this. Otherwise *this is extended to be the smallest rectangle enclosing rhs and the current value of *this. Contrast this with the quite different behavior toward zero-area rectangles used by the friend function described below. Consider the following example: PMRect justOrigin(); //left == top == right == bottom == 0 PMRect justSegment(1,-1,3,-1); //just a line segment from (1,-1) to (3,-1) PMRect someArea(1,1,2,2); //a square someArea.Union(justSegment); someArea.Union(justOrigin); Here someArea would not have changed from its constructed value. Contrast that with the example for the friend function.
| rhs | IN The rectangle with which this one is unioned |
| inlinenoexcept |
Returns the width of the rectangle.
NOTE: This assumes the rect is normalized.
Determines if two rectangles intersect. True if rectangles intersect in both x and y directions, but false if only a side is shared (ie., rectangles must strictly intersect).
| r1 | IN The first rectangle to test |
| r2 | IN The second rectangle to test |
Calculates the intersection of two rectangles. If the rectangles do not strictly intersect, the specified empty rectangle is returned.
| r1 | IN The first rectangle to intersect |
| r2 | IN The second rectangle to intersect |
| emptyRect | IN Used as return value if rectangles do not intersect |
Calculates the intersection of two rectangles. The rectangles do not need to strictly intersect, but may abut. If the two rectangles do not intersect or abut, the specified empty rectangle is returned.
| r1 | IN The first rectangle to intersect |
| r2 | IN The second rectangle to intersect |
| emptyRect | IN Used as return value if rectangles do not intersect or abut |
Determines if two rectangles intersect or abut. True if rectangles intersect in both x and y directions or if they share a side.
| r1 | IN The first rectangle to test |
| r2 | IN The second rectangle to test |
Compares two rectangles for inequality.
Note: This implicitly uses an epsilon comparison.
| a | IN The first rectangle to compare |
| b | IN The second rectangle to compare |
Compares two rectangles for equality. All four components must match.
Note: This implicitly uses an epsilon comparison.
| a | IN The first rectangle to compare |
| b | IN The second rectangle to compare |
| friend |
Union two rectangles together, returning the resulting rectangle. Note this friend function differs from the member Union(rhs) declared above in the behavior of rectangles with zero-area (those for which IsEmpty() returns true). In partcular, r1 and r2 are never considered empty–even if they enclose zero-area. So be careful. Consider the following example: PMRect justOrigin(); //left == top == right == bottom == 0 PMRect justSegment(1,-1,3,-1); //just a line segment from (1,-1) to (3,-1) PMRect someArea(1,1,2,2); //a square PMRect result = Union( Union(someArea, justSegment), justOrigin); Here result would be left == 0, top == -1, right == 3, bottom == 2. Contrast that with the example for the member function.
| r1 | IN The first rectangle to union |
| r2 | IN The second rectangle to union |