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
36BOOST_AUTO_TEST_SUITE( GerbviewApertureMacro )
37
38
39
50BOOST_AUTO_TEST_CASE( EmptyMacroProducesNoOutlines )
51{
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 );
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 );
76}
77
78
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:80
void SetMacro(APERTURE_MACRO *aMacro)
Definition dcode.h:131
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition dcode.h:202
SHAPE_POLY_SET m_Polygon
Definition dcode.h:217
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition dcode.cpp:297
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:54
@ 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:687