KiCad PCB EDA Suite
D_CODE Class Reference

D_CODE holds a gerber DCODE (also called Aperture) definition. More...

#include <dcode.h>

Public Member Functions

 D_CODE (int num_dcode)
 
 ~D_CODE ()
 
void Clear_D_CODE_Data ()
 
void AppendParam (double aValue)
 AppendParam() Add a parameter to the D_CODE parameter list. More...
 
unsigned GetParamCount () const
 GetParamCount() Returns the number of parameters stored in parameter list. More...
 
double GetParam (unsigned aIdx) const
 GetParam() Returns a parameter stored in parameter list. More...
 
void SetMacro (APERTURE_MACRO *aMacro)
 
APERTURE_MACROGetMacro () const
 
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. More...
 
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 some Apertures shapes when they are defined as filled polygons. More...
 
void ConvertShapeToPolygon ()
 Function ConvertShapeToPolygon convert a shape to an equivalent polygon. More...
 
int GetShapeDim (GERBER_DRAW_ITEM *aParent)
 Function GetShapeDim calculates a value that can be used to evaluate the size of text when displaying the D-Code of an item due to the complexity of some shapes, one cannot calculate the "size" of a shape (only a bounding box) but here, the "dimension" of the shape is the diameter of the primitive or for lines the width of the line if the shape is a line. More...
 

Static Public Member Functions

static const wxChar * ShowApertureType (APERTURE_T aType)
 Function ShowApertureType returns a character string telling what type of aperture type aType is. More...
 

Public Attributes

wxSize m_Size
 Horizontal and vertical dimensions. More...
 
APERTURE_T m_Shape
 shape ( Line, rectangle, circle , oval .. ) More...
 
int m_Num_Dcode
 D code value ( >= 10 ) More...
 
wxSize m_Drill
 dimension of the hole (if any) (draill file) More...
 
APERTURE_DEF_HOLETYPE m_DrillShape
 shape of the hole (0 = no hole, round = 1, rect = 2) */ More...
 
double m_Rotation
 shape rotation in degrees More...
 
int m_EdgesCount
 in aperture definition Polygon only: number of edges for the polygon More...
 
bool m_InUse
 false if the aperure (previously defined) is not used to draw something More...
 
bool m_Defined
 false if the aperture is not defined in the header More...
 
wxString m_AperFunction
 the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE More...
 
SHAPE_POLY_SET m_Polygon
 

Private Attributes

APERTURE_MACROm_Macro
 no ownership, points to More...
 
std::vector< double > m_am_params
 parameters used only when this D_CODE holds a reference to an aperture macro, and these parameters would customize the macro. More...
 

Detailed Description

D_CODE holds a gerber DCODE (also called Aperture) definition.

Definition at line 82 of file dcode.h.

Constructor & Destructor Documentation

◆ D_CODE()

D_CODE::D_CODE ( int  num_dcode)

Definition at line 64 of file dcode.cpp.

65 {
66  m_Num_Dcode = num_dcode;
68 }
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
void Clear_D_CODE_Data()
Definition: dcode.cpp:76

References Clear_D_CODE_Data(), and m_Num_Dcode.

◆ ~D_CODE()

D_CODE::~D_CODE ( )

Definition at line 71 of file dcode.cpp.

72 {
73 }

Member Function Documentation

◆ AppendParam()

void D_CODE::AppendParam ( double  aValue)
inline

AppendParam() Add a parameter to the D_CODE parameter list.

used to customize the corresponding aperture macro

Definition at line 122 of file dcode.h.

123  {
124  m_am_params.push_back( aValue );
125  }
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

References m_am_params.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ Clear_D_CODE_Data()

void D_CODE::Clear_D_CODE_Data ( )

Definition at line 76 of file dcode.cpp.

77 {
81  m_Drill.x = m_Drill.y = 0;
83  m_InUse = false;
84  m_Defined = false;
85  m_Macro = NULL;
86  m_Rotation = 0.0;
87  m_EdgesCount = 0;
89 }
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
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
#define DCODE_DEFAULT_SIZE
Definition: dcode.cpp:38
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:104
#define NULL
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
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

