LIB_SHAPE slightly abuses SHAPE_POLY_SET by using it for line chains.

Fixes https://gitlab.com/kicad/code/kicad/issues/11956
This commit is contained in:
Jeff Young 2022-07-08 21:34:49 -06:00
parent 0cb5abd7f7
commit 0953395c87
4 changed files with 31 additions and 3 deletions

View File

@ -1083,7 +1083,7 @@ void EDA_SHAPE::SetPolyPoints( const std::vector<VECTOR2I>& aPoints )
}
std::vector<SHAPE*> EDA_SHAPE::MakeEffectiveShapes( bool aEdgeOnly ) const
std::vector<SHAPE*> EDA_SHAPE::makeEffectiveShapes( bool aEdgeOnly, bool aLineChainOnly ) const
{
std::vector<SHAPE*> effectiveShapes;
int width = GetEffectiveWidth();
@ -1148,6 +1148,9 @@ std::vector<SHAPE*> EDA_SHAPE::MakeEffectiveShapes( bool aEdgeOnly ) const
SHAPE_LINE_CHAIN l = GetPolyShape().COutline( 0 );
if( aLineChainOnly )
l.SetClosed( false );
l.Rotate( getParentOrientation() );
l.Move( getParentPosition() );

View File

@ -87,6 +87,17 @@ public:
VECTOR2I GetCenter() const { return getCenter(); }
/**
* Make a set of SHAPE objects representing the LIB_SHAPE. Caller owns the objects.
*
* @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill
* shapes.
*/
virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const
{
return makeEffectiveShapes( aEdgeOnly, true );
}
void Normalize();
void MirrorHorizontal( const VECTOR2I& aCenter ) override;

View File

@ -269,8 +269,10 @@ public:
* @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill
* shapes.
*/
// fixme: move to shape_compound
std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const;
virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const
{
return makeEffectiveShapes( aEdgeOnly );
}
void ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
@ -332,6 +334,17 @@ protected:
void endEdit( bool aClosed = true );
void setEditState( int aState ) { m_editState = aState; }
/**
* Make a set of SHAPE objects representing the EDA_SHAPE. Caller owns the objects.
*
* @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill
* shapes.
* @param aLineChainOnly indicates SHAPE_POLY_SET is being abused slightly to represent a
* lineChain rather than a closed polygon
*/
// fixme: move to shape_compound
std::vector<SHAPE*> makeEffectiveShapes( bool aEdgeOnly, bool aLineChainOnly = false ) const;
protected:
bool m_endsSwapped; // true if start/end were swapped e.g. SetArcAngleAndEnd
SHAPE_T m_shape; // Shape: line, Circle, Arc

View File

@ -291,6 +291,7 @@ public:
int SegmentCount() const
{
int c = m_points.size() - 1;
if( m_closed )
c++;