KiCad PCB EDA Suite
Loading...
Searching...
No Matches
aperture_macro.h
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) 1992-2010 Jean-Pierre Charras <jp.charras at wanadoo.fr>
5 * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
30#ifndef APERTURE_MACRO_H
31#define APERTURE_MACRO_H
32
33
34#include <vector>
35#include <set>
36
37#include <am_param.h>
38#include <am_primitive.h>
39
40class SHAPE_POLY_SET;
41
42/*
43 * An aperture macro defines a complex shape and is a list of aperture primitives.
44 * Each aperture primitive defines a simple shape (circle, rect, regular polygon...)
45 * Inside a given aperture primitive, a fixed list of parameters defines info
46 * about the shape: size, thickness, number of vertex ...
47 *
48 * Each parameter can be an immediate value or a deferred value.
49 * When value is deferred, it is defined when the aperture macro is instanced by
50 * an ADD macro command
51 * Note also a deferred parameter can be defined in aperture macro,
52 * but outside aperture primitives. Example
53 * %AMRECTHERM*
54 * $4=$3/2* parameter $4 is half value of parameter $3
55 * 21,1,$1-$3,$2-$3,0-$1/2-$4,0-$2/2-$4,0*
56 * For the aperture primitive, parameters $1 to $3 will be defined in ADD command,
57 * and $4 is defined inside the macro
58 *
59 * Each basic shape can be a positive shape or a negative shape.
60 * a negative shape is "local" to the whole shape.
61 * It must be seen like a hole in the shape, and not like a standard negative object.
62 */
63
64
69{
70public:
73 {}
86 double GetLocalParam( const D_CODE* aDcode, unsigned aParamId ) const;
87
94 void InitLocalParams( const D_CODE* aDcode );
95
102 void EvalLocalParams( const AM_PRIMITIVE& aPrimitive );
103
109 double GetLocalParamValue( int aIndex );
110
121 const VECTOR2I& aShapePos );
122
126 wxString m_AmName;
127
132 void AddPrimitiveToList( AM_PRIMITIVE& aPrimitive );
133
142
143private:
147 std::vector<AM_PRIMITIVE> m_primitivesList;
148
153
158 std::map<int, double> m_localParamValues;
159
167
169};
170
171
176{
177 // a "less than" test on two APERTURE_MACROs (.name wxStrings)
178 bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
179 {
180 return am1.m_AmName.Cmp( am2.m_AmName ) < 0; // case specific wxString compare
181 }
182};
183
184
188typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET;
189typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR;
190
191
192#endif // ifndef APERTURE_MACRO_H
std::vector< AM_PARAM > AM_PARAMS
Definition: am_param.h:351
std::set< APERTURE_MACRO, APERTURE_MACRO_less_than > APERTURE_MACRO_SET
A sorted collection of APERTURE_MACROS whose key is the name field in the APERTURE_MACRO.
std::pair< APERTURE_MACRO_SET::iterator, bool > APERTURE_MACRO_SET_PAIR
Hold a parameter value for an "aperture macro" as defined within standard RS274X.
Definition: am_param.h:285
An aperture macro primitive as given in gerber layer format doc.
Definition: am_primitive.h:92
Support the "aperture macro" defined within standard RS274X.
void InitLocalParams(const D_CODE *aDcode)
Init m_localParamValues to a initial values coming from aDcode and clear m_paramLevelEval must be cal...
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
double GetLocalParamValue(int aIndex)
std::map< int, double > m_localParamValues
m_localParamValues is the current value of local parameters after evaluation the key is the local par...
int m_paramLevelEval
the current level of local param values evaluation when a primitive is evaluated, if its m_LocalParam...
std::vector< AM_PRIMITIVE > m_primitivesList
A list of AM_PRIMITIVEs to define the shape of the aperture macro.
void AddLocalParamDefToStack()
A deferred parameter can be defined in aperture macro, but outside aperture primitives.
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
AM_PARAM & GetLastLocalParamDefFromStack()
AM_PARAMS m_localParamStack
m_localparamStack handle a list of local deferred parameters
SHAPE_POLY_SET m_shape
The shape of the item, calculated by GetApertureMacroShape.
void AddPrimitiveToList(AM_PRIMITIVE &aPrimitive)
Add a new ptimitive ( AMP_CIRCLE, AMP_LINE2 ...) to the list of primitives to define the full shape o...
void EvalLocalParams(const AM_PRIMITIVE &aPrimitive)
Evaluate m_localParamValues from current m_paramLevelEval to aPrimitive m_LocalParamLevel if m_paramL...
double GetLocalParam(const D_CODE *aDcode, unsigned aParamId) const
Usually, parameters are defined inside the aperture primitive using immediate mode or deferred mode.
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
Represent a set of closed polygons.
Used by std:set<APERTURE_MACRO> instantiation which uses APERTURE_MACRO.name as its key.
bool operator()(const APERTURE_MACRO &am1, const APERTURE_MACRO &am2) const