KiCad PCB EDA Suite
Loading...
Searching...
No Matches
am_primitive.h
Go to the documentation of this file.
1
5#ifndef AM_PRIMITIVE_H
6#define AM_PRIMITIVE_H
7
8/*
9 * This program source code file is part of KiCad, a free EDA CAD application.
10 *
11 * Copyright (C) 1992-2010 Jean-Pierre Charras <jp.charras at wanadoo.fr>
12 * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
13 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, you may find one here:
27 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
28 * or you may search the http://www.gnu.org website for the version 2 license,
29 * or you may write to the Free Software Foundation, Inc.,
30 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
31 */
32
33#include <vector>
34#include <set>
35
36#include <am_param.h>
37
38class SHAPE_POLY_SET;
39
40/*
41 * An aperture macro defines a complex shape and is a list of aperture primitives.
42 * Each aperture primitive defines a simple shape (circle, rect, regular polygon...)
43 * Inside a given aperture primitive, a fixed list of parameters defines info
44 * about the shape: size, thickness, number of vertex ...
45 *
46 * Each parameter can be an immediate value or a deferred value.
47 * When value is deferred, it is defined when the aperture macro is instanced by
48 * an ADD macro command
49 * Note also a deferred parameter can be defined in aperture macro,
50 * but outside aperture primitives. Example
51 * %AMRECTHERM*
52 * $4=$3/2* parameter $4 is half value of parameter $3
53 * 21,1,$1-$3,$2-$3,0-$1/2-$4,0-$2/2-$4,0*
54 * For the aperture primitive, parameters $1 to $3 will be defined in ADD command,
55 * and $4 is defined inside the macro
56 *
57 * Each basic shape can be a positive shape or a negative shape.
58 * a negative shape is "local" to the whole shape.
59 * It must be seen like a hole in the shape, and not like a standard negative object.
60 */
61
70 AMP_UNKNOWN = -1, // A value for uninitialized AM_PRIMITIVE.
71 AMP_COMMENT = 0, // A primitive description is not really a primitive, this is a
72 // comment
73 AMP_CIRCLE = 1, // Circle. (diameter and position)
74 AMP_LINE2 = 2, // Line with rectangle ends. (Width, start and end pos + rotation)
75 AMP_LINE20 = 20, // Same as AMP_LINE2
76 AMP_LINE_CENTER = 21, // Rectangle. (height, width and center pos + rotation)
77 AMP_LINE_LOWER_LEFT = 22, // Rectangle. (height, width and left bottom corner pos + rotation)
78 AMP_OUTLINE = 4, // Free polyline (n corners + rotation)
79 AMP_POLYGON = 5, // Closed regular polygon(diameter, number of vertices (3 to 10),
80 // rotation)
81 AMP_MOIRE = 6, // A cross hair with n concentric circles + rotation (deprecated in 2021)
82 AMP_THERMAL = 7 // Thermal shape (pos, outer and inner diameter, cross hair
83 // thickness + rotation)
84};
85
86
92{
93public:
96 bool m_GerbMetric; // units for this primitive:
97 // false = Inches, true = metric
98 int m_LocalParamLevel; // count of local param defined inside a aperture macro
99 // local param stack when this primitive is put in
100 // aperture macro primitive stack list
101 // not used outside a aperture macro
102
103 AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
104 {
105 m_Primitive_id = aId;
106 m_GerbMetric = aGerbMetric;
108 }
109
110
112
120 bool IsAMPrimitiveExposureOn( APERTURE_MACRO* aApertMacro ) const;
121
129#if 0
130 void ConvertBasicShapeToPolygon( const D_CODE* aDcode,
131 SHAPE_POLY_SET& aShapeBuffer );
132#endif
134 SHAPE_POLY_SET& aShapeBuffer );
135
136private:
147 //void ConvertShapeToPolygon( const D_CODE* aDcode, std::vector<VECTOR2I>& aBuffer );
148 void ConvertShapeToPolygon( APERTURE_MACRO* aApertMacroe, std::vector<VECTOR2I>& aBuffer );
149};
150
151
152#endif // ifndef AM_PRIMITIVE_H
std::vector< AM_PARAM > AM_PARAMS
Definition: am_param.h:351
AM_PRIMITIVE_ID
The set of all "aperture macro primitives" (primitive numbers).
Definition: am_primitive.h:69
@ AMP_POLYGON
Definition: am_primitive.h:79
@ AMP_LINE_LOWER_LEFT
Definition: am_primitive.h:77
@ AMP_LINE2
Definition: am_primitive.h:74
@ AMP_CIRCLE
Definition: am_primitive.h:73
@ AMP_THERMAL
Definition: am_primitive.h:82
@ AMP_UNKNOWN
Definition: am_primitive.h:70
@ AMP_COMMENT
Definition: am_primitive.h:71
@ AMP_LINE_CENTER
Definition: am_primitive.h:76
@ AMP_MOIRE
Definition: am_primitive.h:81
@ AMP_OUTLINE
Definition: am_primitive.h:78
@ AMP_LINE20
Definition: am_primitive.h:75
An aperture macro primitive as given in gerber layer format doc.
Definition: am_primitive.h:92
void ConvertBasicShapeToPolygon(APERTURE_MACRO *aApertMacro, SHAPE_POLY_SET &aShapeBuffer)
Generate the polygonal shape of the primitive shape of an aperture macro instance.
bool IsAMPrimitiveExposureOn(APERTURE_MACRO *aApertMacro) const
void ConvertShapeToPolygon(APERTURE_MACRO *aApertMacroe, std::vector< VECTOR2I > &aBuffer)
Convert a shape to an equivalent polygon.
AM_PARAMS m_Params
A sequence of parameters used by the primitive.
Definition: am_primitive.h:95
AM_PRIMITIVE_ID m_Primitive_id
The primitive type.
Definition: am_primitive.h:94
int m_LocalParamLevel
Definition: am_primitive.h:98
AM_PRIMITIVE(bool aGerbMetric, AM_PRIMITIVE_ID aId=AMP_UNKNOWN)
Definition: am_primitive.h:103
bool m_GerbMetric
Definition: am_primitive.h:96
Support the "aperture macro" defined within standard RS274X.
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
Represent a set of closed polygons.