Better fix for missing end segment
Rather than skipping our endEdit() call in libedit, we need to
parameterize whether we want the shape open/closed. Closed will remove
the last segment if it lands on the first point. We don't want that
but we do want to remove the last point if it duplicates the second to
last (in the case of double-clicking)
Fixes https://gitlab.com/kicad/code/kicad/issues/10334
(cherry picked from commit 55020c2b89
)
This commit is contained in:
parent
21790fcab7
commit
d5faac7614
|
@ -1383,7 +1383,7 @@ void EDA_SHAPE::calcEdit( const VECTOR2I& aPosition )
|
|||
}
|
||||
|
||||
|
||||
void EDA_SHAPE::endEdit()
|
||||
void EDA_SHAPE::endEdit( bool aClosed )
|
||||
{
|
||||
switch( GetShape() )
|
||||
{
|
||||
|
@ -1402,7 +1402,7 @@ void EDA_SHAPE::endEdit()
|
|||
{
|
||||
if( poly.CPoint( poly.GetPointCount() - 2 ) == poly.CLastPoint() )
|
||||
{
|
||||
poly.SetClosed( true );
|
||||
poly.SetClosed( aClosed );
|
||||
poly.Remove( poly.GetPointCount() - 1 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,10 +78,7 @@ public:
|
|||
bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
|
||||
void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
|
||||
|
||||
/**
|
||||
* The base EndEdit() removes the last point in the polyline, so don't call that here
|
||||
*/
|
||||
void EndEdit() override { }
|
||||
void EndEdit() override { endEdit( false ); }
|
||||
void SetEditState( int aState ) { setEditState( aState ); }
|
||||
|
||||
void AddPoint( const VECTOR2I& aPosition );
|
||||
|
|
|
@ -297,7 +297,12 @@ protected:
|
|||
void beginEdit( const VECTOR2I& aStartPoint );
|
||||
bool continueEdit( const VECTOR2I& aPosition );
|
||||
void calcEdit( const VECTOR2I& aPosition );
|
||||
void endEdit();
|
||||
|
||||
/**
|
||||
* Finishes editing the shape.
|
||||
* @param aClosed Should polygon shapes be closed (yes for pcbnew/fpeditor, no for libedit)
|
||||
*/
|
||||
void endEdit( bool aClosed = true );
|
||||
void setEditState( int aState ) { m_editState = aState; }
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue