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 FP_LIB_TABLE;
45class SYMBOL_LIBS;
46class SEARCH_STACK;
47class S3D_CACHE;
48class KIWAY;
51class PROJECT_FILE;
53
54
62{
63public:
72 class _ELEM
73 {
74 public:
75 virtual ~_ELEM() {}
76
77 virtual KICAD_T Type() = 0; // Sanity-checking for returned values.
78 };
79
80 PROJECT();
81 virtual ~PROJECT();
82
83 //-----<Cross Module API>----------------------------------------------------
84
85 virtual bool TextVarResolver( wxString* aToken ) const;
86
87 virtual std::map<wxString, wxString>& GetTextVars() const;
88
92 virtual void ApplyTextVars( const std::map<wxString, wxString>& aVarsMap );
93
94 int GetTextVarsTicker() const { return m_textVarsTicker; }
96
99
106 virtual const wxString GetProjectFullName() const;
107
114 virtual const wxString GetProjectPath() const;
115
122 virtual const wxString GetProjectDirectory() const;
123
129 virtual const wxString GetProjectName() const;
130
140 virtual bool IsNullProject() const;
141
142 virtual bool IsReadOnly() const { return m_readOnly || IsNullProject(); }
143
144 virtual void SetReadOnly( bool aReadOnly = true ) { m_readOnly = aReadOnly; }
145
149 virtual const wxString GetSheetName( const KIID& aSheetID );
150
156 virtual const wxString FootprintLibTblName() const;
157
161 virtual const wxString SymbolLibTableName() const;
162
163 void PinLibrary( const wxString& aLibrary, bool isSymbolLibrary );
164 void UnpinLibrary( const wxString& aLibrary, bool isSymbolLibrary );
165
167 {
168 wxASSERT( m_projectFile );
169 return *m_projectFile;
170 }
171
173 {
174 wxASSERT( m_localSettings );
175 return *m_localSettings;
176 }
177
180 {
183 SCH_LIB_SELECT, // eeschema/selpart.cpp
185 SCH_LIBEDIT_CUR_SYMBOL, // eeschema/libeditframe.cpp
186
189
196
198 };
199
207 virtual const wxString& GetRString( RSTRING_T aStringId );
208
216 virtual void SetRString( RSTRING_T aStringId, const wxString& aString );
217
222 {
224
229
231 };
232
245 virtual _ELEM* GetElem( ELEM_T aIndex );
246 virtual void SetElem( ELEM_T aIndex, _ELEM* aElem );
247
251 virtual void ElemsClear();
252
256 void Clear() // inline not virtual
257 {
258 ElemsClear();
259
260 for( unsigned i = 0; i<RSTRING_COUNT; ++i )
261 SetRString( RSTRING_T( i ), wxEmptyString );
262 }
263
270 virtual const wxString AbsolutePath( const wxString& aFileName ) const;
271
276 virtual FP_LIB_TABLE* PcbFootprintLibs( KIWAY& aKiway );
277
278private:
279 friend class SETTINGS_MANAGER; // so that SM can set project path
280 friend class TEST_NETLISTS_FIXTURE; // TODO(JE) make this not required
281
289 virtual void setProjectFullName( const wxString& aFullPathAndName );
290
298 virtual void setProjectFile( PROJECT_FILE* aFile )
299 {
300 m_projectFile = aFile;
301 }
302
310 virtual void setLocalSettings( PROJECT_LOCAL_SETTINGS* aSettings )
311 {
312 m_localSettings = aSettings;
313 }
314
318 const wxString libTableName( const wxString& aLibTableName ) const;
319
320private:
321 wxFileName m_project_name;
323
327
330
333
334 std::map<KIID, wxString> m_sheetNames;
335
338
341};
342
343
344#endif // PROJECT_H_
Provide an extensible class to resolve 3D model paths.
Definition: kiid.h:49
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
Definition: project.h:73
virtual KICAD_T Type()=0
virtual ~_ELEM()
Definition: project.h:75
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:70
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:62
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:329
virtual void SetReadOnly(bool aReadOnly=true)
Definition: project.h:144
virtual void setProjectFile(PROJECT_FILE *aFile)
Set the backing store file for this project.
Definition: project.h:298
virtual bool IsReadOnly() const
Definition: project.h:142
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:129
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:192
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:180
@ RSTRING_COUNT
Definition: project.h:197
@ VIEWER_3D_FILTER_INDEX
Definition: project.h:188
@ PCB_FOOTPRINT
Definition: project.h:191
@ VIEWER_3D_PATH
Definition: project.h:187
@ SCH_LIBEDIT_CUR_LIB
Definition: project.h:184
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:192
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:193
@ PCB_FOOTPRINT_VIEWER_FP_NAME
Definition: project.h:194
@ DOC_PATH
Definition: project.h:181
@ SCH_LIB_SELECT
Definition: project.h:183
@ PCB_LIB_NICKNAME
Definition: project.h:190
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:195
@ SCH_LIBEDIT_CUR_SYMBOL
Definition: project.h:185
@ SCH_LIB_PATH
Definition: project.h:182
wxString m_pro_date_and_time
Definition: project.h:322
std::map< KIID, wxString > m_sheetNames
Definition: project.h:334
virtual void setLocalSettings(PROJECT_LOCAL_SETTINGS *aSettings)
Set the local settings backing store.
Definition: project.h:310
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:147
int m_netclassesTicker
Update counter on netclasses.
Definition: project.h:326
virtual const wxString SymbolLibTableName() const
Return the path and file name of this projects symbol library table.
Definition: project.cpp:159
virtual ~PROJECT()
Definition: project.cpp:66
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:339
virtual void ApplyTextVars(const std::map< wxString, wxString > &aVarsMap)
Applies the given var map, it will create or update existing vars.
Definition: project.cpp:90
int GetNetclassesTicker() const
Definition: project.h:97
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:172
virtual void ElemsClear()
Delete all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:55
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
Definition: project.cpp:171
void IncrementNetclassesTicker()
Definition: project.h:98
virtual bool TextVarResolver(wxString *aToken) const
Definition: project.cpp:72
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:166
virtual const wxString GetSheetName(const KIID &aSheetID)
Return the name of the sheet identified by the given UUID.
Definition: project.cpp:254
int GetTextVarsTicker() const
Definition: project.h:94
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:337
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:165
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:299
friend class TEST_NETLISTS_FIXTURE
Definition: project.h:280
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:340
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:309
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:269
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:321
void Clear()
Clear the _ELEMs and RSTRINGs.
Definition: project.h:256
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:332
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:320
int m_textVarsTicker
Update counter on text vars.
Definition: project.h:325
const wxString libTableName(const wxString &aLibTableName) const
Return the full path and file name of the project specific library table aLibTableName.
Definition: project.cpp:209
virtual void setProjectFullName(const wxString &aFullPathAndName)
Set the full directory, basename, and extension of the project.
Definition: project.cpp:105
bool m_readOnly
No project files will be written to disk.
Definition: project.h:324
void IncrementTextVarsTicker()
Definition: project.h:95
virtual const wxString GetProjectDirectory() const
Return the full path of the project DIRECTORY.
Definition: project.cpp:141
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:84
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:280
ELEM_T
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:222
@ ELEM_SYMBOL_LIB_TABLE
Definition: project.h:228
@ ELEM_SCH_SEARCH_STACK
Definition: project.h:226
@ ELEM_3DCACHE
Definition: project.h:227
@ ELEM_COUNT
Definition: project.h:230
@ ELEM_FPTBL
Definition: project.h:223
@ ELEM_SCH_SYMBOL_LIBS
Definition: project.h:225
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:153
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