modedit: Store single copy of the footprint in undo
When changing elements in the module editor, each element shares the same parent. Undo commits store a copy of the parent as it existed before the change. For footprints with many elements, this creates large, slow undo commits as a copy of the full footprint is stored for each element being edited. This keeps a single copy of the footprint in the undo stack per edit. Fixes: lp:1780526 * https://bugs.launchpad.net/kicad/+bug/1780526
This commit is contained in:
parent
53236a3838
commit
3a09358264
|
@ -458,6 +458,13 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
if( lockFlags == SELECTION_LOCKED )
|
if( lockFlags == SELECTION_LOCKED )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// When editing modules, all items have the same parent
|
||||||
|
if( EditingModules() )
|
||||||
|
{
|
||||||
|
m_commit->Modify( selection.Front() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Save items, so changes can be undone
|
// Save items, so changes can be undone
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
{
|
{
|
||||||
|
@ -467,6 +474,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_commit->Modify( item );
|
m_commit->Modify( item );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_cursor = controls->GetCursorPosition();
|
m_cursor = controls->GetCursorPosition();
|
||||||
|
|
||||||
|
@ -694,9 +702,15 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
||||||
updateModificationPoint( selection );
|
updateModificationPoint( selection );
|
||||||
const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
|
const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
|
||||||
|
|
||||||
|
// When editing modules, all items have the same parent
|
||||||
|
if( EditingModules() )
|
||||||
|
{
|
||||||
|
m_commit->Modify( selection.Front() );
|
||||||
|
}
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
{
|
{
|
||||||
if( !item->IsNew() )
|
if( !item->IsNew() && !EditingModules() )
|
||||||
m_commit->Modify( item );
|
m_commit->Modify( item );
|
||||||
|
|
||||||
static_cast<BOARD_ITEM*>( item )->Rotate( selection.GetReferencePoint(), rotateAngle );
|
static_cast<BOARD_ITEM*>( item )->Rotate( selection.GetReferencePoint(), rotateAngle );
|
||||||
|
@ -766,6 +780,12 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||||
auto refPoint = selection.GetReferencePoint();
|
auto refPoint = selection.GetReferencePoint();
|
||||||
wxPoint mirrorPoint( refPoint.x, refPoint.y );
|
wxPoint mirrorPoint( refPoint.x, refPoint.y );
|
||||||
|
|
||||||
|
// When editing modules, all items have the same parent
|
||||||
|
if( EditingModules() )
|
||||||
|
{
|
||||||
|
m_commit->Modify( selection.Front() );
|
||||||
|
}
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
{
|
{
|
||||||
// only modify items we can mirror
|
// only modify items we can mirror
|
||||||
|
@ -775,7 +795,7 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||||
case PCB_MODULE_TEXT_T:
|
case PCB_MODULE_TEXT_T:
|
||||||
case PCB_PAD_T:
|
case PCB_PAD_T:
|
||||||
// Only create undo entry for items on the board
|
// Only create undo entry for items on the board
|
||||||
if( !item->IsNew() )
|
if( !item->IsNew() && !EditingModules() )
|
||||||
m_commit->Modify( item );
|
m_commit->Modify( item );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -839,9 +859,15 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
|
||||||
updateModificationPoint( selection );
|
updateModificationPoint( selection );
|
||||||
auto modPoint = selection.GetReferencePoint();
|
auto modPoint = selection.GetReferencePoint();
|
||||||
|
|
||||||
|
// When editing modules, all items have the same parent
|
||||||
|
if( EditingModules() )
|
||||||
|
{
|
||||||
|
m_commit->Modify( selection.Front() );
|
||||||
|
}
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
{
|
{
|
||||||
if( !item->IsNew() )
|
if( !item->IsNew() && !EditingModules() )
|
||||||
m_commit->Modify( item );
|
m_commit->Modify( item );
|
||||||
|
|
||||||
static_cast<BOARD_ITEM*>( item )->Flip( modPoint );
|
static_cast<BOARD_ITEM*>( item )->Flip( modPoint );
|
||||||
|
@ -928,11 +954,17 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
||||||
// Make sure the rotation is from the right reference point
|
// Make sure the rotation is from the right reference point
|
||||||
selCenter += translation;
|
selCenter += translation;
|
||||||
|
|
||||||
|
// When editing modules, all items have the same parent
|
||||||
|
if( EditingModules() )
|
||||||
|
{
|
||||||
|
m_commit->Modify( selection.Front() );
|
||||||
|
}
|
||||||
|
|
||||||
for( auto selItem : selection )
|
for( auto selItem : selection )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selItem );
|
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selItem );
|
||||||
|
|
||||||
if( !item->IsNew() )
|
if( !item->IsNew() && !EditingModules() )
|
||||||
m_commit->Modify( item );
|
m_commit->Modify( item );
|
||||||
|
|
||||||
item->Move( translation );
|
item->Move( translation );
|
||||||
|
|
Loading…
Reference in New Issue