KiCad PCB EDA Suite
BOARD_DESIGN_SETTINGS Class Reference

Container for design settings for a BOARD object. More...

#include <board_design_settings.h>

Inheritance diagram for BOARD_DESIGN_SETTINGS:
NESTED_SETTINGS JSON_SETTINGS

Public Member Functions

 BOARD_DESIGN_SETTINGS (JSON_SETTINGS *aParent, const std::string &aPath)
 
virtual ~BOARD_DESIGN_SETTINGS ()
 
 BOARD_DESIGN_SETTINGS (const BOARD_DESIGN_SETTINGS &aOther)
 
BOARD_DESIGN_SETTINGSoperator= (const BOARD_DESIGN_SETTINGS &aOther)
 
bool LoadFromFile (const wxString &aDirectory="") override
 Loads the backing file from disk and then calls Load() More...
 
BOARD_STACKUPGetStackupDescriptor ()
 
const BOARD_STACKUPGetStackupDescriptor () const
 
SEVERITY GetSeverity (int aDRCErrorCode)
 
bool Ignore (int aDRCErrorCode)
 Return true if the DRC error code's severity is SEVERITY_IGNORE. More...
 
NETCLASSESGetNetClasses () const
 
void SetNetClasses (NETCLASSES *aNetClasses)
 
ZONE_SETTINGSGetDefaultZoneSettings ()
 
void SetDefaultZoneSettings (const ZONE_SETTINGS &aSettings)
 
NETCLASSGetDefault () const
 
const wxString & GetCurrentNetClassName () const
 
bool UseNetClassTrack () const
 Return true if netclass values should be used to obtain appropriate track width. More...
 
bool UseNetClassVia () const
 Return true if netclass values should be used to obtain appropriate via size. More...
 
bool UseNetClassDiffPair () const
 Return true if netclass values should be used to obtain appropriate diff pair dimensions. More...
 
int GetBiggestClearanceValue () const
 
int GetSmallestClearanceValue () const
 
int GetCurrentMicroViaSize ()
 
int GetCurrentMicroViaDrill ()
 
unsigned GetTrackWidthIndex () const
 
void SetTrackWidthIndex (unsigned aIndex)
 Set the current track width list index to aIndex. More...
 
int GetCurrentTrackWidth () const
 
