SHAPE_LINE_CHAIN: Remove element access
This is the first step to allowing non-segments in the line chain. External routines cannot be allowed to change the line chain without going through the internal routines. To accomplish this, we remove the Vertex() and Point() access routines and only leave the const versions. Transformations are given for both points as well as the chain itself.
This commit is contained in:
parent
7d6665c313
commit
c4d853c1e8
|
@ -248,9 +248,7 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in
|
||||||
{
|
{
|
||||||
for( int s = 0; s < aB.SegmentCount(); s++ )
|
for( int s = 0; s < aB.SegmentCount(); s++ )
|
||||||
{
|
{
|
||||||
SEG seg = aB.CSegment( s );
|
if( aA.Collide( aB.CSegment( s ), aClearance ) )
|
||||||
|
|
||||||
if( aA.Collide( seg, aClearance ) )
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,8 @@ int SHAPE_POLY_SET::NewHole( int aOutline )
|
||||||
|
|
||||||
int SHAPE_POLY_SET::Append( int x, int y, int aOutline, int aHole, bool aAllowDuplication )
|
int SHAPE_POLY_SET::Append( int x, int y, int aOutline, int aHole, bool aAllowDuplication )
|
||||||
{
|
{
|
||||||
|
assert( m_polys.size() );
|
||||||
|
|
||||||
if( aOutline < 0 )
|
if( aOutline < 0 )
|
||||||
aOutline += m_polys.size();
|
aOutline += m_polys.size();
|
||||||
|
|
||||||
|
@ -273,25 +275,6 @@ SHAPE_POLY_SET SHAPE_POLY_SET::Subset( int aFirstPolygon, int aLastPolygon )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I& SHAPE_POLY_SET::Vertex( int aIndex, int aOutline, int aHole )
|
|
||||||
{
|
|
||||||
if( aOutline < 0 )
|
|
||||||
aOutline += m_polys.size();
|
|
||||||
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
if( aHole < 0 )
|
|
||||||
idx = 0;
|
|
||||||
else
|
|
||||||
idx = aHole + 1;
|
|
||||||
|
|
||||||
assert( aOutline < (int) m_polys.size() );
|
|
||||||
assert( idx < (int) m_polys[aOutline].size() );
|
|
||||||
|
|
||||||
return m_polys[aOutline][idx].Point( aIndex );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const VECTOR2I& SHAPE_POLY_SET::CVertex( int aIndex, int aOutline, int aHole ) const
|
const VECTOR2I& SHAPE_POLY_SET::CVertex( int aIndex, int aOutline, int aHole ) const
|
||||||
{
|
{
|
||||||
if( aOutline < 0 )
|
if( aOutline < 0 )
|
||||||
|
@ -311,18 +294,6 @@ const VECTOR2I& SHAPE_POLY_SET::CVertex( int aIndex, int aOutline, int aHole ) c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I& SHAPE_POLY_SET::Vertex( int aGlobalIndex )
|
|
||||||
{
|
|
||||||
SHAPE_POLY_SET::VERTEX_INDEX index;
|
|
||||||
|
|
||||||
// Assure the passed index references a legal position; abort otherwise
|
|
||||||
if( !GetRelativeIndices( aGlobalIndex, &index ) )
|
|
||||||
throw( std::out_of_range( "aGlobalIndex-th vertex does not exist" ) );
|
|
||||||
|
|
||||||
return m_polys[index.m_polygon][index.m_contour].Point( index.m_vertex );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const VECTOR2I& SHAPE_POLY_SET::CVertex( int aGlobalIndex ) const
|
const VECTOR2I& SHAPE_POLY_SET::CVertex( int aGlobalIndex ) const
|
||||||
{
|
{
|
||||||
SHAPE_POLY_SET::VERTEX_INDEX index;
|
SHAPE_POLY_SET::VERTEX_INDEX index;
|
||||||
|
@ -335,12 +306,6 @@ const VECTOR2I& SHAPE_POLY_SET::CVertex( int aGlobalIndex ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I& SHAPE_POLY_SET::Vertex( SHAPE_POLY_SET::VERTEX_INDEX index )
|
|
||||||
{
|
|
||||||
return Vertex( index.m_vertex, index.m_polygon, index.m_contour - 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const VECTOR2I& SHAPE_POLY_SET::CVertex( SHAPE_POLY_SET::VERTEX_INDEX index ) const
|
const VECTOR2I& SHAPE_POLY_SET::CVertex( SHAPE_POLY_SET::VERTEX_INDEX index ) const
|
||||||
{
|
{
|
||||||
return CVertex( index.m_vertex, index.m_polygon, index.m_contour - 1 );
|
return CVertex( index.m_vertex, index.m_polygon, index.m_contour - 1 );
|
||||||
|
@ -1444,6 +1409,23 @@ void SHAPE_POLY_SET::RemoveVertex( VERTEX_INDEX aIndex )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHAPE_POLY_SET::SetVertex( int aGlobalIndex, const VECTOR2I& aPos )
|
||||||
|
{
|
||||||
|
VERTEX_INDEX index;
|
||||||
|
|
||||||
|
if( GetRelativeIndices( aGlobalIndex, &index ) )
|
||||||
|
SetVertex( index, aPos );
|
||||||
|
else
|
||||||
|
throw( std::out_of_range( "aGlobalIndex-th vertex does not exist" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHAPE_POLY_SET::SetVertex( const VERTEX_INDEX& aIndex, const VECTOR2I& aPos )
|
||||||
|
{
|
||||||
|
m_polys[aIndex.m_polygon][aIndex.m_contour].SetPoint( aIndex.m_vertex, aPos );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SHAPE_POLY_SET::containsSingle( const VECTOR2I& aP, int aSubpolyIndex, int aAccuracy,
|
bool SHAPE_POLY_SET::containsSingle( const VECTOR2I& aP, int aSubpolyIndex, int aAccuracy,
|
||||||
bool aUseBBoxCaches ) const
|
bool aUseBBoxCaches ) const
|
||||||
{
|
{
|
||||||
|
@ -1478,6 +1460,18 @@ void SHAPE_POLY_SET::Move( const VECTOR2I& aVector )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHAPE_POLY_SET::Mirror( bool aX, bool aY, const VECTOR2I& aRef )
|
||||||
|
{
|
||||||
|
for( POLYGON& poly : m_polys )
|
||||||
|
{
|
||||||
|
for( SHAPE_LINE_CHAIN& path : poly )
|
||||||
|
{
|
||||||
|
path.Mirror( aX, aY, aRef );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHAPE_POLY_SET::Rotate( double aAngle, const VECTOR2I& aCenter )
|
void SHAPE_POLY_SET::Rotate( double aAngle, const VECTOR2I& aCenter )
|
||||||
{
|
{
|
||||||
for( POLYGON& poly : m_polys )
|
for( POLYGON& poly : m_polys )
|
||||||
|
@ -1676,8 +1670,8 @@ SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode,
|
||||||
for( int currVertex = 0; currVertex < currContour.PointCount(); currVertex++ )
|
for( int currVertex = 0; currVertex < currContour.PointCount(); currVertex++ )
|
||||||
{
|
{
|
||||||
// Current vertex
|
// Current vertex
|
||||||
int x1 = currContour.Point( currVertex ).x;
|
int x1 = currContour.CPoint( currVertex ).x;
|
||||||
int y1 = currContour.Point( currVertex ).y;
|
int y1 = currContour.CPoint( currVertex ).y;
|
||||||
|
|
||||||
if( aPreserveCorners && aPreserveCorners->count( VECTOR2I( x1, y1 ) ) > 0 )
|
if( aPreserveCorners && aPreserveCorners->count( VECTOR2I( x1, y1 ) ) > 0 )
|
||||||
{
|
{
|
||||||
|
@ -1698,12 +1692,12 @@ SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode,
|
||||||
nextVertex = currVertex == currContour.PointCount() - 1 ? 0 : currVertex + 1;
|
nextVertex = currVertex == currContour.PointCount() - 1 ? 0 : currVertex + 1;
|
||||||
|
|
||||||
// Previous vertex computation
|
// Previous vertex computation
|
||||||
double xa = currContour.Point( prevVertex ).x - x1;
|
double xa = currContour.CPoint( prevVertex ).x - x1;
|
||||||
double ya = currContour.Point( prevVertex ).y - y1;
|
double ya = currContour.CPoint( prevVertex ).y - y1;
|
||||||
|
|
||||||
// Next vertex computation
|
// Next vertex computation
|
||||||
double xb = currContour.Point( nextVertex ).x - x1;
|
double xb = currContour.CPoint( nextVertex ).x - x1;
|
||||||
double yb = currContour.Point( nextVertex ).y - y1;
|
double yb = currContour.CPoint( nextVertex ).y - y1;
|
||||||
|
|
||||||
// Compute the new distances
|
// Compute the new distances
|
||||||
double lena = hypot( xa, ya );
|
double lena = hypot( xa, ya );
|
||||||
|
|
|
@ -71,8 +71,7 @@ static const bool NOT_FILLED = false;
|
||||||
GR_DRAWMODE g_XorMode = GR_NXOR;
|
GR_DRAWMODE g_XorMode = GR_NXOR;
|
||||||
|
|
||||||
|
|
||||||
static void ClipAndDrawPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points[],
|
static void ClipAndDrawPoly( EDA_RECT* ClipBox, wxDC* DC, const wxPoint* Points, int n );
|
||||||
int n );
|
|
||||||
|
|
||||||
/* These functions are used by corresponding functions
|
/* These functions are used by corresponding functions
|
||||||
* ( GRSCircle is called by GRCircle for instance) after mapping coordinates
|
* ( GRSCircle is called by GRCircle for instance) after mapping coordinates
|
||||||
|
@ -428,7 +427,7 @@ void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, wxPoint Points[] )
|
static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, const wxPoint* Points, )
|
||||||
{
|
{
|
||||||
if( !ClipBox )
|
if( !ClipBox )
|
||||||
return true;
|
return true;
|
||||||
|
@ -470,9 +469,8 @@ static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, wxPoint Points[] )
|
||||||
/*
|
/*
|
||||||
* Draw a new polyline and fill it if Fill, in screen space.
|
* Draw a new polyline and fill it if Fill, in screen space.
|
||||||
*/
|
*/
|
||||||
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill,
|
||||||
bool Fill, int width,
|
int width, COLOR4D Color, COLOR4D BgColor )
|
||||||
COLOR4D Color, COLOR4D BgColor )
|
|
||||||
{
|
{
|
||||||
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
|
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
|
||||||
return;
|
return;
|
||||||
|
@ -503,11 +501,8 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||||
/*
|
/*
|
||||||
* Draw a new closed polyline and fill it if Fill, in screen space.
|
* Draw a new closed polyline and fill it if Fill, in screen space.
|
||||||
*/
|
*/
|
||||||
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
|
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
|
||||||
int aPointCount, wxPoint aPoints[],
|
bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor )
|
||||||
bool aFill, int aWidth,
|
|
||||||
COLOR4D aColor,
|
|
||||||
COLOR4D aBgColor )
|
|
||||||
{
|
{
|
||||||
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
|
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
|
||||||
return;
|
return;
|
||||||
|
@ -543,8 +538,8 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
|
||||||
/*
|
/*
|
||||||
* Draw a new polyline and fill it if Fill, in drawing space.
|
* Draw a new polyline and fill it if Fill, in drawing space.
|
||||||
*/
|
*/
|
||||||
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
|
||||||
bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
|
COLOR4D Color, COLOR4D BgColor )
|
||||||
{
|
{
|
||||||
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
|
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
|
||||||
}
|
}
|
||||||
|
@ -553,15 +548,15 @@ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||||
/*
|
/*
|
||||||
* Draw a closed polyline and fill it if Fill, in object space.
|
* Draw a closed polyline and fill it if Fill, in object space.
|
||||||
*/
|
*/
|
||||||
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill,
|
||||||
bool Fill, COLOR4D Color, COLOR4D BgColor )
|
COLOR4D Color, COLOR4D BgColor )
|
||||||
{
|
{
|
||||||
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
|
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
|
||||||
bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
|
COLOR4D Color, COLOR4D BgColor )
|
||||||
{
|
{
|
||||||
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
|
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
|
||||||
}
|
}
|
||||||
|
@ -958,7 +953,7 @@ void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y
|
||||||
*/
|
*/
|
||||||
#include <SutherlandHodgmanClipPoly.h>
|
#include <SutherlandHodgmanClipPoly.h>
|
||||||
|
|
||||||
void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], int n )
|
void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint* Points, int n )
|
||||||
{
|
{
|
||||||
if( aClipBox == NULL )
|
if( aClipBox == NULL )
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,8 +200,8 @@ void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset,
|
||||||
SHAPE_LINE_CHAIN& outline = m_Polygons.Outline( idx );
|
SHAPE_LINE_CHAIN& outline = m_Polygons.Outline( idx );
|
||||||
|
|
||||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||||
points_moved.emplace_back( outline.Point( ii ).x + aOffset.x,
|
points_moved.emplace_back(
|
||||||
outline.Point( ii ).y + aOffset.y );
|
outline.CPoint( ii ).x + aOffset.x, outline.CPoint( ii ).y + aOffset.y );
|
||||||
|
|
||||||
GRPoly( nullptr, aDC, points_moved.size(), &points_moved[0], FILLED_SHAPE,
|
GRPoly( nullptr, aDC, points_moved.size(), &points_moved[0], FILLED_SHAPE,
|
||||||
GetPenWidth(), aColor, aColor );
|
GetPenWidth(), aColor, aColor );
|
||||||
|
|
|
@ -777,12 +777,12 @@ void DXF_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize
|
||||||
// TransformRoundRectToPolygon creates only one convex polygon
|
// TransformRoundRectToPolygon creates only one convex polygon
|
||||||
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
|
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
|
||||||
|
|
||||||
MoveTo( wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
|
MoveTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
|
||||||
|
|
||||||
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
||||||
LineTo( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
LineTo( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
|
||||||
|
|
||||||
FinishTo( wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
|
FinishTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DXF_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
void DXF_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
||||||
|
@ -793,12 +793,12 @@ void DXF_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
||||||
{
|
{
|
||||||
SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
|
SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
|
||||||
|
|
||||||
MoveTo( wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
|
MoveTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
|
||||||
|
|
||||||
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
||||||
LineTo( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
LineTo( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
|
||||||
|
|
||||||
FinishTo(wxPoint( poly.Point( 0 ).x, poly.Point( 0 ).y ) );
|
FinishTo( wxPoint( poly.CPoint( 0 ).x, poly.CPoint( 0 ).y ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -902,7 +902,7 @@ void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
|
||||||
cornerList.reserve( poly.PointCount() + 1 );
|
cornerList.reserve( poly.PointCount() + 1 );
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
cornerList.push_back( cornerList[0] );
|
cornerList.push_back( cornerList[0] );
|
||||||
|
@ -942,7 +942,7 @@ void GERBER_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize
|
||||||
cornerList.clear();
|
cornerList.clear();
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
cornerList.push_back( cornerList[0] );
|
cornerList.push_back( cornerList[0] );
|
||||||
|
|
|
@ -650,7 +650,7 @@ void HPGL_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSiz
|
||||||
cornerList.reserve( poly.PointCount() );
|
cornerList.reserve( poly.PointCount() );
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
|
|
||||||
if( cornerList.back() != cornerList.front() )
|
if( cornerList.back() != cornerList.front() )
|
||||||
cornerList.push_back( cornerList.front() );
|
cornerList.push_back( cornerList.front() );
|
||||||
|
@ -672,7 +672,7 @@ void HPGL_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
|
||||||
cornerList.reserve( poly.PointCount() );
|
cornerList.reserve( poly.PointCount() );
|
||||||
|
|
||||||
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
for( int ii = 1; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
|
|
||||||
if( cornerList.back() != cornerList.front() )
|
if( cornerList.back() != cornerList.front() )
|
||||||
cornerList.push_back( cornerList.front() );
|
cornerList.push_back( cornerList.front() );
|
||||||
|
|
|
@ -209,7 +209,7 @@ void PSLIKE_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
|
||||||
cornerList.reserve( poly.PointCount() );
|
cornerList.reserve( poly.PointCount() );
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
cornerList.push_back( cornerList[0] );
|
cornerList.push_back( cornerList[0] );
|
||||||
|
@ -242,7 +242,7 @@ void PSLIKE_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize
|
||||||
cornerList.clear();
|
cornerList.clear();
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x, poly.Point( ii ).y );
|
cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
cornerList.push_back( cornerList[0] );
|
cornerList.push_back( cornerList[0] );
|
||||||
|
|
|
@ -126,8 +126,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
||||||
SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
|
SHAPE_LINE_CHAIN& outline = poly->GetPolygons().Outline( idx );
|
||||||
|
|
||||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||||
points.emplace_back( outline.Point( ii ).x ,
|
points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
|
||||||
outline.Point( ii ).y );
|
|
||||||
|
|
||||||
plotter->PlotPoly( points, FILLED_SHAPE, poly->GetPenWidth() );
|
plotter->PlotPoly( points, FILLED_SHAPE, poly->GetPenWidth() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,6 @@ typedef long time_t;
|
||||||
|
|
||||||
// ignore warning from nested classes
|
// ignore warning from nested classes
|
||||||
#pragma SWIG nowarn=325
|
#pragma SWIG nowarn=325
|
||||||
%ignore SHAPE_LINE_CHAIN::convertFromClipper;
|
|
||||||
#include <geometry/shape_line_chain.h>
|
#include <geometry/shape_line_chain.h>
|
||||||
%include <geometry/shape_line_chain.h>
|
%include <geometry/shape_line_chain.h>
|
||||||
|
|
||||||
|
|
|
@ -836,8 +836,8 @@ void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent,
|
||||||
{
|
{
|
||||||
SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
|
SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
|
||||||
|
|
||||||
GRClosedPoly( aClipBox, aDC,
|
GRClosedPoly( aClipBox, aDC, poly.PointCount(), (wxPoint*) &poly.CPoint( 0 ), aFilledShape,
|
||||||
poly.PointCount(), (wxPoint*)&poly.Point( 0 ), aFilledShape, aColor, aColor );
|
aColor, aColor );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
|
||||||
|
|
||||||
for( int ii = 0; ii < pointCount; ii++ )
|
for( int ii = 0; ii < pointCount; ii++ )
|
||||||
{
|
{
|
||||||
wxPoint p( m_Polygon.Vertex( ii ).x, m_Polygon.Vertex( ii ).y );
|
wxPoint p( m_Polygon.CVertex( ii ).x, m_Polygon.CVertex( ii ).y );
|
||||||
points[ii] = p + aPosition;
|
points[ii] = p + aPosition;
|
||||||
points[ii] = aParent->GetABPosition( points[ii] );
|
points[ii] = aParent->GetABPosition( points[ii] );
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,7 +546,7 @@ void GBR_TO_PCB_EXPORTER::writePcbPolygonItem( GERBER_DRAW_ITEM* aGbrItem, LAYER
|
||||||
int cnt_max = poly.PointCount() -1;
|
int cnt_max = poly.PointCount() -1;
|
||||||
|
|
||||||
// Do not generate last corner, if it is the same point as the first point:
|
// Do not generate last corner, if it is the same point as the first point:
|
||||||
if( poly.Point( 0 ) == poly.Point( cnt_max ) )
|
if( poly.CPoint( 0 ) == poly.CPoint( cnt_max ) )
|
||||||
cnt_max--;
|
cnt_max--;
|
||||||
|
|
||||||
for( int ii = 0; ii <= cnt_max; ii++ )
|
for( int ii = 0; ii <= cnt_max; ii++ )
|
||||||
|
@ -557,9 +557,8 @@ void GBR_TO_PCB_EXPORTER::writePcbPolygonItem( GERBER_DRAW_ITEM* aGbrItem, LAYER
|
||||||
fprintf( m_fp, "\n" );
|
fprintf( m_fp, "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( m_fp, " (xy %s %s)",
|
fprintf( m_fp, " (xy %s %s)", Double2Str( MapToPcbUnits( poly.CPoint( ii ).x ) ).c_str(),
|
||||||
Double2Str( MapToPcbUnits( poly.Point( ii ).x ) ).c_str(),
|
Double2Str( MapToPcbUnits( -poly.CPoint( ii ).y ) ).c_str() );
|
||||||
Double2Str( MapToPcbUnits( -poly.Point( ii ).y ) ).c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( m_fp, ")" );
|
fprintf( m_fp, ")" );
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1992-2017 <Jean-Pierre Charras>
|
* Copyright (C) 1992-2017 <Jean-Pierre Charras>
|
||||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -413,11 +413,7 @@ void GERBER_DRAW_ITEM::MoveAB( const wxPoint& aMoveVector )
|
||||||
m_End += xymove;
|
m_End += xymove;
|
||||||
m_ArcCentre += xymove;
|
m_ArcCentre += xymove;
|
||||||
|
|
||||||
if( m_Polygon.OutlineCount() > 0 )
|
m_Polygon.Move( VECTOR2I( xymove ) );
|
||||||
{
|
|
||||||
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
|
|
||||||
*it += xymove;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,11 +423,7 @@ void GERBER_DRAW_ITEM::MoveXY( const wxPoint& aMoveVector )
|
||||||
m_End += aMoveVector;
|
m_End += aMoveVector;
|
||||||
m_ArcCentre += aMoveVector;
|
m_ArcCentre += aMoveVector;
|
||||||
|
|
||||||
if( m_Polygon.OutlineCount() > 0 )
|
m_Polygon.Move( VECTOR2I( aMoveVector ) );
|
||||||
{
|
|
||||||
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
|
|
||||||
*it += aMoveVector;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -624,13 +616,10 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon()
|
||||||
m_Polygon.Append( VECTOR2I( close ) ); // close the shape
|
m_Polygon.Append( VECTOR2I( close ) ); // close the shape
|
||||||
|
|
||||||
// Create final polygon:
|
// Create final polygon:
|
||||||
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
|
|
||||||
{
|
|
||||||
if( change )
|
if( change )
|
||||||
( *it ).y = -( *it ).y;
|
m_Polygon.Mirror( false, true );
|
||||||
|
|
||||||
*it += start;
|
m_Polygon.Move( VECTOR2I( start ) );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -645,7 +634,7 @@ void GERBER_DRAW_ITEM::PrintGerberPoly( wxDC* aDC, COLOR4D aColor, const wxPoint
|
||||||
|
|
||||||
for( int ii = 0; ii < pointCount; ii++ )
|
for( int ii = 0; ii < pointCount; ii++ )
|
||||||
{
|
{
|
||||||
wxPoint p( poly.Point( ii ).x, poly.Point( ii ).y );
|
wxPoint p( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
|
||||||
points[ii] = p + aOffset;
|
points[ii] = p + aOffset;
|
||||||
points[ii] = GetABPosition( points[ii] );
|
points[ii] = GetABPosition( points[ii] );
|
||||||
}
|
}
|
||||||
|
@ -798,7 +787,7 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos, int aAccuracy ) const
|
||||||
|
|
||||||
case GBR_SPOT_POLY:
|
case GBR_SPOT_POLY:
|
||||||
poly = GetDcodeDescr()->m_Polygon;
|
poly = GetDcodeDescr()->m_Polygon;
|
||||||
poly.Move( m_Start );
|
poly.Move( VECTOR2I( m_Start ) );
|
||||||
return poly.Contains( VECTOR2I( ref_pos ), 0, aAccuracy );
|
return poly.Contains( VECTOR2I( ref_pos ), 0, aAccuracy );
|
||||||
|
|
||||||
case GBR_SPOT_RECT:
|
case GBR_SPOT_RECT:
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <convert_to_biu.h>
|
#include <convert_to_biu.h>
|
||||||
#include <gerbview.h>
|
#include <gerbview.h>
|
||||||
|
|
||||||
|
#include <dcode.h>
|
||||||
#include <gerber_draw_item.h>
|
#include <gerber_draw_item.h>
|
||||||
#include <gerber_file_image.h>
|
#include <gerber_file_image.h>
|
||||||
|
|
||||||
|
@ -253,10 +254,16 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
if( !isFilled )
|
if( !isFilled )
|
||||||
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
|
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
|
||||||
|
|
||||||
SHAPE_POLY_SET absolutePolygon = aItem->m_Polygon;
|
std::vector<VECTOR2I> pts = aItem->m_Polygon.COutline( 0 ).CPoints();
|
||||||
|
|
||||||
for( auto it = absolutePolygon.Iterate( 0 ); it; ++it )
|
for( auto& pt : pts )
|
||||||
*it = aItem->GetABPosition( *it );
|
pt = aItem->GetABPosition( pt );
|
||||||
|
|
||||||
|
|
||||||
|
SHAPE_POLY_SET absolutePolygon;
|
||||||
|
SHAPE_LINE_CHAIN chain( pts );
|
||||||
|
chain.SetClosed( true );
|
||||||
|
absolutePolygon.AddOutline( chain );
|
||||||
|
|
||||||
// Degenerated polygons (having < 3 points) are drawn as lines
|
// Degenerated polygons (having < 3 points) are drawn as lines
|
||||||
// to avoid issues in draw polygon functions
|
// to avoid issues in draw polygon functions
|
||||||
|
@ -362,7 +369,8 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
{
|
{
|
||||||
if( aItem->m_Polygon.OutlineCount() == 0 )
|
if( aItem->m_Polygon.OutlineCount() == 0 )
|
||||||
aItem->ConvertSegmentToPolygon();
|
aItem->ConvertSegmentToPolygon();
|
||||||
drawPolygon( aItem, aItem->m_Polygon, isFilled );
|
|
||||||
|
drawPolygon( aItem, code, isFilled );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -392,23 +400,25 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GERBVIEW_PAINTER::drawPolygon( GERBER_DRAW_ITEM* aParent,
|
void GERBVIEW_PAINTER::drawPolygon(
|
||||||
SHAPE_POLY_SET& aPolygon,
|
GERBER_DRAW_ITEM* aParent, D_CODE* aCode, bool aFilled, bool aShift )
|
||||||
bool aFilled )
|
|
||||||
{
|
{
|
||||||
for( auto it = aPolygon.Iterate( 0 ); it; ++it )
|
SHAPE_POLY_SET poly;
|
||||||
*it = aParent->GetABPosition( *it );
|
auto& pts = aCode->m_Polygon.COutline( 0 ).CPoints();
|
||||||
|
VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
|
||||||
|
|
||||||
|
for( auto& pt : pts )
|
||||||
|
poly.Append( aParent->GetABPosition( pt + offset ) );
|
||||||
|
|
||||||
if( !m_gerbviewSettings.m_polygonFill )
|
if( !m_gerbviewSettings.m_polygonFill )
|
||||||
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
|
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
|
||||||
|
|
||||||
if( !aFilled )
|
if( !aFilled )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < aPolygon.OutlineCount(); i++ )
|
m_gal->DrawPolyline( poly.COutline( 0 ) );
|
||||||
m_gal->DrawPolyline( aPolygon.COutline( i ) );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_gal->DrawPolygon( aPolygon );
|
m_gal->DrawPolygon( poly );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -442,9 +452,9 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
SHAPE_POLY_SET poly = code->m_Polygon;
|
SHAPE_POLY_SET poly = code->m_Polygon;
|
||||||
poly.Move( aItem->m_Start );
|
poly.Move( VECTOR2I( aItem->m_Start ) );
|
||||||
|
|
||||||
drawPolygon( aItem, poly, aFilled );
|
drawPolygon( aItem, code, aFilled );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -469,10 +479,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
SHAPE_POLY_SET poly = code->m_Polygon;
|
drawPolygon( aItem, code, aFilled );
|
||||||
poly.Move( aItem->m_Start );
|
|
||||||
|
|
||||||
drawPolygon( aItem, poly, aFilled );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -511,10 +518,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
SHAPE_POLY_SET poly = code->m_Polygon;
|
drawPolygon( aItem, code, aFilled );
|
||||||
poly.Move( aItem->m_Start );
|
|
||||||
|
|
||||||
drawPolygon( aItem, poly, aFilled );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -524,10 +528,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
SHAPE_POLY_SET poly = code->m_Polygon;
|
drawPolygon( aItem, code, aFilled );
|
||||||
poly.Move( aItem->m_Start );
|
|
||||||
|
|
||||||
drawPolygon( aItem, poly, aFilled );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
#include <painter.h>
|
#include <painter.h>
|
||||||
|
|
||||||
|
#include <dcode.h>
|
||||||
#include <gbr_display_options.h>
|
#include <gbr_display_options.h>
|
||||||
#include <geometry/shape_poly_set.h>
|
#include <geometry/shape_poly_set.h>
|
||||||
|
|
||||||
|
@ -191,8 +193,14 @@ protected:
|
||||||
// Drawing functions
|
// Drawing functions
|
||||||
void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
|
void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
|
||||||
|
|
||||||
/// Helper routine to draw a polygon
|
/**
|
||||||
void drawPolygon( GERBER_DRAW_ITEM* aParent, SHAPE_POLY_SET& aPolygon, bool aFilled );
|
* Helper routine to draw a polygon
|
||||||
|
* @param aParent Pointer to the draw item for AB Position calculation
|
||||||
|
* @param aCode Flash code pointer
|
||||||
|
* @param aFilled If true, draw the polygon as filled, otherwise only outline
|
||||||
|
* @param aShift If true, draw the polygon relative to the parent item position
|
||||||
|
*/
|
||||||
|
void drawPolygon( GERBER_DRAW_ITEM* aParent, D_CODE* aCode, bool aFilled, bool aShift = false );
|
||||||
|
|
||||||
/// Helper to draw a flashed shape (aka spot)
|
/// Helper to draw a flashed shape (aka spot)
|
||||||
void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
|
void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
|
||||||
|
|
|
@ -555,7 +555,7 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command )
|
||||||
if( m_Exposure && GetItemsList() ) // End of polygon
|
if( m_Exposure && GetItemsList() ) // End of polygon
|
||||||
{
|
{
|
||||||
GERBER_DRAW_ITEM * gbritem = m_Drawings.GetLast();
|
GERBER_DRAW_ITEM * gbritem = m_Drawings.GetLast();
|
||||||
gbritem->m_Polygon.Append( gbritem->m_Polygon.Vertex( 0 ) );
|
gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) );
|
||||||
StepAndRepeatItem( *gbritem );
|
StepAndRepeatItem( *gbritem );
|
||||||
}
|
}
|
||||||
m_Exposure = false;
|
m_Exposure = false;
|
||||||
|
@ -670,7 +670,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
|
||||||
if( m_Exposure && GetItemsList() ) // End of polygon
|
if( m_Exposure && GetItemsList() ) // End of polygon
|
||||||
{
|
{
|
||||||
gbritem = m_Drawings.GetLast();
|
gbritem = m_Drawings.GetLast();
|
||||||
gbritem->m_Polygon.Append( gbritem->m_Polygon.Vertex( 0 ) );
|
gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) );
|
||||||
StepAndRepeatItem( *gbritem );
|
StepAndRepeatItem( *gbritem );
|
||||||
}
|
}
|
||||||
m_Exposure = false;
|
m_Exposure = false;
|
||||||
|
|
|
@ -177,7 +177,7 @@ enum HASH_FLAG
|
||||||
|
|
||||||
for( int i = 0; i<m_outline.SegmentCount(); i++ )
|
for( int i = 0; i<m_outline.SegmentCount(); i++ )
|
||||||
{
|
{
|
||||||
SEG edge = m_outline.CSegment( i );
|
SEG edge = m_outline.Segment( i );
|
||||||
|
|
||||||
if( edgeSet.find( edge ) == edgeSet.end() )
|
if( edgeSet.find( edge ) == edgeSet.end() )
|
||||||
{
|
{
|
||||||
|
@ -191,7 +191,7 @@ enum HASH_FLAG
|
||||||
|
|
||||||
for( int i = 0; i<m_outline.SegmentCount(); i++ )
|
for( int i = 0; i<m_outline.SegmentCount(); i++ )
|
||||||
{
|
{
|
||||||
auto edge = m_outline.CSegment( i );
|
auto edge = m_outline.Segment( i );
|
||||||
auto dir = edge.B - edge.A;
|
auto dir = edge.B - edge.A;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ public:
|
||||||
const auto& cell = m_grid [ m_gridSize * gy + gx];
|
const auto& cell = m_grid [ m_gridSize * gy + gx];
|
||||||
for ( auto index : cell )
|
for ( auto index : cell )
|
||||||
{
|
{
|
||||||
const auto& seg = m_outline.CSegment(index);
|
const auto& seg = m_outline.Segment( index );
|
||||||
|
|
||||||
if ( seg.SquaredDistance(aP) <= dist )
|
if ( seg.SquaredDistance(aP) <= dist )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -116,7 +116,6 @@ public:
|
||||||
m_points[3] = aD;
|
m_points[3] = aD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) :
|
SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) :
|
||||||
SHAPE( SH_LINE_CHAIN ),
|
SHAPE( SH_LINE_CHAIN ),
|
||||||
m_closed( false )
|
m_closed( false )
|
||||||
|
@ -127,7 +126,6 @@ public:
|
||||||
m_points[i] = *aV++;
|
m_points[i] = *aV++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHAPE_LINE_CHAIN( const std::vector<wxPoint>& aV ) :
|
SHAPE_LINE_CHAIN( const std::vector<wxPoint>& aV ) :
|
||||||
SHAPE( SH_LINE_CHAIN ),
|
SHAPE( SH_LINE_CHAIN ),
|
||||||
m_closed( false )
|
m_closed( false )
|
||||||
|
@ -138,6 +136,13 @@ public:
|
||||||
m_points.emplace_back( pt.x, pt.y );
|
m_points.emplace_back( pt.x, pt.y );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHAPE_LINE_CHAIN( const std::vector<VECTOR2I>& aV ) :
|
||||||
|
SHAPE( SH_LINE_CHAIN ),
|
||||||
|
m_closed( false )
|
||||||
|
{
|
||||||
|
m_points = aV;
|
||||||
|
}
|
||||||
|
|
||||||
SHAPE_LINE_CHAIN( const ClipperLib::Path& aPath ) :
|
SHAPE_LINE_CHAIN( const ClipperLib::Path& aPath ) :
|
||||||
SHAPE( SH_LINE_CHAIN ),
|
SHAPE( SH_LINE_CHAIN ),
|
||||||
m_closed( true )
|
m_closed( true )
|
||||||
|
@ -252,22 +257,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Point()
|
* Accessor Function to move a point to a specific location
|
||||||
*
|
* @param aIndex Index (wrapping) of the point to move
|
||||||
* Returns a reference to a given point in the line chain.
|
* @param aPos New absolute location of the point
|
||||||
* @param aIndex index of the point
|
|
||||||
* @return reference to the point
|
|
||||||
*/
|
*/
|
||||||
VECTOR2I& Point( int aIndex )
|
void SetPoint( int aIndex, const VECTOR2I& aPos )
|
||||||
{
|
{
|
||||||
if( aIndex < 0 )
|
if( aIndex < 0 )
|
||||||
aIndex += PointCount();
|
aIndex += PointCount();
|
||||||
|
else if( aIndex >= PointCount() )
|
||||||
|
aIndex -= PointCount();
|
||||||
|
|
||||||
return m_points[aIndex];
|
m_points[aIndex] = aPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function CPoint()
|
* Function Point()
|
||||||
*
|
*
|
||||||
* Returns a const reference to a given point in the line chain.
|
* Returns a const reference to a given point in the line chain.
|
||||||
* @param aIndex index of the point
|
* @param aIndex index of the point
|
||||||
|
@ -288,14 +293,6 @@ public:
|
||||||
return m_points;
|
return m_points;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the last point in the line chain.
|
|
||||||
*/
|
|
||||||
VECTOR2I& LastPoint()
|
|
||||||
{
|
|
||||||
return m_points[PointCount() - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last point in the line chain.
|
* Returns the last point in the line chain.
|
||||||
*/
|
*/
|
||||||
|
@ -618,13 +615,6 @@ public:
|
||||||
*/
|
*/
|
||||||
SHAPE_LINE_CHAIN& Simplify();
|
SHAPE_LINE_CHAIN& Simplify();
|
||||||
|
|
||||||
/**
|
|
||||||
* Function convertFromClipper()
|
|
||||||
* Appends the Clipper path to the current SHAPE_LINE_CHAIN
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void convertFromClipper( const ClipperLib::Path& aPath );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Clipper path from the SHAPE_LINE_CHAIN in a given orientation
|
* Creates a new Clipper path from the SHAPE_LINE_CHAIN in a given orientation
|
||||||
*
|
*
|
||||||
|
@ -678,13 +668,31 @@ public:
|
||||||
(*i) += aVector;
|
(*i) += aVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mirrors the line points about y or x (or both)
|
||||||
|
* @param aX If true, mirror about the y axis (flip X coordinate)
|
||||||
|
* @param aY If true, mirror about the x axis (flip Y coordinate)
|
||||||
|
* @param aRef sets the reference point about which to mirror
|
||||||
|
*/
|
||||||
|
void Mirror( bool aX = true, bool aY = false, const VECTOR2I& aRef = { 0, 0 } )
|
||||||
|
{
|
||||||
|
for( auto& pt : m_points )
|
||||||
|
{
|
||||||
|
if( aX )
|
||||||
|
pt.x = -pt.x + 2 * aRef.x;
|
||||||
|
|
||||||
|
if( aY )
|
||||||
|
pt.y = -pt.y + 2 * aRef.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Rotate
|
* Function Rotate
|
||||||
* rotates all vertices by a given angle
|
* rotates all vertices by a given angle
|
||||||
* @param aCenter is the rotation center
|
* @param aCenter is the rotation center
|
||||||
* @param aAngle rotation angle in radians
|
* @param aAngle rotation angle in radians
|
||||||
*/
|
*/
|
||||||
void Rotate( double aAngle, const VECTOR2I& aCenter );
|
void Rotate( double aAngle, const VECTOR2I& aCenter = VECTOR2I( 0, 0 ) );
|
||||||
|
|
||||||
bool IsSolid() const override
|
bool IsSolid() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -229,17 +229,18 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
Advance();
|
Advance();
|
||||||
}
|
}
|
||||||
|
|
||||||
T& Get()
|
const T& Get()
|
||||||
{
|
{
|
||||||
return m_poly->Polygon( m_currentPolygon )[m_currentContour].Point( m_currentVertex );
|
return m_poly->Polygon( m_currentPolygon )[m_currentContour].CPoint(
|
||||||
|
m_currentVertex );
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*()
|
const T& operator*()
|
||||||
{
|
{
|
||||||
return Get();
|
return Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
T* operator->()
|
const T* operator->()
|
||||||
{
|
{
|
||||||
return &Get();
|
return &Get();
|
||||||
}
|
}
|
||||||
|
@ -508,21 +509,12 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
*/
|
*/
|
||||||
void InsertVertex( int aGlobalIndex, VECTOR2I aNewVertex );
|
void InsertVertex( int aGlobalIndex, VECTOR2I aNewVertex );
|
||||||
|
|
||||||
///> Returns the index-th vertex in a given hole outline within a given outline
|
|
||||||
VECTOR2I& Vertex( int aIndex, int aOutline, int aHole );
|
|
||||||
|
|
||||||
///> Returns the index-th vertex in a given hole outline within a given outline
|
///> Returns the index-th vertex in a given hole outline within a given outline
|
||||||
const VECTOR2I& CVertex( int aIndex, int aOutline, int aHole ) const;
|
const VECTOR2I& CVertex( int aIndex, int aOutline, int aHole ) const;
|
||||||
|
|
||||||
///> Returns the aGlobalIndex-th vertex in the poly set
|
|
||||||
VECTOR2I& Vertex( int aGlobalIndex );
|
|
||||||
|
|
||||||
///> Returns the aGlobalIndex-th vertex in the poly set
|
///> Returns the aGlobalIndex-th vertex in the poly set
|
||||||
const VECTOR2I& CVertex( int aGlobalIndex ) const;
|
const VECTOR2I& CVertex( int aGlobalIndex ) const;
|
||||||
|
|
||||||
///> Returns the index-th vertex in a given hole outline within a given outline
|
|
||||||
VECTOR2I& Vertex( VERTEX_INDEX aIndex );
|
|
||||||
|
|
||||||
///> Returns the index-th vertex in a given hole outline within a given outline
|
///> Returns the index-th vertex in a given hole outline within a given outline
|
||||||
const VECTOR2I& CVertex( VERTEX_INDEX aIndex ) const;
|
const VECTOR2I& CVertex( VERTEX_INDEX aIndex ) const;
|
||||||
|
|
||||||
|
@ -938,13 +930,21 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
/// @copydoc SHAPE::Move()
|
/// @copydoc SHAPE::Move()
|
||||||
void Move( const VECTOR2I& aVector ) override;
|
void Move( const VECTOR2I& aVector ) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mirrors the line points about y or x (or both)
|
||||||
|
* @param aX If true, mirror about the y axis (flip x coordinate)
|
||||||
|
* @param aY If true, mirror about the x axis
|
||||||
|
* @param aRef sets the reference point about which to mirror
|
||||||
|
*/
|
||||||
|
void Mirror( bool aX = true, bool aY = false, const VECTOR2I& aRef = { 0, 0 } );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Rotate
|
* Function Rotate
|
||||||
* rotates all vertices by a given angle
|
* rotates all vertices by a given angle
|
||||||
* @param aCenter is the rotation center
|
* @param aCenter is the rotation center
|
||||||
* @param aAngle rotation angle in radians
|
* @param aAngle rotation angle in radians
|
||||||
*/
|
*/
|
||||||
void Rotate( double aAngle, const VECTOR2I& aCenter );
|
void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } );
|
||||||
|
|
||||||
/// @copydoc SHAPE::IsSolid()
|
/// @copydoc SHAPE::IsSolid()
|
||||||
bool IsSolid() const override
|
bool IsSolid() const override
|
||||||
|
@ -1075,6 +1075,22 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
*/
|
*/
|
||||||
int RemoveNullSegments();
|
int RemoveNullSegments();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetVertex
|
||||||
|
* Accessor function to set the position of a specific point
|
||||||
|
* @param aIndex VERTEX_INDEX of the point to move
|
||||||
|
* @param aPos destination position of the specified point
|
||||||
|
*/
|
||||||
|
void SetVertex( const VERTEX_INDEX& aIndex, const VECTOR2I& aPos );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the vertex based on the global index. Throws if the index
|
||||||
|
* doesn't exist
|
||||||
|
* @param aGlobalIndex global index of the to-be-moved vertex
|
||||||
|
* @param aPos New position on the vertex
|
||||||
|
*/
|
||||||
|
void SetVertex( int aGlobalIndex, const VECTOR2I& aPos );
|
||||||
|
|
||||||
///> Returns total number of vertices stored in the set.
|
///> Returns total number of vertices stored in the set.
|
||||||
int TotalVertices() const;
|
int TotalVertices() const;
|
||||||
|
|
||||||
|
|
|
@ -90,20 +90,6 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function Point()
|
* Function Point()
|
||||||
*
|
*
|
||||||
* Returns a reference to a given point in the polygon. Negative indices
|
|
||||||
* count from the end of the point list, e.g. -1 means "last point", -2
|
|
||||||
* means "second to last point" and so on.
|
|
||||||
* @param aIndex index of the point
|
|
||||||
* @return reference to the point
|
|
||||||
*/
|
|
||||||
VECTOR2I& Point( int aIndex )
|
|
||||||
{
|
|
||||||
return m_points.Point( aIndex );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function CPoint()
|
|
||||||
*
|
|
||||||
* Returns a const reference to a given point in the polygon. Negative
|
* Returns a const reference to a given point in the polygon. Negative
|
||||||
* indices count from the end of the point list, e.g. -1 means "last
|
* indices count from the end of the point list, e.g. -1 means "last
|
||||||
* point", -2 means "second to last point" and so on.
|
* point", -2 means "second to last point" and so on.
|
||||||
|
|
|
@ -111,8 +111,8 @@ void GRMoveTo( int x, int y );
|
||||||
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
|
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
|
||||||
int x, int y, int width, COLOR4D Color );
|
int x, int y, int width, COLOR4D Color );
|
||||||
|
|
||||||
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
|
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
|
||||||
int width, COLOR4D Color, COLOR4D BgColor );
|
COLOR4D Color, COLOR4D BgColor );
|
||||||
|
|
||||||
/** Draw cubic (4 points: start control1, control2, end) bezier curve
|
/** Draw cubic (4 points: start control1, control2, end) bezier curve
|
||||||
*/
|
*/
|
||||||
|
@ -131,13 +131,8 @@ void GRBezier( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aPoints,
|
||||||
* @param aPenColor the color of the border.
|
* @param aPenColor the color of the border.
|
||||||
* @param aFillColor the fill color of the polygon's interior.
|
* @param aFillColor the fill color of the polygon's interior.
|
||||||
*/
|
*/
|
||||||
void GRClosedPoly( EDA_RECT* ClipBox,
|
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
|
||||||
wxDC * aDC,
|
bool doFill, COLOR4D aPenColor, COLOR4D aFillColor );
|
||||||
int aPointCount,
|
|
||||||
wxPoint aPoints[],
|
|
||||||
bool doFill,
|
|
||||||
COLOR4D aPenColor,
|
|
||||||
COLOR4D aFillColor );
|
|
||||||
|
|
||||||
// @todo could make these 2 closed polygons calls a single function and default
|
// @todo could make these 2 closed polygons calls a single function and default
|
||||||
// the aPenWidth argument
|
// the aPenWidth argument
|
||||||
|
@ -155,14 +150,8 @@ void GRClosedPoly( EDA_RECT* ClipBox,
|
||||||
* @param aPenColor the color of the border.
|
* @param aPenColor the color of the border.
|
||||||
* @param aFillColor the fill color of the polygon's interior.
|
* @param aFillColor the fill color of the polygon's interior.
|
||||||
*/
|
*/
|
||||||
void GRClosedPoly( EDA_RECT* ClipBox,
|
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
|
||||||
wxDC* aDC,
|
bool doFill, int aPenWidth, COLOR4D aPenColor, COLOR4D aFillColor );
|
||||||
int aPointCount,
|
|
||||||
wxPoint aPoints[],
|
|
||||||
bool doFill,
|
|
||||||
int aPenWidth,
|
|
||||||
COLOR4D aPenColor,
|
|
||||||
COLOR4D aFillColor );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -100,10 +100,7 @@ void DRAWSEGMENT::Move( const wxPoint& aMoveVector )
|
||||||
switch ( m_Shape )
|
switch ( m_Shape )
|
||||||
{
|
{
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
m_Poly.Move( VECTOR2I( aMoveVector ) );
|
||||||
{
|
|
||||||
(*iter) += VECTOR2I( aMoveVector );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CURVE:
|
case S_CURVE:
|
||||||
|
@ -136,10 +133,7 @@ void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
m_Poly.Rotate( -DECIDEG2RAD( aAngle ), VECTOR2I( aRotCentre ) );
|
||||||
{
|
|
||||||
RotatePoint( *iter, VECTOR2I(aRotCentre), aAngle);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CURVE:
|
case S_CURVE:
|
||||||
|
@ -184,13 +178,7 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
m_Poly.Mirror( aFlipLeftRight, !aFlipLeftRight, VECTOR2I( aCentre ) );
|
||||||
{
|
|
||||||
if( aFlipLeftRight )
|
|
||||||
iter->x = aCentre.x - ( iter->x - aCentre.x );
|
|
||||||
else
|
|
||||||
iter->y = aCentre.y - ( iter->y - aCentre.y );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CURVE:
|
case S_CURVE:
|
||||||
|
@ -441,7 +429,8 @@ void DRAWSEGMENT::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffse
|
||||||
for( int jj = 0; jj < outline.OutlineCount(); ++jj )
|
for( int jj = 0; jj < outline.OutlineCount(); ++jj )
|
||||||
{
|
{
|
||||||
SHAPE_LINE_CHAIN& poly = outline.Outline( jj );
|
SHAPE_LINE_CHAIN& poly = outline.Outline( jj );
|
||||||
GRClosedPoly( nullptr, DC, poly.PointCount(), (wxPoint*)&poly.Point( 0 ),
|
GRClosedPoly( nullptr, DC, poly.PointCount(),
|
||||||
|
static_cast<const wxPoint*>( &poly.CPoint( 0 ) ),
|
||||||
IsPolygonFilled(), GetWidth(), color, color );
|
IsPolygonFilled(), GetWidth(), color, color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,13 +327,7 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
// polygon corners coordinates are always relative to the
|
// polygon corners coordinates are always relative to the
|
||||||
// footprint position, orientation 0
|
// footprint position, orientation 0
|
||||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
m_Poly.Mirror( aFlipLeftRight, !aFlipLeftRight );
|
||||||
{
|
|
||||||
if( aFlipLeftRight )
|
|
||||||
MIRROR( iter->x, 0 );
|
|
||||||
else
|
|
||||||
MIRROR( iter->y, 0 );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,13 +385,8 @@ void EDGE_MODULE::Mirror( wxPoint aCentre, bool aMirrorAroundXAxis )
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
// polygon corners coordinates are always relative to the
|
// polygon corners coordinates are always relative to the
|
||||||
// footprint position, orientation 0
|
// footprint position, orientation 0
|
||||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
m_Poly.Mirror( !aMirrorAroundXAxis, aMirrorAroundXAxis );
|
||||||
{
|
break;
|
||||||
if( aMirrorAroundXAxis )
|
|
||||||
MIRROR( iter->y, aCentre.y );
|
|
||||||
else
|
|
||||||
MIRROR( iter->x, aCentre.x );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDrawCoord();
|
SetDrawCoord();
|
||||||
|
@ -433,8 +422,7 @@ void EDGE_MODULE::Move( const wxPoint& aMoveVector )
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
// polygon corners coordinates are always relative to the
|
// polygon corners coordinates are always relative to the
|
||||||
// footprint position, orientation 0
|
// footprint position, orientation 0
|
||||||
for( auto iter = m_Poly.Iterate(); iter; iter++ )
|
m_Poly.Move( VECTOR2I( aMoveVector ) );
|
||||||
*iter += VECTOR2I( aMoveVector );
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -491,13 +491,7 @@ void D_PAD::FlipPrimitives()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flip local coordinates in merged Polygon
|
// Flip local coordinates in merged Polygon
|
||||||
for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt )
|
m_customShapeAsPolygon.Mirror( false, true );
|
||||||
{
|
|
||||||
SHAPE_LINE_CHAIN& poly = m_customShapeAsPolygon.Outline( cnt );
|
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
|
||||||
MIRROR( poly.Point( ii ).y, 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -528,9 +522,7 @@ void D_PAD::MirrorXPrimitives( int aX )
|
||||||
for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt )
|
for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt )
|
||||||
{
|
{
|
||||||
SHAPE_LINE_CHAIN& poly = m_customShapeAsPolygon.Outline( cnt );
|
SHAPE_LINE_CHAIN& poly = m_customShapeAsPolygon.Outline( cnt );
|
||||||
|
poly.Mirror( true, false );
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
|
||||||
MIRROR( poly.Point( ii ).x, 0 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -625,8 +625,8 @@ bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur
|
||||||
|
|
||||||
for( int ii = 0; ii < count; ii++ )
|
for( int ii = 0; ii < count; ii++ )
|
||||||
{
|
{
|
||||||
auto vertex = m_Poly->Vertex( ii );
|
auto vertex = m_Poly->CVertex( ii );
|
||||||
auto vertexNext = m_Poly->Vertex( ( ii + 1 ) % count );
|
auto vertexNext = m_Poly->CVertex( ( ii + 1 ) % count );
|
||||||
|
|
||||||
// Test if the point is within the rect
|
// Test if the point is within the rect
|
||||||
if( arect.Contains( ( wxPoint ) vertex ) )
|
if( arect.Contains( ( wxPoint ) vertex ) )
|
||||||
|
@ -789,8 +789,8 @@ void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge )
|
||||||
|
|
||||||
if( m_Poly->GetNeighbourIndexes( aEdge, nullptr, &next_corner ) )
|
if( m_Poly->GetNeighbourIndexes( aEdge, nullptr, &next_corner ) )
|
||||||
{
|
{
|
||||||
m_Poly->Vertex( aEdge ) += VECTOR2I( offset );
|
m_Poly->SetVertex( aEdge, m_Poly->CVertex( aEdge ) + VECTOR2I( offset ) );
|
||||||
m_Poly->Vertex( next_corner ) += VECTOR2I( offset );
|
m_Poly->SetVertex( next_corner, m_Poly->CVertex( next_corner ) + VECTOR2I( offset ) );
|
||||||
Hatch();
|
Hatch();
|
||||||
|
|
||||||
SetNeedRefill( true );
|
SetNeedRefill( true );
|
||||||
|
@ -802,19 +802,13 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
|
||||||
{
|
{
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
|
|
||||||
for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
|
angle = -DECIDEG2RAD( angle );
|
||||||
{
|
|
||||||
pos = static_cast<wxPoint>( *iterator );
|
|
||||||
RotatePoint( &pos, centre, angle );
|
|
||||||
iterator->x = pos.x;
|
|
||||||
iterator->y = pos.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
m_Poly->Rotate( angle, VECTOR2I( centre ) );
|
||||||
Hatch();
|
Hatch();
|
||||||
|
|
||||||
/* rotate filled areas: */
|
/* rotate filled areas: */
|
||||||
for( auto ic = m_FilledPolysList.Iterate(); ic; ++ic )
|
m_FilledPolysList.Rotate( angle, VECTOR2I( centre ) );
|
||||||
RotatePoint( &ic->x, &ic->y, centre.x, centre.y, angle );
|
|
||||||
|
|
||||||
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
|
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
|
||||||
{
|
{
|
||||||
|
@ -846,23 +840,12 @@ void ZONE_CONTAINER::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
||||||
|
|
||||||
void ZONE_CONTAINER::Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight )
|
void ZONE_CONTAINER::Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight )
|
||||||
{
|
{
|
||||||
for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
|
// ZONE_CONTAINERs mirror about the x-axis (why?!?)
|
||||||
{
|
m_Poly->Mirror( aMirrorLeftRight, !aMirrorLeftRight, VECTOR2I( aMirrorRef ) );
|
||||||
if( aMirrorLeftRight )
|
|
||||||
iterator->x = ( aMirrorRef.x - iterator->x ) + aMirrorRef.x;
|
|
||||||
else
|
|
||||||
iterator->y = ( aMirrorRef.y - iterator->y ) + aMirrorRef.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
Hatch();
|
Hatch();
|
||||||
|
|
||||||
for( auto ic = m_FilledPolysList.Iterate(); ic; ++ic )
|
m_FilledPolysList.Mirror( aMirrorLeftRight, !aMirrorLeftRight, VECTOR2I( aMirrorRef ) );
|
||||||
{
|
|
||||||
if( aMirrorLeftRight )
|
|
||||||
ic->x = ( aMirrorRef.x - ic->x ) + aMirrorRef.x;
|
|
||||||
else
|
|
||||||
ic->y = ( aMirrorRef.y - ic->y ) + aMirrorRef.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( SEG& seg : m_FillSegmList )
|
for( SEG& seg : m_FillSegmList )
|
||||||
{
|
{
|
||||||
|
@ -1009,10 +992,10 @@ void ZONE_CONTAINER::Hatch()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// define range for hatch lines
|
// define range for hatch lines
|
||||||
int min_x = m_Poly->Vertex( 0 ).x;
|
int min_x = m_Poly->CVertex( 0 ).x;
|
||||||
int max_x = m_Poly->Vertex( 0 ).x;
|
int max_x = m_Poly->CVertex( 0 ).x;
|
||||||
int min_y = m_Poly->Vertex( 0 ).y;
|
int min_y = m_Poly->CVertex( 0 ).y;
|
||||||
int max_y = m_Poly->Vertex( 0 ).y;
|
int max_y = m_Poly->CVertex( 0 ).y;
|
||||||
|
|
||||||
for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
|
for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -486,12 +486,12 @@ public:
|
||||||
// Convert global to relative indices
|
// Convert global to relative indices
|
||||||
if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
|
if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
|
||||||
{
|
{
|
||||||
if( m_Poly->Vertex( relativeIndices ).x != new_pos.x ||
|
if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
|
||||||
m_Poly->Vertex( relativeIndices ).y != new_pos.y )
|
|| m_Poly->CVertex( relativeIndices ).y != new_pos.y )
|
||||||
|
{
|
||||||
SetNeedRefill( true );
|
SetNeedRefill( true );
|
||||||
|
m_Poly->SetVertex( relativeIndices, new_pos );
|
||||||
m_Poly->Vertex( relativeIndices ).x = new_pos.x;
|
}
|
||||||
m_Poly->Vertex( relativeIndices ).y = new_pos.y;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
|
throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
|
||||||
|
|
|
@ -125,7 +125,7 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const
|
||||||
if( courtyard.OutlineCount() )
|
if( courtyard.OutlineCount() )
|
||||||
{
|
{
|
||||||
//Overlap between footprint and candidate
|
//Overlap between footprint and candidate
|
||||||
VECTOR2I& pos = courtyard.Vertex( 0, 0, -1 );
|
auto& pos = courtyard.CVertex( 0, 0, -1 );
|
||||||
auto marker = std::unique_ptr<MARKER_PCB>(
|
auto marker = std::unique_ptr<MARKER_PCB>(
|
||||||
marker_factory.NewMarker( wxPoint( pos.x, pos.y ), footprint, candidate,
|
marker_factory.NewMarker( wxPoint( pos.x, pos.y ), footprint, candidate,
|
||||||
DRCE_OVERLAPPING_FOOTPRINTS ) );
|
DRCE_OVERLAPPING_FOOTPRINTS ) );
|
||||||
|
@ -162,7 +162,7 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const
|
||||||
if( courtyard.OutlineCount() )
|
if( courtyard.OutlineCount() )
|
||||||
{
|
{
|
||||||
//Overlap between footprint and candidate
|
//Overlap between footprint and candidate
|
||||||
VECTOR2I& pos = courtyard.Vertex( 0, 0, -1 );
|
auto& pos = courtyard.CVertex( 0, 0, -1 );
|
||||||
auto marker = std::unique_ptr<MARKER_PCB>(
|
auto marker = std::unique_ptr<MARKER_PCB>(
|
||||||
marker_factory.NewMarker( wxPoint( pos.x, pos.y ), footprint, candidate,
|
marker_factory.NewMarker( wxPoint( pos.x, pos.y ), footprint, candidate,
|
||||||
DRCE_OVERLAPPING_FOOTPRINTS ) );
|
DRCE_OVERLAPPING_FOOTPRINTS ) );
|
||||||
|
|
|
@ -1119,8 +1119,8 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P
|
||||||
|
|
||||||
cornerList.reserve( poly.PointCount() );
|
cornerList.reserve( poly.PointCount() );
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x * BOARD_SCALE,
|
cornerList.emplace_back(
|
||||||
-poly.Point( ii ).y * BOARD_SCALE );
|
poly.CPoint( ii ).x * BOARD_SCALE, -poly.CPoint( ii ).y * BOARD_SCALE );
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
cornerList.push_back( cornerList[0] );
|
cornerList.push_back( cornerList[0] );
|
||||||
|
@ -1142,8 +1142,8 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P
|
||||||
cornerList.clear();
|
cornerList.clear();
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
cornerList.emplace_back( poly.Point( ii ).x * BOARD_SCALE,
|
cornerList.emplace_back(
|
||||||
-poly.Point( ii ).y * BOARD_SCALE );
|
poly.CPoint( ii ).x * BOARD_SCALE, -poly.CPoint( ii ).y * BOARD_SCALE );
|
||||||
|
|
||||||
// Close polygon
|
// Close polygon
|
||||||
cornerList.push_back( cornerList[0] );
|
cornerList.push_back( cornerList[0] );
|
||||||
|
|
|
@ -388,20 +388,8 @@ void D_PAD::CustomShapeAsPolygonToBoardPosition( SHAPE_POLY_SET * aMergedPolygon
|
||||||
|
|
||||||
// Move, rotate, ... coordinates in aMergedPolygon according to the
|
// Move, rotate, ... coordinates in aMergedPolygon according to the
|
||||||
// pad position and orientation
|
// pad position and orientation
|
||||||
for( int cnt = 0; cnt < aMergedPolygon->OutlineCount(); ++cnt )
|
aMergedPolygon->Rotate( -DECIDEG2RAD( aRotation ) );
|
||||||
{
|
aMergedPolygon->Move( VECTOR2I( aPosition ) );
|
||||||
SHAPE_LINE_CHAIN& poly = aMergedPolygon->Outline( cnt );
|
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
|
||||||
{
|
|
||||||
wxPoint corner( poly.Point( ii ).x, poly.Point( ii ).y );
|
|
||||||
RotatePoint( &corner, aRotation );
|
|
||||||
corner += aPosition;
|
|
||||||
|
|
||||||
poly.Point( ii ).x = corner.x;
|
|
||||||
poly.Point( ii ).y = corner.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool D_PAD::GetBestAnchorPosition( VECTOR2I& aPos )
|
bool D_PAD::GetBestAnchorPosition( VECTOR2I& aPos )
|
||||||
|
|
|
@ -280,7 +280,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
|
|
||||||
if( poly.PointCount() > 0 )
|
if( poly.PointCount() > 0 )
|
||||||
{
|
{
|
||||||
GRClosedPoly( nullptr, aDC, poly.PointCount(), (wxPoint*)&poly.Point( 0 ),
|
GRClosedPoly( nullptr, aDC, poly.PointCount(),
|
||||||
|
static_cast<const wxPoint*>( &poly.CPoint( 0 ) ),
|
||||||
false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color );
|
false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +308,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
|
|
||||||
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
|
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
|
||||||
|
|
||||||
GRClosedPoly( nullptr, aDC, poly.PointCount(), (wxPoint*)&poly.Point( 0 ), filled, 0,
|
GRClosedPoly( nullptr, aDC, poly.PointCount(),
|
||||||
|
static_cast<const wxPoint*>( &poly.CPoint( 0 ) ), filled, 0,
|
||||||
aDrawInfo.m_Color, aDrawInfo.m_Color );
|
aDrawInfo.m_Color, aDrawInfo.m_Color );
|
||||||
|
|
||||||
if( aDrawInfo.m_PadClearance )
|
if( aDrawInfo.m_PadClearance )
|
||||||
|
@ -327,7 +329,7 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
|
SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
|
||||||
|
|
||||||
GRClosedPoly( nullptr, aDC, clearance_poly.PointCount(),
|
GRClosedPoly( nullptr, aDC, clearance_poly.PointCount(),
|
||||||
(wxPoint*)&clearance_poly.Point( 0 ), false, 0,
|
static_cast<const wxPoint*>( &clearance_poly.CPoint( 0 ) ), false, 0,
|
||||||
aDrawInfo.m_Color, aDrawInfo.m_Color );
|
aDrawInfo.m_Color, aDrawInfo.m_Color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,7 +375,6 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
|
SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
|
||||||
outline.Append( m_customShapeAsPolygon );
|
outline.Append( m_customShapeAsPolygon );
|
||||||
CustomShapeAsPolygonToBoardPosition( &outline, pad_pos, GetOrientation() );
|
CustomShapeAsPolygonToBoardPosition( &outline, pad_pos, GetOrientation() );
|
||||||
SHAPE_LINE_CHAIN* poly;
|
|
||||||
|
|
||||||
if( aDrawInfo.m_Mask_margin.x )
|
if( aDrawInfo.m_Mask_margin.x )
|
||||||
{
|
{
|
||||||
|
@ -387,9 +388,9 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
// ( can happen with CUSTOM pads and negative margins )
|
// ( can happen with CUSTOM pads and negative margins )
|
||||||
for( int jj = 0; jj < outline.OutlineCount(); ++jj )
|
for( int jj = 0; jj < outline.OutlineCount(); ++jj )
|
||||||
{
|
{
|
||||||
poly = &outline.Outline( jj );
|
auto& poly = outline.Outline( jj );
|
||||||
|
|
||||||
GRClosedPoly( nullptr, aDC, poly->PointCount(), (wxPoint*)&poly->Point( 0 ),
|
GRClosedPoly( nullptr, aDC, poly.PointCount(), static_cast<const wxPoint*>( &poly.CPoint( 0 ) ),
|
||||||
aDrawInfo.m_ShowPadFilled, 0, aDrawInfo.m_Color, aDrawInfo.m_Color );
|
aDrawInfo.m_ShowPadFilled, 0, aDrawInfo.m_Color, aDrawInfo.m_Color );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,11 +405,12 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
|
|
||||||
for( int jj = 0; jj < clearance_outline.OutlineCount(); ++jj )
|
for( int jj = 0; jj < clearance_outline.OutlineCount(); ++jj )
|
||||||
{
|
{
|
||||||
poly = &clearance_outline.Outline( jj );
|
auto& poly = clearance_outline.Outline( jj );
|
||||||
|
|
||||||
if( poly->PointCount() > 0 )
|
if( poly.PointCount() > 0 )
|
||||||
{
|
{
|
||||||
GRClosedPoly( nullptr, aDC, poly->PointCount(), (wxPoint*)&poly->Point( 0 ),
|
GRClosedPoly( nullptr, aDC, poly.PointCount(),
|
||||||
|
static_cast<const wxPoint*>( &poly.CPoint( 0 ) ),
|
||||||
false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color );
|
false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -831,8 +831,8 @@ void DIFF_PAIR::CoupledSegmentPairs( COUPLED_SEGMENTS_VEC& aPairs ) const
|
||||||
{
|
{
|
||||||
for( int j = 0; j < n.SegmentCount(); j++ )
|
for( int j = 0; j < n.SegmentCount(); j++ )
|
||||||
{
|
{
|
||||||
SEG sp = p.CSegment( i );
|
SEG sp = p.Segment( i );
|
||||||
SEG sn = n.CSegment( j );
|
SEG sn = n.Segment( j );
|
||||||
|
|
||||||
SEG p_clip, n_clip;
|
SEG p_clip, n_clip;
|
||||||
|
|
||||||
|
|
|
@ -687,7 +687,7 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
|
||||||
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
|
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
shape->Append( poly.Point( ii ) );
|
shape->Append( poly.CPoint( ii ) );
|
||||||
|
|
||||||
solid->SetShape( shape );
|
solid->SetShape( shape );
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
|
||||||
|
|
||||||
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
for( int ii = 0; ii < poly.PointCount(); ++ii )
|
||||||
{
|
{
|
||||||
shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
|
shape->Append( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
solid->SetShape( shape );
|
solid->SetShape( shape );
|
||||||
|
|
|
@ -469,7 +469,7 @@ void LINE::dragCorner45( const VECTOR2I& aP, int aIndex, int aSnappingThreshold
|
||||||
|
|
||||||
void LINE::dragCornerFree( const VECTOR2I& aP, int aIndex, int aSnappingThreshold )
|
void LINE::dragCornerFree( const VECTOR2I& aP, int aIndex, int aSnappingThreshold )
|
||||||
{
|
{
|
||||||
m_line.Point( aIndex ) = aP;
|
m_line.SetPoint( aIndex, aP );
|
||||||
m_line.Simplify();
|
m_line.Simplify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ bool LINE_PLACER::handleSelfIntersections()
|
||||||
// from the beginning
|
// from the beginning
|
||||||
if( n < 2 )
|
if( n < 2 )
|
||||||
{
|
{
|
||||||
m_p_start = tail.Point( 0 );
|
m_p_start = tail.CPoint( 0 );
|
||||||
m_direction = m_initial_direction;
|
m_direction = m_initial_direction;
|
||||||
tail.Clear();
|
tail.Clear();
|
||||||
head.Clear();
|
head.Clear();
|
||||||
|
@ -1228,7 +1228,7 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aInver
|
||||||
VECTOR2I newLast = l.CSegment( 0 ).LineProject( l.CPoint( -1 ) );
|
VECTOR2I newLast = l.CSegment( 0 ).LineProject( l.CPoint( -1 ) );
|
||||||
|
|
||||||
l.Remove( -1, -1 );
|
l.Remove( -1, -1 );
|
||||||
l.Point( 1 ) = newLast;
|
l.SetPoint( 1, newLast );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ SHAPE_LINE_CHAIN MEANDER_SHAPE::genMeanderShape( VECTOR2D aP, VECTOR2D aDir,
|
||||||
SEG axis( aP, aP + aDir );
|
SEG axis( aP, aP + aDir );
|
||||||
|
|
||||||
for( int i = 0; i < lc.PointCount(); i++ )
|
for( int i = 0; i < lc.PointCount(); i++ )
|
||||||
lc.Point( i ) = reflect( lc.CPoint( i ), axis );
|
lc.SetPoint( i, reflect( lc.CPoint( i ), axis ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return lc;
|
return lc;
|
||||||
|
|
|
@ -506,8 +506,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
|
||||||
|
|
||||||
for( int idx = 0; idx < polygonal_shape.PointCount(); idx++ )
|
for( int idx = 0; idx < polygonal_shape.PointCount(); idx++ )
|
||||||
{
|
{
|
||||||
POINT corner( scale( polygonal_shape.Point( idx ).x ),
|
POINT corner( scale( polygonal_shape.CPoint( idx ).x ),
|
||||||
scale( -polygonal_shape.Point( idx ).y ) );
|
scale( -polygonal_shape.CPoint( idx ).y ) );
|
||||||
corner += dsnOffset;
|
corner += dsnOffset;
|
||||||
polygon->AppendPoint( corner );
|
polygon->AppendPoint( corner );
|
||||||
|
|
||||||
|
@ -843,12 +843,12 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
|
||||||
|
|
||||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||||
{
|
{
|
||||||
wxPoint pos( outline.Point( ii ).x, outline.Point( ii ).y );
|
wxPoint pos( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
|
||||||
path->AppendPoint( mapPt( pos ) );
|
path->AppendPoint( mapPt( pos ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close polygon:
|
// Close polygon:
|
||||||
wxPoint pos0( outline.Point( 0 ).x, outline.Point( 0 ).y );
|
wxPoint pos0( outline.CPoint( 0 ).x, outline.CPoint( 0 ).y );
|
||||||
path->AppendPoint( mapPt( pos0 ) );
|
path->AppendPoint( mapPt( pos0 ) );
|
||||||
|
|
||||||
// Generate holes as keepout:
|
// Generate holes as keepout:
|
||||||
|
@ -866,12 +866,12 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
|
||||||
|
|
||||||
for( int jj = 0; jj < hole.PointCount(); jj++ )
|
for( int jj = 0; jj < hole.PointCount(); jj++ )
|
||||||
{
|
{
|
||||||
wxPoint pos( hole.Point( jj ).x, hole.Point( jj ).y );
|
wxPoint pos( hole.CPoint( jj ).x, hole.CPoint( jj ).y );
|
||||||
poly_ko->AppendPoint( mapPt( pos ) );
|
poly_ko->AppendPoint( mapPt( pos ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close polygon:
|
// Close polygon:
|
||||||
wxPoint pos( hole.Point( 0 ).x, hole.Point( 0 ).y );
|
wxPoint pos( hole.CPoint( 0 ).x, hole.CPoint( 0 ).y );
|
||||||
poly_ko->AppendPoint( mapPt( pos ) );
|
poly_ko->AppendPoint( mapPt( pos ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -986,7 +986,7 @@ void DRC::testCopperDrawItem( DRAWSEGMENT* aItem )
|
||||||
auto l = arc.ConvertToPolyline();
|
auto l = arc.ConvertToPolyline();
|
||||||
|
|
||||||
for( int i = 0; i < l.SegmentCount(); i++ )
|
for( int i = 0; i < l.SegmentCount(); i++ )
|
||||||
itemShape.push_back( l.CSegment(i) );
|
itemShape.push_back( l.Segment( i ) );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1003,7 @@ void DRC::testCopperDrawItem( DRAWSEGMENT* aItem )
|
||||||
auto l = circle.ConvertToPolyline();
|
auto l = circle.ConvertToPolyline();
|
||||||
|
|
||||||
for( int i = 0; i < l.SegmentCount(); i++ )
|
for( int i = 0; i < l.SegmentCount(); i++ )
|
||||||
itemShape.push_back( l.CSegment(i) );
|
itemShape.push_back( l.Segment( i ) );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,7 +509,7 @@ void POINT_EDITOR::updateItem() const
|
||||||
SHAPE_POLY_SET& outline = segment->GetPolyShape();
|
SHAPE_POLY_SET& outline = segment->GetPolyShape();
|
||||||
|
|
||||||
for( int i = 0; i < outline.TotalVertices(); ++i )
|
for( int i = 0; i < outline.TotalVertices(); ++i )
|
||||||
outline.Vertex( i ) = m_editPoints->Point( i ).GetPosition();
|
outline.SetVertex( i, m_editPoints->Point( i ).GetPosition() );
|
||||||
|
|
||||||
validatePolygon( outline );
|
validatePolygon( outline );
|
||||||
break;
|
break;
|
||||||
|
@ -552,10 +552,10 @@ void POINT_EDITOR::updateItem() const
|
||||||
|
|
||||||
for( int i = 0; i < outline.TotalVertices(); ++i )
|
for( int i = 0; i < outline.TotalVertices(); ++i )
|
||||||
{
|
{
|
||||||
if( outline.Vertex( i ) != m_editPoints->Point( i ).GetPosition() )
|
if( outline.CVertex( i ) != m_editPoints->Point( i ).GetPosition() )
|
||||||
zone->SetNeedRefill( true );
|
zone->SetNeedRefill( true );
|
||||||
|
|
||||||
outline.Vertex( i ) = m_editPoints->Point( i ).GetPosition();
|
outline.SetVertex( i, m_editPoints->Point( i ).GetPosition() );
|
||||||
}
|
}
|
||||||
|
|
||||||
validatePolygon( outline );
|
validatePolygon( outline );
|
||||||
|
@ -902,7 +902,7 @@ findVertex( SHAPE_POLY_SET& aPolySet, const EDIT_POINT& aPoint )
|
||||||
{
|
{
|
||||||
auto vertexIdx = it.GetIndex();
|
auto vertexIdx = it.GetIndex();
|
||||||
|
|
||||||
if( aPolySet.Vertex( vertexIdx ) == aPoint.GetPosition() )
|
if( aPolySet.CVertex( vertexIdx ) == aPoint.GetPosition() )
|
||||||
return std::make_pair( true, vertexIdx );
|
return std::make_pair( true, vertexIdx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,7 +1006,7 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
firstPointInContour = curr_idx+1; // Prepare next contour analysis
|
firstPointInContour = curr_idx+1; // Prepare next contour analysis
|
||||||
}
|
}
|
||||||
|
|
||||||
SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
|
SEG curr_segment( zoneOutline->CVertex( curr_idx ), zoneOutline->CVertex( jj ) );
|
||||||
|
|
||||||
unsigned int distance = curr_segment.Distance( cursorPos );
|
unsigned int distance = curr_segment.Distance( cursorPos );
|
||||||
|
|
||||||
|
@ -1019,8 +1019,8 @@ int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the point on the closest segment
|
// Find the point on the closest segment
|
||||||
VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
|
auto& sideOrigin = zoneOutline->CVertex( nearestIdx );
|
||||||
VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
|
auto& sideEnd = zoneOutline->CVertex( nextNearestIdx );
|
||||||
SEG nearestSide( sideOrigin, sideEnd );
|
SEG nearestSide( sideOrigin, sideEnd );
|
||||||
VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
|
VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
|
||||||
|
|
||||||
|
|
|
@ -980,11 +980,8 @@ void ZONE_FILLER::buildThermalSpokes( const ZONE_CONTAINER* aZone,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int j = 0; j < spoke.PointCount(); j++ )
|
spoke.Rotate( padAngle );
|
||||||
{
|
spoke.Move( shapePos );
|
||||||
RotatePoint( spoke.Point( j ), padAngle );
|
|
||||||
spoke.Point( j ) += shapePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
spoke.SetClosed( true );
|
spoke.SetClosed( true );
|
||||||
spoke.GenerateBBoxCache();
|
spoke.GenerateBBoxCache();
|
||||||
|
|
|
@ -41,11 +41,11 @@
|
||||||
#include <widgets/progress_reporter.h>
|
#include <widgets/progress_reporter.h>
|
||||||
#include <zone_filler.h>
|
#include <zone_filler.h>
|
||||||
|
|
||||||
|
// TODO: Remove these to the commit object below
|
||||||
// Local variables
|
// Local variables
|
||||||
static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
|
static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
|
||||||
static PICKED_ITEMS_LIST s_AuxiliaryList; // a picked list to store zones that are deleted or added when combined
|
static PICKED_ITEMS_LIST s_AuxiliaryList; // a picked list to store zones that are deleted or added when combined
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE_CONTAINER* aZone )
|
void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE_CONTAINER* aZone )
|
||||||
{
|
{
|
||||||
int dialogResult;
|
int dialogResult;
|
||||||
|
|
|
@ -61,19 +61,21 @@ void unfracture( SHAPE_POLY_SET::POLYGON* aPoly, SHAPE_POLY_SET::POLYGON* aResul
|
||||||
|
|
||||||
bool operator==( const EDGE& aOther ) const
|
bool operator==( const EDGE& aOther ) const
|
||||||
{
|
{
|
||||||
return compareSegs( m_poly->CSegment(m_index), aOther.m_poly->CSegment(aOther.m_index) );
|
return compareSegs(
|
||||||
|
m_poly->Segment( m_index ), aOther.m_poly->Segment( aOther.m_index ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( const EDGE& aOther ) const
|
bool operator!=( const EDGE& aOther ) const
|
||||||
{
|
{
|
||||||
return ! compareSegs( m_poly->CSegment(m_index), aOther.m_poly->CSegment(aOther.m_index) );
|
return !compareSegs(
|
||||||
|
m_poly->Segment( m_index ), aOther.m_poly->Segment( aOther.m_index ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HASH
|
struct HASH
|
||||||
{
|
{
|
||||||
std::size_t operator()( const EDGE& aEdge ) const
|
std::size_t operator()( const EDGE& aEdge ) const
|
||||||
{
|
{
|
||||||
const auto& a = aEdge.m_poly->CSegment(aEdge.m_index);
|
const auto& a = aEdge.m_poly->Segment( aEdge.m_index );
|
||||||
return (std::size_t) ( a.A.x + a.B.x + a.A.y + a.B.y );
|
return (std::size_t) ( a.A.x + a.B.x + a.A.y + a.B.y );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -178,7 +180,7 @@ aResult->clear();
|
||||||
queue.erase( edgeBuf[i] );
|
queue.erase( edgeBuf[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto p_last = lc.CPoint( edgeBuf[cnt-1]->index + 1 );
|
// auto p_last = lc.Point( edgeBuf[cnt-1]->index + 1 );
|
||||||
//printf("appendl %d %d\n", p_last.x, p_last.y);
|
//printf("appendl %d %d\n", p_last.x, p_last.y);
|
||||||
// outl.Append( p_last );
|
// outl.Append( p_last );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue