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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
25
26#ifndef APERTURE_MACRO_H
27#define APERTURE_MACRO_H
28
29
30#include <vector>
31#include <set>
32
33#include <am_param.h>
34#include <am_primitive.h>
35
36class SHAPE_POLY_SET;
37
38/*
39 * An aperture macro defines a complex shape and is a list of aperture primitives.
40 * Each aperture primitive defines a simple shape (circle, rect, regular polygon...)
41 * Inside a given aperture primitive, a fixed list of parameters defines info
42 * about the shape: size, thickness, number of vertex ...
43 *
44 * Each parameter can be an immediate value or a deferred value.
45 * When value is deferred, it is defined when the aperture macro is instanced by
46 * an ADD macro command
47 * Note also a deferred parameter can be defined in aperture macro,
48 * but outside aperture primitives. Example
49 * %AMRECTHERM*
50 * $4=$3/2* parameter $4 is half value of parameter $3
51 * 21,1,$1-$3,$2-$3,0-$1/2-$4,0-$2/2-$4,0*
52 * For the aperture primitive, parameters $1 to $3 will be defined in ADD command,
53 * and $4 is defined inside the macro
54 *
55 * Each basic shape can be a positive shape or a negative shape.
56 * a negative shape is "local" to the whole shape.
57 * It must be seen like a hole in the shape, and not like a standard negative object.
58 */
59
60
65{
66public:
70
82 double GetLocalParam( const D_CODE* aDcode, unsigned aParamId ) const;
83
90 void InitLocalParams( const D_CODE* aDcode );
91
98 void EvalLocalParams( const AM_PRIMITIVE& aPrimitive );
99
105 double GetLocalParamValue( int aIndex );
106
117 const VECTOR2I& aShapePos );
118
122 wxString m_AmName;
123
128 void AddPrimitiveToList( AM_PRIMITIVE& aPrimitive );
129
138
139private:
143 std::vector<AM_PRIMITIVE> m_primitivesList;
144
149
154 std::map<int, double> m_localParamValues;
155
163
165};
166
167
172{
173 // a "less than" test on two APERTURE_MACROs (.name wxStrings)
174 bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
175 {
176 return am1.m_AmName.Cmp( am2.m_AmName ) < 0; // case specific wxString compare
177 }
178};
179
180
184typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET;
185typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR;
186
187
188#endif // ifndef APERTURE_MACRO_H
std::vector< AM_PARAM > AM_PARAMS
Definition am_param.h:347
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:281
An aperture macro primitive as given in gerber layer format doc.
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:76
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
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683