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

758 {
759  SHAPE_POLY_SET shapeBuffer;
760  SHAPE_POLY_SET holeBuffer;
761  bool hasHole = false;
762 
763  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
764  prim_macro != primitives.end(); ++prim_macro )
765  {
766  if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
767  prim_macro->DrawBasicShape( aParent, shapeBuffer, aShapePos );
768  else
769  {
770  prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
771 
772  if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
773  {
774  shapeBuffer.BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
775  holeBuffer.RemoveAllContours();
776  hasHole = true;
777  }
778  }
779  }
780 
781  if( shapeBuffer.OutlineCount() == 0 )
782  return;
783 
784  // If a hole is defined inside a polygon, we must fracture the polygon
785  // to be able to drawn it (i.e link holes by overlapping edges)
786  if( hasHole )
787  shapeBuffer.Fracture( SHAPE_POLY_SET::PM_FAST );
788 
789  for( int ii = 0; ii < shapeBuffer.OutlineCount(); ii++ )
790  {
791  SHAPE_LINE_CHAIN& poly = shapeBuffer.Outline( ii );
792 
793  GRClosedPoly( aClipBox, aDC,
794  poly.PointCount(), (wxPoint*)&poly.Point( 0 ), aFilledShape, aColor, aColor );
795  }
796 }
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 833 of file class_aperture_macro.cpp.

References AM_PARAM::GetValue(), and m_localparamStack.

Referenced by AM_PARAM::GetValue().

834 {
835  // find parameter descr.
836  const AM_PARAM * param = NULL;
837 
838  for( unsigned ii = 0; ii < m_localparamStack.size(); ii ++ )
839  {
840  if( m_localparamStack[ii].GetIndex() == aParamId )
841  {
842  param = &m_localparamStack[ii];
843  break;
844  }
845  }
846 
847  if ( param == NULL ) // not found
848  return 0.0;
849 
850  // Evaluate parameter
851  double value = param->GetValue( aDcode );
852 
853  return value;
854 }
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 808 of file class_aperture_macro.cpp.

References primitives.

Referenced by D_CODE::GetShapeDim().

809 {
810  int dim = -1;
811  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
812  prim_macro != primitives.end(); ++prim_macro )
813  {
814  int pdim = prim_macro->GetShapeDim( aParent );
815  if( dim < pdim )
816  dim = pdim;
817  }
818 
819  return dim;
820 }
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: