IDS peak genericC++ v1.15.0
Loading...
Searching...
No Matches
peak::common::detail::RectangleT< PointType, SizeType > Class Template Reference

A generic rectangle defined by a point and a size. More...

#include <peak_common/types/geometry/peak_common_rectangle.hpp>

Public Member Functions

constexpr RectangleT ()=default
 Default constructor for RectangleT.
constexpr RectangleT (const PointT< PointType > &point, const SizeT< SizeType > &size)
 Constructs a rectangle from a point and a size.
constexpr RectangleT (PointType x, PointType y, SizeType width, SizeType height)
 Constructs a rectangle from coordinates and dimensions.
PEAK_COMMON_NO_DISCARD constexpr PointType GetX () const
 Returns the x-coordinate of the rectangle's top-left corner.
PEAK_COMMON_NO_DISCARD constexpr PointType GetY () const
 Returns the y-coordinate of the rectangle's top-left corner.
PEAK_COMMON_NO_DISCARD constexpr SizeType GetWidth () const
 Returns the width of the rectangle.
PEAK_COMMON_NO_DISCARD constexpr SizeType GetHeight () const
 Returns the height of the rectangle.
PEAK_COMMON_NO_DISCARD constexpr SizeT< SizeType > GetSize () const
 Returns the size of the rectangle.
PEAK_COMMON_NO_DISCARD constexpr PointT< PointType > GetPosition () const
 Returns the top-left corner of the rectangle as a Point.
template<typename RhsPointType, typename RhsSizeType>
constexpr bool operator== (const RectangleT< RhsPointType, RhsSizeType > &rhs) const
 Equality operator.
template<typename RhsPointType, typename RhsSizeType>
constexpr bool operator!= (const RectangleT< RhsPointType, RhsSizeType > &rhs) const
 Inequality operator.
PEAK_COMMON_NO_DISCARD std::string ToString () const
 Returns a string representation of the rectangle.

Friends

std::ostream & operator<< (std::ostream &os, RectangleT rectangle)
 Stream output operator for RectangleT.

Detailed Description

template<typename PointType, typename SizeType>
class peak::common::detail::RectangleT< PointType, SizeType >

A generic rectangle defined by a point and a size.

Represents a rectangle composed of a position (top-left corner) and a size. The position and size types are customizable via template parameters.

Template Parameters
PointTypeThe type representing the positions' coordinates (e.g., int32_t, float).
SizeTypeThe type representing the size's dimensions (e.g., uint32_t, float).
Since
ids_peak_common 1.0

Constructor & Destructor Documentation

◆ RectangleT() [1/3]

template<typename PointType, typename SizeType>
peak::common::detail::RectangleT< PointType, SizeType >::RectangleT ( )
constexprdefault

Default constructor for RectangleT.

Constructs an empty rectangle with default-initialized point and size.

Since
ids_peak_common 1.0

◆ RectangleT() [2/3]

template<typename PointType, typename SizeType>
peak::common::detail::RectangleT< PointType, SizeType >::RectangleT ( const PointT< PointType > & point,
const SizeT< SizeType > & size )
inlineconstexpr

Constructs a rectangle from a point and a size.

Parameters
pointThe top-left corner of the rectangle.
sizeThe dimensions of the rectangle.
Since
ids_peak_common 1.0

◆ RectangleT() [3/3]

template<typename PointType, typename SizeType>
peak::common::detail::RectangleT< PointType, SizeType >::RectangleT ( PointType x,
PointType y,
SizeType width,
SizeType height )
inlineconstexpr

Constructs a rectangle from coordinates and dimensions.

Parameters
xThe x-coordinate of the top-left corner.
yThe y-coordinate of the top-left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.
Since
ids_peak_common 1.0

Member Function Documentation

◆ GetHeight()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD constexpr SizeType peak::common::detail::RectangleT< PointType, SizeType >::GetHeight ( ) const
inlineconstexpr

Returns the height of the rectangle.

Returns
The height value.
Since
ids_peak_common 1.0

◆ GetPosition()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD constexpr PointT< PointType > peak::common::detail::RectangleT< PointType, SizeType >::GetPosition ( ) const
inlineconstexpr

Returns the top-left corner of the rectangle as a Point.

◆ GetSize()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD constexpr SizeT< SizeType > peak::common::detail::RectangleT< PointType, SizeType >::GetSize ( ) const
inlineconstexpr

Returns the size of the rectangle.

◆ GetWidth()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD constexpr SizeType peak::common::detail::RectangleT< PointType, SizeType >::GetWidth ( ) const
inlineconstexpr

Returns the width of the rectangle.

Returns
The value of the first coordinate.
Since
ids_peak_common 1.0

◆ GetX()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD constexpr PointType peak::common::detail::RectangleT< PointType, SizeType >::GetX ( ) const
inlineconstexpr

Returns the x-coordinate of the rectangle's top-left corner.

Returns
The value of the first coordinate.
Since
ids_peak_common 1.0

◆ GetY()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD constexpr PointType peak::common::detail::RectangleT< PointType, SizeType >::GetY ( ) const
inlineconstexpr

Returns the y-coordinate of the rectangle's top-left corner.

Returns
The value of the second coordinate.
Since
ids_peak_common 1.0

◆ operator!=()

template<typename PointType, typename SizeType>
template<typename RhsPointType, typename RhsSizeType>
bool peak::common::detail::RectangleT< PointType, SizeType >::operator!= ( const RectangleT< RhsPointType, RhsSizeType > & rhs) const
inlineconstexpr

Inequality operator.

Returns true if the rectangles are not equal.

Parameters
rhsThe RectangleT object to compare against.
Returns
true if either position or size is different; false otherwise.
Since
ids_peak_common 1.0

◆ operator==()

template<typename PointType, typename SizeType>
template<typename RhsPointType, typename RhsSizeType>
bool peak::common::detail::RectangleT< PointType, SizeType >::operator== ( const RectangleT< RhsPointType, RhsSizeType > & rhs) const
inlineconstexpr

Equality operator.

Compares position and size for equality.

Parameters
rhsThe RectangleT object to compare against.
Returns
true if both position and size are equal; false otherwise.
Since
ids_peak_common 1.0

◆ ToString()

template<typename PointType, typename SizeType>
PEAK_COMMON_NO_DISCARD std::string peak::common::detail::RectangleT< PointType, SizeType >::ToString ( ) const
inline

Returns a string representation of the rectangle.

The output format is: { point: ..., size: ... }.

Returns
A string containing the rectangle's description.
Since
ids_peak_common 1.0

◆ operator<<

template<typename PointType, typename SizeType>
std::ostream & operator<< ( std::ostream & os,
RectangleT< PointType, SizeType > rectangle )
friend

Stream output operator for RectangleT.

Outputs the rectangle in the format: { point: ..., size: ... }.

Parameters
osThe output stream.
rectangleThe rectangle to print.
Returns
Reference to the output stream.
Since
ids_peak_common 1.0

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