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;
38class TEMPLATES;
39
44typedef std::pair<KIID, wxString> FILE_INFO_PAIR;
45
49enum LAST_PATH_TYPE : unsigned int
50{
63
65};
66
74{
75public:
80 PROJECT_FILE( const wxString& aFullPath );
81
82 virtual ~PROJECT_FILE() = default;
83
84 virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
85
86 bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
87
88 bool SaveAs( const wxString& aDirectory, const wxString& aFile );
89
90 void SetProject( PROJECT* aProject )
91 {
92 m_project = aProject;
93 }
94
95 std::vector<FILE_INFO_PAIR>& GetSheets()
96 {
97 return m_sheets;
98 }
99
100 std::vector<FILE_INFO_PAIR>& GetBoards()
101 {
102 return m_boards;
103 }
104
105 std::shared_ptr<NET_SETTINGS>& NetSettings()
106 {
107 return m_NetSettings;
108 }
109
110 std::shared_ptr<COMPONENT_CLASS_SETTINGS>& ComponentClassSettings()
111 {
112 return m_ComponentClassSettings;
113 }
114
115 std::shared_ptr<TIME_DOMAIN_PARAMETERS>& TimeDomainParameters()
116 {
117 return m_timeDomainParameters;
118 }
119
123 bool ShouldAutoSave() const { return !m_wasMigrated && !m_isFutureFormat; }
124
125protected:
126 wxString getFileExt() const override;
127
128 wxString getLegacyFileExt() const override;
129
133public:
139 std::vector<wxString> m_PinnedSymbolLibs;
140
142 std::vector<wxString> m_PinnedFootprintLibs;
143
145 std::vector<wxString> m_PinnedDesignBlockLibs;
146
147 std::map<wxString, wxString> m_TextVars;
148
153 // Schematic ERC settings: lifecycle managed by SCHEMATIC
155
156 // Schematic editing and misc settings: lifecycle managed by SCHEMATIC
158
159 // Legacy parameters LibDir and LibName, for importing old projects
161
162 wxArrayString m_LegacyLibNames;
163
169 std::vector<wxString> m_EquivalenceFiles;
170
177
179 wxString m_PcbLastPath[LAST_PATH_SIZE];
180
187
195 std::shared_ptr<NET_SETTINGS> m_NetSettings;
196
200 std::shared_ptr<COMPONENT_CLASS_SETTINGS> m_ComponentClassSettings;
201
205 std::shared_ptr<TIME_DOMAIN_PARAMETERS> m_timeDomainParameters;
206
207 std::vector<LAYER_PRESET> m_LayerPresets;
208 std::vector<VIEWPORT> m_Viewports;
209 std::vector<VIEWPORT3D> m_Viewports3D;
210 std::vector<LAYER_PAIR_INFO> m_LayerPairInfos;
211
212 struct IP2581_BOM m_IP2581Bom;
213
214private:
220 bool migrateSchema1To2();
221
225 bool migrateSchema2To3();
226
228 std::vector<FILE_INFO_PAIR> m_sheets;
229
231 std::vector<FILE_INFO_PAIR> m_boards;
232
235
237};
238
239// Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
240
241void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair );
242
243void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair );
244
245#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.
Definition: erc_settings.h:135
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 MigrateFromLegacy(wxConfigBase *aLegacyConfig)
Migrates from wxConfig to JSON-based configuration.
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
Management class for layer pairs in a PCB.
Definition: layer_pairs.h:47
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:39
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:74
std::map< wxString, wxString > m_TextVars
Definition: project_file.h:147
std::vector< LAYER_PAIR_INFO > m_LayerPairInfos
List of stored 3D viewports (view matrixes)
Definition: project_file.h:210
ERC_SETTINGS * m_ErcSettings
Eeschema params.
Definition: project_file.h:154
wxString m_LegacyLibDir
Definition: project_file.h:160
std::vector< FILE_INFO_PAIR > & GetSheets()
Definition: project_file.h:95
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:157
std::vector< FILE_INFO_PAIR > & GetBoards()
Definition: project_file.h:100
std::shared_ptr< NET_SETTINGS > & NetSettings()
Definition: project_file.h:105
wxString m_BoardDrawingSheetFile
PcbNew params.
Definition: project_file.h:176
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
Definition: project_file.h:195
PROJECT * m_project
A link to the owning PROJECT.
Definition: project_file.h:234
std::shared_ptr< TIME_DOMAIN_PARAMETERS > m_timeDomainParameters
Time domain parameters for this project.
Definition: project_file.h:205
std::vector< VIEWPORT > m_Viewports
List of stored layer presets.
Definition: project_file.h:208
BOARD_DESIGN_SETTINGS * m_BoardSettings
Board design settings for this project's board.
Definition: project_file.h:186
std::vector< wxString > m_PinnedDesignBlockLibs
The list of pinned design block libraries.
Definition: project_file.h:145
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
Definition: project_file.h:169
std::shared_ptr< COMPONENT_CLASS_SETTINGS > & ComponentClassSettings()
Definition: project_file.h:110
bool ShouldAutoSave() const
Definition: project_file.h:123
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
Definition: project_file.h:142
void SetProject(PROJECT *aProject)
Definition: project_file.h:90
virtual ~PROJECT_FILE()=default
std::vector< FILE_INFO_PAIR > m_sheets
An list of schematic sheets in this project.
Definition: project_file.h:228
bool m_wasMigrated
Definition: project_file.h:236
std::vector< LAYER_PRESET > m_LayerPresets
Definition: project_file.h:207
std::vector< FILE_INFO_PAIR > m_boards
A list of board files in this project.
Definition: project_file.h:231
wxArrayString m_LegacyLibNames
Definition: project_file.h:162
std::shared_ptr< TIME_DOMAIN_PARAMETERS > & TimeDomainParameters()
Definition: project_file.h:115
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Definition: project_file.h:139
std::vector< VIEWPORT3D > m_Viewports3D
List of stored viewports (pos + zoom)
Definition: project_file.h:209
std::shared_ptr< COMPONENT_CLASS_SETTINGS > m_ComponentClassSettings
Component class settings for the project (owned here)
Definition: project_file.h:200
Container for project specific data.
Definition: project.h:65
These are loaded from Eeschema settings but then overwritten by the project settings.
TIME_DOMAIN_PARAMETERS stores the configuration for time-domain tuning.
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.
Definition: project_file.h:50
@ LAST_PATH_PLOT
Definition: project_file.h:60
@ LAST_PATH_SPECCTRADSN
Definition: project_file.h:56
@ LAST_PATH_ODBPP
Definition: project_file.h:62
@ LAST_PATH_GENCAD
Definition: project_file.h:57
@ LAST_PATH_SIZE
Definition: project_file.h:64
@ LAST_PATH_2581
Definition: project_file.h:61
@ LAST_PATH_FIRST
Definition: project_file.h:51
@ LAST_PATH_POS_FILES
Definition: project_file.h:58
@ LAST_PATH_IDF
Definition: project_file.h:54
@ LAST_PATH_VRML
Definition: project_file.h:55
@ LAST_PATH_NETLIST
Definition: project_file.h:52
@ LAST_PATH_STEP
Definition: project_file.h:53
@ LAST_PATH_SVG
Definition: project_file.h:59
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:44