KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ROUNDRECT Class Reference

A round rectangle shape, based on a rectangle and a radius. More...

#include <roundrect.h>

Public Member Functions

 ROUNDRECT ()
 
 ROUNDRECT (SHAPE_RECT aRect, int aRadius, bool aNormalizeOnCreate=false)
 Creates a ROUNDRECT instance.
 
int GetRoundRadius () const
 
const SHAPE_RECTGetRect () const
 Get the basis rectangle of the roundrect.
 
int GetWidth () const
 Shortcut for common values.
 
int GetHeight () const
 
VECTOR2I GetPosition () const
 
BOX2I BBox () const
 Get the bounding box of the roundrect.
 
ROUNDRECT GetInflated (int aOutset) const
 Get the roundrect with the size increased by aOutset in all directions.
 
void TransformToPolygon (SHAPE_POLY_SET &aBuffer) const
 Get the polygonal representation of the roundrect.
 

Static Public Member Functions

static ROUNDRECT OutsetFrom (const SHAPE_RECT &aRect, int aOutset)
 

Private Attributes

SHAPE_RECT m_rect
 
int m_radius
 

Detailed Description

A round rectangle shape, based on a rectangle and a radius.

For now, not an inheritor of SHAPE as that means implementing a lot of Collision logic. Then again, this is a common shape, could be more efficient to do the collision using arcs rather than Clipper'ing pad outsets.

Definition at line 35 of file roundrect.h.

Constructor & Destructor Documentation

◆ ROUNDRECT() [1/2]

ROUNDRECT::ROUNDRECT ( )
inline

Definition at line 38 of file roundrect.h.

References m_radius, and m_rect.

Referenced by GetInflated(), and OutsetFrom().

◆ ROUNDRECT() [2/2]

ROUNDRECT::ROUNDRECT ( SHAPE_RECT aRect,
int aRadius,
bool aNormalizeOnCreate = false )

Creates a ROUNDRECT instance.

Parameters
aRectin the rectangle model
aRadiusis the radius of the round rect
aNormalizeOnCreateallows normalization of the created rect, i.e ensure width and height > 0, regardless width and height of aRect allowing normalization can modifiy the value of origin of created instance from aRect

Definition at line 51 of file roundrect.cpp.

References std::abs(), m_radius, m_rect, and move.

Member Function Documentation

◆ BBox()

BOX2I ROUNDRECT::BBox ( ) const
inline

Get the bounding box of the roundrect.

(This is always the same as the basis rectangle's bounding box.)

Definition at line 75 of file roundrect.h.

References m_rect.

◆ GetHeight()

int ROUNDRECT::GetHeight ( ) const
inline

Definition at line 66 of file roundrect.h.

References m_rect.

◆ GetInflated()

ROUNDRECT ROUNDRECT::GetInflated ( int aOutset) const

Get the roundrect with the size increased by aOutset in all directions.

(the radius increases by aOutset as well).

Definition at line 75 of file roundrect.cpp.

References m_radius, m_rect, and ROUNDRECT().

◆ GetPosition()

VECTOR2I ROUNDRECT::GetPosition ( ) const
inline

Definition at line 68 of file roundrect.h.

References m_rect.

◆ GetRect()

const SHAPE_RECT & ROUNDRECT::GetRect ( ) const
inline

Get the basis rectangle of the roundrect.

This is the rectangle without the rounded corners.

Definition at line 59 of file roundrect.h.

References m_rect.

◆ GetRoundRadius()

int ROUNDRECT::GetRoundRadius ( ) const
inline

Definition at line 52 of file roundrect.h.

References m_radius.

◆ GetWidth()

int ROUNDRECT::GetWidth ( ) const
inline

Shortcut for common values.

Definition at line 64 of file roundrect.h.

References m_rect.

◆ OutsetFrom()

ROUNDRECT ROUNDRECT::OutsetFrom ( const SHAPE_RECT & aRect,
int aOutset )
static

Definition at line 69 of file roundrect.cpp.

References SHAPE_RECT::GetInflated(), and ROUNDRECT().

◆ TransformToPolygon()

Member Data Documentation

◆ m_radius

int ROUNDRECT::m_radius
private

Definition at line 90 of file roundrect.h.

Referenced by GetInflated(), GetRoundRadius(), ROUNDRECT(), ROUNDRECT(), and TransformToPolygon().

◆ m_rect

SHAPE_RECT ROUNDRECT::m_rect
private

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