KiCad PCB EDA Suite
|
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_RECT & | GetRect () 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 |
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.
|
inline |
Definition at line 38 of file roundrect.h.
References m_radius, and m_rect.
Referenced by GetInflated(), and OutsetFrom().
ROUNDRECT::ROUNDRECT | ( | SHAPE_RECT | aRect, |
int | aRadius, | ||
bool | aNormalizeOnCreate = false ) |
Creates a ROUNDRECT instance.
aRect | in the rectangle model |
aRadius | is the radius of the round rect |
aNormalizeOnCreate | allows 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.
|
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.
|
inline |
Definition at line 66 of file roundrect.h.
References m_rect.
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().
|
inline |
Definition at line 68 of file roundrect.h.
References m_rect.
|
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.
|
inline |
Definition at line 52 of file roundrect.h.
References m_radius.
|
inline |
|
static |
Definition at line 69 of file roundrect.cpp.
References SHAPE_RECT::GetInflated(), and ROUNDRECT().
void ROUNDRECT::TransformToPolygon | ( | SHAPE_POLY_SET & | aBuffer | ) | const |
Get the polygonal representation of the roundrect.
Definition at line 81 of file roundrect.cpp.
References ANGLE_360, SHAPE_LINE_CHAIN::Append(), DIRECTION_45::E, m_radius, m_rect, DIRECTION_45::N, DIRECTION_45::NE, SHAPE_POLY_SET::NewOutline(), DIRECTION_45::NW, SHAPE_POLY_SET::Outline(), DIRECTION_45::S, DIRECTION_45::SE, SHAPE_LINE_CHAIN::SetClosed(), DIRECTION_45::SW, and DIRECTION_45::W.
Referenced by BOARD_ADAPTER::addShape(), CONVERT_TOOL::CreateLines(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), EDA_SHAPE::hitTest(), EDA_SHAPE::hitTest(), EDA_SHAPE::makeEffectiveShapes(), SHAPE_RECT::Outline(), processClosedShape(), OUTSET_ROUTINE::ProcessItem(), EDA_SHAPE::rotate(), SHAPE_RECT::TransformToPolygon(), and EDA_SHAPE::UpdateHatching().
|
private |
Definition at line 90 of file roundrect.h.
Referenced by GetInflated(), GetRoundRadius(), ROUNDRECT(), ROUNDRECT(), and TransformToPolygon().
|
private |
Definition at line 89 of file roundrect.h.
Referenced by BBox(), GetHeight(), GetInflated(), GetPosition(), GetRect(), GetWidth(), ROUNDRECT(), ROUNDRECT(), and TransformToPolygon().