Undo for SCH_SHAPEs.

Fixes https://gitlab.com/kicad/code/kicad/issues/10373
This commit is contained in:
Jeff Young 2022-01-11 18:33:30 +00:00
parent a23f6e4e92
commit 062f5e3177
4 changed files with 16 additions and 0 deletions

View File

@ -30,6 +30,7 @@
DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHAPE* aShape ) :
DIALOG_SHAPE_PROPERTIES_BASE( aParent ),
m_frame( aParent ),
m_shape( aShape ),
m_lineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true )
{
@ -88,6 +89,9 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow()
if( !wxDialog::TransferDataFromWindow() )
return false;
if( !m_shape->IsNew() )
m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_shape, UNDO_REDO::CHANGED, false );
STROKE_PARAMS stroke = m_shape->GetStroke();
if( !m_lineWidth.IsIndeterminate() )

View File

@ -42,6 +42,7 @@ public:
bool TransferDataFromWindow() override;
private:
SCH_EDIT_FRAME* m_frame;
SCH_SHAPE* m_shape;
UNIT_BINDER m_lineWidth;
};

View File

@ -48,6 +48,15 @@ EDA_ITEM* SCH_SHAPE::Clone() const
}
void SCH_SHAPE::SwapData( SCH_ITEM* aItem )
{
SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
EDA_SHAPE::SwapShape( shape );
std::swap( m_layer, shape->m_layer );
}
void SCH_SHAPE::SetStroke( const STROKE_PARAMS& aStroke )
{
m_stroke = aStroke;

View File

@ -43,6 +43,8 @@ public:
return wxT( "SCH_SHAPE" );
}
void SwapData( SCH_ITEM* aItem ) override;
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
{
return hitTest( aPosition, aAccuracy );