References APT_CIRCLE, APT_DEF_NO_HOLE, DCODE_DEFAULT_SIZE, m_Defined, m_Drill, m_DrillShape, m_EdgesCount, m_InUse, m_Macro, m_Polygon, m_Rotation, m_Shape, m_Size, NULL, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by D_CODE(), and GERBER_FILE_IMAGE::InitToolTable().

◆ ConvertShapeToPolygon()

void D_CODE::ConvertShapeToPolygon ( )

Function ConvertShapeToPolygon convert a shape to an equivalent polygon.

Arcs and circles are approximated by segments Useful when a shape is not a graphic primitive (shape with hole, rotated shape ... ) and cannot be easily drawn.

Definition at line 300 of file dcode.cpp.

301 {
302  wxPoint initialpos;
303  wxPoint currpos;
304 
306 
307  switch( m_Shape )
308  {
309  case APT_CIRCLE: // creates only a circle with rectangular hole
310  TransformCircleToPolygon( m_Polygon, initialpos, m_Size.x >> 1, ARC_HIGH_DEF,
311  ERROR_INSIDE );
313  break;
314 
315  case APT_RECT:
317  currpos.x = m_Size.x / 2;
318  currpos.y = m_Size.y / 2;
319  initialpos = currpos;
320  m_Polygon.Append( VECTOR2I( currpos ) );
321  currpos.x -= m_Size.x;
322  m_Polygon.Append( VECTOR2I( currpos ) );
323  currpos.y -= m_Size.y;
324  m_Polygon.Append( VECTOR2I( currpos ) );
325  currpos.x += m_Size.x;
326  m_Polygon.Append( VECTOR2I( currpos ) );
327  currpos.y += m_Size.y;
328  m_Polygon.Append( VECTOR2I( currpos ) ); // close polygon
329  m_Polygon.Append( VECTOR2I( initialpos ) );
330 
332  break;
333 
334  case APT_OVAL:
335  {
337  int delta, radius;
338 
339  // we create an horizontal oval shape. then rotate if needed
340  if( m_Size.x > m_Size.y ) // horizontal oval
341  {
342  delta = (m_Size.x - m_Size.y) / 2;
343  radius = m_Size.y / 2;
344  }
345  else // vertical oval
346  {
347  delta = (m_Size.y - m_Size.x) / 2;
348  radius = m_Size.x / 2;
349  }
350 
351  currpos.y = radius;
352  initialpos = currpos;
353  m_Polygon.Append( VECTOR2I( currpos ) );
354 
355  // build the right arc of the shape
356  unsigned ii = 0;
357 
358  for( ; ii <= SEGS_CNT / 2; ii++ )
359  {
360  currpos = initialpos;
361  RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
362  currpos.x += delta;
363  m_Polygon.Append( VECTOR2I( currpos ) );
364  }
365 
366  // build the left arc of the shape
367  for( ii = SEGS_CNT / 2; ii <= SEGS_CNT; ii++ )
368  {
369  currpos = initialpos;
370  RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
371  currpos.x -= delta;
372  m_Polygon.Append( VECTOR2I( currpos ) );
373  }
374 
375  m_Polygon.Append( VECTOR2I( initialpos ) ); // close outline
376 
377  if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon.
378  m_Polygon.Rotate( -M_PI / 2 );
379 
381  }
382  break;
383 
384  case APT_POLYGON:
386  currpos.x = m_Size.x >> 1; // first point is on X axis
387  initialpos = currpos;
388 
389  // rs274x said: m_EdgesCount = 3 ... 12
390  if( m_EdgesCount < 3 )
391  m_EdgesCount = 3;
392 
393  if( m_EdgesCount > 12 )
394  m_EdgesCount = 12;
395 
396  for( int ii = 0; ii < m_EdgesCount; ii++ )
397  {
398  currpos = initialpos;
399  RotatePoint( &currpos, ii * 3600.0 / m_EdgesCount );
400  m_Polygon.Append( VECTOR2I( currpos ) );
401  }
402 
404 
405  if( m_Rotation ) // rotate polygonal shape:
406  {
407  double angle = m_Rotation * M_PI / 180;
408  m_Polygon.Rotate( angle, VECTOR2I( 0, 0 ) );
409  }
410 
411  break;
412 
413  case APT_MACRO:
414 
415  // TODO
416  break;
417  }
418 }
static void addHoleToPolygon(SHAPE_POLY_SET *aPolygon, APERTURE_DEF_HOLETYPE aHoleShape, wxSize aSize, wxPoint aAnchorPos)
Definition: dcode.cpp:423
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
Definition: dcode.h:53
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
double m_Rotation
shape rotation in degrees
Definition: dcode.h:99
wxSize m_Drill
dimension of the hole (if any) (draill file)
Definition: dcode.h:97
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Definition: dcode.h:52
#define SEGS_CNT
Definition: dcode.cpp:290
int NewOutline()
Creates a new hole in a given outline.
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
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
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References addHoleToPolygon(), PNS::angle(), SHAPE_POLY_SET::Append(), APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, ERROR_INSIDE, m_Drill, m_DrillShape, m_EdgesCount, m_Polygon, m_Rotation, m_Shape, m_Size, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Rotate(), RotatePoint(), SEGS_CNT, and TransformCircleToPolygon().

Referenced by DrawFlashedShape(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), GBR_TO_PCB_EXPORTER::export_flashed_copper_item(), GBR_TO_PCB_EXPORTER::export_non_copper_item(), and GERBER_DRAW_ITEM::GetBoundingBox().

◆ DrawFlashedPolygon()

void D_CODE::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 some Apertures shapes when they are defined as filled polygons.

APT_POLYGON is always a polygon, but some complex shapes are also converted to polygons (shapes with holes, some rotated shapes)

Parameters
aParent= the GERBER_DRAW_ITEM being drawn
aClipBox= DC clip box (NULL is no clip)
aDC= device context
aColor= the normal color to use
aFilled= true to draw in filled mode, false to draw in sketch mode
aPosition= the actual shape position

Definition at line 267 of file dcode.cpp.

271 {
272  if( m_Polygon.OutlineCount() == 0 )
273  return;
274 
275  int pointCount = m_Polygon.VertexCount();
276  std::vector<wxPoint> points;
277  points.reserve( pointCount );
278 
279  for( int ii = 0; ii < pointCount; ii++ )
280  {
281  wxPoint p( m_Polygon.CVertex( ii ).x, m_Polygon.CVertex( ii ).y );
282  points[ii] = p + aPosition;
283  points[ii] = aParent->GetABPosition( points[ii] );
284  }
285 
286  GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor );
287 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
int VertexCount(int aOutline=-1, int aHole=-1) const
Returns the number of holes in a given outline.
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return the image position of aPosition for this object.
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:107
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, COLOR4D Color, COLOR4D BgColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:550

References SHAPE_POLY_SET::CVertex(), GERBER_DRAW_ITEM::GetABPosition(), GRClosedPoly(), m_Polygon, SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::VertexCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DrawFlashedShape().

◆ DrawFlashedShape()

void D_CODE::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.

When an item is flashed, the DCode shape is the shape of the item

Parameters
aParent= the GERBER_DRAW_ITEM being drawn
aClipBox= DC clip box (NULL is no clip)
aDC= device context
aColor= the normal color to use
aShapePos= the actual shape position
aFilledShape= true to draw in filled mode, false to draw in sketch mode

Definition at line 151 of file dcode.cpp.

