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>(
330  aCfg, "BoardOutlineThickness", bp + "defaults.board_outline_line_width" );
331 
332  fromLegacy<double>( aCfg, "CourtyardLineWidth", bp + "defaults.courtyard_line_width" );
333 
334  fromLegacy<double>( aCfg, "FabLineWidth", bp + "defaults.fab_line_width" );
335  fromLegacy<double>( aCfg, "FabTextSizeV", bp + "defaults.fab_text_size_v" );
336  fromLegacy<double>( aCfg, "FabTextSizeH", bp + "defaults.fab_text_size_h" );
337  fromLegacy<double>( aCfg, "FabTextSizeThickness", bp + "defaults.fab_text_thickness" );
338  fromLegacy<bool>( aCfg, "FabTextItalic", bp + "defaults.fab_text_italic" );
339  fromLegacy<bool>( aCfg, "FabTextUpright", bp + "defaults.fab_text_upright" );
340 
341  if( !fromLegacy<double>( aCfg, "OthersLineWidth", bp + "defaults.other_line_width" ) )
342  fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.other_line_width" );
343 
344  fromLegacy<double>( aCfg, "OthersTextSizeV", bp + "defaults.other_text_size_v" );
345  fromLegacy<double>( aCfg, "OthersTextSizeH", bp + "defaults.other_text_size_h" );
346  fromLegacy<double>( aCfg, "OthersTextSizeThickness", bp + "defaults.other_text_thickness" );
347  fromLegacy<bool>( aCfg, "OthersTextItalic", bp + "defaults.other_text_italic" );
348  fromLegacy<bool>( aCfg, "OthersTextUpright", bp + "defaults.other_text_upright" );
349 
350  fromLegacy<int>( aCfg, "DimensionUnits", bp + "defaults.dimension_units" );
351  fromLegacy<int>( aCfg, "DimensionPrecision", bp + "defaults.dimension_precision" );
352 
353  std::string sev = bp + "rule_severities";
354 
355  fromLegacy<bool>(
356  aCfg, "RequireCourtyardDefinitions", sev + "legacy_no_courtyard_defined" );
357 
358  fromLegacy<bool>( aCfg, "ProhibitOverlappingCourtyards", sev + "legacy_courtyards_overlap" );
359 
360  {
361  int idx = 1;
362  wxString keyBase = "TrackWidth";
363  wxString key = keyBase;
364  double val;
365 
366  nlohmann::json widths = nlohmann::json::array();
367 
368  key << idx;
369 
370  while( aCfg->Read( key, &val ) )
371  {
372  widths.push_back( val );
373  key = keyBase;
374  key << ++idx;
375  }
376 
377  ( *this )[PointerFromString( bp + "track_widths" )] = widths;
378  }
379 
380  {
381  int idx = 1;
382  wxString keyBase = "ViaDiameter";
383  wxString key = keyBase;
384  double diameter;
385  double drill = 1.0;
386 
387  nlohmann::json vias = nlohmann::json::array();
388 
389  key << idx;
390 
391  while( aCfg->Read( key, &diameter ) )
392  {
393  key = "ViaDrill";
394  aCfg->Read( key << idx, &drill );
395 
396  nlohmann::json via = { { "diameter", diameter }, { "drill", drill } };
397  vias.push_back( via );
398 
399  key = keyBase;
400  key << ++idx;
401  }
402 
403  ( *this )[PointerFromString( bp + "via_dimensions" )] = vias;
404  }
405 
406  {
407  int idx = 1;
408  wxString keyBase = "dPairWidth";
409  wxString key = keyBase;
410  double width;
411  double gap = 1.0;
412  double via_gap = 1.0;
413 
414  nlohmann::json pairs = nlohmann::json::array();
415 
416  key << idx;
417 
418  while( aCfg->Read( key, &width ) )
419  {
420  key = "dPairGap";
421  aCfg->Read( key << idx, &gap );
422 
423  key = "dPairViaGap";
424  aCfg->Read( key << idx, &via_gap );
425 
426  nlohmann::json pair = { { "width", width }, { "gap", gap }, { "via_gap", via_gap } };
427  pairs.push_back( pair );
428 
429  key = keyBase;
430  key << ++idx;
431  }
432 
433  ( *this )[PointerFromString( bp + "diff_pair_dimensions" )] = pairs;
434  }
435 
436  group_blacklist.insert( wxT( "/pcbnew" ) );
437 
438  // General group is unused these days, we can throw it away
439  group_blacklist.insert( wxT( "/general" ) );
440 
441  // Next load sheet names and put all other legacy data in the legacy dict
442  aCfg->SetPath( wxT( "/" ) );
443 
444  auto loadSheetNames =
445  [&]() -> bool
446  {
447  int sheet = 1;
448  wxString entry;
449  nlohmann::json arr = nlohmann::json::array();
450 
451  wxLogTrace( traceSettings, "Migrating sheet names" );
452 
453  aCfg->SetPath( wxT( "/sheetnames" ) );
454 
455  while( aCfg->Read( wxString::Format( "%d", sheet++ ), &entry ) )
456  {
457  wxArrayString tokens = wxSplit( entry, ':' );
458 
459  if( tokens.size() == 2 )
460  {
461  wxLogTrace( traceSettings, "%d: %s = %s", sheet, tokens[0], tokens[1] );
462  arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) );
463  }
464  }
465 
466  ( *this )[PointerFromString( "sheets" )] = arr;
467 
468  aCfg->SetPath( "/" );
469 
470  // TODO: any reason we want to fail on this?
471  return true;
472  };
473 
474  std::vector<wxString> groups;
475 
476  groups.emplace_back( "" );
477 
478  auto loadLegacyPairs =
479  [&]( const std::string& aGroup ) -> bool
480  {
481  wxLogTrace( traceSettings, "Migrating group %s", aGroup );
482  bool success = true;
483  wxString keyStr;
484  wxString val;
485 
486  index = 0;
487 
488  while( aCfg->GetNextEntry( keyStr, index ) )
489  {
490  if( !aCfg->Read( keyStr, &val ) )
491  continue;
492 
493  std::string key( keyStr.ToUTF8() );
494 
495  wxLogTrace( traceSettings, " %s = %s", key, val );
496 
497  try
498  {
499  nlohmann::json::json_pointer ptr( "/legacy" + aGroup + "/" + key );
500  ( *this )[ptr] = val;
501  }
502  catch( ... )
503  {
504  success = false;
505  }
506  }
507 
508  return success;
509  };
510 
511  for( size_t i = 0; i < groups.size(); i++ )
512  {
513  aCfg->SetPath( groups[i] );
514 
515  if( groups[i] == wxT( "/sheetnames" ) )
516  {
517  ret |= loadSheetNames();
518  continue;
519  }
520 
521  aCfg->DeleteEntry( wxT( "last_client" ), true );
522  aCfg->DeleteEntry( wxT( "update" ), true );
523  aCfg->DeleteEntry( wxT( "version" ), true );
524 
525  ret &= loadLegacyPairs( groups[i].ToStdString() );
526 
527  index = 0;
528 
529  while( aCfg->GetNextGroup( str, index ) )
530  {
531  wxString group = groups[i] + "/" + str;
532 
533  if( !group_blacklist.count( group ) )
534  groups.emplace_back( group );
535  }
536 
537  aCfg->SetPath( "/" );
538  }
539 
540  return ret;
541 }
542 
543 
544 bool PROJECT_FILE::SaveToFile( const wxString& aDirectory, bool aForce )
545 {
546  wxASSERT( m_project );
547 
548  ( *this )[PointerFromString( "meta.filename" )] =
550 
551  return JSON_SETTINGS::SaveToFile( aDirectory, aForce );
552 }
553 
554 
555 wxString PROJECT_FILE::getFileExt() const
556 {
557  return ProjectFileExtension;
558 }
559 
560 
562 {
564 }
565 
566 
567 void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair )
568 {
569  aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } );
570 }
571 
572 
573 void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair )
574 {
575  wxASSERT( aJson.is_array() && aJson.size() == 2 );
576  aPair.first = KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) );
577  aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 );
578 }
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)
PROJECT holds project specific data.
Definition: project.h:63
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:39
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
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)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
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
VTBL_ENTRY const wxString GetProjectName() const
Function GetProjectName returns the short name of the project.
Definition: project.cpp:127
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