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 The 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
48 ROUNDRECT( SHAPE_RECT aRect, int aRadius, bool aNormalizeOnCreate = false );
49
50 static ROUNDRECT OutsetFrom( const SHAPE_RECT& aRect, int aOutset );
51
52 int GetRoundRadius() const { return m_radius; }
53
59 const SHAPE_RECT& GetRect() const { return m_rect; }
60
64 int GetWidth() const { return m_rect.GetWidth(); }
65
66 int GetHeight() const { return m_rect.GetHeight(); }
67
68 VECTOR2I GetPosition() const { return m_rect.GetPosition(); }
69
75 BOX2I BBox() const { return m_rect.BBox(); }
76
81 ROUNDRECT GetInflated( int aOutset ) const;
82
86 void TransformToPolygon( SHAPE_POLY_SET& aBuffer ) const;
87
88private:
91};
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
A round rectangle shape, based on a rectangle and a radius.
Definition roundrect.h:36
int m_radius
Definition roundrect.h:90
SHAPE_RECT m_rect
Definition roundrect.h:89
int GetHeight() const
Definition roundrect.h:66
int GetRoundRadius() const
Definition roundrect.h:52
BOX2I BBox() const
Get the bounding box of the roundrect.
Definition roundrect.h:75
int GetWidth() const
Shortcut for common values.
Definition roundrect.h:64
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:59
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:68
void TransformToPolygon(SHAPE_POLY_SET &aBuffer) const
Get the polygonal representation of the roundrect.
Definition roundrect.cpp:81
Represent a set of closed polygons.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695