KiCad PCB EDA Suite
project_file.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 CERN
5  * @author Jon Evans <jon@craftyjon.com>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <config_params.h>
22 #include <project.h>
23 #include <project/net_settings.h>
24 #include <project/project_file.h>
26 #include <settings/parameters.h>
28 #include <wx/config.h>
29 #include <wx/log.h>
30 
31 
34 
35 
36 PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
38  m_sheets(),
39  m_boards(),
40  m_project( nullptr ),
41  m_ErcSettings( nullptr ),
42  m_SchematicSettings( nullptr ),
43  m_BoardSettings()
44 {
45  // Keep old files around
47 
48  m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "sheets", &m_sheets, {} ) );
49 
50  m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "boards", &m_boards, {} ) );
51 
52  m_params.emplace_back( new PARAM_WXSTRING_MAP( "text_variables", &m_TextVars, {} ) );
53 
54  m_params.emplace_back(
55  new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs", &m_PinnedSymbolLibs, {} ) );
56 
57  m_params.emplace_back( new PARAM_LIST<wxString>(
58  "libraries.pinned_footprint_libs", &m_PinnedFootprintLibs, {} ) );
59 
60  m_params.emplace_back(
61  new PARAM_PATH_LIST( "cvpcb.equivalence_files", &m_EquivalenceFiles, {} ) );
62 
63  m_params.emplace_back(
64  new PARAM_PATH( "pcbnew.page_layout_descr_file", &m_BoardPageLayoutDescrFile, "" ) );
65 
66  m_params.emplace_back(
67  new PARAM_PATH( "pcbnew.last_paths.netlist", &m_PcbLastPath[LAST_PATH_NETLIST], "" ) );
68 
69  m_params.emplace_back(
70  new PARAM_PATH( "pcbnew.last_paths.step", &m_PcbLastPath[LAST_PATH_STEP], "" ) );
71 
72  m_params.emplace_back(
73  new PARAM_PATH( "pcbnew.last_paths.idf", &m_PcbLastPath[LAST_PATH_IDF], "" ) );
74 
75  m_params.emplace_back(
76  new PARAM_PATH( "pcbnew.last_paths.vrml", &m_PcbLastPath[LAST_PATH_VRML], "" ) );
77 
78  m_params.emplace_back( new PARAM_PATH(
79  "pcbnew.last_paths.specctra_dsn", &m_PcbLastPath[LAST_PATH_SPECCTRADSN], "" ) );
80 
81  m_params.emplace_back(
82  new PARAM_PATH( "pcbnew.last_paths.gencad", &m_PcbLastPath[LAST_PATH_GENCAD], "" ) );
83 
84  m_params.emplace_back( new PARAM<wxString>( "schematic.legacy_lib_dir", &m_LegacyLibDir, "" ) );
85 
86  m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "schematic.legacy_lib_list",
87  [&]() -> nlohmann::json
88  {
89  nlohmann::json ret = nlohmann::json::array();
90 
91  for( const wxString& libName : m_LegacyLibNames )
92  ret.push_back( libName );
93 
94  return ret;
95  },
96  [&]( const nlohmann::json& aJson )
97  {
98  if( aJson.empty() || !aJson.is_array() )
99  return;
100 
101  m_LegacyLibNames.clear();
102 
103  for( const nlohmann::json& entry : aJson )
104  m_LegacyLibNames.push_back( entry.get<wxString>() );
105  }, {} ) );
106 
107  m_NetSettings = std::make_shared<NET_SETTINGS>( this, "net_settings" );
108 
109  m_params.emplace_back( new PARAM_LAYER_PRESET( "board.layer_presets", &m_LayerPresets ) );
110 }
111 
112 
113 bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg )
114 {
115  bool ret = true;
116  wxString str;
117  long index = 0;
118 
119  std::set<wxString> group_blacklist;
120 
121  // Legacy files don't store board info; they assume board matches project name
122  // We will leave m_boards empty here so it can be populated with other code
123 
124  // First handle migration of data that will be stored locally in this object
125 
126  auto loadPinnedLibs =
127  [&]( const std::string& aDest )
128  {
129  int libIndex = 1;
130  wxString libKey = wxT( "PinnedItems" );
131  libKey << libIndex;
132 
133  nlohmann::json libs = nlohmann::json::array();
134 
135  while( aCfg->Read( libKey, &str ) )
136  {
137  libs.push_back( str );
138 
139  aCfg->DeleteEntry( libKey, true );
140 
141  libKey = wxT( "PinnedItems" );
142  libKey << ++libIndex;
143  }
144 
145  ( *this )[PointerFromString( aDest )] = libs;
146  };
147 
148  aCfg->SetPath( wxT( "/LibeditFrame" ) );
149  loadPinnedLibs( "libraries.pinned_symbol_libs" );
150 
151  aCfg->SetPath( wxT( "/ModEditFrame" ) );
152  loadPinnedLibs( "libraries.pinned_footprint_libs" );
153 
154  aCfg->SetPath( wxT( "/cvpcb/equfiles" ) );
155 
156  {
157  int eqIdx = 1;
158  wxString eqKey = wxT( "EquName" );
159  eqKey << eqIdx;
160 
161  nlohmann::json eqs = nlohmann::json::array();
162 
163  while( aCfg->Read( eqKey, &str ) )
164  {
165  eqs.push_back( str );
166 
167  eqKey = wxT( "EquName" );
168  eqKey << ++eqIdx;
169  }
170 
171  ( *this )[PointerFromString( "cvpcb.equivalence_files" )] = eqs;
172  }
173 
174  // All CvPcb params that we want to keep have been migrated above
175  group_blacklist.insert( wxT( "/cvpcb" ) );
176 
177  aCfg->SetPath( wxT( "/eeschema" ) );
178  fromLegacyString( aCfg, "LibDir", "schematic.legacy_lib_dir" );
179 
180  aCfg->SetPath( wxT( "/eeschema/libraries" ) );
181 
182  {
183  int libIdx = 1;
184  wxString libKey = wxT( "LibName" );
185  libKey << libIdx;
186 
187  nlohmann::json libs = nlohmann::json::array();
188 
189  while( aCfg->Read( libKey, &str ) )
190  {
191  libs.push_back( str );
192 
193  libKey = wxT( "LibName" );
194  libKey << ++libIdx;
195  }
196 
197  ( *this )[PointerFromString( "schematic.legacy_lib_list" )] = libs;
198  }
199 
200  group_blacklist.insert( wxT( "/eeschema" ) );
201 
202  aCfg->SetPath( wxT( "/text_variables" ) );
203 
204  {
205  int txtIdx = 1;
206  wxString txtKey;
207  txtKey << txtIdx;
208 
210 
211  while( aCfg->Read( txtKey, &str ) )
212  {
213  wxArrayString tokens = wxSplit( str, ':' );
214 
215  if( tokens.size() == 2 )
216  vars[ tokens[0].ToStdString() ] = tokens[1];
217 
218  txtKey.clear();
219  txtKey << ++txtIdx;
220  }
221 
222  ( *this )[PointerFromString( "text_variables" )] = vars;
223  }
224 
225  group_blacklist.insert( wxT( "/text_variables" ) );
226 
227  aCfg->SetPath( wxT( "/schematic_editor" ) );
228 
229  fromLegacyString( aCfg, "PageLayoutDescrFile", "schematic.page_layout_descr_file" );
230  fromLegacyString( aCfg, "PlotDirectoryName", "schematic.plot_directory" );
231  fromLegacyString( aCfg, "NetFmtName", "schematic.net_format_name" );
232  fromLegacy<bool>( aCfg, "SpiceAjustPassiveValues", "schematic.spice_adjust_passive_values" );
233  fromLegacy<int>( aCfg, "SubpartIdSeparator", "schematic.subpart_id_separator" );
234  fromLegacy<int>( aCfg, "SubpartFirstId", "schematic.subpart_first_id" );
235 
236  fromLegacy<int>( aCfg, "LineThickness", "schematic.drawing.default_line_thickness" );
237  fromLegacy<int>( aCfg, "WireThickness", "schematic.drawing.default_wire_thickness" );
238  fromLegacy<int>( aCfg, "BusThickness", "schematic.drawing.default_bus_thickness" );
239  fromLegacy<int>( aCfg, "LabSize", "schematic.drawing.default_text_size" );
240  fromLegacy<int>( aCfg, "PinSymbolSize", "schematic.drawing.pin_symbol_size" );
241  fromLegacy<int>( aCfg, "JunctionSize", "schematic.drawing.default_junction_size" );
242 
243  fromLegacyString( aCfg, "FieldNameTemplates", "schematic.drawing.field_names" );
244  fromLegacy<double>( aCfg, "TextOffsetRatio", "schematic.drawing.text_offset_ratio" );
245 
246  // All schematic_editor keys we keep are migrated above
247  group_blacklist.insert( wxT( "/schematic_editor" ) );
248 
249  aCfg->SetPath( wxT( "/pcbnew" ) );
250 
251  fromLegacyString( aCfg, "PageLayoutDescrFile", "pcbnew.page_layout_descr_file" );
252  fromLegacyString( aCfg, "LastNetListRead", "pcbnew.last_paths.netlist" );
253  fromLegacyString( aCfg, "LastSTEPExportPath", "pcbnew.last_paths.step" );
254  fromLegacyString( aCfg, "LastIDFExportPath", "pcbnew.last_paths.idf" );
255  fromLegacyString( aCfg, "LastVRMLExportPath", "pcbnew.last_paths.vmrl" );
256  fromLegacyString( aCfg, "LastSpecctraDSNExportPath", "pcbnew.last_paths.specctra_dsn" );
257  fromLegacyString( aCfg, "LastGenCADExportPath", "pcbnew.last_paths.gencad" );
258 
259  std::string bp = "board.design_settings.";
260 
261  {
262  int idx = 1;
263  wxString key = wxT( "DRCExclusion" );
264  key << idx;
265 
266  nlohmann::json exclusions = nlohmann::json::array();
267 
268  while( aCfg->Read( key, &str ) )
269  {
270  exclusions.push_back( str );
271 
272  key = wxT( "DRCExclusion" );
273  key << ++idx;
274  }
275 
276  ( *this )[PointerFromString( bp + "drc_exclusions" )] = exclusions;
277  }
278 
279  fromLegacy<bool>( aCfg, "AllowMicroVias", bp + "rules.allow_microvias" );
280  fromLegacy<bool>( aCfg, "AllowBlindVias", bp + "rules.allow_blind_buried_vias" );
281  fromLegacy<double>( aCfg, "MinClearance", bp + "rules.min_clearance" );
282  fromLegacy<double>( aCfg, "MinTrackWidth", bp + "rules.min_track_width" );
283  fromLegacy<double>( aCfg, "MinViaAnnulus", bp + "rules.min_via_annulus" );
284  fromLegacy<double>( aCfg, "MinViaDiameter", bp + "rules.min_via_diameter" );
285 
286  if( !fromLegacy<double>( aCfg, "MinThroughDrill", bp + "rules.min_through_hole_diameter" ) )
287  fromLegacy<double>( aCfg, "MinViaDrill", bp + "rules.min_through_hole_diameter" );
288 
289  fromLegacy<double>( aCfg, "MinMicroViaDiameter", bp + "rules.min_microvia_diameter" );
290  fromLegacy<double>( aCfg, "MinMicroViaDrill", bp + "rules.min_microvia_drill" );
291  fromLegacy<double>( aCfg, "MinHoleToHole", bp + "rules.min_hole_to_hole" );
292  fromLegacy<double>( aCfg, "CopperEdgeClearance", bp + "rules.min_copper_edge_clearance" );
293  fromLegacy<double>( aCfg, "SolderMaskClearance", bp + "rules.solder_mask_clearance" );
294  fromLegacy<double>( aCfg, "SolderMaskMinWidth", bp + "rules.solder_mask_min_width" );
295  fromLegacy<double>( aCfg, "SolderPasteClearance", bp + "rules.solder_paste_clearance" );
296  fromLegacy<double>( aCfg, "SolderPasteRatio", bp + "rules.solder_paste_margin_ratio" );
297 
298  if( !fromLegacy<double>( aCfg, "SilkLineWidth", bp + "defaults.silk_line_width" ) )
299  fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.silk_line_width" );
300 
301  if( !fromLegacy<double>( aCfg, "SilkTextSizeV", bp + "defaults.silk_text_size_v" ) )
302  fromLegacy<double>( aCfg, "ModuleTextSizeV", bp + "defaults.silk_text_size_v" );
303 
304  if( !fromLegacy<double>( aCfg, "SilkTextSizeH", bp + "defaults.silk_text_size_h" ) )
305  fromLegacy<double>( aCfg, "ModuleTextSizeH", bp + "defaults.silk_text_size_h" );
306 
307  if( !fromLegacy<double>( aCfg, "SilkTextSizeThickness", bp + "defaults.silk_text_thickness" ) )
308  fromLegacy<double>( aCfg, "ModuleTextSizeThickness", bp + "defaults.silk_text_thickness" );
309 
310  fromLegacy<bool>( aCfg, "SilkTextItalic", bp + "defaults.silk_text_italic" );
311  fromLegacy<bool>( aCfg, "SilkTextUpright", bp + "defaults.silk_text_upright" );
312 
313  if( !fromLegacy<double>( aCfg, "CopperLineWidth", bp + "defaults.copper_line_width" ) )
314  fromLegacy<double>( aCfg, "DrawSegmentWidth", bp + "defaults.copper_line_width" );
315 
316  if( !fromLegacy<double>( aCfg, "CopperTextSizeV", bp + "defaults.copper_text_size_v" ) )
317  fromLegacy<double>( aCfg, "PcbTextSizeV", bp + "defaults.copper_text_size_v" );
318 
319  if( !fromLegacy<double>( aCfg, "CopperTextSizeH", bp + "defaults.copper_text_size_h" ) )
320  fromLegacy<double>( aCfg, "PcbTextSizeH", bp + "defaults.copper_text_size_h" );
321 
322  if( !fromLegacy<double>( aCfg, "CopperTextThickness", bp + "defaults.copper_text_thickness" ) )
323  fromLegacy<double>( aCfg, "PcbTextThickness", bp + "defaults.copper_text_thickness" );
324 
325  fromLegacy<bool>( aCfg, "CopperTextItalic", bp + "defaults.copper_text_italic" );
326  fromLegacy<bool>( aCfg, "CopperTextUpright", bp + "defaults.copper_text_upright" );
327 
328  if( !fromLegacy<double>( aCfg, "EdgeCutLineWidth", bp + "defaults.board_outline_line_width" ) )
329  fromLegacy<double>( aCfg, "BoardOutlineThickness", bp + "defaults.board_outline_line_width" );
330 
331  fromLegacy<double>( aCfg, "CourtyardLineWidth", bp + "defaults.courtyard_line_width" );
332 
333  fromLegacy<double>( aCfg, "FabLineWidth", bp + "defaults.fab_line_width" );
334  fromLegacy<double>( aCfg, "FabTextSizeV", bp + "defaults.fab_text_size_v" );
335  fromLegacy<double>( aCfg, "FabTextSizeH", bp + "defaults.fab_text_size_h" );
336  fromLegacy<double>( aCfg, "FabTextSizeThickness", bp + "defaults.fab_text_thickness" );
337  fromLegacy<bool>( aCfg, "FabTextItalic", bp + "defaults.fab_text_italic" );
338  fromLegacy<bool>( aCfg, "FabTextUpright", bp + "defaults.fab_text_upright" );
339 
340  if( !fromLegacy<double>( aCfg, "OthersLineWidth", bp + "defaults.other_line_width" ) )
341  fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.other_line_width" );
342 
343  fromLegacy<double>( aCfg, "OthersTextSizeV", bp + "defaults.other_text_size_v" );
344  fromLegacy<double>( aCfg, "OthersTextSizeH", bp + "defaults.other_text_size_h" );
345  fromLegacy<double>( aCfg, "OthersTextSizeThickness", bp + "defaults.other_text_thickness" );
346  fromLegacy<bool>( aCfg, "OthersTextItalic", bp + "defaults.other_text_italic" );
347  fromLegacy<bool>( aCfg, "OthersTextUpright", bp + "defaults.other_text_upright" );
348 
349  fromLegacy<int>( aCfg, "DimensionUnits", bp + "defaults.dimension_units" );
350  fromLegacy<int>( aCfg, "DimensionPrecision", bp + "defaults.dimension_precision" );
351 
352  std::string sev = bp + "rule_severities";
353 
354  fromLegacy<bool>( aCfg, "RequireCourtyardDefinitions", sev + "legacy_no_courtyard_defined" );
355 
356  fromLegacy<bool>( aCfg, "ProhibitOverlappingCourtyards", sev + "legacy_courtyards_overlap" );
357 
358  {
359  int idx = 1;
360  wxString keyBase = "TrackWidth";
361  wxString key = keyBase;
362  double val;
363 
364  nlohmann::json widths = nlohmann::json::array();
365 
366  key << idx;
367 
368  while( aCfg->Read( key, &val ) )
369  {
370  widths.push_back( val );
371  key = keyBase;
372  key << ++idx;
373  }
374 
375  ( *this )[PointerFromString( bp + "track_widths" )] = widths;
376  }
377 
378  {
379  int idx = 1;
380  wxString keyBase = "ViaDiameter";
381  wxString key = keyBase;
382  double diameter;
383  double drill = 1.0;
384 
385  nlohmann::json vias = nlohmann::json::array();
386 
387  key << idx;
388 
389  while( aCfg->Read( key, &diameter ) )
390  {
391  key = "ViaDrill";
392  aCfg->Read( key << idx, &drill );
393 
394  nlohmann::json via = { { "diameter", diameter }, { "drill", drill } };
395  vias.push_back( via );
396 
397  key = keyBase;
398  key << ++idx;
399  }
400 
401  ( *this )[PointerFromString( bp + "via_dimensions" )] = vias;
402  }
403 
404  {
405  int idx = 1;
406  wxString keyBase = "dPairWidth";
407  wxString key = keyBase;
408  double width;
409  double gap = 1.0;
410  double via_gap = 1.0;
411 
412  nlohmann::json pairs = nlohmann::json::array();
413 
414  key << idx;
415 
416  while( aCfg->Read( key, &width ) )
417  {
418  key = "dPairGap";
419  aCfg->Read( key << idx, &gap );
420 
421  key = "dPairViaGap";
422  aCfg->Read( key << idx, &via_gap );
423 
424  nlohmann::json pair = { { "width", width }, { "gap", gap }, { "via_gap", via_gap } };
425  pairs.push_back( pair );
426 
427  key = keyBase;
428  key << ++idx;
429  }
430 
431  ( *this )[PointerFromString( bp + "diff_pair_dimensions" )] = pairs;
432  }
433 
434  group_blacklist.insert( wxT( "/pcbnew" ) );
435 
436  // General group is unused these days, we can throw it away
437  group_blacklist.insert( wxT( "/general" ) );
438 
439  // Next load sheet names and put all other legacy data in the legacy dict
440  aCfg->SetPath( wxT( "/" ) );
441 
442  auto loadSheetNames =
443  [&]() -> bool
444  {
445  int sheet = 1;
446  wxString entry;
447  nlohmann::json arr = nlohmann::json::array();
448 
449  wxLogTrace( traceSettings, "Migrating sheet names" );
450 
451  aCfg->SetPath( wxT( "/sheetnames" ) );
452 
453  while( aCfg->Read( wxString::Format( "%d", sheet++ ), &entry ) )
454  {
455  wxArrayString tokens = wxSplit( entry, ':' );
456 
457  if( tokens.size() == 2 )
458  {
459  wxLogTrace( traceSettings, "%d: %s = %s", sheet, tokens[0], tokens[1] );
460  arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) );
461  }
462  }
463 
464  ( *this )[PointerFromString( "sheets" )] = arr;
465 
466  aCfg->SetPath( "/" );
467 
468  // TODO: any reason we want to fail on this?
469  return true;
470  };
471 
472  std::vector<wxString> groups;
473 
474  groups.emplace_back( "" );
475 
476  auto loadLegacyPairs =
477  [&]( const std::string& aGroup ) -> bool
478  {
479  wxLogTrace( traceSettings, "Migrating group %s", aGroup );
480  bool success = true;
481  wxString keyStr;
482  wxString val;
483 
484  index = 0;
485 
486  while( aCfg->GetNextEntry( keyStr, index ) )
487  {
488  if( !aCfg->Read( keyStr, &val ) )
489  continue;
490 
491  std::string key( keyStr.ToUTF8() );
492 
493  wxLogTrace( traceSettings, " %s = %s", key, val );
494 
495  try
496  {
497  nlohmann::json::json_pointer ptr( "/legacy" + aGroup + "/" + key );
498  ( *this )[ptr] = val;
499  }
500  catch( ... )
501  {
502  success = false;
503  }
504  }
505 
506  return success;
507  };
508 
509  for( size_t i = 0; i < groups.size(); i++ )
510  {
511  aCfg->SetPath( groups[i] );
512 
513  if( groups[i] == wxT( "/sheetnames" ) )
514  {
515  ret |= loadSheetNames();
516  continue;
517  }
518 
519  aCfg->DeleteEntry( wxT( "last_client" ), true );
520  aCfg->DeleteEntry( wxT( "update" ), true );
521  aCfg->DeleteEntry( wxT( "version" ), true );
522 
523  ret &= loadLegacyPairs( groups[i].ToStdString() );
524 
525  index = 0;
526 
527  while( aCfg->GetNextGroup( str, index ) )
528  {
529  wxString group = groups[i] + "/" + str;
530 
531  if( !group_blacklist.count( group ) )
532  groups.emplace_back( group );
533  }
534 
535  aCfg->SetPath( "/" );
536  }
537 
538  return ret;
539 }
540 
541 
542 bool PROJECT_FILE::SaveToFile( const wxString& aDirectory, bool aForce )
543 {
544  wxASSERT( m_project );
545 
546  ( *this )[PointerFromString( "meta.filename" )] =
548 
549  return JSON_SETTINGS::SaveToFile( aDirectory, aForce );
550 }
551 
552 
553 wxString PROJECT_FILE::getFileExt() const
554 {
555  return ProjectFileExtension;
556 }
557 
558 
560 {
562 }
563 
564 
565 void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair )
566 {
567  aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } );
568 }
569 
570 
571 void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair )
572 {
573  wxCHECK( aJson.is_array() && aJson.size() == 2, /* void */ );
574  aPair.first = KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) );
575  aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 );
576 }
PROJECT * m_project
A link to the owning PROJECT.
Definition: project_file.h:111
std::map< wxString, wxString > m_TextVars
Definition: project_file.h:128
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Definition: project_file.h:123
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
Definition: project_file.h:126
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
Container for project specific data.
Definition: project.h:62
const std::string ProjectFileExtension
wxArrayString m_LegacyLibNames
Definition: project_file.h:143
std::vector< FILE_INFO_PAIR > m_sheets
An list of schematic sheets in this project.
Definition: project_file.h:105
const int projectFileSchemaVersion
! Update the schema version whenever a migration is required
wxString getLegacyFileExt() const override
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
SETTINGS_LOC
Definition: json_settings.h:44
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:160
nlohmann::json json
Definition: gerbview.cpp:40
bool m_deleteLegacyAfterMigration
Whether or not to delete legacy file after migration.
Stores a path as a string with directory separators normalized to unix-style.
Definition: parameters.h:173
Definition: kiid.h:44
std::pair< KIID, wxString > FILE_INFO_PAIR
For files like sheets and boards, a pair of that object KIID and display name Display name is typical...
Definition: project_file.h:33
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here) NOTE: If we go multi-board in the future,...
Definition: project_file.h:175
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
wxString m_BoardPageLayoutDescrFile
PcbNew params.
Definition: project_file.h:157
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
Definition: project_file.h:150
Definition of file extensions used in Kicad.
wxString getFileExt() const override
const std::string LegacyProjectFileExtension
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
A helper for <wxString, wxString> maps.
Definition: parameters.h:724
void to_json(nlohmann::json &aJson, const FILE_INFO_PAIR &aPair)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
void from_json(const nlohmann::json &aJson, FILE_INFO_PAIR &aPair)
wxString m_LegacyLibDir
Definition: project_file.h:141
virtual const wxString GetProjectName() const
Return the short name of the project.
const wxChar *const traceSettings
Flag to enable debug output of settings operations and management.
std::vector< LAYER_PRESET > m_LayerPresets
List of stored layer presets.
Definition: project_file.h:178
Represents a list of strings holding directory paths.
Definition: parameters.h:560
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
PROJECT_FILE(const wxString &aFullPath)
Constructs the project file for a project.
std::vector< FILE_INFO_PAIR > m_boards
A list of board files in this project.
Definition: project_file.h:108