KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew/test_shape_corner_radius.cpp
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 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
#include <
qa_utils/wx_utils/unit_test_utils.h
>
25
#include <boost/test/unit_test.hpp>
26
27
#include <
pcb_shape.h
>
28
#include <
properties/property_mgr.h
>
29
#include <
properties/property.h
>
30
#include <
i18n_utility.h
>
31
32
BOOST_AUTO_TEST_CASE
( PCBShapeCornerRadius )
33
{
34
PCB_SHAPE
shape(
nullptr
,
SHAPE_T::RECTANGLE
);
35
shape.
SetStart
(
VECTOR2I
( 0, 0 ) );
36
shape.
SetEnd
(
VECTOR2I
( 1000, 600 ) );
37
shape.
SetCornerRadius
( 200 );
38
BOOST_CHECK_EQUAL
( shape.
GetCornerRadius
(), 200 );
39
40
shape.
SetCornerRadius
( 400 );
41
BOOST_CHECK_EQUAL
( shape.
GetCornerRadius
(), 300 );
42
43
shape.
SetCornerRadius
( -10 );
44
BOOST_CHECK_EQUAL
( shape.
GetCornerRadius
(), 0 );
45
}
46
47
BOOST_AUTO_TEST_CASE
( PCBShapeCornerRadiusValidation )
48
{
49
PCB_SHAPE
shape(
nullptr
,
SHAPE_T::RECTANGLE
);
50
shape.
SetStart
(
VECTOR2I
( 0, 0 ) );
51
shape.
SetEnd
(
VECTOR2I
( 1000, 500 ) );
52
53
PROPERTY_MANAGER
& propMgr =
PROPERTY_MANAGER::Instance
();
54
propMgr.
Rebuild
();
55
56
PROPERTY_BASE
* prop = propMgr.
GetProperty
(
TYPE_HASH
(
EDA_SHAPE
),
_HKI
(
"Corner Radius"
) );
57
58
auto
resultTooLarge = prop->
Validate
( wxAny( 400 ), &shape );
59
BOOST_CHECK( resultTooLarge.has_value() );
60
61
auto
resultOK = prop->
Validate
( wxAny( 200 ), &shape );
62
BOOST_CHECK( !resultOK.has_value() );
63
}
EDA_SHAPE
Definition
eda_shape.h:88
EDA_SHAPE::SetCornerRadius
void SetCornerRadius(int aRadius)
Definition
eda_shape.cpp:449
EDA_SHAPE::SetStart
void SetStart(const VECTOR2I &aStart)
Definition
eda_shape.h:177
EDA_SHAPE::SetEnd
void SetEnd(const VECTOR2I &aEnd)
Definition
eda_shape.h:219
EDA_SHAPE::GetCornerRadius
int GetCornerRadius() const
Definition
eda_shape.cpp:443
PCB_SHAPE
Definition
pcb_shape.h:38
PROPERTY_BASE
Definition
property.h:195
PROPERTY_BASE::Validate
VALIDATOR_RESULT Validate(const wxAny &&aValue, EDA_ITEM *aItem)
Definition
property.h:352
PROPERTY_MANAGER
Provide class metadata.Helper macro to map type hashes to names.
Definition
property_mgr.h:74
PROPERTY_MANAGER::Instance
static PROPERTY_MANAGER & Instance()
Definition
property_mgr.h:76
PROPERTY_MANAGER::Rebuild
void Rebuild()
Rebuild the list of all registered properties.
Definition
property_mgr.cpp:267
PROPERTY_MANAGER::GetProperty
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Definition
property_mgr.cpp:46
SHAPE_T::RECTANGLE
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition
eda_shape.h:46
i18n_utility.h
Some functions to handle hotkeys in KiCad.
_HKI
#define _HKI(x)
Definition
page_info.cpp:44
pcb_shape.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(PCBShapeCornerRadius)
Definition
pcbnew/test_shape_corner_radius.cpp:32
property.h
TYPE_HASH
#define TYPE_HASH(x)
Definition
property.h:73
property_mgr.h
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
VECTOR2I
VECTOR2< int32_t > VECTOR2I
Definition
vector2d.h:695
src
qa
tests
pcbnew
test_shape_corner_radius.cpp
Generated on Sun Sep 21 2025 01:05:32 for KiCad PCB EDA Suite by
1.13.2