KiCad PCB EDA Suite
dcode.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 <[email protected]>
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 _DCODE_H_
31#define _DCODE_H_
32
33#include <vector>
34
35#include <gal/color4d.h>
37
38using KIGFX::COLOR4D;
39
40class wxDC;
42
43
49 APT_CIRCLE = 'C', // Flashed shape: Circle with or without hole
50 APT_RECT = 'R', // Flashed shape: Rectangle with or without hole
51 APT_OVAL = '0', // Flashed shape: Oval with or without hole
52 APT_POLYGON = 'P', // Flashed shape: Regular polygon (3 to 12 edges)
53 // with or without hole. Can be rotated
54 APT_MACRO = 'M' // Complex shape given by a macro definition (see AM_PRIMITIVE_ID)
55};
56
57// In aperture definition, round, oval and rectangular flashed shapes
58// can have a hole (round or rectangular)
59// this option is stored in .m_DrillShape D_CODE member
64};
65
66/* define min and max values for D Codes values.
67 * note: values >= 0 and < FIRST_DCODE can be used for special purposes
68 */
69#define FIRST_DCODE 10
70#define LAST_DCODE 10000
71#define TOOLS_MAX_COUNT (LAST_DCODE + 1)
72
73class APERTURE_MACRO;
74
75
79class D_CODE
80{
81public:
82 D_CODE( int num_dcode );
83 ~D_CODE();
84 void Clear_D_CODE_Data();
85
91 void AppendParam( double aValue )
92 {
93 m_am_params.push_back( aValue );
94 }
95
99 unsigned GetParamCount() const
100 {
101 return m_am_params.size();
102 }
103
109 double GetParam( unsigned aIdx ) const
110 {
111 wxASSERT( aIdx <= m_am_params.size() );
112
113 if( aIdx <= m_am_params.size() )
114 return m_am_params[aIdx - 1];
115 else
116 return 0;
117 }
118
119 void SetMacro( APERTURE_MACRO* aMacro )
120 {
121 m_Macro = aMacro;
122 }
123
124 APERTURE_MACRO* GetMacro() const { return m_Macro; }
125
131 static const wxChar* ShowApertureType( APERTURE_T aType );
132
144 void DrawFlashedShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
145 const COLOR4D& aColor,
146 const VECTOR2I& aShapePos, bool aFilledShape );
147
161 void DrawFlashedPolygon( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
162 const COLOR4D& aColor,
163 bool aFilled, const VECTOR2I& aPosition );
164
173 void ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent );
174
186 int GetShapeDim( GERBER_DRAW_ITEM* aParent );
187
188public:
189 wxSize m_Size;
192 wxSize m_Drill;
198 bool m_InUse;
201 wxString m_AperFunction;
204 SHAPE_POLY_SET m_Polygon; /* Polygon used to draw APT_POLYGON shape and some other
205 * complex shapes which are converted to polygon
206 * (shapes with hole )
207 */
208
209private:
211
216 std::vector<double> m_am_params;
217};
218
219
220#endif // ifndef _DCODE_H_
Support the "aperture macro" defined within standard RS274X.
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:124
std::vector< double > m_am_params
parameters used only when this D_CODE holds a reference to an aperture macro, and these parameters wo...
Definition: dcode.h:216
void Clear_D_CODE_Data()
Definition: dcode.cpp:70
double GetParam(unsigned aIdx) const
Return a parameter stored in parameter list.
Definition: dcode.h:109
void DrawFlashedShape(const GERBER_DRAW_ITEM *aParent, wxDC *aDC, const COLOR4D &aColor, const VECTOR2I &aShapePos, bool aFilledShape)
Draw the dcode shape for flashed items.
Definition: dcode.cpp:153
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition: dcode.h:201
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:191
D_CODE(int num_dcode)
Definition: dcode.cpp:58
int GetShapeDim(GERBER_DRAW_ITEM *aParent)
Calculate a value that can be used to evaluate the size of text when displaying the D-Code of an item...
Definition: dcode.cpp:115
~D_CODE()
Definition: dcode.cpp:65
void DrawFlashedPolygon(const GERBER_DRAW_ITEM *aParent, wxDC *aDC, const COLOR4D &aColor, bool aFilled, const VECTOR2I &aPosition)
A helper function used to draw the polygon stored in m_PolyCorners.
Definition: dcode.cpp:266
EDA_ANGLE m_Rotation
shape rotation
Definition: dcode.h:195
void SetMacro(APERTURE_MACRO *aMacro)
Definition: dcode.h:119
wxSize m_Drill
dimension of the hole (if any) (drill file)
Definition: dcode.h:192
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition: dcode.h:196
static const wxChar * ShowApertureType(APERTURE_T aType)
Return a character string telling what type of aperture type aType is.
Definition: dcode.cpp:86
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:190
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:200
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition: dcode.h:193
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:204
bool m_InUse
false if the aperture (previously defined) is not used to draw something
Definition: dcode.h:198
void AppendParam(double aValue)
Add a parameter to the D_CODE parameter list.
Definition: dcode.h:91
unsigned GetParamCount() const
Return the number of parameters stored in parameter list.
Definition: dcode.h:99
APERTURE_MACRO * m_Macro
no ownership, points to GERBER.m_aperture_macros element.
Definition: dcode.h:210
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:189
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition: dcode.cpp:297
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Represent a set of closed polygons.
APERTURE_DEF_HOLETYPE
Definition: dcode.h:60
@ APT_DEF_NO_HOLE
Definition: dcode.h:61
@ APT_DEF_ROUND_HOLE
Definition: dcode.h:62
@ APT_DEF_RECT_HOLE
Definition: dcode.h:63
APERTURE_T
The set of all gerber aperture types allowed, according to page 16 of http://gerbv....
Definition: dcode.h:48
@ APT_RECT
Definition: dcode.h:50
@ APT_OVAL
Definition: dcode.h:51
@ APT_POLYGON
Definition: dcode.h:52
@ APT_CIRCLE
Definition: dcode.h:49
@ APT_MACRO
Definition: dcode.h:54