From b8d193485ddaaf27f9fcce8246f04aec5bea12a7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 18 Oct 2021 13:24:06 +0100 Subject: [PATCH] Respect selection reference point when set. Fixes https://gitlab.com/kicad/code/kicad/issues/8520 --- eeschema/tools/ee_selection_tool.cpp | 8 ++++++-- eeschema/tools/sch_edit_tool.cpp | 16 ++++++++++------ eeschema/tools/sch_move_tool.cpp | 4 ++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 9f17921425..2008692382 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1086,9 +1086,12 @@ EE_SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] ) } else // Trim an existing selection by aFilterList { + bool isMoving = false; + for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i ) { EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i ); + isMoving = static_cast( item )->IsMoving(); if( !item->IsType( aFilterList ) ) { @@ -1096,9 +1099,10 @@ EE_SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] ) m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent ); } } - } - updateReferencePoint(); + if( !isMoving ) + updateReferencePoint(); + } return m_selection; } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 8634d91d14..8dad9c3e24 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -459,7 +459,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) if( principalItemCount == 1 ) { - rotPoint = head->GetPosition(); + if( moving && selection.HasReferencePoint() ) + rotPoint = (wxPoint) selection.GetReferencePoint(); + else + rotPoint = head->GetPosition(); if( !moving ) saveCopyInUndoList( head, UNDO_REDO::CHANGED ); @@ -470,10 +473,8 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) { SCH_SYMBOL* symbol = static_cast( head ); - if( clockwise ) - symbol->SetOrientation( SYM_ROTATE_CLOCKWISE ); - else - symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE ); + for( int i = 0; clockwise ? i < 3 : i < 1; ++i ) + symbol->Rotate( rotPoint ); if( m_frame->eeconfig()->m_AutoplaceFields.enable ) symbol->AutoAutoplaceFields( m_frame->GetScreen() ); @@ -555,7 +556,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) } else { - rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() ); + if( moving && selection.HasReferencePoint() ) + rotPoint = (wxPoint) selection.GetReferencePoint(); + else + rotPoint = m_frame->GetNearestGridPosition( (wxPoint) selection.GetCenter() ); } for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 84b9a08d2c..80d6e2387f 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -320,6 +320,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) { // User wants to warp the mouse m_cursor = grid.BestDragOrigin( m_cursor, snapLayer, selection ); + selection.SetReferencePoint( m_cursor ); } else { @@ -358,6 +359,9 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) updateItem( item, false ); } + if( selection.HasReferencePoint() ) + selection.SetReferencePoint( selection.GetReferencePoint() + delta ); + m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved ); } //------------------------------------------------------------------------