KiCad PCB EDA Suite
Loading...
Searching...
No Matches
project.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) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
5 * Copyright (C) 2022 CERN
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#ifndef PROJECT_H_
25#define PROJECT_H_
26
30#include <map>
31#include <vector>
32#include <kiid.h>
33#include <wx_filename.h>
34#include <wx/string.h>
35#include <core/typeinfo.h>
36
39#define PROJECT_VAR_NAME wxT( "KIPRJMOD" )
40
42#define NAMELESS_PROJECT _( "untitled" )
43
44class wxConfigBase;
45class PARAM_CFG;
46class FP_LIB_TABLE;
47class SYMBOL_LIBS;
48class SEARCH_STACK;
49class S3D_CACHE;
50class KIWAY;
53class PROJECT_FILE;
55
56
64{
65public:
74 class _ELEM
75 {
76 public:
77 virtual ~_ELEM() {}
78
79 virtual KICAD_T Type() = 0; // Sanity-checking for returned values.
80 };
81
82 PROJECT();
83 virtual ~PROJECT();
84
85 //-----<Cross Module API>----------------------------------------------------
86
87 virtual bool TextVarResolver( wxString* aToken ) const;
88
89 virtual std::map<wxString, wxString>& GetTextVars() const;
90
97 virtual const wxString GetProjectFullName() const;
98
105 virtual const wxString GetProjectPath() const;
106
112 virtual const wxString GetProjectName() const;
113
123 virtual bool IsNullProject() const;
124
125 virtual bool IsReadOnly() const { return m_readOnly || IsNullProject(); }
126
127 virtual void SetReadOnly( bool aReadOnly = true ) { m_readOnly = aReadOnly; }
128
132 virtual const wxString GetSheetName( const KIID& aSheetID );
133
139 virtual const wxString FootprintLibTblName() const;
140
144 virtual const wxString SymbolLibTableName() const;
145
146 void PinLibrary( const wxString& aLibrary, bool isSymbolLibrary );
147 void UnpinLibrary( const wxString& aLibrary, bool isSymbolLibrary );
148
150 {
151 wxASSERT( m_projectFile );
152 return *m_projectFile;
153 }
154
156 {
157 wxASSERT( m_localSettings );
158 return *m_localSettings;
159 }
160
163 {
166 SCH_LIB_SELECT, // eeschema/selpart.cpp
168 SCH_LIBEDIT_CUR_SYMBOL, // eeschema/libeditframe.cpp
169
172
179
181 };
182
190 virtual const wxString& GetRString( RSTRING_T aStringId );
191
199 virtual void SetRString( RSTRING_T aStringId, const wxString& aString );
200
205 {
207
212
214 };
215
228 virtual _ELEM* GetElem( ELEM_T aIndex );
229 virtual void SetElem( ELEM_T aIndex, _ELEM* aElem );
230
234 virtual void ElemsClear();
235
239 void Clear() // inline not virtual
240 {
241 ElemsClear();
242
243 for( unsigned i = 0; i<RSTRING_COUNT; ++i )
244 SetRString( RSTRING_T( i ), wxEmptyString );
245 }
246
253 virtual const wxString AbsolutePath( const wxString& aFileName ) const;
254
259 virtual FP_LIB_TABLE* PcbFootprintLibs( KIWAY& aKiway );
260
261 // These are the non-virtual DATA LOAD ON DEMAND members. They load project related
262 // data on demand, and do so typically into m_elems[] at a particular index using
263 // SetElem() & GetElem(). That is, they wrap SetElem() and GetElem().
264 // To get the data to reload on demand, first SetProjectFullName(),
265 // then call SetElem( ELEM_T, NULL ) from client code.
266
267 // non-virtuals resident in PCBNEW link image(s). By being non-virtual, these
268 // functions can get linked into the KIFACE that needs them, and only there.
269 // In fact, the other KIFACEs don't even know they exist.
270#if defined( PCBNEW ) || defined( CVPCB )
275
283 S3D_CACHE* Get3DCacheManager( bool updateProjDir = false );
284
285 void Cleanup3DCache();
286
288 FILENAME_RESOLVER* Get3DFilenameResolver();
289#endif
290
291
292#if defined( EESCHEMA )
293 // These are all prefaced with "Sch"
294 SYMBOL_LIBS* SchLibs();
295
297 SEARCH_STACK* SchSearchS();
298
300 SYMBOL_LIB_TABLE* SchSymbolLibTable();
301
303 FILENAME_RESOLVER* Get3DFilenameResolver() { return nullptr; }
304#endif
305
306private:
307 friend class SETTINGS_MANAGER; // so that SM can set project path
308 friend class TEST_NETLISTS_FIXTURE; // TODO(JE) make this not required
309
317 virtual void setProjectFullName( const wxString& aFullPathAndName );
318
326 virtual void setProjectFile( PROJECT_FILE* aFile )
327 {
328 m_projectFile = aFile;
329 }
330
338 virtual void setLocalSettings( PROJECT_LOCAL_SETTINGS* aSettings )
339 {
340 m_localSettings = aSettings;
341 }
342
346 const wxString libTableName( const wxString& aLibTableName ) const;
347
348 wxFileName m_project_name;
350
353
356
359
360 std::map<KIID, wxString> m_sheetNames;
361
364
367};
368
369
370#endif // PROJECT_H_
Provide an extensible class to resolve 3D model paths.
Definition: kiid.h:48
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:82
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
Definition: project.h:75
virtual KICAD_T Type()=0
virtual ~_ELEM()
Definition: project.h:77
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:65
The project local settings are things that are attached to a particular project, but also might be pa...
Container for project specific data.
Definition: project.h:64
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:355
virtual void SetReadOnly(bool aReadOnly=true)
Definition: project.h:127
virtual void setProjectFile(PROJECT_FILE *aFile)
Set the backing store file for this project.
Definition: project.h:326
virtual bool IsReadOnly() const
Definition: project.h:125
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:120
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:177
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:163
@ RSTRING_COUNT
Definition: project.h:180
@ VIEWER_3D_FILTER_INDEX
Definition: project.h:171
@ PCB_FOOTPRINT
Definition: project.h:174
@ VIEWER_3D_PATH
Definition: project.h:170
@ SCH_LIBEDIT_CUR_LIB
Definition: project.h:167
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:175
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:176
@ PCB_FOOTPRINT_VIEWER_FP_NAME
Definition: project.h:177
@ DOC_PATH
Definition: project.h:164
@ SCH_LIB_SELECT
Definition: project.h:166
@ PCB_LIB_NICKNAME
Definition: project.h:173
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:178
@ SCH_LIBEDIT_CUR_SYMBOL
Definition: project.h:168
@ SCH_LIB_PATH
Definition: project.h:165
wxString m_pro_date_and_time
True if the project is read-only: no project files will be written.
Definition: project.h:349
std::map< KIID, wxString > m_sheetNames
Definition: project.h:360
virtual void setLocalSettings(PROJECT_LOCAL_SETTINGS *aSettings)
Set the local settings backing store.
Definition: project.h:338
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:132
virtual const wxString SymbolLibTableName() const
Return the path and file name of this projects symbol library table.
Definition: project.cpp:144
virtual ~PROJECT()
Definition: project.cpp:64
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:324
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:155
virtual void ElemsClear()
Delete all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:53
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:156
virtual bool TextVarResolver(wxString *aToken) const
Definition: project.cpp:70
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149
virtual const wxString GetSheetName(const KIID &aSheetID)
Return the name of the sheet identified by the given UUID.
Definition: project.cpp:239
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:363
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:150
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:284
friend class TEST_NETLISTS_FIXTURE
Definition: project.h:308
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:366
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:294
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:254
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:348
void Clear()
Clear the _ELEMs and RSTRINGs.
Definition: project.h:239
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:358
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:305
const wxString libTableName(const wxString &aLibTableName) const
Return the full path and file name of the project specific library table aLibTableName.
Definition: project.cpp:194
virtual void setProjectFullName(const wxString &aFullPathAndName)
Set the full directory, basename, and extension of the project.
Definition: project.cpp:88
bool m_readOnly
Definition: project.h:352
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:82
PROJECT()
Definition: project.cpp:44
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:265
ELEM_T
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:205
@ ELEM_SYMBOL_LIB_TABLE
Definition: project.h:211
@ ELEM_SCH_SEARCH_STACK
Definition: project.h:209
@ ELEM_3DCACHE
Definition: project.h:210
@ ELEM_COUNT
Definition: project.h:213
@ ELEM_FPTBL
Definition: project.h:206
@ ELEM_SCH_SYMBOL_LIBS
Definition: project.h:208
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:138
Cache for storing the 3D shapes.
Definition: 3d_cache.h:53
Look for files in a number of paths.
Definition: search_stack.h:42
A collection of SYMBOL_LIB objects.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78