43 extern int scaletoIU(
double aCoord,
bool isMetric );
51 static wxPoint
mapPt(
double x,
double y,
bool isMetric )
99 #define TO_POLY_SHAPE { aShapeBuffer.NewOutline(); \ 100 for( unsigned jj = 0; jj < polybuffer.size(); jj++ )\ 101 aShapeBuffer.Append( polybuffer[jj].x, polybuffer[jj].y );\ 102 aShapeBuffer.Append( polybuffer[0].x, polybuffer[0].y );} 105 static std::vector<wxPoint> polybuffer;
108 wxPoint curPos = aShapePos;
127 rotation =
params[4].GetValue( tool ) * 10.0;
131 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
138 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
140 polybuffer[ii] += curPos;
163 rotation =
params[6].GetValue( tool ) * 10.0;
167 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
172 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
174 polybuffer[ii] += curPos;
195 rotation =
params[5].GetValue( tool ) * 10.0;
199 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
204 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
206 polybuffer[ii] += curPos;
224 rotation =
params[5].GetValue( tool ) * 10.0;
227 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
232 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
234 polybuffer[ii] += curPos;
251 std::vector<wxPoint> subshape_poly;
256 rotation =
params[5].GetValue( tool ) * 10.0;
260 for(
int ii = 0; ii < 4; ii++ )
262 polybuffer = subshape_poly;
263 double sub_rotation = rotation + 900 * ii;
265 for(
unsigned jj = 0; jj < polybuffer.size(); jj++ )
269 for(
unsigned jj = 0; jj < polybuffer.size(); jj++ )
271 polybuffer[jj] += curPos;
302 int diamAdjust = (gap + penThickness) * 2;
304 for(
int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust )
311 if( outerDiam <= penThickness )
327 rotation =
params[8].GetValue( tool ) * 10.0;
328 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
333 polybuffer[ii] += curPos;
358 int numCorners = (int)
params[1].GetValue( tool );
360 int last_prm =
params.size() - 1;
361 rotation =
params[last_prm].GetValue( tool ) * 10.0;
370 for(
int i = 0; i <= numCorners; ++i )
376 polybuffer.push_back(pos);
381 if( prm_idx >= last_prm )
386 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
392 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
394 polybuffer[ii] += curPos;
417 rotation =
params[5].GetValue( tool ) * 10.0;
418 for(
unsigned ii = 0; ii < polybuffer.size(); ii++ )
421 polybuffer[ii] += curPos;
451 std::vector<wxPoint>& aBuffer )
476 aBuffer.push_back( corner );
489 wxPoint delta = end - start;
495 currpt.y += width / 2;
496 aBuffer.push_back( currpt );
498 aBuffer.push_back( currpt );
500 aBuffer.push_back( currpt );
502 aBuffer.push_back( currpt );
507 for(
unsigned ii = 0; ii < 4; ii++ )
510 aBuffer[ii] += start;
523 aBuffer.push_back( pos );
525 aBuffer.push_back( pos );
527 aBuffer.push_back( pos );
529 aBuffer.push_back( pos );
540 aBuffer.push_back( lowerLeft );
541 lowerLeft.y += size.y;
542 aBuffer.push_back( lowerLeft );
543 lowerLeft.x += size.x;
544 aBuffer.push_back( lowerLeft );
545 lowerLeft.y -= size.y;
546 aBuffer.push_back( lowerLeft );
559 outerRadius = std::max( 1, outerRadius );
560 innerRadius = std::max( 1, innerRadius );
563 double angle_start =
RAD2DECIDEG( asin( (
double) halfthickness / innerRadius ) );
566 wxPoint pos, startpos;
569 startpos.x = innerRadius;
570 double angle_end = 900 - angle_start;
575 aBuffer.push_back( pos );
581 aBuffer.push_back( pos );
584 startpos.x = outerRadius;
586 angle_start =
RAD2DECIDEG( asin( (
double) halfthickness / outerRadius ) );
587 angle_end = 900 - angle_start;
594 aBuffer.push_back( pos );
600 aBuffer.push_back( pos );
602 aBuffer.push_back( aBuffer[0] );
614 wxPoint pos( crossHairThickness / 2, crossHairLength / 2 );
615 aBuffer.push_back( pos );
616 pos.y = crossHairThickness / 2;
617 aBuffer.push_back( pos );
618 pos.x = -crossHairLength / 2;
619 aBuffer.push_back( pos );
620 pos.y = -crossHairThickness / 2;
621 aBuffer.push_back( pos );
624 for(
int jj = 1; jj <= 3; jj ++ )
626 for(
int ii = 0; ii < 4; ii++ )
630 aBuffer.push_back( pos );
645 if( vertexcount < 3 )
647 if( vertexcount > 10 )
649 for(
int ii = 0; ii <= vertexcount; ii++ )
651 wxPoint pos( radius, 0);
653 aBuffer.push_back( pos );
695 dim = std::min(size.x, size.y);
702 dim = std::min(size.x, size.y);
724 int numPoints = (int)
params[1].GetValue( tool );
727 wxSize pos_min, pos_max, pos;
729 int last_prm =
params.size() - 1;
731 for(
int i = 0; i<= numPoints; ++i )
738 pos_min = pos_max = pos;
742 if( pos_min.x > pos.x )
744 if( pos_min.y > pos.y )
747 if( pos_max.x < pos.x )
749 if( pos_max.y < pos.y )
756 if( prm_idx >= last_prm )
761 size.x = pos_max.x - pos_min.x;
762 size.y = pos_max.y - pos_min.y;
763 dim = std::min( size.x, size.y );
784 bool hasHole =
false;
788 for( AM_PRIMITIVES::iterator prim_macro =
primitives.begin();
789 prim_macro !=
primitives.end(); ++prim_macro )
794 if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
795 prim_macro->DrawBasicShape( aParent,
m_shape, aShapePos );
798 prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
816 wxPoint center( bb.Centre().x, bb.Centre().y );
832 wxPoint aShapePos,
bool aFilledShape )
839 for(
int ii = 0; ii < shapeBuffer->
OutlineCount(); ii++ )
861 for( AM_PRIMITIVES::iterator prim_macro =
primitives.begin();
862 prim_macro !=
primitives.end(); ++prim_macro )
864 int pdim = prim_macro->GetShapeDim( aParent );
901 double value = param->
GetValue( aDcode );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
double GetValue(const D_CODE *aDcode) const
void Move(const wxPoint &aMoveVector)
Move the rectangle by the aMoveVector.
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void DrawBasicShape(const GERBER_DRAW_ITEM *aParent, SHAPE_POLY_SET &aShapeBuffer, wxPoint aShapePos)
Function drawBasicShape Draw (in fact generate the actual polygonal shape of) the primitive shape of ...
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.
bool IsAMPrimitiveExposureOn(const GERBER_DRAW_ITEM *aParent) const
Function IsAMPrimitiveExposureOn.
double RAD2DECIDEG(double rad)
EDA_RECT m_boundingBox
The bounding box of the item, calculated by GetApertureMacroShape.
void RotatePoint(int *pX, int *pY, double angle)
int PointCount() const
Function PointCount()
double GetLocalParam(const D_CODE *aDcode, unsigned aParamId) const
function GetLocalParam Usually, parameters are defined inside the aperture primitive using immediate ...
int GetShapeDim(const GERBER_DRAW_ITEM *aParent)
GetShapeDim Calculate a value that can be used to evaluate the size of text when displaying the D-Cod...
AM_PARAMS m_localparamStack
int scaletoIU(double aCoord, bool isMetric)
Function scaletoIU converts a distance given in floating point to our internal units.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent, std::vector< wxPoint > &aBuffer)
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return the image position of aPosition for this object.
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)
AM_PARAM holds a parameter value for an "aperture macro" as defined within standard RS274X.
static wxPoint mapPt(double x, double y, bool isMetric)
Function mapPt translates a point from the aperture macro coordinate system to our deci-mils coordina...
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.
AM_PRIMITIVES primitives
A sequence of AM_PRIMITIVEs.
D_CODE holds a gerber DCODE (also called Aperture) definition.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
Handle the component boundary box.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
double ArcTangente(int dy, int dx)
int GetShapeDim(GERBER_DRAW_ITEM *aParent)
Function GetShapeDim Calculate a value that can be used to evaluate the size of text when displaying ...
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 ...
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
AM_PARAMS params
A sequence of parameters used by.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
AM_PRIMITIVE_ID primitive_id
The primitive type.
A color representation with 4 components: red, green, blue, alpha.