OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::Rect Class Reference

Rectangle that holds the top left and bottom right corner in int values. More...

#include "Rect.h"

Inheritance diagram for ot::Rect:
ot::Serializable

Public Member Functions

 Rect ()
 
 Rect (const Point2D &_topLeft, const Point2D &_bottomRight)
 
 Rect (const Point2D &_topLeft, const Size2D &_size)
 
 Rect (const Rect &_other)
 
virtual void addToJsonObject (ot::JsonValue &_object, ot::JsonAllocator &_allocator) const override
 Add the object contents to the provided JSON object.
 
virtual void setFromJsonObject (const ot::ConstJsonObject &_object) override
 Will set the object contents from the provided JSON object.
 
bool operator= (const Rect &_other)
 
bool operator== (const Rect &_other) const
 
bool operator!= (const Rect &_other) const
 
void setTop (int _top)
 
int getTop (void) const
 
void setLeft (int _left)
 
int getLeft (void) const
 
void setTopLeft (const Point2D &_topLeft)
 
const Point2DgetTopLeft (void) const
 
void setBottom (int _bottom)
 
int getBottom (void) const
 
void setRight (int _right)
 
int getRight (void) const
 
void setBottomRight (const Point2D &_bottomRight)
 
const Point2DgetBottomRight (void) const
 
void setWidth (int _width)
 
int getWidth (void) const
 
void setHeight (int _height)
 
int getHeight (void) const
 
void setSize (const Size2D &_size)
 
Size2D getSize (void) const
 
Rect unionWith (const Rect &_other) const
 Calculates and returns the union of this Rect and the provided Rect.
 
Rect intersectsWith (const Rect &_other) const
 Calclates and returns the intersection of this Rect and the provided Rect.
 
bool isAllZero (void) const
 Returns true if top left is (0, 0) and bottom right is (0, 0).
 
bool isValid (void) const
 Returns true if the top left and bottom right points are set correctly. If the left value is bigger than the right value or the bottom value bigger than the top value false is returned.
 
void moveTo (int _ax, int _ay)
 
void moveTo (const Point2D &_topLeft)
 Moves the rect to the specified location. The top left and bottom right will be moved.
 
void moveBy (int _dx, int _dy)
 
void moveBy (const Point2D &_distance)
 Moves the rect by the provided distance. The top left and bottom right will be moved.
 
RectF toRectF (void) const
 
RectD toRectD (void) const
 
- Public Member Functions inherited from ot::Serializable
 Serializable ()
 
virtual ~Serializable ()
 

Detailed Description

Rectangle that holds the top left and bottom right corner in int values.

Rectangle that holds the top left and bottom right corner in float values.

Constructor & Destructor Documentation

◆ Rect() [1/4]

ot::Rect::Rect ( )

◆ Rect() [2/4]

ot::Rect::Rect ( const Point2D & _topLeft,
const Point2D & _bottomRight )

◆ Rect() [3/4]

ot::Rect::Rect ( const Point2D & _topLeft,
const Size2D & _size )

◆ Rect() [4/4]

ot::Rect::Rect ( const Rect & _other)

Member Function Documentation

◆ addToJsonObject()

void ot::Rect::addToJsonObject ( ot::JsonValue & _object,
ot::JsonAllocator & _allocator ) const
overridevirtual

Add the object contents to the provided JSON object.

Parameters
_objectJson object reference
_allocatorAllocator

Implements ot::Serializable.

◆ getBottom()

int ot::Rect::getBottom ( void ) const
inline

◆ getBottomRight()

const Point2D & ot::Rect::getBottomRight ( void ) const
inline

◆ getHeight()

int ot::Rect::getHeight ( void ) const
inline

◆ getLeft()

int ot::Rect::getLeft ( void ) const
inline

◆ getRight()

int ot::Rect::getRight ( void ) const
inline

◆ getSize()

Size2D ot::Rect::getSize ( void ) const
inline

◆ getTop()

int ot::Rect::getTop ( void ) const
inline

◆ getTopLeft()

const Point2D & ot::Rect::getTopLeft ( void ) const
inline

◆ getWidth()

int ot::Rect::getWidth ( void ) const
inline

◆ intersectsWith()

ot::Rect ot::Rect::intersectsWith ( const Rect & _other) const

Calclates and returns the intersection of this Rect and the provided Rect.

◆ isAllZero()

bool ot::Rect::isAllZero ( void ) const
inline

Returns true if top left is (0, 0) and bottom right is (0, 0).

◆ isValid()

bool ot::Rect::isValid ( void ) const
inline

Returns true if the top left and bottom right points are set correctly. If the left value is bigger than the right value or the bottom value bigger than the top value false is returned.

◆ moveBy() [1/2]

void ot::Rect::moveBy ( const Point2D & _distance)

Moves the rect by the provided distance. The top left and bottom right will be moved.

◆ moveBy() [2/2]

void ot::Rect::moveBy ( int _dx,
int _dy )
inline

◆ moveTo() [1/2]

void ot::Rect::moveTo ( const Point2D & _topLeft)

Moves the rect to the specified location. The top left and bottom right will be moved.

◆ moveTo() [2/2]

void ot::Rect::moveTo ( int _ax,
int _ay )
inline

◆ operator!=()

bool ot::Rect::operator!= ( const Rect & _other) const
inline

◆ operator=()

bool ot::Rect::operator= ( const Rect & _other)
inline

◆ operator==()

bool ot::Rect::operator== ( const Rect & _other) const
inline

◆ setBottom()

void ot::Rect::setBottom ( int _bottom)
inline

◆ setBottomRight()

void ot::Rect::setBottomRight ( const Point2D & _bottomRight)
inline

◆ setFromJsonObject()

void ot::Rect::setFromJsonObject ( const ot::ConstJsonObject & _object)
overridevirtual

Will set the object contents from the provided JSON object.

Parameters
_objectThe JSON object containing the information
Exceptions
Willthrow an exception if the provided object is not valid (members missing or invalid types)

Implements ot::Serializable.

◆ setHeight()

void ot::Rect::setHeight ( int _height)
inline

◆ setLeft()

void ot::Rect::setLeft ( int _left)
inline

◆ setRight()

void ot::Rect::setRight ( int _right)
inline

◆ setSize()

void ot::Rect::setSize ( const Size2D & _size)
inline

◆ setTop()

void ot::Rect::setTop ( int _top)
inline

◆ setTopLeft()

void ot::Rect::setTopLeft ( const Point2D & _topLeft)
inline

◆ setWidth()

void ot::Rect::setWidth ( int _width)
inline

◆ toRectD()

ot::RectD ot::Rect::toRectD ( void ) const

◆ toRectF()

ot::RectF ot::Rect::toRectF ( void ) const

◆ unionWith()

ot::Rect ot::Rect::unionWith ( const Rect & _other) const

Calculates and returns the union of this Rect and the provided Rect.


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