Change Position Relative To to use anchor, not centroid.
Fixes: lp:1793984 * https://bugs.launchpad.net/kicad/+bug/1793984
This commit is contained in:
parent
9eb574015c
commit
f3c6e1fb62
|
@ -192,7 +192,7 @@ void DIALOG_POSITION_RELATIVE::OnOkClick( wxCommandEvent& event )
|
|||
POSITION_RELATIVE_TOOL* posrelTool = m_toolMgr->GetTool<POSITION_RELATIVE_TOOL>();
|
||||
wxASSERT( posrelTool );
|
||||
|
||||
posrelTool->RelativeItemSelectionMove( m_anchor_position, m_translation, 0.0 );
|
||||
posrelTool->RelativeItemSelectionMove( m_anchor_position, m_translation );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
|
|
@ -102,19 +102,25 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( wxPoint anchor, wxPoint relativePosition,
|
||||
double rotation )
|
||||
int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( wxPoint aPosAnchor, wxPoint aTranslation )
|
||||
{
|
||||
VECTOR2I rp = m_selection.GetCenter();
|
||||
wxPoint rotPoint( rp.x, rp.y );
|
||||
wxPoint translation = anchor + relativePosition - rotPoint;
|
||||
wxPoint aSelAnchor( INT_MAX, INT_MAX );
|
||||
|
||||
// Find top-left item anchor in selection
|
||||
for( auto item : m_selection )
|
||||
{
|
||||
wxPoint itemAnchor = static_cast<BOARD_ITEM*>( item )->GetPosition();
|
||||
|
||||
if( EuclideanNorm( itemAnchor ) < EuclideanNorm( aSelAnchor ) )
|
||||
aSelAnchor = itemAnchor;
|
||||
}
|
||||
|
||||
wxPoint aggregateTranslation = aPosAnchor + aTranslation - aSelAnchor;
|
||||
|
||||
for( auto item : m_selection )
|
||||
{
|
||||
m_commit->Modify( item );
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Rotate( rotPoint, rotation );
|
||||
static_cast<BOARD_ITEM*>( item )->Move( translation );
|
||||
static_cast<BOARD_ITEM*>( item )->Move( aggregateTranslation );
|
||||
}
|
||||
|
||||
m_commit->Push( _( "Position Relative" ) );
|
||||
|
|
|
@ -62,17 +62,18 @@ public:
|
|||
/**
|
||||
* Function SelectPositionRelativeItem()
|
||||
*
|
||||
* Invokes the picker tool to select the item to which the previos selection will be placed relative to.
|
||||
* Invokes the picker tool to select the item to which the previous selection will be placed
|
||||
* relative to.
|
||||
*/
|
||||
int SelectPositionRelativeItem( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function RelativeItemSelectionMove()
|
||||
*
|
||||
* Positions the m_position_relative_selection selection relative to anchorpostion using the given translation and rotation.
|
||||
* Rotation is around the center of the selection.
|
||||
* Positions the m_position_relative_selection selection relative to anchorpostion using
|
||||
* the given translation.
|
||||
*/
|
||||
int RelativeItemSelectionMove( wxPoint anchor, wxPoint translation, double rotation );
|
||||
int RelativeItemSelectionMove( wxPoint anchor, wxPoint translation );
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
|
Loading…
Reference in New Issue