154 {
155  int radius;
156 
157  switch( m_Shape )
158  {
159  case APT_MACRO:
160  GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor,
161  aShapePos, aFilledShape);
162  break;
163 
164  case APT_CIRCLE:
165  radius = m_Size.x >> 1;
166  if( !aFilledShape )
167  GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius, 0, aColor );
168  else
170  {
171  GRFilledCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
172  radius, aColor );
173  }
174  else if( m_DrillShape == APT_DEF_ROUND_HOLE ) // round hole in shape
175  {
176  int width = (m_Size.x - m_Drill.x ) / 2;
177  GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
178  radius - (width / 2), width, aColor );
179  }
180  else // rectangular hole
181  {
182  if( m_Polygon.OutlineCount() == 0 )
184 
185  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
186  }
187  break;
188 
189  case APT_RECT:
190  {
191  wxPoint start;
192  start.x = aShapePos.x - m_Size.x / 2;
193  start.y = aShapePos.y - m_Size.y / 2;
194  wxPoint end = start + m_Size;
195  start = aParent->GetABPosition( start );
196  end = aParent->GetABPosition( end );
197 
198  if( !aFilledShape )
199  {
200  GRRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor );
201  }
202  else if( m_DrillShape == APT_DEF_NO_HOLE )
203  {
204  GRFilledRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor, aColor );
205  }
206  else
207  {
208  if( m_Polygon.OutlineCount() == 0 )
210 
211  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
212  }
213  }
214  break;
215 
216  case APT_OVAL:
217  {
218  wxPoint start = aShapePos;
219  wxPoint end = aShapePos;
220 
221  if( m_Size.x > m_Size.y ) // horizontal oval
222  {
223  int delta = (m_Size.x - m_Size.y) / 2;
224  start.x -= delta;
225  end.x += delta;
226  radius = m_Size.y; // Width in fact
227  }
228  else // vertical oval
229  {
230  int delta = (m_Size.y - m_Size.x) / 2;
231  start.y -= delta;
232  end.y += delta;
233  radius = m_Size.x; // Width in fact
234  }
235 
236  start = aParent->GetABPosition( start );
237  end = aParent->GetABPosition( end );
238 
239  if( !aFilledShape )
240  {
241  GRCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor );
242  }
243  else if( m_DrillShape == APT_DEF_NO_HOLE )
244  {
245  GRFillCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor );
246  }
247  else
248  {
249  if( m_Polygon.OutlineCount() == 0 )
251 
252  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
253  }
254  }
255  break;
256 
257  case APT_POLYGON:
258  if( m_Polygon.OutlineCount() == 0 )
260 
261  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
262  break;
263  }
264 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
Definition: dcode.h:53
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
void DrawApertureMacroShape(GERBER_DRAW_ITEM *aParent, EDA_RECT *aClipBox, wxDC *aDC, COLOR4D aColor, wxPoint aShapePos, bool aFilledShape)
Function DrawApertureMacroShape Draw the primitive shape for flashed items.
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:882
wxSize m_Drill
dimension of the hole (if any) (draill file)
Definition: dcode.h:97
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:310
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:617
Definition: dcode.h:52
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:842
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return the image position of aPosition for this object.
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:413
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:267
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:594
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:107
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:157
void ConvertShapeToPolygon()
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
Definition: dcode.cpp:300

References APT_CIRCLE, APT_DEF_NO_HOLE, APT_DEF_ROUND_HOLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, ConvertShapeToPolygon(), APERTURE_MACRO::DrawApertureMacroShape(), DrawFlashedPolygon(), GERBER_DRAW_ITEM::GetABPosition(), GetMacro(), GRCircle(), GRCSegm(), GRFillCSegm(), GRFilledCircle(), GRFilledRect(), GRRect(), m_Drill, m_DrillShape, m_Polygon, m_Shape, m_Size, and SHAPE_POLY_SET::OutlineCount().

Referenced by GERBER_DRAW_ITEM::Print().

◆ GetMacro()

◆ GetParam()

double D_CODE::GetParam ( unsigned  aIdx) const
inline

GetParam() Returns a parameter stored in parameter list.

Parameters
aIdx= index of parameter

Definition at line 141 of file dcode.h.

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  }
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

References m_am_params.

Referenced by AM_PARAM::GetValue().

◆ GetParamCount()

unsigned D_CODE::GetParamCount ( ) const
inline

GetParamCount() Returns the number of parameters stored in parameter list.

Definition at line 131 of file dcode.h.

132  {
133  return m_am_params.size();
134  }
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

References m_am_params.

Referenced by AM_PARAM::GetValue().

◆ GetShapeDim()

int D_CODE::GetShapeDim ( GERBER_DRAW_ITEM aParent)

Function GetShapeDim calculates a value that can be used to evaluate the size of text when displaying the D-Code of an item due to the complexity of some shapes, one cannot calculate the "size" of a shape (only a bounding box) but here, the "dimension" of the shape is the diameter of the primitive or for lines the width of the line if the shape is a line.

Parameters
aParent= the parent GERBER_DRAW_ITEM which is actually drawn
Returns
a dimension, or -1 if no dim to calculate

Definition at line 120 of file dcode.cpp.

