From 3651d7c5e70b1530c52e22b01ab018a83fc4bd7a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 19 Sep 2021 17:31:10 +0100 Subject: [PATCH] Remove vestiges of old zoom-auto architecture. Fixes https://gitlab.com/kicad/code/kicad/issues/9055 --- cvpcb/cvpcb_settings.cpp | 4 ---- cvpcb/cvpcb_settings.h | 2 -- cvpcb/display_footprints_frame.cpp | 29 ++-------------------------- cvpcb/display_footprints_frame.h | 14 -------------- include/pcb_base_frame.h | 10 ---------- pcbnew/footprint_viewer_frame.cpp | 29 ++-------------------------- pcbnew/footprint_viewer_frame.h | 3 --- pcbnew/pcbnew_settings.cpp | 4 ---- pcbnew/pcbnew_settings.h | 4 +--- pcbnew/toolbars_footprint_viewer.cpp | 16 ++++++++------- pcbnew/tools/pcb_actions.cpp | 5 ----- pcbnew/tools/pcb_actions.h | 1 - pcbnew/tools/pcb_viewer_tools.cpp | 9 --------- pcbnew/tools/pcb_viewer_tools.h | 1 - 14 files changed, 14 insertions(+), 117 deletions(-) diff --git a/cvpcb/cvpcb_settings.cpp b/cvpcb/cvpcb_settings.cpp index 7d549f82db..58899ba163 100644 --- a/cvpcb/cvpcb_settings.cpp +++ b/cvpcb/cvpcb_settings.cpp @@ -31,7 +31,6 @@ const int cvpcbSchemaVersion = 0; CVPCB_SETTINGS::CVPCB_SETTINGS() : APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ), - m_FootprintViewerAutoZoom( false ), m_FootprintViewerZoom( 1.0 ), m_FilterFootprint( 0 ), m_LibrariesWidth( 0 ), @@ -62,9 +61,6 @@ CVPCB_SETTINGS::CVPCB_SETTINGS() : m_params.emplace_back( new PARAM( "footprint_viewer.graphic_items_fill", &m_FootprintViewerDisplayOptions.m_DisplayGraphicsFill, true ) ); - m_params.emplace_back( new PARAM( "footprint_viewer.auto_zoom", - &m_FootprintViewerAutoZoom, false ) ); - m_params.emplace_back( new PARAM( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) ); diff --git a/cvpcb/cvpcb_settings.h b/cvpcb/cvpcb_settings.h index 1a1fefa929..6898f70f3e 100644 --- a/cvpcb/cvpcb_settings.h +++ b/cvpcb/cvpcb_settings.h @@ -43,8 +43,6 @@ public: MAGNETIC_SETTINGS m_FootprintViewerMagneticSettings; - bool m_FootprintViewerAutoZoom; - double m_FootprintViewerZoom; int m_FilterFootprint; diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index bf942a47f1..5033df6548 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -212,13 +212,6 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) ); - auto autoZoomCond = - [this] ( const SELECTION& aSel ) - { - return GetAutoZoom(); - }; - - mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) ); mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) ); mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) ); @@ -301,9 +294,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar() m_mainToolBar->Add( ACTIONS::zoomInCenter ); m_mainToolBar->Add( ACTIONS::zoomOutCenter ); m_mainToolBar->Add( ACTIONS::zoomFitScreen ); - m_mainToolBar->Add( ACTIONS::zoomTool, - ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL ); - m_mainToolBar->Add( PCB_ACTIONS::zoomFootprintAutomatically, ACTION_TOOLBAR::TOGGLE ); + m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL ); m_mainToolBar->AddScaledSeparator( this ); m_mainToolBar->Add( ACTIONS::show3DViewer ); @@ -515,7 +506,7 @@ void DISPLAY_FOOTPRINTS_FRAME::updateView() m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - if( GetAutoZoom() ) + if( m_zoomSelectBox->GetSelection() == 0 ) m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); else m_toolManager->RunAction( ACTIONS::centerContents, true ); @@ -553,22 +544,6 @@ BOARD_ITEM_CONTAINER* DISPLAY_FOOTPRINTS_FRAME::GetModel() const } -void DISPLAY_FOOTPRINTS_FRAME::SetAutoZoom( bool aAutoZoom ) -{ - CVPCB_SETTINGS* cfg = dynamic_cast( config() ); - wxCHECK( cfg, /* void */ ); - cfg->m_FootprintViewerAutoZoom = aAutoZoom; -} - - -bool DISPLAY_FOOTPRINTS_FRAME::GetAutoZoom() -{ - CVPCB_SETTINGS* cfg = dynamic_cast( config() ); - wxCHECK( cfg, false ); - return cfg->m_FootprintViewerAutoZoom; -} - - SELECTION& DISPLAY_FOOTPRINTS_FRAME::GetCurrentSelection() { return m_toolManager->GetTool()->GetSelection(); diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index 50223312be..e615a59d43 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -108,20 +108,6 @@ public: // currently: do nothing in CvPcb. } - /** - * Set if the canvas should automatically zoom to the footprint on load. - * - * @param aAutoZoom is true if it should automatically zoom - */ - void SetAutoZoom( bool aAutoZoom ) override; - - /** - * Get if the canvas should automatically zoom to the footprint on load. - * - * @return true if it should automatically zoom - */ - bool GetAutoZoom() override; - SELECTION& GetCurrentSelection() override; DECLARE_EVENT_TABLE() diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 688a8c23a7..472cbe219d 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -378,16 +378,6 @@ public: virtual void ActivateGalCanvas() override; - /** - * Does nothing. Should be overridden in derived classes which support autozoom. - */ - virtual void SetAutoZoom( bool aAutoZoom ) {} - - /** - * Always returns false. Should be overridden in derived classes which support autozoom. - */ - virtual bool GetAutoZoom() { return false; } - protected: bool canCloseWindow( wxCloseEvent& aCloseEvent ) override; diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 858a8e661c..4539a5e6c7 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -58,6 +58,7 @@ #include #include #include +#include using namespace std::placeholders; @@ -336,14 +337,6 @@ void FOOTPRINT_VIEWER_FRAME::setupUIConditions() mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) ); mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) ); - auto autoZoomCond = - [this] ( const SELECTION& ) - { - return GetAutoZoom(); - }; - - mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) ); - #undef ENABLE #undef CHECK } @@ -813,24 +806,6 @@ COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings() const } -bool FOOTPRINT_VIEWER_FRAME::GetAutoZoom() -{ - // It is stored in pcbnew's settings - PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); - wxCHECK( cfg, false ); - return cfg->m_FootprintViewerAutoZoom; -} - - -void FOOTPRINT_VIEWER_FRAME::SetAutoZoom( bool aAutoZoom ) -{ - // It is stored in pcbnew's settings - PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); - wxASSERT( cfg ); - cfg->m_FootprintViewerAutoZoom = aAutoZoom; -} - - void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) { PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); @@ -1064,7 +1039,7 @@ void FOOTPRINT_VIEWER_FRAME::updateView() m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - if( GetAutoZoom() ) + if( m_zoomSelectBox->GetSelection() == 0 ) m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); else m_toolManager->RunAction( ACTIONS::centerContents, true ); diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 22e71c88d4..8c4a921602 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -54,9 +54,6 @@ public: virtual COLOR4D GetGridColor() override; - bool GetAutoZoom() override; - void SetAutoZoom( bool aAutoZoom ) override; - MAGNETIC_SETTINGS* GetMagneticItemsSettings() override { return &m_magneticItems; diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index 6ca3b73132..c5f232a383 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -75,7 +75,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_AutoRefillZones( true ), m_AllowFreePads( false ), m_PnsSettings( nullptr ), - m_FootprintViewerAutoZoom( false ), m_FootprintViewerZoom( 1.0 ) { m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL; @@ -502,9 +501,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() addParamsForWindow( &m_FootprintViewer, "footprint_viewer" ); - m_params.emplace_back( new PARAM( "footprint_viewer.auto_zoom", - &m_FootprintViewerAutoZoom, false ) ); - m_params.emplace_back( new PARAM( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index db2c798c24..578df6181d 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -296,9 +296,7 @@ public: std::unique_ptr m_PnsSettings; - bool m_FootprintViewerAutoZoom; ///< Should the footprint viewer auto zoom on select - - double m_FootprintViewerZoom; ///< The last zoom level in the footprint viewer + double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto) wxString m_lastFootprintLibDir; diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index 52ebf06fd9..5b8e93c5fd 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -68,9 +68,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() m_mainToolBar->Add( ACTIONS::zoomInCenter ); m_mainToolBar->Add( ACTIONS::zoomOutCenter ); m_mainToolBar->Add( ACTIONS::zoomFitScreen ); - m_mainToolBar->Add( ACTIONS::zoomTool, - ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL ); - m_mainToolBar->Add( PCB_ACTIONS::zoomFootprintAutomatically, ACTION_TOOLBAR::TOGGLE ); + m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL ); m_mainToolBar->AddScaledSeparator( this ); m_mainToolBar->Add( ACTIONS::show3DViewer ); @@ -82,8 +80,10 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() // Grid selection choice box. if( m_gridSelectBox == nullptr ) - m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT, - wxDefaultPosition, wxDefaultSize, 0, nullptr ); + { + m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT, wxDefaultPosition, + wxDefaultSize, 0, nullptr ); + } UpdateGridSelectBox(); m_mainToolBar->AddControl( m_gridSelectBox ); @@ -92,8 +92,10 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() // Zoom selection choice box. if( m_zoomSelectBox == nullptr ) - m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, - wxDefaultPosition, wxDefaultSize, 0, nullptr ); + { + m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition, + wxDefaultSize, 0, nullptr ); + } UpdateZoomSelectBox(); m_mainToolBar->AddControl( m_zoomSelectBox ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 7b07452729..00765f655b 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -824,11 +824,6 @@ TOOL_ACTION PCB_ACTIONS::showPadNumbers( "pcbnew.Control.showPadNumbers", _( "Show pad numbers" ), _( "Show pad numbers" ), BITMAPS::pad_number ); -TOOL_ACTION PCB_ACTIONS::zoomFootprintAutomatically( "pcbnew.Control.zoomFootprintAutomatically", - AS_GLOBAL, 0, "", - _( "Automatically zoom to fit" ), _( "Zoom to fit when changing footprint" ), - BITMAPS::zoom_auto_fit_in_page ); - TOOL_ACTION PCB_ACTIONS::zoneDisplayFilled( "pcbnew.Control.zoneDisplayEnable", AS_GLOBAL, 0, "", _( "Draw Zone Fills" ), _( "Show filled areas of zones" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 6d24a189fb..e6b6117349 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -246,7 +246,6 @@ public: static TOOL_ACTION zoneDisplayTriangulated; static TOOL_ACTION zoneDisplayToggle; static TOOL_ACTION showPadNumbers; - static TOOL_ACTION zoomFootprintAutomatically; // Layer control static TOOL_ACTION layerTop; diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 3862c50896..9af5ee420f 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -85,14 +85,6 @@ template void Flip( T& aValue ) } -int PCB_VIEWER_TOOLS::ZoomAutomatically( const TOOL_EVENT& aEvent ) -{ - frame()->SetAutoZoom( !frame()->GetAutoZoom() ); - - return 0; -} - - int PCB_VIEWER_TOOLS::ShowPadNumbers( const TOOL_EVENT& aEvent ) { auto opts = displayOptions(); @@ -347,7 +339,6 @@ void PCB_VIEWER_TOOLS::setTransitions() Go( &PCB_VIEWER_TOOLS::PadDisplayMode, PCB_ACTIONS::padDisplayMode.MakeEvent() ); Go( &PCB_VIEWER_TOOLS::GraphicOutlines, PCB_ACTIONS::graphicsOutlines.MakeEvent() ); Go( &PCB_VIEWER_TOOLS::TextOutlines, PCB_ACTIONS::textOutlines.MakeEvent() ); - Go( &PCB_VIEWER_TOOLS::ZoomAutomatically, PCB_ACTIONS::zoomFootprintAutomatically.MakeEvent() ); Go( &PCB_VIEWER_TOOLS::MeasureTool, ACTIONS::measureTool.MakeEvent() ); } diff --git a/pcbnew/tools/pcb_viewer_tools.h b/pcbnew/tools/pcb_viewer_tools.h index eb6ffdc873..cd3a5af2ff 100644 --- a/pcbnew/tools/pcb_viewer_tools.h +++ b/pcbnew/tools/pcb_viewer_tools.h @@ -58,7 +58,6 @@ public: int PadDisplayMode( const TOOL_EVENT& aEvent ); int GraphicOutlines( const TOOL_EVENT& aEvent ); int TextOutlines( const TOOL_EVENT& aEvent ); - int ZoomAutomatically( const TOOL_EVENT& aEvent ); /// Show the 3D viewer int Show3DViewer( const TOOL_EVENT& aEvent );