KiCad PCB EDA Suite
Loading...
Searching...
No Matches
project_file.h
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 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Jon Evans <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef KICAD_PROJECT_FILE_H
23#define KICAD_PROJECT_FILE_H
24
25#include <common.h> // needed for wxstring hash template
26#include <kiid.h>
30
32class ERC_SETTINGS;
33class NET_SETTINGS;
35class TUNING_PROFILES;
38class TEMPLATES;
39
44typedef std::pair<KIID, wxString> FILE_INFO_PAIR;
45
50{
52 wxString name;
53 wxString filename;
54
56
57 TOP_LEVEL_SHEET_INFO( const KIID& aUuid, const wxString& aName, const wxString& aFilename )
58 : uuid( aUuid ), name( aName ), filename( aFilename )
59 {}
60
61 bool operator==( const TOP_LEVEL_SHEET_INFO& aOther ) const
62 {
63 return uuid == aOther.uuid && name == aOther.name && filename == aOther.filename;
64 }
65
66 bool operator!=( const TOP_LEVEL_SHEET_INFO& aOther ) const
67 {
68 return !( *this == aOther );
69 }
70};
71
86
94{
95public:
100 PROJECT_FILE( const wxString& aFullPath );
101
102 virtual ~PROJECT_FILE() = default;
103
104 virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
105
106 bool LoadFromFile( const wxString& aDirectory = "" ) override;
107
108 bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
109
110 bool SaveAs( const wxString& aDirectory, const wxString& aFile );
111
112 void SetProject( PROJECT* aProject )
113 {
114 m_project = aProject;
115 }
116
117 std::vector<FILE_INFO_PAIR>& GetSheets()
118 {
119 return m_sheets;
120 }
121
122 std::vector<FILE_INFO_PAIR>& GetBoards()
123 {
124 return m_boards;
125 }
126
127 std::vector<TOP_LEVEL_SHEET_INFO>& GetTopLevelSheets()
128 {
129 return m_topLevelSheets;
130 }
131
132 const std::vector<TOP_LEVEL_SHEET_INFO>& GetTopLevelSheets() const
133 {
134 return m_topLevelSheets;
135 }
136
137 std::shared_ptr<NET_SETTINGS>& NetSettings()
138 {
139 return m_NetSettings;
140 }
141
142 std::shared_ptr<COMPONENT_CLASS_SETTINGS>& ComponentClassSettings()
143 {
145 }
146
147 std::shared_ptr<TUNING_PROFILES>& TuningProfileParameters() { return m_tuningProfileParameters; }
148
152 bool ShouldAutoSave() const { return !m_wasMigrated && !m_isFutureFormat; }
153
154protected:
155 wxString getFileExt() const override;
156
157 wxString getLegacyFileExt() const override;
158
162public:
166
168 std::vector<wxString> m_PinnedSymbolLibs;
169
171 std::vector<wxString> m_PinnedFootprintLibs;
172
174 std::vector<wxString> m_PinnedDesignBlockLibs;
175
176 std::map<wxString, wxString> m_TextVars;
177
181
182 // Schematic ERC settings: lifecycle managed by SCHEMATIC
184
185 // Schematic editing and misc settings: lifecycle managed by SCHEMATIC
187
188 // Legacy parameters LibDir and LibName, for importing old projects
190
191 wxArrayString m_LegacyLibNames;
192
194 std::map<wxString, std::vector<wxString>> m_BusAliases;
195
199
201 std::vector<wxString> m_EquivalenceFiles;
202
206
209
212
219
227 std::shared_ptr<NET_SETTINGS> m_NetSettings;
228
229
230
234 std::shared_ptr<COMPONENT_CLASS_SETTINGS> m_ComponentClassSettings;
235
239 std::shared_ptr<TUNING_PROFILES> m_tuningProfileParameters;
240
241 std::vector<LAYER_PRESET> m_LayerPresets;
242 std::vector<VIEWPORT> m_Viewports;
243 std::vector<VIEWPORT3D> m_Viewports3D;
244 std::vector<LAYER_PAIR_INFO> m_LayerPairInfos;
245
247
248private:
254 bool migrateSchema1To2();
255
259 bool migrateSchema2To3();
260
262 std::vector<FILE_INFO_PAIR> m_sheets;
263
265 std::vector<TOP_LEVEL_SHEET_INFO> m_topLevelSheets;
266
268 std::vector<FILE_INFO_PAIR> m_boards;
269
272
274};
275
276// Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
277
278void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair );
279
280void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair );
281
282// Specializations to allow directly reading/writing TOP_LEVEL_SHEET_INFO from JSON
283
284void to_json( nlohmann::json& aJson, const TOP_LEVEL_SHEET_INFO& aInfo );
285
286void from_json( const nlohmann::json& aJson, TOP_LEVEL_SHEET_INFO& aInfo );
287
288#endif
Container for design settings for a BOARD object.
COMPONENT_CLASS_SETTINGS stores data for component classes, including rules for automatic generation ...
Container for ERC settings.
virtual wxString getFileExt() const
bool m_isFutureFormat
Set to true if this settings is loaded from a file with a newer schema version than is known.
virtual bool LoadFromFile(const wxString &aDirectory="")
Loads the backing file from disk and then calls Load()
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig)
Migrates from wxConfig to JSON-based configuration.
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
virtual wxString getLegacyFileExt() const
Definition kiid.h:49
Management class for layer pairs in a PCB.
Definition layer_pairs.h:47
NET_SETTINGS stores various net-related settings in a project context.
std::map< wxString, wxString > m_TextVars
std::vector< LAYER_PAIR_INFO > m_LayerPairInfos
List of stored 3D viewports (view matrixes)
ERC_SETTINGS * m_ErcSettings
Eeschema params.
wxString m_LegacyLibDir
std::vector< FILE_INFO_PAIR > & GetSheets()
SCHEMATIC_SETTINGS * m_SchematicSettings
std::vector< FILE_INFO_PAIR > & GetBoards()
bool migrateSchema1To2()
IPC-2581 BOM settings.
std::shared_ptr< NET_SETTINGS > & NetSettings()
wxString m_BoardDrawingSheetFile
PcbNew params.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
struct IP2581_BOM m_IP2581Bom
Layer pair list for the board.
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
PROJECT * m_project
A link to the owning PROJECT.
std::vector< TOP_LEVEL_SHEET_INFO > m_topLevelSheets
A list of top-level schematic sheets in this project.
std::vector< VIEWPORT > m_Viewports
List of stored layer presets.
BOARD_DESIGN_SETTINGS * m_BoardSettings
Board design settings for this project's board.
std::vector< wxString > m_PinnedDesignBlockLibs
The list of pinned design block libraries.
bool SaveAs(const wxString &aDirectory, const wxString &aFile)
std::map< wxString, std::vector< wxString > > m_BusAliases
Bus alias definitions for the schematic project.
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
bool migrateSchema2To3()
Schema version 3: move layer presets to use named render layers.
std::shared_ptr< COMPONENT_CLASS_SETTINGS > & ComponentClassSettings()
bool ShouldAutoSave() const
const std::vector< TOP_LEVEL_SHEET_INFO > & GetTopLevelSheets() const
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
void SetProject(PROJECT *aProject)
virtual ~PROJECT_FILE()=default
std::vector< FILE_INFO_PAIR > m_sheets
An list of schematic sheets in this project.
std::shared_ptr< TUNING_PROFILES > & TuningProfileParameters()
std::vector< LAYER_PRESET > m_LayerPresets
std::vector< FILE_INFO_PAIR > m_boards
A list of board files in this project.
std::shared_ptr< TUNING_PROFILES > m_tuningProfileParameters
Tuning profile parameters for this project.
wxArrayString m_LegacyLibNames
std::vector< TOP_LEVEL_SHEET_INFO > & GetTopLevelSheets()
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
std::vector< VIEWPORT3D > m_Viewports3D
List of stored viewports (pos + zoom)
PROJECT_FILE(const wxString &aFullPath)
Construct the project file for a project.
std::shared_ptr< COMPONENT_CLASS_SETTINGS > m_ComponentClassSettings
Component class settings for the project (owned here)
Container for project specific data.
Definition project.h:66
These are loaded from Eeschema settings but then overwritten by the project settings.
TUNING_PROFILES stores the configuration for impedance / delay tuning profiles.
The common library.
#define KICOMMON_API
Definition kicommon.h:28
void to_json(nlohmann::json &aJson, const FILE_INFO_PAIR &aPair)
void from_json(const nlohmann::json &aJson, FILE_INFO_PAIR &aPair)
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
@ LAST_PATH_PLOT
@ LAST_PATH_SPECCTRADSN
@ LAST_PATH_SIZE
@ LAST_PATH_FIRST
@ LAST_PATH_IDF
@ LAST_PATH_VRML
@ LAST_PATH_NETLIST
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...
Information about a top-level schematic sheet.
bool operator!=(const TOP_LEVEL_SHEET_INFO &aOther) const
KIID uuid
Unique identifier for the sheet.
TOP_LEVEL_SHEET_INFO(const KIID &aUuid, const wxString &aName, const wxString &aFilename)
bool operator==(const TOP_LEVEL_SHEET_INFO &aOther) const
wxString name
Display name for the sheet.
TOP_LEVEL_SHEET_INFO()=default
wxString filename
Relative path to the sheet file.