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:
parent
d349821137
commit
a67bf00b9e
|
@ -106,6 +106,14 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
if( selection.Empty() || m_moveInProgress )
|
if( selection.Empty() || m_moveInProgress )
|
||||||
return 0;
|
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();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
m_frame->PushTool( tool );
|
||||||
Activate();
|
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.
|
// 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 );
|
moveItem( item, m_moveOffset );
|
||||||
|
|
||||||
// Set up the starting position and move/drag offset
|
// 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();
|
VECTOR2I delta = m_cursor - selection.GetReferencePoint();
|
||||||
|
|
||||||
// Drag items to the current cursor position
|
// Drag items to the current cursor position
|
||||||
for( EDA_ITEM* item : selection )
|
for( WS_DATA_ITEM* item : unique_peers )
|
||||||
moveItem( item, delta );
|
moveItem( item, delta );
|
||||||
|
|
||||||
selection.SetReferencePoint( m_cursor );
|
selection.SetReferencePoint( m_cursor );
|
||||||
|
@ -182,7 +190,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
m_moveOffset += delta;
|
m_moveOffset += delta;
|
||||||
prevPos = m_cursor;
|
prevPos = m_cursor;
|
||||||
|
|
||||||
for( EDA_ITEM* item : selection )
|
for( WS_DATA_ITEM* item : unique_peers )
|
||||||
moveItem( item, delta );
|
moveItem( item, delta );
|
||||||
|
|
||||||
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
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 );
|
aItem->MoveToUi( aItem->GetStartPosUi() + (wxPoint) aDelta );
|
||||||
WS_DATA_ITEM* dataItem = drawItem->GetPeer();
|
|
||||||
|
|
||||||
dataItem->MoveToUi( dataItem->GetStartPosUi() + (wxPoint) aDelta );
|
for( WS_DRAW_ITEM_BASE* item : aItem->GetDrawItems() )
|
||||||
|
|
||||||
for( WS_DRAW_ITEM_BASE* item : dataItem->GetDrawItems() )
|
|
||||||
{
|
{
|
||||||
getView()->Update( item );
|
getView()->Update( item );
|
||||||
item->SetFlags( IS_MOVED );
|
item->SetFlags( IS_MOVED );
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
int DeleteItemCursor( const TOOL_EVENT& aEvent );
|
int DeleteItemCursor( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
private:
|
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
|
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
||||||
///> selected items.
|
///> selected items.
|
||||||
|
|
Loading…
Reference in New Issue