KiCad PCB EDA Suite
ADVANCED_CFG Class Reference

Class containing "advanced" configuration options. More...

#include <advanced_config.h>

Static Public Member Functions

static const ADVANCED_CFGGetCfg ()
 Get the singleton instance's config, which is shared by all consumers of advanced config. More...
 

Public Attributes

double m_extraClearance
 Extra fill clearance for zone fills. More...
 
bool m_realTimeConnectivity
 Do real-time connectivity. More...
 
int m_coroutineStackSize
 Set the stack size for coroutines. More...
 
bool m_ShowRouterDebugGraphics
 Show PNS router debug graphics. More...
 
bool m_CompactSave
 Save files in compact display mode When is is not specified, points are written one per line. More...
 

Private Member Functions

 ADVANCED_CFG ()
 
void loadFromConfigFile ()
 Load the config from the normal config file. More...
 
void loadSettings (wxConfigBase &aCfg)
 

Detailed Description

Class containing "advanced" configuration options.

Options set here are for developer or advanced users only. If a general user needs to set one of these for normal KiCad use, either:

  • They are working around some bug that should be fixed, or
  • The parameter they are setting is of general interest and should be in the main application config, with UI provided.

Options in this class are, in general, preferable to #defines, as they allow more flexible configuration by developers, and don't hide code from the compiler on other configurations, which can result in broken builds.

Never use advanced configs in an untestable way. If a function depends on advanced config such that you cannot test it without changing the config, "lift" the config to a higher level and make pass it as parameter of the code under test. The tests can pass their own values as needed.

This also applies to code that does not depend on "common" - it cannot use this class, so you must pass configuration in as proper parameters.

Sometimes you can just use values directly, and sometimes helper functions might be provided to allow extra logic (for example when a advanced config applies only on certain platforms).

For more information on what config keys set these parameters in the config files, and why you might want to set them, see AC_KEYS

Definition at line 58 of file advanced_config.h.

Constructor & Destructor Documentation

◆ ADVANCED_CFG()

ADVANCED_CFG::ADVANCED_CFG ( )
private

Definition at line 165 of file advanced_config.cpp.

166 {
167  wxLogTrace( AdvancedConfigMask, "Init advanced config" );
168 
169  // Init defaults - this is done in case the config doesn't exist,
170  // then the values will remain as set here.
171  m_realTimeConnectivity = true;
174 
176 }
bool m_ShowRouterDebugGraphics
Show PNS router debug graphics.
void loadFromConfigFile()
Load the config from the normal config file.
int m_coroutineStackSize
Set the stack size for coroutines.
bool m_realTimeConnectivity
Do real-time connectivity.
static constexpr int default_stack
static const wxChar AdvancedConfigMask[]

References AdvancedConfigMask, AC_STACK::default_stack, loadFromConfigFile(), m_coroutineStackSize, m_realTimeConnectivity, and m_ShowRouterDebugGraphics.

Member Function Documentation

◆ GetCfg()

const ADVANCED_CFG & ADVANCED_CFG::GetCfg ( )
static

Get the singleton instance's config, which is shared by all consumers of advanced config.

This configuration is read-only - to set options, users should add the parameters to their config files at ~/.config/kicad/advanced, or the platform equivalent.

Definition at line 179 of file advanced_config.cpp.

180 {
181  static ADVANCED_CFG instance;
182  return instance;
183 }
Class containing "advanced" configuration options.

Referenced by SCH_CONNECTION::AppendInfoToMsgPanel(), SCH_EDITOR_CONTROL::AssignNetclass(), ZONE_FILLER::buildCopperItemClearances(), COROUTINE< int, const TOOL_EVENT & >::COROUTINE(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS(), PCB_IO::format(), SCH_EDITOR_CONTROL::HighlightNetCursor(), SCH_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::OnModify(), CONNECTION_GRAPH::Recalculate(), SCH_SEXPR_PLUGIN_CACHE::savePolyLine(), PNS_KICAD_IFACE::SetView(), and BUS_UNFOLD_MENU::update().

◆ loadFromConfigFile()

void ADVANCED_CFG::loadFromConfigFile ( )
private

Load the config from the normal config file.

Definition at line 186 of file advanced_config.cpp.

187 {
188  const auto k_advanced = getAdvancedCfgFilename();
189 
190  if( !k_advanced.FileExists() )
191  {
192  wxLogTrace( AdvancedConfigMask, "File does not exist %s", k_advanced.GetFullPath() );
193  return;
194  }
195 
196  wxLogTrace( AdvancedConfigMask, "Loading advanced config from: %s", k_advanced.GetFullPath() );
197 
198  wxFileConfig file_cfg( "", "", k_advanced.GetFullPath() );
199  loadSettings( file_cfg );
200 }
void loadSettings(wxConfigBase &aCfg)
static wxFileName getAdvancedCfgFilename()
Get the filename for the advanced config file.
static const wxChar AdvancedConfigMask[]

References AdvancedConfigMask, getAdvancedCfgFilename(), and loadSettings().

Referenced by ADVANCED_CFG().

◆ loadSettings()

void ADVANCED_CFG::loadSettings ( wxConfigBase &  aCfg)
private

Definition at line 203 of file advanced_config.cpp.

204 {
205  std::vector<PARAM_CFG*> configParams;
206 
207  configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity,
208  &m_realTimeConnectivity, false ) );
209 
210  configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::ExtraFillMargin,
211  &m_extraClearance, 0.002, 0.0, 1.0 ) );
212 
213  configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::CoroutineStackSize,
216 
217  configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ShowRouterDebugGraphics,
218  &m_ShowRouterDebugGraphics, false ) );
219 
220  configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::CompactFileSave,
221  &m_CompactSave, false ) );
222 
223  wxConfigLoadSetups( &aCfg, configParams );
224 
225  for( auto param : configParams )
226  delete param;
227 
228  dumpCfg( configParams );
229 }
double m_extraClearance
Extra fill clearance for zone fills.
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
void wxConfigLoadSetups(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG to load configuration values from aCfg.
Configuration parameter - Double Precision Class.
bool m_ShowRouterDebugGraphics
Show PNS router debug graphics.
static const wxChar RealtimeConnectivity[]
Testing mode for new connectivity algorithm.
static void dumpCfg(const std::vector< PARAM_CFG * > &aArray)
Dump the configs in the given array to trace.
Configuration parameter - Integer Class.
Configuration parameter - Boolean Class.
int m_coroutineStackSize
Set the stack size for coroutines.
bool m_realTimeConnectivity
Do real-time connectivity.
static const wxChar CoroutineStackSize[]
Configure the coroutine stack size in bytes.
static constexpr int default_stack
static constexpr int max_stack
static const wxChar ShowRouterDebugGraphics[]
Show PNS router debug graphics while routing.
static const wxChar CompactFileSave[]
When set to true, this will wrap polygon point sets at 4 points per line rather than a single point p...
static constexpr int min_stack
static const wxChar ExtraFillMargin[]
When filling zones, we add an extra amount of clearance to each zone to ensure that rounding errors d...

References AC_KEYS::CompactFileSave, AC_KEYS::CoroutineStackSize, AC_STACK::default_stack, dumpCfg(), AC_KEYS::ExtraFillMargin, m_CompactSave, m_coroutineStackSize, m_extraClearance, m_realTimeConnectivity, m_ShowRouterDebugGraphics, AC_STACK::max_stack, AC_STACK::min_stack, AC_KEYS::RealtimeConnectivity, AC_KEYS::ShowRouterDebugGraphics, and wxConfigLoadSetups().

Referenced by loadFromConfigFile().

Member Data Documentation

◆ m_CompactSave

bool ADVANCED_CFG::m_CompactSave

Save files in compact display mode When is is not specified, points are written one per line.

Definition at line 95 of file advanced_config.h.

Referenced by PCB_IO::format(), loadSettings(), and SCH_SEXPR_PLUGIN_CACHE::savePolyLine().

◆ m_coroutineStackSize

int ADVANCED_CFG::m_coroutineStackSize

Set the stack size for coroutines.

Definition at line 84 of file advanced_config.h.

Referenced by ADVANCED_CFG(), COROUTINE< int, const TOOL_EVENT & >::COROUTINE(), and loadSettings().

◆ m_extraClearance

double ADVANCED_CFG::m_extraClearance

Extra fill clearance for zone fills.

Definition at line 74 of file advanced_config.h.

Referenced by loadSettings().

◆ m_realTimeConnectivity

bool ADVANCED_CFG::m_realTimeConnectivity

Do real-time connectivity.

Definition at line 79 of file advanced_config.h.

Referenced by ADVANCED_CFG(), SCH_EDITOR_CONTROL::AssignNetclass(), and loadSettings().

◆ m_ShowRouterDebugGraphics

bool ADVANCED_CFG::m_ShowRouterDebugGraphics

Show PNS router debug graphics.

Definition at line 89 of file advanced_config.h.

Referenced by ADVANCED_CFG(), and loadSettings().


The documentation for this class was generated from the following files: