KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 The 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
46class FP_LIB_TABLE;
47class SYMBOL_LIBS;
48class SEARCH_STACK;
49class S3D_CACHE;
50class KIWAY;
53class PROJECT_FILE;
55
56
64{
65public:
69 enum class ELEM
70 {
71 FPTBL,
72
73 SCH_SYMBOL_LIBS,
74 SCH_SEARCH_STACK,
75 S3DCACHE,
78
80
82 BOARD,
83
84 COUNT
85 };
86
96 {
97 public:
98 virtual ~_ELEM() {}
99
100 virtual PROJECT::ELEM ProjectElementType() = 0; // Sanity-checking for returned values.
101 };
102
103 PROJECT();
104 virtual ~PROJECT();
105
106 //-----<Cross Module API>----------------------------------------------------
107
108 virtual bool TextVarResolver( wxString* aToken ) const;
109
110 virtual std::map<wxString, wxString>& GetTextVars() const;
111
115 virtual void ApplyTextVars( const std::map<wxString, wxString>& aVarsMap );
116
117 int GetTextVarsTicker() const { return m_textVarsTicker; }
118 void IncrementTextVarsTicker() { m_textVarsTicker++; }
119
120 int GetNetclassesTicker() const { return m_netclassesTicker; }
121 void IncrementNetclassesTicker() { m_netclassesTicker++; }
122
129 virtual const wxString GetProjectFullName() const;
130
137 virtual const wxString GetProjectPath() const;
138
145 virtual const wxString GetProjectDirectory() const;
146
152 virtual const wxString GetProjectName() const;
153
163 virtual bool IsNullProject() const;
164
165 virtual bool IsReadOnly() const { return m_readOnly || IsNullProject(); }
166
167 virtual void SetReadOnly( bool aReadOnly = true ) { m_readOnly = aReadOnly; }
168
172 virtual const wxString GetSheetName( const KIID& aSheetID );
173
179 virtual const wxString FootprintLibTblName() const;
180
184 virtual const wxString SymbolLibTableName() const;
185
189 virtual const wxString DesignBlockLibTblName() const;
190
192 {
196
197 LIB_TYPE_COUNT
198 };
199
200 void PinLibrary( const wxString& aLibrary, enum LIB_TYPE_T aLibType );
201 void UnpinLibrary( const wxString& aLibrary, enum LIB_TYPE_T aLibType );
202
204 {
205 wxASSERT( m_projectFile );
206 return *m_projectFile;
207 }
208
210 {
211 wxASSERT( m_localSettings );
212 return *m_localSettings;
213 }
214
217 {
220 SCH_LIB_SELECT, // eeschema/selpart.cpp
222 SCH_LIBEDIT_CUR_SYMBOL, // eeschema/libeditframe.cpp
223
226
233
234 RSTRING_COUNT
235 };
236
244 virtual const wxString& GetRString( RSTRING_T aStringId );
245
253 virtual void SetRString( RSTRING_T aStringId, const wxString& aString );
254
267 virtual _ELEM* GetElem( PROJECT::ELEM aIndex );
268 virtual void SetElem( PROJECT::ELEM aIndex, _ELEM* aElem );
269
273 void Clear() // inline not virtual
274 {
275 elemsClear();
276
277 for( unsigned i = 0; i<RSTRING_COUNT; ++i )
278 SetRString( RSTRING_T( i ), wxEmptyString );
279 }
280
287 virtual const wxString AbsolutePath( const wxString& aFileName ) const;
288
293 virtual FP_LIB_TABLE* PcbFootprintLibs( KIWAY& aKiway );
294
298 virtual DESIGN_BLOCK_LIB_TABLE* DesignBlockLibs();
299
300private:
301 friend class SETTINGS_MANAGER; // so that SM can set project path
302 friend class TEST_NETLISTS_FIXTURE; // TODO(JE) make this not required
303
304
308 virtual void elemsClear();
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
348private:
349 wxFileName m_project_name;
351
355
358
361
362 std::map<KIID, wxString> m_sheetNames;
363
365 std::array<wxString,RSTRING_COUNT> m_rstrings;
366
368 std::array<_ELEM*,static_cast<unsigned int>( PROJECT::ELEM::COUNT )> m_elems;
369};
370
371
372#endif // PROJECT_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
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:285
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
Definition: project.h:96
virtual PROJECT::ELEM ProjectElementType()=0
virtual ~_ELEM()
Definition: project.h:98
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:73
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:357
virtual void SetReadOnly(bool aReadOnly=true)
Definition: project.h:167
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:165
LIB_TYPE_T
Definition: project.h:192
@ SYMBOL_LIB
Definition: project.h:193
@ DESIGN_BLOCK_LIB
Definition: project.h:195
@ FOOTPRINT_LIB
Definition: project.h:194
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:217
@ VIEWER_3D_FILTER_INDEX
Definition: project.h:225
@ PCB_FOOTPRINT
Definition: project.h:228
@ VIEWER_3D_PATH
Definition: project.h:224
@ SCH_LIBEDIT_CUR_LIB
Definition: project.h:221
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:229
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:230
@ PCB_FOOTPRINT_VIEWER_FP_NAME
Definition: project.h:231
@ DOC_PATH
Definition: project.h:218
@ SCH_LIB_SELECT
Definition: project.h:220
@ PCB_LIB_NICKNAME
Definition: project.h:227
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:232
@ SCH_LIBEDIT_CUR_SYMBOL
Definition: project.h:222
@ SCH_LIB_PATH
Definition: project.h:219
wxString m_pro_date_and_time
Definition: project.h:350
std::map< KIID, wxString > m_sheetNames
Definition: project.h:362
virtual void setLocalSettings(PROJECT_LOCAL_SETTINGS *aSettings)
Set the local settings backing store.
Definition: project.h:338
int m_netclassesTicker
Update counter on netclasses.
Definition: project.h:354
int GetNetclassesTicker() const
Definition: project.h:120
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:209
void IncrementNetclassesTicker()
Definition: project.h:121
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:203
int GetTextVarsTicker() const
Definition: project.h:117
std::array< _ELEM *, static_cast< unsigned int >(PROJECT::ELEM::COUNT)> m_elems
Definition: project.h:368
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:349
void Clear()
Clear the _ELEMs and RSTRINGs.
Definition: project.h:273
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:360
int m_textVarsTicker
Update counter on text vars.
Definition: project.h:353
std::array< wxString, RSTRING_COUNT > m_rstrings
Definition: project.h:365
bool m_readOnly
No project files will be written to disk.
Definition: project.h:352
void IncrementTextVarsTicker()
Definition: project.h:118
ELEM
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:70
Cache for storing the 3D shapes.
Definition: 3d_cache.h:55
Holds all the data relating to one schematic.
Definition: schematic.h:69
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