KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_aperture_macro.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 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
27
28
#include <boost/test/unit_test.hpp>
29
30
#include <
aperture_macro.h
>
31
#include <
dcode.h
>
32
#include <
gerber_draw_item.h
>
33
#include <
gerber_file_image.h
>
34
35
36
BOOST_AUTO_TEST_SUITE
( GerbviewApertureMacro )
37
38
39
50
BOOST_AUTO_TEST_CASE
( EmptyMacroProducesNoOutlines )
51
{
52
GERBER_FILE_IMAGE
image
( 0 );
53
54
D_CODE
* dcode =
image
.GetDCODEOrCreate( 10,
true
);
55
BOOST_REQUIRE
( dcode !=
nullptr
);
56
dcode->
m_ApertType
=
APT_MACRO
;
57
58
// A macro with no primitives simulates a macro with invalid template parameters:
59
// it produces no shapes, so GetApertureMacroShape returns an empty SHAPE_POLY_SET.
60
APERTURE_MACRO
emptyMacro;
61
emptyMacro.
m_AmName
= wxT(
"EMPTY_TEST_MACRO"
);
62
dcode->
SetMacro
( &emptyMacro );
63
64
GERBER_DRAW_ITEM
item( &
image
);
65
item.
m_ShapeType
=
GBR_SPOT_MACRO
;
66
item.
m_DCode
= 10;
67
68
SHAPE_POLY_SET
* shape = emptyMacro.
GetApertureMacroShape
( &item,
VECTOR2I
( 0, 0 ) );
69
70
BOOST_REQUIRE
( shape !=
nullptr
);
71
BOOST_CHECK_EQUAL
( shape->
OutlineCount
(), 0 );
72
73
// ConvertShapeToPolygon must also leave m_Polygon with 0 outlines for an empty macro.
74
dcode->
ConvertShapeToPolygon
( &item );
75
BOOST_CHECK_EQUAL
( dcode->
m_Polygon
.
OutlineCount
(), 0 );
76
}
77
78
79
BOOST_AUTO_TEST_SUITE_END
()
aperture_macro.h
BITMAPS::image
@ image
Definition
bitmaps_list.h:311
APERTURE_MACRO
Support the "aperture macro" defined within standard RS274X.
Definition
aperture_macro.h:69
APERTURE_MACRO::m_AmName
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
Definition
aperture_macro.h:126
APERTURE_MACRO::GetApertureMacroShape
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
Definition
aperture_macro.cpp:103
D_CODE
A gerber DCODE (also called Aperture) definition.
Definition
dcode.h:80
D_CODE::SetMacro
void SetMacro(APERTURE_MACRO *aMacro)
Definition
dcode.h:131
D_CODE::m_ApertType
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition
dcode.h:202
D_CODE::m_Polygon
SHAPE_POLY_SET m_Polygon
Definition
dcode.h:217
D_CODE::ConvertShapeToPolygon
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition
dcode.cpp:297
GERBER_DRAW_ITEM
Definition
gerber_draw_item.h:64
GERBER_DRAW_ITEM::m_ShapeType
GBR_BASIC_SHAPE_TYPE m_ShapeType
Definition
gerber_draw_item.h:232
GERBER_DRAW_ITEM::m_DCode
int m_DCode
Definition
gerber_draw_item.h:242
GERBER_FILE_IMAGE
Hold the image data and parameters for one gerber file and layer parameters.
Definition
gerber_file_image.h:116
SHAPE_POLY_SET
Represent a set of closed polygons.
Definition
shape_poly_set.h:69
SHAPE_POLY_SET::OutlineCount
int OutlineCount() const
Return the number of outlines in the set.
Definition
shape_poly_set.h:736
dcode.h
APT_MACRO
@ APT_MACRO
Definition
dcode.h:54
gerber_draw_item.h
GBR_SPOT_MACRO
@ GBR_SPOT_MACRO
Definition
gerber_draw_item.h:60
gerber_file_image.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:71
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2I
VECTOR2< int32_t > VECTOR2I
Definition
vector2d.h:687
src
qa
tests
gerbview
test_aperture_macro.cpp
Generated on Sun Apr 26 2026 00:06:59 for KiCad PCB EDA Suite by
1.13.2