25#include <wx/stdpaths.h>
66 for(
unsigned i = 0; i <
m_elems.size(); ++i )
81 if( aToken->IsSameAs( wxT(
"PROJECTNAME" ) ) )
86 else if( aToken->IsSameAs( wxT(
"CURRENT_DATE" ) ) )
91 else if( aToken->IsSameAs( wxT(
"VCSHASH" ) ) )
96 else if( aToken->IsSameAs( wxT(
"VCSSHORTHASH" ) ) )
119 if( aVarsMap.size() == 0 )
122 std::map<wxString, wxString>& existingVarsMap =
GetTextVars();
124 for(
const auto& var : aVarsMap )
127 existingVarsMap[var.first] = var.second;
136 wxFileName candidate_path( aFullPathAndName );
140 if(
m_project_name.GetFullPath() != candidate_path.GetFullPath() )
207 std::vector<wxString>* pinnedLibsCfg =
nullptr;
208 std::vector<wxString>* pinnedLibsFile =
nullptr;
225 wxFAIL_MSG(
"Cannot pin library: invalid library type" );
230 pinnedLibsFile->push_back( aLibrary );
235 pinnedLibsCfg->push_back( aLibrary );
244 std::vector<wxString>* pinnedLibsCfg =
nullptr;
245 std::vector<wxString>* pinnedLibsFile =
nullptr;
262 wxFAIL_MSG(
"Cannot unpin library: invalid library type" );
266 std::erase( *pinnedLibsFile, aLibrary );
269 std::erase( *pinnedLibsCfg, aLibrary );
277 wxString
path = fn.GetPath();
281 if( !fn.GetDirCount() || !fn.IsOk() || !wxFileName::IsDirWritable(
path ) )
293 fn.AssignDir( wxStandardPaths::Get().GetTempDir() );
296#if defined( __WINDOWS__ )
297 fn.AppendDir( wxT(
"kicad" ) );
306 fn.SetName( wxS(
"prj-" ) + aLibTableName );
310 fn.SetName( aLibTableName );
315 return fn.GetFullPath();
323 for(
const std::pair<KIID, wxString>& pair :
GetProjectFile().GetSheets() )
336 unsigned ndx = unsigned( aIndex );
347 unsigned ndx = unsigned( aIndex );
355 static wxString no_cookie_for_you;
359 return no_cookie_for_you;
368 if(
static_cast<unsigned>( aIndex ) <
m_elems.size() )
369 return m_elems[
static_cast<unsigned>( aIndex )];
378 if(
static_cast<unsigned>( aIndex ) <
m_elems.size() )
380 delete m_elems[
static_cast<unsigned>(aIndex)];
381 m_elems[
static_cast<unsigned>( aIndex )] = aElem;
388 wxFileName fn = aFileName;
392 if( aFileName.StartsWith( wxT(
"${" ) ) )
395 if( !fn.IsAbsolute() )
401 return fn.GetFullPath();
473 _(
"Error loading project design block library table." ) );
PROJECT::ELEM ProjectElementType() override
static DESIGN_BLOCK_LIB_TABLE & GetGlobalLibTable()
PROJECT::ELEM ProjectElementType() override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
static wxString GetCurrentHash(const wxString &aProjectFile, bool aShort)
Return the current HEAD commit hash for the repository containing aProjectFile.
wxString AsString() const
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
std::map< wxString, wxString > m_TextVars
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
void SetProjectLock(LOCKFILE *aLockFile)
LOCKFILE * GetProjectLock() const
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual void SetElem(PROJECT::ELEM aIndex, _ELEM *aElem)
virtual const wxString DesignBlockLibTblName() const
Return the path and file name of this projects design block library table.
void PinLibrary(const wxString &aLibrary, enum LIB_TYPE_T aLibType)
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
std::map< KIID, wxString > m_sheetNames
std::unique_ptr< LOCKFILE > m_project_lock
Lock.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
int m_netclassesTicker
Update counter on netclasses.
virtual const wxString SymbolLibTableName() const
Return the path and file name of this projects symbol library table.
virtual _ELEM * GetElem(PROJECT::ELEM aIndex)
Get and set the elements for this project.
virtual DESIGN_BLOCK_LIB_TABLE * DesignBlockLibs()
Return the table of design block libraries.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
virtual void ApplyTextVars(const std::map< wxString, wxString > &aVarsMap)
Applies the given var map, it will create or update existing vars.
virtual bool TextVarResolver(wxString *aToken) const
virtual PROJECT_FILE & GetProjectFile() const
virtual const wxString GetSheetName(const KIID &aSheetID)
Return the name of the sheet identified by the given UUID.
std::array< _ELEM *, static_cast< unsigned int >(PROJECT::ELEM::COUNT)> m_elems
virtual void elemsClear()
Delete all the _ELEMs and set their pointers to NULL.
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
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...
wxFileName m_project_name
<fullpath>/<basename>.pro
void Clear()
Clear the _ELEMs and RSTRINGs.
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
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.
int m_textVarsTicker
Update counter on text vars.
void UnpinLibrary(const wxString &aLibrary, enum LIB_TYPE_T aLibType)
std::array< wxString, RSTRING_COUNT > m_rstrings
const wxString libTableName(const wxString &aLibTableName) const
Return the full path and file name of the project specific library table aLibTableName.
virtual void setProjectFullName(const wxString &aFullPathAndName)
Set the full directory, basename, and extension of the project.
bool m_readOnly
No project files will be written to disk.
virtual const wxString GetProjectDirectory() const
Return the full path of the project DIRECTORY.
virtual std::map< wxString, wxString > & GetTextVars() const
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
ELEM
The set of #_ELEMs that a PROJECT can hold.
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Save a loaded project.
static wxString GetCurrentDate()
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static const std::string SymbolLibraryTableFileName
static const std::string ProjectFileExtension
static const std::string DesignBlockLibraryTableFileName
static const std::string FootprintLibraryTableFileName
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ KIFACE_NEW_FOOTPRINT_TABLE
Return a new FP_LIB_TABLE with the global table installed as a fallback.
This file contains miscellaneous commonly used macros and functions.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::vector< wxString > pinned_design_block_libs
std::vector< wxString > pinned_fp_libs
std::vector< wxString > pinned_symbol_libs
Implement a participant in the KIWAY alchemy.
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().