KiCad PCB EDA Suite
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 (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jon Evans <jon@craftyjon.com>
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>
28 #include <settings/json_settings.h>
30 
32 class ERC_SETTINGS;
33 class NET_SETTINGS;
34 class SCHEMATIC_SETTINGS;
35 class TEMPLATES;
36 
41 typedef std::pair<KIID, wxString> FILE_INFO_PAIR;
42 
46 enum LAST_PATH_TYPE : unsigned int
47 {
54 
56 };
57 
65 {
66 public:
71  PROJECT_FILE( const wxString& aFullPath );
72 
73  virtual ~PROJECT_FILE() = default;
74 
75  virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
76 
77  bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
78 
79  void SetProject( PROJECT* aProject )
80  {
81  m_project = aProject;
82  }
83 
84  std::vector<FILE_INFO_PAIR>& GetSheets()
85  {
86  return m_sheets;
87  }
88 
89  std::vector<FILE_INFO_PAIR>& GetBoards()
90  {
91  return m_boards;
92  }
93 
95  {
96  return *m_NetSettings;
97  }
98 
99 protected:
100  wxString getFileExt() const override;
101 
102  wxString getLegacyFileExt() const override;
103 
107 public:
112  std::vector<wxString> m_PinnedSymbolLibs;
114 
116  std::vector<wxString> m_PinnedFootprintLibs;
117 
118  std::map<wxString, wxString> m_TextVars;
119 
124  // Schematic ERC settings: lifecycle managed by SCHEMATIC
126 
127  // Schematic editing and misc settings: lifecycle managed by SCHEMATIC
129 
130  // Legacy parameters LibDir and LibName, for importing old projects
131  wxString m_LegacyLibDir;
132 
133  wxArrayString m_LegacyLibNames;
134 
139  std::vector<wxString> m_EquivalenceFiles;
141 
146  wxString m_BoardDrawingSheetFile;
148 
151 
158 
166  std::shared_ptr<NET_SETTINGS> m_NetSettings;
167 
169  std::vector<LAYER_PRESET> m_LayerPresets;
170 
171 private:
173  std::vector<FILE_INFO_PAIR> m_sheets;
174 
176  std::vector<FILE_INFO_PAIR> m_boards;
177 
180 };
181 
182 // Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
183 
184 void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair );
185 
186 void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair );
187 
188 #endif
PROJECT * m_project
A link to the owning PROJECT.
Definition: project_file.h:179
void SetProject(PROJECT *aProject)
Definition: project_file.h:79
std::map< wxString, wxString > m_TextVars
Definition: project_file.h:118
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Definition: project_file.h:113
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
Definition: project_file.h:116
Container for project specific data.
Definition: project.h:62
wxArrayString m_LegacyLibNames
Definition: project_file.h:133
std::vector< FILE_INFO_PAIR > m_sheets
An list of schematic sheets in this project.
Definition: project_file.h:173
wxString getLegacyFileExt() const override
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:150
nlohmann::json json
Definition: gerbview.cpp:41
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:64
void to_json(nlohmann::json &aJson, const FILE_INFO_PAIR &aPair)
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:35
wxString m_BoardDrawingSheetFile
PcbNew params.
Definition: project_file.h:147
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
Definition: project_file.h:166
virtual ~PROJECT_FILE()=default
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
Definition: project_file.h:140
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
ERC_SETTINGS * m_ErcSettings
Eeschema params.
Definition: project_file.h:125
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:128
wxString getFileExt() const override
Container for ERC settings.
Definition: erc_settings.h:106
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
Definition: project_file.h:46
void from_json(const nlohmann::json &aJson, FILE_INFO_PAIR &aPair)
std::vector< FILE_INFO_PAIR > & GetSheets()
Definition: project_file.h:84
BOARD_DESIGN_SETTINGS * m_BoardSettings
Board design settings for this project's board.
Definition: project_file.h:157
std::vector< FILE_INFO_PAIR > & GetBoards()
Definition: project_file.h:89
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
The common library.
These settings were stored in SCH_BASE_FRAME previously.
wxString m_LegacyLibDir
Definition: project_file.h:131
std::vector< LAYER_PRESET > m_LayerPresets
List of stored layer presets.
Definition: project_file.h:169
PROJECT_FILE(const wxString &aFullPath)
Construct 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:176
Container for design settings for a BOARD object.