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...
 
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 163 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 825 of file class_aperture_macro.cpp.

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

Referenced by D_CODE::DrawFlashedShape().

829 {
830  SHAPE_POLY_SET* shapeBuffer = GetApertureMacroShape( aParent, aShapePos );
831 
832  if( shapeBuffer->OutlineCount() == 0 )
833  return;
834 
835  for( int ii = 0; ii < shapeBuffer->OutlineCount(); ii++ )
836  {
837  SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
838 
839  GRClosedPoly( aClipBox, aDC,
840  poly.PointCount(), (wxPoint*)&poly.Point( 0 ), aFilledShape, aColor, aColor );
841  }
842 }
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:784
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Class SHAPE_LINE_CHAIN.
VECTOR2I & Point(int aIndex)
Function Point()
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 776 of file class_aperture_macro.cpp.

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

778 {
779  SHAPE_POLY_SET holeBuffer;
780  bool hasHole = false;
781 
783 
784  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
785  prim_macro != primitives.end(); ++prim_macro )
786  {
787  if( prim_macro->primitive_id == AMP_COMMENT )
788  continue;
789 
790  if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
791  prim_macro->DrawBasicShape( aParent, m_shape, aShapePos );
792  else
793  {
794  prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
795 
796  if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
797  {
799  holeBuffer.RemoveAllContours();
800  hasHole = true;
801  }
802  }
803  }
804 
805  // If a hole is defined inside a polygon, we must fracture the polygon
806  // to be able to drawn it (i.e link holes by overlapping edges)
807  if( hasHole )
809 
810  m_boundingBox = EDA_RECT( wxPoint( 0, 0 ), wxSize( 1, 1 ) );
811  auto bb = m_shape.BBox();
812  wxPoint center( bb.Centre().x, bb.Centre().y );
813  m_boundingBox.Move( aParent->GetABPosition( center ) );
814  m_boundingBox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
815 
816  return &m_shape;
817 }
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_RECT m_boundingBox
The bounding box of the item, calculated by GetApertureMacroShape.
int OutlineCount() const
Returns the number of outlines in the set
Class SHAPE_POLY_SET.
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
SHAPE_POLY_SET m_shape
The shape of the item, calculated by GetApertureMacroShape.
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
Class EDA_RECT handles the component boundary box.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp ...
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns the image position of aPosition for this object.
const BOX2I BBox(int aClearance=0) const override
Function BBox()
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
EDA_RECT APERTURE_MACRO::GetBoundingBox ( ) const
inline

Returns the bounding box of the shape.

Definition at line 231 of file class_aperture_macro.h.

References m_boundingBox.

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

232  {
233  return m_boundingBox;
234  }
EDA_RECT m_boundingBox
The bounding box of the item, calculated by GetApertureMacroShape.
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 879 of file class_aperture_macro.cpp.

References AM_PARAM::GetValue(), and m_localparamStack.

Referenced by AM_PARAM::GetValue().

880 {
881  // find parameter descr.
882  const AM_PARAM * param = NULL;
883 
884  for( unsigned ii = 0; ii < m_localparamStack.size(); ii ++ )
885  {
886  if( m_localparamStack[ii].GetIndex() == aParamId )
887  {
888  param = &m_localparamStack[ii];
889  break;
890  }
891  }
892 
893  if ( param == NULL ) // not found
894  return 0.0;
895 
896  // Evaluate parameter
897  double value = param->GetValue( aDcode );
898 
899  return value;
900 }
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 854 of file class_aperture_macro.cpp.

References primitives.

Referenced by D_CODE::GetShapeDim().

855 {
856  int dim = -1;
857  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
858  prim_macro != primitives.end(); ++prim_macro )
859  {
860  int pdim = prim_macro->GetShapeDim( aParent );
861  if( dim < pdim )
862  dim = pdim;
863  }
864 
865  return dim;
866 }
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.

Member Data Documentation

EDA_RECT APERTURE_MACRO::m_boundingBox

The bounding box of the item, calculated by GetApertureMacroShape.

Definition at line 177 of file class_aperture_macro.h.

Referenced by GetApertureMacroShape(), and GetBoundingBox().

AM_PARAMS APERTURE_MACRO::m_localparamStack

Definition at line 174 of file class_aperture_macro.h.

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

SHAPE_POLY_SET APERTURE_MACRO::m_shape

The shape of the item, calculated by GetApertureMacroShape.

Definition at line 176 of file class_aperture_macro.h.

Referenced by GetApertureMacroShape().

wxString APERTURE_MACRO::name
AM_PRIMITIVES APERTURE_MACRO::primitives

A sequence of AM_PRIMITIVEs.

Definition at line 166 of file class_aperture_macro.h.

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


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