121 {
122  int dim = -1;
123  switch( m_Shape )
124  {
125  case APT_CIRCLE:
126  dim = m_Size.x;
127  break;
128 
129  case APT_RECT:
130  case APT_OVAL:
131  dim = std::min( m_Size.x, m_Size.y );
132  break;
133 
134  case APT_POLYGON:
135  dim = std::min( m_Size.x, m_Size.y );
136  break;
137 
138  case APT_MACRO:
139  if( m_Macro )
140  dim = m_Macro->GetShapeDim( aParent );
141  break;
142 
143  default:
144  break;
145  }
146 
147  return dim;
148 }
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
Definition: dcode.h:53
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
APERTURE_MACRO * m_Macro
no ownership, points to
Definition: dcode.h:85
Definition: dcode.h:52
int GetShapeDim(GERBER_DRAW_ITEM *aParent)
Function GetShapeDim Calculate a value that can be used to evaluate the size of text when displaying ...

References APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, APERTURE_MACRO::GetShapeDim(), m_Macro, m_Shape, and m_Size.

Referenced by GERBER_DRAW_ITEM::GetTextD_CodePrms().

◆ SetMacro()

void D_CODE::SetMacro ( APERTURE_MACRO aMacro)
inline

Definition at line 151 of file dcode.h.

152  {
153  m_Macro = aMacro;
154  }
APERTURE_MACRO * m_Macro
no ownership, points to
Definition: dcode.h:85

References m_Macro.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ ShowApertureType()

const wxChar * D_CODE::ShowApertureType ( APERTURE_T  aType)
static

Function ShowApertureType returns a character string telling what type of aperture type aType is.

Parameters
aTypeThe aperture type to show.

Definition at line 92 of file dcode.cpp.

93 {
94  const wxChar* ret;
95 
96  switch( aType )
97  {
98  case APT_CIRCLE:
99  ret = wxT( "Round" ); break;
100 
101  case APT_RECT:
102  ret = wxT( "Rect" ); break;
103 
104  case APT_OVAL:
105  ret = wxT( "Oval" ); break;
106 
107  case APT_POLYGON:
108  ret = wxT( "Poly" ); break;
109 
110  case APT_MACRO:
111  ret = wxT( "Macro" ); break;
112 
113  default:
114  ret = wxT( "???" ); break;
115  }
116 
117  return ret;
118 }
Definition: dcode.h:53
Definition: dcode.h:52

References APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, and APT_RECT.

Referenced by GERBVIEW_INSPECTION_TOOL::ShowDCodes(), and GERBVIEW_FRAME::updateDCodeSelectBox().

Member Data Documentation

◆ m_am_params

std::vector<double> D_CODE::m_am_params
private

parameters used only when this D_CODE holds a reference to an aperture macro, and these parameters would customize the macro.

Definition at line 91 of file dcode.h.

Referenced by AppendParam(), GetParam(), and GetParamCount().

◆ m_AperFunction

◆ m_Defined

◆ m_Drill

wxSize D_CODE::m_Drill

dimension of the hole (if any) (draill file)

Definition at line 97 of file dcode.h.

Referenced by Clear_D_CODE_Data(), ConvertShapeToPolygon(), DrawFlashedShape(), and GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ m_DrillShape

APERTURE_DEF_HOLETYPE D_CODE::m_DrillShape

shape of the hole (0 = no hole, round = 1, rect = 2) */

Definition at line 98 of file dcode.h.

Referenced by Clear_D_CODE_Data(), ConvertShapeToPolygon(), DrawFlashedShape(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), and GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ m_EdgesCount

int D_CODE::m_EdgesCount

in aperture definition Polygon only: number of edges for the polygon

Definition at line 100 of file dcode.h.

Referenced by Clear_D_CODE_Data(), ConvertShapeToPolygon(), and GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ m_InUse

◆ m_Macro

APERTURE_MACRO* D_CODE::m_Macro
private

no ownership, points to

Definition at line 85 of file dcode.h.

Referenced by Clear_D_CODE_Data(), GetMacro(), GetShapeDim(), and SetMacro().

◆ m_Num_Dcode

◆ m_Polygon

◆ m_Rotation

double D_CODE::m_Rotation

shape rotation in degrees

Definition at line 99 of file dcode.h.

Referenced by Clear_D_CODE_Data(), ConvertShapeToPolygon(), and GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ m_Shape

◆ m_Size


The documentation for this class was generated from the following files: