mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 23:13:43 +00:00
Move footprint viewer/cvpcb actions to tool framework
This commit is contained in:
parent
04ab369a49
commit
784246575b
common/settings
cvpcb
include/settings
pcbnew
@ -31,8 +31,6 @@ const int cvpcbSchemaVersion = 0;
|
||||
|
||||
CVPCB_SETTINGS::CVPCB_SETTINGS() :
|
||||
PCB_VIEWERS_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ),
|
||||
m_FootprintViewerZoom( 1.0 ),
|
||||
m_FootprintViewerAutoZoomOnSelect( true ),
|
||||
m_FilterFlags( 0 ),
|
||||
m_LibrariesWidth( 0 ),
|
||||
m_FootprintsWidth( 0 )
|
||||
|
@ -31,5 +31,4 @@ enum id_cvpcb_frm
|
||||
ID_CVPCB_COMPONENT_LIST = ID_END_LIST,
|
||||
ID_CVPCB_FOOTPRINT_LIST,
|
||||
ID_CVPCB_LIBRARY_LIST,
|
||||
ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL
|
||||
};
|
||||
|
@ -144,20 +144,9 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
|
||||
// Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
|
||||
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() );
|
||||
|
||||
/* TODO (ISM): Re-enable this once this is turned into an action
|
||||
if( cfg )
|
||||
{
|
||||
GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
|
||||
|
||||
wxAuiToolBarItem* toolOpt = m_tbTopMain->FindTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL );
|
||||
|
||||
if( cfg->m_FootprintViewerAutoZoomOnSelect )
|
||||
toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
|
||||
else
|
||||
toolOpt->SetState( 0 );
|
||||
}
|
||||
*/
|
||||
|
||||
updateView();
|
||||
|
||||
Show( true );
|
||||
@ -219,7 +208,7 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
|
||||
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::fpAutoZoom, CHECK( cond.FootprintViewerAutoZoom() ) );
|
||||
#undef CHECK
|
||||
}
|
||||
|
||||
@ -271,15 +260,9 @@ std::optional<TOOLBAR_CONFIGURATION> DISPLAY_FOOTPRINTS_FRAME::DefaultTopMainToo
|
||||
config.AppendSeparator()
|
||||
.AppendControl( m_tbZoomSelectName );
|
||||
|
||||
config.AppendSeparator();
|
||||
config.AppendSeparator()
|
||||
.AppendAction( PCB_ACTIONS::fpAutoZoom );
|
||||
|
||||
/* TODO (ISM): Turn this into an action
|
||||
// Option to run Zoom automatique on footprint selection change
|
||||
m_tbTopMain->AddTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL, wxEmptyString,
|
||||
KiScaledBitmap( BITMAPS::zoom_auto_fit_in_page, this ),
|
||||
_( "Automatic Zoom on footprint change" ),
|
||||
wxITEM_CHECK );
|
||||
*/
|
||||
// clang-format on
|
||||
return config;
|
||||
}
|
||||
@ -307,13 +290,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
PCB_BASE_FRAME::SaveSettings( cfg );
|
||||
|
||||
cfg->m_FootprintViewerDisplayOptions = GetDisplayOptions();
|
||||
|
||||
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
|
||||
|
||||
/* TODO (ISM): Move to action framework
|
||||
wxAuiToolBarItem* toolOpt = m_tbTopMain->FindTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL );
|
||||
cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -504,14 +481,14 @@ void DISPLAY_FOOTPRINTS_FRAME::updateView()
|
||||
|
||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||
|
||||
/* TODO (ISM): Move to action framework
|
||||
wxAuiToolBarItem* toolOpt = m_tbTopMain->FindTool( ID_CVPCB_FPVIEWER_AUTOZOOM_TOOL );
|
||||
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() );
|
||||
wxCHECK( cfg, /* void */ );
|
||||
|
||||
if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
|
||||
if( cfg->m_FootprintViewerAutoZoomOnSelect )
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
||||
else
|
||||
m_toolManager->RunAction( ACTIONS::centerContents );
|
||||
*/
|
||||
|
||||
UpdateMsgPanel();
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,6 @@ public:
|
||||
|
||||
MAGNETIC_SETTINGS m_FootprintViewerMagneticSettings;
|
||||
|
||||
double m_FootprintViewerZoom;
|
||||
bool m_FootprintViewerAutoZoomOnSelect;
|
||||
|
||||
int m_FilterFlags;
|
||||
wxString m_FilterString;
|
||||
int m_LibrariesWidth;
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <pcbnew_id.h>
|
||||
#include <footprint_editor_settings.h>
|
||||
#include <pgm_base.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <project_pcb.h>
|
||||
#include <project/project_file.h>
|
||||
#include <settings/settings_manager.h>
|
||||
@ -292,13 +293,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
|
||||
wxASSERT( cfg );
|
||||
GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
|
||||
|
||||
wxAuiToolBarItem* toolOpt = m_tbTopMain->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
|
||||
|
||||
if( cfg->m_FootprintViewerAutoZoomOnSelect )
|
||||
toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
|
||||
else
|
||||
toolOpt->SetState( 0 );
|
||||
|
||||
updateView();
|
||||
setupUnits( config() );
|
||||
|
||||
@ -376,6 +370,8 @@ void FOOTPRINT_VIEWER_FRAME::setupUIConditions()
|
||||
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
|
||||
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::fpAutoZoom, CHECK( cond.FootprintViewerAutoZoom() ) );
|
||||
|
||||
#undef ENABLE
|
||||
#undef CHECK
|
||||
}
|
||||
@ -843,8 +839,6 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
if( GetCanvas() && GetCanvas()->GetView() )
|
||||
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
|
||||
|
||||
wxAuiToolBarItem* toolOpt = m_tbTopMain->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
|
||||
cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
|
||||
cfg->m_FootprintViewerLibListWidth = m_libList->GetSize().x;
|
||||
cfg->m_FootprintViewerFPListWidth = m_fpList->GetSize().x;
|
||||
|
||||
@ -1095,13 +1089,15 @@ void FOOTPRINT_VIEWER_FRAME::updateView()
|
||||
|
||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||
|
||||
wxAuiToolBarItem* toolOpt = m_tbTopMain->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
|
||||
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( config() );
|
||||
wxCHECK( cfg, /* void */ );
|
||||
|
||||
if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
|
||||
if( cfg->m_FootprintViewerAutoZoomOnSelect )
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
||||
else
|
||||
m_toolManager->RunAction( ACTIONS::centerContents );
|
||||
|
||||
|
||||
UpdateMsgPanel();
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ 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,
|
||||
|
@ -81,8 +81,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
|
||||
m_AutoRefillZones( false ),
|
||||
m_AllowFreePads( false ),
|
||||
m_PnsSettings( nullptr ),
|
||||
m_FootprintViewerZoom( 1.0 ),
|
||||
m_FootprintViewerAutoZoomOnSelect( true ),
|
||||
m_FootprintViewerLibListWidth( 200 ),
|
||||
m_FootprintViewerFPListWidth( 300 )
|
||||
{
|
||||
|
@ -116,10 +116,15 @@ public:
|
||||
bool m_DisplayPadFill;
|
||||
};
|
||||
|
||||
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
|
||||
bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection
|
||||
|
||||
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay;
|
||||
|
||||
PCB_VIEWERS_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ):
|
||||
APP_SETTINGS_BASE( aFilename, aSchemaVersion )
|
||||
APP_SETTINGS_BASE( aFilename, aSchemaVersion ),
|
||||
m_FootprintViewerZoom( 1.0 ),
|
||||
m_FootprintViewerAutoZoomOnSelect( true )
|
||||
{
|
||||
m_ViewersDisplay.m_DisplayGraphicsFill = true;
|
||||
m_ViewersDisplay.m_DisplayTextFill = true;
|
||||
@ -457,8 +462,6 @@ public:
|
||||
|
||||
std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings;
|
||||
|
||||
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
|
||||
bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection
|
||||
int m_FootprintViewerLibListWidth;
|
||||
int m_FootprintViewerFPListWidth;
|
||||
|
||||
|
@ -69,15 +69,8 @@ std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_VIEWER_FRAME::DefaultTopMainToolb
|
||||
.AppendControl( m_tbGridSelectName );
|
||||
|
||||
config.AppendSeparator()
|
||||
.AppendControl( m_tbZoomSelectName );
|
||||
|
||||
// Option to run Zoom automatique on footprint selection change
|
||||
/* TODO (ISM): Convert to action
|
||||
m_tbTopMain->AddTool( ID_FPVIEWER_AUTOZOOM_TOOL, wxEmptyString,
|
||||
KiScaledBitmap( BITMAPS::zoom_auto_fit_in_page, this ),
|
||||
_( "Automatic Zoom on footprint change" ),
|
||||
wxITEM_CHECK );
|
||||
*/
|
||||
.AppendControl( m_tbZoomSelectName )
|
||||
.AppendAction( PCB_ACTIONS::fpAutoZoom);
|
||||
|
||||
// clang-format on
|
||||
return config;
|
||||
|
@ -1508,6 +1508,14 @@ TOOL_ACTION PCB_ACTIONS::zoneDisplayToggle( TOOL_ACTION_ARGS()
|
||||
.Icon( BITMAPS::show_zone ) );
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::fpAutoZoom( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Control.fpAutoZoom" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.FriendlyName( _( "Automatic zoom" ) )
|
||||
.Tooltip( _( "Automatic Zoom on footprint change" ) )
|
||||
.Icon( BITMAPS::zoom_auto_fit_in_page )
|
||||
.ToolbarState( TOOLBAR_STATE::TOGGLE ) );
|
||||
|
||||
// Layer control
|
||||
|
||||
// Translate aLayer to the action that switches to it
|
||||
|
@ -345,6 +345,7 @@ public:
|
||||
static TOOL_ACTION zoneDisplayTriangulated;
|
||||
static TOOL_ACTION zoneDisplayToggle;
|
||||
static TOOL_ACTION showPadNumbers;
|
||||
static TOOL_ACTION fpAutoZoom;
|
||||
|
||||
// Layer control
|
||||
static TOOL_ACTION layerTop;
|
||||
|
@ -136,6 +136,16 @@ SELECTION_CONDITION PCB_EDITOR_CONDITIONS::Get45degMode()
|
||||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::FootprintViewerAutoZoom()
|
||||
{
|
||||
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
||||
|
||||
wxASSERT( drwFrame );
|
||||
|
||||
return std::bind( &PCB_EDITOR_CONDITIONS::footprintViewerAutoZoom, _1, drwFrame );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDITOR_CONDITIONS::hasItemsFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
||||
{
|
||||
BOARD* board = aFrame->GetBoard();
|
||||
@ -186,6 +196,7 @@ bool PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc( const SELECTION& aSelection, PC
|
||||
return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDITOR_CONDITIONS::get45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
||||
{
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
@ -195,3 +206,9 @@ bool PCB_EDITOR_CONDITIONS::get45degModeFunc( const SELECTION& aSelection, PCB_B
|
||||
else
|
||||
return mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" )->m_Use45Limit;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDITOR_CONDITIONS::footprintViewerAutoZoom( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
||||
{
|
||||
return static_cast<PCB_VIEWERS_SETTINGS_BASE*>( aFrame->config() )->m_FootprintViewerAutoZoomOnSelect;
|
||||
}
|
||||
|
@ -109,6 +109,13 @@ public:
|
||||
*/
|
||||
SELECTION_CONDITION Get45degMode();
|
||||
|
||||
/**
|
||||
* Create a functor that tests if the footprint viewer should auto zoom on new footprints.
|
||||
*
|
||||
* @return Functor returning true if auto zoom is enabled.
|
||||
*/
|
||||
SELECTION_CONDITION FootprintViewerAutoZoom();
|
||||
|
||||
protected:
|
||||
///< Helper function used by HasItems()
|
||||
static bool hasItemsFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
|
||||
@ -137,6 +144,9 @@ protected:
|
||||
|
||||
///< Helper function used by Line45degMode()
|
||||
static bool get45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
|
||||
|
||||
/// Helper function used by FootprintViewerAutoZoom()
|
||||
static bool footprintViewerAutoZoom( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
|
||||
};
|
||||
|
||||
#endif /* PCB_EDITOR_CONDITIONS_H_ */
|
||||
|
@ -404,6 +404,18 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
int PCB_VIEWER_TOOLS::FootprintAutoZoom( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
PCB_VIEWERS_SETTINGS_BASE* cfg = dynamic_cast<PCB_VIEWERS_SETTINGS_BASE*>( frame()->config() );
|
||||
|
||||
// Toggle the setting
|
||||
if( cfg )
|
||||
cfg->m_FootprintViewerAutoZoomOnSelect = !cfg->m_FootprintViewerAutoZoomOnSelect;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PCB_VIEWER_TOOLS::setTransitions()
|
||||
{
|
||||
// clang-format off
|
||||
@ -415,6 +427,8 @@ void PCB_VIEWER_TOOLS::setTransitions()
|
||||
Go( &PCB_VIEWER_TOOLS::GraphicOutlines, PCB_ACTIONS::graphicsOutlines.MakeEvent() );
|
||||
Go( &PCB_VIEWER_TOOLS::TextOutlines, PCB_ACTIONS::textOutlines.MakeEvent() );
|
||||
|
||||
Go( &PCB_VIEWER_TOOLS::FootprintAutoZoom, PCB_ACTIONS::fpAutoZoom.MakeEvent() );
|
||||
|
||||
Go( &PCB_VIEWER_TOOLS::MeasureTool, ACTIONS::measureTool.MakeEvent() );
|
||||
// clang-format on
|
||||
}
|
||||
|
@ -61,6 +61,9 @@ public:
|
||||
int GraphicOutlines( const TOOL_EVENT& aEvent );
|
||||
int TextOutlines( const TOOL_EVENT& aEvent );
|
||||
|
||||
/// Automatically zoom to fit on footprints
|
||||
int FootprintAutoZoom( const TOOL_EVENT& aEvent );
|
||||
|
||||
/// Show the 3D viewer
|
||||
int Show3DViewer( const TOOL_EVENT& aEvent );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user