KiCad PCB EDA Suite
APERTURE_MACRO Struct Reference

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

#include <am_primitive.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...
 
SHAPE_POLY_SETGetApertureMacroShape (const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
 Function GetApertureMacroShape Calculate the primitive shape for flashed items. 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...
 
EDA_RECT GetBoundingBox () const
 Returns the bounding box of the shape. 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
 
SHAPE_POLY_SET m_shape
 The shape of the item, calculated by GetApertureMacroShape. More...
 
EDA_RECT m_boundingBox
 The bounding box of the item, calculated by GetApertureMacroShape. More...
 

Detailed Description

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

Definition at line 162 of file am_primitive.h.

Member Function Documentation

◆ DrawApertureMacroShape()

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 829 of file am_primitive.cpp.

833 {
834  SHAPE_POLY_SET* shapeBuffer = GetApertureMacroShape( aParent, aShapePos );
835 
836  if( shapeBuffer->OutlineCount() == 0 )
837  return;
838 
839  for( int ii = 0; ii < shapeBuffer->OutlineCount(); ii++ )
840  {
841  SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
842 
843  GRClosedPoly( aClipBox, aDC, poly.PointCount(), (wxPoint*) &poly.CPoint( 0 ), aFilledShape,
844  aColor, aColor );
845  }
846 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_LINE_CHAIN.
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, COLOR4D Color, COLOR4D BgColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:550

References SHAPE_LINE_CHAIN::CPoint(), GetApertureMacroShape(), GRClosedPoly(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by D_CODE::DrawFlashedShape().

◆ GetApertureMacroShape()

SHAPE_POLY_SET * APERTURE_MACRO::GetApertureMacroShape ( const GERBER_DRAW_ITEM aParent,
wxPoint  aShapePos 
)

Function GetApertureMacroShape Calculate 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
Returns
The shape of the item

Definition at line 780 of file am_primitive.cpp.

782 {
783  SHAPE_POLY_SET holeBuffer;
784  bool hasHole = false;
785 
787 
788  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
789  prim_macro != primitives.end(); ++prim_macro )
790  {
791  if( prim_macro->primitive_id == AMP_COMMENT )
792  continue;
793 
794  if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
795  prim_macro->DrawBasicShape( aParent, m_shape, aShapePos );
796  else
797  {
798  prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
799 
800  if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
801  {
803  holeBuffer.RemoveAllContours();
804  hasHole = true;
805  }
806  }
807  }
808 
809  // If a hole is defined inside a polygon, we must fracture the polygon
810  // to be able to drawn it (i.e link holes by overlapping edges)
811  if( hasHole )
813 
814  m_boundingBox = EDA_RECT( wxPoint( 0, 0 ), wxSize( 1, 1 ) );
815  auto bb = m_shape.BBox();
816  wxPoint center( bb.Centre().x, bb.Centre().y );
817  m_boundingBox.Move( aParent->GetABPosition( center ) );
818  m_boundingBox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
819 
820  return &m_shape;
821 }
void Move(const wxPoint &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: eda_rect.cpp:51
int OutlineCount() const
Return the number of vertices in a given outline/hole.
EDA_RECT m_boundingBox
The bounding box of the item, calculated by GetApertureMacroShape.
Definition: am_primitive.h:176
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return the image position of aPosition for this object.
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
SHAPE_POLY_SET m_shape
The shape of the item, calculated by GetApertureMacroShape.
Definition: am_primitive.h:175
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.
Definition: am_primitive.h:165
Handle the component boundary box.
Definition: eda_rect.h:42
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363

References AMP_COMMENT, SHAPE_POLY_SET::BBox(), SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::Fracture(), GERBER_DRAW_ITEM::GetABPosition(), EDA_RECT::Inflate(), m_boundingBox, m_shape, EDA_RECT::Move(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, primitives, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), DrawApertureMacroShape(), fillFlashedGBRITEM(), GERBER_DRAW_ITEM::GetBoundingBox(), and GERBER_DRAW_ITEM::HitTest().

◆ GetBoundingBox()

EDA_RECT APERTURE_MACRO::GetBoundingBox ( ) const
inline

Returns the bounding box of the shape.

Definition at line 230 of file am_primitive.h.

231  {
232  return m_boundingBox;
233  }
EDA_RECT m_boundingBox
The bounding box of the item, calculated by GetApertureMacroShape.
Definition: am_primitive.h:176

References m_boundingBox.

Referenced by GERBER_DRAW_ITEM::GetBoundingBox(), and GERBER_DRAW_ITEM::ViewGetLOD().

◆ GetLocalParam()

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 883 of file am_primitive.cpp.

884 {
885  // find parameter descr.
886  const AM_PARAM * param = NULL;
887 
888  for( unsigned ii = 0; ii < m_localparamStack.size(); ii ++ )
889  {
890  if( m_localparamStack[ii].GetIndex() == aParamId )
891  {
892  param = &m_localparamStack[ii];
893  break;
894  }
895  }
896 
897  if ( param == NULL ) // not found
898  return 0.0;
899 
900  // Evaluate parameter
901  double value = param->GetValue( aDcode );
902 
903  return value;
904 }
double GetValue(const D_CODE *aDcode) const
Definition: am_param.cpp:74
AM_PARAMS m_localparamStack
Definition: am_primitive.h:173
#define NULL
AM_PARAM holds a parameter value for an "aperture macro" as defined within standard RS274X.
Definition: am_param.h:286

References AM_PARAM::GetValue(), m_localparamStack, and NULL.

Referenced by AM_PARAM::GetValue().

◆ GetShapeDim()

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 858 of file am_primitive.cpp.

859 {
860  int dim = -1;
861  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
862  prim_macro != primitives.end(); ++prim_macro )
863  {
864  int pdim = prim_macro->GetShapeDim( aParent );
865  if( dim < pdim )
866  dim = pdim;
867  }
868 
869  return dim;
870 }
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.
Definition: am_primitive.h:165

References primitives.

Referenced by D_CODE::GetShapeDim().

Member Data Documentation

◆ m_boundingBox

EDA_RECT APERTURE_MACRO::m_boundingBox

The bounding box of the item, calculated by GetApertureMacroShape.

Definition at line 176 of file am_primitive.h.

Referenced by GetApertureMacroShape(), and GetBoundingBox().

◆ m_localparamStack

AM_PARAMS APERTURE_MACRO::m_localparamStack

Definition at line 173 of file am_primitive.h.

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

◆ m_shape

SHAPE_POLY_SET APERTURE_MACRO::m_shape

The shape of the item, calculated by GetApertureMacroShape.

Definition at line 175 of file am_primitive.h.

Referenced by GetApertureMacroShape().

◆ name

wxString APERTURE_MACRO::name

◆ primitives

AM_PRIMITIVES APERTURE_MACRO::primitives

A sequence of AM_PRIMITIVEs.

Definition at line 165 of file am_primitive.h.

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


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