Gerbview: fix coding style (better names for variable members is some classes).

(no actual change in code)
This commit is contained in:
jean-pierre charras 2023-01-13 18:57:18 +01:00
parent b3d1384896
commit 00d77f624a
6 changed files with 108 additions and 106 deletions

View File

@ -31,9 +31,6 @@
#include <am_primitive.h>
#include <macros.h>
#include <wx/debug.h>
extern int ReadInt( char*& text, bool aSkipSeparator = true );
extern double ReadDouble( char*& text, bool aSkipSeparator = true );
extern double Evaluate( AM_PARAM_EVAL_STACK& aExp );
@ -208,8 +205,10 @@ bool AM_PARAM::ReadParam( char*& aText )
// defered value defined later, in ADD command which define defered parameters
++aText;
ivalue = ReadInt( aText, false );
if( m_index < 1 )
SetIndex( ivalue );
PushOperator( PUSHPARM, ivalue );
found = true;
break;

View File

@ -63,9 +63,9 @@ bool AM_PRIMITIVE::IsAMPrimitiveExposureOn( const GERBER_DRAW_ITEM* aParent ) co
* In a aperture macro shape, a basic primitive with exposure off is a hole in the shape
* it is NOT a negative shape
*/
wxASSERT( params.size() );
wxASSERT( m_Params.size() );
switch( primitive_id )
switch( m_Primitive_id )
{
case AMP_CIRCLE:
case AMP_LINE2:
@ -75,7 +75,7 @@ bool AM_PRIMITIVE::IsAMPrimitiveExposureOn( const GERBER_DRAW_ITEM* aParent ) co
case AMP_OUTLINE:
case AMP_POLYGON:
// All have an exposure parameter and can return a value (0 or 1)
return params[0].GetValue( aParent->GetDcodeDescr() ) != 0;
return m_Params[0].GetValue( aParent->GetDcodeDescr() ) != 0;
break;
case AMP_THERMAL: // Exposure is always on
@ -117,7 +117,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
VECTOR2I curPos = aShapePos;
D_CODE* tool = aParent->GetDcodeDescr();
switch( primitive_id )
switch( m_Primitive_id )
{
case AMP_CIRCLE: // Circle, given diameter and position
{
@ -130,9 +130,9 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
ConvertShapeToPolygon( aParent, polybuffer );
// shape rotation (if any):
if( params.size() >= 5 )
if( m_Params.size() >= 5 )
{
EDA_ANGLE rotation( params[4].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[4].GetValue( tool ), DEGREES_T );
if( !rotation.IsZero() )
{
@ -168,7 +168,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
ConvertShapeToPolygon( aParent, polybuffer );
// shape rotation:
EDA_ANGLE rotation( params[6].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[6].GetValue( tool ), DEGREES_T );
if( !rotation.IsZero() )
{
@ -200,7 +200,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
ConvertShapeToPolygon( aParent, polybuffer );
// shape rotation:
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[5].GetValue( tool ), DEGREES_T );
if( !rotation.IsZero() )
{
@ -229,7 +229,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
ConvertShapeToPolygon( aParent, polybuffer );
// shape rotation:
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[5].GetValue( tool ), DEGREES_T );
if( !rotation.IsZero() )
{
@ -259,11 +259,11 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
* on.
*/
std::vector<VECTOR2I> subshape_poly;
curPos += mapPt( params[0].GetValue( tool ), params[1].GetValue( tool ), m_GerbMetric );
curPos += mapPt( m_Params[0].GetValue( tool ), m_Params[1].GetValue( tool ), m_GerbMetric );
ConvertShapeToPolygon( aParent, subshape_poly );
// shape rotation:
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[5].GetValue( tool ), DEGREES_T );
// Because a thermal shape has 4 identical sub-shapes, only one is created in subshape_poly.
// We must draw 4 sub-shapes rotated by 90 deg
@ -293,7 +293,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
* The moire primitive is a cross hair centered on concentric rings (annuli).
* Exposure is always on.
*/
curPos += mapPt( params[0].GetValue( tool ), params[1].GetValue( tool ),
curPos += mapPt( m_Params[0].GetValue( tool ), m_Params[1].GetValue( tool ),
m_GerbMetric );
/* Generated by an aperture macro declaration like:
@ -302,10 +302,10 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
* crosshair len, rotation. The type is not stored in parameters list, so the first
* parameter is pos.x.
*/
int outerDiam = scaletoIU( params[2].GetValue( tool ), m_GerbMetric );
int penThickness = scaletoIU( params[3].GetValue( tool ), m_GerbMetric );
int gap = scaletoIU( params[4].GetValue( tool ), m_GerbMetric );
int numCircles = KiROUND( params[5].GetValue( tool ) );
int outerDiam = scaletoIU( m_Params[2].GetValue( tool ), m_GerbMetric );
int penThickness = scaletoIU( m_Params[3].GetValue( tool ), m_GerbMetric );
int gap = scaletoIU( m_Params[4].GetValue( tool ), m_GerbMetric );
int numCircles = KiROUND( m_Params[5].GetValue( tool ) );
// Draw circles:
VECTOR2I center = aParent->GetABPosition( curPos );
@ -336,7 +336,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
// Draw the cross:
ConvertShapeToPolygon( aParent, polybuffer );
EDA_ANGLE rotation( params[8].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[8].GetValue( tool ), DEGREES_T );
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
{
@ -370,25 +370,25 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
* rotation
* type is not stored in parameters list, so the first parameter is exposure
*/
// params[0] is the exposure and params[1] is the corners count after the first corner
int numCorners = (int) params[1].GetValue( tool );
// m_Params[0] is the exposure and m_Params[1] is the corners count after the first corner
int numCorners = (int) m_Params[1].GetValue( tool );
// the shape rotation is the last param of list, after corners
int last_prm = params.size() - 1;
EDA_ANGLE rotation( params[last_prm].GetValue( tool ), DEGREES_T );
int last_prm = m_Params.size() - 1;
EDA_ANGLE rotation( m_Params[last_prm].GetValue( tool ), DEGREES_T );
VECTOR2I pos;
// Read points.
// Note: numCorners is the polygon corner count, following the first corner
// * the polygon is always closed,
// * therefore the last XY coordinate is the same as the first
int prm_idx = 2; // params[2] is the first X coordinate
int prm_idx = 2; // m_Params[2] is the first X coordinate
for( int i = 0; i <= numCorners; ++i )
{
pos.x = scaletoIU( params[prm_idx].GetValue( tool ), m_GerbMetric );
pos.x = scaletoIU( m_Params[prm_idx].GetValue( tool ), m_GerbMetric );
prm_idx++;
pos.y = scaletoIU( params[prm_idx].GetValue( tool ), m_GerbMetric );
pos.y = scaletoIU( m_Params[prm_idx].GetValue( tool ), m_GerbMetric );
prm_idx++;
polybuffer.push_back(pos);
@ -427,13 +427,13 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
* type(5), exposure, vertices count, pox.x, pos.y, diameter, rotation
* type is not stored in parameters list, so the first parameter is exposure
*/
curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric );
curPos += mapPt( m_Params[2].GetValue( tool ), m_Params[3].GetValue( tool ), m_GerbMetric );
// Creates the shape:
ConvertShapeToPolygon( aParent, polybuffer );
// rotate polygon and move it to the actual position
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
EDA_ANGLE rotation( m_Params[5].GetValue( tool ), DEGREES_T );
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
{
@ -463,7 +463,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
{
D_CODE* tool = aParent->GetDcodeDescr();
switch( primitive_id )
switch( m_Primitive_id )
{
case AMP_CIRCLE:
{
@ -473,14 +473,14 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
* <rotation> is a optional parameter: rotation from origin.
* type is not stored in parameters list, so the first parameter is exposure
*/
int radius = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ) / 2;
int radius = scaletoIU( m_Params[1].GetValue( tool ), m_GerbMetric ) / 2;
// A circle primitive can have a 0 size (for instance when used in roundrect macro),
// so skip it
if( radius <= 0 )
break;
VECTOR2I center = mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ),
VECTOR2I center = mapPt( m_Params[2].GetValue( tool ), m_Params[3].GetValue( tool ),
m_GerbMetric );
VECTOR2I corner;
EDA_ANGLE delta = ANGLE_360 / seg_per_circle; // rot angle in 0.1 degree
@ -500,11 +500,11 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
case AMP_LINE2:
case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation)
{
int width = scaletoIU( params[1].GetValue( tool ), m_GerbMetric );
int width = scaletoIU( m_Params[1].GetValue( tool ), m_GerbMetric );
VECTOR2I start =
mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[2].GetValue( tool ), m_Params[3].GetValue( tool ), m_GerbMetric );
VECTOR2I end =
mapPt( params[4].GetValue( tool ), params[5].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[4].GetValue( tool ), m_Params[5].GetValue( tool ), m_GerbMetric );
VECTOR2I delta = end - start;
int len = KiROUND( EuclideanNorm( delta ) );
@ -535,9 +535,9 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
case AMP_LINE_CENTER:
{
VECTOR2I size =
mapPt( params[1].GetValue( tool ), params[2].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[1].GetValue( tool ), m_Params[2].GetValue( tool ), m_GerbMetric );
VECTOR2I pos =
mapPt( params[3].GetValue( tool ), params[4].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[3].GetValue( tool ), m_Params[4].GetValue( tool ), m_GerbMetric );
// Build poly:
pos.x -= size.x / 2;
@ -555,9 +555,9 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
case AMP_LINE_LOWER_LEFT:
{
VECTOR2I size =
mapPt( params[1].GetValue( tool ), params[2].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[1].GetValue( tool ), m_Params[2].GetValue( tool ), m_GerbMetric );
VECTOR2I lowerLeft =
mapPt( params[3].GetValue( tool ), params[4].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[3].GetValue( tool ), m_Params[4].GetValue( tool ), m_GerbMetric );
// Build poly:
aBuffer.push_back( lowerLeft );
@ -574,16 +574,16 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
{
// Only 1/4 of the full shape is built, because the other 3 shapes will be draw from
// this first rotated by 90, 180 and 270 deg.
// params = center.x (unused here), center.y (unused here), outside diam, inside diam,
// m_Params = center.x (unused here), center.y (unused here), outside diam, inside diam,
// crosshair thickness.
int outerRadius = scaletoIU( params[2].GetValue( tool ), m_GerbMetric ) / 2;
int innerRadius = scaletoIU( params[3].GetValue( tool ), m_GerbMetric ) / 2;
int outerRadius = scaletoIU( m_Params[2].GetValue( tool ), m_GerbMetric ) / 2;
int innerRadius = scaletoIU( m_Params[3].GetValue( tool ), m_GerbMetric ) / 2;
// Safety checks to guarantee no divide-by-zero
outerRadius = std::max( 1, outerRadius );
innerRadius = std::max( 1, innerRadius );
int halfthickness = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2;
int halfthickness = scaletoIU( m_Params[4].GetValue( tool ), m_GerbMetric ) / 2;
EDA_ANGLE angle_start( asin( (double) halfthickness / innerRadius ), RADIANS_T );
// Draw shape in the first quadrant (X and Y > 0)
@ -632,8 +632,8 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
{
// A cross hair with n concentric circles. Only the cross is built as
// polygon because circles can be drawn easily
int crossHairThickness = scaletoIU( params[6].GetValue( tool ), m_GerbMetric );
int crossHairLength = scaletoIU( params[7].GetValue( tool ), m_GerbMetric );
int crossHairThickness = scaletoIU( m_Params[6].GetValue( tool ), m_GerbMetric );
int crossHairLength = scaletoIU( m_Params[7].GetValue( tool ), m_GerbMetric );
// Create cross. First create 1/4 of the shape.
// Others point are the same, rotated by 90, 180 and 270 deg
@ -666,8 +666,8 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
case AMP_POLYGON: // Creates a regular polygon
{
int vertexcount = KiROUND( params[1].GetValue( tool ) );
int radius = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2;
int vertexcount = KiROUND( m_Params[1].GetValue( tool ) );
int radius = scaletoIU( m_Params[4].GetValue( tool ), m_GerbMetric ) / 2;
// rs274x said: vertex count = 3 ... 10, and the first corner is on the X axis
if( vertexcount < 3 )
@ -699,22 +699,22 @@ int AM_PRIMITIVE::GetShapeDim( const GERBER_DRAW_ITEM* aParent )
int dim = -1;
D_CODE* tool = aParent->GetDcodeDescr();
switch( primitive_id )
switch( m_Primitive_id )
{
case AMP_CIRCLE:
// params = exposure, diameter, pos.x, pos.y
dim = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ); // Diameter
// m_Params = exposure, diameter, pos.x, pos.y
dim = scaletoIU( m_Params[1].GetValue( tool ), m_GerbMetric ); // Diameter
break;
case AMP_LINE2:
case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation)
dim = scaletoIU( params[1].GetValue( tool ), m_GerbMetric ); // line width
dim = scaletoIU( m_Params[1].GetValue( tool ), m_GerbMetric ); // line width
break;
case AMP_LINE_CENTER:
{
VECTOR2I size =
mapPt( params[1].GetValue( tool ), params[2].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[1].GetValue( tool ), m_Params[2].GetValue( tool ), m_GerbMetric );
dim = std::min(size.x, size.y);
break;
}
@ -722,7 +722,7 @@ int AM_PRIMITIVE::GetShapeDim( const GERBER_DRAW_ITEM* aParent )
case AMP_LINE_LOWER_LEFT:
{
VECTOR2I size =
mapPt( params[1].GetValue( tool ), params[2].GetValue( tool ), m_GerbMetric );
mapPt( m_Params[1].GetValue( tool ), m_Params[2].GetValue( tool ), m_GerbMetric );
dim = std::min(size.x, size.y);
break;
}
@ -731,14 +731,14 @@ int AM_PRIMITIVE::GetShapeDim( const GERBER_DRAW_ITEM* aParent )
{
// Only 1/4 of the full shape is built, because the other 3 shapes will be draw from
// this first rotated by 90, 180 and 270 deg.
// params = center.x (unused here), center.y (unused here), outside diam, inside diam,
// m_Params = center.x (unused here), center.y (unused here), outside diam, inside diam,
// crosshair thickness.
dim = scaletoIU( params[2].GetValue( tool ), m_GerbMetric ) / 2; // Outer diam
dim = scaletoIU( m_Params[2].GetValue( tool ), m_GerbMetric ) / 2; // Outer diam
break;
}
case AMP_MOIRE: // A cross hair with n concentric circles.
dim = scaletoIU( params[7].GetValue( tool ), m_GerbMetric ); // = cross hair len
dim = scaletoIU( m_Params[7].GetValue( tool ), m_GerbMetric ); // = cross hair len
break;
case AMP_OUTLINE: // a free polygon :
@ -747,19 +747,19 @@ int AM_PRIMITIVE::GetShapeDim( const GERBER_DRAW_ITEM* aParent )
// criteria b?)
// exposure, corners count, corner1.x, corner.1y, ..., rotation
// note: corners count is the count of corners following corner1
int numPoints = (int) params[1].GetValue( tool );
int numPoints = (int) m_Params[1].GetValue( tool );
// Read points. numPoints does not include the starting point, so add 1.
// and calculate the bounding box;
VECTOR2I pos_min, pos_max, pos;
int prm_idx = 2; // params[2] is the first X coordinate
int last_prm = params.size() - 1;
int prm_idx = 2; // m_Params[2] is the first X coordinate
int last_prm = m_Params.size() - 1;
for( int i = 0; i<= numPoints; ++i )
{
pos.x = scaletoIU( params[prm_idx].GetValue( tool ), m_GerbMetric );
pos.x = scaletoIU( m_Params[prm_idx].GetValue( tool ), m_GerbMetric );
prm_idx++;
pos.y = scaletoIU( params[prm_idx].GetValue( tool ), m_GerbMetric );
pos.y = scaletoIU( m_Params[prm_idx].GetValue( tool ), m_GerbMetric );
prm_idx++;
if( i == 0 )
@ -799,7 +799,7 @@ int AM_PRIMITIVE::GetShapeDim( const GERBER_DRAW_ITEM* aParent )
}
case AMP_POLYGON: // Regular polygon
dim = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2; // Radius
dim = scaletoIU( m_Params[4].GetValue( tool ), m_GerbMetric ) / 2; // Radius
break;
case AMP_COMMENT:
@ -819,10 +819,10 @@ SHAPE_POLY_SET* APERTURE_MACRO::GetApertureMacroShape( const GERBER_DRAW_ITEM* a
m_shape.RemoveAllContours();
for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
prim_macro != primitives.end(); ++prim_macro )
for( AM_PRIMITIVES::iterator prim_macro = m_PrimitivesList.begin();
prim_macro != m_PrimitivesList.end(); ++prim_macro )
{
if( prim_macro->primitive_id == AMP_COMMENT )
if( prim_macro->m_Primitive_id == AMP_COMMENT )
continue;
if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
@ -882,8 +882,8 @@ int APERTURE_MACRO::GetShapeDim( GERBER_DRAW_ITEM* aParent )
{
int dim = -1;
for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
prim_macro != primitives.end(); ++prim_macro )
for( AM_PRIMITIVES::iterator prim_macro = m_PrimitivesList.begin();
prim_macro != m_PrimitivesList.end(); ++prim_macro )
{
int pdim = prim_macro->GetShapeDim( aParent );
@ -900,11 +900,11 @@ double APERTURE_MACRO::GetLocalParam( const D_CODE* aDcode, unsigned aParamId )
// find parameter descr.
const AM_PARAM * param = nullptr;
for( unsigned ii = 0; ii < m_localparamStack.size(); ii ++ )
for( unsigned ii = 0; ii < m_LocalParamStack.size(); ii ++ )
{
if( m_localparamStack[ii].GetIndex() == aParamId )
if( m_LocalParamStack[ii].GetIndex() == aParamId )
{
param = &m_localparamStack[ii];
param = &m_LocalParamStack[ii];
break;
}
}

View File

@ -92,15 +92,14 @@ enum AM_PRIMITIVE_ID {
class AM_PRIMITIVE
{
public:
AM_PRIMITIVE_ID primitive_id; ///< The primitive type
AM_PARAMS params; ///< A sequence of parameters used by
// the primitive
AM_PRIMITIVE_ID m_Primitive_id; ///< The primitive type
AM_PARAMS m_Params; ///< A sequence of parameters used by the primitive
bool m_GerbMetric; // units for this primitive:
// false = Inches, true = metric
AM_PRIMITIVE( bool aGerbMetric, AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
{
primitive_id = aId;
m_Primitive_id = aId;
m_GerbMetric = aGerbMetric;
}
@ -163,8 +162,9 @@ typedef std::vector<AM_PRIMITIVE> AM_PRIMITIVES;
/**
* Support the "aperture macro" defined within standard RS274X.
*/
struct APERTURE_MACRO
class APERTURE_MACRO
{
public:
/**
* Usually, parameters are defined inside the aperture primitive using immediate mode or
* deferred mode.
@ -207,9 +207,7 @@ struct APERTURE_MACRO
const VECTOR2I& aShapePos, bool aFilledShape );
/**
* C
*
* alculate a value that can be used to evaluate the size of text when displaying the
* 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
@ -228,8 +226,9 @@ struct APERTURE_MACRO
return m_boundingBox;
}
wxString name; ///< The name of the aperture macro
AM_PRIMITIVES primitives; ///< A sequence of AM_PRIMITIVEs
wxString m_AmName; ///< The name of the aperture macro as defined
///< like %AMVB_RECTANGLE* (name is VB_RECTANGLE)
AM_PRIMITIVES m_PrimitivesList; ///< A sequence of AM_PRIMITIVEs
/* A deferred parameter can be defined in aperture macro,
* but outside aperture primitives. Example
@ -237,8 +236,9 @@ struct APERTURE_MACRO
* $4=$3/2* parameter $4 is half value of parameter $3
* m_localparamStack handle a list of local deferred parameters
*/
AM_PARAMS m_localparamStack;
AM_PARAMS m_LocalParamStack;
private:
SHAPE_POLY_SET m_shape; ///< The shape of the item, calculated by GetApertureMacroShape
BOX2I m_boundingBox; ///< The bounding box of the item, calculated by
///< GetApertureMacroShape.
@ -254,7 +254,7 @@ struct APERTURE_MACRO_less_than
// a "less than" test on two APERTURE_MACROs (.name wxStrings)
bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
{
return am1.name.Cmp( am2.name ) < 0; // case specific wxString compare
return am1.m_AmName.Cmp( am2.m_AmName ) < 0; // case specific wxString compare
}
};

View File

@ -70,7 +70,7 @@ enum APERTURE_DEF_HOLETYPE {
#define LAST_DCODE 10000
#define TOOLS_MAX_COUNT (LAST_DCODE + 1)
struct APERTURE_MACRO;
class APERTURE_MACRO;
/**

View File

@ -224,7 +224,7 @@ wxString GERBER_DRAW_ITEM::ShowGBRShape() const
D_CODE* dcode = GetDcodeDescr();
if( dcode && dcode->GetMacro() )
name << wxT(" ") << dcode->GetMacro()->name;
name << wxT(" ") << dcode->GetMacro()->m_AmName;
return name;
}

View File

@ -35,6 +35,7 @@
#include <macros.h>
#include <X2_gerber_attributes.h>
#include <gbr_metadata.h>
#include <wx/log.h>
extern int ReadInt( char*& text, bool aSkipSeparator = true );
extern double ReadDouble( char*& text, bool aSkipSeparator = true );
@ -852,7 +853,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff,
APERTURE_MACRO am_lookup;
while( *aText && *aText != '*' && *aText != ',' )
am_lookup.name.Append( *aText++ );
am_lookup.m_AmName.Append( *aText++ );
// When an aperture definition is like %AMLINE2* 22,1,$1,$2,0,0,-45*
// the ADDxx<MACRO_NAME> command has parameters, like %ADD14LINE2,0.8X0.5*%
@ -869,7 +870,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff,
{
msg.Printf( wxT( "RS274X: aperture macro %s has invalid template "
"parameters\n" ),
TO_UTF8( am_lookup.name ) );
TO_UTF8( am_lookup.m_AmName ) );
AddMessageToList( msg );
ok = false;
break;
@ -890,7 +891,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff,
if( !pam )
{
msg.Printf( wxT( "RS274X: aperture macro %s not found\n" ),
TO_UTF8( am_lookup.name ) );
TO_UTF8( am_lookup.m_AmName ) );
AddMessageToList( msg );
ok = false;
break;
@ -986,7 +987,7 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
break;
}
am.name.Append( *aText++ );
am.m_AmName.Append( *aText++ );
}
// Read aperture macro parameters
@ -1019,18 +1020,20 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
// all other symbols are illegal.
if( *aText == '$' ) // local parameter declaration, inside the aperture macro
{
am.m_localparamStack.push_back( AM_PARAM() );
AM_PARAM& param = am.m_localparamStack.back();
am.m_LocalParamStack.push_back( AM_PARAM() );
AM_PARAM& param = am.m_LocalParamStack.back();
aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
if( aText == nullptr) // End of File
return false;
param.ReadParam( aText );
continue;
}
else if( !isdigit(*aText) ) // Ill. symbol
{
msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": ill. symbol, line: \"%s\"" ),
am.name, FROM_UTF8( aBuff ) );
am.m_AmName, FROM_UTF8( aBuff ) );
AddMessageToList( msg );
primitive_type = AMP_COMMENT;
}
@ -1088,7 +1091,7 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
default:
msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line %d: \"%s\"" ),
am.name, primitive_type, m_LineNum, FROM_UTF8( aBuff ) );
am.m_AmName, primitive_type, m_LineNum, FROM_UTF8( aBuff ) );
AddMessageToList( msg );
return false;
}
@ -1097,14 +1100,14 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
continue;
AM_PRIMITIVE prim( m_GerbMetric );
prim.primitive_id = (AM_PRIMITIVE_ID) primitive_type;
prim.m_Primitive_id = (AM_PRIMITIVE_ID) primitive_type;
int ii;
for( ii = 0; ii < paramCount && *aText && *aText != '*'; ++ii )
{
prim.params.push_back( AM_PARAM() );
prim.m_Params.push_back( AM_PARAM() );
AM_PARAM& param = prim.params.back();
AM_PARAM& param = prim.m_Params.back();
aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
@ -1119,27 +1122,27 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
// maybe some day we can throw an exception and track a line number
msg.Printf( wxT( "RS274X: read macro descr type %d: read %d parameters, insufficient "
"parameters\n" ),
prim.primitive_id, ii );
prim.m_Primitive_id, ii );
AddMessageToList( msg );
}
// there are more parameters to read if this is an AMP_OUTLINE
if( prim.primitive_id == AMP_OUTLINE )
if( prim.m_Primitive_id == AMP_OUTLINE )
{
// so far we have read [0]:exposure, [1]:#points, [2]:X start, [3]: Y start
// Now read all the points, plus trailing rotation in degrees.
// params[1] is a count of polygon points, so it must be given
// m_Params[1] is a count of polygon points, so it must be given
// in advance, i.e. be immediate.
wxASSERT( prim.params[1].IsImmediate() );
wxASSERT( prim.m_Params[1].IsImmediate() );
paramCount = (int) prim.params[1].GetValue( nullptr ) * 2 + 1;
paramCount = (int) prim.m_Params[1].GetValue( nullptr ) * 2 + 1;
for( int jj = 0; jj < paramCount && *aText != '*'; ++jj )
{
prim.params.push_back( AM_PARAM() );
prim.m_Params.push_back( AM_PARAM() );
AM_PARAM& param = prim.params.back();
AM_PARAM& param = prim.m_Params.back();
aText = GetNextLine( aBuff, aBuffSize, aText, gerber_file );
@ -1151,14 +1154,14 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
}
// AMP_CIRCLE can have a optional parameter (rotation)
if( prim.primitive_id == AMP_CIRCLE && aText && *aText != '*' )
if( prim.m_Primitive_id == AMP_CIRCLE && aText && *aText != '*' )
{
prim.params.push_back( AM_PARAM() );
AM_PARAM& param = prim.params.back();
prim.m_Params.push_back( AM_PARAM() );
AM_PARAM& param = prim.m_Params.back();
param.ReadParam( aText );
}
am.primitives.push_back( prim );
am.m_PrimitivesList.push_back( prim );
}
m_aperture_macros.insert( am );