JUCE  v5.1.1-3-g1a0b28c73
JUCE API
RectangleList< ValueType > Class Template Reference

Maintains a set of rectangles as a complex region. More...

#include <juce_RectangleList.h>

Inheritance diagram for RectangleList< ValueType >:
Collaboration diagram for RectangleList< ValueType >:

Public Types

typedef Rectangle< ValueType > RectangleType
 

Public Member Functions

 RectangleList () noexcept
 Creates an empty RectangleList. More...
 
 RectangleList (const RectangleList &other)
 Creates a copy of another list. More...
 
 RectangleList (const RectangleType &rect)
 Creates a list containing just one rectangle. More...
 
 RectangleList (RectangleList &&other) noexcept
 Move constructor. More...
 
void add (const RectangleType &rect)
 Merges a new rectangle into the list. More...
 
void add (ValueType x, ValueType y, ValueType width, ValueType height)
 Merges a new rectangle into the list. More...
 
void add (const RectangleList &other)
 Merges another rectangle list into this one. More...
 
void addWithoutMerging (const RectangleType &rect)
 Dumbly adds a rectangle to the list without checking for overlaps. More...
 
const RectangleTypebegin () const noexcept
 Standard method for iterating the rectangles in the list. More...
 
void clear ()
 Removes all rectangles to leave an empty region. More...
 
bool clipTo (const RectangleType &rect)
 Removes any areas of the region that lie outside a given rectangle. More...
 
template<typename OtherValueType >
bool clipTo (const RectangleList< OtherValueType > &other)
 Removes any areas of the region that lie outside a given rectangle list. More...
 
void consolidate ()
 Optimises the list into a minimum number of constituent rectangles. More...
 
bool containsPoint (Point< ValueType > point) const noexcept
 Checks whether the region contains a given point. More...
 
bool containsPoint (ValueType x, ValueType y) const noexcept
 Checks whether the region contains a given point. More...
 
bool containsRectangle (const RectangleType &rectangleToCheck) const
 Checks whether the region contains the whole of a given rectangle. More...
 
const RectangleTypeend () const noexcept
 Standard method for iterating the rectangles in the list. More...
 
void ensureStorageAllocated (int minNumRectangles)
 Increases the internal storage to hold a minimum number of rectangles. More...
 
RectangleType getBounds () const noexcept
 Returns the smallest rectangle that can enclose the whole of this region. More...
 
bool getIntersectionWith (const RectangleType &rect, RectangleList &destRegion) const
 Creates a region which is the result of clipping this one to a given rectangle. More...
 
int getNumRectangles () const noexcept
 Returns the number of rectangles in the list. More...
 
RectangleType getRectangle (int index) const noexcept
 Returns one of the rectangles at a particular index. More...
 
bool intersects (const RectangleList &other) const noexcept
 Checks whether this region intersects any part of another one. More...
 
bool intersectsRectangle (const RectangleType &rectangleToCheck) const noexcept
 Checks whether the region contains any part of a given rectangle. More...
 
bool isEmpty () const noexcept
 Returns true if the region is empty. More...
 
void offsetAll (Point< ValueType > offset) noexcept
 Adds an x and y value to all the coordinates. More...
 
void offsetAll (ValueType dx, ValueType dy) noexcept
 Adds an x and y value to all the coordinates. More...
 
RectangleListoperator= (const RectangleList &other)
 Copies this list from another one. More...
 
RectangleListoperator= (RectangleList &&other) noexcept
 Move assignment operator. More...
 
template<typename ScaleType >
void scaleAll (ScaleType scaleFactor) noexcept
 Scales all the coordinates. More...
 
void subtract (const RectangleType &rect)
 Removes a rectangular region from the list. More...
 
bool subtract (const RectangleList &otherList)
 Removes all areas in another RectangleList from this one. More...
 
void swapWith (RectangleList &otherList) noexcept
 Swaps the contents of this and another list. More...
 
Path toPath () const
 Creates a Path object to represent this region. More...
 
void transformAll (const AffineTransform &transform) noexcept
 Applies a transform to all the rectangles. More...
 

Private Attributes

Array< RectangleTyperects
 

Detailed Description

template<typename ValueType>
class RectangleList< ValueType >

Maintains a set of rectangles as a complex region.

This class allows a set of rectangles to be treated as a solid shape, and can add and remove rectangular sections of it, and simplify overlapping or adjacent rectangles.

See also
Rectangle

Member Typedef Documentation

◆ RectangleType

template<typename ValueType>
typedef Rectangle<ValueType> RectangleList< ValueType >::RectangleType

Constructor & Destructor Documentation

◆ RectangleList() [1/4]

template<typename ValueType>
RectangleList< ValueType >::RectangleList ( )
inlinenoexcept

Creates an empty RectangleList.

◆ RectangleList() [2/4]

template<typename ValueType>
RectangleList< ValueType >::RectangleList ( const RectangleList< ValueType > &  other)
inline

Creates a copy of another list.

◆ RectangleList() [3/4]

template<typename ValueType>
RectangleList< ValueType >::RectangleList ( const RectangleType rect)
inline

Creates a list containing just one rectangle.

◆ RectangleList() [4/4]

template<typename ValueType>
RectangleList< ValueType >::RectangleList ( RectangleList< ValueType > &&  other)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ add() [1/3]

template<typename ValueType>
void RectangleList< ValueType >::add ( const RectangleType rect)
inline

Merges a new rectangle into the list.

The rectangle being added will first be clipped to remove any parts of it that overlap existing rectangles in the list, and adjacent rectangles will be merged into it.

The rectangle can have any size and may be empty, but if it's floating point then it's expected to not contain any INF values.

Referenced by RectangleList< int >::add(), and RenderingHelpers::SavedStateBase< SoftwareRendererSavedState >::clipToRectangleList().

◆ add() [2/3]

template<typename ValueType>
void RectangleList< ValueType >::add ( ValueType  x,
ValueType  y,
ValueType  width,
ValueType  height 
)
inline

Merges a new rectangle into the list.

The rectangle being added will first be clipped to remove any parts of it that overlap existing rectangles in the list.

◆ add() [3/3]

template<typename ValueType>
void RectangleList< ValueType >::add ( const RectangleList< ValueType > &  other)
inline

Merges another rectangle list into this one.

Any overlaps between the two lists will be clipped, so that the result is the union of both lists.

◆ addWithoutMerging()

template<typename ValueType>
void RectangleList< ValueType >::addWithoutMerging ( const RectangleType rect)
inline

Dumbly adds a rectangle to the list without checking for overlaps.

This simply adds the rectangle to the end, it doesn't merge it or remove any overlapping bits.

The rectangle can have any size and may be empty, but if it's floating point then it's expected to not contain any INF values.

Referenced by RectangleList< int >::RectangleList().

◆ begin()

template<typename ValueType>
const RectangleType* RectangleList< ValueType >::begin ( ) const
inlinenoexcept

Standard method for iterating the rectangles in the list.

◆ clear()

template<typename ValueType>
void RectangleList< ValueType >::clear ( )
inline

Removes all rectangles to leave an empty region.

Referenced by RectangleList< int >::clipTo(), and RectangleList< int >::getIntersectionWith().

◆ clipTo() [1/2]

template<typename ValueType>
bool RectangleList< ValueType >::clipTo ( const RectangleType rect)
inline

Removes any areas of the region that lie outside a given rectangle.

Any rectangles in the list which overlap this will be clipped and subdivided if necessary.

Returns true if the resulting region is not empty, false if it is empty.

See also
getIntersectionWith

◆ clipTo() [2/2]

template<typename ValueType>
template<typename OtherValueType >
bool RectangleList< ValueType >::clipTo ( const RectangleList< OtherValueType > &  other)
inline

Removes any areas of the region that lie outside a given rectangle list.

Any rectangles in this object which overlap the specified list will be clipped and subdivided if necessary.

Returns true if the resulting region is not empty, false if it is empty.

See also
getIntersectionWith

◆ consolidate()

template<typename ValueType>
void RectangleList< ValueType >::consolidate ( )
inline

Optimises the list into a minimum number of constituent rectangles.

This will try to combine any adjacent rectangles into larger ones where possible, to simplify lists that might have been fragmented by repeated add/subtract calls.

◆ containsPoint() [1/2]

template<typename ValueType>
bool RectangleList< ValueType >::containsPoint ( Point< ValueType >  point) const
inlinenoexcept

Checks whether the region contains a given point.

Returns
true if the point lies within one of the rectangles in the list

Referenced by RectangleList< int >::containsPoint().

◆ containsPoint() [2/2]

template<typename ValueType>
bool RectangleList< ValueType >::containsPoint ( ValueType  x,
ValueType  y 
) const
inlinenoexcept

Checks whether the region contains a given point.

Returns
true if the point lies within one of the rectangles in the list

◆ containsRectangle()

template<typename ValueType>
bool RectangleList< ValueType >::containsRectangle ( const RectangleType rectangleToCheck) const
inline

Checks whether the region contains the whole of a given rectangle.

Returns
true all parts of the rectangle passed in lie within the region defined by this object
See also
intersectsRectangle, containsPoint

◆ end()

template<typename ValueType>
const RectangleType* RectangleList< ValueType >::end ( ) const
inlinenoexcept

Standard method for iterating the rectangles in the list.

