Naming conventions and a bug fix on arc points.

This commit is contained in:
Jeff Young 2021-07-18 13:31:56 +01:00
parent 9cb4c9bfc2
commit e61822c9e0
40 changed files with 475 additions and 459 deletions

View File

@ -257,10 +257,10 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
}
// For Bezier curve:
m_bezierCtrl1X.SetValue( m_item->GetBezControl1().x );
m_bezierCtrl1Y.SetValue( m_item->GetBezControl1().y );
m_bezierCtrl2X.SetValue( m_item->GetBezControl2().x );
m_bezierCtrl2Y.SetValue( m_item->GetBezControl2().y );
m_bezierCtrl1X.SetValue( m_item->GetBezierC1().x );
m_bezierCtrl1Y.SetValue( m_item->GetBezierC1().y );
m_bezierCtrl2X.SetValue( m_item->GetBezierC2().x );
m_bezierCtrl2Y.SetValue( m_item->GetBezierC2().y );
m_filledCtrl->SetValue( m_item->IsFilled() );
m_locked->SetValue( m_item->IsLocked() );
@ -329,8 +329,8 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
// For Bezier curve: Set the two control points
if( m_item->GetShape() == PCB_SHAPE_TYPE::CURVE )
{
m_item->SetBezControl1( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue() ) );
m_item->SetBezControl2( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue() ) );
m_item->SetBezierC1( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue()));
m_item->SetBezierC2( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue()));
}
if( m_item->GetShape() == PCB_SHAPE_TYPE::ARC )
@ -347,8 +347,8 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
if( m_fp_item->GetShape() == PCB_SHAPE_TYPE::CURVE )
{
m_fp_item->SetBezier0_C1( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue() ) );
m_fp_item->SetBezier0_C2( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue() ) );
m_fp_item->SetBezierC1_0( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue()));
m_fp_item->SetBezierC2_0( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue()));
}
}

View File

@ -101,10 +101,10 @@ bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow()
m_startY.SetValue( m_shape->GetStart().y );
m_endX.SetValue( m_shape->GetEnd().x );
m_endY.SetValue( m_shape->GetEnd().y );
m_ctrl1X.SetValue( m_shape->GetBezControl1().x );
m_ctrl1Y.SetValue( m_shape->GetBezControl1().y );
m_ctrl2X.SetValue( m_shape->GetBezControl2().x );
m_ctrl2Y.SetValue( m_shape->GetBezControl2().y );
m_ctrl1X.SetValue( m_shape->GetBezierC1().x );
m_ctrl1Y.SetValue( m_shape->GetBezierC1().y );
m_ctrl2X.SetValue( m_shape->GetBezierC2().x );
m_ctrl2Y.SetValue( m_shape->GetBezierC2().y );
m_radius.Show( false );
m_filledCtrl->Show( false );
break;
@ -192,8 +192,8 @@ bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow()
case PCB_SHAPE_TYPE::CURVE: // Segment with rounded ends
m_shape->SetStart( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) );
m_shape->SetEnd( wxPoint( m_endX.GetValue(), m_endY.GetValue() ) );
m_shape->SetBezControl1( wxPoint( m_ctrl1X.GetValue(), m_ctrl1Y.GetValue() ) );
m_shape->SetBezControl1( wxPoint( m_ctrl2X.GetValue(), m_ctrl2Y.GetValue() ) );
m_shape->SetBezierC1( wxPoint( m_ctrl1X.GetValue(), m_ctrl1Y.GetValue()));
m_shape->SetBezierC1( wxPoint( m_ctrl2X.GetValue(), m_ctrl2Y.GetValue()));
break;
case PCB_SHAPE_TYPE::ARC: // Arc with rounded ends

View File

@ -1212,43 +1212,44 @@ static void FootprintWriteShape( FILE* aFile, FOOTPRINT* aFootprint, const wxStr
{
case PCB_SHAPE_TYPE::SEGMENT:
fprintf( aFile, "LINE %g %g %g %g\n",
shape->m_Start0.x / SCALE_FACTOR,
-shape->m_Start0.y / SCALE_FACTOR,
shape->m_End0.x / SCALE_FACTOR,
-shape->m_End0.y / SCALE_FACTOR );
shape->GetStart0().x / SCALE_FACTOR,
-shape->GetStart0().y / SCALE_FACTOR,
shape->GetEnd0().x / SCALE_FACTOR,
-shape->GetEnd0().y / SCALE_FACTOR );
break;
case PCB_SHAPE_TYPE::RECT:
{
fprintf( aFile, "LINE %g %g %g %g\n",
shape->m_Start0.x / SCALE_FACTOR,
-shape->m_Start0.y / SCALE_FACTOR,
shape->m_End0.x / SCALE_FACTOR,
-shape->m_Start0.y / SCALE_FACTOR );
shape->GetStart0().x / SCALE_FACTOR,
-shape->GetStart0().y / SCALE_FACTOR,
shape->GetEnd0().x / SCALE_FACTOR,
-shape->GetStart0().y / SCALE_FACTOR );
fprintf( aFile, "LINE %g %g %g %g\n",
shape->m_End0.x / SCALE_FACTOR,
-shape->m_Start0.y / SCALE_FACTOR,
shape->m_End0.x / SCALE_FACTOR,
-shape->m_End0.y / SCALE_FACTOR );
shape->GetEnd0().x / SCALE_FACTOR,
-shape->GetStart0().y / SCALE_FACTOR,
shape->GetEnd0().x / SCALE_FACTOR,
-shape->GetEnd0().y / SCALE_FACTOR );
fprintf( aFile, "LINE %g %g %g %g\n",
shape->m_End0.x / SCALE_FACTOR,
-shape->m_End0.y / SCALE_FACTOR,
shape->m_Start0.x / SCALE_FACTOR,
-shape->m_End0.y / SCALE_FACTOR );
shape->GetEnd0().x / SCALE_FACTOR,
-shape->GetEnd0().y / SCALE_FACTOR,
shape->GetStart0().x / SCALE_FACTOR,
-shape->GetEnd0().y / SCALE_FACTOR );
fprintf( aFile, "LINE %g %g %g %g\n",
shape->m_Start0.x / SCALE_FACTOR,
-shape->m_End0.y / SCALE_FACTOR,
shape->m_Start0.x / SCALE_FACTOR,
-shape->m_Start0.y / SCALE_FACTOR );
shape->GetStart0().x / SCALE_FACTOR,
-shape->GetEnd0().y / SCALE_FACTOR,
shape->GetStart0().x / SCALE_FACTOR,
-shape->GetStart0().y / SCALE_FACTOR );
}
break;
case PCB_SHAPE_TYPE::CIRCLE:
{
int radius = KiROUND( GetLineLength( shape->m_End0, shape->m_Start0 ) );
int radius = KiROUND( GetLineLength( shape->GetEnd0(), shape->GetStart0() ) );
fprintf( aFile, "CIRCLE %g %g %g\n",
shape->m_Start0.x / SCALE_FACTOR,
-shape->m_Start0.y / SCALE_FACTOR,
shape->GetStart0().x / SCALE_FACTOR,
-shape->GetStart0().y / SCALE_FACTOR,
radius / SCALE_FACTOR );
break;
}
@ -1256,14 +1257,14 @@ static void FootprintWriteShape( FILE* aFile, FOOTPRINT* aFootprint, const wxStr
case PCB_SHAPE_TYPE::ARC:
{
int arcendx, arcendy;
arcendx = shape->m_End0.x - shape->m_Start0.x;
arcendy = shape->m_End0.y - shape->m_Start0.y;
arcendx = shape->GetEnd0().x - shape->GetStart0().x;
arcendy = shape->GetEnd0().y - shape->GetStart0().y;
RotatePoint( &arcendx, &arcendy, -shape->GetAngle() );
arcendx += shape->GetStart0().x;
arcendy += shape->GetStart0().y;
fprintf( aFile, "ARC %g %g %g %g %g %g\n",
shape->m_End0.x / SCALE_FACTOR,
shape->GetEnd0().x / SCALE_FACTOR,
-shape->GetEnd0().y / SCALE_FACTOR,
arcendx / SCALE_FACTOR,
-arcendy / SCALE_FACTOR,

View File

@ -57,25 +57,25 @@ void FP_SHAPE::SetLocalCoord()
if( fp == NULL )
{
m_Start0 = m_start;
m_End0 = m_end;
m_ThirdPoint0 = m_thirdPoint;
m_Bezier0_C1 = m_bezierC1;
m_Bezier0_C2 = m_bezierC2;
m_start0 = m_start;
m_end0 = m_end;
m_thirdPoint0 = m_thirdPoint;
m_bezierC1_0 = m_bezierC1;
m_bezierC2_0 = m_bezierC2;
return;
}
m_Start0 = m_start - fp->GetPosition();
m_End0 = m_end - fp->GetPosition();
m_ThirdPoint0 = m_thirdPoint - fp->GetPosition();
m_Bezier0_C1 = m_bezierC1 - fp->GetPosition();
m_Bezier0_C2 = m_bezierC2 - fp->GetPosition();
m_start0 = m_start - fp->GetPosition();
m_end0 = m_end - fp->GetPosition();
m_thirdPoint0 = m_thirdPoint - fp->GetPosition();
m_bezierC1_0 = m_bezierC1 - fp->GetPosition();
m_bezierC2_0 = m_bezierC2 - fp->GetPosition();
double angle = fp->GetOrientation();
RotatePoint( &m_Start0.x, &m_Start0.y, -angle );
RotatePoint( &m_End0.x, &m_End0.y, -angle );
RotatePoint( &m_ThirdPoint0.x, &m_ThirdPoint0.y, -angle );
RotatePoint( &m_Bezier0_C1.x, &m_Bezier0_C1.y, -angle );
RotatePoint( &m_Bezier0_C2.x, &m_Bezier0_C2.y, -angle );
RotatePoint( &m_start0.x, &m_start0.y, -angle );
RotatePoint( &m_end0.x, &m_end0.y, -angle );
RotatePoint( &m_thirdPoint0.x, &m_thirdPoint0.y, -angle );
RotatePoint( &m_bezierC1_0.x, &m_bezierC1_0.y, -angle );
RotatePoint( &m_bezierC2_0.x, &m_bezierC2_0.y, -angle );
}
@ -83,11 +83,11 @@ void FP_SHAPE::SetDrawCoord()
{
FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_parent );
m_start = m_Start0;
m_end = m_End0;
m_thirdPoint = m_ThirdPoint0;
m_bezierC1 = m_Bezier0_C1;
m_bezierC2 = m_Bezier0_C2;
m_start = m_start0;
m_end = m_end0;
m_thirdPoint = m_thirdPoint0;
m_bezierC1 = m_bezierC1_0;
m_bezierC2 = m_bezierC2_0;
if( fp )
{
@ -146,11 +146,11 @@ void FP_SHAPE::SetAngle( double aAngle, bool aUpdateEnd )
// Update the parent class (updates the global m_ThirdPoint)
PCB_SHAPE::SetAngle( aAngle, aUpdateEnd );
// Also update the local m_ThirdPoint0 if requested
// Also update the local m_thirdPoint0 if requested
if( aUpdateEnd )
{
m_ThirdPoint0 = m_End0;
RotatePoint( &m_ThirdPoint0, m_Start0, -m_angle );
m_thirdPoint0 = m_end0;
RotatePoint( &m_thirdPoint0, m_start0, -m_angle );
}
}
@ -162,7 +162,7 @@ void FP_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
switch( GetShape() )
{
case PCB_SHAPE_TYPE::ARC:
// Update arc angle but do not yet update m_ThirdPoint0 and m_thirdPoint,
// Update arc angle but do not yet update m_thirdPoint0 and m_thirdPoint,
// arc center and start point must be updated before calculation arc end.
SetAngle( -GetAngle(), false );
KI_FALLTHROUGH;
@ -172,7 +172,7 @@ void FP_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
case PCB_SHAPE_TYPE::CURVE:
// If Start0 and Start are equal (ie: Footprint Editor), then flip both sets around the
// centre point.
if( m_start == m_Start0 )
if( m_start == m_start0 )
pt = aCentre;
if( aFlipLeftRight )
@ -182,11 +182,11 @@ void FP_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
MIRROR( m_thirdPoint.x, aCentre.x );
MIRROR( m_bezierC1.x, aCentre.x );
MIRROR( m_bezierC2.x, aCentre.x );
MIRROR( m_Start0.x, pt.x );
MIRROR( m_End0.x, pt.x );
MIRROR( m_ThirdPoint0.x, pt.x );
MIRROR( m_Bezier0_C1.x, pt.x );
MIRROR( m_Bezier0_C2.x, pt.x );
MIRROR( m_start0.x, pt.x );
MIRROR( m_end0.x, pt.x );
MIRROR( m_thirdPoint0.x, pt.x );
MIRROR( m_bezierC1_0.x, pt.x );
MIRROR( m_bezierC2_0.x, pt.x );
}
else
{
@ -195,11 +195,11 @@ void FP_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
MIRROR( m_thirdPoint.y, aCentre.y );
MIRROR( m_bezierC1.y, aCentre.y );
MIRROR( m_bezierC2.y, aCentre.y );
MIRROR( m_Start0.y, pt.y );
MIRROR( m_End0.y, pt.y );
MIRROR( m_ThirdPoint0.y, pt.y );
MIRROR( m_Bezier0_C1.y, pt.y );
MIRROR( m_Bezier0_C2.y, pt.y );
MIRROR( m_start0.y, pt.y );
MIRROR( m_end0.y, pt.y );
MIRROR( m_thirdPoint0.y, pt.y );
MIRROR( m_bezierC1_0.y, pt.y );
MIRROR( m_bezierC2_0.y, pt.y );
}
RebuildBezierToSegmentsPointsList( m_width );
@ -229,7 +229,7 @@ void FP_SHAPE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
switch( GetShape() )
{
case PCB_SHAPE_TYPE::ARC:
// Update arc angle but do not yet update m_ThirdPoint0 and m_thirdPoint,
// Update arc angle but do not yet update m_thirdPoint0 and m_thirdPoint,
// arc center and start point must be updated before calculation arc end.
SetAngle( -GetAngle(), false );
KI_FALLTHROUGH;
@ -239,19 +239,19 @@ void FP_SHAPE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
case PCB_SHAPE_TYPE::SEGMENT:
if( aMirrorAroundXAxis )
{
MIRROR( m_Start0.y, aCentre.y );
MIRROR( m_End0.y, aCentre.y );
MIRROR( m_ThirdPoint0.y, aCentre.y );
MIRROR( m_Bezier0_C1.y, aCentre.y );
MIRROR( m_Bezier0_C2.y, aCentre.y );
MIRROR( m_start0.y, aCentre.y );
MIRROR( m_end0.y, aCentre.y );
MIRROR( m_thirdPoint0.y, aCentre.y );
MIRROR( m_bezierC1_0.y, aCentre.y );
MIRROR( m_bezierC2_0.y, aCentre.y );
}
else
{
MIRROR( m_Start0.x, aCentre.x );
MIRROR( m_End0.x, aCentre.x );
MIRROR( m_ThirdPoint0.x, aCentre.x );
MIRROR( m_Bezier0_C1.x, aCentre.x );
MIRROR( m_Bezier0_C2.x, aCentre.x );
MIRROR( m_start0.x, aCentre.x );
MIRROR( m_end0.x, aCentre.x );
MIRROR( m_thirdPoint0.x, aCentre.x );
MIRROR( m_bezierC1_0.x, aCentre.x );
MIRROR( m_bezierC2_0.x, aCentre.x );
}
for( unsigned ii = 0; ii < m_bezierPoints.size(); ii++ )
@ -290,11 +290,11 @@ void FP_SHAPE::Move( const wxPoint& aMoveVector )
{
// Move an edge of the footprint.
// This is a footprint shape modification.
m_Start0 += aMoveVector;
m_End0 += aMoveVector;
m_ThirdPoint0 += aMoveVector;
m_Bezier0_C1 += aMoveVector;
m_Bezier0_C2 += aMoveVector;
m_start0 += aMoveVector;
m_end0 += aMoveVector;
m_thirdPoint0 += aMoveVector;
m_bezierC1_0 += aMoveVector;
m_bezierC2_0 += aMoveVector;
switch( GetShape() )
{

View File

@ -71,7 +71,7 @@ public:
* Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
* @param aAngle is tenths of degrees, but will soon be degrees.
* @param aUpdateEnd = true to update also arc end coordinates m_thirdPoint and
* m_ThirdPoint0, so must be called after setting m_Start, m_Start0, m_End and m_End0
* m_thirdPoint0, so must be called after setting m_Start, m_start0, m_End and m_end0
*/
void SetAngle( double aAngle, bool aUpdateEnd = true ) override;
@ -108,20 +108,20 @@ public:
bool IsParentFlipped() const;
void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
const wxPoint& GetStart0() const { return m_Start0; }
void SetStart0( const wxPoint& aPoint ) { m_start0 = aPoint; }
const wxPoint& GetStart0() const { return m_start0; }
void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
const wxPoint& GetEnd0() const { return m_End0; }
void SetEnd0( const wxPoint& aPoint ) { m_end0 = aPoint; }
const wxPoint& GetEnd0() const { return m_end0; }
void SetThirdPoint0( const wxPoint& aPoint ){ m_ThirdPoint0 = aPoint; }
const wxPoint& GetThirdPoint0() const { return m_ThirdPoint0; }
void SetThirdPoint0( const wxPoint& aPoint ){ m_thirdPoint0 = aPoint; }
const wxPoint& GetThirdPoint0() const { return m_thirdPoint0; }
void SetBezier0_C1( const wxPoint& aPoint ) { m_Bezier0_C1 = aPoint; }
const wxPoint& GetBezier0_C1() const { return m_Bezier0_C1; }
void SetBezierC1_0( const wxPoint& aPoint ) { m_bezierC1_0 = aPoint; }
const wxPoint& GetBezierC1_0() const { return m_bezierC1_0; }
void SetBezier0_C2( const wxPoint& aPoint ) { m_Bezier0_C2 = aPoint; }
const wxPoint& GetBezier0_C2() const { return m_Bezier0_C2; }
void SetBezierC2_0( const wxPoint& aPoint ) { m_bezierC2_0 = aPoint; }
const wxPoint& GetBezierC2_0() const { return m_bezierC2_0; }
/**
* Set relative coordinates from draw coordinates.
@ -157,11 +157,12 @@ public:
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
wxPoint m_Start0; ///< Start point or center, relative to footprint origin, orient 0.
wxPoint m_End0; ///< End point, relative to footprint origin, orient 0.
wxPoint m_ThirdPoint0; ///< End point for an arc.
wxPoint m_Bezier0_C1; ///< Bezier Control Point 1, relative to footprint origin, orient 0.
wxPoint m_Bezier0_C2; ///< Bezier Control Point 2, relative to footprint origin, orient 0.
protected:
wxPoint m_start0; ///< Start point or circle center, relative to footprint origin, orient 0.
wxPoint m_end0; ///< End point or circle edge, relative to footprint origin, orient 0.
wxPoint m_thirdPoint0; ///< End point for an arc.
wxPoint m_bezierC1_0; ///< Bezier Control Point 1, relative to footprint origin, orient 0.
wxPoint m_bezierC2_0; ///< Bezier Control Point 2, relative to footprint origin, orient 0.
};
#endif // FP_SHAPE_H

View File

@ -122,8 +122,8 @@ bool GRAPHICS_CLEANER::areEquivalent( PCB_SHAPE* aShape1, PCB_SHAPE* aShape2 )
return false;
case PCB_SHAPE_TYPE::CURVE:
return aShape1->GetBezControl1() == aShape2->GetBezControl1()
&& aShape1->GetBezControl2() == aShape2->GetBezControl2()
return aShape1->GetBezierC1() == aShape2->GetBezierC1()
&& aShape1->GetBezierC2() == aShape2->GetBezierC2()
&& aShape1->GetBezierPoints() == aShape2->GetBezierPoints();
default:

View File

@ -164,8 +164,8 @@ void GRAPHICS_IMPORTER_PCBNEW::AddSpline( const VECTOR2D& aStart, const VECTOR2D
spline->SetLayer( GetLayer() );
spline->SetWidth( MapLineWidth( aWidth ) );
spline->SetStart( MapCoordinate( aStart ) );
spline->SetBezControl1( MapCoordinate( BezierControl1 ) );
spline->SetBezControl2( MapCoordinate( BezierControl2 ) );
spline->SetBezierC1( MapCoordinate( BezierControl1 ));
spline->SetBezierC2( MapCoordinate( BezierControl2 ));
spline->SetEnd( MapCoordinate( aEnd ) );
spline->RebuildBezierToSegmentsPointsList( aWidth );

View File

@ -104,8 +104,8 @@ void PAD::AddPrimitiveCurve( const wxPoint& aStart, const wxPoint& aEnd, const w
item->SetFilled( false );
item->SetStart( aStart );
item->SetEnd( aEnd );
item->SetBezControl1( aCtrl1 );
item->SetBezControl2( aCtrl2 );
item->SetBezierC1( aCtrl1 );
item->SetBezierC2( aCtrl2 );
item->SetWidth( aThickness );
item->SetParent( this );
m_editPrimitives.emplace_back( item );

View File

@ -1497,8 +1497,8 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
// Use thickness as filter value to convert the curve to polyline when the curve
// is not supported
m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
VECTOR2D( aShape->GetBezControl1() ),
VECTOR2D( aShape->GetBezControl2() ),
VECTOR2D( aShape->GetBezierC1() ),
VECTOR2D( aShape->GetBezierC2() ),
VECTOR2D( aShape->GetEnd() ), thickness );
}
else
@ -1510,8 +1510,8 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
// Use thickness as filter value to convert the curve to polyline when the curve
// is not supported
m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
VECTOR2D( aShape->GetBezControl1() ),
VECTOR2D( aShape->GetBezControl2() ),
VECTOR2D( aShape->GetBezierC1() ),
VECTOR2D( aShape->GetBezierC2() ),
VECTOR2D( aShape->GetEnd() ), thickness );
}
break;

View File

@ -109,11 +109,11 @@ public:
void SetShape( PCB_SHAPE_TYPE aShape ) { m_shape = aShape; }
PCB_SHAPE_TYPE GetShape() const { return m_shape; }
void SetBezControl1( const wxPoint& aPoint ) { m_bezierC1 = aPoint; }
const wxPoint& GetBezControl1() const { return m_bezierC1; }
void SetBezierC1( const wxPoint& aPoint ) { m_bezierC1 = aPoint; }
const wxPoint& GetBezierC1() const { return m_bezierC1; }
void SetBezControl2( const wxPoint& aPoint ) { m_bezierC2 = aPoint; }
const wxPoint& GetBezControl2() const { return m_bezierC2; }
void SetBezierC2( const wxPoint& aPoint ) { m_bezierC2 = aPoint; }
const wxPoint& GetBezierC2() const { return m_bezierC2; }
void SetPosition( const wxPoint& aPos ) override;
wxPoint GetPosition() const override;

View File

@ -679,8 +679,8 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape )
break;
case PCB_SHAPE_TYPE::CURVE:
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezControl1(),
aShape->GetBezControl2(), aShape->GetEnd(), 0, thickness );
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
break;
default:
@ -921,8 +921,8 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
break;
case PCB_SHAPE_TYPE::CURVE:
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezControl1(),
aShape->GetBezControl2(), aShape->GetEnd(), 0, thickness );
m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
break;
case PCB_SHAPE_TYPE::POLYGON:

View File

@ -1964,26 +1964,26 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers()
// We convert them to an oval in most cases, but handle also the possibility of
// encountering arcs in here.
std::vector<PCB_SHAPE*> outlineSegments =
getDrawSegmentsFromVertices( csCopper.Shape.Vertices );
std::vector<PCB_SHAPE*> outlineShapes = getShapesFromVertices( csCopper.Shape.Vertices );
for( auto& seg : outlineSegments )
for( PCB_SHAPE* shape : outlineShapes )
{
SHAPE_POLY_SET segment;
SHAPE_POLY_SET poly;
if( seg->GetShape() == PCB_SHAPE_TYPE::ARC )
if( shape->GetShape() == PCB_SHAPE_TYPE::ARC )
{
TransformArcToPolygon( segment, seg->GetStart(), seg->GetArcMid(),
seg->GetEnd(), copperWidth, ARC_HIGH_DEF,
TransformArcToPolygon( poly, shape->GetArcStart(), shape->GetArcMid(),
shape->GetArcEnd(), copperWidth, ARC_HIGH_DEF,
ERROR_LOC::ERROR_INSIDE );
}
else
{
TransformOvalToPolygon( segment, seg->GetStart(), seg->GetEnd(),
copperWidth, ARC_HIGH_DEF, ERROR_LOC::ERROR_INSIDE );
TransformOvalToPolygon( poly, shape->GetStart(), shape->GetEnd(),
copperWidth, ARC_HIGH_DEF,
ERROR_LOC::ERROR_INSIDE );
}
rawPolys.BooleanAdd( segment, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
rawPolys.BooleanAdd( poly, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
}
}
@ -2028,31 +2028,29 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers()
if( csCopper.Shape.Type == SHAPE_TYPE::OPENSHAPE
|| csCopper.Shape.Type == SHAPE_TYPE::OUTLINE )
{
std::vector<PCB_SHAPE*> outlineSegments =
getDrawSegmentsFromVertices( csCopper.Shape.Vertices );
std::vector<PCB_SHAPE*> outlineShapes = getShapesFromVertices( csCopper.Shape.Vertices );
std::vector<PCB_TRACK*> outlineTracks = makeTracksFromDrawsegments( outlineSegments,
m_board, getKiCadNet( csCopper.NetRef.NetID ),
getKiCadLayer( csCopper.LayerID ),
getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ) );
std::vector<PCB_TRACK*> outlineTracks = makeTracksFromShapes( outlineShapes, m_board,
getKiCadNet( csCopper.NetRef.NetID ),
getKiCadLayer( csCopper.LayerID ),
getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ) );
//cleanup
for( PCB_SHAPE* seg : outlineSegments )
delete seg;
for( PCB_SHAPE* shape : outlineShapes )
delete shape;
for( CUTOUT cutout : csCopper.Shape.Cutouts )
{
std::vector<PCB_SHAPE*> cutoutSeg =
getDrawSegmentsFromVertices( cutout.Vertices );
std::vector<PCB_SHAPE*> cutoutShapes = getShapesFromVertices( cutout.Vertices );
std::vector<PCB_TRACK*> cutoutTracks = makeTracksFromDrawsegments( cutoutSeg,
m_board, getKiCadNet( csCopper.NetRef.NetID ),
getKiCadLayer( csCopper.LayerID ),
getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ) );
std::vector<PCB_TRACK*> cutoutTracks = makeTracksFromShapes( cutoutShapes, m_board,
getKiCadNet( csCopper.NetRef.NetID ),
getKiCadLayer( csCopper.LayerID ),
getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ));
//cleanup
for( PCB_SHAPE* seg : cutoutSeg )
delete seg;
for( PCB_SHAPE* shape : cutoutShapes )
delete shape;
}
}
else
@ -2355,7 +2353,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks( const NET_ID& aCadstarNe
for( const NET_PCB::ROUTE_VERTEX& v : routeVertices )
{
PCB_SHAPE* shape = getDrawSegmentFromVertex( prevEnd, v.Vertex );
PCB_SHAPE* shape = getShapeFromVertex( prevEnd, v.Vertex );
shape->SetLayer( getKiCadLayer( aCadstarRoute.LayerID ) );
shape->SetWidth( getKiCadLength( v.RouteWidth ) );
shape->SetLocked( v.Fixed );
@ -2364,7 +2362,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks( const NET_ID& aCadstarNe
}
NETINFO_ITEM* net = getKiCadNet( aCadstarNetID );
std::vector<PCB_TRACK*> tracks = makeTracksFromDrawsegments( shapes, m_board, net );
std::vector<PCB_TRACK*> tracks = makeTracksFromShapes( shapes, m_board, net );
//cleanup
for( PCB_SHAPE* shape : shapes )
@ -2593,12 +2591,12 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
case SHAPE_TYPE::OPENSHAPE:
case SHAPE_TYPE::OUTLINE:
///TODO update this when Polygons in KiCad can be defined with no fill
drawCadstarVerticesAsSegments( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
drawCadstarCutoutsAsSegments( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
drawCadstarVerticesAsShapes( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
drawCadstarCutoutsAsShapes( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
break;
case SHAPE_TYPE::HATCHED:
@ -2643,50 +2641,61 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
}
void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarCutoutsAsSegments( const std::vector<CUTOUT>& aCutouts,
const PCB_LAYER_ID& aKiCadLayer,
const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID,
const wxPoint& aMoveVector,
const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarCutoutsAsShapes( const std::vector<CUTOUT>& aCutouts,
const PCB_LAYER_ID& aKiCadLayer,
const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID,
const wxPoint& aMoveVector,
const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
{
for( CUTOUT cutout : aCutouts )
{
drawCadstarVerticesAsSegments( cutout.Vertices, aKiCadLayer, aLineThickness, aContainer,
aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
drawCadstarVerticesAsShapes( cutout.Vertices, aKiCadLayer, aLineThickness, aContainer,
aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
}
}
void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarVerticesAsSegments(
const std::vector<VERTEX>& aCadstarVertices, const PCB_LAYER_ID& aKiCadLayer,
const int& aLineThickness, BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID, const wxPoint& aMoveVector, const double& aRotationAngle,
const double& aScalingFactor, const wxPoint& aTransformCentre, const bool& aMirrorInvert )
void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarVerticesAsShapes( const std::vector<VERTEX>& aCadstarVertices,
const PCB_LAYER_ID& aKiCadLayer,
const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID,
const wxPoint& aMoveVector,
const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
{
std::vector<PCB_SHAPE*> drawSegments =
getDrawSegmentsFromVertices( aCadstarVertices, aContainer, aCadstarGroupID, aMoveVector,
aRotationAngle, aScalingFactor, aTransformCentre, aMirrorInvert );
std::vector<PCB_SHAPE*> shapes = getShapesFromVertices( aCadstarVertices, aContainer,
aCadstarGroupID, aMoveVector,
aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
for( PCB_SHAPE* ds : drawSegments )
for( PCB_SHAPE* shape : shapes )
{
ds->SetWidth( aLineThickness );
ds->SetLayer( aKiCadLayer );
ds->SetParent( aContainer );
aContainer->Add( ds, ADD_MODE::APPEND );
shape->SetWidth( aLineThickness );
shape->SetLayer( aKiCadLayer );
shape->SetParent( aContainer );
aContainer->Add( shape, ADD_MODE::APPEND );
}
}
std::vector<PCB_SHAPE*> CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentsFromVertices(
const std::vector<VERTEX>& aCadstarVertices, BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID, const wxPoint& aMoveVector, const double& aRotationAngle,
const double& aScalingFactor, const wxPoint& aTransformCentre, const bool& aMirrorInvert )
std::vector<PCB_SHAPE*> CADSTAR_PCB_ARCHIVE_LOADER::getShapesFromVertices(
const std::vector<VERTEX>& aCadstarVertices,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID,
const wxPoint& aMoveVector,
const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
{
std::vector<PCB_SHAPE*> drawSegments;
@ -2700,9 +2709,9 @@ std::vector<PCB_SHAPE*> CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentsFromVertices(
for( size_t i = 1; i < aCadstarVertices.size(); i++ )
{
cur = &aCadstarVertices.at( i );
drawSegments.push_back(
getDrawSegmentFromVertex( prev->End, *cur, aContainer, aCadstarGroupID, aMoveVector,
aRotationAngle, aScalingFactor, aTransformCentre, aMirrorInvert ) );
drawSegments.push_back( getShapeFromVertex( prev->End, *cur, aContainer, aCadstarGroupID,
aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert ) );
prev = cur;
}
@ -2710,17 +2719,17 @@ std::vector<PCB_SHAPE*> CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentsFromVertices(
}
PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT& aCadstarStartPoint,
const VERTEX& aCadstarVertex,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID,
const wxPoint& aMoveVector,
const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex( const POINT& aCadstarStartPoint,
const VERTEX& aCadstarVertex,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID,
const wxPoint& aMoveVector,
const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
{
PCB_SHAPE* ds = nullptr;
PCB_SHAPE* shape = nullptr;
bool cw = false;
double arcStartAngle, arcEndAngle, arcAngle;
@ -2730,9 +2739,13 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT& aC
if( aCadstarVertex.Type == VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE
|| aCadstarVertex.Type == VERTEX_TYPE::CLOCKWISE_SEMICIRCLE )
{
centerPoint = ( startPoint + endPoint ) / 2;
}
else
{
centerPoint = getKiCadPoint( aCadstarVertex.Center );
}
switch( aCadstarVertex.Type )
{
@ -2741,16 +2754,16 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT& aC
if( isFootprint( aContainer ) )
{
ds = new FP_SHAPE( static_cast<FOOTPRINT*>( aContainer ), PCB_SHAPE_TYPE::SEGMENT );
shape = new FP_SHAPE( static_cast<FOOTPRINT*>( aContainer ), PCB_SHAPE_TYPE::SEGMENT );
}
else
{
ds = new PCB_SHAPE( aContainer );
ds->SetShape( PCB_SHAPE_TYPE::SEGMENT );
shape = new PCB_SHAPE( aContainer );
shape->SetShape( PCB_SHAPE_TYPE::SEGMENT );
}
ds->SetStart( startPoint );
ds->SetEnd( endPoint );
shape->SetStart( startPoint );
shape->SetEnd( endPoint );
break;
case VERTEX_TYPE::CLOCKWISE_SEMICIRCLE:
@ -2763,16 +2776,16 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT& aC
if( isFootprint( aContainer ) )
{
ds = new FP_SHAPE( (FOOTPRINT*) aContainer, PCB_SHAPE_TYPE::ARC );
shape = new FP_SHAPE((FOOTPRINT*) aContainer, PCB_SHAPE_TYPE::ARC );
}
else
{
ds = new PCB_SHAPE( aContainer );
ds->SetShape( PCB_SHAPE_TYPE::ARC );
shape = new PCB_SHAPE( aContainer );
shape->SetShape( PCB_SHAPE_TYPE::ARC );
}
ds->SetArcStart( startPoint );
ds->SetCenter( centerPoint );
shape->SetArcStart( startPoint );
shape->SetCenter( centerPoint );
arcStartAngle = getPolarAngle( startPoint - centerPoint );
arcEndAngle = getPolarAngle( endPoint - centerPoint );
@ -2781,37 +2794,37 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT& aC
// with opposite start/end points and same centre point)
if( cw )
ds->SetAngle( NormalizeAnglePos( arcAngle ) );
shape->SetAngle( NormalizeAnglePos( arcAngle ) );
else
ds->SetAngle( NormalizeAngleNeg( arcAngle ) );
shape->SetAngle( NormalizeAngleNeg( arcAngle ) );
break;
}
//Apply transforms
if( aMirrorInvert )
ds->Flip( aTransformCentre, true );
shape->Flip( aTransformCentre, true );
if( aScalingFactor != 1.0 )
{
ds->Move( -aTransformCentre );
ds->Scale( aScalingFactor );
ds->Move( aTransformCentre );
shape->Move( -aTransformCentre );
shape->Scale( aScalingFactor );
shape->Move( aTransformCentre );
}
if( aRotationAngle != 0.0 )
ds->Rotate( aTransformCentre, aRotationAngle );
shape->Rotate( aTransformCentre, aRotationAngle );
if( aMoveVector != wxPoint{ 0, 0 } )
ds->Move( aMoveVector );
shape->Move( aMoveVector );
if( isFootprint( aContainer ) && ds != nullptr )
static_cast<FP_SHAPE*>( ds )->SetLocalCoord();
if( isFootprint( aContainer ) && shape != nullptr )
static_cast<FP_SHAPE*>( shape )->SetLocalCoord();
if( !aCadstarGroupID.IsEmpty() )
addToGroup( aCadstarGroupID, ds );
addToGroup( aCadstarGroupID, shape );
return ds;
return shape;
}
@ -2853,35 +2866,29 @@ SHAPE_POLY_SET CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape( const SHA
{
GROUP_ID noGroup = wxEmptyString;
std::vector<PCB_SHAPE*> outlineSegments = getDrawSegmentsFromVertices( aCadstarShape.Vertices,
aContainer, noGroup,
aMoveVector,
aRotationAngle,
aScalingFactor,
aTransformCentre,
aMirrorInvert );
std::vector<PCB_SHAPE*> outlineShapes = getShapesFromVertices( aCadstarShape.Vertices,
aContainer, noGroup, aMoveVector,
aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
SHAPE_POLY_SET polySet( getLineChainFromDrawsegments( outlineSegments ) );
SHAPE_POLY_SET polySet( getLineChainFromShapes( outlineShapes ) );
//cleanup
for( PCB_SHAPE* seg : outlineSegments )
delete seg;
for( PCB_SHAPE* shape : outlineShapes )
delete shape;
for( CUTOUT cutout : aCadstarShape.Cutouts )
{
std::vector<PCB_SHAPE*> cutoutSeg = getDrawSegmentsFromVertices( cutout.Vertices,
aContainer, noGroup,
aMoveVector,
aRotationAngle,
aScalingFactor,
aTransformCentre,
aMirrorInvert );
std::vector<PCB_SHAPE*> cutoutShapes = getShapesFromVertices( cutout.Vertices, aContainer,
noGroup, aMoveVector,
aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
polySet.AddHole( getLineChainFromDrawsegments( cutoutSeg ) );
polySet.AddHole( getLineChainFromShapes( cutoutShapes ) );
//cleanup
for( PCB_SHAPE* seg : cutoutSeg )
delete seg;
for( PCB_SHAPE* shape : cutoutShapes )
delete shape;
}
if( aLineThickness > 0 )
@ -2903,40 +2910,40 @@ SHAPE_POLY_SET CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape( const SHA
}
SHAPE_LINE_CHAIN CADSTAR_PCB_ARCHIVE_LOADER::getLineChainFromDrawsegments( const std::vector<PCB_SHAPE*> aDrawsegments )
SHAPE_LINE_CHAIN CADSTAR_PCB_ARCHIVE_LOADER::getLineChainFromShapes( const std::vector<PCB_SHAPE*> aShapes )
{
SHAPE_LINE_CHAIN lineChain;
for( PCB_SHAPE* ds : aDrawsegments )
for( PCB_SHAPE* shape : aShapes )
{
switch( ds->GetShape() )
switch( shape->GetShape() )
{
case PCB_SHAPE_TYPE::ARC:
{
if( ds->GetClass() == wxT( "MGRAPHIC" ) )
if( shape->GetClass() == wxT( "MGRAPHIC" ) )
{
FP_SHAPE* em = (FP_SHAPE*) ds;
SHAPE_ARC arc( em->GetStart0(), em->GetEnd0(), (double) em->GetAngle() / 10.0 );
FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
SHAPE_ARC arc( fp_shape->GetStart0(), fp_shape->GetEnd0(), fp_shape->GetAngle() / 10.0 );
lineChain.Append( arc );
}
else
{
SHAPE_ARC arc( ds->GetCenter(), ds->GetArcStart(), (double) ds->GetAngle() / 10.0 );
SHAPE_ARC arc( shape->GetCenter(), shape->GetArcStart(), shape->GetAngle() / 10.0 );
lineChain.Append( arc );
}
}
break;
case PCB_SHAPE_TYPE::SEGMENT:
if( ds->GetClass() == wxT( "MGRAPHIC" ) )
if( shape->GetClass() == wxT( "MGRAPHIC" ) )
{
FP_SHAPE* em = (FP_SHAPE*) ds;
lineChain.Append( em->GetStart0().x, em->GetStart0().y );
lineChain.Append( em->GetEnd0().x, em->GetEnd0().y );
FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
lineChain.Append( fp_shape->GetStart0().x, fp_shape->GetStart0().y );
lineChain.Append( fp_shape->GetEnd0().x, fp_shape->GetEnd0().y );
}
else
{
lineChain.Append( ds->GetStartX(), ds->GetStartY() );
lineChain.Append( ds->GetEndX(), ds->GetEndY() );
lineChain.Append( shape->GetStartX(), shape->GetStartY() );
lineChain.Append( shape->GetEndX(), shape->GetEndY() );
}
break;
@ -2960,8 +2967,8 @@ SHAPE_LINE_CHAIN CADSTAR_PCB_ARCHIVE_LOADER::getLineChainFromDrawsegments( const
}
std::vector<PCB_TRACK*> CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(
const std::vector<PCB_SHAPE*> aDrawsegments,
std::vector<PCB_TRACK*> CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes(
const std::vector<PCB_SHAPE*> aShapes,
BOARD_ITEM_CONTAINER* aParentContainer,
NETINFO_ITEM* aNet, PCB_LAYER_ID aLayerOverride,
int aWidthOverride )
@ -2989,36 +2996,36 @@ std::vector<PCB_TRACK*> CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(
}
};
for( PCB_SHAPE* ds : aDrawsegments )
for( PCB_SHAPE* shape : aShapes )
{
switch( ds->GetShape() )
switch( shape->GetShape() )
{
case PCB_SHAPE_TYPE::ARC:
if( ds->GetClass() == wxT( "MGRAPHIC" ) )
if( shape->GetClass() == wxT( "MGRAPHIC" ) )
{
FP_SHAPE* em = (FP_SHAPE*) ds;
SHAPE_ARC arc( em->GetStart0(), em->GetEnd0(), (double) em->GetAngle() / 10.0 );
FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
SHAPE_ARC arc( fp_shape->GetStart0(), fp_shape->GetEnd0(), fp_shape->GetAngle() / 10.0 );
track = new PCB_ARC( aParentContainer, &arc );
}
else
{
SHAPE_ARC arc( ds->GetCenter(), ds->GetArcStart(), (double) ds->GetAngle() / 10.0 );
SHAPE_ARC arc( shape->GetCenter(), shape->GetArcStart(), shape->GetAngle() / 10.0 );
track = new PCB_ARC( aParentContainer, &arc );
}
break;
case PCB_SHAPE_TYPE::SEGMENT:
if( ds->GetClass() == wxT( "MGRAPHIC" ) )
if( shape->GetClass() == wxT( "MGRAPHIC" ) )
{
FP_SHAPE* em = (FP_SHAPE*) ds;
FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
track = new PCB_TRACK( aParentContainer );
track->SetStart( em->GetStart0() );
track->SetEnd( em->GetEnd0() );
track->SetStart( fp_shape->GetStart0() );
track->SetEnd( fp_shape->GetEnd0() );
}
else
{
track = new PCB_TRACK( aParentContainer );
track->SetStart( ds->GetStart() );
track->SetEnd( ds->GetEnd() );
track->SetStart( shape->GetStart() );
track->SetEnd( shape->GetEnd() );
}
break;
@ -3028,19 +3035,19 @@ std::vector<PCB_TRACK*> CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(
}
if( aWidthOverride == -1 )
track->SetWidth( ds->GetWidth() );
track->SetWidth( shape->GetWidth() );
else
track->SetWidth( aWidthOverride );
if( aLayerOverride == PCB_LAYER_ID::UNDEFINED_LAYER )
track->SetLayer( ds->GetLayer() );
track->SetLayer( shape->GetLayer() );
else
track->SetLayer( aLayerOverride );
if( aNet != nullptr )
track->SetNet( aNet );
track->SetLocked( ds->IsLocked() );
track->SetLocked( shape->IsLocked() );
// Apply route offsetting, mimmicking the behaviour of the CADSTAR post processor
if( prevTrack != nullptr )

View File

@ -236,15 +236,15 @@ private:
* @param aTransformCentre around which all transforms are applied (KiCad coordinates)
* @param aMirrorInvert if true, mirrors the drawsegments
*/
void drawCadstarCutoutsAsSegments( const std::vector<CUTOUT>& aCutouts,
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
void drawCadstarCutoutsAsShapes( const std::vector<CUTOUT>& aCutouts,
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/**
* @brief Uses PCB_SHAPE to draw the vertices on m_board object
@ -260,15 +260,15 @@ private:
* @param aMirrorInvert if true, mirrors the drawsegment
* @param aCadstarGroupID to add the shape to
*/
void drawCadstarVerticesAsSegments( const std::vector<VERTEX>& aCadstarVertices,
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
void drawCadstarVerticesAsShapes( const std::vector<VERTEX>& aCadstarVertices,
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness,
BOARD_ITEM_CONTAINER* aContainer,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/**
* @brief Returns a vector of pointers to PCB_SHAPE objects. Caller owns the objects.
@ -282,14 +282,14 @@ private:
* @param aMirrorInvert if true, mirrors the drawsegment
* @return
*/
std::vector<PCB_SHAPE*> getDrawSegmentsFromVertices( const std::vector<VERTEX>& aCadstarVertices,
BOARD_ITEM_CONTAINER* aContainer = nullptr,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
std::vector<PCB_SHAPE*> getShapesFromVertices( const std::vector<VERTEX>& aCadstarVertices,
BOARD_ITEM_CONTAINER* aContainer = nullptr,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/**
* @brief Returns a pointer to a PCB_SHAPE object. Caller owns the object.
@ -304,15 +304,15 @@ private:
* @param aMirrorInvert if true, mirrors the drawsegment
* @return
*/
PCB_SHAPE* getDrawSegmentFromVertex( const POINT& aCadstarStartPoint,
const VERTEX& aCadstarVertex,
BOARD_ITEM_CONTAINER* aContainer = nullptr,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
PCB_SHAPE* getShapeFromVertex( const POINT& aCadstarStartPoint,
const VERTEX& aCadstarVertex,
BOARD_ITEM_CONTAINER* aContainer = nullptr,
const GROUP_ID& aCadstarGroupID = wxEmptyString,
const wxPoint& aMoveVector = { 0, 0 },
const double& aRotationAngle = 0.0,
const double& aScalingFactor = 1.0,
const wxPoint& aTransformCentre = { 0, 0 },
const bool& aMirrorInvert = false );
/**
* @brief
@ -347,14 +347,14 @@ private:
/**
* @brief Returns a SHAPE_LINE_CHAIN object from a series of PCB_SHAPE objects
* @param aDrawSegments
* @param aShapes
* @return
*/
SHAPE_LINE_CHAIN getLineChainFromDrawsegments( const std::vector<PCB_SHAPE*> aDrawSegments );
SHAPE_LINE_CHAIN getLineChainFromShapes( const std::vector<PCB_SHAPE*> aShapes );
/**
* @brief Returns a vector of pointers to TRACK/ARC objects. Caller owns the objects
* @param aDrawsegments
* @param aShapes
* @param aParentContainer sets this as the parent of each TRACK object and Add()s it to the parent
* @param aNet sets all the tracks to this net, unless nullptr
* @param aLayerOverride Sets all tracks to this layer, or, if it is UNDEFINED_LAYER, uses the layers
@ -363,11 +363,11 @@ private:
* in the DrawSegments
* @return
*/
std::vector<PCB_TRACK*> makeTracksFromDrawsegments( const std::vector<PCB_SHAPE*> aDrawsegments,
BOARD_ITEM_CONTAINER* aParentContainer,
NETINFO_ITEM* aNet = nullptr,
PCB_LAYER_ID aLayerOverride = UNDEFINED_LAYER,
int aWidthOverride = -1 );
std::vector<PCB_TRACK*> makeTracksFromShapes( const std::vector<PCB_SHAPE*> aShapes,
BOARD_ITEM_CONTAINER* aParentContainer,
NETINFO_ITEM* aNet = nullptr,
PCB_LAYER_ID aLayerOverride = UNDEFINED_LAYER,
int aWidthOverride = -1 );
/**
* @brief Adds a CADSTAR Attribute to a KiCad footprint

View File

@ -893,8 +893,8 @@ void PCB_IO::format( const PCB_SHAPE* aShape, int aNestLevel ) const
m_out->Print( aNestLevel, "(gr_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
locked.c_str(),
FormatInternalUnits( aShape->GetStart() ).c_str(),
FormatInternalUnits( aShape->GetBezControl1() ).c_str(),
FormatInternalUnits( aShape->GetBezControl2() ).c_str(),
FormatInternalUnits( aShape->GetBezierC1() ).c_str(),
FormatInternalUnits( aShape->GetBezierC2() ).c_str(),
FormatInternalUnits( aShape->GetEnd() ).c_str() );
break;
@ -1018,8 +1018,8 @@ void PCB_IO::format( const FP_SHAPE* aFPShape, int aNestLevel ) const
m_out->Print( aNestLevel, "(fp_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
locked.c_str(),
FormatInternalUnits( aFPShape->GetStart0() ).c_str(),
FormatInternalUnits( aFPShape->GetBezier0_C1() ).c_str(),
FormatInternalUnits( aFPShape->GetBezier0_C2() ).c_str(),
FormatInternalUnits( aFPShape->GetBezierC1_0() ).c_str(),
FormatInternalUnits( aFPShape->GetBezierC2_0() ).c_str(),
FormatInternalUnits( aFPShape->GetEnd0() ).c_str() );
break;
@ -1636,8 +1636,8 @@ void PCB_IO::format( const PAD* aPad, int aNestLevel ) const
case PCB_SHAPE_TYPE::CURVE: // Bezier Curve
m_out->Print( nested_level, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
FormatInternalUnits( primitive->GetStart() ).c_str(),
FormatInternalUnits( primitive->GetBezControl1() ).c_str(),
FormatInternalUnits( primitive->GetBezControl2() ).c_str(),
FormatInternalUnits( primitive->GetBezierC1() ).c_str(),
FormatInternalUnits( primitive->GetBezierC2() ).c_str(),
FormatInternalUnits( primitive->GetEnd() ).c_str() );
break;

View File

@ -2417,8 +2417,8 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
Expecting( T_pts );
shape->SetStart( parseXY() );
shape->SetBezControl1( parseXY() );
shape->SetBezControl2( parseXY() );
shape->SetBezierC1( parseXY());
shape->SetBezierC2( parseXY());
shape->SetEnd( parseXY() );
NeedRIGHT();
break;
@ -3616,8 +3616,8 @@ FP_SHAPE* PCB_PARSER::parseFP_SHAPE()
if( token != T_angle )
Expecting( T_angle );
// Setting angle will set m_ThirdPoint0, so must be done after setting
// m_Start0 and m_End0
// Setting angle will set m_thirdPoint0, so must be done after setting
// m_start0 and m_end0
shape->SetAngle( parseDouble( "segment angle" ) * 10.0 );
NeedRIGHT();
break;
@ -3675,8 +3675,8 @@ FP_SHAPE* PCB_PARSER::parseFP_SHAPE()
Expecting( T_pts );
shape->SetStart0( parseXY() );
shape->SetBezier0_C1( parseXY() );
shape->SetBezier0_C2( parseXY() );
shape->SetBezierC1_0( parseXY());
shape->SetBezierC2_0( parseXY());
shape->SetEnd0( parseXY() );
NeedRIGHT();
break;
@ -4323,8 +4323,8 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
case T_gr_curve:
dummysegm = parsePCB_SHAPE();
pad->AddPrimitiveCurve( dummysegm->GetStart(), dummysegm->GetEnd(),
dummysegm->GetBezControl1(),
dummysegm->GetBezControl2(), dummysegm->GetWidth() );
dummysegm->GetBezierC1(),
dummysegm->GetBezierC2(), dummysegm->GetWidth() );
break;
default:

View File

@ -1711,11 +1711,11 @@ void LEGACY_PLUGIN::loadFP_SHAPE( FOOTPRINT* aFootprint )
width = biuParse( data, &data );
layer = layerParse( data );
dwg->m_Start0 = wxPoint( start0_x, start0_y );
dwg->m_End0 = wxPoint( end0_x, end0_y );
dwg->SetStart0( wxPoint( start0_x, start0_y ) );
dwg->SetEnd0( wxPoint( end0_x, end0_y ) );
// Setting angle will set m_ThirdPoint0, so must be done after setting
// m_Start0 and m_End0
// Setting angle will set m_thirdPoint0, so must be done after setting
// m_start0 and m_end0
dwg->SetAngle( angle );
}
break;
@ -1732,8 +1732,8 @@ void LEGACY_PLUGIN::loadFP_SHAPE( FOOTPRINT* aFootprint )
width = biuParse( data, &data );
layer = layerParse( data );
dwg->m_Start0 = wxPoint( start0_x, start0_y );
dwg->m_End0 = wxPoint( end0_x, end0_y );
dwg->SetStart0( wxPoint( start0_x, start0_y ) );
dwg->SetEnd0( wxPoint( end0_x, end0_y ) );
}
break;
@ -1749,8 +1749,8 @@ void LEGACY_PLUGIN::loadFP_SHAPE( FOOTPRINT* aFootprint )
width = biuParse( data, &data );
layer = layerParse( data );
dwg->m_Start0 = wxPoint( start0_x, start0_y );
dwg->m_End0 = wxPoint( end0_x, end0_y );
dwg->SetStart0( wxPoint( start0_x, start0_y ) );
dwg->SetEnd0( wxPoint( end0_x, end0_y ) );
std::vector<wxPoint> pts;
pts.reserve( ptCount );
@ -2029,7 +2029,7 @@ void LEGACY_PLUGIN::loadPCB_LINE()
break;
case 6:
y = biuParse( data );
dseg->SetBezControl1( wxPoint( x, y ) );
dseg->SetBezierC1( wxPoint( x, y ));
break;
case 7:
@ -2037,7 +2037,7 @@ void LEGACY_PLUGIN::loadPCB_LINE()
break;
case 8:
y = biuParse( data );
dseg->SetBezControl2( wxPoint( x, y ) );
dseg->SetBezierC2( wxPoint( x, y ));
break;
default:

View File

@ -37,7 +37,8 @@
namespace PCAD2KICAD {
PCB_ARC::PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
PCB_ARC::PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard )
{
m_objType = wxT( 'A' );
m_StartX = 0;
@ -52,9 +53,7 @@ PCB_ARC::~PCB_ARC()
}
void PCB_ARC::Parse( XNODE* aNode,
int aLayer,
const wxString& aDefaultMeasurementUnit,
void PCB_ARC::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -67,8 +66,10 @@ void PCB_ARC::Parse( XNODE* aNode,
m_KiCadLayer = GetKiCadLayer();
if( FindNode( aNode, wxT( "width" ) ) )
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
aDefaultMeasurementUnit, &m_Width, aActualConversion );
{
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultUnits, &m_Width,
aActualConversion );
}
if( aNode->GetName() == wxT( "triplePointArc" ) )
{
@ -76,24 +77,27 @@ void PCB_ARC::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_positionX, &m_positionY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
aActualConversion );
}
// start point
if( lNode )
lNode = lNode->GetNext();
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_StartX, &m_StartY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_StartX, &m_StartY,
aActualConversion );
}
// end point
if( lNode )
lNode = lNode->GetNext();
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&endX, &endY, aActualConversion );
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &endX, &endY, aActualConversion );
if( m_StartX == endX && m_StartY == endY )
{
@ -113,20 +117,27 @@ void PCB_ARC::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_positionX, &m_positionY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
aActualConversion );
}
lNode = FindNode( aNode, wxT( "radius" ) );
if( lNode)
SetWidth( FindNode( aNode, wxT( "radius" ) )->GetNodeContent(),
aDefaultMeasurementUnit, &r, aActualConversion );
{
SetWidth( FindNode( aNode, wxT( "radius" ) )->GetNodeContent(), aDefaultUnits, &r,
aActualConversion );
}
lNode = FindNode( aNode, wxT( "startAngle" ) );
if( lNode )
a = StrToInt1Units( lNode->GetNodeContent() );
lNode = FindNode( aNode, wxT( "sweepAngle" ) );
if( lNode )
m_Angle = StrToInt1Units( lNode->GetNodeContent() );
@ -164,11 +175,11 @@ void PCB_ARC::AddToFootprint( FOOTPRINT* aFootprint )
aFootprint, ( IsCircle() ? PCB_SHAPE_TYPE::CIRCLE : PCB_SHAPE_TYPE::ARC ) );
aFootprint->Add( arc );
arc->m_Start0 = wxPoint( m_positionX, m_positionY );
arc->m_End0 = wxPoint( m_StartX, m_StartY );
arc->SetStart0( wxPoint( m_positionX, m_positionY ) );
arc->SetEnd0( wxPoint( m_StartX, m_StartY ) );
// Setting angle will set m_ThirdPoint0, so must be done after setting
// m_Start0 and m_End0
// Setting angle will set m_thirdPoint0, so must be done after setting
// m_start0 and m_end0
arc->SetAngle( -m_Angle );
arc->SetWidth( m_Width );

View File

@ -41,7 +41,7 @@ public:
PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_ARC();
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion );
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;

View File

@ -34,8 +34,7 @@
namespace PCAD2KICAD {
PCB_COMPONENT::PCB_COMPONENT( PCB_CALLBACKS* aCallbacks,
BOARD* aBoard ) :
PCB_COMPONENT::PCB_COMPONENT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
m_uuid(),
m_callbacks( aCallbacks ),
m_board( aBoard )

View File

@ -33,9 +33,7 @@
namespace PCAD2KICAD {
PCB_COPPER_POUR::PCB_COPPER_POUR( PCB_CALLBACKS* aCallbacks,
BOARD* aBoard,
int aPCadLayer ) :
PCB_COPPER_POUR::PCB_COPPER_POUR( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer ) :
PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
{
m_filled = false;
@ -47,8 +45,7 @@ PCB_COPPER_POUR::~PCB_COPPER_POUR()
}
bool PCB_COPPER_POUR::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
bool PCB_COPPER_POUR::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -67,16 +64,22 @@ bool PCB_COPPER_POUR::Parse( XNODE* aNode,
}
if( FindNode( aNode, wxT( "width" ) ) )
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
aDefaultMeasurementUnit, &m_width, aActualConversion );
{
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultUnits, &m_width,
aActualConversion );
}
if( FindNode( aNode, wxT( "pourSpacing" ) ) )
SetWidth( FindNode( aNode, wxT( "pourSpacing" ) )->GetNodeContent(),
aDefaultMeasurementUnit, &pourSpacing, aActualConversion );
{
SetWidth( FindNode( aNode, wxT( "pourSpacing" ) )->GetNodeContent(), aDefaultUnits,
&pourSpacing, aActualConversion );
}
if( FindNode( aNode, wxT( "thermalWidth" ) ) )
SetWidth( FindNode( aNode, wxT( "thermalWidth" ) )->GetNodeContent(),
aDefaultMeasurementUnit, &thermalWidth, aActualConversion );
{
SetWidth( FindNode( aNode, wxT( "thermalWidth" ) )->GetNodeContent(), aDefaultUnits,
&thermalWidth, aActualConversion );
}
if( FindNode( aNode, wxT( "island" ) ) )
m_filled = true;
@ -86,7 +89,7 @@ bool PCB_COPPER_POUR::Parse( XNODE* aNode,
if( lNode )
{
// retrieve copper pour outline
FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
FormPolygon( lNode, &m_outline, aDefaultUnits, aActualConversion );
m_positionX = m_outline[0]->x;
m_positionY = m_outline[0]->y;

View File

@ -41,7 +41,7 @@ public:
~PCB_COPPER_POUR();
virtual bool Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
const wxString& aDefaultUnits,
const wxString& aActualConversion ) override;
};

View File

@ -37,8 +37,8 @@
namespace PCAD2KICAD {
PCB_LINE::PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_COMPONENT( aCallbacks,
aBoard )
PCB_LINE::PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard )
{
m_Width = 0;
m_ToX = 0;
@ -52,9 +52,7 @@ PCB_LINE::~PCB_LINE()
}
void PCB_LINE::Parse( XNODE* aNode,
int aLayer,
const wxString& aDefaultMeasurementUnit,
void PCB_LINE::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -70,20 +68,21 @@ void PCB_LINE::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_positionX, &m_positionY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
aActualConversion );
}
if( lNode )
lNode = lNode->GetNext();
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_ToX, &m_ToY, aActualConversion );
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_ToX, &m_ToY, aActualConversion );
lNode = FindNode( aNode, wxT( "width" ) );
if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Width, aActualConversion );
SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Width, aActualConversion );
lNode = FindNode( aNode, wxT( "netNameRef" ) );
@ -123,8 +122,8 @@ void PCB_LINE::AddToFootprint( FOOTPRINT* aFootprint )
FP_SHAPE* segment = new FP_SHAPE( aFootprint, PCB_SHAPE_TYPE::SEGMENT );
aFootprint->Add( segment );
segment->m_Start0 = wxPoint( m_positionX, m_positionY );
segment->m_End0 = wxPoint( m_ToX, m_ToY );
segment->SetStart0( wxPoint( m_positionX, m_positionY ) );
segment->SetEnd0( wxPoint( m_ToX, m_ToY ) );
segment->SetWidth( m_Width );
segment->SetLayer( m_KiCadLayer );

View File

@ -42,7 +42,7 @@ public:
PCB_LINE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_LINE();
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion );
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;

View File

@ -58,7 +58,7 @@ PCB_PAD::~PCB_PAD()
}
void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -89,7 +89,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
if( lNode )
{
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_positionX, &m_positionY,
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
aActualConversion );
}
@ -150,7 +150,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
cNode = FindNode( lNode, wxT( "holeDiam" ) );
if( cNode )
SetWidth( cNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Hole, aActualConversion );
SetWidth( cNode->GetNodeContent(), aDefaultUnits, &m_Hole, aActualConversion );
if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ) == wxT( "False" ) )
m_IsHolePlated = false;
@ -166,7 +166,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
if( FindNode( cNode, wxT( "layerNumRef" ) ) )
{
padShape = new PCB_PAD_SHAPE( m_callbacks, m_board );
padShape->Parse( cNode, aDefaultMeasurementUnit, aActualConversion );
padShape->Parse( cNode, aDefaultUnits, aActualConversion );
m_Shapes.Add( padShape );
}
}
@ -290,6 +290,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
// Set the proper net code
NETINFO_ITEM* netinfo = m_board->FindNet( m_net );
if( netinfo == NULL ) // I believe this should not happen, but just in case
{
// It is a new net

View File

@ -41,7 +41,7 @@ public:
PCB_PAD( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_PAD();
virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion );
virtual void Flip() override;

View File

@ -32,8 +32,8 @@
namespace PCAD2KICAD {
PCB_PAD_SHAPE::PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks,
BOARD* aBoard ) : PCB_COMPONENT( aCallbacks, aBoard )
PCB_PAD_SHAPE::PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_COMPONENT( aCallbacks, aBoard )
{
m_Shape = wxEmptyString;
m_Width = 0;
@ -46,8 +46,7 @@ PCB_PAD_SHAPE::~PCB_PAD_SHAPE()
}
void PCB_PAD_SHAPE::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
void PCB_PAD_SHAPE::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
wxString str, s;
@ -83,14 +82,12 @@ void PCB_PAD_SHAPE::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "shapeWidth" ) );
if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Width,
aActualConversion );
SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Width, aActualConversion );
lNode = FindNode( aNode, wxT( "shapeHeight" ) );
if( lNode )
SetWidth(
lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Height, aActualConversion );
SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Height, aActualConversion );
}
else if( m_Shape == wxT( "Polygon" ) )
{
@ -108,7 +105,7 @@ void PCB_PAD_SHAPE::Parse( XNODE* aNode,
while( lNode )
{
s = lNode->GetNodeContent();
SetPosition( s, aDefaultMeasurementUnit, &x, &y, aActualConversion );
SetPosition( s, aDefaultUnits, &x, &y, aActualConversion );
if( minX > x )
minX = x;

View File

@ -40,7 +40,7 @@ public:
PCB_PAD_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_PAD_SHAPE();
virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion );
void AddToBoard() override;

View File

@ -46,8 +46,7 @@ PCB_PLANE::~PCB_PLANE()
}
bool PCB_PLANE::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
bool PCB_PLANE::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -65,15 +64,17 @@ bool PCB_PLANE::Parse( XNODE* aNode,
}
if( FindNode( aNode, wxT( "width" ) ) )
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
aDefaultMeasurementUnit, &m_width, aActualConversion );
{
SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultUnits, &m_width,
aActualConversion );
}
lNode = FindNode( aNode, wxT( "pcbPoly" ) );
if( lNode )
{
// retrieve plane outline
FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
FormPolygon( lNode, &m_outline, aDefaultUnits, aActualConversion );
m_positionX = m_outline[0]->x;
m_positionY = m_outline[0]->y;

View File

@ -39,7 +39,7 @@ public:
PCB_PLANE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
~PCB_PLANE();
virtual bool Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
virtual bool Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion ) override;
};

View File

@ -26,7 +26,6 @@
#include <pcad/pcb_polygon.h>
#include <board.h>
#include <common.h>
#include <footprint.h>
#include <fp_shape.h>
#include <math/util.h> // for KiROUND
@ -107,9 +106,8 @@ void PCB_POLYGON::SetOutline( VERTICES_ARRAY* aOutline )
}
}
void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
const wxString& aDefaultMeasurementUnit,
const wxString& aActualConversion )
void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
const wxString& aDefaultUnits, const wxString& aActualConversion )
{
XNODE* lNode;
double x, y;
@ -120,8 +118,8 @@ void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
{
if( lNode->GetName() == wxT( "pt" ) )
{
SetDoublePrecisionPosition(
lNode->GetNodeContent(), aDefaultMeasurementUnit, &x, &y, aActualConversion );
SetDoublePrecisionPosition( lNode->GetNodeContent(), aDefaultUnits, &x, &y,
aActualConversion );
aPolygon->Add( new wxRealPoint( x, y ) );
}
@ -130,8 +128,7 @@ void PCB_POLYGON::FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
}
bool PCB_POLYGON::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
bool PCB_POLYGON::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -149,14 +146,14 @@ bool PCB_POLYGON::Parse( XNODE* aNode,
}
// retrieve polygon outline
FormPolygon( aNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
FormPolygon( aNode, &m_outline, aDefaultUnits, aActualConversion );
m_positionX = m_outline[0]->x;
m_positionY = m_outline[0]->y;
// fill the polygon with the same contour as its outline is
m_islands.Add( new VERTICES_ARRAY );
FormPolygon( aNode, m_islands[0], aDefaultMeasurementUnit, aActualConversion );
FormPolygon( aNode, m_islands[0], aDefaultUnits, aActualConversion );
return true;
}

View File

@ -42,7 +42,7 @@ public:
PCB_POLYGON( PCB_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer );
~PCB_POLYGON();
virtual bool Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
virtual bool Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion );
virtual void SetPosOffset( int aX_offs, int aY_offs ) override;
@ -59,7 +59,7 @@ public:
void SetOutline( VERTICES_ARRAY* aOutline );
void FormPolygon( XNODE* aNode, VERTICES_ARRAY* aPolygon,
const wxString& aDefaultMeasurementUnit, const wxString& actualConversion );
const wxString& aDefaultUnits, const wxString& actualConversion );
int m_width;
int m_priority;

View File

@ -46,7 +46,7 @@ PCB_TEXT::~PCB_TEXT()
}
void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurementUnit,
void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -61,7 +61,7 @@ void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurem
if( lNode )
{
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_positionX, &m_positionY,
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
aActualConversion );
}
@ -88,7 +88,7 @@ void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurem
lNode = FindNode( aNode, wxT( "textStyleRef" ) );
if( lNode )
SetFontProperty( lNode, &m_name, aDefaultMeasurementUnit, aActualConversion );
SetFontProperty( lNode, &m_name, aDefaultUnits, aActualConversion );
}

View File

@ -42,7 +42,7 @@ public:
PCB_TEXT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_TEXT();
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion );
void AddToFootprint( FOOTPRINT* aFootprint ) override;

View File

@ -33,7 +33,8 @@
namespace PCAD2KICAD {
PCB_VIA::PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCB_PAD( aCallbacks, aBoard )
PCB_VIA::PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_PAD( aCallbacks, aBoard )
{
m_objType = wxT( 'V' );
}
@ -44,8 +45,7 @@ PCB_VIA::~PCB_VIA()
}
void PCB_VIA::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
void PCB_VIA::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode, * tNode;
@ -66,8 +66,10 @@ void PCB_VIA::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "pt" ) );
if( lNode )
SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
&m_positionX, &m_positionY, aActualConversion );
{
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
aActualConversion );
}
lNode = FindNode( aNode, wxT( "netNameRef" ) );
@ -111,8 +113,7 @@ void PCB_VIA::Parse( XNODE* aNode,
lNode = FindNode( tNode, wxT( "holeDiam" ) );
if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Hole,
aActualConversion );
SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Hole, aActualConversion );
lNode = FindNode( tNode, wxT( "viaShape" ) );
@ -125,7 +126,7 @@ void PCB_VIA::Parse( XNODE* aNode,
if( FindNode( lNode, wxT( "layerNumRef" ) ) )
{
viaShape = new PCB_VIA_SHAPE( m_callbacks, m_board );
viaShape->Parse( lNode, aDefaultMeasurementUnit, aActualConversion );
viaShape->Parse( lNode, aDefaultUnits, aActualConversion );
m_Shapes.Add( viaShape );
}
}

View File

@ -41,7 +41,7 @@ public:
PCB_VIA( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_VIA();
virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion ) override;
};

View File

@ -32,8 +32,8 @@
namespace PCAD2KICAD {
PCB_VIA_SHAPE::PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks,
BOARD* aBoard ) : PCB_PAD_SHAPE( aCallbacks, aBoard )
PCB_VIA_SHAPE::PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
PCB_PAD_SHAPE( aCallbacks, aBoard )
{
}
@ -43,8 +43,7 @@ PCB_VIA_SHAPE::~PCB_VIA_SHAPE()
}
void PCB_VIA_SHAPE::Parse( XNODE* aNode,
const wxString& aDefaultMeasurementUnit,
void PCB_VIA_SHAPE::Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
@ -72,12 +71,12 @@ void PCB_VIA_SHAPE::Parse( XNODE* aNode,
lNode = FindNode( aNode, wxT( "shapeWidth" ) );
if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Width, aActualConversion );
SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Width, aActualConversion );
lNode = FindNode( aNode, wxT( "shapeHeight" ) );
if( lNode )
SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_Height, aActualConversion );
SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Height, aActualConversion );
}

View File

@ -40,7 +40,7 @@ public:
PCB_VIA_SHAPE( PCB_CALLBACKS* aCallbacks, BOARD* aBoard );
~PCB_VIA_SHAPE();
virtual void Parse( XNODE* aNode, const wxString& aDefaultMeasurementUnit,
virtual void Parse( XNODE* aNode, const wxString& aDefaultUnits,
const wxString& aActualConversion ) override;
};

View File

@ -689,7 +689,6 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
else // pad name is a duplicate within this footprint
{
char buf[32];
int duplicates = ++pinmap[ padName ];
sprintf( buf, "@%d", duplicates );
@ -753,11 +752,11 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
path->SetLayerId( "signal" );
double radius = graphic->GetRadius();
wxPoint circle_centre = graphic->m_Start0;
wxPoint circle_centre = graphic->GetStart0();
SHAPE_LINE_CHAIN polyline;
ConvertArcToPolyline( polyline, VECTOR2I( circle_centre ), radius,
0.0, 360.0, ARC_HIGH_DEF, ERROR_INSIDE );
ConvertArcToPolyline( polyline, VECTOR2I( circle_centre ), radius, 0.0, 360.0,
ARC_HIGH_DEF, ERROR_INSIDE );
for( int ii = 0; ii < polyline.PointCount(); ++ii )
{
@ -805,8 +804,8 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
path->SetAperture( 0 );//scale( graphic->GetWidth() ) );
path->SetLayerId( "signal" );
wxPoint arc_centre = graphic->m_Start0;
double radius = graphic->GetRadius()+ graphic->GetWidth()/2;
wxPoint arc_centre = graphic->GetStart0();
double radius = graphic->GetRadius() + graphic->GetWidth()/2;
double arcStartDeg = graphic->GetArcAngleStart() / 10.0;
double arcAngleDeg = graphic->GetAngle() / 10.0;

View File

@ -605,8 +605,8 @@ PCB_LAYER_ID PAD_TOOL::explodePad( PAD* aPad )
shape->SetWidth( primitive->GetWidth() );
shape->SetStart( primitive->GetStart() );
shape->SetEnd( primitive->GetEnd() );
shape->SetBezControl1( primitive->GetBezControl1() );
shape->SetBezControl2( primitive->GetBezControl2() );
shape->SetBezierC1( primitive->GetBezierC1());
shape->SetBezierC2( primitive->GetBezierC2());
shape->SetAngle( primitive->GetAngle() );
shape->SetPolyShape( primitive->GetPolyShape() );
shape->SetLocalCoord();
@ -716,8 +716,8 @@ void PAD_TOOL::recombinePad( PAD* aPad )
pcbShape->SetWidth( fpShape->GetWidth() );
pcbShape->SetStart( fpShape->GetStart() );
pcbShape->SetEnd( fpShape->GetEnd() );
pcbShape->SetBezControl1( fpShape->GetBezControl1() );
pcbShape->SetBezControl2( fpShape->GetBezControl2() );
pcbShape->SetBezierC1( fpShape->GetBezierC1());
pcbShape->SetBezierC2( fpShape->GetBezierC2());
pcbShape->SetAngle( fpShape->GetAngle() );
pcbShape->SetPolyShape( fpShape->GetPolyShape() );

View File

@ -227,8 +227,8 @@ std::shared_ptr<EDIT_POINTS> PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem )
case PCB_SHAPE_TYPE::CURVE:
points->AddPoint( shape->GetStart() );
points->AddPoint( shape->GetBezControl1() );
points->AddPoint( shape->GetBezControl2() );
points->AddPoint( shape->GetBezierC1() );
points->AddPoint( shape->GetBezierC2() );
points->AddPoint( shape->GetEnd() );
break;
@ -1153,9 +1153,9 @@ void PCB_POINT_EDITOR::updateItem() const
if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) )
shape->SetStart( (wxPoint) m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() );
else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) )
shape->SetBezControl1( (wxPoint) m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() );
shape->SetBezierC1((wxPoint) m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition());
else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) )
shape->SetBezControl2( (wxPoint) m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() );
shape->SetBezierC2((wxPoint) m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition());
else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) )
shape->SetEnd( (wxPoint) m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() );
@ -1587,8 +1587,8 @@ void PCB_POINT_EDITOR::updatePoints()
case PCB_SHAPE_TYPE::CURVE:
m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( shape->GetStart() );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezControl1() );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezControl2() );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezierC1() );
m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezierC2() );
m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( shape->GetEnd() );
break;