Image Component Library (ICL)
Public Member Functions | Static Public Attributes | List of all members
icl::utils::Rect Class Reference

Rectangle class of the ICL used e.g. for the Images ROI-rect. More...

#include <Rect.h>

Inheritance diagram for icl::utils::Rect:
icl::qt::DefineRectanglesMouseHandler::DefinedRect

Public Member Functions

 Rect ()
 default constructor More...
 
 Rect (int x, int y, int width, int height)
 creates a defined Rect More...
 
 Rect (const Point &p, const Size &s)
 creates a new Rect with specified offset and size More...
 
 Rect (const Rect &r)
 create a deep copy of a rect More...
 
 Rect (const Rect32f &other)
 creates a Rect from given Rect32f instance More...
 
bool isNull () const
 checks wether the object instance is null, i.e. all elements are zero More...
 
bool operator== (const Rect &s) const
 checks if two rects are equal More...
 
bool operator!= (const Rect &s) const
 checks if two rects are not equal More...
 
Rect operator * (double d) const
 scales all parameters of the rect by a double value More...
 
Rect operator/ (double d) const
 scales all parameters of the rect by a double value More...
 
Rect operator+ (const Size &s) const
 adds a size to the rects size More...
 
Rect operator- (const Size &s) const
 substracts a size for the rects size More...
 
Rectoperator+= (const Size &s)
 adds a size to the rects size More...
 
Rectoperator-= (const Size &s)
 substracs a size from the rects size More...
 
Rect operator+ (const Point &p) const
 adds a Point to the rects offset More...
 
Rect operator- (const Point &p) const
 substracts a Point from the rects offset More...
 
Rectoperator+= (const Point &p)
 adds a Point to the rects offset More...
 
Rectoperator-= (const Point &p)
 substracts a Point from the rects offset More...
 
Rectoperator *= (double d)
 scales all rect params inplace More...
 
Rectoperator/= (double d)
 scales all rect params inplace More...
 
int getDim () const
 returns width*height More...
 
Rect operator & (const Rect &r) const
 intersection of two Rects More...
 
Rectoperator&= (const Rect &r)
 inplace intersection of two rects More...
 
Rect operator| (const Rect &r) const
 union of two Rects More...
 
Rectoperator|= (const Rect &r)
 inplace union of two rects More...
 
Rect normalized () const
 rects with negative sizes are normalized to Positive sizes More...
 
bool contains (const Rect &r) const
 returns if a Rect containes another rect More...
 
bool contains (int x, int y) const
 returns if the Rect contains a given point (pixel-based) More...
 
Rectenlarge (int k)
 let the rect grow by k pixles into each direction More...
 
Rect enlarged (int k) const
 returns an enlarged instance of this rect More...
 
Point ul () const
 returns upper left point of the rect More...
 
Point ll () const
 returns lower left point of the rect More...
 
Point ur () const
 returns upper right point of the rect More...
 
Point lr () const
 returns lower right point of the rect More...
 
Point center () const
 returns the center Point of the rect More...
 
int left () const
 returns the left border position More...
 
int right () const
 returns the right border position More...
 
int bottom () const
 returns the position of the bottom border More...
 
int top () const
 returns the position of the upper border More...
 
Size getSize () const
 returns the size of the rect More...
 
Rect transform (double xfac, double yfac) const
 

Static Public Attributes

static const Rect null
 null Rect is w=0, h=0, x=0, y=0 More...
 

Detailed Description

Rectangle class of the ICL used e.g. for the Images ROI-rect.

Please take care of the following conventions when using Rects in the ICL library:

                |------ width ------>|
              ............................
              ............................
origin(x,y)---->Xooooooooooooooooooooo....  ___
              ..oooooooooooooooooooooo....  /|\
              ..oooooooooooooooooooooo....   |
              ..oooooooooooooooooooooo.... height
              ..oooooooooooooooooooooo....   |
              ..oooooooooooooooooooooo....  _|_
              ............................
              ............................
    

Please note, that a rect fits a discrete set of points: For instance the Rect (x=2,y=1,width=3,height=4) contains exactly 3x4=12 points i.e. those ones with $x \in {2,3,4}$ and $y \in {1,2,3,4}$. Hence a full image roi of an image of size 640x480 has an offset of (0,0), a size of 640x480, but it contains only x-values within the range 0-639 and y-values within range 0-479.

Constructor & Destructor Documentation

◆ Rect() [1/5]

icl::utils::Rect::Rect ( )
inline

default constructor

◆ Rect() [2/5]

icl::utils::Rect::Rect ( int  x,
int  y,
int  width,
int  height 
)
inline

creates a defined Rect

◆ Rect() [3/5]

icl::utils::Rect::Rect ( const Point p,
const Size s 
)
inline

creates a new Rect with specified offset and size

◆ Rect() [4/5]

icl::utils::Rect::Rect ( const Rect r)
inline

create a deep copy of a rect

◆ Rect() [5/5]

icl::utils::Rect::Rect ( const Rect32f other)

creates a Rect from given Rect32f instance

