KiCad PCB EDA Suite
D_CODE Class Reference

Class 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

Class 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 65 of file dcode.cpp.

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

References Clear_D_CODE_Data(), and m_Num_Dcode.

◆ ~D_CODE()

D_CODE::~D_CODE ( )

Definition at line 72 of file dcode.cpp.

73 {
74 }

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 77 of file dcode.cpp.

78 {
82  m_Drill.x = m_Drill.y = 0;
84  m_InUse = false;
85  m_Defined = false;
86  m_Macro = NULL;
87  m_Rotation = 0.0;
88  m_EdgesCount = 0;
90 }
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:39
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:104
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
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, 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 301 of file dcode.cpp.

302 {
303  wxPoint initialpos;
304  wxPoint currpos;
305 
307 
308  switch( m_Shape )
309  {
310  case APT_CIRCLE: // creates only a circle with rectangular hole
311  TransformCircleToPolygon( m_Polygon, initialpos, m_Size.x >> 1, ARC_HIGH_DEF );
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  {
379  for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
380  it->Rotate( -M_PI / 2 );
381  }
382 
384  }
385  break;
386 
387  case APT_POLYGON:
389  currpos.x = m_Size.x >> 1; // first point is on X axis
390  initialpos = currpos;
391 
392  // rs274x said: m_EdgesCount = 3 ... 12
393  if( m_EdgesCount < 3 )
394  m_EdgesCount = 3;
395 
396  if( m_EdgesCount > 12 )
397  m_EdgesCount = 12;
398 
399  for( int ii = 0; ii < m_EdgesCount; ii++ )
400  {
401  currpos = initialpos;
402  RotatePoint( &currpos, ii * 3600.0 / m_EdgesCount );
403  m_Polygon.Append( VECTOR2I( currpos ) );
404  }
405 
407 
408  if( m_Rotation ) // rotate polygonal shape:
409  {
410  double angle = m_Rotation * M_PI / 180;
411  m_Polygon.Rotate( angle, VECTOR2I( 0, 0 ) );
412  }
413 
414  break;
415 
416  case APT_MACRO:
417 
418  // TODO
419  break;
420  }
421 }
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, wxPoint aCenter, int aRadius, int aError)
static void addHoleToPolygon(SHAPE_POLY_SET *aPolygon, APERTURE_DEF_HOLETYPE aHoleShape, wxSize aSize, wxPoint aAnchorPos)
Definition: dcode.cpp:426
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 RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
Definition: dcode.h:52
#define SEGS_CNT
Definition: dcode.cpp:291
int NewOutline()
Creates a new empty polygon in the set and returns its index
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)
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
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 Rotate(double aAngle, const VECTOR2I &aCenter)
Function Rotate rotates all vertices by a given angle.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References addHoleToPolygon(), PNS::angle(), SHAPE_POLY_SET::Append(), APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, SHAPE_POLY_SET::Iterate(), 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(), 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 268 of file dcode.cpp.

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

References GERBER_DRAW_ITEM::GetABPosition(), GRClosedPoly(), m_Polygon, SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::Vertex(), 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 152 of file dcode.cpp.

155 {
156  int radius;
157 
158  switch( m_Shape )
159  {
160  case APT_MACRO:
161  GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor,
162  aShapePos, aFilledShape);
163  break;
164 
165  case APT_CIRCLE:
166  radius = m_Size.x >> 1;
167  if( !aFilledShape )
168  GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius, 0, aColor );
169  else
171  {
172  GRFilledCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
173  radius, aColor );
174  }
175  else if( m_DrillShape == APT_DEF_ROUND_HOLE ) // round hole in shape
176  {
177  int width = (m_Size.x - m_Drill.x ) / 2;
178  GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
179  radius - (width / 2), width, aColor );
180  }
181  else // rectangular hole
182  {
183  if( m_Polygon.OutlineCount() == 0 )
185 
186  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
187  }
188  break;
189 
190  case APT_RECT:
191  {
192  wxPoint start;
193  start.x = aShapePos.x - m_Size.x / 2;
194  start.y = aShapePos.y - m_Size.y / 2;
195  wxPoint end = start + m_Size;
196  start = aParent->GetABPosition( start );
197  end = aParent->GetABPosition( end );
198 
199  if( !aFilledShape )
200  {
201  GRRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor );
202  }
203  else if( m_DrillShape == APT_DEF_NO_HOLE )
204  {
205  GRFilledRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor, aColor );
206  }
207  else
208  {
209  if( m_Polygon.OutlineCount() == 0 )
211 
212  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
213  }
214  }
215  break;
216 
217  case APT_OVAL:
218  {
219  wxPoint start = aShapePos;
220  wxPoint end = aShapePos;
221 
222  if( m_Size.x > m_Size.y ) // horizontal oval
223  {
224  int delta = (m_Size.x - m_Size.y) / 2;
225  start.x -= delta;
226  end.x += delta;
227  radius = m_Size.y;
228  }
229  else // horizontal oval
230  {
231  int delta = (m_Size.y - m_Size.x) / 2;
232  start.y -= delta;
233  end.y += delta;
234  radius = m_Size.x;
235  }
236 
237  start = aParent->GetABPosition( start );
238  end = aParent->GetABPosition( end );
239 
240  if( !aFilledShape )
241  {
242  GRCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor );
243  }
244  else if( m_DrillShape == APT_DEF_NO_HOLE )
245  {
246  GRFillCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor );
247  }
248  else
249  {
250  if( m_Polygon.OutlineCount() == 0 )
252 
253  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
254  }
255  }
256  break;
257 
258  case APT_POLYGON:
259  if( m_Polygon.OutlineCount() == 0 )
261 
262  DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
263  break;
264  }
265 }
int OutlineCount() const
Returns the number of outlines in the set
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:888
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:312
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:623
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:848
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns 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:415
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:268
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:600
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:301

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 121 of file dcode.cpp.

122 {
123  int dim = -1;
124  switch( m_Shape )
125  {
126  case APT_CIRCLE:
127  dim = m_Size.x;
128  break;
129 
130  case APT_RECT:
131  case APT_OVAL:
132  dim = std::min( m_Size.x, m_Size.y );
133  break;
134 
135  case APT_POLYGON:
136  dim = std::min( m_Size.x, m_Size.y );
137  break;
138 
139  case APT_MACRO:
140  if( m_Macro )
141  dim = m_Macro->GetShapeDim( aParent );
142  break;
143 
144  default:
145  break;
146  }
147 
148  return dim;
149 }
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 ...
#define min(a, b)
Definition: auxiliary.h:85

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

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 93 of file dcode.cpp.

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

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

Referenced by GERBVIEW_FRAME::Liste_D_Codes(), 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: