From 6bad4bb1a22fbae19174124e51d8ec7f005a236a Mon Sep 17 00:00:00 2001 From: John Beard Date: Sat, 7 Sep 2024 12:07:33 +0100 Subject: [PATCH] Put extension snaps behind an advanced config This can be backed out when the snapping bevaviour is considered good enough to be on by default. --- common/advanced_config.cpp | 7 +++++++ include/advanced_config.h | 8 ++++++++ pcbnew/tools/pcb_grid_helper.cpp | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index bbc6ebea4f..fb0ca1c84c 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -117,6 +117,7 @@ static const wxChar EnableAPILogging[] = wxT( "EnableAPILogging" ); static const wxChar MaxFileSystemWatchers[] = wxT( "MaxFileSystemWatchers" ); static const wxChar MinorSchematicGraphSize[] = wxT( "MinorSchematicGraphSize" ); static const wxChar ResolveTextRecursionDepth[] = wxT( "ResolveTextRecursionDepth" ); +static const wxChar EnableExtensionSnaps[] = wxT( "EnableExtensionSnaps" ); } // namespace KEYS @@ -280,6 +281,8 @@ ADVANCED_CFG::ADVANCED_CFG() m_ResolveTextRecursionDepth = 3; + m_EnableExtensionSnaps = false; + loadFromConfigFile(); } @@ -523,6 +526,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) &m_ResolveTextRecursionDepth, m_ResolveTextRecursionDepth, 0, 10 ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableExtensionSnaps, + &m_EnableExtensionSnaps, + m_EnableExtensionSnaps ) ); + // Special case for trace mask setting...we just grab them and set them immediately // Because we even use wxLogTrace inside of advanced config wxString traceMasks; diff --git a/include/advanced_config.h b/include/advanced_config.h index c6af868c14..974ab8ac26 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -644,6 +644,14 @@ public: */ int m_ResolveTextRecursionDepth; + /** + * Enable snap anchors based on item line extensions. + * + * Setting name: "EnableExtensionSnaps" + * Default value: false + */ + bool m_EnableExtensionSnaps; + ///@} private: diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index 9698983865..2ad8fbd94f 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -175,6 +176,12 @@ PCB_GRID_HELPER::~PCB_GRID_HELPER() void PCB_GRID_HELPER::AddConstructionItems( std::vector aItems, bool aExtensionOnly, bool aIsPersistent ) { + if( !ADVANCED_CFG::GetCfg().m_EnableExtensionSnaps ) + { + return; + } + + // For all the elements that get drawn construction geometry, // add something suitable to the construction helper. // This can be nothing.