void SetCustomTrackWidth (int aWidth)
 Sets custom width for track (i.e. More...
 
int GetCustomTrackWidth () const
 
unsigned GetViaSizeIndex () const
 
void SetViaSizeIndex (unsigned aIndex)
 Set the current via size list index to aIndex. More...
 
int GetCurrentViaSize () const
 
void SetCustomViaSize (int aSize)
 Set custom size for via diameter (i.e. More...
 
int GetCustomViaSize () const
 
int GetCurrentViaDrill () const
 
void SetCustomViaDrill (int aDrill)
 Sets custom size for via drill (i.e. More...
 
int GetCustomViaDrill () const
 
void UseCustomTrackViaSize (bool aEnabled)
 Enables/disables custom track/via size settings. More...
 
bool UseCustomTrackViaSize () const
 
unsigned GetDiffPairIndex () const
 
void SetDiffPairIndex (unsigned aIndex)
 
void SetCustomDiffPairWidth (int aWidth)
 Sets custom track width for differential pairs (i.e. More...
 
int GetCustomDiffPairWidth ()
 
void SetCustomDiffPairGap (int aGap)
 Sets custom gap for differential pairs (i.e. More...
 
int GetCustomDiffPairGap ()
 Function GetCustomDiffPairGap. More...
 
void SetCustomDiffPairViaGap (int aGap)
 Sets custom via gap for differential pairs (i.e. More...
 
int GetCustomDiffPairViaGap ()
 
void UseCustomDiffPairDimensions (bool aEnabled)
 Enables/disables custom differential pair dimensions. More...
 
bool UseCustomDiffPairDimensions () const
 
int GetCurrentDiffPairWidth () const
 
int GetCurrentDiffPairGap () const
 
int GetCurrentDiffPairViaGap () const
 
void SetMinHoleSeparation (int aDistance)
 
void SetCopperEdgeClearance (int aDistance)
 
void SetSilkClearance (int aDistance)
 Set the minimum distance between silk items to aValue. More...
 
LSET GetEnabledLayers () const
 Return a bit-mask of all the layers that are enabled. More...
 
void SetEnabledLayers (LSET aMask)
 Change the bit-mask of enabled layers to aMask. More...
 
bool IsLayerEnabled (PCB_LAYER_ID aLayerId) const
 Test whether a given layer aLayerId is enabled. More...
 
int GetCopperLayerCount () const
 
void SetCopperLayerCount (int aNewLayerCount)
 Set the copper layer count to aNewLayerCount. More...
 
int GetBoardThickness () const
 
void SetBoardThickness (int aThickness)
 
int GetDRCEpsilon () const
 
int GetHolePlatingThickness () const
 Pad & via drills are finish size. More...
 
int GetLineThickness (PCB_LAYER_ID aLayer) const
 Return the default graphic segment thickness from the layer class for the given layer. More...
 
wxSize GetTextSize (PCB_LAYER_ID aLayer) const
 Return the default text size from the layer class for the given layer. More...
 
int GetTextThickness (PCB_LAYER_ID aLayer) const
 Return the default text thickness from the layer class for the given layer. More...
 
bool GetTextItalic (PCB_LAYER_ID aLayer) const
 
bool GetTextUpright (PCB_LAYER_ID aLayer) const
 
int GetLayerClass (PCB_LAYER_ID aLayer) const
 
void SetAuxOrigin (const wxPoint &aOrigin)
 
const wxPoint & GetAuxOrigin ()
 
void SetGridOrigin (const wxPoint &aOrigin)
 
const wxPoint & GetGridOrigin ()
 
bool SaveToFile (const wxString &aDirectory="", bool aForce=false) override
 Calls Store() and then saves the JSON document contents into the parent JSON_SETTINGS. More...
 
void SetParent (JSON_SETTINGS *aParent, bool aLoadFromFile=true)
 
JSON_SETTINGSGetParent ()
 
wxString GetFilename () const
 
wxString GetFullFilename () const
 
void SetFilename (const wxString &aFilename)
 
void SetLocation (SETTINGS_LOC aLocation)
 
SETTINGS_LOC GetLocation () const
 
void SetLegacyFilename (const wxString &aFilename)
 
bool IsReadOnly () const
 
void SetReadOnly (bool aReadOnly)
 
nlohmann::jsonAt (const std::string &aPath)
 Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these functions take a string that is passed to PointerFromString internally. More...
 
bool Contains (const std::string &aPath) const
 
size_t Count (const std::string &aPath) const
 
JSON_SETTINGS_INTERNALSInternals ()
 
virtual void Load ()
 Updates the parameters of this object based on the current JSON document contents. More...
 
virtual bool Store ()
 Stores the current parameters into the JSON document represented by this object Note: this doesn't do any writing to disk; that's handled by SETTINGS_MANAGER. More...
 
void ResetToDefaults ()
 Resets all parameters to default values. More...
 
OPT< nlohmann::jsonGetJson (const std::string &aPath) const
 Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1.key2.key3" to refer to nested objects. More...
 
template<typename ValueType >
OPT< ValueType > Get (const std::string &aPath) const
 Fetches a value from within the JSON document. More...
 
template<>
OPT< wxString > Get (const std::string &aPath) const
 
template<typename ValueType >
void Set (const std::string &aPath, ValueType aVal)
 Stores a value into the JSON document Will throw an exception if ValueType isn't something that the library can handle. More...
 
template<>
void Set (const std::string &aPath, wxString aVal)
 
template<>
void Set (const std::string &aPath, wxString aVal)
 
bool Migrate ()
 Migrates the schema of this settings from the version in the file to the latest version. More...
 
virtual bool MigrateFromLegacy (wxConfigBase *aLegacyConfig)
 Migrates from wxConfig to JSON-based configuration. More...
 
void AddNestedSettings (NESTED_SETTINGS *aSettings)
 Transfers ownership of a given NESTED_SETTINGS to this object. More...
 
void ReleaseNestedSettings (NESTED_SETTINGS *aSettings)
 Saves and frees a nested settings object, if it exists within this one. More...
 
void SetManager (SETTINGS_MANAGER *aManager)
 

Static Public Member Functions

static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, wxString &aTarget)
 Sets the given string if the given key/path is present. More...
 
static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, bool &aTarget)
 Sets the given bool if the given key/path is present. More...
 
static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, int &aTarget)
 Sets the given int if the given key/path is present. More...
 
static bool SetIfPresent (const nlohmann::json &aObj, const std::string &aPath, unsigned int &aTarget)
 Sets the given unsigned int if the given key/path is present. More...
 

Public Attributes

std::vector< int > m_TrackWidthList
 
std::vector< VIA_DIMENSIONm_ViasDimensionsList
 
std::vector< DIFF_PAIR_DIMENSIONm_DiffPairDimensionsList
 
bool m_MicroViasAllowed
 true to allow micro vias More...
 
bool m_BlindBuriedViaAllowed
 true to allow blind/buried vias More...
 
VIATYPE m_CurrentViaType
 (VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA) More...
 
bool m_UseConnectedTrackWidth
 
bool m_TempOverrideTrackWidth
 
int m_MinClearance
 
int m_TrackMinWidth
 
int m_ViasMinAnnularWidth
 
int m_ViasMinSize
 
int m_MinThroughDrill
 
int m_MicroViasMinSize
 
int m_MicroViasMinDrill
 
int m_CopperEdgeClearance
 
int m_HoleClearance
 
int m_HoleToHoleMin
 
int m_SilkClearance
 
std::shared_ptr< DRC_ENGINEm_DRCEngine
 
std::map< int, SEVERITYm_DRCSeverities
 
std::set< wxString > m_DrcExclusions
 
int m_ZoneFillVersion
 Option to select different fill algorithms. More...
 
bool m_ZoneKeepExternalFillets
 
int m_MaxError
 
int m_SolderMaskMargin
 
int m_SolderMaskMinWidth
 
int m_SolderPasteMargin
 
double m_SolderPasteMarginRatio
 
std::vector< TEXT_ITEM_INFOm_DefaultFPTextItems
 
int m_LineThickness [LAYER_CLASS_COUNT]
 
wxSize m_TextSize [LAYER_CLASS_COUNT]
 
int m_TextThickness [LAYER_CLASS_COUNT]
 
bool m_TextItalic [LAYER_CLASS_COUNT]
 
bool m_TextUpright [LAYER_CLASS_COUNT]
 
DIM_UNITS_MODE m_DimensionUnitsMode
 
int m_DimensionPrecision
 Number of digits after the decimal. More...
 
DIM_UNITS_FORMAT m_DimensionUnitsFormat
 
bool m_DimensionSuppressZeroes
 
DIM_TEXT_POSITION m_DimensionTextPosition
 
bool m_DimensionKeepTextAligned
 
int m_DimensionArrowLength
 
int m_DimensionExtensionOffset
 
std::unique_ptr< PADm_Pad_Master
 
bool m_HasStackup
 
bool m_UseHeightForLengthCalcs
 Enable inclusion of stackup height in track length measurements and length tuning. More...
 

Protected Member Functions

void registerMigration (int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
 Registers a migration from one schema version to another. More...
 
template<typename ValueType >
bool fromLegacy (wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
 Translates a legacy wxConfig value to a given JSON pointer value. More...
 
bool fromLegacyString (wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
 Translates a legacy wxConfig string value to a given JSON pointer value. More...
 
bool fromLegacyColor (wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
 Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value. More...
 
virtual wxString getFileExt () const
 
virtual wxString getLegacyFileExt () const
 

Protected Attributes

JSON_SETTINGSm_parent
 A pointer to the parent object to load and store from. More...
 
std::string m_path
 The path (in pointer format) of where to store this document in the parent. More...
 
wxString m_filename
 The filename (not including path) of this settings file (inicode) More...
 
wxString m_legacy_filename
 The filename of the wxConfig legacy file (if different from m_filename) More...
 
SETTINGS_LOC m_location
 The location of this settings file (. More...
 
std::vector< PARAM_BASE * > m_params
 The list of parameters (owned by this object) More...
 
std::vector< NESTED_SETTINGS * > m_nested_settings
 Nested settings files that live inside this one, if any. More...
 
bool m_createIfMissing
 Whether or not the backing store file should be created it if doesn't exist. More...
 
bool m_createIfDefault
 Whether or not the backing store file should be created if all parameters are still at their default values. More...
 
bool m_writeFile
 Whether or not the backing store file should be written. More...
 
bool m_deleteLegacyAfterMigration
 Whether or not to delete legacy file after migration. More...
 
bool m_resetParamsIfMissing
 Whether or not to set parameters to their default value if missing from JSON on Load() More...
 
int m_schemaVersion
 Version of this settings schema. More...
 
SETTINGS_MANAGERm_manager
 A pointer to the settings manager managing this file (may be null) More...
 
std::map< int, std::pair< int, std::function< bool()> > > m_migrators
 A map of starting schema version to a pair of <ending version, migrator function> More...
 
std::unique_ptr< JSON_SETTINGS_INTERNALSm_internals
 

Private Member Functions

void initFromOther (const BOARD_DESIGN_SETTINGS &aOther)
 
bool migrateSchema0to1 ()
 

Private Attributes

wxPoint m_auxOrigin
 origin for plot exports More...
 
wxPoint m_gridOrigin
 origin for grid offsets More...
 
unsigned m_trackWidthIndex
 
unsigned m_viaSizeIndex
 
unsigned m_diffPairIndex
 
bool m_useCustomTrackVia
 
int m_customTrackWidth
 
VIA_DIMENSION m_customViaSize
 
bool m_useCustomDiffPair
 
DIFF_PAIR_DIMENSION m_customDiffPair
 
int m_copperLayerCount
 Number of copper layers for this design. More...
 
LSET m_enabledLayers
 Bit-mask for layer enabling. More...
 
int m_boardThickness
 Board thickness for 3D viewer. More...
 
wxString m_currentNetClassName
 Current net class name used to display netclass info. More...
 
BOARD_STACKUP m_stackup
 the description of layers stackup, for board fabrication only physical layers are in layers stackup. More...
 
NETCLASSES m_internalNetClasses
 Net classes that are loaded from the board file before these were stored in the project. More...
 
NETCLASSESm_netClasses
 This will point to m_internalNetClasses until it is repointed to the project after load. More...
 
ZONE_SETTINGS m_defaultZoneSettings
 The default settings that will be used for new zones. More...
 

Detailed Description

Container for design settings for a BOARD object.

Definition at line 220 of file board_design_settings.h.

Constructor & Destructor Documentation

◆ BOARD_DESIGN_SETTINGS() [1/2]

BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS ( JSON_SETTINGS aParent,
const std::string &  aPath 
)

Definition at line 42 of file board_design_settings.cpp.

42  :
43  NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aParent, aPath )
44 {
45  // We want to leave alone parameters that aren't found in the project JSON as they may be
46  // initialized by the board file parser before NESTED_SETTINGS::LoadFromFile is called.
47  m_resetParamsIfMissing = false;
48 
49  // Create a default NETCLASS list so that things don't break horribly if there's no project
50  // loaded. This also is used during file load for legacy boards that have netclasses stored
51  // in the file. After load, this information will be moved to the project and the pointer
52  // updated.
54 
55  m_HasStackup = false; // no stackup defined by default
56 
57  m_Pad_Master = std::make_unique<PAD>( nullptr );
58 
59  LSET all_set = LSET().set();
60  m_enabledLayers = all_set; // All layers enabled at first.
61  // SetCopperLayerCount() will adjust this.
62 
63  SetCopperLayerCount( 2 ); // Default design is a double sided board
65 
66  // if true, when creating a new track starting on an existing track, use this track width
69 
71  m_MicroViasAllowed = false;
72 
73  // First is always the reference designator
74  m_DefaultFPTextItems.emplace_back( wxT( "REF**" ), true, F_SilkS );
75  // Second is always the value
76  m_DefaultFPTextItems.emplace_back( wxT( "" ), true, F_Fab );
77  // Any following ones are freebies
78  m_DefaultFPTextItems.emplace_back( wxT( "${REFERENCE}" ), true, F_Fab );
79 
84  m_TextItalic[ LAYER_CLASS_SILK ] = false;
86 
93 
94  // Edges & Courtyards; text properties aren't used but better to have them holding
95  // reasonable values than not.
100  m_TextItalic[ LAYER_CLASS_EDGES ] = false;
101  m_TextUpright[ LAYER_CLASS_EDGES ] = false;
102 
109 
114  m_TextItalic[ LAYER_CLASS_FAB ] = false;
115  m_TextUpright[ LAYER_CLASS_FAB ] = false;
116 
121  m_TextItalic[ LAYER_CLASS_OTHERS ] = false;
123 
132 
133  m_useCustomTrackVia = false;
137 
138  m_useCustomDiffPair = false;
142 
154 
155  for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode )
156  m_DRCSeverities[ errorCode ] = RPT_SEVERITY_ERROR;
157 
159 
163 
166 
171 
174 
175  m_MaxError = ARC_HIGH_DEF;
176  m_ZoneFillVersion = 6; // Use new algo by default to fill zones
177  m_ZoneKeepExternalFillets = false; // Use new algo by default. Legacy boards might
178  // want to set it to true for old algo....
180 
181  // Global mask margins:
184 
185  // Solder paste margin absolute value
187  // Solder paste margin as a ratio of pad size
188  // The final margin is the sum of these 2 values
189  // Usually < 0 because the mask is smaller than pad
191 
192  // Layer thickness for 3D viewer
194 
195  m_viaSizeIndex = 0;
196  m_trackWidthIndex = 0;
197  m_diffPairIndex = 0;
198 
199  // Parameters stored in JSON in the project file
200 
201  // NOTE: Previously, BOARD_DESIGN_SETTINGS stored the basic board layer information (layer
202  // names and enable/disable state) in the project file even though this information is also
203  // stored in the board file. This was implemented for importing these settings from another
204  // project. Going forward, the import feature will just import from other board files (since
205  // we could have multi-board projects in the future anyway) so this functionality is dropped.
206 
207  m_params.emplace_back( new PARAM<bool>( "rules.allow_microvias", &m_MicroViasAllowed, false ) );
208 
209  m_params.emplace_back( new PARAM<bool>( "rules.allow_blind_buried_vias",
210  &m_BlindBuriedViaAllowed, false ) );
211 
212  m_params.emplace_back( new PARAM<bool>( "rules.use_height_for_length_calcs",
213  &m_UseHeightForLengthCalcs, true ) );
214 
215  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_clearance", &m_MinClearance,
217  MM_PER_IU ) );
218 
219  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_track_width", &m_TrackMinWidth,
221  MM_PER_IU ) );
222 
223  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_annular_width",
225  Millimeter2iu( 25.0 ), MM_PER_IU ) );
226 
227  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_diameter", &m_ViasMinSize,
229  MM_PER_IU ) );
230 
231  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_through_hole_diameter",
233  Millimeter2iu( 25.0 ), MM_PER_IU ) );
234 
235  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_diameter",
237  Millimeter2iu( 10.0 ), MM_PER_IU ) );
238 
239  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_drill", &m_MicroViasMinDrill,
241  Millimeter2iu( 10.0 ), MM_PER_IU ) );
242 
243  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_to_hole", &m_HoleToHoleMin,
245  MM_PER_IU ) );
246 
247  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_clearance", &m_HoleClearance,
249  MM_PER_IU ) );
250 
251  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_silk_clearance", &m_SilkClearance,
253  MM_PER_IU ) );
254 
255  // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method
256  // based on the edge cut thicknesses.
257  m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_copper_edge_clearance",
259  Millimeter2iu( -0.01 ), Millimeter2iu( 25.0 ), MM_PER_IU ) );
260 
261  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
262  [&]() -> nlohmann::json
263  {
264  nlohmann::json ret = {};
265 
266  for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
267  {
268  wxString name = item.GetSettingsKey();
269  int code = item.GetErrorCode();
270 
271  if( name.IsEmpty() || m_DRCSeverities.count( code ) == 0 )
272  continue;
273 
274  ret[std::string( name.ToUTF8() )] = SeverityToString( m_DRCSeverities[code] );
275  }
276 
277  return ret;
278  },
279  [&]( const nlohmann::json& aJson )
280  {
281  if( !aJson.is_object() )
282  return;
283 
284  for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
285  {
286  wxString name = item.GetSettingsKey();
287  std::string key( name.ToUTF8() );
288 
289  if( aJson.contains( key ) )
290  m_DRCSeverities[item.GetErrorCode()] = SeverityFromString( aJson[key] );
291  }
292  }, {} ) );
293 
294  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drc_exclusions",
295  [&]() -> nlohmann::json
296  {
297  nlohmann::json js = nlohmann::json::array();
298 
299  for( const auto& entry : m_DrcExclusions )
300  js.push_back( entry );
301 
302  return js;
303  },
304  [&]( const nlohmann::json& aObj )
305  {
306  m_DrcExclusions.clear();
307 
308  if( !aObj.is_array() )
309  return;
310 
311  for( const nlohmann::json& entry : aObj )
312  {
313  if( entry.empty() )
314  continue;
315 
316  m_DrcExclusions.insert( entry.get<wxString>() );
317  }
318  },
319  {} ) );
320 
321  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "track_widths",
322  [&]() -> nlohmann::json
323  {
324  nlohmann::json js = nlohmann::json::array();
325 
326  for( const int& width : m_TrackWidthList )
327  js.push_back( Iu2Millimeter( width ) );
328 
329  return js;
330  },
331  [&]( const nlohmann::json& aJson )
332  {
333  if( !aJson.is_array() )
334  return;
335 
336  m_TrackWidthList.clear();
337 
338  for( const nlohmann::json& entry : aJson )
339  {
340  if( entry.empty() )
341  continue;
342 
343  m_TrackWidthList.emplace_back( Millimeter2iu( entry.get<double>() ) );
344  }
345  },
346  {} ) );
347 
348  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "via_dimensions",
349  [&]() -> nlohmann::json
350  {
351  nlohmann::json js = nlohmann::json::array();
352 
353  for( const auto& via : m_ViasDimensionsList )
354  {
355  nlohmann::json entry = {};
356 
357  entry["diameter"] = Iu2Millimeter( via.m_Diameter );
358  entry["drill"] = Iu2Millimeter( via.m_Drill );
359 
360  js.push_back( entry );
361  }
362 
363  return js;
364  },
365  [&]( const nlohmann::json& aObj )
366  {
367  if( !aObj.is_array() )
368  return;
369 
370  m_ViasDimensionsList.clear();
371 
372  for( const nlohmann::json& entry : aObj )
373  {
374  if( entry.empty() || !entry.is_object() )
375  continue;
376 
377  if( !entry.contains( "diameter" ) || !entry.contains( "drill" ) )
378  continue;
379 
380  int diameter = Millimeter2iu( entry["diameter"].get<double>() );
381  int drill = Millimeter2iu( entry["drill"].get<double>() );
382 
383  m_ViasDimensionsList.emplace_back( VIA_DIMENSION( diameter, drill ) );
384  }
385  },
386  {} ) );
387 
388  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "diff_pair_dimensions",
389  [&]() -> nlohmann::json
390  {
391  nlohmann::json js = nlohmann::json::array();
392 
393  for( const auto& pair : m_DiffPairDimensionsList )
394  {
395  nlohmann::json entry = {};
396 
397  entry["width"] = Iu2Millimeter( pair.m_Width );
398  entry["gap"] = Iu2Millimeter( pair.m_Gap );
399  entry["via_gap"] = Iu2Millimeter( pair.m_ViaGap );
400 
401  js.push_back( entry );
402  }
403 
404  return js;
405  },
406  [&]( const nlohmann::json& aObj )
407  {
408  if( !aObj.is_array() )
409  return;
410 
411  m_DiffPairDimensionsList.clear();
412 
413  for( const nlohmann::json& entry : aObj )
414  {
415  if( entry.empty() || !entry.is_object() )
416  continue;
417 
418  if( !entry.contains( "width" ) || !entry.contains( "gap" )
419  || !entry.contains( "via_gap" ) )
420  continue;
421 
422  int width = Millimeter2iu( entry["width"].get<double>() );
423  int gap = Millimeter2iu( entry["gap"].get<double>() );
424  int via_gap = Millimeter2iu( entry["via_gap"].get<double>() );
425 
426  m_DiffPairDimensionsList.emplace_back(
427  DIFF_PAIR_DIMENSION( width, gap, via_gap ) );
428  }
429  },
430  {} ) );
431 
432  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_line_width",
434  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
435 
436  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_v",
438  TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, MM_PER_IU ) );
439 
440  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_h",
442  TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, MM_PER_IU ) );
443 
444  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_thickness",
446  TEXTS_MAX_WIDTH, MM_PER_IU ) );
447 
448  m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_italic",
449  &m_TextItalic[LAYER_CLASS_SILK], false ) );
450 
451  m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_upright",
452  &m_TextUpright[ LAYER_CLASS_SILK ], true ) );
453 
454  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_line_width",
456  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
457 
458  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_v",
460  TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, MM_PER_IU ) );
461 
462  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_h",
464  TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, MM_PER_IU ) );
465 
466  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_thickness",
468  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
469 
470  m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_italic",
471  &m_TextItalic[LAYER_CLASS_COPPER], false ) );
472 
473  m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_upright",
474  &m_TextUpright[LAYER_CLASS_COPPER], true ) );
475 
476  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.board_outline_line_width",
478  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
479 
480  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.courtyard_line_width",
482  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
483 
484  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_line_width",
486  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
487 
488  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_v",
490  TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, MM_PER_IU ) );
491 
492  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_h",
494  TEXTS_MIN_SIZE, TEXTS_MAX_SIZE, MM_PER_IU ) );
495 
496  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_thickness",
498  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
499 
500  m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_italic",
501  &m_TextItalic[LAYER_CLASS_FAB], false ) );
502 
503  m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_upright",
504  &m_TextUpright[LAYER_CLASS_FAB], true ) );
505 
506  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_line_width",
508  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
509 
510  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_v",
512  TEXTS_MAX_SIZE, MM_PER_IU ) );
513 
514  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_h",
516  TEXTS_MAX_SIZE, MM_PER_IU ) );
517 
518  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_thickness",
520  Millimeter2iu( 0.01 ), Millimeter2iu( 5.0 ), MM_PER_IU ) );
521 
522  m_params.emplace_back( new PARAM<bool>( "defaults.other_text_italic",
523  &m_TextItalic[LAYER_CLASS_OTHERS], false ) );
524 
525  m_params.emplace_back( new PARAM<bool>( "defaults.other_text_upright",
526  &m_TextUpright[LAYER_CLASS_OTHERS], true ) );
527 
528  m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_MODE>( "defaults.dimension_units",
531 
532  m_params.emplace_back( new PARAM<int>( "defaults.dimension_precision",
533  &m_DimensionPrecision, 4, 0, 5 ) );
534 
535  m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_FORMAT>( "defaults.dimensions.units_format",
538 
539  m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.suppress_zeroes",
540  &m_DimensionSuppressZeroes, false ) );
541 
542  // NOTE: excluding DIM_TEXT_POSITION::MANUAL from the valid range here
543  m_params.emplace_back( new PARAM_ENUM<DIM_TEXT_POSITION>( "defaults.dimensions.text_position",
546 
547  m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.keep_text_aligned",
548  &m_DimensionKeepTextAligned, true ) );
549 
550  m_params.emplace_back( new PARAM<int>( "defaults.dimensions.arrow_length",
552  Mils2iu( DEFAULT_DIMENSION_ARROW_LENGTH ) ) );
553 
554  m_params.emplace_back( new PARAM<int>( "defaults.dimensions.extension_offset",
557 
558  m_params.emplace_back( new PARAM<bool>( "defaults.zones.45_degree_only",
560 
561  m_params.emplace_back( new PARAM_SCALED<int>( "defaults.zones.min_clearance",
563  Millimeter2iu( 0.0 ), Millimeter2iu( 25.0 ), MM_PER_IU ) );
564 
565  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "defaults.pads",
566  [&]() -> nlohmann::json
567  {
568  nlohmann::json ret =
569  {
570  { "width", Iu2Millimeter( m_Pad_Master->GetSize().x ) },
571  { "height", Iu2Millimeter( m_Pad_Master->GetSize().y ) },
572  { "drill", Iu2Millimeter( m_Pad_Master->GetDrillSize().x ) }
573  };
574 
575  return ret;
576  },
577  [&]( const nlohmann::json& aJson )
578  {
579  if( aJson.contains( "width" ) && aJson.contains( "height" )
580  && aJson.contains( "drill" ) )
581  {
582  wxSize sz;
583  sz.SetWidth( Millimeter2iu( aJson["width"].get<double>() ) );
584  sz.SetHeight( Millimeter2iu( aJson["height"].get<double>() ) );
585 
586  m_Pad_Master->SetSize( sz );
587 
588  int drill = Millimeter2iu( aJson["drill"].get<double>() );
589 
590  m_Pad_Master->SetDrillSize( wxSize( drill, drill ) );
591  }
592  }, {} ) );
593 
594  m_params.emplace_back( new PARAM_SCALED<int>( "rules.max_error", &m_MaxError, ARC_HIGH_DEF,
595  Millimeter2iu( 0.0001 ), Millimeter2iu( 1.0 ), MM_PER_IU ) );
596 
597  // TODO: replace with zones_fill_version parameter and migrate zones_use_no_outline?
598  m_params.emplace_back( new PARAM_LAMBDA<bool>( "zones_use_no_outline",
599  [this]() -> bool
600  {
601  return m_ZoneFillVersion >= 6;
602  },
603  [this]( bool aVal )
604  {
605  m_ZoneFillVersion = aVal ? 6 : 5;
606  },
607  true ) );
608 
609  m_params.emplace_back( new PARAM<bool>( "zones_allow_external_fillets",
610  &m_ZoneKeepExternalFillets, false ) );
611 
612  registerMigration( 0, 1, std::bind( &BOARD_DESIGN_SETTINGS::migrateSchema0to1, this ) );
613 
614  registerMigration( 1, 2,
615  [&]() -> bool
616  {
617  // Schema 1 to 2: move mask and paste margin settings back to board.
618  // The parameters are removed, so we just have to manually load them here and
619  // they will get saved with the board
620  if( OPT<double> optval = Get<double>( "rules.solder_mask_clearance" ) )
621  m_SolderMaskMargin = static_cast<int>( *optval * IU_PER_MM );
622 
623  if( OPT<double> optval = Get<double>( "rules.solder_mask_min_width" ) )
624  m_SolderMaskMinWidth = static_cast<int>( *optval * IU_PER_MM );
625 
626  if( OPT<double> optval = Get<double>( "rules.solder_paste_clearance" ) )
627  m_SolderPasteMargin = static_cast<int>( *optval * IU_PER_MM );
628 
629  if( OPT<double> optval = Get<double>( "rules.solder_paste_margin_ratio" ) )
630  m_SolderPasteMarginRatio = *optval;
631 
632  try
633  {
634  At( "rules" ).erase( "solder_mask_clearance" );
635  At( "rules" ).erase( "solder_mask_min_width" );
636  At( "rules" ).erase( "solder_paste_clearance" );
637  At( "rules" ).erase( "solder_paste_margin_ratio" );
638  }
639  catch( ... )
640  {}
641 
642  return true;
643  } );
644 }
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_SILK_TEXT_WIDTH
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
#define DEFAULT_TRACKMINWIDTH
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
int m_ZoneFillVersion
Option to select different fill algorithms.
#define DEFAULT_COURTYARD_WIDTH
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
#define DEFAULT_SOLDERPASTE_RATIO
#define DEFAULT_VIASMINSIZE
#define TEXTS_MAX_WIDTH
Maximum text width in internal units (10 inches)
Definition: pcbnew.h:33
std::vector< int > m_TrackWidthList
static constexpr double IU_PER_MM
Mock up a conversion function.
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:74
NETCLASSES m_internalNetClasses
Net classes that are loaded from the board file before these were stored in the project.
#define DEFAULT_TEXT_WIDTH
#define LEGACY_COPPEREDGECLEARANCE
#define DEFAULT_BOARD_THICKNESS_MM
int m_DimensionPrecision
Number of digits after the decimal.
ZONE_SETTINGS m_defaultZoneSettings
The default settings that will be used for new zones.
#define DEFAULT_LINE_WIDTH
#define DEFAULT_DIMENSION_ARROW_LENGTH
#define DEFAULT_COPPER_LINE_WIDTH
#define DEFAULT_HOLETOHOLEMIN
Text appears outside the dimension line (default)
Stores an enum as an integer.
Definition: parameters.h:215
DIFF_PAIR_DIMENSION m_customDiffPair
#define DEFAULT_CUSTOMDPAIRGAP
VIATYPE m_CurrentViaType
(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
nlohmann::json json
Definition: gerbview.cpp:41
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
Container to handle a stock of specific differential pairs each with unique track width,...
std::unique_ptr< PAD > m_Pad_Master
#define DEFAULT_MINCLEARANCE
#define DEFAULT_MINTHROUGHDRILL
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
#define DEFAULT_CUSTOMDPAIRVIAGAP
#define DEFAULT_DIMENSION_EXTENSION_OFFSET
Text appears in line with the dimension line.
#define DEFAULT_SOLDERPASTE_CLEARANCE
wxSize m_TextSize[LAYER_CLASS_COUNT]
#define DEFAULT_CUSTOMDPAIRWIDTH
#define DEFAULT_SILK_TEXT_SIZE
int m_TextThickness[LAYER_CLASS_COUNT]
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
#define DEFAULT_SILK_LINE_WIDTH
bool m_TextItalic[LAYER_CLASS_COUNT]
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:333
#define ZONE_CLEARANCE_MIL
Definition: zones.h:33
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
const int bdsSchemaVersion
#define TEXTS_MAX_SIZE
Maximum text size in internal units (10 inches)
Definition: pcbnew.h:32
#define DEFAULT_MICROVIASMINSIZE
#define DEFAULT_MICROVIASMINDRILL
#define DEFAULT_SOLDERMASK_MIN_WIDTH
int m_LineThickness[LAYER_CLASS_COUNT]
#define DEFAULT_HOLECLEARANCE
#define TEXTS_MIN_SIZE
Minimum text size in internal units (1 mil)
Definition: pcbnew.h:31
#define DEFAULT_COPPEREDGECLEARANCE
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
bool m_resetParamsIfMissing
Whether or not to set parameters to their default value if missing from JSON on Load()
wxString SeverityToString(const SEVERITY &aSeverity)
Definition: ui_common.cpp:59
const char * name
Definition: DXF_plotter.cpp:56
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
#define DEFAULT_SILKCLEARANCE
std::map< int, SEVERITY > m_DRCSeverities
SEVERITY SeverityFromString(const wxString &aSeverity)
Definition: ui_common.cpp:48
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition: drc_item.h:105
NESTED_SETTINGS(const std::string &aName, int aSchemaVersion, JSON_SETTINGS *aParent, const std::string &aPath)
#define DEFAULT_COPPER_TEXT_WIDTH
std::vector< VIA_DIMENSION > m_ViasDimensionsList
boost::optional< T > OPT
Definition: optional.h:7
#define DEFAULT_CUSTOMTRACKWIDTH
DIM_UNITS_FORMAT m_DimensionUnitsFormat
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
NETCLASSES * m_netClasses
This will point to m_internalNetClasses until it is repointed to the project after load.
#define DEFAULT_SOLDERMASK_CLEARANCE
#define DEFAULT_COPPER_TEXT_SIZE
bool m_MicroViasAllowed
true to allow micro vias
std::set< wxString > m_DrcExclusions
static constexpr int Millimeter2iu(double mm)
LSET m_enabledLayers
Bit-mask for layer enabling.
int m_boardThickness
Board thickness for 3D viewer.
bool m_TextUpright[LAYER_CLASS_COUNT]

References JSON_SETTINGS::At(), AUTOMATIC, BARE_SUFFIX, DEFAULT_BOARD_THICKNESS_MM, DEFAULT_COPPER_LINE_WIDTH, DEFAULT_COPPER_TEXT_SIZE, DEFAULT_COPPER_TEXT_WIDTH, DEFAULT_COPPEREDGECLEARANCE, DEFAULT_COURTYARD_WIDTH, DEFAULT_CUSTOMDPAIRGAP, DEFAULT_CUSTOMDPAIRVIAGAP, DEFAULT_CUSTOMDPAIRWIDTH, DEFAULT_CUSTOMTRACKWIDTH, DEFAULT_DIMENSION_ARROW_LENGTH, DEFAULT_DIMENSION_EXTENSION_OFFSET, DEFAULT_EDGE_WIDTH, DEFAULT_HOLECLEARANCE, DEFAULT_HOLETOHOLEMIN, DEFAULT_LINE_WIDTH, DEFAULT_MICROVIASMINDRILL, DEFAULT_MICROVIASMINSIZE, DEFAULT_MINCLEARANCE, DEFAULT_MINTHROUGHDRILL, DEFAULT_SILK_LINE_WIDTH, DEFAULT_SILK_TEXT_SIZE, DEFAULT_SILK_TEXT_WIDTH, DEFAULT_SILKCLEARANCE, DEFAULT_SOLDERMASK_CLEARANCE, DEFAULT_SOLDERMASK_MIN_WIDTH, DEFAULT_SOLDERPASTE_CLEARANCE, DEFAULT_SOLDERPASTE_RATIO, DEFAULT_TEXT_SIZE, DEFAULT_TEXT_WIDTH, DEFAULT_TRACKMINWIDTH, DEFAULT_VIASMINSIZE, DRCE_DANGLING_TRACK, DRCE_DANGLING_VIA, DRCE_DRILLED_HOLES_COLOCATED, DRCE_DUPLICATE_FOOTPRINT, DRCE_EXTRA_FOOTPRINT, DRCE_FIRST, DRCE_LAST, DRCE_MISSING_COURTYARD, DRCE_MISSING_FOOTPRINT, DRCE_NET_CONFLICT, DRCE_NPTH_IN_COURTYARD, DRCE_OVERLAPPING_SILK, DRCE_PTH_IN_COURTYARD, DRCE_SILK_MASK_CLEARANCE, F_Fab, F_SilkS, DRC_ITEM::GetItemsWithSeverities(), INCHES, INLINE, IU_PER_MM, LAYER_CLASS_COPPER, LAYER_CLASS_COURTYARD, LAYER_CLASS_EDGES, LAYER_CLASS_FAB, LAYER_CLASS_OTHERS, LAYER_CLASS_SILK, LEGACY_COPPEREDGECLEARANCE, m_BlindBuriedViaAllowed, m_boardThickness, m_CopperEdgeClearance, m_CurrentViaType, m_customDiffPair, m_customTrackWidth, m_customViaSize, m_DefaultFPTextItems, m_defaultZoneSettings, VIA_DIMENSION::m_Diameter, m_DiffPairDimensionsList, m_diffPairIndex, m_DimensionArrowLength, m_DimensionExtensionOffset, m_DimensionKeepTextAligned, m_DimensionPrecision, m_DimensionSuppressZeroes, m_DimensionTextPosition, m_DimensionUnitsFormat, m_DimensionUnitsMode, m_DrcExclusions, m_DRCSeverities, VIA_DIMENSION::m_Drill, m_enabledLayers, DIFF_PAIR_DIMENSION::m_Gap, m_HasStackup, m_HoleClearance, m_HoleToHoleMin, m_internalNetClasses, m_LineThickness, m_MaxError, m_MicroViasAllowed, m_MicroViasMinDrill, m_MicroViasMinSize, m_MinClearance, m_MinThroughDrill, m_netClasses, m_Pad_Master, JSON_SETTINGS::m_params, JSON_SETTINGS::m_resetParamsIfMissing, m_SilkClearance, m_SolderMaskMargin, m_SolderMaskMinWidth, m_SolderPasteMargin, m_SolderPasteMarginRatio, m_TempOverrideTrackWidth, m_TextItalic, m_TextSize, m_TextThickness, m_TextUpright, m_TrackMinWidth, m_trackWidthIndex, m_TrackWidthList, m_UseConnectedTrackWidth, m_useCustomDiffPair, m_useCustomTrackVia, m_UseHeightForLengthCalcs, DIFF_PAIR_DIMENSION::m_ViaGap, m_ViasDimensionsList, m_viaSizeIndex, m_ViasMinAnnularWidth, m_ViasMinSize, DIFF_PAIR_DIMENSION::m_Width, ZONE_SETTINGS::m_Zone_45_Only, ZONE_SETTINGS::m_ZoneClearance, m_ZoneFillVersion, m_ZoneKeepExternalFillets, migrateSchema0to1(), Millimeter2iu(), name, NO_SUFFIX, OUTSIDE, PAREN_SUFFIX, JSON_SETTINGS::registerMigration(), RPT_SEVERITY_ERROR, RPT_SEVERITY_IGNORE, RPT_SEVERITY_WARNING, SetCopperLayerCount(), SeverityFromString(), SeverityToString(), TEXTS_MAX_SIZE, TEXTS_MAX_WIDTH, TEXTS_MIN_SIZE, THROUGH, via, and ZONE_CLEARANCE_MIL.

◆ ~BOARD_DESIGN_SETTINGS()

BOARD_DESIGN_SETTINGS::~BOARD_DESIGN_SETTINGS ( )
virtual

Definition at line 647 of file board_design_settings.cpp.

648 {
649  if( m_parent )
650  {
652  m_parent = nullptr;
653  }
654 }
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
void ReleaseNestedSettings(NESTED_SETTINGS *aSettings)
Saves and frees a nested settings object, if it exists within this one.

References NESTED_SETTINGS::m_parent, and JSON_SETTINGS::ReleaseNestedSettings().

◆ BOARD_DESIGN_SETTINGS() [2/2]

BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS ( const BOARD_DESIGN_SETTINGS aOther)

Definition at line 657 of file board_design_settings.cpp.

657  :
658  NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aOther.m_parent,
659  aOther.m_path ),
660  m_Pad_Master( nullptr )
661 {
662  initFromOther( aOther );
663 }
std::unique_ptr< PAD > m_Pad_Master
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
const int bdsSchemaVersion
NESTED_SETTINGS(const std::string &aName, int aSchemaVersion, JSON_SETTINGS *aParent, const std::string &aPath)
void initFromOther(const BOARD_DESIGN_SETTINGS &aOther)
std::string m_path
The path (in pointer format) of where to store this document in the parent.

References initFromOther().

Member Function Documentation

◆ AddNestedSettings()

void JSON_SETTINGS::AddNestedSettings ( NESTED_SETTINGS aSettings)
inherited

Transfers ownership of a given NESTED_SETTINGS to this object.

Can be used to construct a NESTED_SETTINGS without the parent object needing to know about the implementation of the nested object;

Parameters
aSettingsis the settings object to take ownership of
aTargetis a pointer to update to the passed in settings

Definition at line 743 of file json_settings.cpp.

744 {
745  wxLogTrace( traceSettings, "AddNestedSettings %s", aSettings->GetFilename() );
746  m_nested_settings.push_back( aSettings );
747 }
wxString GetFilename() const
Definition: json_settings.h:72
std::vector< NESTED_SETTINGS * > m_nested_settings
Nested settings files that live inside this one, if any.
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.

References JSON_SETTINGS::GetFilename(), JSON_SETTINGS::m_nested_settings, and traceSettings.

Referenced by NESTED_SETTINGS::SetParent().

◆ At()

nlohmann::json & JSON_SETTINGS::At ( const std::string &  aPath)
inherited

Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these functions take a string that is passed to PointerFromString internally.

Definition at line 111 of file json_settings.cpp.

112 {
113  return m_internals->At( aPath );
114 }
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals

References JSON_SETTINGS::m_internals.

Referenced by BOARD_DESIGN_SETTINGS(), EESCHEMA_SETTINGS::migrateBomSettings(), GERBVIEW_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), migrateSchema0to1(), PCBNEW_SETTINGS::PCBNEW_SETTINGS(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ Contains()

bool JSON_SETTINGS::Contains ( const std::string &  aPath) const
inherited

Definition at line 117 of file json_settings.cpp.

118 {
119  return m_internals->contains( JSON_SETTINGS_INTERNALS::PointerFromString( aPath ) );
120 }
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals

References JSON_SETTINGS::m_internals, and JSON_SETTINGS_INTERNALS::PointerFromString().

Referenced by LoadFromFile(), EESCHEMA_SETTINGS::migrateBomSettings(), COLOR_SETTINGS::migrateSchema0to1(), migrateSchema0to1(), PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS(), and SETTINGS_MANAGER::SaveColorSettings().

◆ Count()

size_t JSON_SETTINGS::Count ( const std::string &  aPath) const
inherited

Definition at line 123 of file json_settings.cpp.

124 {
126 }
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals

References JSON_SETTINGS::m_internals, and JSON_SETTINGS_INTERNALS::PointerFromString().

Referenced by FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1().

◆ fromLegacy()

template<typename ValueType >
template bool JSON_SETTINGS::fromLegacy< bool > ( wxConfigBase *  aConfig,
const std::string &  aKey,
const std::string &  aDest 
)
protectedinherited

Translates a legacy wxConfig value to a given JSON pointer value.

Template Parameters
ValueTypeis the basic type of the value
Parameters
aConfigis the legacy config to read from
aKeyis the key (within the current path) to read
aDestis a string that will form a JSON pointer (key1.key2.key3) to write to

Definition at line 655 of file json_settings.cpp.

657 {
658  ValueType val;
659 
660  if( aConfig->Read( aKey, &val ) )
661  {
662  try
663  {
664  ( *m_internals )[aDest] = val;
665  }
666  catch( ... )
667  {
668  wxASSERT_MSG( false, wxT( "Could not write value in fromLegacy!" ) );
669  return false;
670  }
671 
672  return true;
673  }
674 
675  return false;
676 }

◆ fromLegacyColor()

bool JSON_SETTINGS::fromLegacyColor ( wxConfigBase *  aConfig,
const std::string &  aKey,
const std::string &  aDest 
)
protectedinherited

Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value.

Parameters
aConfigis the legacy config to read from
aKeyis the key (within the current path) to read
aDestis a string that will form a JSON pointer (key1.key2.key3) to write to

Definition at line 715 of file json_settings.cpp.

717 {
718  wxString str;
719 
720  if( aConfig->Read( aKey, &str ) )
721  {
723  color.SetFromWxString( str );
724 
725  try
726  {
727  nlohmann::json js = nlohmann::json::array( { color.r, color.g, color.b, color.a } );
728  ( *m_internals )[aDest] = js;
729  }
730  catch( ... )
731  {
732  wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyColor!" ) );
733  return false;
734  }
735 
736  return true;
737  }
738 
739  return false;
740 }
int color
Definition: DXF_plotter.cpp:57
nlohmann::json json
Definition: gerbview.cpp:41
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color.

Referenced by APP_SETTINGS_BASE::migrateWindowConfig().

◆ fromLegacyString()

bool JSON_SETTINGS::fromLegacyString ( wxConfigBase *  aConfig,
const std::string &  aKey,
const std::string &  aDest 
)
protectedinherited

Translates a legacy wxConfig string value to a given JSON pointer value.

Parameters
aConfigis the legacy config to read from
aKeyis the key (within the current path) to read
aDestis a string that will form a JSON pointer (key1.key2.key3) to write to

Definition at line 691 of file json_settings.cpp.

693 {
694  wxString str;
695 
696  if( aConfig->Read( aKey, &str ) )
697  {
698  try
699  {
700  ( *m_internals )[aDest] = str.ToUTF8();
701  }
702  catch( ... )
703  {
704  wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyString!" ) );
705  return false;
706  }
707 
708  return true;
709  }
710 
711  return false;
712 }

Referenced by BITMAP2CMP_SETTINGS::MigrateFromLegacy(), GERBVIEW_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy(), PROJECT_FILE::MigrateFromLegacy(), PCB_CALCULATOR_SETTINGS::MigrateFromLegacy(), COMMON_SETTINGS::MigrateFromLegacy(), APP_SETTINGS_BASE::MigrateFromLegacy(), EESCHEMA_SETTINGS::MigrateFromLegacy(), PCBNEW_SETTINGS::MigrateFromLegacy(), and APP_SETTINGS_BASE::migrateWindowConfig().

◆ Get() [1/2]

template<typename ValueType >
template OPT< unsigned long long > JSON_SETTINGS::Get< unsigned long long > ( const std::string &  aPath) const
inherited

Fetches a value from within the JSON document.

Will return an empty optional if the value is not found or a mismatching type.

Template Parameters
ValueTypeis the type to cast to
Parameters
aPathis the path within the document to retrieve
Returns
a value from within this document

Definition at line 494 of file json_settings.cpp.

495 {
496  if( OPT<nlohmann::json> ret = GetJson( aPath ) )
497  {
498  try
499  {
500  return ret->get<ValueType>();
501  }
502  catch( ... )
503  {
504  }
505  }
506 
507  return NULLOPT;
508 }
OPT< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
const auto NULLOPT
Definition: optional.h:9
boost::optional< T > OPT
Definition: optional.h:7

References JSON_SETTINGS::GetJson(), and NULLOPT.

Referenced by PARAM< wxString >::Load(), COLOR_MAP_PARAM::Load(), PARAM_ENUM< EnumType >::Load(), PARAM_LAMBDA< nlohmann::json >::Load(), PARAM_SCALED< ValueType >::Load(), PARAM< wxString >::MatchesFile(), COLOR_MAP_PARAM::MatchesFile(), PARAM_PATH::MatchesFile(), PARAM_ENUM< EnumType >::MatchesFile(), PARAM_LAMBDA< nlohmann::json >::MatchesFile(), and PARAM_SCALED< ValueType >::MatchesFile().

◆ Get() [2/2]

OPT< wxString > JSON_SETTINGS::Get ( const std::string &  aPath) const
inherited

Definition at line 773 of file json_settings.cpp.

774 {
775  if( OPT<nlohmann::json> opt_json = GetJson( aPath ) )
776  return wxString( opt_json->get<std::string>().c_str(), wxConvUTF8 );
777 
778  return NULLOPT;
779 }
OPT< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
const auto NULLOPT
Definition: optional.h:9
boost::optional< T > OPT
Definition: optional.h:7

References JSON_SETTINGS::GetJson(), and NULLOPT.

◆ GetAuxOrigin()

◆ GetBiggestClearanceValue()

int BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue ( ) const
Returns
the biggest clearance value found in NetClasses list.

Definition at line 886 of file board_design_settings.cpp.

887 {
888  int biggest = 0;
889  DRC_CONSTRAINT constraint;
890 
891  if( m_DRCEngine )
892  {
893  m_DRCEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, constraint );
894  biggest = std::max( biggest, constraint.Value().Min() );
895 
896  m_DRCEngine->QueryWorstConstraint( HOLE_CLEARANCE_CONSTRAINT, constraint );
897  biggest = std::max( biggest, constraint.Value().Min() );
898 
899  m_DRCEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, constraint );
900  biggest = std::max( biggest, constraint.Value().Min() );
901  }
902 
903  return biggest;
904 }
MINOPTMAX< int > & Value()
Definition: drc_rule.h:123
T Min() const
Definition: minoptmax.h:33
std::shared_ptr< DRC_ENGINE > m_DRCEngine

References CLEARANCE_CONSTRAINT, EDGE_CLEARANCE_CONSTRAINT, HOLE_CLEARANCE_CONSTRAINT, m_DRCEngine, MINOPTMAX< T >::Min(), and DRC_CONSTRAINT::Value().

Referenced by ZONE_FILLER::buildThermalSpokes(), ZONE_FILLER::Fill(), PNS_KICAD_IFACE_BASE::SyncWorld(), PCB_TRACK::ViewBBox(), and FOOTPRINT::ViewBBox().

◆ GetBoardThickness()

◆ GetCopperLayerCount()

int BOARD_DESIGN_SETTINGS::GetCopperLayerCount ( ) const
inline

◆ GetCurrentDiffPairGap()

int BOARD_DESIGN_SETTINGS::GetCurrentDiffPairGap ( ) const
Returns
the current diff pair gap, according to the selected options ( using the default netclass value or a preset/custom value )

Definition at line 1017 of file board_design_settings.cpp.

1018 {
1019  if( m_useCustomDiffPair )
1020  {
1021  return m_customDiffPair.m_Gap;
1022  }
1023  else if( m_diffPairIndex == 0 )
1024  {
1025  if( GetNetClasses().GetDefaultPtr()->HasDiffPairGap() )
1027  else
1029  }
1030  else
1031  {
1033  }
1034 }
int GetDiffPairGap() const
Definition: netclass.h:152
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
DIFF_PAIR_DIMENSION m_customDiffPair
NETCLASSES & GetNetClasses() const
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258
int GetClearance() const
Definition: netclass.h:124

References NETCLASS::GetClearance(), NETCLASSES::GetDefaultPtr(), NETCLASS::GetDiffPairGap(), GetNetClasses(), m_customDiffPair, m_DiffPairDimensionsList, m_diffPairIndex, DIFF_PAIR_DIMENSION::m_Gap, and m_useCustomDiffPair.

Referenced by GetCurrentDiffPairViaGap(), and PNS_KICAD_IFACE_BASE::ImportSizes().

◆ GetCurrentDiffPairViaGap()

int BOARD_DESIGN_SETTINGS::GetCurrentDiffPairViaGap ( ) const
Returns
the current diff pair via gap, according to the selected options ( using the default netclass value or a preset/custom value ) the default netclass is always in m_DiffPairDimensionsList[0].

Definition at line 1037 of file board_design_settings.cpp.

1038 {
1039  if( m_useCustomDiffPair )
1040  {
1041  return m_customDiffPair.m_ViaGap;
1042  }
1043  else if( m_diffPairIndex == 0 )
1044  {
1045  if( GetNetClasses().GetDefaultPtr()->HasDiffPairViaGap() )
1047  else
1048  return GetCurrentDiffPairGap();
1049  }
1050  else
1051  {
1052  return m_DiffPairDimensionsList[m_diffPairIndex].m_ViaGap;
1053  }
1054 }
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
DIFF_PAIR_DIMENSION m_customDiffPair
int GetDiffPairViaGap() const
Definition: netclass.h:156
NETCLASSES & GetNetClasses() const
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258

References GetCurrentDiffPairGap(), NETCLASSES::GetDefaultPtr(), NETCLASS::GetDiffPairViaGap(), GetNetClasses(), m_customDiffPair, m_DiffPairDimensionsList, m_diffPairIndex, m_useCustomDiffPair, and DIFF_PAIR_DIMENSION::m_ViaGap.

Referenced by PNS_KICAD_IFACE_BASE::ImportSizes().

◆ GetCurrentDiffPairWidth()

int BOARD_DESIGN_SETTINGS::GetCurrentDiffPairWidth ( ) const
Returns
the current diff pair track width, according to the selected options ( using the default netclass value or a preset/custom value )

Definition at line 997 of file board_design_settings.cpp.

998 {
999  if( m_useCustomDiffPair )
1000  {
1001  return m_customDiffPair.m_Width;
1002  }
1003  else if( m_diffPairIndex == 0 )
1004  {
1005  if( GetNetClasses().GetDefaultPtr()->HasDiffPairWidth() )
1007  else
1009  }
1010  else
1011  {
1012  return m_DiffPairDimensionsList[m_diffPairIndex].m_Width;
1013  }
1014 }
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
DIFF_PAIR_DIMENSION m_customDiffPair
int GetTrackWidth() const
Definition: netclass.h:128
NETCLASSES & GetNetClasses() const
int GetDiffPairWidth() const
Definition: netclass.h:148
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258

References NETCLASSES::GetDefaultPtr(), NETCLASS::GetDiffPairWidth(), GetNetClasses(), NETCLASS::GetTrackWidth(), m_customDiffPair, m_DiffPairDimensionsList, m_diffPairIndex, m_useCustomDiffPair, and DIFF_PAIR_DIMENSION::m_Width.

Referenced by PNS_KICAD_IFACE_BASE::ImportSizes().

◆ GetCurrentMicroViaDrill()

int BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill ( )
Returns
the current micro via drill that is the current netclass value.

Definition at line 926 of file board_design_settings.cpp.

927 {
928  NETCLASSPTR netclass = GetNetClasses().Find( m_currentNetClassName );
929 
930  return netclass->GetuViaDrill();
931 }
wxString m_currentNetClassName
Current net class name used to display netclass info.
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
NETCLASSES & GetNetClasses() const

References NETCLASSES::Find(), GetNetClasses(), and m_currentNetClassName.

◆ GetCurrentMicroViaSize()

int BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize ( )
Returns
the current micro via size that is the current netclass value.

Definition at line 918 of file board_design_settings.cpp.

919 {
920  NETCLASSPTR netclass = GetNetClasses().Find( m_currentNetClassName );
921 
922  return netclass->GetuViaDiameter();
923 }
wxString m_currentNetClassName
Current net class name used to display netclass info.
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
NETCLASSES & GetNetClasses() const

References NETCLASSES::Find(), GetNetClasses(), and m_currentNetClassName.

◆ GetCurrentNetClassName()

const wxString& BOARD_DESIGN_SETTINGS::GetCurrentNetClassName ( ) const
inline
Returns
the current net class name.

Definition at line 277 of file board_design_settings.h.

278  {
279  return m_currentNetClassName;
280  }
wxString m_currentNetClassName
Current net class name used to display netclass info.

References m_currentNetClassName.

Referenced by DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists().

◆ GetCurrentTrackWidth()

int BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth ( ) const
Returns
the current track width according to the selected options ( using the default netclass value or a preset/custom value ) the default netclass is always in m_TrackWidthList[0]

Definition at line 974 of file board_design_settings.cpp.

975 {
976  if( m_useCustomTrackVia )
977  return m_customTrackWidth;
978  else if( m_trackWidthIndex == 0 )
980  else
982 }
std::vector< int > m_TrackWidthList
int GetTrackWidth() const
Definition: netclass.h:128
NETCLASSES & GetNetClasses() const
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258

References NETCLASSES::GetDefaultPtr(), GetNetClasses(), NETCLASS::GetTrackWidth(), m_customTrackWidth, m_trackWidthIndex, m_TrackWidthList, and m_useCustomTrackVia.

Referenced by EDIT_TOOL::ChangeTrackWidth(), MICROWAVE_TOOL::createBaseFootprint(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createInductorBetween(), PNS_KICAD_IFACE_BASE::ImportSizes(), and PCB_EDIT_FRAME::SetTrackSegmentWidth().

◆ GetCurrentViaDrill()

int BOARD_DESIGN_SETTINGS::GetCurrentViaDrill ( ) const
Returns
the current via size, according to the selected options ( using the default netclass value or a preset/custom value ) the default netclass is always in m_TrackWidthList[0].

Definition at line 952 of file board_design_settings.cpp.

953 {
954  int drill;
955 
956  if( m_useCustomTrackVia )
957  drill = m_customViaSize.m_Drill;
958  else if( m_viaSizeIndex == 0 )
959  drill = GetNetClasses().GetDefaultPtr()->GetViaDrill();
960  else
961  drill = m_ViasDimensionsList[ m_viaSizeIndex ].m_Drill;
962 
963  return drill > 0 ? drill : -1;
964 }
int GetViaDrill() const
Definition: netclass.h:136
NETCLASSES & GetNetClasses() const
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258
std::vector< VIA_DIMENSION > m_ViasDimensionsList

References NETCLASSES::GetDefaultPtr(), GetNetClasses(), NETCLASS::GetViaDrill(), m_customViaSize, VIA_DIMENSION::m_Drill, m_useCustomTrackVia, m_ViasDimensionsList, and m_viaSizeIndex.

Referenced by EDIT_TOOL::ChangeTrackWidth(), DRAWING_TOOL::DrawVia(), ROUTER_TOOL::handleLayerSwitch(), PNS_KICAD_IFACE_BASE::ImportSizes(), and PCB_EDIT_FRAME::SetTrackSegmentWidth().

◆ GetCurrentViaSize()

int BOARD_DESIGN_SETTINGS::GetCurrentViaSize ( ) const
Returns
the current via size, according to the selected options ( using the default netclass value or a preset/custom value ) the default netclass is always in m_TrackWidthList[0]

Definition at line 941 of file board_design_settings.cpp.

942 {
943  if( m_useCustomTrackVia )
945  else if( m_viaSizeIndex == 0 )
947  else
948  return m_ViasDimensionsList[ m_viaSizeIndex ].m_Diameter;
949 }
NETCLASSES & GetNetClasses() const
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258
int GetViaDiameter() const
Definition: netclass.h:132
std::vector< VIA_DIMENSION > m_ViasDimensionsList

References NETCLASSES::GetDefaultPtr(), GetNetClasses(), NETCLASS::GetViaDiameter(), m_customViaSize, VIA_DIMENSION::m_Diameter, m_useCustomTrackVia, m_ViasDimensionsList, and m_viaSizeIndex.

Referenced by EDIT_TOOL::ChangeTrackWidth(), DRAWING_TOOL::DrawVia(), ROUTER_TOOL::handleLayerSwitch(), PNS_KICAD_IFACE_BASE::ImportSizes(), and PCB_EDIT_FRAME::SetTrackSegmentWidth().

◆ GetCustomDiffPairGap()

int BOARD_DESIGN_SETTINGS::GetCustomDiffPairGap ( )
inline

Function GetCustomDiffPairGap.

Returns
Current custom gap width for differential pairs.

Definition at line 501 of file board_design_settings.h.

502  {
503  return m_customDiffPair.m_Gap;
504  }
DIFF_PAIR_DIMENSION m_customDiffPair

◆ GetCustomDiffPairViaGap()

int BOARD_DESIGN_SETTINGS::GetCustomDiffPairViaGap ( )
inline
Returns
Current custom via gap width for differential pairs.

Definition at line 520 of file board_design_settings.h.

◆ GetCustomDiffPairWidth()

int BOARD_DESIGN_SETTINGS::GetCustomDiffPairWidth ( )
inline
Returns
Current custom track width for differential pairs.

Definition at line 482 of file board_design_settings.h.

483  {
484  return m_customDiffPair.m_Width;
485  }
DIFF_PAIR_DIMENSION m_customDiffPair

◆ GetCustomTrackWidth()

int BOARD_DESIGN_SETTINGS::GetCustomTrackWidth ( ) const
inline
Returns
Current custom width for a track.

Definition at line 361 of file board_design_settings.h.

362  {
363  return m_customTrackWidth;
364  }

References m_customTrackWidth.

Referenced by DIALOG_TRACK_VIA_SIZE::TransferDataToWindow().

◆ GetCustomViaDrill()

int BOARD_DESIGN_SETTINGS::GetCustomViaDrill ( ) const
inline
Returns
Current custom size for the via drill.

Definition at line 432 of file board_design_settings.h.

433  {
434  return m_customViaSize.m_Drill;
435  }

Referenced by DIALOG_TRACK_VIA_SIZE::TransferDataToWindow().

◆ GetCustomViaSize()

int BOARD_DESIGN_SETTINGS::GetCustomViaSize ( ) const
inline
Returns
Current custom size for the via diameter.

Definition at line 404 of file board_design_settings.h.

405  {
407  }

Referenced by DIALOG_TRACK_VIA_SIZE::TransferDataToWindow().

◆ GetDefault()

◆ GetDefaultZoneSettings()

ZONE_SETTINGS& BOARD_DESIGN_SETTINGS::GetDefaultZoneSettings ( )
inline

◆ GetDiffPairIndex()

unsigned BOARD_DESIGN_SETTINGS::GetDiffPairIndex ( ) const
inline
Returns
the current diff pair dimension list index.

Definition at line 461 of file board_design_settings.h.

461 { return m_diffPairIndex; }

References m_diffPairIndex.

Referenced by BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), and DIFF_PAIR_MENU::update().

