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  * @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 #ifndef KICAD_PROJECT_FILE_H
22 #define KICAD_PROJECT_FILE_H
23 
24 #include <common.h>
26 #include <settings/json_settings.h>
28 
30 class ERC_SETTINGS;
31 class NET_SETTINGS;
32 class SCHEMATIC_SETTINGS;
33 class TEMPLATES;
34 
39 typedef std::pair<KIID, wxString> FILE_INFO_PAIR;
40 
44 enum LAST_PATH_TYPE : unsigned int
45 {
52 
54 };
55 
63 {
64 public:
69  PROJECT_FILE( const wxString& aFullPath );
70 
71  virtual ~PROJECT_FILE() = default;
72 
73  virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
74 
75  bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
76 
77  void SetProject( PROJECT* aProject )
78  {
79  m_project = aProject;
80  }
81 
82  std::vector<FILE_INFO_PAIR>& GetSheets()
83  {
84  return m_sheets;
85  }
86 
87  std::vector<FILE_INFO_PAIR>& GetBoards()
88  {
89  return m_boards;
90  }
91 
93  {
94  return *m_NetSettings;
95  }
96 
97 protected:
98  wxString getFileExt() const override;
99 
100  wxString getLegacyFileExt() const override;
101 
102 private:
103 
105  std::vector<FILE_INFO_PAIR> m_sheets;
106 
108  std::vector<FILE_INFO_PAIR> m_boards;
109 
112 
116 public:
117 
122  std::vector<wxString> m_PinnedSymbolLibs;
124 
126  std::vector<wxString> m_PinnedFootprintLibs;
127 
128  std::map<wxString, wxString> m_TextVars;
129 
134  // Schematic ERC settings: lifecycle managed by SCHEMATIC
136 
137  // Schematic editing and misc settings: lifecycle managed by SCHEMATIC
139 
150 
151  // Legacy parameters LibDir and LibName, for importing old projects
152  wxString m_LegacyLibDir;
153 
154  wxArrayString m_LegacyLibNames;
155 
160  std::vector<wxString> m_EquivalenceFiles;
162 
169 
172 
179 
186  std::shared_ptr<NET_SETTINGS> m_NetSettings;
187 
189  std::vector<LAYER_PRESET> m_LayerPresets;
190 };
191 
192 // Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
193 
194 void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair );
195 
196 void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair );
197 
198 #endif
PROJECT * m_project
A link to the owning PROJECT.
Definition: project_file.h:111
void SetProject(PROJECT *aProject)
Definition: project_file.h:77
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
PROJECT holds project specific data.
Definition: project.h:61
wxArrayString m_LegacyLibNames
Definition: project_file.h:154
std::vector< FILE_INFO_PAIR > m_sheets
An list of schematic sheets in this project.
Definition: project_file.h:105
wxString getLegacyFileExt() const override
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:171
nlohmann::json json
Definition: gerbview.cpp:40
PROJECT_FILE is the backing store for a PROJECT, in JSON format.
Definition: project_file.h:62
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: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:186
virtual ~PROJECT_FILE()=default
wxString m_BoardPageLayoutDescrFile
PcbNew params.
Definition: project_file.h:168
TEMPLATES * m_TemplateFieldNames
A pointer to the template fieldnames object owned by the parent SCH_BASE_FRAME.
Definition: project_file.h:149
std::vector< wxString > m_EquivalenceFiles
CvPcb params.
Definition: project_file.h:161
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
ERC_SETTINGS * m_ErcSettings
Eeschema params.
Definition: project_file.h:135
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:138
wxString getFileExt() const override
Container for ERC settings.
Definition: erc_settings.h:87
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
Definition: project_file.h:44
void from_json(const nlohmann::json &aJson, FILE_INFO_PAIR &aPair)
std::vector< FILE_INFO_PAIR > & GetSheets()
Definition: project_file.h:82
BOARD_DESIGN_SETTINGS * m_BoardSettings
Board design settings for this project's board.
Definition: project_file.h:178
std::vector< FILE_INFO_PAIR > & GetBoards()
Definition: project_file.h:87
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:152
std::vector< LAYER_PRESET > m_LayerPresets
List of stored layer presets.
Definition: project_file.h:189
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
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.