diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 95d1488330..9f86dc8170 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -1083,7 +1083,7 @@ void EDA_SHAPE::SetPolyPoints( const std::vector& aPoints ) } -std::vector EDA_SHAPE::MakeEffectiveShapes( bool aEdgeOnly ) const +std::vector EDA_SHAPE::makeEffectiveShapes( bool aEdgeOnly, bool aLineChainOnly ) const { std::vector effectiveShapes; int width = GetEffectiveWidth(); @@ -1148,6 +1148,9 @@ std::vector EDA_SHAPE::MakeEffectiveShapes( bool aEdgeOnly ) const SHAPE_LINE_CHAIN l = GetPolyShape().COutline( 0 ); + if( aLineChainOnly ) + l.SetClosed( false ); + l.Rotate( getParentOrientation() ); l.Move( getParentPosition() ); diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h index 1a3ae683ea..31a548e7f5 100644 --- a/eeschema/lib_shape.h +++ b/eeschema/lib_shape.h @@ -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 MakeEffectiveShapes( bool aEdgeOnly = false ) const + { + return makeEffectiveShapes( aEdgeOnly, true ); + } + void Normalize(); void MirrorHorizontal( const VECTOR2I& aCenter ) override; diff --git a/include/eda_shape.h b/include/eda_shape.h index 8fc2601df5..54304cb6c5 100644 --- a/include/eda_shape.h +++ b/include/eda_shape.h @@ -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 MakeEffectiveShapes( bool aEdgeOnly = false ) const; + virtual std::vector MakeEffectiveShapes( bool aEdgeOnly = false ) const + { + return makeEffectiveShapes( aEdgeOnly ); + } void ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& 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 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 diff --git a/libs/kimath/include/geometry/shape_line_chain.h b/libs/kimath/include/geometry/shape_line_chain.h index 3049df2051..9d32e733f4 100644 --- a/libs/kimath/include/geometry/shape_line_chain.h +++ b/libs/kimath/include/geometry/shape_line_chain.h @@ -291,6 +291,7 @@ public: int SegmentCount() const { int c = m_points.size() - 1; + if( m_closed ) c++;