◆ GetDRCEpsilon()

int BOARD_DESIGN_SETTINGS::GetDRCEpsilon ( ) const

Definition at line 1118 of file board_design_settings.cpp.

1119 {
1120  return Millimeter2iu( ADVANCED_CFG::GetCfg().m_DRCEpsilon );
1121 }
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static constexpr int Millimeter2iu(double mm)

References ADVANCED_CFG::GetCfg(), and Millimeter2iu().

Referenced by ZONE_FILLER::buildCopperItemClearances(), calcIsInsideArea(), DRAWING_TOOL::DrawVia(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), and DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole().

◆ GetEnabledLayers()

LSET BOARD_DESIGN_SETTINGS::GetEnabledLayers ( ) const
inline

Return a bit-mask of all the layers that are enabled.

Returns
the enabled layers in bit-mapped form.

Definition at line 588 of file board_design_settings.h.

589  {
590  return m_enabledLayers;
591  }
LSET m_enabledLayers
Bit-mask for layer enabling.

References m_enabledLayers.

Referenced by BOARD_STACKUP::BuildDefaultStackupList(), CreatePadsShapesSection(), CreateRoutesSection(), BOARD::GetEnabledLayers(), and HYPERLYNX_EXPORTER::writeStackupInfo().

◆ getFileExt()

virtual wxString JSON_SETTINGS::getFileExt ( ) const
inlineprotectedvirtualinherited

Reimplemented in PROJECT_FILE, and PROJECT_LOCAL_SETTINGS.

Definition at line 270 of file json_settings.h.

271  {
272  return wxT( "json" );
273  }

Referenced by JSON_SETTINGS::GetFullFilename(), JSON_SETTINGS::LoadFromFile(), and JSON_SETTINGS::SaveToFile().

◆ GetFilename()

◆ GetFullFilename()

wxString JSON_SETTINGS::GetFullFilename ( ) const
inherited

Definition at line 105 of file json_settings.cpp.

106 {
107  return wxString( m_filename + "." + getFileExt() );
108 }
wxString m_filename
The filename (not including path) of this settings file (inicode)
virtual wxString getFileExt() const

References JSON_SETTINGS::getFileExt(), and JSON_SETTINGS::m_filename.

Referenced by JSON_SETTINGS::JSON_SETTINGS(), NESTED_SETTINGS::LoadFromFile(), JSON_SETTINGS::LoadFromFile(), and JSON_SETTINGS::SaveToFile().

◆ GetGridOrigin()

const wxPoint& BOARD_DESIGN_SETTINGS::GetGridOrigin ( )
inline

◆ GetHolePlatingThickness()

int BOARD_DESIGN_SETTINGS::GetHolePlatingThickness ( ) const

Pad & via drills are finish size.

Adding the hole plating thickness gives you the actual hole size.

Definition at line 1124 of file board_design_settings.cpp.

1125 {
1126  return Millimeter2iu( ADVANCED_CFG::GetCfg().m_HoleWallThickness );
1127 }
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static constexpr int Millimeter2iu(double mm)

References ADVANCED_CFG::GetCfg(), and Millimeter2iu().

Referenced by ZONE_FILLER::addHoleKnockout(), ZONE_FILLER::buildCopperItemClearances(), KIGFX::PCB_PAINTER::Draw(), PCB_VIA::GetEffectiveShape(), BOARD_ADAPTER::GetHolePlatingThickness(), DRC_ENGINE::GetShape(), PNS_KICAD_IFACE_BASE::syncPad(), PNS_KICAD_IFACE_BASE::syncVia(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones().

◆ GetJson()

OPT< nlohmann::json > JSON_SETTINGS::GetJson ( const std::string &  aPath) const
inherited

Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1.key2.key3" to refer to nested objects.

Parameters
aPathis a string containing one or more keys separated by '.'
Returns
a JSON object from within this one

Definition at line 474 of file json_settings.cpp.

475 {
476  nlohmann::json::json_pointer ptr = m_internals->PointerFromString( aPath );
477 
478  if( m_internals->contains( ptr ) )
479  {
480  try
481  {
482  return OPT<nlohmann::json>{ m_internals->at( ptr ) };
483  }
484  catch( ... )
485  {
486  }
487  }
488 
489  return OPT<nlohmann::json>{};
490 }
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
boost::optional< T > OPT
Definition: optional.h:7

References JSON_SETTINGS::m_internals.

Referenced by JSON_SETTINGS::Get(), PARAM_LAMBDA< nlohmann::json >::Load(), PARAM_LIST< wxString >::Load(), PARAM_MAP< Value >::Load(), PARAM_WXSTRING_MAP::Load(), PARAM_LAMBDA< nlohmann::json >::MatchesFile(), PARAM_LIST< wxString >::MatchesFile(), PARAM_PATH_LIST::MatchesFile(), PARAM_MAP< Value >::MatchesFile(), PARAM_WXSTRING_MAP::MatchesFile(), SETTINGS_MANAGER::SaveColorSettings(), and NESTED_SETTINGS::SaveToFile().

◆ GetLayerClass()

int BOARD_DESIGN_SETTINGS::GetLayerClass ( PCB_LAYER_ID  aLayer) const

Definition at line 1101 of file board_design_settings.cpp.

1102 {
1103  if( aLayer == F_SilkS || aLayer == B_SilkS )
1104  return LAYER_CLASS_SILK;
1105  else if( IsCopperLayer( aLayer ) )
1106  return LAYER_CLASS_COPPER;
1107  else if( aLayer == Edge_Cuts )
1108  return LAYER_CLASS_EDGES;
1109  else if( aLayer == F_CrtYd || aLayer == B_CrtYd )
1110  return LAYER_CLASS_COURTYARD;
1111  else if( aLayer == F_Fab || aLayer == B_Fab )
1112  return LAYER_CLASS_FAB;
1113  else
1114  return LAYER_CLASS_OTHERS;
1115 }
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:797

References B_CrtYd, B_Fab, B_SilkS, Edge_Cuts, F_CrtYd, F_Fab, F_SilkS, IsCopperLayer(), LAYER_CLASS_COPPER, LAYER_CLASS_COURTYARD, LAYER_CLASS_EDGES, LAYER_CLASS_FAB, LAYER_CLASS_OTHERS, and LAYER_CLASS_SILK.

Referenced by GetLineThickness(), GetTextItalic(), GetTextSize(), GetTextThickness(), and GetTextUpright().

◆ getLegacyFileExt()

virtual wxString JSON_SETTINGS::getLegacyFileExt ( ) const
inlineprotectedvirtualinherited

Reimplemented in PROJECT_FILE, and PROJECT_LOCAL_SETTINGS.

Definition at line 275 of file json_settings.h.

276  {
277  return wxEmptyString;
278  }

Referenced by JSON_SETTINGS::LoadFromFile().

◆ GetLineThickness()

◆ GetLocation()

SETTINGS_LOC JSON_SETTINGS::GetLocation ( ) const
inlineinherited

Definition at line 79 of file json_settings.h.

79 { return m_location; }
SETTINGS_LOC m_location
The location of this settings file (.

References JSON_SETTINGS::m_location.

Referenced by SETTINGS_MANAGER::GetPathForSettingsFile().

◆ GetNetClasses()

◆ GetParent()

JSON_SETTINGS* NESTED_SETTINGS::GetParent ( void  )
inlineinherited

Definition at line 54 of file nested_settings.h.

55  {
56  return m_parent;
57  }
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.

References NESTED_SETTINGS::m_parent.

Referenced by LoadFromFile().

◆ GetSeverity()

◆ GetSmallestClearanceValue()

int BOARD_DESIGN_SETTINGS::GetSmallestClearanceValue ( ) const
Returns
the smallest clearance value found in NetClasses list.

Definition at line 907 of file board_design_settings.cpp.

908 {
909  int clearance = GetDefault()->GetClearance();
910 
911  for( const std::pair<const wxString, NETCLASSPTR>& netclass : GetNetClasses().NetClasses() )
912  clearance = std::min( clearance, netclass.second->GetClearance() );
913 
914  return clearance;
915 }
NETCLASSES & GetNetClasses() const
int GetClearance() const
Definition: netclass.h:124
NETCLASS * GetDefault() const

References NETCLASS::GetClearance(), GetDefault(), and GetNetClasses().

Referenced by DIALOG_PLOT::init_Dialog().

◆ GetStackupDescriptor() [1/2]

◆ GetStackupDescriptor() [2/2]

const BOARD_STACKUP& BOARD_DESIGN_SETTINGS::GetStackupDescriptor ( ) const
inline

Definition at line 234 of file board_design_settings.h.

234 { return m_stackup; }
BOARD_STACKUP m_stackup
the description of layers stackup, for board fabrication only physical layers are in layers stackup.

References m_stackup.

◆ GetTextItalic()

bool BOARD_DESIGN_SETTINGS::GetTextItalic ( PCB_LAYER_ID  aLayer) const

◆ GetTextSize()

wxSize BOARD_DESIGN_SETTINGS::GetTextSize ( PCB_LAYER_ID  aLayer) const

Return the default text size from the layer class for the given layer.

Definition at line 1136 of file board_design_settings.cpp.

1137 {
1138  return m_TextSize[ GetLayerClass( aLayer ) ];
1139 }
int GetLayerClass(PCB_LAYER_ID aLayer) const
wxSize m_TextSize[LAYER_CLASS_COUNT]

References GetLayerClass(), and m_TextSize.

Referenced by PCB_BASE_FRAME::CreateNewFootprint(), EAGLE_PLUGIN::loadPlain(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DRAWING_TOOL::PlaceText(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ GetTextThickness()

int BOARD_DESIGN_SETTINGS::GetTextThickness ( PCB_LAYER_ID  aLayer) const

Return the default text thickness from the layer class for the given layer.

Definition at line 1142 of file board_design_settings.cpp.

1143 {
1144  return m_TextThickness[ GetLayerClass( aLayer ) ];
1145 }
int GetLayerClass(PCB_LAYER_ID aLayer) const
int m_TextThickness[LAYER_CLASS_COUNT]

References GetLayerClass(), and m_TextThickness.

Referenced by PCB_BASE_FRAME::CreateNewFootprint(), EAGLE_PLUGIN::loadPlain(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DRAWING_TOOL::PlaceText(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ GetTextUpright()

bool BOARD_DESIGN_SETTINGS::GetTextUpright ( PCB_LAYER_ID  aLayer) const

◆ GetTrackWidthIndex()

unsigned BOARD_DESIGN_SETTINGS::GetTrackWidthIndex ( ) const
inline

◆ GetViaSizeIndex()

unsigned BOARD_DESIGN_SETTINGS::GetViaSizeIndex ( ) const
inline

◆ Ignore()

bool BOARD_DESIGN_SETTINGS::Ignore ( int  aDRCErrorCode)

Return true if the DRC error code's severity is SEVERITY_IGNORE.

Definition at line 880 of file board_design_settings.cpp.

881 {
882  return m_DRCSeverities[ aDRCErrorCode ] == RPT_SEVERITY_IGNORE;
883 }
std::map< int, SEVERITY > m_DRCSeverities

References m_DRCSeverities, and RPT_SEVERITY_IGNORE.

Referenced by DRC_ENGINE::RunTests().

◆ initFromOther()

void BOARD_DESIGN_SETTINGS::initFromOther ( const BOARD_DESIGN_SETTINGS aOther)
private

Definition at line 673 of file board_design_settings.cpp.

674 {
675  // Copy of NESTED_SETTINGS around is not allowed, so let's just update the params.
686  m_ViasMinSize = aOther.m_ViasMinSize;
698  m_MaxError = aOther.m_MaxError;
704 
705  std::copy( std::begin( aOther.m_LineThickness ), std::end( aOther.m_LineThickness ),
706  std::begin( m_LineThickness ) );
707 
708  std::copy( std::begin( aOther.m_TextSize ), std::end( aOther.m_TextSize ),
709  std::begin( m_TextSize ) );
710 
711  std::copy( std::begin( aOther.m_TextThickness ), std::end( aOther.m_TextThickness ),
712  std::begin( m_TextThickness ) );
713 
714  std::copy( std::begin( aOther.m_TextItalic ), std::end( aOther.m_TextItalic ),
715  std::begin( m_TextItalic ) );
716 
717  std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ),
718  std::begin( m_TextUpright ) );
719 
728 
729  m_auxOrigin = aOther.m_auxOrigin;
730  m_gridOrigin = aOther.m_gridOrigin;
731  m_HasStackup = aOther.m_HasStackup;
733 
746  m_stackup = aOther.m_stackup;
747 
748  // Only take the pointer from the other if it isn't the default
749  if( aOther.m_netClasses == &aOther.m_internalNetClasses )
751  else
752  m_netClasses = aOther.m_netClasses;
753 
755 }
int m_ZoneFillVersion
Option to select different fill algorithms.
wxString m_currentNetClassName
Current net class name used to display netclass info.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
std::vector< int > m_TrackWidthList
BOARD_STACKUP m_stackup
the description of layers stackup, for board fabrication only physical layers are in layers stackup.
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
NETCLASSES m_internalNetClasses
Net classes that are loaded from the board file before these were stored in the project.
wxPoint m_auxOrigin
origin for plot exports
int m_DimensionPrecision
Number of digits after the decimal.
ZONE_SETTINGS m_defaultZoneSettings
The default settings that will be used for new zones.
DIFF_PAIR_DIMENSION m_customDiffPair
VIATYPE m_CurrentViaType
(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
int m_LineThickness[LAYER_CLASS_COUNT]
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
wxPoint m_gridOrigin
origin for grid offsets
std::map< int, SEVERITY > m_DRCSeverities
std::vector< VIA_DIMENSION > m_ViasDimensionsList
DIM_UNITS_FORMAT m_DimensionUnitsFormat
NETCLASSES * m_netClasses
This will point to m_internalNetClasses until it is repointed to the project after load.
int m_copperLayerCount
Number of copper layers for this design.
bool m_MicroViasAllowed
true to allow micro vias
std::set< wxString > m_DrcExclusions
LSET m_enabledLayers
Bit-mask for layer enabling.
int m_boardThickness
Board thickness for 3D viewer.
bool m_TextUpright[LAYER_CLASS_COUNT]

References m_auxOrigin, m_BlindBuriedViaAllowed, m_boardThickness, m_CopperEdgeClearance, m_copperLayerCount, m_currentNetClassName, m_CurrentViaType, m_customDiffPair, m_customTrackWidth, m_customViaSize, m_DefaultFPTextItems, m_defaultZoneSettings, m_DiffPairDimensionsList, m_diffPairIndex, m_DimensionArrowLength, m_DimensionExtensionOffset, m_DimensionKeepTextAligned, m_DimensionPrecision, m_DimensionSuppressZeroes, m_DimensionTextPosition, m_DimensionUnitsFormat, m_DimensionUnitsMode, m_DrcExclusions, m_DRCSeverities, m_enabledLayers, m_gridOrigin, m_HasStackup, m_HoleClearance, m_HoleToHoleMin, m_internalNetClasses, m_LineThickness, m_MaxError, m_MicroViasAllowed, m_MicroViasMinDrill, m_MicroViasMinSize, m_MinClearance, m_MinThroughDrill, m_netClasses, m_SilkClearance, m_SolderMaskMargin, m_SolderMaskMinWidth, m_SolderPasteMargin, m_SolderPasteMarginRatio, m_stackup, m_TextItalic, m_TextSize, m_TextThickness, m_TextUpright, m_TrackMinWidth, m_trackWidthIndex, m_TrackWidthList, m_UseConnectedTrackWidth, m_useCustomDiffPair, m_useCustomTrackVia, m_UseHeightForLengthCalcs, m_ViasDimensionsList, m_viaSizeIndex, m_ViasMinAnnularWidth, m_ViasMinSize, m_ZoneFillVersion, and m_ZoneKeepExternalFillets.

Referenced by BOARD_DESIGN_SETTINGS(), and operator=().

◆ Internals()

JSON_SETTINGS_INTERNALS * JSON_SETTINGS::Internals ( )
inherited

Definition at line 129 of file json_settings.cpp.

130 {
131  return m_internals.get();
132 }
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals

References JSON_SETTINGS::m_internals.

Referenced by COLOR_SETTINGS::migrateSchema0to1(), and SETTINGS_MANAGER::SaveColorSettings().

◆ IsLayerEnabled()

bool BOARD_DESIGN_SETTINGS::IsLayerEnabled ( PCB_LAYER_ID  aLayerId) const
inline

Test whether a given layer aLayerId is enabled.

Parameters
aLayerIdThe layer to be tested.
Returns
true if the layer is enabled.

Definition at line 606 of file board_design_settings.h.

607  {
608  if( aLayerId >= 0 && aLayerId < PCB_LAYER_ID_COUNT )
609  return m_enabledLayers[aLayerId];
610 
611  return false;
612  }
LSET m_enabledLayers
Bit-mask for layer enabling.

References PCB_LAYER_ID_COUNT.

Referenced by BOARD::IsLayerEnabled(), and BOARD::IsLayerVisible().

◆ IsReadOnly()

◆ Load()

void JSON_SETTINGS::Load ( )
virtualinherited

Updates the parameters of this object based on the current JSON document contents.

Definition at line 135 of file json_settings.cpp.

136 {
137  for( auto param : m_params )
138  {
139  try
140  {
141  param->Load( this, m_resetParamsIfMissing );
142  }
143  catch( ... )
144  {
145  // Skip unreadable parameters in file
146  wxLogTrace( traceSettings, "param '%s' load err", param->GetJsonPath().c_str() );
147  }
148  }
149 }
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
bool m_resetParamsIfMissing
Whether or not to set parameters to their default value if missing from JSON on Load()
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.

References JSON_SETTINGS::m_params, JSON_SETTINGS::m_resetParamsIfMissing, and traceSettings.

Referenced by COLOR_SETTINGS::CreateBuiltinColorSettings(), NESTED_SETTINGS::LoadFromFile(), JSON_SETTINGS::LoadFromFile(), LoadFromFile(), COLOR_SETTINGS::migrateSchema0to1(), and SETTINGS_MANAGER::SaveColorSettings().

◆ LoadFromFile()

bool BOARD_DESIGN_SETTINGS::LoadFromFile ( const wxString &  aDirectory = "")
overridevirtual

Loads the backing file from disk and then calls Load()

Parameters
aDirectoryis the path to the file
Returns
true if the file was found on disk and loaded or migrated

Reimplemented from JSON_SETTINGS.

Definition at line 809 of file board_design_settings.cpp.

810 {
811  bool ret = NESTED_SETTINGS::LoadFromFile( aDirectory );
812 
813  // A number of things won't have been translated by the PROJECT_FILE migration because of
814  // descoped objects required to decode this data. So, it will be in the legacy.pcbnew
815  // section and needs to be pulled out here
816 
817  PROJECT_FILE* project = dynamic_cast<PROJECT_FILE*>( GetParent() );
818 
819  if( !project )
820  return ret;
821 
822  bool migrated = false;
823 
824  auto drcName =
825  []( int aCode ) -> std::string
826  {
827  std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( aCode );
828  wxString name = item->GetSettingsKey();
829  return std::string( name.ToUTF8() );
830  };
831 
832  std::string bp = "board.design_settings.rule_severities.";
833  std::string rs = "rule_severities.";
834 
835  if( OPT<bool> v = project->Get<bool>( bp + "legacy_no_courtyard_defined" ) )
836  {
837  if( *v )
838  Set( rs + drcName( DRCE_MISSING_COURTYARD ), "error" );
839  else
840  Set( rs + drcName( DRCE_MISSING_COURTYARD ), "ignore" );
841 
842  project->Internals()->erase( m_internals->PointerFromString( bp + "legacy_no_courtyard_defined" ) );
843  migrated = true;
844  }
845 
846  if( OPT<bool> v = project->Get<bool>( bp + "legacy_courtyards_overlap" ) )
847  {
848  if( *v )
849  Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "error" );
850  else
851  Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "ignore" );
852 
853  project->Internals()->erase( JSON_SETTINGS_INTERNALS::PointerFromString( bp + "legacy_courtyards_overlap" ) );
854  migrated = true;
855  }
856 
857  if( Contains( "legacy" ) )
858  {
859  // This defaults to false for new boards, but version 5.1.x and prior kept the fillets
860  // so we do the same for legacy boards.
862 
863  project->At( "legacy" ).erase( "pcbnew" );
864  }
865 
866  // Now that we have everything, we need to load again
867  if( migrated )
868  Load();
869 
870  return ret;
871 }
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:266
JSON_SETTINGS * GetParent()
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
bool LoadFromFile(const wxString &aDirectory="") override
Loads the JSON document from the parent and then calls Load()
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:64
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
const char * name
Definition: DXF_plotter.cpp:56
boost::optional< T > OPT
Definition: optional.h:7
bool Contains(const std::string &aPath) const
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.

References JSON_SETTINGS::Contains(), DRC_ITEM::Create(), DRCE_MISSING_COURTYARD, DRCE_OVERLAPPING_FOOTPRINTS, NESTED_SETTINGS::GetParent(), JSON_SETTINGS::Load(), NESTED_SETTINGS::LoadFromFile(), JSON_SETTINGS::m_internals, m_ZoneKeepExternalFillets, name, JSON_SETTINGS_INTERNALS::PointerFromString(), project, and JSON_SETTINGS::Set().

◆ Migrate()

bool JSON_SETTINGS::Migrate ( )
inherited

Migrates the schema of this settings from the version in the file to the latest version.

Schema migration doesn't need to be used every time a setting is added! This is intended to be more of an "escape hatch" in the event that we decide to move settings around or make other changes to a settings file format that can't simply be handled by loading a new default

Returns
true if migration was successful

Definition at line 552 of file json_settings.cpp.

553 {
554  int filever = m_internals->Get<int>( "meta.version" );
555 
556  while( filever < m_schemaVersion )
557  {
558  if( !m_migrators.count( filever ) )
559  {
560  wxLogTrace( traceSettings, "Migrator missing for %s version %d!",
561  typeid( *this ).name(), filever );
562  return false;
563  }
564 
565  std::pair<int, std::function<bool()>> pair = m_migrators.at( filever );
566 
567  if( pair.second() )
568  {
569  wxLogTrace( traceSettings, "Migrated %s from %d to %d", typeid( *this ).name(),
570  filever, pair.first );
571  filever = pair.first;
572  m_internals->At( "meta.version" ) = filever;
573  }
574  else
575  {
576  wxLogTrace( traceSettings, "Migration failed for %s from %d to %d",
577  typeid( *this ).name(), filever, pair.first );
578  return false;
579  }
580  }
581 
582  return true;
583 }
std::map< int, std::pair< int, std::function< bool()> > > m_migrators
A map of starting schema version to a pair of <ending version, migrator function>
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.
int m_schemaVersion
Version of this settings schema.

References JSON_SETTINGS::m_internals, JSON_SETTINGS::m_migrators, JSON_SETTINGS::m_schemaVersion, and traceSettings.

Referenced by NESTED_SETTINGS::LoadFromFile(), and JSON_SETTINGS::LoadFromFile().

◆ MigrateFromLegacy()

bool JSON_SETTINGS::MigrateFromLegacy ( wxConfigBase *  aLegacyConfig)
virtualinherited

Migrates from wxConfig to JSON-based configuration.

Should be implemented by any subclasses of JSON_SETTINGS that map to a legacy (wxConfig-based) config file.

Parameters
aLegacyConfigis a wxConfigBase holding a loaded configuration to migrate
Returns
true if migration was successful

Reimplemented in PCBNEW_SETTINGS, EESCHEMA_SETTINGS, APP_SETTINGS_BASE, COMMON_SETTINGS, PCB_CALCULATOR_SETTINGS, EDA_3D_VIEWER_SETTINGS, PROJECT_FILE, COLOR_SETTINGS, PROJECT_LOCAL_SETTINGS, SYMBOL_EDITOR_SETTINGS, FOOTPRINT_EDITOR_SETTINGS, GERBVIEW_SETTINGS, CVPCB_SETTINGS, BITMAP2CMP_SETTINGS, PL_EDITOR_SETTINGS, and KICAD_SETTINGS.

Definition at line 586 of file json_settings.cpp.

587 {
588  wxLogTrace( traceSettings,
589  "MigrateFromLegacy() not implemented for %s", typeid( *this ).name() );
590  return false;
591 }
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.

References traceSettings.

Referenced by JSON_SETTINGS::LoadFromFile().

◆ migrateSchema0to1()

bool BOARD_DESIGN_SETTINGS::migrateSchema0to1 ( )
private

Schema 0 to 1: default dimension precision changed in meaning. Previously it was an enum with the following meaning:

0: 0.01mm / 1 mil / 0.001 in 1: 0.001mm / 0.1 mil / 0.0001 in 2: 0.0001mm / 0.01 mil / 0.00001 in

Now it is independent of display units and is an integer meaning the number of digits displayed after the decimal point, so we have to migrate based on the default units.

The units is an integer with the following mapping:

0: Inches 1: Mils 2: Millimeters

Definition at line 758 of file board_design_settings.cpp.

759 {
777  std::string units_ptr( "defaults.dimension_units" );
778  std::string precision_ptr( "defaults.dimension_precision" );
779 
780  if( !( Contains( units_ptr ) && Contains( precision_ptr ) &&
781  At( units_ptr ).is_number_integer() &&
782  At( precision_ptr ).is_number_integer() ) )
783  {
784  // if either is missing or invalid, migration doesn't make sense
785  return true;
786  }
787 
788  int units = Get<int>( units_ptr ).value();
789  int precision = Get<int>( precision_ptr ).value();
790 
791  // The enum maps directly to precision if the units is mils
792  int extraDigits = 0;
793 
794  switch( units )
795  {
796  case 0: extraDigits = 3; break;
797  case 2: extraDigits = 2; break;
798  default: break;
799  }
800 
801  precision += extraDigits;
802 
803  Set( precision_ptr, precision );
804 
805  return true;
806 }
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
bool Contains(const std::string &aPath) const

References JSON_SETTINGS::At(), JSON_SETTINGS::Contains(), and JSON_SETTINGS::Set().

Referenced by BOARD_DESIGN_SETTINGS().

◆ operator=()

BOARD_DESIGN_SETTINGS & BOARD_DESIGN_SETTINGS::operator= ( const BOARD_DESIGN_SETTINGS aOther)

Definition at line 666 of file board_design_settings.cpp.

667 {
668  initFromOther( aOther );
669  return *this;
670 }
void initFromOther(const BOARD_DESIGN_SETTINGS &aOther)

References initFromOther().

◆ registerMigration()

void JSON_SETTINGS::registerMigration ( int  aOldSchemaVersion,
int  aNewSchemaVersion,
std::function< bool(void)>  aMigrator 
)
protectedinherited

Registers a migration from one schema version to another.

If the schema version in the file loaded from disk is less than the schema version of the JSON_SETTINGS class, migration functions will be called one after the other until the data is up-to-date.

Parameters
aOldSchemaVersionis the starting schema version for this migration
aNewSchemaVersionis the ending schema version for this migration
aMigratoris a function that performs the migration and returns true if successful

Definition at line 543 of file json_settings.cpp.

545 {
546  wxASSERT( aNewSchemaVersion > aOldSchemaVersion );
547  wxASSERT( aNewSchemaVersion <= m_schemaVersion );
548  m_migrators[aOldSchemaVersion] = std::make_pair( aNewSchemaVersion, aMigrator );
549 }
std::map< int, std::pair< int, std::function< bool()> > > m_migrators
A map of starting schema version to a pair of <ending version, migrator function>
int m_schemaVersion
Version of this settings schema.

References JSON_SETTINGS::m_migrators, and JSON_SETTINGS::m_schemaVersion.

Referenced by BOARD_DESIGN_SETTINGS(), COLOR_SETTINGS::COLOR_SETTINGS(), EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS(), EESCHEMA_SETTINGS::EESCHEMA_SETTINGS(), FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS(), NET_SETTINGS::NET_SETTINGS(), PCBNEW_SETTINGS::PCBNEW_SETTINGS(), PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS(), and SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS().

◆ ReleaseNestedSettings()

void JSON_SETTINGS::ReleaseNestedSettings ( NESTED_SETTINGS aSettings)
inherited

Saves and frees a nested settings object, if it exists within this one.

Parameters
aSettingsis a pointer to a NESTED_SETTINGS that has already been added to this one

Definition at line 750 of file json_settings.cpp.

751 {
752  if( !aSettings )
753  return;
754 
755  auto it = std::find_if( m_nested_settings.begin(), m_nested_settings.end(),
756  [&aSettings]( const JSON_SETTINGS* aPtr ) {
757  return aPtr == aSettings;
758  } );
759 
760  if( it != m_nested_settings.end() )
761  {
762  wxLogTrace( traceSettings, "Flush and release %s", ( *it )->GetFilename() );
763  ( *it )->SaveToFile();
764  m_nested_settings.erase( it );
765  }
766 
767  aSettings->SetParent( nullptr );
768 }
void SetParent(JSON_SETTINGS *aParent, bool aLoadFromFile=true)
std::vector< NESTED_SETTINGS * > m_nested_settings
Nested settings files that live inside this one, if any.
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.

References JSON_SETTINGS::m_nested_settings, NESTED_SETTINGS::SetParent(), and traceSettings.

Referenced by ~BOARD_DESIGN_SETTINGS(), ERC_SETTINGS::~ERC_SETTINGS(), NESTED_SETTINGS::~NESTED_SETTINGS(), NET_SETTINGS::~NET_SETTINGS(), and SCHEMATIC_SETTINGS::~SCHEMATIC_SETTINGS().

◆ ResetToDefaults()

void JSON_SETTINGS::ResetToDefaults ( )
inherited

Resets all parameters to default values.

Does NOT write to file or update underlying JSON.

Definition at line 367 of file json_settings.cpp.

368 {
369  for( auto param : m_params )
370  param->SetDefault();
371 }
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)

References JSON_SETTINGS::m_params.

Referenced by EDA_3D_VIEWER_FRAME::Process_Special_Functions(), PANEL_COMMON_SETTINGS::ResetPanel(), and PANEL_MOUSE_SETTINGS::ResetPanel().

◆ SaveToFile()

bool NESTED_SETTINGS::SaveToFile ( const wxString &  aDirectory = "",
bool  aForce = false 
)
overridevirtualinherited

Calls Store() and then saves the JSON document contents into the parent JSON_SETTINGS.

Parameters
aDirectoryis ignored
Returns
true if the document contents were updated

Reimplemented from JSON_SETTINGS.

Definition at line 113 of file nested_settings.cpp.

114 {
115  if( !m_parent )
116  return false;
117 
118  try
119  {
120  bool modified = Store();
121 
122  auto jsonObjectInParent = m_parent->GetJson( m_path );
123 
124  if( !jsonObjectInParent )
125  modified = true;
126  else if( !nlohmann::json::diff( *m_internals, jsonObjectInParent.value() ).empty() )
127  modified = true;
128 
129  if( modified || aForce )
130  {
131  ( *m_parent->m_internals )[m_path].update( *m_internals );
132 
133  wxLogTrace( traceSettings, "Stored NESTED_SETTINGS %s with schema %d",
134  GetFilename(),
135  m_schemaVersion );
136  }
137 
138  return modified;
139  }
140  catch( ... )
141  {
142  wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not store to %s at %s",
143  m_filename,
145  m_path );
146 
147  return false;
148  }
149 }
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
wxString GetFilename() const
Definition: json_settings.h:72
OPT< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
wxString m_filename
The filename (not including path) of this settings file (inicode)
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
static bool empty(const wxTextEntryBase *aCtrl)
std::string m_path
The path (in pointer format) of where to store this document in the parent.
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.
int m_schemaVersion
Version of this settings schema.

References empty(), JSON_SETTINGS::GetFilename(), JSON_SETTINGS::GetJson(), JSON_SETTINGS::m_filename, JSON_SETTINGS::m_internals, NESTED_SETTINGS::m_parent, NESTED_SETTINGS::m_path, JSON_SETTINGS::m_schemaVersion, JSON_SETTINGS::Store(), and traceSettings.

◆ Set() [1/3]

template<typename ValueType >
template void JSON_SETTINGS::Set< const char * > ( const std::string &  aPath,
ValueType  aVal 
)
inherited

Stores a value into the JSON document Will throw an exception if ValueType isn't something that the library can handle.

Template Parameters
ValueTypeis the type to store
Parameters
aPathis a path to store in the form "key1.key2.key3"
aValis the value to store

Definition at line 524 of file json_settings.cpp.

525 {
526  m_internals->SetFromString( aPath, aVal );
527 }
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals

References JSON_SETTINGS::m_internals.

Referenced by COLOR_SETTINGS::COLOR_SETTINGS(), EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS(), LoadFromFile(), APP_SETTINGS_BASE::migrateFindReplace(), GERBVIEW_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy(), PROJECT_FILE::MigrateFromLegacy(), EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy(), COMMON_SETTINGS::MigrateFromLegacy(), APP_SETTINGS_BASE::MigrateFromLegacy(), EESCHEMA_SETTINGS::MigrateFromLegacy(), PCBNEW_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), migrateSchema0to1(), PCBNEW_SETTINGS::PCBNEW_SETTINGS(), PROJECT_LOCAL_SETTINGS::SaveAs(), PROJECT_FILE::SaveAs(), PROJECT_LOCAL_SETTINGS::SaveToFile(), PROJECT_FILE::SaveToFile(), SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS(), PARAM< wxString >::Store(), COLOR_MAP_PARAM::Store(), PARAM_PATH::Store(), PARAM_ENUM< EnumType >::Store(), PARAM_LAMBDA< nlohmann::json >::Store(), PARAM_SCALED< ValueType >::Store(), PARAM_LIST< wxString >::Store(), PARAM_PATH_LIST::Store(), PARAM_MAP< Value >::Store(), and PARAM_WXSTRING_MAP::Store().

◆ Set() [2/3]

template<>
void JSON_SETTINGS::Set ( const std::string &  aPath,
wxString  aVal 
)
inherited

◆ Set() [3/3]

template<>
void JSON_SETTINGS::Set ( const std::string &  aPath,
wxString  aVal 
)
inherited

Definition at line 782 of file json_settings.cpp.

783 {
784  ( *m_internals )[aPath] = aVal.ToUTF8();
785 }

◆ SetAuxOrigin()

void BOARD_DESIGN_SETTINGS::SetAuxOrigin ( const wxPoint &  aOrigin)
inline

◆ SetBoardThickness()

void BOARD_DESIGN_SETTINGS::SetBoardThickness ( int  aThickness)
inline

Definition at line 630 of file board_design_settings.h.

630 { m_boardThickness = aThickness; }
int m_boardThickness
Board thickness for 3D viewer.

Referenced by LEGACY_PLUGIN::loadGENERAL(), and PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow().

◆ SetCopperEdgeClearance()

void BOARD_DESIGN_SETTINGS::SetCopperEdgeClearance ( int  aDistance)
Parameters
aValueThe minimum distance between copper items and board edges.

Definition at line 1063 of file board_design_settings.cpp.

1064 {
1065  m_CopperEdgeClearance = aDistance;
1066 }

References m_CopperEdgeClearance.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles(), and PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow().

◆ SetCopperLayerCount()

void BOARD_DESIGN_SETTINGS::SetCopperLayerCount ( int  aNewLayerCount)

Set the copper layer count to aNewLayerCount.

Parameters
aNewLayerCountThe new number of enabled copper layers.

Definition at line 1075 of file board_design_settings.cpp.

1076 {
1077  m_copperLayerCount = aNewLayerCount;
1078 
1079  // Update only enabled copper layers mask
1080  m_enabledLayers &= ~LSET::AllCuMask();
1081 
1082  if( aNewLayerCount > 0 )
1083  m_enabledLayers |= LSET::AllCuMask( aNewLayerCount );
1084 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
int m_copperLayerCount
Number of copper layers for this design.
LSET m_enabledLayers
Bit-mask for layer enabling.

References LSET::AllCuMask(), m_copperLayerCount, and m_enabledLayers.

Referenced by BOARD_DESIGN_SETTINGS(), and BOARD::SetCopperLayerCount().

◆ SetCustomDiffPairGap()

void BOARD_DESIGN_SETTINGS::SetCustomDiffPairGap ( int  aGap)
inline

Sets custom gap for differential pairs (i.e.

not available in netclasses or preset list).

Parameters
aGapis the new gap.

Definition at line 492 of file board_design_settings.h.

493  {
494  m_customDiffPair.m_Gap = aGap;
495  }
DIFF_PAIR_DIMENSION m_customDiffPair

Referenced by ROUTER_TOOL::DpDimensionsDialog(), and BOARD::SynchronizeNetsAndNetClasses().

◆ SetCustomDiffPairViaGap()

void BOARD_DESIGN_SETTINGS::SetCustomDiffPairViaGap ( int  aGap)
inline

Sets custom via gap for differential pairs (i.e.

not available in netclasses or preset list).

Parameters
aGapis the new gap. Specify 0 to use the DiffPairGap for vias as well.

Definition at line 512 of file board_design_settings.h.

513  {
514  m_customDiffPair.m_ViaGap = aGap;
515  }
DIFF_PAIR_DIMENSION m_customDiffPair

Referenced by ROUTER_TOOL::DpDimensionsDialog(), and BOARD::SynchronizeNetsAndNetClasses().

◆ SetCustomDiffPairWidth()

void BOARD_DESIGN_SETTINGS::SetCustomDiffPairWidth ( int  aWidth)
inline

Sets custom track width for differential pairs (i.e.

not available in netclasses or preset list).

Parameters
aDrillis the new track wdith.

Definition at line 474 of file board_design_settings.h.

475  {
476  m_customDiffPair.m_Width = aWidth;
477  }
DIFF_PAIR_DIMENSION m_customDiffPair

Referenced by ROUTER_TOOL::DpDimensionsDialog(), and BOARD::SynchronizeNetsAndNetClasses().

◆ SetCustomTrackWidth()

void BOARD_DESIGN_SETTINGS::SetCustomTrackWidth ( int  aWidth)
inline

Sets custom width for track (i.e.

not available in netclasses or preset list).

To have it returned with GetCurrentTrackWidth() you need to enable custom track & via sizes with UseCustomTrackViaSize().

Parameters
aWidthis the new track width.

Definition at line 353 of file board_design_settings.h.

354  {
355  m_customTrackWidth = aWidth;
356  }

Referenced by BOARD::SynchronizeNetsAndNetClasses(), and DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow().

◆ SetCustomViaDrill()

void BOARD_DESIGN_SETTINGS::SetCustomViaDrill ( int  aDrill)
inline

Sets custom size for via drill (i.e.

not available in netclasses or preset list).

To have it returned with GetCurrentViaDrill() you need to enable custom track & via sizes with UseCustomTrackViaSize().

Parameters
aDrillis the new drill size.

Definition at line 424 of file board_design_settings.h.

425  {
426  m_customViaSize.m_Drill = aDrill;
427  }

Referenced by BOARD::SynchronizeNetsAndNetClasses(), and DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow().

◆ SetCustomViaSize()

void BOARD_DESIGN_SETTINGS::SetCustomViaSize ( int  aSize)
inline

Set custom size for via diameter (i.e.

not available in netclasses or preset list).

To have it returned with GetCurrentViaSize() you need to enable custom track & via sizes with UseCustomTrackViaSize().

Parameters
aSizeis the new drill diameter.

Definition at line 396 of file board_design_settings.h.

397  {
398  m_customViaSize.m_Diameter = aSize;
399  }

Referenced by BOARD::SynchronizeNetsAndNetClasses(), and DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow().

◆ SetDefaultZoneSettings()

void BOARD_DESIGN_SETTINGS::SetDefaultZoneSettings ( const ZONE_SETTINGS aSettings)
inline

Definition at line 261 of file board_design_settings.h.

262  {
263  m_defaultZoneSettings = aSettings;
264  }
ZONE_SETTINGS m_defaultZoneSettings
The default settings that will be used for new zones.

Referenced by PCB_BASE_FRAME::SetZoneSettings(), and BOARD::SetZoneSettings().

◆ SetDiffPairIndex()

void BOARD_DESIGN_SETTINGS::SetDiffPairIndex ( unsigned  aIndex)
Parameters
aIndexis the diff pair dimensions list index to set.

Definition at line 985 of file board_design_settings.cpp.

986 {
987  if( !m_DiffPairDimensionsList.empty() )
988  {
989  m_diffPairIndex = std::min( aIndex,
990  static_cast<unsigned>( m_DiffPairDimensionsList.size() ) - 1 );
991  }
992 
993  m_useCustomDiffPair = false;
994 }
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList

References m_DiffPairDimensionsList, m_diffPairIndex, and m_useCustomDiffPair.

Referenced by DIFF_PAIR_MENU::eventHandler(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ SetEnabledLayers()

void BOARD_DESIGN_SETTINGS::SetEnabledLayers ( LSET  aMask)

Change the bit-mask of enabled layers to aMask.

Parameters
aMask= The new bit-mask of enabled layers.

Definition at line 1087 of file board_design_settings.cpp.

1088 {
1089  // Back and front layers are always enabled.
1090  aMask.set( B_Cu ).set( F_Cu );
1091 
1092  m_enabledLayers = aMask;
1093 
1094  // update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
1095  m_copperLayerCount = ( aMask & LSET::AllCuMask() ).count();
1096 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
Definition: layer_ids.h:71
int m_copperLayerCount
Number of copper layers for this design.
LSET m_enabledLayers
Bit-mask for layer enabling.

References LSET::AllCuMask(), B_Cu, F_Cu, m_copperLayerCount, and m_enabledLayers.

Referenced by BOARD::SetEnabledLayers().

◆ SetFilename()

void JSON_SETTINGS::SetFilename ( const wxString &  aFilename)
inlineinherited

Definition at line 76 of file json_settings.h.

76 { m_filename = aFilename; }
wxString m_filename
The filename (not including path) of this settings file (inicode)

References JSON_SETTINGS::m_filename.

Referenced by SETTINGS_MANAGER::GetColorSettings(), PROJECT_LOCAL_SETTINGS::SaveAs(), PROJECT_FILE::SaveAs(), SETTINGS_MANAGER::SaveProjectAs(), and SETTINGS_MANAGER::SaveProjectCopy().

◆ SetGridOrigin()

void BOARD_DESIGN_SETTINGS::SetGridOrigin ( const wxPoint &  aOrigin)
inline

◆ SetIfPresent() [1/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
wxString &  aTarget 
)
staticinherited

Sets the given string if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 594 of file json_settings.cpp.

596 {
597  nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
598 
599  if( aObj.contains( ptr ) && aObj.at( ptr ).is_string() )
600  {
601  aTarget = aObj.at( ptr ).get<wxString>();
602  return true;
603  }
604 
605  return false;
606 }
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.

References JSON_SETTINGS_INTERNALS::PointerFromString().

Referenced by FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ SetIfPresent() [2/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
bool &  aTarget 
)
staticinherited

Sets the given bool if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 609 of file json_settings.cpp.

611 {
612  nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
613 
614  if( aObj.contains( ptr ) && aObj.at( ptr ).is_boolean() )
615  {
616  aTarget = aObj.at( ptr ).get<bool>();
617  return true;
618  }
619 
620  return false;
621 }
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [3/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
int &  aTarget 
)
staticinherited

Sets the given int if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 624 of file json_settings.cpp.

626 {
627  nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
628 
629  if( aObj.contains( ptr ) && aObj.at( ptr ).is_number_integer() )
630  {
631  aTarget = aObj.at( ptr ).get<int>();
632  return true;
633  }
634 
635  return false;
636 }
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [4/4]

bool JSON_SETTINGS::SetIfPresent ( const nlohmann::json aObj,
const std::string &  aPath,
unsigned int &  aTarget 
)
staticinherited

Sets the given unsigned int if the given key/path is present.

Parameters
aObjis the source object
aTargetis the storage destination
Returns
True if set, false if not

Definition at line 639 of file json_settings.cpp.

641 {
642  nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
643 
644  if( aObj.contains( ptr ) && aObj.at( ptr ).is_number_unsigned() )
645  {
646  aTarget = aObj.at( ptr ).get<unsigned int>();
647  return true;
648  }
649 
650  return false;
651 }
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetLegacyFilename()

void JSON_SETTINGS::SetLegacyFilename ( const wxString &  aFilename)
inlineinherited

Definition at line 81 of file json_settings.h.

81 { m_legacy_filename = aFilename; }
wxString m_legacy_filename
The filename of the wxConfig legacy file (if different from m_filename)

References JSON_SETTINGS::m_legacy_filename.

Referenced by SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS().

◆ SetLocation()

void JSON_SETTINGS::SetLocation ( SETTINGS_LOC  aLocation)
inlineinherited

Definition at line 78 of file json_settings.h.

78 { m_location = aLocation; }
SETTINGS_LOC m_location
The location of this settings file (.

References JSON_SETTINGS::m_location.

Referenced by COLOR_SETTINGS::COLOR_SETTINGS().

◆ SetManager()

void JSON_SETTINGS::SetManager ( SETTINGS_MANAGER aManager)
inlineinherited

Definition at line 191 of file json_settings.h.

192  {
193  m_manager = aManager;
194  }
SETTINGS_MANAGER * m_manager
A pointer to the settings manager managing this file (may be null)

References JSON_SETTINGS::m_manager.

◆ SetMinHoleSeparation()

void BOARD_DESIGN_SETTINGS::SetMinHoleSeparation ( int  aDistance)
Parameters
aValueThe minimum distance between the edges of two holes or 0 to disable hole-to-hole separation checking.

Definition at line 1057 of file board_design_settings.cpp.

1058 {
1059  m_HoleToHoleMin = aDistance;
1060 }

References m_HoleToHoleMin.

Referenced by PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow().

◆ SetNetClasses()

void BOARD_DESIGN_SETTINGS::SetNetClasses ( NETCLASSES aNetClasses)
inline

Definition at line 248 of file board_design_settings.h.

249  {
250  if( aNetClasses )
251  m_netClasses = aNetClasses;
252  else
254  }
NETCLASSES m_internalNetClasses
Net classes that are loaded from the board file before these were stored in the project.
NETCLASSES * m_netClasses
This will point to m_internalNetClasses until it is repointed to the project after load.

References m_internalNetClasses.

Referenced by BOARD::SetProject().

◆ SetParent()

void NESTED_SETTINGS::SetParent ( JSON_SETTINGS aParent,
bool  aLoadFromFile = true 
)
inherited

Definition at line 152 of file nested_settings.cpp.

153 {
154  m_parent = aParent;
155 
156  if( m_parent )
157  {
158  m_parent->AddNestedSettings( this );
159 
160  // In case we were created after the parent's ctor
161  if( aLoadFromFile )
162  LoadFromFile();
163  }
164 }
bool LoadFromFile(const wxString &aDirectory="") override
Loads the JSON document from the parent and then calls Load()
void AddNestedSettings(NESTED_SETTINGS *aSettings)
Transfers ownership of a given NESTED_SETTINGS to this object.
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.

References JSON_SETTINGS::AddNestedSettings(), NESTED_SETTINGS::LoadFromFile(), and NESTED_SETTINGS::m_parent.

Referenced by BOARD::ClearProject(), NESTED_SETTINGS::NESTED_SETTINGS(), and JSON_SETTINGS::ReleaseNestedSettings().

◆ SetReadOnly()

void JSON_SETTINGS::SetReadOnly ( bool  aReadOnly)
inlineinherited

◆ SetSilkClearance()

void BOARD_DESIGN_SETTINGS::SetSilkClearance ( int  aDistance)

Set the minimum distance between silk items to aValue.

Note
Compound graphics within a single footprint or on the board are not checked, but distances between text and between graphics from different footprints are.
Parameters
aValueThe minimum distance between silk items.

Definition at line 1069 of file board_design_settings.cpp.

1070 {
1071  m_SilkClearance = aDistance;
1072 }

References m_SilkClearance.

◆ SetTrackWidthIndex()

void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex ( unsigned  aIndex)

◆ SetViaSizeIndex()

void BOARD_DESIGN_SETTINGS::SetViaSizeIndex ( unsigned  aIndex)

◆ Store()

bool JSON_SETTINGS::Store ( )
virtualinherited

Stores the current parameters into the JSON document represented by this object Note: this doesn't do any writing to disk; that's handled by SETTINGS_MANAGER.

Returns
true if any part of the JSON document was updated

Definition at line 353 of file json_settings.cpp.

354 {
355  bool modified = false;
356 
357  for( auto param : m_params )
358  {
359  modified |= !param->MatchesFile( this );
360  param->Store( this );
361  }
362 
363  return modified;
364 }
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)

References JSON_SETTINGS::m_params.

Referenced by PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), SETTINGS_MANAGER::SaveColorSettings(), NESTED_SETTINGS::SaveToFile(), and JSON_SETTINGS::SaveToFile().

◆ UseCustomDiffPairDimensions() [1/2]

void BOARD_DESIGN_SETTINGS::UseCustomDiffPairDimensions ( bool  aEnabled)
inline

Enables/disables custom differential pair dimensions.

Parameters
aEnableddecides if custom settings should be used for new differential pairs.

Definition at line 530 of file board_design_settings.h.

531  {
532  m_useCustomDiffPair = aEnabled;
533  }

Referenced by DIFF_PAIR_MENU::eventHandler(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), and DIFF_PAIR_MENU::update().

◆ UseCustomDiffPairDimensions() [2/2]

bool BOARD_DESIGN_SETTINGS::UseCustomDiffPairDimensions ( ) const
inline
Returns
True if custom sizes of diff pairs are enabled, false otherwise.

Definition at line 538 of file board_design_settings.h.

539  {
540  return m_useCustomDiffPair;
541  }

References m_useCustomDiffPair.

◆ UseCustomTrackViaSize() [1/2]

void BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize ( bool  aEnabled)
inline

◆ UseCustomTrackViaSize() [2/2]

bool BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize ( ) const
inline
Returns
True if custom sizes of tracks & vias are enabled, false otherwise.

Definition at line 453 of file board_design_settings.h.

454  {
455  return m_useCustomTrackVia;
456  }

References m_useCustomTrackVia.

◆ UseNetClassDiffPair()

bool BOARD_DESIGN_SETTINGS::UseNetClassDiffPair ( ) const
inline

Return true if netclass values should be used to obtain appropriate diff pair dimensions.

Definition at line 301 of file board_design_settings.h.

302  {
303  return ( m_diffPairIndex == 0 && !m_useCustomDiffPair );
304  }

Referenced by PNS_KICAD_IFACE_BASE::ImportSizes().

◆ UseNetClassTrack()

bool BOARD_DESIGN_SETTINGS::UseNetClassTrack ( ) const
inline

Return true if netclass values should be used to obtain appropriate track width.

Definition at line 285 of file board_design_settings.h.

286  {
287  return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia );
288  }

Referenced by PNS_KICAD_IFACE_BASE::ImportSizes().

◆ UseNetClassVia()

bool BOARD_DESIGN_SETTINGS::UseNetClassVia ( ) const
inline

Return true if netclass values should be used to obtain appropriate via size.

Definition at line 293 of file board_design_settings.h.

294  {
295  return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia );
296  }

