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 <jean-pierre.charras@gipsa-lab.inpg.fr>
5  * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 1992-2010 KiCad Developers, see change_log.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 <base_struct.h>
36 #include <gal/color4d.h>
38 
39 using KIGFX::COLOR4D;
40 
41 class wxDC;
42 class GERBER_DRAW_ITEM;
43 
44 
50 enum APERTURE_T {
51  APT_CIRCLE = 'C', // Flashed shape: Circle with or without hole
52  APT_RECT = 'R', // Flashed shape: Rectangle with or without hole
53  APT_OVAL = '0', // Flashed shape: Oval with or without hole
54  APT_POLYGON = 'P', // Flashed shape: Regular polygon (3 to 12 edges)
55  // with or without hole. Can be rotated
56  APT_MACRO = 'M' // Complex shape given by a macro definition (see AM_PRIMITIVE_ID)
57 };
58 
59 // In aperture definition, round, oval and rectangular flashed shapes
60 // can have a hole (round or rectangular)
61 // this option is stored in .m_DrillShape D_CODE member
66 };
67 
68 /* define min and max values for D Codes values.
69  * note: values >= 0 and > FIRST_DCODE can be used for special purposes
70  */
71 #define FIRST_DCODE 10
72 #define LAST_DCODE 999
73 #define TOOLS_MAX_COUNT (LAST_DCODE + 1)
74 
75 struct APERTURE_MACRO;
76 
77 
82 class D_CODE
83 {
84 private:
86  // GERBER.m_aperture_macros element
91  std::vector<double> m_am_params;
92 
93 public:
94  wxSize m_Size;
97  wxSize m_Drill;
99  double m_Rotation;
101  bool m_InUse;
103  bool m_Defined;
105  wxString m_AperFunction;
106  SHAPE_POLY_SET m_Polygon; /* Polygon used to draw APT_POLYGON shape and some other
108  * complex shapes which are converted to polygon
109  * (shapes with hole )
110  */
111 
112 public:
113  D_CODE( int num_dcode );
114  ~D_CODE();
115  void Clear_D_CODE_Data();
116 
122  void AppendParam( double aValue )
123  {
124  m_am_params.push_back( aValue );
125  }
126 
131  unsigned GetParamCount() const
132  {
133  return m_am_params.size();
134  }
135 
141  double GetParam( unsigned aIdx ) const
142  {
143  wxASSERT( aIdx <= m_am_params.size() );
144  if( aIdx <= m_am_params.size() )
145  return m_am_params[aIdx - 1];
146  else
147  return 0;
148  }
149 
150 
151  void SetMacro( APERTURE_MACRO* aMacro )
152  {
153  m_Macro = aMacro;
154  }
155 
156 
157  APERTURE_MACRO* GetMacro() const { return m_Macro; }
158 
164  static const wxChar* ShowApertureType( APERTURE_T aType );
165 
177  void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox,
178  wxDC* aDC, COLOR4D aColor,
179  wxPoint aShapePos, bool aFilledShape );
180 
194  void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
195  EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor,
196  bool aFilled, const wxPoint& aPosition );
197 
205  void ConvertShapeToPolygon();
206 
218  int GetShapeDim( GERBER_DRAW_ITEM* aParent );
219 };
220 
221 
222 #endif // ifndef _DCODE_H_
double GetParam(unsigned aIdx) const
GetParam() Returns a parameter stored in parameter list.
Definition: dcode.h:141
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
Definition: dcode.h:53
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
double m_Rotation
shape rotation in degrees
Definition: dcode.h:99
APERTURE_MACRO * m_Macro
no ownership, points to
Definition: dcode.h:85
wxSize m_Drill
dimension of the hole (if any) (draill file)
Definition: dcode.h:97
Definition: dcode.h:52
APERTURE_DEF_HOLETYPE
Definition: dcode.h:62
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:104
D_CODE(int num_dcode)
Definition: dcode.cpp:67
void AppendParam(double aValue)
AppendParam() Add a parameter to the D_CODE parameter list.
Definition: dcode.h:122
Class SHAPE_POLY_SET.
APERTURE_T
Enum APERTURE_T is the set of all gerber aperture types allowed, according to page 16 of http://gerbv...
Definition: dcode.h:50
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
static const wxChar * ShowApertureType(APERTURE_T aType)
Function ShowApertureType returns a character string telling what type of aperture type aType is...
Definition: dcode.cpp:95
unsigned GetParamCount() const
GetParamCount() Returns the number of parameters stored in parameter list.
Definition: dcode.h:131
void DrawFlashedPolygon(GERBER_DRAW_ITEM *aParent, EDA_RECT *aClipBox, wxDC *aDC, COLOR4D aColor, bool aFilled, const wxPoint &aPosition)
Function DrawFlashedPolygon a helper function used to draw the polygon stored ion m_PolyCorners Draw ...
Definition: dcode.cpp:270
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE ...
Definition: dcode.h:105
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
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:91
void DrawFlashedShape(GERBER_DRAW_ITEM *aParent, EDA_RECT *aClipBox, wxDC *aDC, COLOR4D aColor, wxPoint aShapePos, bool aFilledShape)
Function DrawFlashedShape Draw the dcode shape for flashed items.
Definition: dcode.cpp:154
Class EDA_RECT handles the component boundary box.
void SetMacro(APERTURE_MACRO *aMacro)
Definition: dcode.h:151
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:107
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition: dcode.h:100
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:157
void ConvertShapeToPolygon()
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
Definition: dcode.cpp:303
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
Basic classes for most KiCad items.
int GetShapeDim(GERBER_DRAW_ITEM *aParent)
Function GetShapeDim calculates a value that can be used to evaluate the size of text when displaying...
Definition: dcode.cpp:123
~D_CODE()
Definition: dcode.cpp:74
void Clear_D_CODE_Data()
Definition: dcode.cpp:79
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39