Maintains a set of rectangles as a complex region. More...
Classes | |
| class | Iterator |
| An iterator for accessing all the rectangles in a RectangleList. More... | |
Public Member Functions | |
| RectangleList () noexcept | |
| Creates an empty RectangleList. | |
| RectangleList (const RectangleList &other) | |
| Creates a copy of another list. | |
| RectangleList (const Rectangle< int > &rect) | |
| Creates a list containing just one rectangle. | |
| RectangleList & | operator= (const RectangleList &other) |
| Copies this list from another one. | |
| ~RectangleList () | |
| Destructor. | |
| bool | isEmpty () const noexcept |
| Returns true if the region is empty. | |
| int | getNumRectangles () const noexcept |
| Returns the number of rectangles in the list. | |
| Rectangle< int > | 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 (int x, int y, int width, int height) |
| Merges a new rectangle into the list. | |
| void | add (const Rectangle< int > &rect) |
| Merges a new rectangle into the list. | |
| void | addWithoutMerging (const Rectangle< int > &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 Rectangle< int > &rect) |
| Removes a rectangular region from the list. | |
| bool | subtract (const RectangleList &otherList) |
| Removes all areas in another RectangleList from this one. | |
| bool | clipTo (const Rectangle< int > &rect) |
| Removes any areas of the region that lie outside a given rectangle. | |
| bool | clipTo (const RectangleList &other) |
| Removes any areas of the region that lie outside a given rectangle list. | |
| bool | getIntersectionWith (const Rectangle< int > &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 (int x, int y) const noexcept |
| Checks whether the region contains a given point. | |
| bool | containsRectangle (const Rectangle< int > &rectangleToCheck) const |
| Checks whether the region contains the whole of a given rectangle. | |
| bool | intersectsRectangle (const Rectangle< int > &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. | |
| Rectangle< int > | 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 (int dx, int dy) noexcept |
| Adds an x and y value to all the co-ordinates. | |
| Path | toPath () const |
| Creates a Path object to represent this region. | |
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.
| RectangleList::RectangleList | ( | ) |
Creates an empty RectangleList.
| RectangleList::RectangleList | ( | const RectangleList & | other ) |
Creates a copy of another list.
| RectangleList::RectangleList | ( | const Rectangle< int > & | rect ) |
Creates a list containing just one rectangle.
| RectangleList::~RectangleList | ( | ) |
Destructor.
| RectangleList& RectangleList::operator= | ( | const RectangleList & | other ) |
Copies this list from another one.
| bool RectangleList::isEmpty | ( | ) | const |
Returns true if the region is empty.
| int RectangleList::getNumRectangles | ( | ) | const |
Returns the number of rectangles in the list.
| Rectangle<int> RectangleList::getRectangle | ( | int | index ) | const |
Returns one of the rectangles at a particular index.
| void RectangleList::clear | ( | ) |
Removes all rectangles to leave an empty region.
| void RectangleList::add | ( | int | x, |
| int | y, | ||
| int | width, | ||
| int | height | ||
| ) |
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.
| void RectangleList::add | ( | const Rectangle< int > & | rect ) |
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.
| void RectangleList::addWithoutMerging | ( | const Rectangle< int > & | rect ) |
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.
| void RectangleList::add | ( | const RectangleList & | other ) |
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.
| void RectangleList::subtract | ( | const Rectangle< int > & | rect ) |
Removes a rectangular region from the list.
Any rectangles in the list which overlap this will be clipped and subdivided if necessary.
| bool RectangleList::subtract | ( | const RectangleList & | otherList ) |
Removes all areas in another RectangleList from this one.
Any rectangles in the list which overlap this will be clipped and subdivided if necessary.
| bool RectangleList::clipTo | ( | const Rectangle< int > & | rect ) |
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.
| bool RectangleList::clipTo | ( | const RectangleList & | other ) |
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.
| bool RectangleList::getIntersectionWith | ( | const Rectangle< int > & | rect, |
| RectangleList & | destRegion | ||
| ) | const |
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.
| void RectangleList::swapWith | ( | RectangleList & | otherList ) |
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.
| bool RectangleList::containsPoint | ( | int | x, |
| int | y | ||
| ) | const |
Checks whether the region contains a given point.
| bool RectangleList::containsRectangle | ( | const Rectangle< int > & | rectangleToCheck ) | const |
Checks whether the region contains the whole of a given rectangle.
| bool RectangleList::intersectsRectangle | ( | const Rectangle< int > & | rectangleToCheck ) | const |
Checks whether the region contains any part of a given rectangle.
| bool RectangleList::intersects | ( | const RectangleList & | other ) | const |
Checks whether this region intersects any part of another one.
| Rectangle<int> RectangleList::getBounds | ( | ) | const |
Returns the smallest rectangle that can enclose the whole of this region.
| void RectangleList::consolidate | ( | ) |
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.
| void RectangleList::offsetAll | ( | int | dx, |
| int | dy | ||
| ) |
Adds an x and y value to all the co-ordinates.