25#include <wx/stdpaths.h>
46 m_textVarsTicker( 0 ),
47 m_netclassesTicker( 0 ),
48 m_projectFile( nullptr ),
49 m_localSettings( nullptr )
59 for(
unsigned i = 0; i <
m_elems.size(); ++i )
92 if( aVarsMap.size() == 0 )
95 std::map<wxString, wxString>& existingVarsMap =
GetTextVars();
97 for(
const auto& var : aVarsMap )
100 existingVarsMap[var.first] = var.second;
109 wxFileName candidate_path( aFullPathAndName );
113 if(
m_project_name.GetFullPath() != candidate_path.GetFullPath() )
180 std::vector<wxString>* pinnedLibsCfg =
nullptr;
181 std::vector<wxString>* pinnedLibsFile =
nullptr;
198 wxFAIL_MSG(
"Cannot pin library: invalid library type" );
203 pinnedLibsFile->push_back( aLibrary );
208 pinnedLibsCfg->push_back( aLibrary );
217 std::vector<wxString>* pinnedLibsCfg =
nullptr;
218 std::vector<wxString>* pinnedLibsFile =
nullptr;
235 wxFAIL_MSG(
"Cannot unpin library: invalid library type" );
250 wxString
path = fn.GetPath();
254 if( !fn.GetDirCount() || !fn.IsOk() || !wxFileName::IsDirWritable(
path ) )
266 fn.AssignDir( wxStandardPaths::Get().GetTempDir() );
269#if defined( __WINDOWS__ )
270 fn.AppendDir( wxT(
"kicad" ) );
279 fn.SetName( wxS(
"prj-" ) + aLibTableName );
283 fn.SetName( aLibTableName );
288 return fn.GetFullPath();
296 for(
const std::pair<KIID, wxString>& pair :
GetProjectFile().GetSheets() )
309 unsigned ndx = unsigned( aIndex );
320 unsigned ndx = unsigned( aIndex );
328 static wxString no_cookie_for_you;
332 return no_cookie_for_you;
341 if(
static_cast<unsigned>( aIndex ) <
m_elems.size() )
342 return m_elems[
static_cast<unsigned>( aIndex )];
351 if(
static_cast<unsigned>( aIndex ) <
m_elems.size() )
353 delete m_elems[
static_cast<unsigned>(aIndex)];
354 m_elems[
static_cast<unsigned>( aIndex )] = aElem;
361 wxFileName fn = aFileName;
365 if( aFileName.StartsWith( wxT(
"${" ) ) )
368 if( !fn.IsAbsolute() )
374 return fn.GetFullPath();
446 _(
"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.
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
std::vector< wxString > m_PinnedDesignBlockLibs
The list of pinned design block libraries.
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
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
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
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 void ElemsClear()
Delete all the _ELEMs and set their pointers to NULL.
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 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.
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.
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.
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)
Saves a loaded project.
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 ProjectFileExtension
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.
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
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
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
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().