Read files with rectangle primitives in custom pads.

This commit is contained in:
Jeff Young 2020-06-19 16:09:25 +01:00
parent 09cb75b8a1
commit 9ba9f0288e
3 changed files with 48 additions and 24 deletions

View File

@ -304,17 +304,19 @@ public:
* a curve
*/
void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness,
bool aMergePrimitives = true ); ///< add a polygonal basic shape
bool aMergePrimitives = true );
void AddPrimitivePoly( const std::vector<wxPoint>& aPoly, int aThickness,
bool aMergePrimitives = true ); ///< add a polygonal basic shape
void AddPrimitiveSegment( wxPoint aStart, wxPoint aEnd, int aThickness,
bool aMergePrimitives = true ); ///< segment basic shape
void AddPrimitiveCircle( wxPoint aCenter, int aRadius, int aThickness,
bool aMergePrimitives = true ); ///< ring or circle basic shape
void AddPrimitiveArc( wxPoint aCenter, wxPoint aStart, int aArcAngle, int aThickness,
bool aMergePrimitives = true ); ///< arc basic shape
void AddPrimitiveCurve( wxPoint aStart, wxPoint aEnd, wxPoint aCtrl1, wxPoint aCtrl2,
int aThickness, bool aMergePrimitives = true ); ///< curve basic shape
bool aMergePrimitives = true );
void AddPrimitiveSegment( const wxPoint& aStart, const wxPoint& aEnd, int aThickness,
bool aMergePrimitives = true );
void AddPrimitiveCircle( const wxPoint& aCenter, int aRadius, int aThickness,
bool aMergePrimitives = true ); ///< ring or circle basic shape
void AddPrimitiveRect( const wxPoint& aStart, const wxPoint& aEnd, int aThickness,
bool aMergePrimitives = true );
void AddPrimitiveArc( const wxPoint& aCenter, const wxPoint& aStart, int aArcAngle,
int aThickness, bool aMergePrimitives = true );
void AddPrimitiveCurve( const wxPoint& aStart, const wxPoint& aEnd, const wxPoint& aCtrl1,
const wxPoint& aCtrl2, int aThickness, bool aMergePrimitives = true );
bool GetBestAnchorPosition( VECTOR2I& aPos );

View File

@ -174,7 +174,7 @@ void D_PAD::AddPrimitivePoly( const std::vector<wxPoint>& aPoly, int aThickness,
}
void D_PAD::AddPrimitiveSegment( wxPoint aStart, wxPoint aEnd, int aThickness,
void D_PAD::AddPrimitiveSegment( const wxPoint& aStart, const wxPoint& aEnd, int aThickness,
bool aMergePrimitives )
{
PAD_CS_PRIMITIVE shape( S_SEGMENT );
@ -188,8 +188,8 @@ void D_PAD::AddPrimitiveSegment( wxPoint aStart, wxPoint aEnd, int aThickness,
}
void D_PAD::AddPrimitiveArc( wxPoint aCenter, wxPoint aStart, int aArcAngle, int aThickness,
bool aMergePrimitives )
void D_PAD::AddPrimitiveArc( const wxPoint& aCenter, const wxPoint& aStart, int aArcAngle,
int aThickness, bool aMergePrimitives )
{
PAD_CS_PRIMITIVE shape( S_ARC );
shape.m_Start = aCenter;
@ -203,8 +203,8 @@ void D_PAD::AddPrimitiveArc( wxPoint aCenter, wxPoint aStart, int aArcAngle, int
}
void D_PAD::AddPrimitiveCurve( wxPoint aStart, wxPoint aEnd, wxPoint aCtrl1, wxPoint aCtrl2,
int aThickness, bool aMergePrimitives )
void D_PAD::AddPrimitiveCurve( const wxPoint& aStart, const wxPoint& aEnd, const wxPoint& aCtrl1,
const wxPoint& aCtrl2, int aThickness, bool aMergePrimitives )
{
PAD_CS_PRIMITIVE shape( S_CURVE );
shape.m_Start = aStart;
@ -219,7 +219,7 @@ void D_PAD::AddPrimitiveCurve( wxPoint aStart, wxPoint aEnd, wxPoint aCtrl1, wxP
}
void D_PAD::AddPrimitiveCircle( wxPoint aCenter, int aRadius, int aThickness,
void D_PAD::AddPrimitiveCircle( const wxPoint& aCenter, int aRadius, int aThickness,
bool aMergePrimitives )
{
PAD_CS_PRIMITIVE shape( S_CIRCLE );
@ -233,6 +233,20 @@ void D_PAD::AddPrimitiveCircle( wxPoint aCenter, int aRadius, int aThickness,
}
void D_PAD::AddPrimitiveRect( const wxPoint& aStart, const wxPoint& aEnd, int aThickness,
bool aMergePrimitives )
{
PAD_CS_PRIMITIVE shape( S_RECT );
shape.m_Start = aStart;
shape.m_End = aEnd;
shape.m_Thickness = aThickness;
m_basicShapes.push_back( shape );
if( aMergePrimitives )
MergePrimitivesAsPolygon();
}
bool D_PAD::SetPrimitives( const std::vector<PAD_CS_PRIMITIVE>& aPrimitivesList )
{
// clear old list

View File

@ -3352,37 +3352,45 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent )
case T_gr_arc:
dummysegm = parseDRAWSEGMENT();
pad->AddPrimitiveArc( dummysegm->GetCenter(), dummysegm->GetArcStart(),
dummysegm->GetAngle(), dummysegm->GetWidth(), false );
dummysegm->GetAngle(), dummysegm->GetWidth(), false );
break;
case T_gr_line:
dummysegm = parseDRAWSEGMENT();
pad->AddPrimitiveSegment( dummysegm->GetStart(), dummysegm->GetEnd(),
dummysegm->GetWidth(), false );
dummysegm->GetWidth(), false );
break;
case T_gr_circle:
dummysegm = parseDRAWSEGMENT( true ); // Circles with 0 thickness are allowed
// ( filled circles )
pad->AddPrimitiveCircle( dummysegm->GetCenter(), dummysegm->GetRadius(),
dummysegm->GetWidth(), false );
dummysegm->GetWidth(), false );
break;
case T_gr_rect:
dummysegm = parseDRAWSEGMENT( true );
pad->AddPrimitiveRect( dummysegm->GetStart(), dummysegm->GetEnd(),
dummysegm->GetWidth(), false );
break;
case T_gr_poly:
dummysegm = parseDRAWSEGMENT();
pad->AddPrimitivePoly(
dummysegm->BuildPolyPointsList(), dummysegm->GetWidth(), false );
pad->AddPrimitivePoly( dummysegm->BuildPolyPointsList(),
dummysegm->GetWidth(), false );
break;
case T_gr_curve:
dummysegm = parseDRAWSEGMENT();
pad->AddPrimitiveCurve( dummysegm->GetStart(), dummysegm->GetEnd(),
dummysegm->GetBezControl1(), dummysegm->GetBezControl2(),
dummysegm->GetWidth(), false );
dummysegm->GetBezControl1(),
dummysegm->GetBezControl2(),
dummysegm->GetWidth(), false );
break;
default:
Expecting( "gr_line, gr_arc, gr_circle, gr_curve or gr_poly" );
Expecting( "gr_line, gr_arc, gr_circle, gr_curve, gr_rect or gr_poly" );
break;
}