KiCad PCB EDA Suite
APERTURE_MACRO Struct Reference

Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X. More...

#include <class_aperture_macro.h>

Public Member Functions

double GetLocalParam (const D_CODE *aDcode, unsigned aParamId) const
 function GetLocalParam Usually, parameters are defined inside the aperture primitive using immediate mode or defered mode. More...
 
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. More...
 
int GetShapeDim (GERBER_DRAW_ITEM *aParent)
 Function GetShapeDim 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 a shape using many primitives one cannot calculate the "size" of a shape (only abounding box) but most of aperture macro are using one or few primitives and the "dimension" of the shape is the diameter of the primitive (or the max diameter of primitives) More...
 

Public Attributes

wxString name
 The name of the aperture macro. More...
 
AM_PRIMITIVES primitives
 A sequence of AM_PRIMITIVEs. More...
 
AM_PARAMS m_localparamStack
 

Detailed Description

Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.

Definition at line 160 of file class_aperture_macro.h.

Member Function Documentation

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

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

Parameters
aParent= the parent GERBER_DRAW_ITEM which is actually drawn
aClipBox= DC clip box (NULL is no clip)
aDC= device context
aColor= the color of shape
aShapePos= the actual shape position
aFilledShape= true to draw in filled mode, false to draw in skecth mode

Definition at line 713 of file class_aperture_macro.cpp.

References SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::Fracture(), GRClosedPoly(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), primitives, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by D_CODE::DrawFlashedShape().

717 {
718  SHAPE_POLY_SET shapeBuffer;
719  SHAPE_POLY_SET holeBuffer;
720  bool hasHole = false;
721 
722  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
723  prim_macro != primitives.end(); ++prim_macro )
724  {
725  if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
726  prim_macro->DrawBasicShape( aParent, shapeBuffer, aShapePos );
727  else
728  {
729  prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
730 
731  if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
732  {
733  shapeBuffer.BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
734  holeBuffer.RemoveAllContours();
735  hasHole = true;
736  }
737  }
738  }
739 
740  if( shapeBuffer.OutlineCount() == 0 )
741  return;
742 
743  // If a hole is defined inside a polygon, we must fracture the polygon
744  // to be able to drawn it (i.e link holes by overlapping edges)
745  if( hasHole )
746  shapeBuffer.Fracture( SHAPE_POLY_SET::PM_FAST );
747 
748  for( int ii = 0; ii < shapeBuffer.OutlineCount(); ii++ )
749  {
750  SHAPE_LINE_CHAIN& poly = shapeBuffer.Outline( ii );
751 
752  GRClosedPoly( aClipBox, aDC,
753  poly.PointCount(), (wxPoint*)&poly.Point( 0 ), aFilledShape, aColor, aColor );
754  }
755 }
int PointCount() const
Function PointCount()
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:777
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.
Class SHAPE_LINE_CHAIN.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
VECTOR2I & Point(int aIndex)
Function Point()
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp ...
double APERTURE_MACRO::GetLocalParam ( const D_CODE aDcode,
unsigned  aParamId 
) const

function GetLocalParam Usually, parameters are defined inside the aperture primitive using immediate mode or defered mode.

in defered mode the value is defined in a DCODE that want to use the aperture macro. But some parameters are defined outside the aperture primitive and are local to the aperture macro

Returns
the value of a defered parameter defined inside the aperture macro
Parameters
aDcode= the D_CODE that uses this apertur macro and define defered parameters
aParamId= the param id (defined by $3 or $5 ..) to evaluate

in defered mode the value is defined in a DCODE that want to use the aperture macro. But some parameters are defined outside the aperture primitive and are local to the aperture macro

Returns
the value of a defered parameter defined inside the aperture macro
Parameters
aParamId= the param id (defined by $3 or $5 ..) to evaluate

Definition at line 792 of file class_aperture_macro.cpp.

References AM_PARAM::GetValue(), and m_localparamStack.

Referenced by AM_PARAM::GetValue().

793 {
794  // find parameter descr.
795  const AM_PARAM * param = NULL;
796  for( unsigned ii = 0; ii < m_localparamStack.size(); ii ++ )
797  {
798  if( m_localparamStack[ii].GetIndex() == aParamId )
799  {
800  param = &m_localparamStack[ii];
801  break;
802  }
803  }
804  if ( param == NULL ) // not found
805  return 0.0;
806  // Evaluate parameter
807  double value = param->GetValue( aDcode );
808  return value;
809 }
Class AM_PARAM holds a parameter value for an "aperture macro" as defined within standard RS274X...
double GetValue(const D_CODE *aDcode) const
int APERTURE_MACRO::GetShapeDim ( GERBER_DRAW_ITEM aParent)

Function GetShapeDim 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 a shape using many primitives one cannot calculate the "size" of a shape (only abounding box) but most of aperture macro are using one or few primitives and the "dimension" of the shape is the diameter of the primitive (or the max diameter of primitives)

GetShapeDim 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 a shape using many primitives one cannot calculate the "size" of a shape (only abounding box) but most of aperture macro are using one or few primitives and the "dimension" of the shape is the diameter of the primitive (or the max diameter of primitives)

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

Definition at line 767 of file class_aperture_macro.cpp.

References primitives.

Referenced by D_CODE::GetShapeDim().

768 {
769  int dim = -1;
770  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
771  prim_macro != primitives.end(); ++prim_macro )
772  {
773  int pdim = prim_macro->GetShapeDim( aParent );
774  if( dim < pdim )
775  dim = pdim;
776  }
777 
778  return dim;
779 }
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.

Member Data Documentation

AM_PARAMS APERTURE_MACRO::m_localparamStack

Definition at line 171 of file class_aperture_macro.h.

Referenced by GetLocalParam(), and GERBER_FILE_IMAGE::ReadApertureMacro().

wxString APERTURE_MACRO::name
AM_PRIMITIVES APERTURE_MACRO::primitives

A sequence of AM_PRIMITIVEs.

Definition at line 163 of file class_aperture_macro.h.

Referenced by DrawApertureMacroShape(), GetShapeDim(), and GERBER_FILE_IMAGE::ReadApertureMacro().


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