Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::GenericOptRect< C > Class Template Reference

Axis-aligned generic rectangle that can be empty. More...

#include <generic-rect.h>

Inheritance diagram for Geom::GenericOptRect< C >:

Public Types

using D1Value = CInterval
 
using D1Reference = CInterval &
 
using D1ConstReference = CInterval const &
 

Public Member Functions

area () const
 Compute the rectangle's area.
 
bool hasZeroArea () const
 Check whether the rectangle has zero area.
 
OptCRect regularized () const
 Returns an empty optional (testing false) if the rectangle has zero area.
 
Check other rectangles and points for inclusion.
bool empty () const
 Check for emptiness.
 
bool intersects (CRect const &r) const
 Check whether the rectangles have any common points.
 
bool contains (CRect const &r) const
 Check whether the rectangle includes all points in the given rectangle.
 
bool intersects (OptCRect const &r) const
 Check whether the rectangles have any common points.
 
bool contains (OptCRect const &r) const
 Check whether the rectangle includes all points in the given rectangle.
 
bool contains (CPoint const &p) const
 Check whether the given point is within the rectangle.
 
Modify the potentially empty rectangle.
void unionWith (CRect const &b)
 Enlarge the rectangle to contain the argument.
 
void unionWith (OptCRect const &b)
 Enlarge the rectangle to contain the argument.
 
void intersectWith (CRect const &b)
 Leave only the area overlapping with the argument.
 
void intersectWith (OptCRect const &b)
 Leave only the area overlapping with the argument.
 
void expandTo (CPoint const &p)
 Create or enlarge the rectangle to contain the given point.
 
Operators
GenericOptRect< C > & operator|= (OptCRect const &b)
 Union with b.
 
GenericOptRect< C > & operator&= (CRect const &b)
 Intersect with b.
 
GenericOptRect< C > & operator&= (OptCRect const &b)
 Intersect with b.
 
bool operator== (OptCRect const &other) const
 Test for equality.
 
bool operator== (CRect const &other) const
 

Private Types

using CInterval = typename CoordTraits< C >::IntervalType
 
using OptCInterval = typename CoordTraits< C >::OptIntervalType
 
using CPoint = typename CoordTraits< C >::PointType
 
using CRect = typename CoordTraits< C >::RectType
 
using OptCRect = typename CoordTraits< C >::OptRectType
 
using Base = std::optional< CRect >
 

Create potentially empty rectangles.

 GenericOptRect ()=default
 
 GenericOptRect (GenericRect< C > const &a)
 
 GenericOptRect (CPoint const &a, CPoint const &b)
 
 GenericOptRect (C x0, C y0, C x1, C y1)
 
 GenericOptRect (OptCInterval const &x_int, OptCInterval const &y_int)
 Creates an empty OptRect when one of the argument intervals is empty.
 
template<typename InputIterator >
static OptCRect from_range (InputIterator start, InputIterator end)
 Create a rectangle from a range of points.
 

Detailed Description

template<typename C>
class Geom::GenericOptRect< C >

Axis-aligned generic rectangle that can be empty.

Definition at line 346 of file generic-rect.h.

Member Typedef Documentation

◆ Base

template<typename C >
using Geom::GenericOptRect< C >::Base = std::optional<CRect>
private

Definition at line 360 of file generic-rect.h.

◆ CInterval

template<typename C >
using Geom::GenericOptRect< C >::CInterval = typename CoordTraits<C>::IntervalType
private

Definition at line 355 of file generic-rect.h.

◆ CPoint

template<typename C >
using Geom::GenericOptRect< C >::CPoint = typename CoordTraits<C>::PointType
private

Definition at line 357 of file generic-rect.h.

◆ CRect

template<typename C >
using Geom::GenericOptRect< C >::CRect = typename CoordTraits<C>::RectType
private

Definition at line 358 of file generic-rect.h.

◆ D1ConstReference

template<typename C >
using Geom::GenericOptRect< C >::D1ConstReference = CInterval const &

Definition at line 364 of file generic-rect.h.

◆ D1Reference

template<typename C >
using Geom::GenericOptRect< C >::D1Reference = CInterval &

Definition at line 363 of file generic-rect.h.

◆ D1Value

template<typename C >
using Geom::GenericOptRect< C >::D1Value = CInterval

Definition at line 362 of file generic-rect.h.

◆ OptCInterval

template<typename C >
using Geom::GenericOptRect< C >::OptCInterval = typename CoordTraits<C>::OptIntervalType
private

Definition at line 356 of file generic-rect.h.

◆ OptCRect

template<typename C >
using Geom::GenericOptRect< C >::OptCRect = typename CoordTraits<C>::OptRectType
private

Definition at line 359 of file generic-rect.h.

Constructor & Destructor Documentation

◆ GenericOptRect() [1/5]

template<typename C >
Geom::GenericOptRect< C >::GenericOptRect ( )
default

◆ GenericOptRect() [2/5]

template<typename C >
Geom::GenericOptRect< C >::GenericOptRect ( GenericRect< C > const &  a)
inline

Definition at line 369 of file generic-rect.h.

◆ GenericOptRect() [3/5]

template<typename C >
Geom::GenericOptRect< C >::GenericOptRect ( CPoint const &  a,
CPoint const &  b 
)
inline

Definition at line 370 of file generic-rect.h.

◆ GenericOptRect() [4/5]

template<typename C >
Geom::GenericOptRect< C >::GenericOptRect ( x0,
y0,
x1,
y1 
)
inline

Definition at line 371 of file generic-rect.h.

◆ GenericOptRect() [5/5]

template<typename C >
Geom::GenericOptRect< C >::GenericOptRect ( OptCInterval const &  x_int,
OptCInterval const &  y_int 
)
inline

Creates an empty OptRect when one of the argument intervals is empty.

Definition at line 373 of file generic-rect.h.

Member Function Documentation

◆ area()

template<typename C >
C Geom::GenericOptRect< C >::area ( ) const
inline

◆ contains() [1/3]

template<typename C >
bool Geom::GenericOptRect< C >::contains ( CPoint const &  p) const
inline

Check whether the given point is within the rectangle.

An empty rectangle will not contain any points.

Definition at line 420 of file generic-rect.h.

◆ contains() [2/3]

template<typename C >
bool Geom::GenericOptRect< C >::contains ( CRect const &  r) const
inline

Check whether the rectangle includes all points in the given rectangle.

Empty rectangles will be contained in any non-empty rectangle.

Definition at line 407 of file generic-rect.h.

Referenced by Inkscape::UI::Tools::TextTool::_updateCursor(), pathv_fully_contains(), scroll_to_show_item(), sp_item_group_ungroup(), and Inkscape::UI::Tools::sp_tweak_dilate_recursive().

◆ contains() [3/3]

template<typename C >
bool Geom::GenericOptRect< C >::contains ( OptCRect const &  r) const
inline

Check whether the rectangle includes all points in the given rectangle.

Empty rectangles will be contained in any non-empty rectangle. An empty rectangle will not contain other empty rectangles.

Definition at line 416 of file generic-rect.h.

◆ empty()

template<typename C >
bool Geom::GenericOptRect< C >::empty ( ) const
inline

◆ expandTo()

template<typename C >
void Geom::GenericOptRect< C >::expandTo ( CPoint const &  p)
inline

Create or enlarge the rectangle to contain the given point.

If the rectangle is empty, after calling this method it will be non-empty and it will contain only the given point.

Definition at line 474 of file generic-rect.h.

Referenced by Inkscape::UI::ControlPointSelection::_updateBounds(), and Geom::aligned_bbox().

◆ from_range()

template<typename C >
template<typename InputIterator >
static OptCRect Geom::GenericOptRect< C >::from_range ( InputIterator  start,
InputIterator  end 
)
inlinestatic

Create a rectangle from a range of points.

The resulting rectangle will contain all points from the range. If the range contains no points, the result will be an empty rectangle. The return type of iterators must be convertible to the corresponding point type (Point or IntPoint).

Parameters
startBeginning of the range
endEnd of the range
Returns
Rectangle that contains all points from [start, end).

Definition at line 389 of file generic-rect.h.

References end, result, and start.

◆ hasZeroArea()

template<typename C >
bool Geom::GenericOptRect< C >::hasZeroArea ( ) const
inline

Check whether the rectangle has zero area.

Definition at line 426 of file generic-rect.h.

Referenced by Inkscape::DrawingPattern::_updateItem(), and Inkscape::DrawingPattern::renderPattern().

◆ intersects() [1/2]

template<typename C >
bool Geom::GenericOptRect< C >::intersects ( CRect const &  r) const
inline

◆ intersects() [2/2]

template<typename C >
bool Geom::GenericOptRect< C >::intersects ( OptCRect const &  r) const
inline

Check whether the rectangles have any common points.

Empty rectangles will not intersect with any other rectangle. Two empty rectangles will not intersect each other.

Definition at line 412 of file generic-rect.h.

◆ intersectWith() [1/2]

template<typename C >
void Geom::GenericOptRect< C >::intersectWith ( CRect const &  b)
inline

Leave only the area overlapping with the argument.

If the rectangles do not have any points in common, after calling this method the rectangle will be empty.

Definition at line 452 of file generic-rect.h.

References Geom::X, and Geom::Y.

Referenced by Geom::operator&(), Geom::operator&(), Inkscape::DrawingItem::render(), Inkscape::DrawingItem::update(), and SPItem::visualBounds().

◆ intersectWith() [2/2]

template<typename C >
void Geom::GenericOptRect< C >::intersectWith ( OptCRect const &  b)
inline

Leave only the area overlapping with the argument.

If the argument is empty or the rectangles do not have any points in common, after calling this method the rectangle will be empty.

Definition at line 464 of file generic-rect.h.

◆ operator&=() [1/2]

template<typename C >
GenericOptRect< C > & Geom::GenericOptRect< C >::operator&= ( CRect const &  b)
inline

Intersect with b.

Definition at line 491 of file generic-rect.h.

◆ operator&=() [2/2]

template<typename C >
GenericOptRect< C > & Geom::GenericOptRect< C >::operator&= ( OptCRect const &  b)
inline

Intersect with b.

Definition at line 496 of file generic-rect.h.

◆ operator==() [1/2]

template<typename C >
bool Geom::GenericOptRect< C >::operator== ( CRect const &  other) const
inline

Definition at line 506 of file generic-rect.h.

◆ operator==() [2/2]

template<typename C >
bool Geom::GenericOptRect< C >::operator== ( OptCRect const &  other) const
inline

Test for equality.

All empty rectangles are equal.

Definition at line 502 of file generic-rect.h.

◆ operator|=()

template<typename C >
GenericOptRect< C > & Geom::GenericOptRect< C >::operator|= ( OptCRect const &  b)
inline

Union with b.

Definition at line 486 of file generic-rect.h.

◆ regularized()

template<typename C >
OptCRect Geom::GenericOptRect< C >::regularized ( ) const
inline

Returns an empty optional (testing false) if the rectangle has zero area.

Definition at line 428 of file generic-rect.h.

◆ unionWith() [1/2]

◆ unionWith() [2/2]

template<typename C >
void Geom::GenericOptRect< C >::unionWith ( OptCRect const &  b)
inline

Enlarge the rectangle to contain the argument.

Unioning with an empty rectangle results in no changes. If this rectangle is empty, after calling this method it will be equal to the argument.

Definition at line 446 of file generic-rect.h.


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