Loading...
Searching...
No Matches
juce::RectangleList< ValueType > Class Template Referencefinal

## Detailed Description

template<typename ValueType>
class juce::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

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

- juce_graphics/geometry/juce_RectangleList.h

## Public Types

using | RectangleType = Rectangle<ValueType>

## Public Member Functions

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

## Member Typedef Documentation

## RectangleType

template<typename ValueType>

using juce::RectangleList< ValueType >::RectangleType = Rectangle<ValueType>

## Constructors and Destructors

## RectangleList() [1/4]

template<typename ValueType>

juce::RectangleList< ValueType >::RectangleList | ( |  | ) |

default

Creates an empty RectangleList.

Referenced by add(), add(), clipTo(), containsRectangle(), getIntersectionWith(), intersects(), operator=(), operator=(), RectangleList(), RectangleList(), subtract(), and swapWith().

## RectangleList() [2/4]

template<typename ValueType>

juce::RectangleList< ValueType >::RectangleList | ( | const RectangleList< ValueType > & | other | ) |

inline

Creates a copy of another list.

References RectangleList().

## RectangleList() [3/4]

template<typename ValueType>

juce::RectangleList< ValueType >::RectangleList | ( | RectangleType | rect | ) |

inline

Creates a list containing just one rectangle.

References addWithoutMerging().

## RectangleList() [4/4]

template<typename ValueType>

juce::RectangleList< ValueType >::RectangleList | ( | RectangleList< ValueType > && | other | ) |

inline noexcept

Move constructor.

References RectangleList().

## Member Functions

## operator=() [1/2]

template<typename ValueType>

RectangleList & juce::RectangleList< ValueType >::operator= | ( | const RectangleList< ValueType > & | other | ) |

inline

Copies this list from another one.

References RectangleList().

## operator=() [2/2]

template<typename ValueType>

RectangleList & juce::RectangleList< ValueType >::operator= | ( | RectangleList< ValueType > && | other | ) |

inline noexcept

Move assignment operator.

References RectangleList().

## isEmpty()

template<typename ValueType>

bool juce::RectangleList< ValueType >::isEmpty | ( |  | ) | const

inline noexcept

Returns true if the region is empty.

Referenced by add(), clipTo(), containsRectangle(), getBounds(), getIntersectionWith(), and subtract().

## getNumRectangles()

template<typename ValueType>

int juce::RectangleList< ValueType >::getNumRectangles | ( |  | ) | const

inline noexcept

Returns the number of rectangles in the list.

## getRectangle()

template<typename ValueType>

RectangleType juce::RectangleList< ValueType >::getRectangle | ( | int | index | ) | const

inline noexcept

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.

## clear()

template<typename ValueType>

void juce::RectangleList< ValueType >::clear | ( |  | ) |

inline

Removes all rectangles to leave an empty region.

Referenced by clipTo(), and getIntersectionWith().

## add() [1/3]

template<typename ValueType>

