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

Definition at line 67 of file dcode.cpp.

References Clear_D_CODE_Data(), and m_Num_Dcode.

68 {
69  m_Num_Dcode = num_dcode;
71 }
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
void Clear_D_CODE_Data()
Definition: dcode.cpp:79
D_CODE::~D_CODE ( )

Definition at line 74 of file dcode.cpp.

75 {
76 }

Member Function Documentation

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.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

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
void D_CODE::Clear_D_CODE_Data ( )

Definition at line 79 of file dcode.cpp.

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

80 {
84  m_Drill.x = m_Drill.y = 0;
86  m_InUse = false;
87  m_Defined = false;
88  m_Macro = NULL;
89  m_Rotation = 0.0;
90  m_EdgesCount = 0;
92 }
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:41
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
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 303 of file dcode.cpp.

References addHoleToPolygon(), PNS::angle(), SHAPE_POLY_SET::Append(), APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, delta, SHAPE_POLY_SET::Iterate(), KiROUND(), m_Drill, m_DrillShape, m_EdgesCount, m_Polygon, m_Rotation, m_Shape, m_Size, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::RemoveAllContours(), RotatePoint(), SEGS_CNT, TransformCircleToPolygon(), wxPoint::x, and wxPoint::y.

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

304 {
305  wxPoint initialpos;
306  wxPoint currpos;
307 
309 
310  switch( m_Shape )
311  {
312  case APT_CIRCLE: // creates only a circle with rectangular hole
313  TransformCircleToPolygon( m_Polygon, initialpos, m_Size.x >> 1, SEGS_CNT );
315  break;
316 
317  case APT_RECT:
319  currpos.x = m_Size.x / 2;
320  currpos.y = m_Size.y / 2;
321  initialpos = currpos;
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 ) );
327  currpos.x += m_Size.x;
328  m_Polygon.Append( VECTOR2I( currpos ) );
329  currpos.y += m_Size.y;
330  m_Polygon.Append( VECTOR2I( currpos ) ); // close polygon
331  m_Polygon.Append( VECTOR2I( initialpos ) );
332 
334  break;
335 
336  case APT_OVAL:
337  {
339  int delta, radius;
340 
341  // we create an horizontal oval shape. then rotate if needed
342  if( m_Size.x > m_Size.y ) // horizontal oval
343  {
344  delta = (m_Size.x - m_Size.y) / 2;
345  radius = m_Size.y / 2;
346  }
347  else // vertical oval
348  {
349  delta = (m_Size.y - m_Size.x) / 2;
350  radius = m_Size.x / 2;
351  }
352 
353  currpos.y = radius;
354  initialpos = currpos;
355  m_Polygon.Append( VECTOR2I( currpos ) );
356 
357  // build the right arc of the shape
358  unsigned ii = 0;
359 
360  for( ; ii <= SEGS_CNT / 2; ii++ )
361  {
362  currpos = initialpos;
363  RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
364  currpos.x += delta;
365  m_Polygon.Append( VECTOR2I( currpos ) );
366  }
367 
368  // build the left arc of the shape
369  for( ii = SEGS_CNT / 2; ii <= SEGS_CNT; ii++ )
370  {
371  currpos = initialpos;
372  RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
373  currpos.x -= delta;
374  m_Polygon.Append( VECTOR2I( currpos ) );
375  }
376 
377  m_Polygon.Append( VECTOR2I( initialpos ) ); // close outline
378 
379  if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon.
380  {
381  for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
382  it->Rotate( -M_PI / 2 );
383  }
384 
386  }
387  break;
388 
389  case APT_POLYGON:
391  currpos.x = m_Size.x >> 1; // first point is on X axis
392  initialpos = currpos;
393 
394  // rs274x said: m_EdgesCount = 3 ... 12
395  if( m_EdgesCount < 3 )
396  m_EdgesCount = 3;
397 
398  if( m_EdgesCount > 12 )
399  m_EdgesCount = 12;
400 
401  for( int ii = 0; ii < m_EdgesCount; ii++ )
402  {
403  currpos = initialpos;
404  RotatePoint( &currpos, ii * 3600.0 / m_EdgesCount );
405  m_Polygon.Append( VECTOR2I( currpos ) );
406  }
407 
409 
410  if( m_Rotation ) // vertical oval, rotate polygon.
411  {
412  int angle = KiROUND( m_Rotation * 10 );
413 
414  for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
415  it->Rotate( -angle );
416  }
417 
418  break;
419 
420  case APT_MACRO:
421 
422  // TODO
423  break;
424  }
425 }
static void addHoleToPolygon(SHAPE_POLY_SET *aPolygon, APERTURE_DEF_HOLETYPE aHoleShape, wxSize aSize, wxPoint aAnchorPos)
Definition: dcode.cpp:430
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
Definition: dcode.h:53
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
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:317
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:589
static const int delta[8][2]
Definition: solve.cpp:112
Definition: dcode.h:52
#define SEGS_CNT
Definition: dcode.cpp:293
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
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) ...
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 270 of file dcode.cpp.

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

274 {
275  if( m_Polygon.OutlineCount() == 0 )
276  return;
277 
278  int pointCount = m_Polygon.VertexCount();
279  std::vector<wxPoint> points;
280  points.reserve( pointCount );
281 
282  for( int ii = 0; ii < pointCount; ii++ )
283  {
284  wxPoint p( m_Polygon.Vertex( ii ).x, m_Polygon.Vertex( ii ).y );
285  points[ii] = p + aPosition;
286  points[ii] = aParent->GetABPosition( points[ii] );
287  }
288 
289  GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor );
290 }
int OutlineCount() const
Returns the number of outlines in the set
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:784
VECTOR2I & Vertex(int aIndex, int aOutline, int aHole)
Returns the index-th vertex in a given hole outline within a given outline
int VertexCount(int aOutline=-1, int aHole=-1) const
Returns the number of vertices in a given outline/hole
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:107
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns the image position of aPosition for this object.
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 154 of file dcode.cpp.

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, SHAPE_POLY_SET::OutlineCount(), wxPoint::x, and wxPoint::y.

Referenced by GERBER_DRAW_ITEM::Draw().

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

Referenced by AM_PARAM::GetValue().

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
unsigned D_CODE::GetParamCount ( ) const
inline

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

Definition at line 131 of file dcode.h.

Referenced by AM_PARAM::GetValue().

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

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

124 {
125  int dim = -1;
126  switch( m_Shape )
127  {
128  case APT_CIRCLE:
129  dim = m_Size.x;
130  break;
131 
132  case APT_RECT:
133  case APT_OVAL:
134  dim = std::min( m_Size.x, m_Size.y );
135  break;
136 
137  case APT_POLYGON:
138  dim = std::min( m_Size.x, m_Size.y );
139  break;
140 
141  case APT_MACRO:
142  if( m_Macro )
143  dim = m_Macro->GetShapeDim( aParent );
144  break;
145 
146  default:
147  break;
148  }
149 
150  return dim;
151 }
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
void D_CODE::SetMacro ( APERTURE_MACRO aMacro)
inline

Definition at line 151 of file dcode.h.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

152  {
153  m_Macro = aMacro;
154  }
APERTURE_MACRO * m_Macro
no ownership, points to
Definition: dcode.h:85
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 95 of file dcode.cpp.

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

Referenced by GERBVIEW_FRAME::Liste_D_Codes(), and GERBVIEW_FRAME::updateDCodeSelectBox().

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

Member Data Documentation

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.

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

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

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

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(), and GetShapeDim().

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


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