◆ ensureStorageAllocated()

template<typename ValueType>
void RectangleList< ValueType >::ensureStorageAllocated ( int  minNumRectangles)
inline

Increases the internal storage to hold a minimum number of rectangles.

Calling this before adding a large number of rectangles means that the array won't have to keep dynamically resizing itself as the elements are added, and it'll therefore be more efficient.

See also
Array::ensureStorageAllocated

◆ getBounds()

template<typename ValueType>
RectangleType RectangleList< ValueType >::getBounds ( ) const
inlinenoexcept

Returns the smallest rectangle that can enclose the whole of this region.

◆ getIntersectionWith()

template<typename ValueType>
bool RectangleList< ValueType >::getIntersectionWith ( const RectangleType rect,
RectangleList< ValueType > &  destRegion 
) const
inline

Creates a region which is the result of clipping this one to a given rectangle.

Unlike the other clipTo method, this one doesn't affect this object - it puts the resulting region into the list whose reference is passed-in.

Returns true if the resulting region is not empty, false if it is empty.

See also
clipTo

◆ getNumRectangles()

template<typename ValueType>
int RectangleList< ValueType >::getNumRectangles ( ) const
inlinenoexcept

Returns the number of rectangles in the list.

◆ getRectangle()

template<typename ValueType>
RectangleType RectangleList< ValueType >::getRectangle ( int  index) const
inlinenoexcept

Returns one of the rectangles at a particular index.

Returns
the rectangle at the index, or an empty rectangle if the index is out-of-range.

◆ intersects()

template<typename ValueType>
bool RectangleList< ValueType >::intersects ( const RectangleList< ValueType > &  other) const
inlinenoexcept

Checks whether this region intersects any part of another one.

See also
intersectsRectangle

◆ intersectsRectangle()

template<typename ValueType>
bool RectangleList< ValueType >::intersectsRectangle ( const RectangleType rectangleToCheck) const
inlinenoexcept

Checks whether the region contains any part of a given rectangle.

Returns
true if any part of the rectangle passed in lies within the region defined by this object
See also
containsRectangle

◆ isEmpty()

◆ offsetAll() [1/2]

template<typename ValueType>
void RectangleList< ValueType >::offsetAll ( Point< ValueType >  offset)
inlinenoexcept

◆ offsetAll() [2/2]

template<typename ValueType>
void RectangleList< ValueType >::offsetAll ( ValueType  dx,
ValueType  dy 
)
inlinenoexcept

Adds an x and y value to all the coordinates.

◆ operator=() [1/2]

template<typename ValueType>
RectangleList& RectangleList< ValueType >::operator= ( const RectangleList< ValueType > &  other)
inline

Copies this list from another one.

◆ operator=() [2/2]

template<typename ValueType>
RectangleList& RectangleList< ValueType >::operator= ( RectangleList< ValueType > &&  other)
inlinenoexcept

Move assignment operator.

◆ scaleAll()

template<typename ValueType>
template<typename ScaleType >
void RectangleList< ValueType >::scaleAll ( ScaleType  scaleFactor)
inlinenoexcept

Scales all the coordinates.

◆ subtract() [1/2]

template<typename ValueType>
void RectangleList< ValueType >::subtract ( const RectangleType rect)
inline

Removes a rectangular region from the list.

Any rectangles in the list which overlap this will be clipped and subdivided if necessary.

Referenced by RectangleList< int >::add(), RectangleList< int >::containsRectangle(), CameraDevice::Pimpl::drawCurrentImage(), and RectangleList< int >::subtract().

◆ subtract() [2/2]

template<typename ValueType>
bool RectangleList< ValueType >::subtract ( const RectangleList< ValueType > &  otherList)
inline

Removes all areas in another RectangleList from this one.

Any rectangles in the list which overlap this will be clipped and subdivided if necessary.

Returns
true if the resulting list is non-empty.

◆ swapWith()

template<typename ValueType>
void RectangleList< ValueType >::swapWith ( RectangleList< ValueType > &  otherList)
inlinenoexcept

Swaps the contents of this and another list.

This swaps their internal pointers, so is hugely faster than using copy-by-value to swap them.

Referenced by RectangleList< int >::clipTo().

◆ toPath()

template<typename ValueType>
Path RectangleList< ValueType >::toPath ( ) const
inline

◆ transformAll()

template<typename ValueType>
void RectangleList< ValueType >::transformAll ( const AffineTransform transform)
inlinenoexcept

Applies a transform to all the rectangles.

Obviously this will create a mess if the transform involves any rotation or skewing.

Referenced by RenderingHelpers::SavedStateBase< SoftwareRendererSavedState >::fillRectList().

Member Data Documentation

◆ rects


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