KiCad PCB EDA Suite
Loading...
Searching...
No Matches
roundrect.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <geometry/shape_rect.h>
27
36{
37public:
38 ROUNDRECT() : m_rect(), m_radius( 0 ) {}
39
40 ROUNDRECT( SHAPE_RECT aRect, int aRadius );
41
42 static ROUNDRECT OutsetFrom( const SHAPE_RECT& aRect, int aOutset );
43
44 int GetRoundRadius() const { return m_radius; }
45
51 const SHAPE_RECT& GetRect() const { return m_rect; }
52
56 int GetWidth() const { return m_rect.GetWidth(); }
57
58 int GetHeight() const { return m_rect.GetHeight(); }
59
60 VECTOR2I GetPosition() const { return m_rect.GetPosition(); }
61
67 BOX2I BBox() const { return m_rect.BBox(); }
68
73 ROUNDRECT GetInflated( int aOutset ) const;
74
78 void TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aError, ERROR_LOC aErrorLoc ) const
79 /*override */;
80
81private:
84};
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
A round rectangle shape, based on a rectangle and a radius.
Definition: roundrect.h:36
int m_radius
Definition: roundrect.h:83
SHAPE_RECT m_rect
Definition: roundrect.h:82
int GetHeight() const
Definition: roundrect.h:58
int GetRoundRadius() const
Definition: roundrect.h:44
BOX2I BBox() const
Get the bounding box of the roundrect.
Definition: roundrect.h:67
int GetWidth() const
Shortcut for common values.
Definition: roundrect.h:56
static ROUNDRECT OutsetFrom(const SHAPE_RECT &aRect, int aOutset)
Definition: roundrect.cpp:69
const SHAPE_RECT & GetRect() const
Get the basis rectangle of the roundrect.
Definition: roundrect.h:51
ROUNDRECT GetInflated(int aOutset) const
Get the roundrect with the size increased by aOutset in all directions.
Definition: roundrect.cpp:75
VECTOR2I GetPosition() const
Definition: roundrect.h:60
ROUNDRECT()
Definition: roundrect.h:38
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const
Get the polygonal representation of the roundrect.
Definition: roundrect.cpp:81
Represent a set of closed polygons.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition: shape_rect.h:102
const VECTOR2I & GetPosition() const
Definition: shape_rect.h:160
int GetWidth() const
Definition: shape_rect.h:176
int GetHeight() const
Definition: shape_rect.h:184