void juce::RectangleList< ValueType >::add | ( | 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.

References juce::Rectangle< ValueType >::contains(), juce::Rectangle< ValueType >::intersects(), juce::Rectangle< ValueType >::isEmpty(), isEmpty(), juce::Rectangle< ValueType >::isFinite(), jassert, RectangleList(), and subtract().

Referenced by add(), and add().

## add() [2/3]

template<typename ValueType>

void juce::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.

References add(), x, and y.

## addWithoutMerging()

template<typename ValueType>

void juce::RectangleList< ValueType >::addWithoutMerging | ( | 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.

References juce::Rectangle< ValueType >::isEmpty(), juce::Rectangle< ValueType >::isFinite(), and jassert.

Referenced by juce::LowLevelGraphicsContext::drawRect(), and RectangleList().

## add() [3/3]

template<typename ValueType>

void juce::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.

References add(), and RectangleList().

## subtract() [1/2]

template<typename ValueType>

void juce::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.

References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::begin(), juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::end(), juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::resize(), juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::size(), and subtract().

Referenced by add(), containsRectangle(), subtract(), and subtract().

## subtract() [2/2]

template<typename ValueType>

bool juce::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.

References isEmpty(), RectangleList(), and subtract().

## clipTo() [1/2]

template<typename ValueType>

bool juce::RectangleList< ValueType >::clipTo | ( | 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

References clear(), juce::Rectangle< ValueType >::intersectRectangle(), juce::Rectangle< ValueType >::isEmpty(), juce::Rectangle< ValueType >::isFinite(), and jassert.

## clipTo() [2/2]

template<typename ValueType>
template<typename OtherValueType>

bool juce::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

References isEmpty(), RectangleList(), and swapWith().

## getIntersectionWith()

template<typename ValueType>

bool juce::RectangleList< ValueType >::getIntersectionWith | ( | 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

References clear(), juce::Rectangle< ValueType >::intersectRectangle(), juce::Rectangle< ValueType >::isEmpty(), isEmpty(), juce::Rectangle< ValueType >::isFinite(), jassert, and RectangleList().

## swapWith()

template<typename ValueType>

void juce::RectangleList< ValueType >::swapWith | ( | RectangleList< ValueType > & | otherList | ) |

inline noexcept

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.

References RectangleList().

Referenced by clipTo().

## containsPoint() [1/2]

template<typename ValueType>

bool juce::RectangleList< ValueType >::containsPoint | ( | Point< ValueType > | point | ) | const

inline noexcept

Checks whether the region contains a given point.

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

Referenced by containsPoint().

## containsPoint() [2/2]

template<typename ValueType>

bool juce::RectangleList< ValueType >::containsPoint | ( | ValueType | x,
|  | ValueType | y ) const

inline noexcept

Checks whether the region contains a given point.

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

References containsPoint(), x, and y.

## containsRectangle()

template<typename ValueType>

bool juce::RectangleList< ValueType >::containsRectangle | ( | 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

References isEmpty(), RectangleList(), and subtract().

## intersectsRectangle()

template<typename ValueType>

bool juce::RectangleList< ValueType >::intersectsRectangle | ( | RectangleType | rectangleToCheck | ) | const

inline noexcept

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

## intersects()

template<typename ValueType>

bool juce::RectangleList< ValueType >::intersects | ( | const RectangleList< ValueType > & | other | ) | const

inline noexcept

Checks whether this region intersects any part of another one.

See also
  intersectsRectangle

References RectangleList().

## getBounds()

template<typename ValueType>

RectangleType juce::RectangleList< ValueType >::getBounds | ( |  | ) | const

inline noexcept

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

References juce::Rectangle< ValueType >::getX(), isEmpty(), juce::jmax(), and juce::jmin().

## consolidate()

template<typename ValueType>

void juce::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.

## offsetAll() [1/2]

template<typename ValueType>

void juce::RectangleList< ValueType >::offsetAll | ( | Point< ValueType > | offset | ) |

inline noexcept

Adds an x and y value to all the coordinates.

Referenced by offsetAll().

## offsetAll() [2/2]

template<typename ValueType>

void juce::RectangleList< ValueType >::offsetAll | ( | ValueType | dx,
|  | ValueType | dy )

inline noexcept

Adds an x and y value to all the coordinates.

References offsetAll().

## scaleAll()

template<typename ValueType>
template<typename ScaleType>

void juce::RectangleList< ValueType >::scaleAll | ( | ScaleType | scaleFactor | ) |

inline noexcept

Scales all the coordinates.

## transformAll()

template<typename ValueType>

void juce::RectangleList< ValueType >::transformAll | ( | const AffineTransform & | transform | ) |

inline noexcept

Applies a transform to all the rectangles.

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

## toPath()

template<typename ValueType>

Path juce::RectangleList< ValueType >::toPath | ( |  | ) | const

inline

Creates a Path object to represent this region.

References juce::Path::addRectangle().

## begin()

template<typename ValueType>

const RectangleType * juce::RectangleList< ValueType >::begin | ( |  | ) | const

inline noexcept

Standard method for iterating the rectangles in the list.

## end()

template<typename ValueType>

const RectangleType * juce::RectangleList< ValueType >::end | ( |  | ) | const

inline noexcept

Standard method for iterating the rectangles in the list.

## ensureStorageAllocated()

template<typename ValueType>

void juce::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

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited