Hierarchy navigation: keep the last used zoom level in a sheet when go back to this sheet.

Fixes #7107
https://gitlab.com/kicad/code/kicad/issues/7107
This commit is contained in:
jean-pierre charras 2021-01-17 09:41:49 +01:00
parent 68efdb2fff
commit e10025db64
4 changed files with 23 additions and 7 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -250,6 +250,10 @@ void HIERARCHY_NAVIG_DLG::onSelectSheetPath( wxTreeEvent& event )
wxTreeItemId itemSel = m_Tree->GetSelection();
TreeItemData* itemData = static_cast<TreeItemData*>( m_Tree->GetItemData( itemSel ) );
// Store the current zoom level into the current screen before switching
m_SchFrameEditor->GetScreen()->m_LastZoomLevel =
m_SchFrameEditor->GetCanvas()->GetView()->GetScale();
m_SchFrameEditor->SetCurrentSheet( itemData->m_SheetPath );
m_SchFrameEditor->DisplayCurrentSheet();
@ -286,7 +290,6 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
{
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
m_toolManager->RunAction( EE_ACTIONS::clearSelection, true );
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
wxASSERT( screen );
@ -304,7 +307,8 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
}
else
{
// RedrawScreen() will set zoom to last used
// Set zoom to last used in this screen
GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
}

View File

@ -4,7 +4,7 @@
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -69,8 +69,8 @@ SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) :
m_paper( wxT( "A4" ) )
{
m_modification_sync = 0;
m_refCount = 0;
m_LastZoomLevel = 1.0;
// Suitable for schematic only. For symbol_editor and viewlib, must be set to true
m_Center = false;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -507,6 +507,12 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override;
#endif
/**
* last value for the zoom level, usefull in Eeschema when changing the current displayed
* sheet to reuse the same zoom level when back to the sheet using this screen
*/
double m_LastZoomLevel;
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 CERN
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -1692,6 +1692,9 @@ int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
// Store the current zoom level into the current screen before switching
m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale();
m_frame->GetCurrentSheet().push_back( sheet );
m_frame->DisplayCurrentSheet();
m_frame->UpdateHierarchyNavigator();
@ -1708,6 +1711,9 @@ int SCH_EDITOR_CONTROL::LeaveSheet( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
// Store the current zoom level into the current screen before switching
m_frame->GetScreen()->m_LastZoomLevel = m_frame->GetCanvas()->GetView()->GetScale();
m_frame->GetCurrentSheet().pop_back();
m_frame->DisplayCurrentSheet();
m_frame->UpdateHierarchyNavigator();