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
 
TEARDROP_PARAMETERS_LISTGetTeadropParamsList ()
 
SEVERITY GetSeverity (int aDRCErrorCode)
 
bool Ignore (int aDRCErrorCode)
 Return true if the DRC error code's severity is SEVERITY_IGNORE. More...
 
ZONE_SETTINGSGetDefaultZoneSettings ()
 
void SetDefaultZoneSettings (const ZONE_SETTINGS &aSettings)
 
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
 
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
 
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
 The full thickness of the board including copper and masks. More...
 
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...
 
VECTOR2I 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 VECTOR2I &aOrigin)
 
const VECTOR2IGetAuxOrigin ()
 
void SetGridOrigin (const VECTOR2I &aOrigin)
 
const VECTOR2IGetGridOrigin ()
 
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
 
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...
 
std::optional< 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 >
std::optional< ValueType > Get (const std::string &aPath) const
 Fetches a value from within the JSON document. More...
 
template<>
std::optional< 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)
 
const std::string FormatAsString () const
 
bool LoadFromRawFile (const wxString &aPath)
 

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
 
TEARDROP_PARAMETERS_LIST m_TeardropParamsList
 The parameters of teardrops for the different teardrop targets (via/pad, track end) 3 set of parameters always exist: for round shapes, for rect shapes, for track ends. More...
 
VIATYPE m_CurrentViaType
 (VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA) More...
 
bool m_UseConnectedTrackWidth
 
bool m_TempOverrideTrackWidth
 
int m_MinClearance
 
int m_MinConn
 
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
 
int m_MinResolvedSpokes
 
int m_MinSilkTextHeight
 
int m_MinSilkTextThickness
 
std::shared_ptr< DRC_ENGINEm_DRCEngine
 
std::map< int, SEVERITYm_DRCSeverities
 
std::set< wxString > m_DrcExclusions
 
bool m_ZoneKeepExternalFillets
 
int m_MaxError
 
int m_SolderMaskExpansion
 
int m_SolderMaskMinWidth
 
int m_SolderMaskToCopperClearance
 
int m_SolderPasteMargin
 
double m_SolderPasteMarginRatio
 
bool m_AllowSoldermaskBridgesInFPs
 
std::shared_ptr< NET_SETTINGSm_NetSettings
 
std::vector< TEXT_ITEM_INFOm_DefaultFPTextItems
 
int m_LineThickness [LAYER_CLASS_COUNT]
 
VECTOR2I 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
 
DIM_PRECISION 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
 

Static Protected Member Functions

template<typename ResultType >
static ResultType fetchOrDefault (const nlohmann::json &aJson, const std::string &aKey, ResultType aDefault=ResultType())
 Helper to retrieve a value from a JSON object (dictionary) as a certain result type. More...
 

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

VECTOR2I m_auxOrigin
 origin for plot exports More...
 
VECTOR2I 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...
 
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 222 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 41 of file board_design_settings.cpp.

41 :
42 NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aParent, aPath )
43{
44 // We want to leave alone parameters that aren't found in the project JSON as they may be
45 // initialized by the board file parser before NESTED_SETTINGS::LoadFromFile is called.
47
48 // Create a default NET_SETTINGS so that things don't break horribly if there's no project
49 // loaded. This also is used during file load for legacy boards that have netclasses stored
50 // in the file. After load, this information will be moved to the project and the pointer
51 // updated.
52 m_NetSettings = std::make_shared<NET_SETTINGS>( nullptr, "" );
53
54 m_HasStackup = false; // no stackup defined by default
55
56 m_Pad_Master = std::make_unique<PAD>( nullptr );
57
58 LSET all_set = LSET().set();
59 m_enabledLayers = all_set; // All layers enabled at first.
60 // SetCopperLayerCount() will adjust this.
61
62 SetCopperLayerCount( 2 ); // Default design is a double sided board
64
65 // if true, when creating a new track starting on an existing track, use this track width
68
69 // First is always the reference designator
70 m_DefaultFPTextItems.emplace_back( wxT( "REF**" ), true, F_SilkS );
71 // Second is always the value
72 m_DefaultFPTextItems.emplace_back( wxT( "" ), true, F_Fab );
73 // Any following ones are freebies
74 m_DefaultFPTextItems.emplace_back( wxT( "${REFERENCE}" ), true, F_Fab );
75
82
89
90 // Edges & Courtyards; text properties aren't used but better to have them holding
91 // reasonable values than not.
98
105
110 m_TextItalic[ LAYER_CLASS_FAB ] = false;
112
119
128
129 m_useCustomTrackVia = false;
133
134 m_useCustomDiffPair = false;
138
154
155 for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode )
156 m_DRCSeverities[ errorCode ] = RPT_SEVERITY_ERROR;
157
159
163
166
169
171
176
182
184
187
189
193
194 // Global mask margins:
198
199 // Solder paste margin absolute value
201 // Solder paste margin as a ratio of pad size
202 // The final margin is the sum of these 2 values
203 // Usually < 0 because the mask is smaller than pad
205
207
208 // Layer thickness for 3D viewer
210
211 m_viaSizeIndex = 0;
213 m_diffPairIndex = 0;
214
215 // Parameters stored in JSON in the project file
216
217 // NOTE: Previously, BOARD_DESIGN_SETTINGS stored the basic board layer information (layer
218 // names and enable/disable state) in the project file even though this information is also
219 // stored in the board file. This was implemented for importing these settings from another
220 // project. Going forward, the import feature will just import from other board files (since
221 // we could have multi-board projects in the future anyway) so this functionality is dropped.
222
223
224 m_params.emplace_back( new PARAM<bool>( "rules.use_height_for_length_calcs",
225 &m_UseHeightForLengthCalcs, true ) );
226
227 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_clearance",
230
231 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_connection",
233 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
234
235 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_track_width",
238
239 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_annular_width",
242
243 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_via_diameter",
246
247 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_through_hole_diameter",
250
251 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_diameter",
254
255 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_microvia_drill",
258
259 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_to_hole",
262
263 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_hole_clearance",
265 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
266
267 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_silk_clearance",
269 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
270
271 // While the maximum *effective* value is 4, we've had users interpret this as the count on
272 // all layers, and enter something like 10. They'll figure it out soon enough *unless* we
273 // enforce a max of 4 (and therefore reset it back to the default of 2), at which point it
274 // just looks buggy.
275 m_params.emplace_back( new PARAM<int>( "rules.min_resolved_spokes",
277
278 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_text_height",
280 pcbIUScale.mmToIU( 0.00 ), pcbIUScale.mmToIU( 100.0 ), pcbIUScale.MM_PER_IU ) );
281
282 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_text_thickness",
285
286 // Note: a clearance of -0.01 is a flag indicating we should use the legacy (pre-6.0) method
287 // based on the edge cut thicknesses.
288 m_params.emplace_back( new PARAM_SCALED<int>( "rules.min_copper_edge_clearance",
290 pcbIUScale.mmToIU( -0.01 ), pcbIUScale.mmToIU( 25.0 ), pcbIUScale.MM_PER_IU ) );
291
292 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
293 [&]() -> nlohmann::json
294 {
295 nlohmann::json ret = {};
296
297 for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
298 {
299 wxString name = item.GetSettingsKey();
300 int code = item.GetErrorCode();
301
302 if( name.IsEmpty() || m_DRCSeverities.count( code ) == 0 )
303 continue;
304
305 ret[std::string( name.ToUTF8() )] = SeverityToString( m_DRCSeverities[code] );
306 }
307
308 return ret;
309 },
310 [&]( const nlohmann::json& aJson )
311 {
312 if( !aJson.is_object() )
313 return;
314
315 for( const RC_ITEM& item : DRC_ITEM::GetItemsWithSeverities() )
316 {
317 wxString name = item.GetSettingsKey();
318 std::string key( name.ToUTF8() );
319
320 if( aJson.contains( key ) )
321 m_DRCSeverities[item.GetErrorCode()] = SeverityFromString( aJson[key] );
322 }
323 }, {} ) );
324
325 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drc_exclusions",
326 [&]() -> nlohmann::json
327 {
328 nlohmann::json js = nlohmann::json::array();
329
330 for( const auto& entry : m_DrcExclusions )
331 js.push_back( entry );
332
333 return js;
334 },
335 [&]( const nlohmann::json& aObj )
336 {
337 m_DrcExclusions.clear();
338
339 if( !aObj.is_array() )
340 return;
341
342 for( const nlohmann::json& entry : aObj )
343 {
344 if( entry.empty() )
345 continue;
346
347 m_DrcExclusions.insert( entry.get<wxString>() );
348 }
349 },
350 {} ) );
351
352 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "track_widths",
353 [&]() -> nlohmann::json
354 {
355 nlohmann::json js = nlohmann::json::array();
356
357 for( const int& width : m_TrackWidthList )
358 js.push_back( pcbIUScale.IUTomm( width ) );
359
360 return js;
361 },
362 [&]( const nlohmann::json& aJson )
363 {
364 if( !aJson.is_array() )
365 return;
366
367 m_TrackWidthList.clear();
368
369 for( const nlohmann::json& entry : aJson )
370 {
371 if( entry.empty() )
372 continue;
373
374 m_TrackWidthList.emplace_back( pcbIUScale.mmToIU( entry.get<double>() ) );
375 }
376 },
377 {} ) );
378
379 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "via_dimensions",
380 [&]() -> nlohmann::json
381 {
382 nlohmann::json js = nlohmann::json::array();
383
384 for( const auto& via : m_ViasDimensionsList )
385 {
386 nlohmann::json entry = {};
387
388 entry["diameter"] = pcbIUScale.IUTomm( via.m_Diameter );
389 entry["drill"] = pcbIUScale.IUTomm( via.m_Drill );
390
391 js.push_back( entry );
392 }
393
394 return js;
395 },
396 [&]( const nlohmann::json& aObj )
397 {
398 if( !aObj.is_array() )
399 return;
400
401 m_ViasDimensionsList.clear();
402
403 for( const nlohmann::json& entry : aObj )
404 {
405 if( entry.empty() || !entry.is_object() )
406 continue;
407
408 if( !entry.contains( "diameter" ) || !entry.contains( "drill" ) )
409 continue;
410
411 int diameter = pcbIUScale.mmToIU( entry["diameter"].get<double>() );
412 int drill = pcbIUScale.mmToIU( entry["drill"].get<double>() );
413
414 m_ViasDimensionsList.emplace_back( VIA_DIMENSION( diameter, drill ) );
415 }
416 },
417 {} ) );
418
419 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "diff_pair_dimensions",
420 [&]() -> nlohmann::json
421 {
422 nlohmann::json js = nlohmann::json::array();
423
424 for( const auto& pair : m_DiffPairDimensionsList )
425 {
426 nlohmann::json entry = {};
427
428 entry["width"] = pcbIUScale.IUTomm( pair.m_Width );
429 entry["gap"] = pcbIUScale.IUTomm( pair.m_Gap );
430 entry["via_gap"] = pcbIUScale.IUTomm( pair.m_ViaGap );
431
432 js.push_back( entry );
433 }
434
435 return js;
436 },
437 [&]( const nlohmann::json& aObj )
438 {
439 if( !aObj.is_array() )
440 return;
441
443
444 for( const nlohmann::json& entry : aObj )
445 {
446 if( entry.empty() || !entry.is_object() )
447 continue;
448
449 if( !entry.contains( "width" ) || !entry.contains( "gap" )
450 || !entry.contains( "via_gap" ) )
451 continue;
452
453 int width = pcbIUScale.mmToIU( entry["width"].get<double>() );
454 int gap = pcbIUScale.mmToIU( entry["gap"].get<double>() );
455 int via_gap = pcbIUScale.mmToIU( entry["via_gap"].get<double>() );
456
457 m_DiffPairDimensionsList.emplace_back(
458 DIFF_PAIR_DIMENSION( width, gap, via_gap ) );
459 }
460 },
461 {} ) );
462
463 // Handle options for teardrops (targets and some others):
464 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "teardrop_options",
465 [&]() -> nlohmann::json
466 {
467 nlohmann::json js = nlohmann::json::array();
468 nlohmann::json entry = {};
469
470 entry["td_onviapad"] = m_TeardropParamsList.m_TargetViasPads;
471 entry["td_onpadsmd"] = m_TeardropParamsList.m_TargetPadsWithNoHole;
472 entry["td_ontrackend"] = m_TeardropParamsList.m_TargetTrack2Track;
473 entry["td_onroundshapesonly"] = m_TeardropParamsList.m_UseRoundShapesOnly;
474 entry["td_allow_use_two_tracks"] = m_TeardropParamsList.m_AllowUseTwoTracks;
475 entry["td_curve_segcount"] = m_TeardropParamsList.m_CurveSegCount;
476 entry["td_on_pad_in_zone"] = m_TeardropParamsList.m_TdOnPadsInZones;
477
478 js.push_back( entry );
479
480 return js;
481 },
482 [&]( const nlohmann::json& aObj )
483 {
484 if( !aObj.is_array() )
485 return;
486
487 for( const nlohmann::json& entry : aObj )
488 {
489 if( entry.empty() || !entry.is_object() )
490 continue;
491
492 if( entry.contains( "td_onviapad" ) )
493 m_TeardropParamsList.m_TargetViasPads = entry["td_onviapad"].get<bool>();
494
495 if( entry.contains( "td_onpadsmd" ) )
496 m_TeardropParamsList.m_TargetPadsWithNoHole = entry["td_onpadsmd"].get<bool>();
497
498 if( entry.contains( "td_ontrackend" ) )
499 m_TeardropParamsList.m_TargetTrack2Track = entry["td_ontrackend"].get<bool>();
500
501 if( entry.contains( "td_onroundshapesonly" ) )
502 m_TeardropParamsList.m_UseRoundShapesOnly = entry["td_onroundshapesonly"].get<bool>();
503
504 if( entry.contains( "td_allow_use_two_tracks" ) )
505 m_TeardropParamsList.m_AllowUseTwoTracks = entry["td_allow_use_two_tracks"].get<bool>();
506
507 if( entry.contains( "td_curve_segcount" ) )
508 m_TeardropParamsList.m_CurveSegCount = entry["td_curve_segcount"].get<int>();
509
510 if( entry.contains( "td_on_pad_in_zone" ) )
511 m_TeardropParamsList.m_TdOnPadsInZones = entry["td_on_pad_in_zone"].get<bool>();
512 }
513 },
514 {} ) );
515
516 // Handle parameters (sizes, shape) for each type of teardrop:
517 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "teardrop_parameters",
518 [&]() -> nlohmann::json
519 {
520 nlohmann::json js = nlohmann::json::array();
521
522 for( size_t ii = 0; ii < m_TeardropParamsList.GetParametersCount(); ii++ )
523 {
524 nlohmann::json entry = {};
526
527 entry["td_target_name"] = GetTeardropTargetCanonicalName( (TARGET_TD)ii );
528 entry["td_maxlen"] = pcbIUScale.IUTomm( td_prm->m_TdMaxLen );
529 entry["td_maxheight"] = pcbIUScale.IUTomm( td_prm->m_TdMaxHeight );
530 entry["td_length_ratio"] = td_prm->m_LengthRatio;
531 entry["td_height_ratio"] = td_prm->m_HeightRatio;
532 entry["td_curve_segcount"] = td_prm->m_CurveSegCount;
533 entry["td_width_to_size_filter_ratio"] = td_prm->m_WidthtoSizeFilterRatio;
534
535 js.push_back( entry );
536 }
537
538 return js;
539 },
540 [&]( const nlohmann::json& aObj )
541 {
542 if( !aObj.is_array() )
543 return;
544
545 for( const nlohmann::json& entry : aObj )
546 {
547 if( entry.empty() || !entry.is_object() )
548 continue;
549
550 if( !entry.contains( "td_target_name" ) )
551 continue;
552
553 int idx = GetTeardropTargetTypeFromCanonicalName( entry["td_target_name"].get<std::string>() );
554
555 if( idx >= 0 && idx < 3 )
556 {
558
559 if( entry.contains( "td_maxlen" ) )
560 td_prm->m_TdMaxLen = pcbIUScale.mmToIU( entry["td_maxlen"].get<double>() );
561
562 if( entry.contains( "td_maxheight" ) )
563 td_prm->m_TdMaxHeight = pcbIUScale.mmToIU( entry["td_maxheight"].get<double>() );
564
565 if( entry.contains( "td_length_ratio" ) )
566 td_prm->m_LengthRatio = entry["td_length_ratio"].get<double>();
567
568 if( entry.contains( "td_height_ratio" ) )
569 td_prm->m_HeightRatio = entry["td_height_ratio"].get<double>();
570
571 if( entry.contains( "td_curve_segcount" ) )
572 td_prm->m_CurveSegCount = entry["td_curve_segcount"].get<int>();
573
574 if( entry.contains( "td_width_to_size_filter_ratio" ) )
575 td_prm->m_WidthtoSizeFilterRatio = entry["td_width_to_size_filter_ratio"].get<double>();
576 }
577 }
578 },
579 {} ) );
580
581 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_line_width",
584
585 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_v",
588
589 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_size_h",
592
593 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.silk_text_thickness",
596
597 m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_italic",
598 &m_TextItalic[LAYER_CLASS_SILK], false ) );
599
600 m_params.emplace_back( new PARAM<bool>( "defaults.silk_text_upright",
601 &m_TextUpright[ LAYER_CLASS_SILK ], true ) );
602
603 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_line_width",
606
607 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_v",
610
611 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_size_h",
614
615 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.copper_text_thickness",
618
619 m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_italic",
620 &m_TextItalic[LAYER_CLASS_COPPER], false ) );
621
622 m_params.emplace_back( new PARAM<bool>( "defaults.copper_text_upright",
624
625 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.board_outline_line_width",
628
629 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.courtyard_line_width",
632
633 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_line_width",
636
637 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_v",
640
641 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_size_h",
644
645 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.fab_text_thickness",
648
649 m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_italic",
650 &m_TextItalic[LAYER_CLASS_FAB], false ) );
651
652 m_params.emplace_back( new PARAM<bool>( "defaults.fab_text_upright",
653 &m_TextUpright[LAYER_CLASS_FAB], true ) );
654
655 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_line_width",
658
659 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_v",
662
663 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_size_h",
666
667 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.other_text_thickness",
670
671 m_params.emplace_back( new PARAM<bool>( "defaults.other_text_italic",
672 &m_TextItalic[LAYER_CLASS_OTHERS], false ) );
673
674 m_params.emplace_back( new PARAM<bool>( "defaults.other_text_upright",
676
677 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_MODE>( "defaults.dimension_units",
680
681 m_params.emplace_back( new PARAM_ENUM<DIM_PRECISION>( "defaults.dimension_precision",
683
684 m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_FORMAT>( "defaults.dimensions.units_format",
687
688 m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.suppress_zeroes",
689 &m_DimensionSuppressZeroes, false ) );
690
691 // NOTE: excluding DIM_TEXT_POSITION::MANUAL from the valid range here
692 m_params.emplace_back( new PARAM_ENUM<DIM_TEXT_POSITION>( "defaults.dimensions.text_position",
695
696 m_params.emplace_back( new PARAM<bool>( "defaults.dimensions.keep_text_aligned",
698
699 m_params.emplace_back( new PARAM<int>( "defaults.dimensions.arrow_length",
702
703 m_params.emplace_back( new PARAM<int>( "defaults.dimensions.extension_offset",
706
707 m_params.emplace_back( new PARAM_SCALED<int>( "defaults.zones.min_clearance",
710
711 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "defaults.pads",
712 [&]() -> nlohmann::json
713 {
714 nlohmann::json ret =
715 {
716 { "width", pcbIUScale.IUTomm( m_Pad_Master->GetSize().x ) },
717 { "height", pcbIUScale.IUTomm( m_Pad_Master->GetSize().y ) },
718 { "drill", pcbIUScale.IUTomm( m_Pad_Master->GetDrillSize().x ) }
719 };
720
721 return ret;
722 },
723 [&]( const nlohmann::json& aJson )
724 {
725 if( aJson.contains( "width" ) && aJson.contains( "height" )
726 && aJson.contains( "drill" ) )
727 {
728 VECTOR2I sz;
729 sz.x = pcbIUScale.mmToIU( aJson["width"].get<double>() );
730 sz.y = pcbIUScale.mmToIU( aJson["height"].get<double>() );
731
732 m_Pad_Master->SetSize( sz );
733
734 int drill = pcbIUScale.mmToIU( aJson["drill"].get<double>() );
735
736 m_Pad_Master->SetDrillSize( VECTOR2I( drill, drill ) );
737 }
738 }, {} ) );
739
740 m_params.emplace_back( new PARAM_SCALED<int>( "rules.max_error",
742
743 m_params.emplace_back( new PARAM_SCALED<int>( "rules.solder_mask_to_copper_clearance",
746
747 m_params.emplace_back( new PARAM<bool>( "zones_allow_external_fillets",
748 &m_ZoneKeepExternalFillets, false ) );
749
751
752 registerMigration( 1, 2,
753 [&]() -> bool
754 {
755 // Schema 1 to 2: move mask and paste margin settings back to board.
756 // The parameters are removed, so we just have to manually load them here and
757 // they will get saved with the board
758 if( std::optional<double> optval = Get<double>( "rules.solder_mask_clearance" ) )
759 m_SolderMaskExpansion = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
760
761 if( std::optional<double> optval = Get<double>( "rules.solder_mask_min_width" ) )
762 m_SolderMaskMinWidth = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
763
764 if( std::optional<double> optval = Get<double>( "rules.solder_paste_clearance" ) )
765 m_SolderPasteMargin = static_cast<int>( *optval * pcbIUScale.IU_PER_MM );
766
767 if( std::optional<double> optval = Get<double>( "rules.solder_paste_margin_ratio" ) )
768 m_SolderPasteMarginRatio = *optval;
769
770 try
771 {
772 At( "rules" ).erase( "solder_mask_clearance" );
773 At( "rules" ).erase( "solder_mask_min_width" );
774 At( "rules" ).erase( "solder_paste_clearance" );
775 At( "rules" ).erase( "solder_paste_margin_ratio" );
776 }
777 catch( ... )
778 {}
779
780 return true;
781 } );
782}
const char * name
Definition: DXF_plotter.cpp:56
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
const int bdsSchemaVersion
#define DEFAULT_MICROVIASMINDRILL
#define DEFAULT_SOLDERPASTE_CLEARANCE
#define DEFAULT_SOLDERPASTE_RATIO
#define DEFAULT_CUSTOMDPAIRWIDTH
#define DEFAULT_VIASMINSIZE
#define DEFAULT_TEXT_WIDTH
#define DEFAULT_COPPER_TEXT_WIDTH
#define DEFAULT_CUSTOMDPAIRGAP
#define DEFAULT_MINCLEARANCE
#define DEFAULT_HOLECLEARANCE
#define DEFAULT_SOLDERMASK_EXPANSION
@ LAYER_CLASS_OTHERS
@ LAYER_CLASS_FAB
@ LAYER_CLASS_COURTYARD
@ LAYER_CLASS_SILK
@ LAYER_CLASS_COPPER
@ LAYER_CLASS_EDGES
#define LEGACY_COPPEREDGECLEARANCE
#define DEFAULT_SOLDERMASK_MIN_WIDTH
#define DEFAULT_DIMENSION_EXTENSION_OFFSET
#define DEFAULT_COPPEREDGECLEARANCE
#define DEFAULT_DIMENSION_ARROW_LENGTH
#define DEFAULT_TRACKMINWIDTH
#define DEFAULT_MINTHROUGHDRILL
#define DEFAULT_SILK_TEXT_SIZE
#define DEFAULT_HOLETOHOLEMIN
#define DEFAULT_MINCONNECTION
#define DEFAULT_COPPER_LINE_WIDTH
#define DEFAULT_SILK_LINE_WIDTH
#define DEFAULT_SILKCLEARANCE
#define DEFAULT_MICROVIASMINSIZE
#define DEFAULT_SILK_TEXT_WIDTH
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_CUSTOMTRACKWIDTH
#define DEFAULT_CUSTOMDPAIRVIAGAP
#define DEFAULT_COPPER_TEXT_SIZE
#define DEFAULT_SOLDERMASK_TO_COPPER_CLEARANCE
#define DEFAULT_LINE_WIDTH
#define DEFAULT_COURTYARD_WIDTH
#define DEFAULT_BOARD_THICKNESS_MM
#define DEFAULT_MINRESOLVEDSPOKES
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
std::vector< TEXT_ITEM_INFO > m_DefaultFPTextItems
VIATYPE m_CurrentViaType
(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
std::shared_ptr< NET_SETTINGS > m_NetSettings
DIM_UNITS_FORMAT m_DimensionUnitsFormat
std::map< int, SEVERITY > m_DRCSeverities
bool m_TextUpright[LAYER_CLASS_COUNT]
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
std::set< wxString > m_DrcExclusions
std::unique_ptr< PAD > m_Pad_Master
TEARDROP_PARAMETERS_LIST m_TeardropParamsList
The parameters of teardrops for the different teardrop targets (via/pad, track end) 3 set of paramete...
int m_boardThickness
Board thickness for 3D viewer.
int m_TextThickness[LAYER_CLASS_COUNT]
ZONE_SETTINGS m_defaultZoneSettings
The default settings that will be used for new zones.
std::vector< int > m_TrackWidthList
DIFF_PAIR_DIMENSION m_customDiffPair
int m_LineThickness[LAYER_CLASS_COUNT]
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
VECTOR2I m_TextSize[LAYER_CLASS_COUNT]
LSET m_enabledLayers
Bit-mask for layer enabling.
bool m_TextItalic[LAYER_CLASS_COUNT]
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
std::vector< VIA_DIMENSION > m_ViasDimensionsList
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition: drc_item.h:122
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
friend class NESTED_SETTINGS
Definition: json_settings.h:62
bool m_resetParamsIfMissing
Whether or not to set parameters to their default value if missing from JSON on Load()
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
Stores an enum as an integer.
Definition: parameters.h:217
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:335
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:75
bool m_TargetPadsWithNoHole
True to create teardrops for pads without holes (SMD and others.
int m_CurveSegCount
the number of segments to apprximate a curve (Bezier curve) in a teardrop Must be > 2,...
bool m_TargetViasPads
True to create teardrops for vias and pads with holes.
bool m_UseRoundShapesOnly
True to create teardrops for round shapes only.
bool m_TargetTrack2Track
True to create teardrops at the end of a track connected to the end of another track having a differe...
bool m_TdOnPadsInZones
Pads inside a zone of the same net do not have teardrop added.
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
TEARDROP_PARAMETERS * GetParameters(TARGET_TD aTdType)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
double m_HeightRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxHeight
max allowed height for teardrops in IU. <= 0 to disable
int m_TdMaxLen
the type of target for these parameters
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
double m_LengthRatio
The length of a teardrop as ratio between length and size of pad/via.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
@ DRCE_SILK_EDGE_CLEARANCE
Definition: drc_item.h:90
@ DRCE_PADSTACK
Definition: drc_item.h:59
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition: drc_item.h:76
@ DRCE_OVERLAPPING_SILK
Definition: drc_item.h:93
@ DRCE_MISSING_COURTYARD
Definition: drc_item.h:62
@ DRCE_ISOLATED_COPPER
Definition: drc_item.h:47
@ DRCE_COPPER_SLIVER
Definition: drc_item.h:84
@ DRCE_PTH_IN_COURTYARD
Definition: drc_item.h:65
@ DRCE_FIRST
Definition: drc_item.h:38
@ DRCE_DANGLING_VIA
Definition: drc_item.h:49
@ DRCE_FOOTPRINT_TYPE_MISMATCH
Definition: drc_item.h:75
@ DRCE_DUPLICATE_FOOTPRINT
Definition: drc_item.h:71
@ DRCE_DANGLING_TRACK
Definition: drc_item.h:50
@ DRCE_TEXT_HEIGHT
Definition: drc_item.h:91
@ DRCE_DRILLED_HOLES_COLOCATED
Definition: drc_item.h:52
@ DRCE_EXTRA_FOOTPRINT
Definition: drc_item.h:72
@ DRCE_SILK_CLEARANCE
Definition: drc_item.h:88
@ DRCE_LAST
Definition: drc_item.h:101
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition: drc_item.h:77
@ DRCE_NET_CONFLICT
Definition: drc_item.h:73
@ DRCE_MISSING_FOOTPRINT
Definition: drc_item.h:70
@ DRCE_TEXT_THICKNESS
Definition: drc_item.h:92
@ DRCE_NPTH_IN_COURTYARD
Definition: drc_item.h:66
@ DRCE_CONNECTION_WIDTH
Definition: drc_item.h:56
nlohmann::json json
Definition: gerbview.cpp:44
@ F_Fab
Definition: layer_ids.h:120
@ F_SilkS
Definition: layer_ids.h:104
@ OUTSIDE
Text appears outside the dimension line (default)
@ INLINE
Text appears in line with the dimension line.
#define TEXTS_MAX_SIZE
Maximum text size in internal units (10 inches)
Definition: pcbnew.h:32
#define TEXTS_MIN_SIZE
Minimum text size in internal units (1 mil)
Definition: pcbnew.h:31
#define TEXTS_MAX_WIDTH
Maximum text width in internal units (10 inches)
Definition: pcbnew.h:33
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
Container to handle a stock of specific differential pairs each with unique track width,...
constexpr double IUTomm(int iu) const
Definition: base_units.h:87
const double IU_PER_MM
Definition: base_units.h:77
const double MM_PER_IU
Definition: base_units.h:79
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
std::string GetTeardropTargetCanonicalName(TARGET_TD aTdType)
TARGET_TD GetTeardropTargetTypeFromCanonicalName(const std::string &aTargetName)
wxString SeverityToString(const SEVERITY &aSeverity)
Definition: ui_common.cpp:59
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
#define ZONE_CLEARANCE_MM
Definition: zones.h:37

References ARC_HIGH_DEF, 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_MINCONNECTION, DEFAULT_MINRESOLVEDSPOKES, DEFAULT_MINTHROUGHDRILL, DEFAULT_SILK_LINE_WIDTH, DEFAULT_SILK_TEXT_SIZE, DEFAULT_SILK_TEXT_WIDTH, DEFAULT_SILKCLEARANCE, DEFAULT_SOLDERMASK_EXPANSION, DEFAULT_SOLDERMASK_MIN_WIDTH, DEFAULT_SOLDERMASK_TO_COPPER_CLEARANCE, DEFAULT_SOLDERPASTE_CLEARANCE, DEFAULT_SOLDERPASTE_RATIO, DEFAULT_TEXT_SIZE, DEFAULT_TEXT_WIDTH, DEFAULT_TRACKMINWIDTH, DEFAULT_VIASMINSIZE, DRCE_CONNECTION_WIDTH, DRCE_COPPER_SLIVER, DRCE_DANGLING_TRACK, DRCE_DANGLING_VIA, DRCE_DRILLED_HOLES_COLOCATED, DRCE_DUPLICATE_FOOTPRINT, DRCE_EXTRA_FOOTPRINT, DRCE_FIRST, DRCE_FOOTPRINT_TYPE_MISMATCH, DRCE_ISOLATED_COPPER, DRCE_LAST, DRCE_LIB_FOOTPRINT_ISSUES, DRCE_LIB_FOOTPRINT_MISMATCH, DRCE_MISSING_COURTYARD, DRCE_MISSING_FOOTPRINT, DRCE_NET_CONFLICT, DRCE_NPTH_IN_COURTYARD, DRCE_OVERLAPPING_SILK, DRCE_PADSTACK, DRCE_PTH_IN_COURTYARD, DRCE_SILK_CLEARANCE, DRCE_SILK_EDGE_CLEARANCE, DRCE_TEXT_HEIGHT, DRCE_TEXT_THICKNESS, F_Fab, F_SilkS, DRC_ITEM::GetItemsWithSeverities(), TEARDROP_PARAMETERS_LIST::GetParameters(), TEARDROP_PARAMETERS_LIST::GetParametersCount(), GetTeardropTargetCanonicalName(), GetTeardropTargetTypeFromCanonicalName(), INCHES, INLINE, EDA_IU_SCALE::IU_PER_MM, EDA_IU_SCALE::IUTomm(), LAYER_CLASS_COPPER, LAYER_CLASS_COURTYARD, LAYER_CLASS_EDGES, LAYER_CLASS_FAB, LAYER_CLASS_OTHERS, LAYER_CLASS_SILK, LEGACY_COPPEREDGECLEARANCE, m_AllowSoldermaskBridgesInFPs, TEARDROP_PARAMETERS_LIST::m_AllowUseTwoTracks, m_boardThickness, m_CopperEdgeClearance, m_CurrentViaType, TEARDROP_PARAMETERS::m_CurveSegCount, TEARDROP_PARAMETERS_LIST::m_CurveSegCount, 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, TEARDROP_PARAMETERS::m_HeightRatio, m_HoleClearance, m_HoleToHoleMin, TEARDROP_PARAMETERS::m_LengthRatio, m_LineThickness, m_MaxError, m_MicroViasMinDrill, m_MicroViasMinSize, m_MinClearance, m_MinConn, m_MinResolvedSpokes, m_MinSilkTextHeight, m_MinSilkTextThickness, m_MinThroughDrill, m_NetSettings, m_Pad_Master, JSON_SETTINGS::m_params, JSON_SETTINGS::m_resetParamsIfMissing, m_SilkClearance, m_SolderMaskExpansion, m_SolderMaskMinWidth, m_SolderMaskToCopperClearance, m_SolderPasteMargin, m_SolderPasteMarginRatio, TEARDROP_PARAMETERS_LIST::m_TargetPadsWithNoHole, TEARDROP_PARAMETERS_LIST::m_TargetTrack2Track, TEARDROP_PARAMETERS_LIST::m_TargetViasPads, TEARDROP_PARAMETERS::m_TdMaxHeight, TEARDROP_PARAMETERS::m_TdMaxLen, TEARDROP_PARAMETERS_LIST::m_TdOnPadsInZones, m_TeardropParamsList, m_TempOverrideTrackWidth, m_TextItalic, m_TextSize, m_TextThickness, m_TextUpright, m_TrackMinWidth, m_trackWidthIndex, m_TrackWidthList, m_UseConnectedTrackWidth, m_useCustomDiffPair, m_useCustomTrackVia, m_UseHeightForLengthCalcs, TEARDROP_PARAMETERS_LIST::m_UseRoundShapesOnly, DIFF_PAIR_DIMENSION::m_ViaGap, m_ViasDimensionsList, m_viaSizeIndex, m_ViasMinAnnularWidth, m_ViasMinSize, DIFF_PAIR_DIMENSION::m_Width, TEARDROP_PARAMETERS::m_WidthtoSizeFilterRatio, ZONE_SETTINGS::m_ZoneClearance, m_ZoneKeepExternalFillets, migrateSchema0to1(), EDA_IU_SCALE::MilsToIU(), EDA_IU_SCALE::MM_PER_IU, EDA_IU_SCALE::mmToIU(), name, NO_SUFFIX, OUTSIDE, PAREN_SUFFIX, pcbIUScale, JSON_SETTINGS::registerMigration(), RPT_SEVERITY_ERROR, RPT_SEVERITY_IGNORE, RPT_SEVERITY_WARNING, SetCopperLayerCount(), SeverityToString(), TEXTS_MAX_SIZE, TEXTS_MAX_WIDTH, TEXTS_MIN_SIZE, THROUGH, V_VVVVV, via, VECTOR2< T >::x, X, X_XXXX, VECTOR2< T >::y, and ZONE_CLEARANCE_MM.

◆ ~BOARD_DESIGN_SETTINGS()

BOARD_DESIGN_SETTINGS::~BOARD_DESIGN_SETTINGS ( )
virtual

Definition at line 785 of file board_design_settings.cpp.

786{
787 if( m_parent )
788 {
790 m_parent = nullptr;
791 }
792}
void ReleaseNestedSettings(NESTED_SETTINGS *aSettings)
Saves and frees a nested settings object, if it exists within this one.
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.

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 795 of file board_design_settings.cpp.

795 :
796 NESTED_SETTINGS( "board_design_settings", bdsSchemaVersion, aOther.m_parent,
797 aOther.m_path ),
798 m_Pad_Master( nullptr )
799{
800 initFromOther( aOther );
801}
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 790 of file json_settings.cpp.

791{
792 wxLogTrace( traceSettings, wxT( "AddNestedSettings %s" ), aSettings->GetFilename() );
793 m_nested_settings.push_back( aSettings );
794}
std::vector< NESTED_SETTINGS * > m_nested_settings
Nested settings files that live inside this one, if any.
wxString GetFilename() const
Definition: json_settings.h:73
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 EESCHEMA_SETTINGS::migrateBomSettings(), GERBVIEW_SETTINGS::MigrateFromLegacy(), APP_SETTINGS_BASE::migrateLibTreeWidth(), migrateSchema0to1(), FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1(), COLOR_SETTINGS::migrateSchema0to1(), PCBNEW_SETTINGS::PCBNEW_SETTINGS(), and PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS().

◆ Contains()

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

◆ fetchOrDefault()

template<typename ResultType >
template bool JSON_SETTINGS::fetchOrDefault ( const nlohmann::json aJson,
const std::string &  aKey,
ResultType  aDefault = ResultType() 
)
staticprotectedinherited

Helper to retrieve a value from a JSON object (dictionary) as a certain result type.

Template Parameters
ResultTypeis the type of the retrieved value.
Parameters
aJsonis the object to act on .
aKeyis the object key to retrieve the value for.
Returns
the result, or aDefault if aKey is not found.

Definition at line 849 of file json_settings.cpp.

851{
852 ResultType ret = aDefault;
853
854 try
855 {
856 if( aJson.contains( aKey ) )
857 ret = aJson.at( aKey ).get<ResultType>();
858 }
859 catch( ... )
860 {
861 }
862
863 return ret;
864}

◆ FormatAsString()

const std::string JSON_SETTINGS::FormatAsString ( ) const
inherited

Definition at line 478 of file json_settings.cpp.

479{
481
482 std::stringstream buffer;
483 buffer << std::setw( 2 ) << *m_internals << std::endl;
484
485 return buffer.str();
486}
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
std::vector< FAB_LAYER_COLOR > dummy

References dummy, and JSON_SETTINGS::m_internals.

Referenced by ROUTER_TOOL::saveRouterDebugLog().

◆ 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 702 of file json_settings.cpp.

704{
705 ValueType val;
706
707 if( aConfig->Read( aKey, &val ) )
708 {
709 try
710 {
711 ( *m_internals )[aDest] = val;
712 }
713 catch( ... )
714 {
715 wxASSERT_MSG( false, wxT( "Could not write value in fromLegacy!" ) );
716 return false;
717 }
718
719 return true;
720 }
721
722 return false;
723}

◆ 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 762 of file json_settings.cpp.

764{
765 wxString str;
766
767 if( aConfig->Read( aKey, &str ) )
768 {
770 color.SetFromWxString( str );
771
772 try
773 {
774 nlohmann::json js = nlohmann::json::array( { color.r, color.g, color.b, color.a } );
775 ( *m_internals )[aDest] = js;
776 }
777 catch( ... )
778 {
779 wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyColor!" ) );
780 return false;
781 }
782
783 return true;
784 }
785
786 return false;
787}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102

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 738 of file json_settings.cpp.

740{
741 wxString str;
742
743 if( aConfig->Read( aKey, &str ) )
744 {
745 try
746 {
747 ( *m_internals )[aDest] = str.ToUTF8();
748 }
749 catch( ... )
750 {
751 wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyString!" ) );
752 return false;
753 }
754
755 return true;
756 }
757
758 return false;
759}

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

◆ Get() [1/2]

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

Definition at line 820 of file json_settings.cpp.

821{
822 if( std::optional<nlohmann::json> opt_json = GetJson( aPath ) )
823 return wxString( opt_json->get<std::string>().c_str(), wxConvUTF8 );
824
825 return std::nullopt;
826}
std::optional< 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....

References JSON_SETTINGS::GetJson().

◆ Get() [2/2]

template<typename ValueType >
template std::optional< 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 541 of file json_settings.cpp.

542{
543 if( std::optional<nlohmann::json> ret = GetJson( aPath ) )
544 {
545 try
546 {
547 return ret->get<ValueType>();
548 }
549 catch( ... )
550 {
551 }
552 }
553
554 return std::nullopt;
555}

References JSON_SETTINGS::GetJson().

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

◆ GetAuxOrigin()

◆ GetBiggestClearanceValue()

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

Definition at line 1029 of file board_design_settings.cpp.

1030{
1031 int biggest = 0;
1032 DRC_CONSTRAINT constraint;
1033
1034 if( m_DRCEngine )
1035 {
1036 m_DRCEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, constraint );
1037 biggest = std::max( biggest, constraint.Value().Min() );
1038
1039 m_DRCEngine->QueryWorstConstraint( HOLE_CLEARANCE_CONSTRAINT, constraint );
1040 biggest = std::max( biggest, constraint.Value().Min() );
1041
1042 m_DRCEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, constraint );
1043 biggest = std::max( biggest, constraint.Value().Min() );
1044
1045 m_DRCEngine->QueryWorstConstraint( HOLE_TO_HOLE_CONSTRAINT, constraint );
1046 biggest = std::max( biggest, constraint.Value().Min() );
1047 }
1048
1049 return biggest;
1050}
std::shared_ptr< DRC_ENGINE > m_DRCEngine
MINOPTMAX< int > & Value()
Definition: drc_rule.h:142
T Min() const
Definition: minoptmax.h:33
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:50
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:47
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:48
@ HOLE_TO_HOLE_CONSTRAINT
Definition: drc_rule.h:49

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

Referenced by ZONE_FILLER::buildThermalSpokes(), ZONE_FILLER::Fill(), PNS_KICAD_IFACE_BASE::SyncWorld(), FOOTPRINT::ViewBBox(), PAD::ViewBBox(), and PCB_TRACK::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 1147 of file board_design_settings.cpp.

1148{
1150 {
1151 return m_customDiffPair.m_Gap;
1152 }
1153 else if( m_diffPairIndex == 0 )
1154 {
1155 if( m_NetSettings->m_DefaultNetClass->HasDiffPairGap() )
1156 return m_NetSettings->m_DefaultNetClass->GetDiffPairGap();
1157 else
1158 return m_NetSettings->m_DefaultNetClass->GetClearance();
1159 }
1160 else
1161 {
1163 }
1164}

References m_customDiffPair, m_DiffPairDimensionsList, m_diffPairIndex, DIFF_PAIR_DIMENSION::m_Gap, m_NetSettings, 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 1167 of file board_design_settings.cpp.

1168{
1170 {
1172 }
1173 else if( m_diffPairIndex == 0 )
1174 {
1175 if( m_NetSettings->m_DefaultNetClass->HasDiffPairViaGap() )
1176 return m_NetSettings->m_DefaultNetClass->GetDiffPairViaGap();
1177 else
1178 return GetCurrentDiffPairGap();
1179 }
1180 else
1181 {
1183 }
1184}

References GetCurrentDiffPairGap(), m_customDiffPair, m_DiffPairDimensionsList, m_diffPairIndex, m_NetSettings, 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 1127 of file board_design_settings.cpp.

1128{
1130 {
1132 }
1133 else if( m_diffPairIndex == 0 )
1134 {
1135 if( m_NetSettings->m_DefaultNetClass->HasDiffPairWidth() )
1136 return m_NetSettings->m_DefaultNetClass->GetDiffPairWidth();
1137 else
1138 return m_NetSettings->m_DefaultNetClass->GetTrackWidth();
1139 }
1140 else
1141 {
1143 }
1144}

References m_customDiffPair, m_DiffPairDimensionsList, m_diffPairIndex, m_NetSettings, m_useCustomDiffPair, and DIFF_PAIR_DIMENSION::m_Width.

Referenced by PNS_KICAD_IFACE_BASE::ImportSizes().

◆ GetCurrentNetClassName()

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

Definition at line 263 of file board_design_settings.h.

264 {
266 }
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 1104 of file board_design_settings.cpp.

1105{
1107 return m_customTrackWidth;
1108 else if( m_trackWidthIndex == 0 )
1109 return m_NetSettings->m_DefaultNetClass->GetTrackWidth();
1110 else
1112}

References m_customTrackWidth, m_NetSettings, 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 1082 of file board_design_settings.cpp.

1083{
1084 int drill;
1085
1087 drill = m_customViaSize.m_Drill;
1088 else if( m_viaSizeIndex == 0 )
1089 drill = m_NetSettings->m_DefaultNetClass->GetViaDrill();
1090 else
1091 drill = m_ViasDimensionsList[ m_viaSizeIndex ].m_Drill;
1092
1093 return drill > 0 ? drill : -1;
1094}

References m_customViaSize, VIA_DIMENSION::m_Drill, m_NetSettings, 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 1071 of file board_design_settings.cpp.

1072{
1075 else if( m_viaSizeIndex == 0 )
1076 return m_NetSettings->m_DefaultNetClass->GetViaDiameter();
1077 else
1078 return m_ViasDimensionsList[ m_viaSizeIndex ].m_Diameter;
1079}

References m_customViaSize, VIA_DIMENSION::m_Diameter, m_NetSettings, 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 477 of file board_design_settings.h.

478 {
479 return m_customDiffPair.m_Gap;
480 }

References m_customDiffPair, and DIFF_PAIR_DIMENSION::m_Gap.

◆ GetCustomDiffPairViaGap()

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

Definition at line 496 of file board_design_settings.h.

References m_customDiffPair, DIFF_PAIR_DIMENSION::m_Gap, and DIFF_PAIR_DIMENSION::m_ViaGap.

◆ GetCustomDiffPairWidth()

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

Definition at line 458 of file board_design_settings.h.

459 {
461 }

References m_customDiffPair, and DIFF_PAIR_DIMENSION::m_Width.

◆ GetCustomTrackWidth()

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

Definition at line 337 of file board_design_settings.h.

338 {
339 return m_customTrackWidth;
340 }

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 408 of file board_design_settings.h.

409 {
411 }

References m_customViaSize, and VIA_DIMENSION::m_Drill.

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 380 of file board_design_settings.h.

381 {
383 }

References m_customViaSize, and VIA_DIMENSION::m_Diameter.

Referenced by DIALOG_TRACK_VIA_SIZE::TransferDataToWindow().

◆ GetDefaultZoneSettings()

◆ GetDiffPairIndex()

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

Definition at line 437 of file board_design_settings.h.

437{ return m_diffPairIndex; }

References m_diffPairIndex.

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

◆ GetDRCEpsilon()

◆ 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 543 of file board_design_settings.h.

544 {
545 return m_enabledLayers;
546 }

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 DATABASE_LIB_SETTINGS, PROJECT_FILE, and PROJECT_LOCAL_SETTINGS.

Definition at line 275 of file json_settings.h.

276 {
277 return wxT( "json" );
278 }

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}
virtual wxString getFileExt() const

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

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

◆ GetGridOrigin()

const VECTOR2I & 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 1236 of file board_design_settings.cpp.

1237{
1238 return pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_HoleWallThickness );
1239}

References ADVANCED_CFG::GetCfg(), EDA_IU_SCALE::mmToIU(), and pcbIUScale.

Referenced by KIGFX::PCB_PAINTER::Draw(), and BOARD_ADAPTER::GetHolePlatingThickness().

◆ GetJson()

std::optional< 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 521 of file json_settings.cpp.

522{
523 nlohmann::json::json_pointer ptr = m_internals->PointerFromString( aPath );
524
525 if( m_internals->contains( ptr ) )
526 {
527 try
528 {
529 return std::optional<nlohmann::json>{ m_internals->at( ptr ) };
530 }
531 catch( ... )
532 {
533 }
534 }
535
536 return std::optional<nlohmann::json>{};
537}

References JSON_SETTINGS::m_internals.

Referenced by JSON_SETTINGS::Get(), PARAM_LAMBDA< ValueType >::Load(), PARAM_LIST< Type >::Load(), PARAM_SET< Type >::Load(), PARAM_MAP< Value >::Load(), PARAM_LAMBDA< ValueType >::MatchesFile(), PARAM_LIST< Type >::MatchesFile(), PARAM_SET< Type >::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 1213 of file board_design_settings.cpp.

1214{
1215 if( aLayer == F_SilkS || aLayer == B_SilkS )
1216 return LAYER_CLASS_SILK;
1217 else if( IsCopperLayer( aLayer ) )
1218 return LAYER_CLASS_COPPER;
1219 else if( aLayer == Edge_Cuts )
1220 return LAYER_CLASS_EDGES;
1221 else if( aLayer == F_CrtYd || aLayer == B_CrtYd )
1222 return LAYER_CLASS_COURTYARD;
1223 else if( aLayer == F_Fab || aLayer == B_Fab )
1224 return LAYER_CLASS_FAB;
1225 else
1226 return LAYER_CLASS_OTHERS;
1227}
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:827
@ F_CrtYd
Definition: layer_ids.h:117
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_CrtYd
Definition: layer_ids.h:116
@ B_SilkS
Definition: layer_ids.h:103
@ B_Fab
Definition: layer_ids.h:119

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 CONVERT_TOOL::CreatePolys(), 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 280 of file json_settings.h.

281 {
282 return wxEmptyString;
283 }

Referenced by JSON_SETTINGS::LoadFromFile().

◆ GetLineThickness()

◆ GetLocation()

SETTINGS_LOC JSON_SETTINGS::GetLocation ( ) const
inlineinherited

Definition at line 80 of file json_settings.h.

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

References JSON_SETTINGS::m_location.

Referenced by SETTINGS_MANAGER::GetPathForSettingsFile().

◆ GetParent()

JSON_SETTINGS * NESTED_SETTINGS::GetParent ( void  )
inlineinherited

Definition at line 54 of file nested_settings.h.

55 {
56 return m_parent;
57 }

References NESTED_SETTINGS::m_parent.

Referenced by LoadFromFile().

◆ GetSeverity()

SEVERITY BOARD_DESIGN_SETTINGS::GetSeverity ( int  aDRCErrorCode)

◆ GetSmallestClearanceValue()

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

Definition at line 1053 of file board_design_settings.cpp.

1054{
1055 int clearance = m_NetSettings->m_DefaultNetClass->GetClearance();
1056
1057 for( const auto& [ name, netclass ] : m_NetSettings->m_NetClasses )
1058 clearance = std::min( clearance, netclass->GetClearance() );
1059
1060 return clearance;
1061}

References m_NetSettings, and name.

Referenced by DIALOG_PLOT::init_Dialog().

◆ GetStackupDescriptor() [1/2]

◆ GetStackupDescriptor() [2/2]

const BOARD_STACKUP & BOARD_DESIGN_SETTINGS::GetStackupDescriptor ( ) const
inline

Definition at line 236 of file board_design_settings.h.

236{ return m_stackup; }

References m_stackup.

◆ GetTeadropParamsList()

TEARDROP_PARAMETERS_LIST * BOARD_DESIGN_SETTINGS::GetTeadropParamsList ( )
inline

◆ GetTextItalic()

◆ GetTextSize()

◆ GetTextThickness()

int BOARD_DESIGN_SETTINGS::GetTextThickness ( PCB_LAYER_ID  aLayer) const

◆ GetTextUpright()

◆ 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 1023 of file board_design_settings.cpp.

1024{
1025 return m_DRCSeverities[ aDRCErrorCode ] == RPT_SEVERITY_IGNORE;
1026}

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 811 of file board_design_settings.cpp.

812{
813 // Copy of NESTED_SETTINGS around is not allowed, so let's just update the params.
820 m_MinConn = aOther.m_MinConn;
836 m_MaxError = aOther.m_MaxError;
843
844 std::copy( std::begin( aOther.m_LineThickness ), std::end( aOther.m_LineThickness ),
845 std::begin( m_LineThickness ) );
846
847 std::copy( std::begin( aOther.m_TextSize ), std::end( aOther.m_TextSize ),
848 std::begin( m_TextSize ) );
849
850 std::copy( std::begin( aOther.m_TextThickness ), std::end( aOther.m_TextThickness ),
851 std::begin( m_TextThickness ) );
852
853 std::copy( std::begin( aOther.m_TextItalic ), std::end( aOther.m_TextItalic ),
854 std::begin( m_TextItalic ) );
855
856 std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ),
857 std::begin( m_TextUpright ) );
858
867
868 m_auxOrigin = aOther.m_auxOrigin;
869 m_gridOrigin = aOther.m_gridOrigin;
870 m_HasStackup = aOther.m_HasStackup;
872
885 m_stackup = aOther.m_stackup;
887 m_Pad_Master = std::make_unique<PAD>( *aOther.m_Pad_Master );
889}

References m_auxOrigin, 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_LineThickness, m_MaxError, m_MicroViasMinDrill, m_MicroViasMinSize, m_MinClearance, m_MinConn, m_MinSilkTextHeight, m_MinSilkTextThickness, m_MinThroughDrill, m_NetSettings, m_Pad_Master, m_SilkClearance, m_SolderMaskExpansion, m_SolderMaskMinWidth, m_SolderMaskToCopperClearance, 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, and m_ZoneKeepExternalFillets.

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

◆ Internals()

JSON_SETTINGS_INTERNALS * JSON_SETTINGS::Internals ( )
inherited

Definition at line 123 of file json_settings.cpp.

124{
125 return m_internals.get();
126}

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 561 of file board_design_settings.h.

562 {
563 if( aLayerId >= 0 && aLayerId < PCB_LAYER_ID_COUNT )
564 return m_enabledLayers[aLayerId];
565
566 return false;
567 }
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137

References m_enabledLayers, and PCB_LAYER_ID_COUNT.

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

◆ IsReadOnly()

◆ Load()

◆ 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 943 of file board_design_settings.cpp.

944{
945 bool ret = NESTED_SETTINGS::LoadFromFile( aDirectory );
946
947 // A number of things won't have been translated by the PROJECT_FILE migration because of
948 // descoped objects required to decode this data. So, it will be in the legacy.pcbnew
949 // section and needs to be pulled out here
950
951 PROJECT_FILE* project = dynamic_cast<PROJECT_FILE*>( GetParent() );
952
953 if( !project )
954 return ret;
955
956 bool migrated = false;
957
958 auto drcName =
959 []( int aCode ) -> std::string
960 {
961 std::shared_ptr<DRC_ITEM> item = DRC_ITEM::Create( aCode );
962 wxString name = item->GetSettingsKey();
963 return std::string( name.ToUTF8() );
964 };
965
966 const std::string rs = "rule_severities.";
967 const std::string no_courtyard_key = "legacy_no_courtyard_defined";
968 const std::string courtyard_overlap_key = "legacy_courtyards_overlap";
969
970 try
971 {
972 nlohmann::json& severities =
973 project->Internals()->at( "/board/design_settings/rule_severities"_json_pointer );
974
975 if( severities.contains( no_courtyard_key ) )
976 {
977 if( severities[no_courtyard_key].get<bool>() )
978 Set( rs + drcName( DRCE_MISSING_COURTYARD ), "error" );
979 else
980 Set( rs + drcName( DRCE_MISSING_COURTYARD ), "ignore" );
981
982 severities.erase( no_courtyard_key );
983 migrated = true;
984 }
985
986 if( severities.contains( courtyard_overlap_key ) )
987 {
988 if( severities[courtyard_overlap_key].get<bool>() )
989 Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "error" );
990 else
991 Set( rs + drcName( DRCE_OVERLAPPING_FOOTPRINTS ), "ignore" );
992
993 severities.erase( courtyard_overlap_key );
994 migrated = true;
995 }
996 }
997 catch( ... )
998 {
999 }
1000 if( Contains( "legacy" ) )
1001 {
1002 // This defaults to false for new boards, but version 5.1.x and prior kept the fillets
1003 // so we do the same for legacy boards.
1005
1006 project->At( "legacy" ).erase( "pcbnew" );
1007 }
1008
1009 // Now that we have everything, we need to load again
1010 if( migrated )
1011 Load();
1012
1013 return ret;
1014}
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:325
bool Contains(const std::string &aPath) const
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
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...
JSON_SETTINGS * GetParent()
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:65
@ DRCE_OVERLAPPING_FOOTPRINTS
Definition: drc_item.h:61

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

◆ LoadFromRawFile()

bool JSON_SETTINGS::LoadFromRawFile ( const wxString &  aPath)
inherited

Definition at line 489 of file json_settings.cpp.

490{
491 try
492 {
493 wxFFileInputStream fp( aPath, wxT( "rt" ) );
494 wxStdInputStream fstream( fp );
495
496 if( fp.IsOk() )
497 {
498 *static_cast<nlohmann::json*>( m_internals.get() ) =
499 nlohmann::json::parse( fstream, nullptr,
500 /* allow_exceptions = */ true,
501 /* ignore_comments = */ true );
502 }
503 else
504 {
505 return false;
506 }
507 }
508 catch( nlohmann::json::parse_error& error )
509 {
510 wxLogTrace( traceSettings, wxT( "Json parse error reading %s: %s" ), aPath, error.what() );
511
512 return false;
513 }
514
515 // Now that we have new data in the JSON structure, load the params again
516 Load();
517 return true;
518}
bool parse(std::istream &aStream, bool aVerbose)
Parse a PCB or footprint file from the given input stream.

References JSON_SETTINGS::Load(), JSON_SETTINGS::m_internals, parse(), and traceSettings.

◆ 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 599 of file json_settings.cpp.

600{
601 int filever = m_internals->Get<int>( "meta.version" );
602
603 while( filever < m_schemaVersion )
604 {
605 if( !m_migrators.count( filever ) )
606 {
607 wxLogTrace( traceSettings, wxT( "Migrator missing for %s version %d!" ),
608 typeid( *this ).name(), filever );
609 return false;
610 }
611
612 std::pair<int, std::function<bool()>> pair = m_migrators.at( filever );
613
614 if( pair.second() )
615 {
616 wxLogTrace( traceSettings, wxT( "Migrated %s from %d to %d" ), typeid( *this ).name(),
617 filever, pair.first );
618 filever = pair.first;
619 m_internals->At( "meta.version" ) = filever;
620 }
621 else
622 {
623 wxLogTrace( traceSettings, wxT( "Migration failed for %s from %d to %d" ),
624 typeid( *this ).name(), filever, pair.first );
625 return false;
626 }
627 }
628
629 return true;
630}
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_internals, JSON_SETTINGS::m_migrators, JSON_SETTINGS::m_schemaVersion, and traceSettings.

Referenced by JSON_SETTINGS::LoadFromFile(), and NESTED_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 PROJECT_FILE, APP_SETTINGS_BASE, COLOR_SETTINGS, EDA_3D_VIEWER_SETTINGS, BITMAP2CMP_SETTINGS, EESCHEMA_SETTINGS, SYMBOL_EDITOR_SETTINGS, GERBVIEW_SETTINGS, FOOTPRINT_EDITOR_SETTINGS, PROJECT_LOCAL_SETTINGS, COMMON_SETTINGS, CVPCB_SETTINGS, KICAD_SETTINGS, PL_EDITOR_SETTINGS, PCB_CALCULATOR_SETTINGS, and PCBNEW_SETTINGS.

Definition at line 633 of file json_settings.cpp.

634{
635 wxLogTrace( traceSettings,
636 wxT( "MigrateFromLegacy() not implemented for %s" ), typeid( *this ).name() );
637 return false;
638}

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 892 of file board_design_settings.cpp.

893{
911 std::string units_ptr( "defaults.dimension_units" );
912 std::string precision_ptr( "defaults.dimension_precision" );
913
914 if( !( Contains( units_ptr ) && Contains( precision_ptr ) &&
915 At( units_ptr ).is_number_integer() &&
916 At( precision_ptr ).is_number_integer() ) )
917 {
918 // if either is missing or invalid, migration doesn't make sense
919 return true;
920 }
921
922 int units = *Get<int>( units_ptr );
923 int precision = *Get<int>( precision_ptr );
924
925 // The enum maps directly to precision if the units is mils
926 int extraDigits = 0;
927
928 switch( units )
929 {
930 case 0: extraDigits = 3; break;
931 case 2: extraDigits = 2; break;
932 default: break;
933 }
934
935 precision += extraDigits;
936
937 Set( precision_ptr, precision );
938
939 return true;
940}
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...

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 804 of file board_design_settings.cpp.

805{
806 initFromOther( aOther );
807 return *this;
808}

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 590 of file json_settings.cpp.

592{
593 wxASSERT( aNewSchemaVersion > aOldSchemaVersion );
594 wxASSERT( aNewSchemaVersion <= m_schemaVersion );
595 m_migrators[aOldSchemaVersion] = std::make_pair( aNewSchemaVersion, aMigrator );
596}

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(), SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS(), and SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_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 797 of file json_settings.cpp.

798{
799 if( !aSettings || !m_manager )
800 return;
801
802 auto it = std::find_if( m_nested_settings.begin(), m_nested_settings.end(),
803 [&aSettings]( const JSON_SETTINGS* aPtr ) {
804 return aPtr == aSettings;
805 } );
806
807 if( it != m_nested_settings.end() )
808 {
809 wxLogTrace( traceSettings, wxT( "Flush and release %s" ), ( *it )->GetFilename() );
810 ( *it )->SaveToFile();
811 m_nested_settings.erase( it );
812 }
813
814 aSettings->SetParent( nullptr );
815}
SETTINGS_MANAGER * m_manager
A pointer to the settings manager managing this file (may be null)
void SetParent(JSON_SETTINGS *aParent, bool aLoadFromFile=true)

References JSON_SETTINGS::m_manager, 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}

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 115 of file nested_settings.cpp.

116{
117 if( !m_parent )
118 return false;
119
121
122 try
123 {
124 bool modified = Store();
125
126 auto jsonObjectInParent = m_parent->GetJson( m_path );
127
128 if( !jsonObjectInParent )
129 modified = true;
130 else if( !nlohmann::json::diff( *m_internals, jsonObjectInParent.value() ).empty() )
131 modified = true;
132
133 if( modified || aForce )
134 {
135 ( *m_parent->m_internals )[m_path].update( *m_internals );
136
137 wxLogTrace( traceSettings, wxS( "Stored NESTED_SETTINGS %s with schema %d" ),
138 GetFilename(),
140 }
141
142 return modified;
143 }
144 catch( ... )
145 {
146 wxLogTrace( traceSettings, wxS( "NESTED_SETTINGS %s: Could not store to %s at %s" ),
149 m_path );
150
151 return false;
152 }
153}
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...

References dummy, 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 571 of file json_settings.cpp.

572{
573 m_internals->SetFromString( aPath, aVal );
574}

References JSON_SETTINGS::m_internals.

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

◆ Set() [2/3]

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

Definition at line 829 of file json_settings.cpp.

830{
831 ( *m_internals )[aPath] = aVal.ToUTF8();
832}

◆ Set() [3/3]

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

◆ SetAuxOrigin()

void BOARD_DESIGN_SETTINGS::SetAuxOrigin ( const VECTOR2I aOrigin)
inline

◆ SetBoardThickness()

◆ 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 1187 of file board_design_settings.cpp.

1188{
1189 m_copperLayerCount = aNewLayerCount;
1190
1191 // Update only enabled copper layers mask
1192 m_enabledLayers &= ~LSET::AllCuMask();
1193
1194 if( aNewLayerCount > 0 )
1195 m_enabledLayers |= LSET::AllCuMask( aNewLayerCount );
1196}
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773

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 468 of file board_design_settings.h.

469 {
470 m_customDiffPair.m_Gap = aGap;
471 }

References m_customDiffPair, and DIFF_PAIR_DIMENSION::m_Gap.

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 488 of file board_design_settings.h.

489 {
491 }

References m_customDiffPair, and DIFF_PAIR_DIMENSION::m_ViaGap.

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 450 of file board_design_settings.h.

451 {
452 m_customDiffPair.m_Width = aWidth;
453 }

References m_customDiffPair, and DIFF_PAIR_DIMENSION::m_Width.

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 329 of file board_design_settings.h.

330 {
331 m_customTrackWidth = aWidth;
332 }

References m_customTrackWidth.

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 400 of file board_design_settings.h.

401 {
402 m_customViaSize.m_Drill = aDrill;
403 }

References m_customViaSize, and VIA_DIMENSION::m_Drill.

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 372 of file board_design_settings.h.

373 {
375 }

References m_customViaSize, and VIA_DIMENSION::m_Diameter.

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

◆ SetDefaultZoneSettings()

void BOARD_DESIGN_SETTINGS::SetDefaultZoneSettings ( const ZONE_SETTINGS aSettings)
inline

Definition at line 255 of file board_design_settings.h.

256 {
257 m_defaultZoneSettings = aSettings;
258 }

References m_defaultZoneSettings.

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 1115 of file board_design_settings.cpp.

1116{
1117 if( !m_DiffPairDimensionsList.empty() )
1118 {
1119 m_diffPairIndex = std::min( aIndex,
1120 static_cast<unsigned>( m_DiffPairDimensionsList.size() ) - 1 );
1121 }
1122
1123 m_useCustomDiffPair = false;
1124}

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 1199 of file board_design_settings.cpp.

1200{
1201 // Back and front layers are always enabled.
1202 aMask.set( B_Cu ).set( F_Cu );
1203
1204 m_enabledLayers = aMask;
1205
1206 // update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
1207 m_copperLayerCount = ( aMask & LSET::AllCuMask() ).count();
1208}
@ B_Cu
Definition: layer_ids.h:95
@ F_Cu
Definition: layer_ids.h:64

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

◆ SetGridOrigin()

void BOARD_DESIGN_SETTINGS::SetGridOrigin ( const VECTOR2I aOrigin)
inline

◆ SetIfPresent() [1/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 656 of file json_settings.cpp.

658{
659 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
660
661 if( aObj.contains( ptr ) && aObj.at( ptr ).is_boolean() )
662 {
663 aTarget = aObj.at( ptr ).get<bool>();
664 return true;
665 }
666
667 return false;
668}

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [2/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 671 of file json_settings.cpp.

673{
674 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
675
676 if( aObj.contains( ptr ) && aObj.at( ptr ).is_number_integer() )
677 {
678 aTarget = aObj.at( ptr ).get<int>();
679 return true;
680 }
681
682 return false;
683}

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [3/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 686 of file json_settings.cpp.

688{
689 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
690
691 if( aObj.contains( ptr ) && aObj.at( ptr ).is_number_unsigned() )
692 {
693 aTarget = aObj.at( ptr ).get<unsigned int>();
694 return true;
695 }
696
697 return false;
698}

References JSON_SETTINGS_INTERNALS::PointerFromString().

◆ SetIfPresent() [4/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 641 of file json_settings.cpp.

643{
644 nlohmann::json::json_pointer ptr = JSON_SETTINGS_INTERNALS::PointerFromString( aPath );
645
646 if( aObj.contains( ptr ) && aObj.at( ptr ).is_string() )
647 {
648 aTarget = aObj.at( ptr ).get<wxString>();
649 return true;
650 }
651
652 return false;
653}

References JSON_SETTINGS_INTERNALS::PointerFromString().

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

◆ SetLegacyFilename()

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

Definition at line 82 of file json_settings.h.

82{ 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 79 of file json_settings.h.

79{ m_location = aLocation; }

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 }

References JSON_SETTINGS::m_manager.

◆ SetParent()

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

Definition at line 156 of file nested_settings.cpp.

157{
158 m_parent = aParent;
159
160 if( m_parent )
161 {
163
164 // In case we were created after the parent's ctor
165 if( aLoadFromFile )
166 LoadFromFile();
167 }
168}
void AddNestedSettings(NESTED_SETTINGS *aSettings)
Transfers ownership of a given NESTED_SETTINGS to this object.

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()

◆ SetTrackWidthIndex()

void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex ( unsigned  aIndex)

Set the current track width list index to aIndex.

Parameters
aIndexis the track width list index.

Definition at line 1097 of file board_design_settings.cpp.

1098{
1099 m_trackWidthIndex = std::min( aIndex, (unsigned) m_TrackWidthList.size() );
1100 m_useCustomTrackVia = false;
1101}

References m_trackWidthIndex, m_TrackWidthList, and m_useCustomTrackVia.

Referenced by TRACK_WIDTH_MENU::eventHandler(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), and PCB_EDIT_FRAME::UpdateTrackWidthSelectBox().

◆ 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}

References JSON_SETTINGS::m_params.

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

◆ UseCustomDiffPairDimensions() [1/2]

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

Definition at line 514 of file board_design_settings.h.

515 {
516 return m_useCustomDiffPair;
517 }

References m_useCustomDiffPair.

◆ UseCustomDiffPairDimensions() [2/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 506 of file board_design_settings.h.

507 {
508 m_useCustomDiffPair = aEnabled;
509 }

References m_useCustomDiffPair.

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

◆ UseCustomTrackViaSize() [1/2]

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

Definition at line 429 of file board_design_settings.h.

430 {
431 return m_useCustomTrackVia;
432 }

References m_useCustomTrackVia.

◆ UseCustomTrackViaSize() [2/2]

void BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize ( bool  aEnabled)
inline

◆ 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 287 of file board_design_settings.h.

288 {
289 return ( m_diffPairIndex == 0 && !m_useCustomDiffPair );
290 }

References m_diffPairIndex, and m_useCustomDiffPair.

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

◆ UseNetClassTrack()

bool BOARD_DESIGN_SETTINGS::UseNetClassTrack ( ) const
inline

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

Definition at line 271 of file board_design_settings.h.

272 {
273 return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia );
274 }

References m_trackWidthIndex, and m_useCustomTrackVia.

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

◆ UseNetClassVia()

bool BOARD_DESIGN_SETTINGS::UseNetClassVia ( ) const
inline

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

Definition at line 279 of file board_design_settings.h.

280 {
281 return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia );
282 }

References m_useCustomTrackVia, and m_viaSizeIndex.

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

Member Data Documentation

◆ m_AllowSoldermaskBridgesInFPs

◆ m_auxOrigin

VECTOR2I BOARD_DESIGN_SETTINGS::m_auxOrigin
private

origin for plot exports

Definition at line 729 of file board_design_settings.h.

Referenced by GetAuxOrigin(), initFromOther(), and SetAuxOrigin().

◆ m_boardThickness

int BOARD_DESIGN_SETTINGS::m_boardThickness
private

Board thickness for 3D viewer.

Definition at line 751 of file board_design_settings.h.

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

◆ m_CopperEdgeClearance

◆ m_copperLayerCount

int BOARD_DESIGN_SETTINGS::m_copperLayerCount
private

Number of copper layers for this design.

Definition at line 747 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 318 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 312 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 755 of file board_design_settings.h.

Referenced by GetCurrentNetClassName(), and initFromOther().

◆ m_CurrentViaType

VIATYPE BOARD_DESIGN_SETTINGS::m_CurrentViaType

(VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)

Definition at line 648 of file board_design_settings.h.

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

◆ m_customDiffPair

◆ m_customTrackWidth

int BOARD_DESIGN_SETTINGS::m_customTrackWidth
private

◆ m_customViaSize

◆ 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 764 of file board_design_settings.h.

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

◆ m_deleteLegacyAfterMigration

bool JSON_SETTINGS::m_deleteLegacyAfterMigration
protectedinherited

Whether or not to delete legacy file after migration.

Definition at line 324 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

◆ m_DimensionArrowLength

◆ m_DimensionExtensionOffset

◆ m_DimensionKeepTextAligned

◆ 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

◆ m_filename

◆ m_gridOrigin

VECTOR2I BOARD_DESIGN_SETTINGS::m_gridOrigin
private

origin for grid offsets

Definition at line 730 of file board_design_settings.h.

Referenced by GetGridOrigin(), initFromOther(), and SetGridOrigin().

◆ m_HasStackup

◆ m_HoleClearance

◆ m_HoleToHoleMin

◆ 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 300 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 303 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 333 of file json_settings.h.

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

◆ m_MaxError

◆ 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 336 of file json_settings.h.

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

◆ m_MinClearance

◆ m_MinConn

◆ m_MinResolvedSpokes

◆ m_MinSilkTextHeight

◆ m_MinSilkTextThickness

◆ 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 309 of file json_settings.h.

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

◆ m_NetSettings

◆ 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 327 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_SolderMaskExpansion

◆ m_SolderMaskMinWidth

◆ m_SolderMaskToCopperClearance

◆ 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 761 of file board_design_settings.h.

Referenced by GetStackupDescriptor(), and initFromOther().

◆ m_TeardropParamsList

TEARDROP_PARAMETERS_LIST BOARD_DESIGN_SETTINGS::m_TeardropParamsList

The parameters of teardrops for the different teardrop targets (via/pad, track end) 3 set of parameters always exist: for round shapes, for rect shapes, for track ends.

Definition at line 646 of file board_design_settings.h.

Referenced by BOARD_DESIGN_SETTINGS(), and GetTeadropParamsList().

◆ 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_ZoneKeepExternalFillets


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