Member Function Documentation

◆ bottom()

int icl::utils::Rect::bottom ( ) const
inline

returns the position of the bottom border

◆ center()

Point icl::utils::Rect::center ( ) const
inline

returns the center Point of the rect

◆ contains() [1/2]

bool icl::utils::Rect::contains ( const Rect r) const
inline

returns if a Rect containes another rect

◆ contains() [2/2]

bool icl::utils::Rect::contains ( int  x,
int  y 
) const
inline

returns if the Rect contains a given point (pixel-based)

Note: We are talking here in terms of pixel-based rects: The rect x=5,y=5,width=10,height=20 contains the x-indices withing the interval [5,15[ (half-opened interval). In terms of discrete X-values, the intervall meets the set {5,6,...13,14}. The same is true for Y-values.

◆ enlarge()

Rect& icl::utils::Rect::enlarge ( int  k)
inline

let the rect grow by k pixles into each direction

if k<0 the rect becomes smaller E.g. Rect(10,10,90,90).enlarge(10) creates a Rect (0,0,100,100)

Parameters
kamount of pixel the rectangle is enlarged by
Returns
*this

◆ enlarged()

Rect icl::utils::Rect::enlarged ( int  k) const
inline

returns an enlarged instance of this rect

See also
enlarge(int)

◆ getDim()

int icl::utils::Rect::getDim ( ) const
inline

returns width*height

◆ getSize()

Size icl::utils::Rect::getSize ( ) const
inline

returns the size of the rect

◆ isNull()

bool icl::utils::Rect::isNull ( ) const
inline

checks wether the object instance is null, i.e. all elements are zero

◆ left()

int icl::utils::Rect::left ( ) const
inline

returns the left border position

◆ ll()

Point icl::utils::Rect::ll ( ) const
inline

returns lower left point of the rect

◆ lr()

Point icl::utils::Rect::lr ( ) const
inline

returns lower right point of the rect

◆ normalized()

Rect icl::utils::Rect::normalized ( ) const
inline

rects with negative sizes are normalized to Positive sizes

e.g. the rect (5,5,-5,-5) is normalized to (0,0,5,5)

◆ operator &()

Rect icl::utils::Rect::operator & ( const Rect r) const
inline

intersection of two Rects

◆ operator *()

Rect icl::utils::Rect::operator * ( double  d) const
inline

scales all parameters of the rect by a double value

◆ operator *=()

Rect& icl::utils::Rect::operator *= ( double  d)
inline

scales all rect params inplace

◆ operator!=()

bool icl::utils::Rect::operator!= ( const Rect s) const
inline

checks if two rects are not equal

◆ operator&=()

Rect& icl::utils::Rect::operator&= ( const Rect r)
inline

inplace intersection of two rects

◆ operator+() [1/2]

Rect icl::utils::Rect::operator+ ( const Size s) const
inline

adds a size to the rects size

◆ operator+() [2/2]

Rect icl::utils::Rect::operator+ ( const Point p) const
inline

adds a Point to the rects offset

◆ operator+=() [1/2]

Rect& icl::utils::Rect::operator+= ( const Size s)
inline

adds a size to the rects size

◆ operator+=() [2/2]

Rect& icl::utils::Rect::operator+= ( const Point p)
inline

adds a Point to the rects offset

◆ operator-() [1/2]

Rect icl::utils::Rect::operator- ( const Size s) const
inline

substracts a size for the rects size

◆ operator-() [2/2]

Rect icl::utils::Rect::operator- ( const Point p) const
inline

substracts a Point from the rects offset

◆ operator-=() [1/2]

Rect& icl::utils::Rect::operator-= ( const Size s)
inline

substracs a size from the rects size

◆ operator-=() [2/2]

Rect& icl::utils::Rect::operator-= ( const Point p)
inline

substracts a Point from the rects offset

◆ operator/()

Rect icl::utils::Rect::operator/ ( double  d) const
inline

scales all parameters of the rect by a double value

◆ operator/=()

Rect& icl::utils::Rect::operator/= ( double  d)
inline

scales all rect params inplace

◆ operator==()

bool icl::utils::Rect::operator== ( const Rect s) const
inline

checks if two rects are equal

◆ operator|()

Rect icl::utils::Rect::operator| ( const Rect r) const
inline

union of two Rects

◆ operator|=()

Rect& icl::utils::Rect::operator|= ( const Rect r)
inline

inplace union of two rects

◆ right()

int icl::utils::Rect::right ( ) const
inline

returns the right border position

◆ top()

int icl::utils::Rect::top ( ) const
inline

returns the position of the upper border

◆ transform()

Rect icl::utils::Rect::transform ( double  xfac,
double  yfac 
) const
inline

◆ ul()

Point icl::utils::Rect::ul ( ) const
inline

returns upper left point of the rect

◆ ur()

Point icl::utils::Rect::ur ( ) const
inline

returns upper right point of the rect

Member Data Documentation

◆ null

const Rect icl::utils::Rect::null
static

null Rect is w=0, h=0, x=0, y=0


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