KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 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 _DCODE_H_
27#define _DCODE_H_
28
29#include <vector>
30
31#include <gal/color4d.h>
33
34using KIGFX::COLOR4D;
35
36class wxDC;
38
39
45 APT_CIRCLE = 'C', // Flashed shape: Circle with or without hole
46 APT_RECT = 'R', // Flashed shape: Rectangle with or without hole
47 APT_OVAL = '0', // Flashed shape: Oval with or without hole
48 APT_POLYGON = 'P', // Flashed shape: Regular polygon (3 to 12 edges)
49 // with or without hole. Can be rotated
50 APT_MACRO = 'M' // Complex shape given by a macro definition (see AM_PRIMITIVE_ID)
51};
52
53// In aperture definition, round, oval and rectangular flashed shapes
54// can have a hole (round or rectangular)
55// this option is stored in .m_DrillShape D_CODE member
61
62/* define min and max values for D Codes values.
63 * note: values >= 0 and < FIRST_DCODE can be used for special purposes (plot commands)
64 * Revision I1 permits apertures up to 2^31-1.
65 */
66#define FIRST_DCODE 10
67#define LAST_DCODE 0x7FFFFFFF
68
69class APERTURE_MACRO;
70
71
75class D_CODE
76{
77public:
78 D_CODE( int num_dcode );
79 ~D_CODE();
80
86 static bool IsValidDcodeValue( int aDcodeValue )
87 {
88 return aDcodeValue >= FIRST_DCODE;
89 }
90
91 void Clear_D_CODE_Data();
92
98 void AppendParam( double aValue )
99 {
100 m_am_params.push_back( aValue );
101 }
102
106 unsigned GetParamCount() const
107 {
108 return m_am_params.size();
109 }
110
117 double GetParam( unsigned aIdx ) const
118 {
119 wxASSERT( aIdx <= m_am_params.size() );
120
121 if( aIdx <= m_am_params.size() )
122 return m_am_params[aIdx - 1];
123 else
124 return 0;
125 }
126
127 void SetMacro( APERTURE_MACRO* aMacro )
128 {
129 m_Macro = aMacro;
130 }
131
132 APERTURE_MACRO* GetMacro() const { return m_Macro; }
133
139 static const wxChar* ShowApertureType( APERTURE_T aType );
140
152 void DrawFlashedShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
153 const COLOR4D& aColor,
154 const VECTOR2I& aShapePos, bool aFilledShape );
155
169 void DrawFlashedPolygon( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
170 const COLOR4D& aColor,
171 bool aFilled, const VECTOR2I& aPosition );
172
181 void ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent );
182
194 int GetShapeDim( GERBER_DRAW_ITEM* aParent );
195
196public:
207 bool m_InUse;
210 wxString m_AperFunction;
213 SHAPE_POLY_SET m_Polygon; /* Polygon used to draw APT_POLYGON shape and some other
214 * complex shapes which are converted to polygon
215 * (shapes with hole )
216 */
217
218private:
220
225 std::vector<double> m_am_params;
226};
227
228
229#endif // ifndef _DCODE_H_
Support the "aperture macro" defined within standard RS274X.
APERTURE_MACRO * GetMacro() const
Definition dcode.h:132
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:225
void Clear_D_CODE_Data()
Definition dcode.cpp:66
double GetParam(unsigned aIdx) const
Return a parameter stored in parameter list.
Definition dcode.h:117
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:149
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition dcode.h:210
int m_Num_Dcode
D code value ( >= 10 )
Definition dcode.h:200
D_CODE(int num_dcode)
Definition dcode.cpp:54
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:111
~D_CODE()
Definition dcode.cpp:61
static bool IsValidDcodeValue(int aDcodeValue)
Definition dcode.h:86
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:262
EDA_ANGLE m_Rotation
shape rotation
Definition dcode.h:204
VECTOR2I m_Drill
dimension of the hole (if any) (drill file)
Definition dcode.h:201
void SetMacro(APERTURE_MACRO *aMacro)
Definition dcode.h:127
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition dcode.h:205
static const wxChar * ShowApertureType(APERTURE_T aType)
Return a character string telling what type of aperture type aType is.
Definition dcode.cpp:82
VECTOR2I m_Size
Horizontal and vertical dimensions.
Definition dcode.h:197
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition dcode.h:198
bool m_Defined
false if the aperture is not defined in the header
Definition dcode.h:209
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition dcode.h:202
SHAPE_POLY_SET m_Polygon
Definition dcode.h:213
bool m_InUse
false if the aperture (previously defined) is not used to draw something
Definition dcode.h:207
void AppendParam(double aValue)
Add a parameter to the D_CODE parameter list.
Definition dcode.h:98
unsigned GetParamCount() const
Return the number of parameters stored in parameter list.
Definition dcode.h:106
APERTURE_MACRO * m_Macro
no ownership, points to GERBER.m_aperture_macros element.
Definition dcode.h:219
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition dcode.cpp:293
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Represent a set of closed polygons.
APERTURE_DEF_HOLETYPE
Definition dcode.h:56
@ APT_DEF_NO_HOLE
Definition dcode.h:57
@ APT_DEF_ROUND_HOLE
Definition dcode.h:58
@ APT_DEF_RECT_HOLE
Definition dcode.h:59
APERTURE_T
The set of all gerber aperture types allowed from ADD dcode command, like ADD11C,0....
Definition dcode.h:44
@ APT_RECT
Definition dcode.h:46
@ APT_OVAL
Definition dcode.h:47
@ APT_POLYGON
Definition dcode.h:48
@ APT_CIRCLE
Definition dcode.h:45
@ APT_MACRO
Definition dcode.h:50
#define FIRST_DCODE
Definition dcode.h:66
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683