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, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <geometry/shape_rect.h>
23
32{
33public:
34 ROUNDRECT() : m_rect(), m_radius( 0 ) {}
35
44 ROUNDRECT( SHAPE_RECT aRect, int aRadius, bool aNormalizeOnCreate = false );
45
46 static ROUNDRECT OutsetFrom( const SHAPE_RECT& aRect, int aOutset );
47
48 int GetRoundRadius() const { return m_radius; }
49
55 const SHAPE_RECT& GetRect() const { return m_rect; }
56
60 int GetWidth() const { return m_rect.GetWidth(); }
61
62 int GetHeight() const { return m_rect.GetHeight(); }
63
64 VECTOR2I GetPosition() const { return m_rect.GetPosition(); }
65
71 BOX2I BBox() const { return m_rect.BBox(); }
72
77 ROUNDRECT GetInflated( int aOutset ) const;
78
82 void TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aMaxError ) const;
83
84private:
87};
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
A round rectangle shape, based on a rectangle and a radius.
Definition roundrect.h:32
int m_radius
Definition roundrect.h:86
SHAPE_RECT m_rect
Definition roundrect.h:85
int GetHeight() const
Definition roundrect.h:62
int GetRoundRadius() const
Definition roundrect.h:48
BOX2I BBox() const
Get the bounding box of the roundrect.
Definition roundrect.h:71
int GetWidth() const
Shortcut for common values.
Definition roundrect.h:60
static ROUNDRECT OutsetFrom(const SHAPE_RECT &aRect, int aOutset)
Definition roundrect.cpp:67
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aMaxError) const
Get the polygonal representation of the roundrect.
Definition roundrect.cpp:79
const SHAPE_RECT & GetRect() const
Get the basis rectangle of the roundrect.
Definition roundrect.h:55
ROUNDRECT GetInflated(int aOutset) const
Get the roundrect with the size increased by aOutset in all directions.
Definition roundrect.cpp:73
VECTOR2I GetPosition() const
Definition roundrect.h:64
Represent a set of closed polygons.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683