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, see <https://www.gnu.org/licenses/>.
18 */
19
23
24#include <boost/test/unit_test.hpp>
25
26#include <aperture_macro.h>
27#include <dcode.h>
28#include <gerber_draw_item.h>
29#include <gerber_file_image.h>
30
31
32BOOST_AUTO_TEST_SUITE( GerbviewApertureMacro )
33
34
35
46BOOST_AUTO_TEST_CASE( EmptyMacroProducesNoOutlines )
47{
49
50 D_CODE* dcode = image.GetDCODEOrCreate( 10, true );
51 BOOST_REQUIRE( dcode != nullptr );
52 dcode->m_ApertType = APT_MACRO;
53
54 // A macro with no primitives simulates a macro with invalid template parameters:
55 // it produces no shapes, so GetApertureMacroShape returns an empty SHAPE_POLY_SET.
56 APERTURE_MACRO emptyMacro;
57 emptyMacro.m_AmName = wxT( "EMPTY_TEST_MACRO" );
58 dcode->SetMacro( &emptyMacro );
59
60 GERBER_DRAW_ITEM item( &image );
62 item.m_DCode = 10;
63
64 SHAPE_POLY_SET* shape = emptyMacro.GetApertureMacroShape( &item, VECTOR2I( 0, 0 ) );
65
66 BOOST_REQUIRE( shape != nullptr );
67 BOOST_CHECK_EQUAL( shape->OutlineCount(), 0 );
68
69 // ConvertShapeToPolygon must also leave m_Polygon with 0 outlines for an empty macro.
70 dcode->ConvertShapeToPolygon( &item );
72}
73
74
Support the "aperture macro" defined within standard RS274X.
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
A gerber DCODE (also called Aperture) definition.
Definition dcode.h:76
void SetMacro(APERTURE_MACRO *aMacro)
Definition dcode.h:127
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition dcode.h:198
SHAPE_POLY_SET m_Polygon
Definition dcode.h:213
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition dcode.cpp:293
GBR_BASIC_SHAPE_TYPE m_ShapeType
Hold the image data and parameters for one gerber file and layer parameters.
Represent a set of closed polygons.
int OutlineCount() const
Return the number of outlines in the set.
@ APT_MACRO
Definition dcode.h:50
@ GBR_SPOT_MACRO
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683