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

803 {
804  SHAPE_POLY_SET* shapeBuffer = GetApertureMacroShape( aParent, aShapePos );
805 
806  if( shapeBuffer->OutlineCount() == 0 )
807  return;
808 
809  for( int ii = 0; ii < shapeBuffer->OutlineCount(); ii++ )
810  {
811  SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
812 
813  GRClosedPoly( aClipBox, aDC,
814  poly.PointCount(), (wxPoint*)&poly.Point( 0 ), aFilledShape, aColor, aColor );
815  }
816 }
int PointCount() const
Function PointCount()
SHAPE_POLY_SET * GetApertureMacroShape(GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
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
Class SHAPE_LINE_CHAIN.
VECTOR2I & Point(int aIndex)
Function Point()
SHAPE_POLY_SET * APERTURE_MACRO::GetApertureMacroShape ( 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 750 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(), and fillFlashedGBRITEM().

752 {
753  SHAPE_POLY_SET holeBuffer;
754  bool hasHole = false;
755 
757 
758  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
759  prim_macro != primitives.end(); ++prim_macro )
760  {
761  if( prim_macro->primitive_id == AMP_COMMENT )
762  continue;
763 
764  if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
765  prim_macro->DrawBasicShape( aParent, m_shape, aShapePos );
766  else
767  {
768  prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
769 
770  if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
771  {
773  holeBuffer.RemoveAllContours();
774  hasHole = true;
775  }
776  }
777  }
778 
779  // If a hole is defined inside a polygon, we must fracture the polygon
780  // to be able to drawn it (i.e link holes by overlapping edges)
781  if( hasHole )
783 
784  m_boundingBox = EDA_RECT( wxPoint( 0, 0 ), wxSize( 1, 1 ) );
785  auto bb = m_shape.BBox();
786  wxPoint center( bb.Centre().x, bb.Centre().y );
787  m_boundingBox.Move( aParent->GetABPosition( center ) );
788  m_boundingBox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
789 
790  return &m_shape;
791 }
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 229 of file class_aperture_macro.h.

References m_boundingBox.

Referenced by GERBER_DRAW_ITEM::GetBoundingBox().

230  {
231  return m_boundingBox;
232  }
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 853 of file class_aperture_macro.cpp.

References AM_PARAM::GetValue(), and m_localparamStack.

Referenced by AM_PARAM::GetValue().

854 {
855  // find parameter descr.
856  const AM_PARAM * param = NULL;
857 
858  for( unsigned ii = 0; ii < m_localparamStack.size(); ii ++ )
859  {
860  if( m_localparamStack[ii].GetIndex() == aParamId )
861  {
862  param = &m_localparamStack[ii];
863  break;
864  }
865  }
866 
867  if ( param == NULL ) // not found
868  return 0.0;
869 
870  // Evaluate parameter
871  double value = param->GetValue( aDcode );
872 
873  return value;
874 }
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 828 of file class_aperture_macro.cpp.

References primitives.

Referenced by D_CODE::GetShapeDim().

829 {
830  int dim = -1;
831  for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
832  prim_macro != primitives.end(); ++prim_macro )
833  {
834  int pdim = prim_macro->GetShapeDim( aParent );
835  if( dim < pdim )
836  dim = pdim;
837  }
838 
839  return dim;
840 }
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 175 of file class_aperture_macro.h.

Referenced by GetApertureMacroShape(), and GetBoundingBox().

AM_PARAMS APERTURE_MACRO::m_localparamStack

Definition at line 172 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 174 of file class_aperture_macro.h.

Referenced by GetApertureMacroShape(), and GERBER_DRAW_ITEM::HitTest().

wxString APERTURE_MACRO::name
AM_PRIMITIVES APERTURE_MACRO::primitives

A sequence of AM_PRIMITIVEs.

Definition at line 164 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: