7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 09:01:42 +00:00

Add ADVANCED_CFG variable for recursion depth of variables

At 10, a strict recursion shows a noticable lag in schematics with
larger numbers of fields.  2 may be a sweet spot unless we find a
schematic where this does not work
This commit is contained in:
Seth Hillbrand 2024-07-02 11:37:21 -07:00
parent 7608be0bc0
commit b4760b9b2c
7 changed files with 32 additions and 5 deletions

View File

@ -113,6 +113,7 @@ static const wxChar EnableCacheFriendlyFracture[] = wxT( "EnableCacheFriendlyFra
static const wxChar EnableAPILogging[] = wxT( "EnableAPILogging" );
static const wxChar MaxFileSystemWatchers[] = wxT( "MaxFileSystemWatchers" );
static const wxChar MinorSchematicGraphSize[] = wxT( "MinorSchematicGraphSize" );
static const wxChar ResolveTextRecursionDepth[] = wxT( "ResolveTextRecursionDepth" );
} // namespace KEYS
@ -271,6 +272,8 @@ ADVANCED_CFG::ADVANCED_CFG()
m_MinorSchematicGraphSize = 10000;
m_ResolveTextRecursionDepth = 2;
loadFromConfigFile();
}
@ -501,6 +504,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
&m_MinorSchematicGraphSize, m_MinorSchematicGraphSize,
0, 2147483647 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::ResolveTextRecursionDepth,
&m_ResolveTextRecursionDepth,
m_ResolveTextRecursionDepth, 0, 10 ) );
// 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;

View File

@ -32,6 +32,8 @@
#include <wx/log.h>
#include <wx/menu.h>
#include <advanced_config.h>
#include <base_units.h>
#include <common.h> // for ExpandTextVars
#include <sch_edit_frame.h>
@ -264,9 +266,14 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT
if( text == wxS( "~" ) ) // Legacy placeholder for empty string
text = wxS( "" );
// The iteration here it to allow for nested variables in the
// text strings (e.g. ${${VAR}}). Although the symbols and sheets
// and labels recurse, text that is none of those types such as text
// boxes and labels do not. This only loops if there is still a
// variable to resolve.
for( int ii = 0; ii < 10 && text.Contains( wxT( "${" ) ); ++ii )
{
if( aDepth < 10 )
if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
{
if( m_parent && m_parent->Type() == LIB_SYMBOL_T )
text = ExpandTextVars( text, &libSymbolResolver );

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <advanced_config.h>
#include <base_units.h>
#include <pgm_base.h>
#include <sch_edit_frame.h>
@ -909,7 +910,7 @@ wxString SCH_LABEL_BASE::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowE
}
else if( HasTextVars() )
{
if( aDepth < 10 )
if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
text = ExpandTextVars( text, &textResolver );
}

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <advanced_config.h>
#include <base_units.h>
#include <pgm_base.h>
#include <sch_edit_frame.h>
@ -432,7 +433,7 @@ wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraTe
}
else if( HasTextVars() )
{
if( aDepth < 10 )
if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
text = ExpandTextVars( text, &textResolver );
}

View File

@ -21,6 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <advanced_config.h>
#include <base_units.h>
#include <pgm_base.h>
#include <sch_edit_frame.h>
@ -364,7 +365,7 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr
if( HasTextVars() )
{
if( aDepth < 10 )
if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
text = ExpandTextVars( text, &textResolver );
}

View File

@ -599,6 +599,15 @@ public:
*/
int m_MinorSchematicGraphSize;
/**
* The number of recursions to resolve text variables.
*
* Setting name: "ResolveTextRecursionDepth"
* Valid values: 0 to 10
* Default value: 2
*/
int m_ResolveTextRecursionDepth;
///@}
private:

View File

@ -25,6 +25,7 @@
#include <google/protobuf/any.pb.h>
#include <advanced_config.h>
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <bitmaps.h>
@ -209,7 +210,7 @@ wxString PCB_TEXT::GetShownText( bool aAllowExtraText, int aDepth ) const
if( HasTextVars() )
{
if( aDepth < 10 )
if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
text = ExpandTextVars( text, &resolver );
}