Browse Source

Footprint viewers: fix regression: re-add automatic zoom option when loading a new footprint

Fixes #11402
https://gitlab.com/kicad/code/kicad/issues/11402
7.0
jean-pierre charras 4 years ago
parent
commit
0211d07060
  1. 3
      cvpcb/cvpcb_id.h
  2. 5
      cvpcb/cvpcb_settings.cpp
  3. 3
      cvpcb/cvpcb_settings.h
  4. 27
      cvpcb/display_footprints_frame.cpp
  5. 16
      pcbnew/footprint_viewer_frame.cpp
  6. 1
      pcbnew/pcbnew_id.h
  7. 6
      pcbnew/pcbnew_settings.cpp
  8. 3
      pcbnew/pcbnew_settings.h
  9. 8
      pcbnew/toolbars_footprint_viewer.cpp

3
cvpcb/cvpcb_id.h

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2022 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
@ -43,4 +43,5 @@ enum id_cvpcb_frm
ID_CVPCB_FOOTPRINT_LIST,
ID_CVPCB_LIBRARY_LIST,
ID_CVPCB_FILTER_TEXT_EDIT,
ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL
};

5
cvpcb/cvpcb_settings.cpp

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2022 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
@ -32,6 +32,7 @@ const int cvpcbSchemaVersion = 0;
CVPCB_SETTINGS::CVPCB_SETTINGS() :
APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ),
m_FootprintViewerZoom( 1.0 ),
m_FootprintViewerAutoZoomOnSelect( true ),
m_FilterFootprint( 0 ),
m_LibrariesWidth( 0 ),
m_FootprintsWidth( 0 )
@ -50,6 +51,8 @@ CVPCB_SETTINGS::CVPCB_SETTINGS() :
addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
&m_FootprintViewerAutoZoomOnSelect, true ) );
}

3
cvpcb/cvpcb_settings.h

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2022 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
@ -44,6 +44,7 @@ public:
MAGNETIC_SETTINGS m_FootprintViewerMagneticSettings;
double m_FootprintViewerZoom;
bool m_FootprintViewerAutoZoomOnSelect;
int m_FilterFootprint;
int m_LibrariesWidth;

27
cvpcb/display_footprints_frame.cpp

@ -3,7 +3,7 @@
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2007-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2007-2022 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
@ -56,6 +56,7 @@
#include <widgets/infobar.h>
#include <wx/choice.h>
#include <wx/debug.h>
#include <cvpcb_id.h>
BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
@ -145,8 +146,17 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() );
if( cfg )
{
GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL );
if( cfg->m_FootprintViewerAutoZoomOnSelect )
toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
else
toolOpt->SetState( 0 );
}
updateView();
Show( true );
@ -306,6 +316,14 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
UpdateZoomSelectBox();
m_mainToolBar->AddControl( m_zoomSelectBox );
// Option to run Zoom automatique on footprint selection changge
m_mainToolBar->AddTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL, wxEmptyString,
KiScaledBitmap( BITMAPS::zoom_auto_fit_in_page, this ),
_( "Automatic Zoom on footprint change" ),
wxITEM_CHECK );
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->UpdateControlWidth( ID_ON_GRID_SELECT );
m_mainToolBar->UpdateControlWidth( ID_ON_ZOOM_SELECT );
@ -349,6 +367,9 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_FootprintViewerDisplayOptions = GetDisplayOptions();
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL );
cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
}
@ -495,7 +516,9 @@ void DISPLAY_FOOTPRINTS_FRAME::updateView()
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
if( m_zoomSelectBox->GetSelection() == 0 )
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL );
if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
else
m_toolManager->RunAction( ACTIONS::centerContents, true );

16
pcbnew/footprint_viewer_frame.cpp

@ -275,11 +275,18 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
GetCanvas()->GetGAL()->SetAxesEnabled( true );
ActivateGalCanvas();
// Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
// Restore last zoom and auto zoom option. (If auto-zooming we'll adjust when we load the footprint.)
PCBNEW_SETTINGS* cfg = GetPcbNewSettings();
wxASSERT( cfg );
GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
if( cfg->m_FootprintViewerAutoZoomOnSelect )
toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
else
toolOpt->SetState( 0 );
updateView();
setupUnits( config() );
@ -802,6 +809,9 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
if( GetCanvas() && GetCanvas()->GetView() )
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
}
@ -1060,7 +1070,9 @@ void FOOTPRINT_VIEWER_FRAME::updateView()
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
if( m_zoomSelectBox->GetSelection() == 0 )
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
else
m_toolManager->RunAction( ACTIONS::centerContents, true );

1
pcbnew/pcbnew_id.h

@ -103,6 +103,7 @@ enum pcbnew_ids
ID_MODVIEW_FOOTPRINT_LIST,
ID_MODVIEW_PREVIOUS,
ID_MODVIEW_NEXT,
ID_FPVIEWER_AUTOZOOM_TOOL,
ID_FOOTPRINT_WIZARD_NEXT,
ID_FOOTPRINT_WIZARD_PREVIOUS,

6
pcbnew/pcbnew_settings.cpp

@ -75,7 +75,8 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_AutoRefillZones( false ),
m_AllowFreePads( false ),
m_PnsSettings( nullptr ),
m_FootprintViewerZoom( 1.0 )
m_FootprintViewerZoom( 1.0 ),
m_FootprintViewerAutoZoomOnSelect( true )
{
m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL;
m_MagneticItems.tracks = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL;
@ -521,6 +522,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
&m_FootprintViewerZoom, 1.0 ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
&m_FootprintViewerAutoZoomOnSelect, true ) );
addParamsForWindow( &m_FootprintWizard, "footprint_wizard" );
m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir",

3
pcbnew/pcbnew_settings.h

@ -347,7 +347,8 @@ public:
std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings;
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection
wxString m_lastFootprintLibDir;

8
pcbnew/toolbars_footprint_viewer.cpp

@ -101,6 +101,14 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
UpdateZoomSelectBox();
m_mainToolBar->AddControl( m_zoomSelectBox );
// Option to run Zoom automatique on footprint selection changge
m_mainToolBar->AddTool( ID_FPVIEWER_AUTOZOOM_TOOL, wxEmptyString,
KiScaledBitmap( BITMAPS::zoom_auto_fit_in_page, this ),
_( "Automatic Zoom on footprint change" ),
wxITEM_CHECK );
m_mainToolBar->AddScaledSeparator( this );
// after adding the buttons to the toolbar, must call Realize() to
// reflect the changes
m_mainToolBar->KiRealize();

Loading…
Cancel
Save