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, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include <
qa_utils/wx_utils/unit_test_utils.h
>
21
#include <boost/test/unit_test.hpp>
22
23
#include <
pcb_shape.h
>
24
#include <
properties/property_mgr.h
>
25
#include <
properties/property.h
>
26
#include <
i18n_utility.h
>
27
28
BOOST_AUTO_TEST_CASE
( PCBShapeCornerRadius )
29
{
30
PCB_SHAPE
shape(
nullptr
,
SHAPE_T::RECTANGLE
);
31
shape.
SetStart
(
VECTOR2I
( 0, 0 ) );
32
shape.
SetEnd
(
VECTOR2I
( 1000, 600 ) );
33
shape.
SetCornerRadius
( 200 );
34
BOOST_CHECK_EQUAL
( shape.
GetCornerRadius
(), 200 );
35
36
shape.
SetCornerRadius
( 400 );
37
BOOST_CHECK_EQUAL
( shape.
GetCornerRadius
(), 300 );
38
39
shape.
SetCornerRadius
( -10 );
40
BOOST_CHECK_EQUAL
( shape.
GetCornerRadius
(), 0 );
41
}
42
43
BOOST_AUTO_TEST_CASE
( PCBShapeCornerRadiusValidation )
44
{
45
PCB_SHAPE
shape(
nullptr
,
SHAPE_T::RECTANGLE
);
46
shape.
SetStart
(
VECTOR2I
( 0, 0 ) );
47
shape.
SetEnd
(
VECTOR2I
( 1000, 500 ) );
48
49
PROPERTY_MANAGER
& propMgr =
PROPERTY_MANAGER::Instance
();
50
propMgr.
Rebuild
();
51
52
PROPERTY_BASE
* prop = propMgr.
GetProperty
(
TYPE_HASH
(
EDA_SHAPE
),
_HKI
(
"Corner Radius"
) );
53
54
auto
resultTooLarge = prop->
Validate
( wxAny( 400 ), &shape );
55
BOOST_CHECK( resultTooLarge.has_value() );
56
57
auto
resultOK = prop->
Validate
( wxAny( 200 ), &shape );
58
BOOST_CHECK( !resultOK.has_value() );
59
}
EDA_SHAPE
Definition
eda_shape.h:98
EDA_SHAPE::SetCornerRadius
void SetCornerRadius(int aRadius)
Definition
eda_shape.cpp:581
EDA_SHAPE::GetCornerRadius
int GetCornerRadius() const
Definition
eda_shape.cpp:575
PCB_SHAPE
Definition
pcb_shape.h:35
PCB_SHAPE::SetEnd
void SetEnd(const VECTOR2I &aEnd) override
Definition
pcb_shape.cpp:882
PCB_SHAPE::SetStart
void SetStart(const VECTOR2I &aStart) override
Definition
pcb_shape.cpp:875
PROPERTY_BASE
Definition
property.h:196
PROPERTY_BASE::Validate
VALIDATOR_RESULT Validate(const wxAny &&aValue, EDA_ITEM *aItem)
Definition
property.h:355
PROPERTY_MANAGER
Provide class metadata.Helper macro to map type hashes to names.
Definition
property_mgr.h:79
PROPERTY_MANAGER::Instance
static PROPERTY_MANAGER & Instance()
Definition
property_mgr.h:81
PROPERTY_MANAGER::Rebuild
void Rebuild()
Rebuild the list of all registered properties.
Definition
property_mgr.cpp:278
PROPERTY_MANAGER::GetProperty
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Definition
property_mgr.cpp:49
SHAPE_T::RECTANGLE
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition
eda_shape.h:47
i18n_utility.h
Some functions to handle hotkeys in KiCad.
_HKI
#define _HKI(x)
Definition
page_info.cpp:40
pcb_shape.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(PCBShapeCornerRadius)
Definition
pcbnew/test_shape_corner_radius.cpp:28
property.h
TYPE_HASH
#define TYPE_HASH(x)
Definition
property.h:74
property_mgr.h
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
VECTOR2I
VECTOR2< int32_t > VECTOR2I
Definition
vector2d.h:683
src
qa
tests
pcbnew
test_shape_corner_radius.cpp
Generated on Fri Jun 26 2026 00:05:44 for KiCad PCB EDA Suite by
1.13.2