diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 16a0a6035c..b635b1f201 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -123,8 +123,8 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wx { if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() ) { - m_frame->Schematic().SetCurrentSheet( *sheetWithSymbolFound ); - m_frame->DisplayCurrentSheet(); + m_frame->GetToolManager()->RunAction( SCH_ACTIONS::changeSheet, + sheetWithSymbolFound ); } if( crossProbingSettings.center_on_items ) diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 76301200b4..1ea600f9be 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -569,14 +569,8 @@ void DIALOG_ERC::OnERCItemSelected( wxDataViewEvent& aEvent ) if( !sheet.empty() && sheet != m_parent->GetCurrentSheet() ) { - m_parent->GetToolManager()->RunAction( ACTIONS::cancelInteractive ); - m_parent->GetToolManager()->RunAction( SCH_ACTIONS::clearSelection ); - - // Store the current zoom level into the current screen before switching - m_parent->GetScreen()->m_LastZoomLevel = m_parent->GetCanvas()->GetView()->GetScale(); - - m_parent->SetCurrentSheet( sheet ); - m_parent->DisplayCurrentSheet(); + m_parent->GetToolManager()->RunAction( SCH_ACTIONS::changeSheet, + &sheet ); m_parent->RedrawScreen( m_parent->GetScreen()->m_ScrollCenter, false ); } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 9cb7f62716..234b48bba2 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -148,17 +148,11 @@ int SCH_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent ) if( m_frame->GetCurrentSheet().Last() != &root ) { - m_toolMgr->RunAction( ACTIONS::cancelInteractive ); - m_toolMgr->RunAction( SCH_ACTIONS::clearSelection ); - - // Store the current zoom level into the current screen before switching - m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale(); - SCH_SHEET_PATH rootSheetPath; rootSheetPath.push_back( &root ); - m_frame->SetCurrentSheet( rootSheetPath ); - m_frame->DisplayCurrentSheet(); + m_frame->GetToolManager()->RunAction( SCH_ACTIONS::changeSheet, + &rootSheetPath ); wxSafeYield(); } diff --git a/eeschema/tools/sch_find_replace_tool.cpp b/eeschema/tools/sch_find_replace_tool.cpp index 657cab5bff..418afd7a49 100644 --- a/eeschema/tools/sch_find_replace_tool.cpp +++ b/eeschema/tools/sch_find_replace_tool.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "sch_actions.h" int SCH_FIND_REPLACE_TOOL::FindAndReplace( const TOOL_EVENT& aEvent ) @@ -290,11 +291,8 @@ int SCH_FIND_REPLACE_TOOL::FindNext( const TOOL_EVENT& aEvent ) { if( m_frame->Schematic().CurrentSheet() != sheet ) { - // Store the current zoom level into the current screen before switching - m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale(); - - m_frame->Schematic().SetCurrentSheet( sheet ); - m_frame->DisplayCurrentSheet(); + m_frame->GetToolManager()->RunAction( SCH_ACTIONS::changeSheet, + &sheet ); } break; diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index fe91a93a59..4e8efc1568 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -2540,8 +2540,8 @@ void SCH_SELECTION_TOOL::SyncSelection( const std::optional& tar if( targetSheetPath && targetSheetPath != editFrame->Schematic().CurrentSheet() ) { - editFrame->Schematic().SetCurrentSheet( *targetSheetPath ); - editFrame->DisplayCurrentSheet(); + SCH_SHEET_PATH path = targetSheetPath.value(); + m_frame->GetToolManager()->RunAction( SCH_ACTIONS::changeSheet, &path ); } ClearSelection( items.size() > 0 ? true /*quiet mode*/ : false ); diff --git a/eeschema/widgets/search_handlers.cpp b/eeschema/widgets/search_handlers.cpp index afd617b706..e2c59cff73 100644 --- a/eeschema/widgets/search_handlers.cpp +++ b/eeschema/widgets/search_handlers.cpp @@ -128,11 +128,10 @@ void SCH_SEARCH_HANDLER::SelectItems( std::vector& aItemRows ) if( allHitsOnSamePage && !selectedHits.empty() ) { - if( m_frame->GetCurrentSheet() != *selectedHits.front().sheetPath ) - { - m_frame->SetCurrentSheet( *selectedHits.front().sheetPath ); - m_frame->DisplayCurrentSheet(); - } + SCH_SHEET_PATH* sheet = selectedHits.front().sheetPath; + + if( m_frame->GetCurrentSheet() != *sheet ) + m_frame->GetToolManager()->RunAction( SCH_ACTIONS::changeSheet, sheet ); if( selectedItems.size() ) m_frame->GetToolManager()->RunAction( SCH_ACTIONS::addItemsToSel, &selectedItems );