Only move page_layout repeated items once

The page layout items have peers for duplicated items that mark the
originating element.  We avoid the duplicate EDA_ITEM selections when
moving

Fixes https://gitlab.com/kicad/code/kicad/issues/6920
This commit is contained in:
Seth Hillbrand 2021-01-04 06:40:12 -08:00
parent d349821137
commit a67bf00b9e
2 changed files with 15 additions and 10 deletions

View File

@ -106,6 +106,14 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
if( selection.Empty() || m_moveInProgress )
return 0;
std::set<WS_DATA_ITEM*> unique_peers;
for( EDA_ITEM* item : selection )
{
WS_DRAW_ITEM_BASE* drawItem = static_cast<WS_DRAW_ITEM_BASE*>( item );
unique_peers.insert( drawItem->GetPeer() );
}
std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool );
Activate();
@ -136,7 +144,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Apply any initial offset in case we're coming from a previous command.
//
for( EDA_ITEM* item : selection )
for( WS_DATA_ITEM* item : unique_peers )
moveItem( item, m_moveOffset );
// Set up the starting position and move/drag offset
@ -148,7 +156,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
VECTOR2I delta = m_cursor - selection.GetReferencePoint();
// Drag items to the current cursor position
for( EDA_ITEM* item : selection )
for( WS_DATA_ITEM* item : unique_peers )
moveItem( item, delta );
selection.SetReferencePoint( m_cursor );
@ -182,7 +190,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
m_moveOffset += delta;
prevPos = m_cursor;
for( EDA_ITEM* item : selection )
for( WS_DATA_ITEM* item : unique_peers )
moveItem( item, delta );
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
@ -261,14 +269,11 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
}
void PL_EDIT_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta )
void PL_EDIT_TOOL::moveItem( WS_DATA_ITEM* aItem, VECTOR2I aDelta )
{
WS_DRAW_ITEM_BASE* drawItem = static_cast<WS_DRAW_ITEM_BASE*>( aItem );
WS_DATA_ITEM* dataItem = drawItem->GetPeer();
aItem->MoveToUi( aItem->GetStartPosUi() + (wxPoint) aDelta );
dataItem->MoveToUi( dataItem->GetStartPosUi() + (wxPoint) aDelta );
for( WS_DRAW_ITEM_BASE* item : dataItem->GetDrawItems() )
for( WS_DRAW_ITEM_BASE* item : aItem->GetDrawItems() )
{
getView()->Update( item );
item->SetFlags( IS_MOVED );

View File

@ -68,7 +68,7 @@ public:
int DeleteItemCursor( const TOOL_EVENT& aEvent );
private:
void moveItem( EDA_ITEM* aItem, VECTOR2I aDelta );
void moveItem( WS_DATA_ITEM* aItem, VECTOR2I aDelta );
///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items.