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 <array>
31#include <map>
32#include <vector>
33#include <kiid.h>
34#include <wx_filename.h>
35#include <wx/string.h>
36#include <core/typeinfo.h>
37
40#define PROJECT_VAR_NAME wxT( "KIPRJMOD" )
41
43#define NAMELESS_PROJECT _( "untitled" )
44
45class FP_LIB_TABLE;
46class SYMBOL_LIBS;
47class SEARCH_STACK;
48class S3D_CACHE;
49class KIWAY;
52class PROJECT_FILE;
54
55
63{
64public:
68 enum class ELEM
69 {
70 FPTBL,
71
72 SCH_SYMBOL_LIBS,
73 SCH_SEARCH_STACK,
74 S3DCACHE,
77
78 COUNT
79 };
80
90 {
91 public:
92 virtual ~_ELEM() {}
93
94 virtual PROJECT::ELEM ProjectElementType() = 0; // Sanity-checking for returned values.
95 };
96
97 PROJECT();
98 virtual ~PROJECT();
99
100 //-----<Cross Module API>----------------------------------------------------
101
102 virtual bool TextVarResolver( wxString* aToken ) const;
103
104 virtual std::map<wxString, wxString>& GetTextVars() const;
105
109 virtual void ApplyTextVars( const std::map<wxString, wxString>& aVarsMap );
110
111 int GetTextVarsTicker() const { return m_textVarsTicker; }
112 void IncrementTextVarsTicker() { m_textVarsTicker++; }
113
114 int GetNetclassesTicker() const { return m_netclassesTicker; }
115 void IncrementNetclassesTicker() { m_netclassesTicker++; }
116
123 virtual const wxString GetProjectFullName() const;
124
131 virtual const wxString GetProjectPath() const;
132
139 virtual const wxString GetProjectDirectory() const;
140
146 virtual const wxString GetProjectName() const;
147
157 virtual bool IsNullProject() const;
158
159 virtual bool IsReadOnly() const { return m_readOnly || IsNullProject(); }
160
161 virtual void SetReadOnly( bool aReadOnly = true ) { m_readOnly = aReadOnly; }
162
166 virtual const wxString GetSheetName( const KIID& aSheetID );
167
173 virtual const wxString FootprintLibTblName() const;
174
178 virtual const wxString SymbolLibTableName() const;
179
180 void PinLibrary( const wxString& aLibrary, bool isSymbolLibrary );
181 void UnpinLibrary( const wxString& aLibrary, bool isSymbolLibrary );
182
184 {
185 wxASSERT( m_projectFile );
186 return *m_projectFile;
187 }
188
190 {
191 wxASSERT( m_localSettings );
192 return *m_localSettings;
193 }
194
197 {
200 SCH_LIB_SELECT, // eeschema/selpart.cpp
202 SCH_LIBEDIT_CUR_SYMBOL, // eeschema/libeditframe.cpp
203
206
213
214 RSTRING_COUNT
215 };
216
224 virtual const wxString& GetRString( RSTRING_T aStringId );
225
233 virtual void SetRString( RSTRING_T aStringId, const wxString& aString );
234
247 virtual _ELEM* GetElem( PROJECT::ELEM aIndex );
248 virtual void SetElem( PROJECT::ELEM aIndex, _ELEM* aElem );
249
253 virtual void ElemsClear();
254
258 void Clear() // inline not virtual
259 {
260 ElemsClear();
261
262 for( unsigned i = 0; i<RSTRING_COUNT; ++i )
263 SetRString( RSTRING_T( i ), wxEmptyString );
264 }
265
272 virtual const wxString AbsolutePath( const wxString& aFileName ) const;
273
278 virtual FP_LIB_TABLE* PcbFootprintLibs( KIWAY& aKiway );
279
280private:
281 friend class SETTINGS_MANAGER; // so that SM can set project path
282 friend class TEST_NETLISTS_FIXTURE; // TODO(JE) make this not required
283
291 virtual void setProjectFullName( const wxString& aFullPathAndName );
292
300 virtual void setProjectFile( PROJECT_FILE* aFile )
301 {
302 m_projectFile = aFile;
303 }
304
312 virtual void setLocalSettings( PROJECT_LOCAL_SETTINGS* aSettings )
313 {
314 m_localSettings = aSettings;
315 }
316
320 const wxString libTableName( const wxString& aLibTableName ) const;
321
322private:
323 wxFileName m_project_name;
325
329
332
335
336 std::map<KIID, wxString> m_sheetNames;
337
339 std::array<wxString,RSTRING_COUNT> m_rstrings;
340
342 std::array<_ELEM*,static_cast<unsigned int>( PROJECT::ELEM::COUNT )> m_elems;
343};
344
345
346#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:90
virtual PROJECT::ELEM ProjectElementType()=0
virtual ~_ELEM()
Definition: project.h:92
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:71
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:63
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:331
virtual void SetReadOnly(bool aReadOnly=true)
Definition: project.h:161
virtual void setProjectFile(PROJECT_FILE *aFile)
Set the backing store file for this project.
Definition: project.h:300
virtual bool IsReadOnly() const
Definition: project.h:159
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:197
@ VIEWER_3D_FILTER_INDEX
Definition: project.h:205
@ PCB_FOOTPRINT
Definition: project.h:208
@ VIEWER_3D_PATH
Definition: project.h:204
@ SCH_LIBEDIT_CUR_LIB
Definition: project.h:201
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:209
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:210
@ PCB_FOOTPRINT_VIEWER_FP_NAME
Definition: project.h:211
@ DOC_PATH
Definition: project.h:198
@ SCH_LIB_SELECT
Definition: project.h:200
@ PCB_LIB_NICKNAME
Definition: project.h:207
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:212
@ SCH_LIBEDIT_CUR_SYMBOL
Definition: project.h:202
@ SCH_LIB_PATH
Definition: project.h:199
wxString m_pro_date_and_time
Definition: project.h:324
std::map< KIID, wxString > m_sheetNames
Definition: project.h:336
virtual void setLocalSettings(PROJECT_LOCAL_SETTINGS *aSettings)
Set the local settings backing store.
Definition: project.h:312
int m_netclassesTicker
Update counter on netclasses.
Definition: project.h:328
int GetNetclassesTicker() const
Definition: project.h:114
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:189
void IncrementNetclassesTicker()
Definition: project.h:115
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:183
int GetTextVarsTicker() const
Definition: project.h:111
std::array< _ELEM *, static_cast< unsigned int >(PROJECT::ELEM::COUNT)> m_elems
Definition: project.h:342
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:323
void Clear()
Clear the _ELEMs and RSTRINGs.
Definition: project.h:258
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:334
int m_textVarsTicker
Update counter on text vars.
Definition: project.h:327
std::array< wxString, RSTRING_COUNT > m_rstrings
Definition: project.h:339
bool m_readOnly
No project files will be written to disk.
Definition: project.h:326
void IncrementTextVarsTicker()
Definition: project.h:112
ELEM
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:69
Cache for storing the 3D shapes.
Definition: 3d_cache.h:54
Look for files in a number of paths.
Definition: search_stack.h:43
A collection of SYMBOL_LIB objects.
wxString GetTextVars(const wxString &aSource)
Returns any variables unexpanded, e.g.
Definition: common.cpp:121
#define KICOMMON_API
Definition: kicommon.h:28