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)
 
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, int aError, ERROR_LOC aErrorLoc) 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.

Referenced by GetInflated(), and OutsetFrom().

◆ ROUNDRECT() [2/2]

ROUNDRECT::ROUNDRECT ( SHAPE_RECT  aRect,
int  aRadius 
)

Definition at line 53 of file roundrect.cpp.

References m_radius, m_rect, and SHAPE_RECT::MajorDimension().

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 67 of file roundrect.h.

References SHAPE_RECT::BBox(), and m_rect.

◆ GetHeight()

int ROUNDRECT::GetHeight ( ) const
inline

Definition at line 58 of file roundrect.h.

References SHAPE_RECT::GetHeight(), and 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 SHAPE_RECT::GetInflated(), m_radius, m_rect, and ROUNDRECT().

◆ GetPosition()

VECTOR2I ROUNDRECT::GetPosition ( ) const
inline

Definition at line 60 of file roundrect.h.

References SHAPE_RECT::GetPosition(), and 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 51 of file roundrect.h.

References m_rect.

◆ GetRoundRadius()

int ROUNDRECT::GetRoundRadius ( ) const
inline

Definition at line 44 of file roundrect.h.

References m_radius.

◆ GetWidth()

int ROUNDRECT::GetWidth ( ) const
inline

Shortcut for common values.

Definition at line 56 of file roundrect.h.

References SHAPE_RECT::GetWidth(), and 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 83 of file roundrect.h.

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

◆ m_rect

SHAPE_RECT ROUNDRECT::m_rect
private

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