Referenced by ROUTER_TOOL::handleLayerSwitch(), and PNS_KICAD_IFACE_BASE::ImportSizes().

Member Data Documentation

◆ m_auxOrigin

wxPoint BOARD_DESIGN_SETTINGS::m_auxOrigin
private

origin for plot exports

Definition at line 772 of file board_design_settings.h.

Referenced by GetAuxOrigin(), and initFromOther().

◆ m_BlindBuriedViaAllowed

◆ m_boardThickness

int BOARD_DESIGN_SETTINGS::m_boardThickness
private

Board thickness for 3D viewer.

Definition at line 794 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), GetBoardThickness(), and initFromOther().

◆ m_CopperEdgeClearance

◆ m_copperLayerCount

int BOARD_DESIGN_SETTINGS::m_copperLayerCount
private

Number of copper layers for this design.

Definition at line 790 of file board_design_settings.h.

Referenced by GetCopperLayerCount(), initFromOther(), SetCopperLayerCount(), and SetEnabledLayers().

◆ m_createIfDefault

bool JSON_SETTINGS::m_createIfDefault
protectedinherited

Whether or not the backing store file should be created if all parameters are still at their default values.

Ignored if m_createIfMissing is false or m_writeFile is false.

Definition at line 302 of file json_settings.h.

Referenced by JSON_SETTINGS::SaveToFile().

◆ m_createIfMissing

bool JSON_SETTINGS::m_createIfMissing
protectedinherited

Whether or not the backing store file should be created it if doesn't exist.

Definition at line 296 of file json_settings.h.

Referenced by JSON_SETTINGS::SaveToFile().

◆ m_currentNetClassName

wxString BOARD_DESIGN_SETTINGS::m_currentNetClassName
private

Current net class name used to display netclass info.

This is also the last used netclass after starting a track.

Definition at line 798 of file board_design_settings.h.

Referenced by GetCurrentMicroViaDrill(), GetCurrentMicroViaSize(), GetCurrentNetClassName(), and initFromOther().

◆ m_CurrentViaType

VIATYPE BOARD_DESIGN_SETTINGS::m_CurrentViaType

(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)

Definition at line 686 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), DRAWING_TOOL::DrawVia(), and initFromOther().

◆ m_customDiffPair

DIFF_PAIR_DIMENSION BOARD_DESIGN_SETTINGS::m_customDiffPair
private

◆ m_customTrackWidth

int BOARD_DESIGN_SETTINGS::m_customTrackWidth
private

◆ m_customViaSize

VIA_DIMENSION BOARD_DESIGN_SETTINGS::m_customViaSize
private

◆ m_DefaultFPTextItems

◆ m_defaultZoneSettings

ZONE_SETTINGS BOARD_DESIGN_SETTINGS::m_defaultZoneSettings
private

The default settings that will be used for new zones.

Definition at line 813 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), GetDefaultZoneSettings(), and initFromOther().

◆ m_deleteLegacyAfterMigration

bool JSON_SETTINGS::m_deleteLegacyAfterMigration
protectedinherited

Whether or not to delete legacy file after migration.

Definition at line 308 of file json_settings.h.

Referenced by JSON_SETTINGS::LoadFromFile(), PROJECT_FILE::PROJECT_FILE(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ m_DiffPairDimensionsList

◆ m_diffPairIndex

unsigned BOARD_DESIGN_SETTINGS::m_diffPairIndex
private

◆ m_DimensionArrowLength

◆ m_DimensionExtensionOffset

◆ m_DimensionKeepTextAligned

◆ m_DimensionPrecision

int BOARD_DESIGN_SETTINGS::m_DimensionPrecision

◆ m_DimensionSuppressZeroes

◆ m_DimensionTextPosition

◆ m_DimensionUnitsFormat

◆ m_DimensionUnitsMode

◆ m_DRCEngine

◆ m_DrcExclusions

std::set<wxString> BOARD_DESIGN_SETTINGS::m_DrcExclusions

◆ m_DRCSeverities

◆ m_enabledLayers

LSET BOARD_DESIGN_SETTINGS::m_enabledLayers
private

Bit-mask for layer enabling.

Definition at line 792 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), GetEnabledLayers(), initFromOther(), SetCopperLayerCount(), and SetEnabledLayers().

◆ m_filename

◆ m_gridOrigin

wxPoint BOARD_DESIGN_SETTINGS::m_gridOrigin
private

origin for grid offsets

Definition at line 773 of file board_design_settings.h.

Referenced by GetGridOrigin(), and initFromOther().

◆ m_HasStackup

◆ m_HoleClearance

◆ m_HoleToHoleMin

◆ m_internalNetClasses

NETCLASSES BOARD_DESIGN_SETTINGS::m_internalNetClasses
private

Net classes that are loaded from the board file before these were stored in the project.

Definition at line 807 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), initFromOther(), and SetNetClasses().

◆ m_internals

◆ m_legacy_filename

wxString JSON_SETTINGS::m_legacy_filename
protectedinherited

The filename of the wxConfig legacy file (if different from m_filename)

Definition at line 284 of file json_settings.h.

Referenced by JSON_SETTINGS::LoadFromFile(), and JSON_SETTINGS::SetLegacyFilename().

◆ m_LineThickness

◆ m_location

SETTINGS_LOC JSON_SETTINGS::m_location
protectedinherited

The location of this settings file (.

See also
SETTINGS_LOC)

Definition at line 287 of file json_settings.h.

Referenced by JSON_SETTINGS::GetLocation(), and JSON_SETTINGS::SetLocation().

◆ m_manager

SETTINGS_MANAGER* JSON_SETTINGS::m_manager
protectedinherited

A pointer to the settings manager managing this file (may be null)

Definition at line 317 of file json_settings.h.

Referenced by FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), and JSON_SETTINGS::SetManager().

◆ m_MaxError

◆ m_MicroViasAllowed

◆ m_MicroViasMinDrill

◆ m_MicroViasMinSize

◆ m_migrators

std::map<int, std::pair<int, std::function<bool()> > > JSON_SETTINGS::m_migrators
protectedinherited

A map of starting schema version to a pair of <ending version, migrator function>

Definition at line 320 of file json_settings.h.

Referenced by JSON_SETTINGS::Migrate(), and JSON_SETTINGS::registerMigration().

◆ m_MinClearance

◆ m_MinThroughDrill

◆ m_nested_settings

std::vector<NESTED_SETTINGS*> JSON_SETTINGS::m_nested_settings
protectedinherited

Nested settings files that live inside this one, if any.

Definition at line 293 of file json_settings.h.

Referenced by JSON_SETTINGS::AddNestedSettings(), JSON_SETTINGS::LoadFromFile(), JSON_SETTINGS::ReleaseNestedSettings(), and JSON_SETTINGS::SaveToFile().

◆ m_netClasses

NETCLASSES* BOARD_DESIGN_SETTINGS::m_netClasses
private

This will point to m_internalNetClasses until it is repointed to the project after load.

Definition at line 810 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), GetNetClasses(), and initFromOther().

◆ m_Pad_Master

◆ m_params

◆ m_parent

◆ m_path

std::string NESTED_SETTINGS::m_path
protectedinherited

The path (in pointer format) of where to store this document in the parent.

Definition at line 65 of file nested_settings.h.

Referenced by NESTED_SETTINGS::LoadFromFile(), and NESTED_SETTINGS::SaveToFile().

◆ m_resetParamsIfMissing

bool JSON_SETTINGS::m_resetParamsIfMissing
protectedinherited

Whether or not to set parameters to their default value if missing from JSON on Load()

Definition at line 311 of file json_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), and JSON_SETTINGS::Load().

◆ m_schemaVersion

int JSON_SETTINGS::m_schemaVersion
protectedinherited

◆ m_SilkClearance

◆ m_SolderMaskMargin

◆ m_SolderMaskMinWidth

◆ m_SolderPasteMargin

◆ m_SolderPasteMarginRatio

◆ m_stackup

BOARD_STACKUP BOARD_DESIGN_SETTINGS::m_stackup
private

the description of layers stackup, for board fabrication only physical layers are in layers stackup.

It includes not only layers enabled for the board edition, but also dielectric layers

Definition at line 804 of file board_design_settings.h.

Referenced by GetStackupDescriptor(), and initFromOther().

◆ m_TempOverrideTrackWidth

◆ m_TextItalic

◆ m_TextSize

◆ m_TextThickness

◆ m_TextUpright

◆ m_TrackMinWidth

◆ m_trackWidthIndex

unsigned BOARD_DESIGN_SETTINGS::m_trackWidthIndex
private

◆ m_TrackWidthList

◆ m_UseConnectedTrackWidth

◆ m_useCustomDiffPair

◆ m_useCustomTrackVia

◆ m_UseHeightForLengthCalcs

bool BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs

◆ m_ViasDimensionsList

◆ m_viaSizeIndex

unsigned BOARD_DESIGN_SETTINGS::m_viaSizeIndex
private

◆ m_ViasMinAnnularWidth

◆ m_ViasMinSize

◆ m_writeFile

bool JSON_SETTINGS::m_writeFile
protectedinherited

◆ m_ZoneFillVersion

int BOARD_DESIGN_SETTINGS::m_ZoneFillVersion

Option to select different fill algorithms.

There are currently two supported values: 5:

  • Use thick outlines around filled polygons (gives smoothest shape but at the expense of processing time and slight infidelity when exporting)
  • Use zone outline when knocking out higher-priority zones (just wrong, but mimics legacy behavior. 6:
  • No thick outline.
  • Use filled areas when knocking out higher-priority zones.

Definition at line 721 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), ZONE_FILLER::buildCopperItemClearances(), ZONE_FILLER::Fill(), KI_TEST::FillZones(), initFromOther(), PCB_PARSER::parseSetup(), PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow(), and PANEL_SETUP_CONSTRAINTS::TransferDataToWindow().

◆ m_ZoneKeepExternalFillets


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