Honor the {0, 0} reference on the clipboard.
Fixes: lp:1840819 * https://bugs.launchpad.net/kicad/+bug/1840819
This commit is contained in:
parent
a25368cc6b
commit
aaa44b7348
|
@ -131,7 +131,7 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
||||||
partialModule.Add( clone );
|
partialModule.Add( clone );
|
||||||
|
|
||||||
// locate the reference point at (0, 0) in the copied items
|
// locate the reference point at (0, 0) in the copied items
|
||||||
clone->Move( wxPoint(-refPoint.x, -refPoint.y ) );
|
clone->Move( (wxPoint) -refPoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the new relative internal local coordinates of copied items
|
// Set the new relative internal local coordinates of copied items
|
||||||
|
@ -173,7 +173,7 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected )
|
||||||
std::unique_ptr<BOARD_ITEM> clone( static_cast<BOARD_ITEM*> ( item->Clone() ) );
|
std::unique_ptr<BOARD_ITEM> clone( static_cast<BOARD_ITEM*> ( item->Clone() ) );
|
||||||
|
|
||||||
// locate the reference point at (0, 0) in the copied items
|
// locate the reference point at (0, 0) in the copied items
|
||||||
clone->Move( wxPoint(-refPoint.x, -refPoint.y ) );
|
clone->Move( (wxPoint) -refPoint );
|
||||||
|
|
||||||
Format( clone.get(), 1 );
|
Format( clone.get(), 1 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,7 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(), item_layers,
|
m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(), item_layers,
|
||||||
sel_items );
|
sel_items );
|
||||||
controls->ForceCursorPosition(true, m_cursor );
|
controls->ForceCursorPosition( true, m_cursor );
|
||||||
VECTOR2I movement( m_cursor - prevPos );
|
VECTOR2I movement( m_cursor - prevPos );
|
||||||
selection.SetReferencePoint( m_cursor );
|
selection.SetReferencePoint( m_cursor );
|
||||||
|
|
||||||
|
|
|
@ -606,7 +606,7 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
placeBoardItems( static_cast<BOARD*>( clipItem ) );
|
placeBoardItems( static_cast<BOARD*>( clipItem ), true );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
items.push_back( clipItem );
|
items.push_back( clipItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
placeBoardItems( items, true );
|
placeBoardItems( items, true, true );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ static void moveNoFlagToVector( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard )
|
int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
|
||||||
{
|
{
|
||||||
// items are new if the current board is not the board source
|
// items are new if the current board is not the board source
|
||||||
bool isNew = board() != aBoard;
|
bool isNew = board() != aBoard;
|
||||||
|
@ -742,11 +742,12 @@ int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard )
|
||||||
moveNoFlagToVector( aBoard->Drawings(), items, isNew );
|
moveNoFlagToVector( aBoard->Drawings(), items, isNew );
|
||||||
moveNoFlagToVector( aBoard->Zones(), items, isNew );
|
moveNoFlagToVector( aBoard->Zones(), items, isNew );
|
||||||
|
|
||||||
return placeBoardItems( items, isNew );
|
return placeBoardItems( items, isNew, aAnchorAtOrigin );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew )
|
int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
||||||
|
bool aAnchorAtOrigin )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
|
@ -769,9 +770,16 @@ int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsN
|
||||||
|
|
||||||
if( selection.Size() > 0 )
|
if( selection.Size() > 0 )
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = (BOARD_ITEM*) selection.GetTopLeftItem();
|
if( aAnchorAtOrigin )
|
||||||
|
{
|
||||||
|
selection.SetReferencePoint( VECTOR2I( 0, 0 ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOARD_ITEM* item = (BOARD_ITEM*) selection.GetTopLeftItem();
|
||||||
|
selection.SetReferencePoint( item->GetPosition() );
|
||||||
|
}
|
||||||
|
|
||||||
selection.SetReferencePoint( item->GetPosition() );
|
|
||||||
getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
|
getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
|
||||||
|
|
||||||
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
||||||
|
@ -855,7 +863,7 @@ int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
|
||||||
brd->SetEnabledLayers( enabledLayers );
|
brd->SetEnabledLayers( enabledLayers );
|
||||||
brd->SetVisibleLayers( enabledLayers );
|
brd->SetVisibleLayers( enabledLayers );
|
||||||
|
|
||||||
return placeBoardItems( brd );
|
return placeBoardItems( brd, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,14 +97,17 @@ public:
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int placeBoardItems( BOARD* aBoard );
|
/**
|
||||||
|
* Add and select or just select for move/place command a list of board items.
|
||||||
/** add and selec or just select for move/place command a list of board items.
|
|
||||||
* @param aItems is the list of items
|
* @param aItems is the list of items
|
||||||
* @param aIsNew = true to add items to the current board, false to just select if
|
* @param aIsNew = true to add items to the current board, false to just select if
|
||||||
* items are already managed by the current board
|
* items are already managed by the current board
|
||||||
|
* @param aAnchorAtOrigin = true if the items are translated so that the anchor is {0, 0}
|
||||||
|
* (if false, the top-left item's origin will be used)
|
||||||
*/
|
*/
|
||||||
int placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew );
|
int placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew, bool aAnchorAtOrigin );
|
||||||
|
|
||||||
|
int placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin );
|
||||||
|
|
||||||
///> Pointer to the currently used edit frame.
|
///> Pointer to the currently used edit frame.
|
||||||
PCB_BASE_FRAME* m_frame;
|
PCB_BASE_FRAME* m_frame;
|
||||||
|
|
Loading…
Reference in New Issue