KiCad PCB EDA Suite
D_CODE Class Reference

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)
 Add a parameter to the D_CODE parameter list. More...
 
unsigned GetParamCount () const
 Return the number of parameters stored in parameter list. More...
 
double GetParam (unsigned aIdx) const
 Return 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, const COLOR4D &aColor, const wxPoint &aShapePos, bool aFilledShape)
 Draw the dcode shape for flashed items. More...
 
void DrawFlashedPolygon (GERBER_DRAW_ITEM *aParent, EDA_RECT *aClipBox, wxDC *aDC, const COLOR4D &aColor, bool aFilled, const wxPoint &aPosition)
 A helper function used to draw the polygon stored in m_PolyCorners. More...
 
void ConvertShapeToPolygon ()
 Convert a shape to an equivalent polygon. More...
 
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. More...
 

Static Public Member Functions

static const wxChar * ShowApertureType (APERTURE_T aType)
 Return 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) (drill 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 aperture (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). More...
 
SHAPE_POLY_SET m_Polygon
 

Private Attributes

APERTURE_MACROm_Macro
 no ownership, points to GERBER.m_aperture_macros element. 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

A gerber DCODE (also called Aperture) definition.

Definition at line 80 of file dcode.h.

Constructor & Destructor Documentation

◆ D_CODE()

D_CODE::D_CODE ( int  num_dcode)

Definition at line 59 of file dcode.cpp.

60 {
61  m_Num_Dcode = num_dcode;
63 }
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:190
void Clear_D_CODE_Data()
Definition: dcode.cpp:71

References Clear_D_CODE_Data(), and m_Num_Dcode.

◆ ~D_CODE()

D_CODE::~D_CODE ( )

Definition at line 66 of file dcode.cpp.

67 {
68 }

Member Function Documentation

◆ AppendParam()

void D_CODE::AppendParam ( double  aValue)
inline

Add a parameter to the D_CODE parameter list.

Used to customize the corresponding aperture macro.

Definition at line 92 of file dcode.h.

93  {
94  m_am_params.push_back( aValue );
95  }
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:215

References m_am_params.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ Clear_D_CODE_Data()

void D_CODE::Clear_D_CODE_Data ( )

Definition at line 71 of file dcode.cpp.

72 {
76  m_Drill.x = m_Drill.y = 0;
78  m_InUse = false;
79  m_Defined = false;
80  m_Macro = nullptr;
81  m_Rotation = 0.0;
82  m_EdgesCount = 0;
84 }
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:188
bool m_InUse
false if the aperture (previously defined) is not used to draw something
Definition: dcode.h:197
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:189
double m_Rotation
shape rotation in degrees
Definition: dcode.h:194
APERTURE_MACRO * m_Macro
no ownership, points to GERBER.m_aperture_macros element.
Definition: dcode.h:209
wxSize m_Drill
dimension of the hole (if any) (drill file)
Definition: dcode.h:191
#define DCODE_DEFAULT_SIZE
Definition: dcode.cpp:38
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:199
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition: dcode.h:192
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:203
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition: dcode.h:195

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 ( )

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

299 {
300  wxPoint initialpos;
301  wxPoint currpos;
302 
304 
305  switch( m_Shape )
306  {
307  case APT_CIRCLE: // creates only a circle with rectangular hole
308  TransformCircleToPolygon( m_Polygon, initialpos, m_Size.x >> 1, ARC_HIGH_DEF,
309  ERROR_INSIDE );
311  break;
312 
313  case APT_RECT:
315  currpos.x = m_Size.x / 2;
316  currpos.y = m_Size.y / 2;
317  initialpos = currpos;
318  m_Polygon.Append( VECTOR2I( currpos ) );
319  currpos.x -= m_Size.x;
320  m_Polygon.Append( VECTOR2I( currpos ) );
321  currpos.y -= m_Size.y;
322  m_Polygon.Append( VECTOR2I( currpos ) );
323  currpos.x += m_Size.x;
324  m_Polygon.Append( VECTOR2I( currpos ) );
325  currpos.y += m_Size.y;
326  m_Polygon.Append( VECTOR2I( currpos ) ); // close polygon
327  m_Polygon.Append( VECTOR2I( initialpos ) );
328 
330  break;
331 
332  case APT_OVAL:
333  {
335  int delta, radius;
336 
337  // we create an horizontal oval shape. then rotate if needed
338  if( m_Size.x > m_Size.y ) // horizontal oval
339  {
340  delta = ( m_Size.x - m_Size.y ) / 2;
341  radius = m_Size.y / 2;
342  }
343  else // vertical oval
344  {
345  delta = (m_Size.y - m_Size.x) / 2;
346  radius = m_Size.x / 2;
347  }
348 
349  currpos.y = radius;
350  initialpos = currpos;
351  m_Polygon.Append( VECTOR2I( currpos ) );
352 
353  // build the right arc of the shape
354  unsigned ii = 0;
355 
356  for( ; ii <= SEGS_CNT / 2; ii++ )
357  {
358  currpos = initialpos;
359  RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
360  currpos.x += delta;
361  m_Polygon.Append( VECTOR2I( currpos ) );
362  }
363 
364  // build the left arc of the shape
365  for( ii = SEGS_CNT / 2; ii <= SEGS_CNT; ii++ )
366  {
367  currpos = initialpos;
368  RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
369  currpos.x -= delta;
370  m_Polygon.Append( VECTOR2I( currpos ) );
371  }
372 
373  m_Polygon.Append( VECTOR2I( initialpos ) ); // close outline
374 
375  if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon.
376  m_Polygon.Rotate( -M_PI / 2 );
377 
379  }
380 
381  break;
382 
383  case APT_POLYGON:
385  currpos.x = m_Size.x >> 1; // first point is on X axis
386  initialpos = currpos;
387 
388  // rs274x said: m_EdgesCount = 3 ... 12
389  if( m_EdgesCount < 3 )
390  m_EdgesCount = 3;
391 
392  if( m_EdgesCount > 12 )
393  m_EdgesCount = 12;
394 
395  for( int ii = 0; ii < m_EdgesCount; ii++ )
396  {
397  currpos = initialpos;
398  RotatePoint( &currpos, ii * 3600.0 / m_EdgesCount );
399  m_Polygon.Append( VECTOR2I( currpos ) );
400  }
401 
403 
404  if( m_Rotation ) // rotate polygonal shape:
405  {
406  double angle = m_Rotation * M_PI / 180;
407  m_Polygon.Rotate( angle, VECTOR2I( 0, 0 ) );
408  }
409 
410  break;
411 
412  case APT_MACRO:
413 
414  // TODO
415  break;
416  }
417 }
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:188
Definition: dcode.h:52
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:189
double m_Rotation
shape rotation in degrees
Definition: dcode.h:194
wxSize m_Drill
dimension of the hole (if any) (drill file)
Definition: dcode.h:191
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:229
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Definition: dcode.h:51
static void addHoleToPolygon(SHAPE_POLY_SET *aPolygon, APERTURE_DEF_HOLETYPE aHoleShape, const wxSize &aSize, const wxPoint &aAnchorPos)
Definition: dcode.cpp:422
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
constexpr int delta
#define SEGS_CNT
Definition: dcode.cpp:288
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:192
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:203
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
Definition: dcode.h:195
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, delta, 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,
const COLOR4D aColor,
bool  aFilled,
const wxPoint &  aPosition 
)

A helper function used to draw the polygon stored in 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
aParentis the GERBER_DRAW_ITEM being drawn.
aClipBoxis the device context clip box (NULL is no clip).
aDCis the device context.
aColoris the normal color to use.
aFilledset to true to draw in filled mode, false to draw in sketch mode.
aPositionis the actual shape position.

Definition at line 266 of file dcode.cpp.

268 {
269  if( m_Polygon.OutlineCount() == 0 )
270  return;
271 
272  int pointCount = m_Polygon.VertexCount();
273  std::vector<wxPoint> points;
274  points.reserve( pointCount );
275 
276  for( int ii = 0; ii < pointCount; ii++ )
277  {
278  wxPoint p( m_Polygon.CVertex( ii ).x, m_Polygon.CVertex( ii ).y );
279  points[ii] = p + aPosition;
280  points[ii] = aParent->GetABPosition( points[ii] );
281  }
282 
283  GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor );
284 }
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.
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a closed polyline and fill it if Fill, in object space.
Definition: gr_basic.cpp:507
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:203

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,
const COLOR4D aColor,
const wxPoint &  aShapePos,
bool  aFilledShape 
)

Draw the dcode shape for flashed items.

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

Parameters
aParentis the GERBER_DRAW_ITEM being drawn.
aClipBoxis the device context clip box (NULL is no clip).
aDCis the device context.
aColoris the normal color to use.
aShapePosis the actual shape position
aFilledShapeset to true to draw in filled mode, false to draw in sketch mode

Definition at line 148 of file dcode.cpp.

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

References APT_CIRCLE, APT_DEF_NO_HOLE, APT_DEF_ROUND_HOLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, ConvertShapeToPolygon(), delta, 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()

APERTURE_MACRO* D_CODE::GetMacro ( ) const
inline

Definition at line 125 of file dcode.h.

125 { return m_Macro; }
APERTURE_MACRO * m_Macro
no ownership, points to GERBER.m_aperture_macros element.
Definition: dcode.h:209

References m_Macro.

Referenced by KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), DrawFlashedShape(), fillFlashedGBRITEM(), GERBER_DRAW_ITEM::GetBoundingBox(), AM_PARAM::GetValue(), GERBER_DRAW_ITEM::HitTest(), GERBER_DRAW_ITEM::ShowGBRShape(), and GERBER_DRAW_ITEM::ViewGetLOD().

◆ GetParam()

double D_CODE::GetParam ( unsigned  aIdx) const
inline

Return a parameter stored in parameter list.

Parameters
aIdxis the index of parameter.

Definition at line 110 of file dcode.h.

111  {
112  wxASSERT( aIdx <= m_am_params.size() );
113 
114  if( aIdx <= m_am_params.size() )
115  return m_am_params[aIdx - 1];
116  else
117  return 0;
118  }
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:215

References m_am_params.

Referenced by AM_PARAM::GetValue().

◆ GetParamCount()

unsigned D_CODE::GetParamCount ( ) const
inline

Return the number of parameters stored in parameter list.

Definition at line 100 of file dcode.h.

101  {
102  return m_am_params.size();
103  }
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:215

References m_am_params.

Referenced by AM_PARAM::GetValue().

◆ GetShapeDim()

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

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
aParentis the parent GERBER_DRAW_ITEM which is actually drawn.
Returns
a dimension, or -1 if no dim to calculate.

Definition at line 116 of file dcode.cpp.

117 {
118  int dim = -1;
119 
120  switch( m_Shape )
121  {
122  case APT_CIRCLE:
123  dim = m_Size.x;
124  break;
125 
126  case APT_RECT:
127  case APT_OVAL:
128  dim = std::min( m_Size.x, m_Size.y );
129  break;
130 
131  case APT_POLYGON:
132  dim = std::min( m_Size.x, m_Size.y );
133  break;
134 
135  case APT_MACRO:
136  if( m_Macro )
137  dim = m_Macro->GetShapeDim( aParent );
138  break;
139 
140  default:
141  break;
142  }
143 
144  return dim;
145 }
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:188
Definition: dcode.h:52
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:189
APERTURE_MACRO * m_Macro
no ownership, points to GERBER.m_aperture_macros element.
Definition: dcode.h:209
Definition: dcode.h:51
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...

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 120 of file dcode.h.

121  {
122  m_Macro = aMacro;
123  }
APERTURE_MACRO * m_Macro
no ownership, points to GERBER.m_aperture_macros element.
Definition: dcode.h:209

References m_Macro.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ ShowApertureType()

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

Return a character string telling what type of aperture type aType is.

Parameters
aTypeis the aperture type to show.

Definition at line 87 of file dcode.cpp.

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

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 215 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) (drill file)

Definition at line 191 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 192 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 195 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 GERBER.m_aperture_macros element.

Definition at line 209 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 194 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: