KiCad PCB EDA Suite
PROJECT Class Reference

Container for project specific data. More...

#include <project.h>

Classes

class  _ELEM
 A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives. More...
 

Public Types

enum  RSTRING_T {
  DOC_PATH , SCH_LIB_PATH , SCH_LIB_SELECT , SCH_LIBEDIT_CUR_LIB ,
  SCH_LIBEDIT_CUR_SYMBOL , VIEWER_3D_PATH , VIEWER_3D_FILTER_INDEX , PCB_LIB_NICKNAME ,
  PCB_FOOTPRINT , PCB_FOOTPRINT_EDITOR_FP_NAME , PCB_FOOTPRINT_EDITOR_LIB_NICKNAME , PCB_FOOTPRINT_VIEWER_FP_NAME ,
  PCB_FOOTPRINT_VIEWER_LIB_NICKNAME , RSTRING_COUNT
}
 Retain a number of project specific wxStrings, enumerated here: More...
 
enum  ELEM_T {
  ELEM_FPTBL , ELEM_SCH_SYMBOL_LIBS , ELEM_SCH_SEARCH_STACK , ELEM_3DCACHE ,
  ELEM_SYMBOL_LIB_TABLE , ELEM_COUNT
}
 The set of #_ELEMs that a PROJECT can hold. More...
 

Public Member Functions

 PROJECT ()
 
virtual ~PROJECT ()
 
virtual bool TextVarResolver (wxString *aToken) const
 
virtual std::map< wxString, wxString > & GetTextVars () const
 
virtual const wxString GetProjectFullName () const
 Return the full path and name of the project. More...
 
virtual const wxString GetProjectPath () const
 Return the full path of the project. More...
 
virtual const wxString GetProjectName () const
 Return the short name of the project. More...
 
virtual bool IsNullProject () const
 Check if this project is a null project (i.e. More...
 
virtual bool IsReadOnly () const
 
virtual void SetReadOnly (bool aReadOnly=true)
 
virtual const wxString GetSheetName (const KIID &aSheetID)
 Return the name of the sheet identified by the given UUID. More...
 
virtual const wxString FootprintLibTblName () const
 Returns the path and filename of this project's footprint library table. More...
 
virtual const wxString SymbolLibTableName () const
 Return the path and file name of this projects symbol library table. More...
 
void PinLibrary (const wxString &aLibrary, bool isSymbolLibrary)
 
void UnpinLibrary (const wxString &aLibrary, bool isSymbolLibrary)
 
virtual PROJECT_FILEGetProjectFile () const
 
virtual PROJECT_LOCAL_SETTINGSGetLocalSettings () const
 
virtual const wxString & GetRString (RSTRING_T aStringId)
 Return a "retained string", which is any session and project specific string identified in enum RSTRING_T. More...
 
virtual void SetRString (RSTRING_T aStringId, const wxString &aString)
 Store a "retained string", which is any session and project specific string identified in enum RSTRING_T. More...
 
virtual _ELEMGetElem (ELEM_T aIndex)
 Get and set the elements for this project. More...
 
virtual void SetElem (ELEM_T aIndex, _ELEM *aElem)
 
virtual void ElemsClear ()
 Delete all the _ELEMs and set their pointers to NULL. More...
 
void Clear ()
 Clear the _ELEMs and RSTRINGs. More...
 
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. More...
 
virtual FP_LIB_TABLEPcbFootprintLibs (KIWAY &aKiway)
 Return the table of footprint libraries. More...
 

Private Member Functions

virtual void setProjectFullName (const wxString &aFullPathAndName)
 Set the full directory, basename, and extension of the project. More...
 
virtual void setProjectFile (PROJECT_FILE *aFile)
 Set the backing store file for this project. More...
 
virtual void setLocalSettings (PROJECT_LOCAL_SETTINGS *aSettings)
 Set the local settings backing store. More...
 
const wxString libTableName (const wxString &aLibTableName) const
 Return the full path and file name of the project specific library table aLibTableName. More...
 

Private Attributes

wxFileName m_project_name
 <fullpath>/<basename>.pro More...
 
wxString m_pro_date_and_time
 True if the project is read-only: no project files will be written. More...
 
bool m_readOnly
 
PROJECT_FILEm_projectFile
 Backing store for project data – owned by SETTINGS_MANAGER. More...
 
PROJECT_LOCAL_SETTINGSm_localSettings
 Backing store for project local settings – owned by SETTINGS_MANAGER. More...
 
std::map< KIID, wxString > m_sheetNames
 
wxString m_rstrings [RSTRING_COUNT]
 
_ELEMm_elems [ELEM_COUNT]
 

Friends

class SETTINGS_MANAGER
 
class TEST_NETLISTS_FIXTURE
 

Detailed Description

Container for project specific data.

Because it is in the neutral program top, which is not linked to by subsidiary DSOs, any functions in this interface must be virtual.

Definition at line 63 of file project.h.

Member Enumeration Documentation

◆ ELEM_T

The set of #_ELEMs that a PROJECT can hold.

Enumerator
ELEM_FPTBL 
ELEM_SCH_SYMBOL_LIBS 
ELEM_SCH_SEARCH_STACK 
ELEM_3DCACHE 
ELEM_SYMBOL_LIB_TABLE 
ELEM_COUNT 

Definition at line 204 of file project.h.

205 {
207
212
214 };
@ ELEM_SYMBOL_LIB_TABLE
Definition: project.h:211
@ ELEM_SCH_SEARCH_STACK
Definition: project.h:209
@ ELEM_3DCACHE
Definition: project.h:210
@ ELEM_COUNT
Definition: project.h:213
@ ELEM_FPTBL
Definition: project.h:206
@ ELEM_SCH_SYMBOL_LIBS
Definition: project.h:208

◆ RSTRING_T

Retain a number of project specific wxStrings, enumerated here:

Enumerator
DOC_PATH 
SCH_LIB_PATH 
SCH_LIB_SELECT 
SCH_LIBEDIT_CUR_LIB 
SCH_LIBEDIT_CUR_SYMBOL 
VIEWER_3D_PATH 
VIEWER_3D_FILTER_INDEX 
PCB_LIB_NICKNAME 
PCB_FOOTPRINT 
PCB_FOOTPRINT_EDITOR_FP_NAME 
PCB_FOOTPRINT_EDITOR_LIB_NICKNAME 
PCB_FOOTPRINT_VIEWER_FP_NAME 
PCB_FOOTPRINT_VIEWER_LIB_NICKNAME 
RSTRING_COUNT 

Definition at line 162 of file project.h.

163 {
164 DOC_PATH,
166 SCH_LIB_SELECT, // eeschema/selpart.cpp
168 SCH_LIBEDIT_CUR_SYMBOL, // eeschema/libeditframe.cpp
169
172
179
181 };
@ RSTRING_COUNT
Definition: project.h:180
@ VIEWER_3D_FILTER_INDEX
Definition: project.h:171
@ PCB_FOOTPRINT
Definition: project.h:174
@ VIEWER_3D_PATH
Definition: project.h:170
@ SCH_LIBEDIT_CUR_LIB
Definition: project.h:167
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:175
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:176
@ PCB_FOOTPRINT_VIEWER_FP_NAME
Definition: project.h:177
@ DOC_PATH
Definition: project.h:164
@ SCH_LIB_SELECT
Definition: project.h:166
@ PCB_LIB_NICKNAME
Definition: project.h:173
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:178
@ SCH_LIBEDIT_CUR_SYMBOL
Definition: project.h:168
@ SCH_LIB_PATH
Definition: project.h:165

Constructor & Destructor Documentation

◆ PROJECT()

PROJECT::PROJECT ( )

Definition at line 44 of file project.cpp.

44 :
45 m_readOnly( false ),
46 m_projectFile( nullptr ),
47 m_localSettings( nullptr )
48{
49 memset( m_elems, 0, sizeof( m_elems ) );
50}
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:355
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:366
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:358
bool m_readOnly
Definition: project.h:352

References m_elems.

◆ ~PROJECT()

PROJECT::~PROJECT ( )
virtual

Definition at line 64 of file project.cpp.

65{
66 ElemsClear();
67}
virtual void ElemsClear()
Delete all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:53

References ElemsClear().

Member Function Documentation

◆ AbsolutePath()

const wxString PROJECT::AbsolutePath ( const wxString &  aFileName) const
virtual

Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.

This intends to overcome the now missing chdir() into the project directory.

Definition at line 305 of file project.cpp.

306{
307 wxFileName fn = aFileName;
308
309 // Paths which start with an unresolved variable reference are more likely to be
310 // absolute than relative.
311 if( aFileName.StartsWith( wxT( "${" ) ) )
312 return aFileName;
313
314 if( !fn.IsAbsolute() )
315 {
316 wxString pro_dir = wxPathOnly( GetProjectFullName() );
317 fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS, pro_dir );
318 }
319
320 return fn.GetFullPath();
321}
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:120
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:38

References FN_NORMALIZE_FLAGS, and GetProjectFullName().

Referenced by PCB_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::doCloseWindow(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_BASE_EDIT_FRAME::GetDesignRulesPath(), DIALOG_GENDRILL::OnGenReportFile(), SCH_EDIT_FRAME::OnOpenCvpcb(), SCH_EDIT_FRAME::OnOpenPcbnew(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Print(), SCH_EDIT_FRAME::PrintPage(), SIM_LIB_MGR::ResolveLibraryPath(), SCH_EDIT_FRAME::SaveProject(), SCH_EDIT_FRAME::saveSchematicFile(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), SIM_PLOT_FRAME::updateTitle(), and WriteDRCReport().

◆ Clear()

void PROJECT::Clear ( )
inline

Clear the _ELEMs and RSTRINGs.

Definition at line 239 of file project.h.

240 {
241 ElemsClear();
242
243 for( unsigned i = 0; i<RSTRING_COUNT; ++i )
244 SetRString( RSTRING_T( i ), wxEmptyString );
245 }
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:163
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:254

References ElemsClear(), RSTRING_COUNT, and SetRString().

Referenced by setProjectFullName().

◆ ElemsClear()

void PROJECT::ElemsClear ( )
virtual

Delete all the _ELEMs and set their pointers to NULL.

Definition at line 53 of file project.cpp.

54{
55 // careful here, this should work, but the virtual destructor may not
56 // be in the same link image as PROJECT.
57 for( unsigned i = 0; i < arrayDim( m_elems ); ++i )
58 {
59 SetElem( ELEM_T( i ), nullptr );
60 }
61}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:294
ELEM_T
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:205

References arrayDim(), m_elems, and SetElem().

Referenced by Clear(), and ~PROJECT().

◆ FootprintLibTblName()

const wxString PROJECT::FootprintLibTblName ( ) const
virtual

Returns the path and filename of this project's footprint library table.

This project specific footprint library table not the global one.

Definition at line 150 of file project.cpp.

151{
152 return libTableName( wxS( "fp-lib-table" ) );
153}
const wxString libTableName(const wxString &aLibTableName) const
Return the full path and file name of the project specific library table aLibTableName.
Definition: project.cpp:194

References libTableName().

Referenced by InvokePcbLibTableEditor(), PCB_EDIT_FRAME::OpenProjectFiles(), and PcbFootprintLibs().

◆ GetElem()

PROJECT::_ELEM * PROJECT::GetElem ( ELEM_T  aIndex)
virtual

Get and set the elements for this project.

This is a cross module API, therefore the #_ELEM destructor is virtual and can point to a destructor function in another link image. Be careful that that program module is resident at time of destruction.

Summary: -#) cross module API. -#) PROJECT knows nothing about #_ELEM objects except how to delete them and set and get pointers to them.

Definition at line 284 of file project.cpp.

285{
286 // This is virtual, so implement it out of line
287 if( unsigned( aIndex ) < arrayDim( m_elems ) )
288 return m_elems[aIndex];
289
290 return nullptr;
291}

References arrayDim(), and m_elems.

Referenced by PcbFootprintLibs(), and LEGACY_RESCUER::WriteRescueLibrary().

◆ GetLocalSettings()

◆ GetProjectFile()

virtual PROJECT_FILE & PROJECT::GetProjectFile ( ) const
inlinevirtual

Definition at line 149 of file project.h.

150 {
151 wxASSERT( m_projectFile );
152 return *m_projectFile;
153 }

References m_projectFile.

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), FP_TREE_MODEL_ADAPTER::AddLibraries(), CONNECTION_GRAPH::buildConnectionGraph(), CVPCB_MAINFRAME::buildEquivalenceList(), CVPCB_MAINFRAME::BuildLibrariesListBox(), FOOTPRINT_EDIT_FRAME::buildSaveAsDialog(), SYMBOL_EDIT_FRAME::buildSaveAsDialog(), BOARD::ClearProject(), DIALOG_ASSIGN_NETCLASS::DIALOG_ASSIGN_NETCLASS(), DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP(), DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP(), SCH_EDIT_FRAME::doCloseWindow(), SCHEMATIC::ErcSettings(), SCH_ITEM::GetEffectiveNetClass(), PCB_EDIT_FRAME::GetLastPath(), SYMBOL_LIBS::GetLibNamesAndPaths(), SCH_EDIT_FRAME::GetSchematicJunctionSize(), GetSheetName(), GetTextVars(), DIALOG_CONFIG_EQUFILES::Init(), FIELDS_GRID_TABLE< T >::initGrid(), PCB_EDIT_FRAME::LoadProjectSettings(), SIM_PLOT_FRAME::LoadSettings(), DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), DIALOG_BOARD_SETUP::onAuxiliaryAction(), DIALOG_CONFIG_EQUFILES::OnOkClick(), SCH_BASE_FRAME::PickSymbolFromLibTree(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), SCHEMATIC::Reset(), SCH_EDIT_FRAME::SaveProject(), KICAD_MANAGER_CONTROL::SaveProjectAs(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), ROUTER_TOOL::saveRouterDebugLog(), SIM_PLOT_FRAME::SaveSettings(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), PCB_EDIT_FRAME::SetLastPath(), SYMBOL_LIBS::SetLibNamesAndPaths(), SCHEMATIC::SetProject(), BOARD::SetProject(), SCHEMATIC::Settings(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), DIALOG_ASSIGN_NETCLASS::TransferDataFromWindow(), and EDA_3D_VIEWER_FRAME::~EDA_3D_VIEWER_FRAME().

◆ GetProjectFullName()

const wxString PROJECT::GetProjectFullName ( ) const
virtual

◆ GetProjectName()

◆ GetProjectPath()

const wxString PROJECT::GetProjectPath ( ) const
virtual

Return the full path of the project.

This is the path of the project file and will always be an absolute path, ending with a path separator.

Definition at line 126 of file project.cpp.

127{
128 return m_project_name.GetPathWithSep();
129}

References m_project_name.

Referenced by PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), PCB_BASE_EDIT_FRAME::createNewLibrary(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), KICAD_MANAGER_CONTROL::Execute(), FOOTPRINT_LIST::GetInstance(), SCH_ALTIUM_PLUGIN::getLibFileName(), SCH_EAGLE_PLUGIN::getLibFileName(), SETTINGS_MANAGER::GetPathForSettingsFile(), SETTINGS_MANAGER::GetProjectBackupsPath(), EESCHEMA_JOBS_HANDLER::InitRenderSettings(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), EDA_DRAW_FRAME::LibraryFileBrowser(), SCH_ALTIUM_PLUGIN::Load(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_SEXPR_PLUGIN::Load(), SCH_LEGACY_PLUGIN::Load(), SCH_EDIT_FRAME::LoadProject(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheets(), NormalizePath(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel(), DIALOG_SIM_MODEL< T_symbol, T_field >::onBrowseButtonClick(), WX_HTML_REPORT_PANEL::onBtnSaveToFile(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), PANEL_FP_PROPERTIES_3D_MODEL::PANEL_FP_PROPERTIES_3D_MODEL(), PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE(), SCH_ALTIUM_PLUGIN::ParseAltiumSch(), SCH_ALTIUM_PLUGIN::ParseHarnessType(), SCH_EDITOR_CONTROL::Paste(), PathIsInsideProject(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), ResolveFile(), SETTINGS_MANAGER::SaveProject(), SIM_PLOT_FRAME::saveWorkbook(), FILENAME_RESOLVER::SetProject(), SCH_EDIT_FRAME::WriteNetListFile(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

◆ GetRString()

const wxString & PROJECT::GetRString ( RSTRING_T  aStringId)
virtual

Return a "retained string", which is any session and project specific string identified in enum RSTRING_T.

Retained strings are not written to disk, and are therefore good only for the current session.

Definition at line 265 of file project.cpp.

266{
267 unsigned ndx = unsigned( aIndex );
268
269 if( ndx < arrayDim( m_rstrings ) )
270 {
271 return m_rstrings[ndx];
272 }
273 else
274 {
275 static wxString no_cookie_for_you;
276
277 wxASSERT( 0 ); // bad index
278
279 return no_cookie_for_you;
280 }
281}
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:363

References arrayDim(), and m_rstrings.

Referenced by PCB_EDIT_FRAME::ExportFootprintsToLibrary(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), SYMBOL_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), SYMBOL_EDIT_FRAME::saveLibrary(), and SCH_BASE_FRAME::SelectLibraryFromList().

◆ GetSheetName()

const wxString PROJECT::GetSheetName ( const KIID aSheetID)
virtual

Return the name of the sheet identified by the given UUID.

Definition at line 239 of file project.cpp.

240{
241 if( m_sheetNames.empty() )
242 {
243 for( const std::pair<KIID, wxString>& pair : GetProjectFile().GetSheets() )
244 m_sheetNames[pair.first] = pair.second;
245 }
246
247 if( m_sheetNames.count( aSheetID ) )
248 return m_sheetNames.at( aSheetID );
249 else
250 return aSheetID.AsString();
251}
wxString AsString() const
Definition: kiid.cpp:257
std::map< KIID, wxString > m_sheetNames
Definition: project.h:360
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149

References KIID::AsString(), GetProjectFile(), and m_sheetNames.

◆ GetTextVars()

◆ IsNullProject()

bool PROJECT::IsNullProject ( ) const
virtual

Check if this project is a null project (i.e.

the default project object created when no real project is open).

The null project still presents all the same project interface, but is not backed by any files, so saving it makes no sense.

Returns
true if this is an empty project.

Definition at line 138 of file project.cpp.

139{
140 return m_project_name.GetName().IsEmpty();
141}

References m_project_name.

Referenced by AskSaveBoardFileName(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), IsReadOnly(), EDA_DRAW_FRAME::LibraryFileBrowser(), SYMBOL_LIBS::LoadAllLibraries(), PCB_EDIT_FRAME::SaveProjectSettings(), BOARD::SynchronizeProperties(), PANEL_SETUP_RULES::TransferDataFromWindow(), and PANEL_SETUP_RULES::TransferDataToWindow().

◆ IsReadOnly()

virtual bool PROJECT::IsReadOnly ( ) const
inlinevirtual

Definition at line 125 of file project.h.

125{ return m_readOnly || IsNullProject(); }
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:138

References IsNullProject(), and m_readOnly.

Referenced by SETTINGS_MANAGER::SaveProject(), and SETTINGS_MANAGER::SaveProjectAs().

◆ libTableName()

const wxString PROJECT::libTableName ( const wxString &  aLibTableName) const
private

Return the full path and file name of the project specific library table aLibTableName.

Definition at line 194 of file project.cpp.

195{
196 wxFileName fn = GetProjectFullName();
197 wxString path = fn.GetPath();
198
199 // if there's no path to the project name, or the name as a whole is bogus or its not
200 // write-able then use a template file.
201 if( !fn.GetDirCount() || !fn.IsOk() || !wxFileName::IsDirWritable( path ) )
202 {
203 // return a template filename now.
204
205 // this next line is likely a problem now, since it relies on an
206 // application title which is no longer constant or known. This next line needs
207 // to be re-thought out.
208
209#ifdef __WXMAC__
210 fn.AssignDir( KIPLATFORM::ENV::GetUserConfigPath() );
211#else
212 // don't pollute home folder, temp folder seems to be more appropriate
213 fn.AssignDir( wxStandardPaths::Get().GetTempDir() );
214#endif
215
216#if defined( __WINDOWS__ )
217 fn.AppendDir( wxT( "kicad" ) );
218#endif
219
220 /*
221 * The library table name used when no project file is passed to the appropriate
222 * code. This is used temporarily to store the project specific library table
223 * until the project file being edited is saved. It is then moved to the correct
224 * file in the folder where the project file is saved.
225 */
226 fn.SetName( wxS( "prj-" ) + aLibTableName );
227 }
228 else // normal path.
229 {
230 fn.SetName( aLibTableName );
231 }
232
233 fn.ClearExt();
234
235 return fn.GetFullPath();
236}
wxString GetUserConfigPath()
Retrieves the operating system specific path for a user's configuration store.

References GetProjectFullName(), KIPLATFORM::ENV::GetUserConfigPath(), and path.

Referenced by FootprintLibTblName(), and SymbolLibTableName().

◆ PcbFootprintLibs()

FP_LIB_TABLE * PROJECT::PcbFootprintLibs ( KIWAY aKiway)
virtual

Return the table of footprint libraries.

Requires an active Kiway as this is fetched from Pcbnew.

Definition at line 324 of file project.cpp.

325{
326 // This is a lazy loading function, it loads the project specific table when
327 // that table is asked for, not before.
328
330
331 if( tbl )
332 {
333 wxASSERT( tbl->Type() == FP_LIB_TABLE_T );
334 }
335 else
336 {
337 try
338 {
339 // Build a new project specific FP_LIB_TABLE with the global table as a fallback.
340 // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
341 // stack this way, all using the same global fallback table.
342 KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB );
343
344 tbl = (FP_LIB_TABLE*) kiface->IfaceOrAddress( KIFACE_NEW_FOOTPRINT_TABLE );
345 tbl->Load( FootprintLibTblName() );
346
347 SetElem( ELEM_FPTBL, tbl );
348 }
349 catch( const IO_ERROR& ioe )
350 {
351 DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ),
352 ioe.What() );
353 }
354 catch( ... )
355 {
356 DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
357 }
358 }
359
360 return tbl;
361}
KICAD_T Type() override
Definition: fp_lib_table.h:99
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition: kiway.cpp:198
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:282
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:150
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:284
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
return & kiface
Definition: cvpcb.cpp:112
#define _(s)
@ KIFACE_NEW_FOOTPRINT_TABLE
Return a new FP_LIB_TABLE with the global table installed as a fallback.
Definition: kiface_ids.h:46
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:151
@ FP_LIB_TABLE_T
Definition: typeinfo.h:235

References _, DisplayErrorMessage(), ELEM_FPTBL, KIWAY::FACE_PCB, FootprintLibTblName(), FP_LIB_TABLE_T, GetElem(), kiface, KIWAY::KiFACE(), KIFACE_NEW_FOOTPRINT_TABLE, LIB_TABLE::Load(), SetElem(), FP_LIB_TABLE::Type(), and IO_ERROR::What().

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), CVPCB_MAINFRAME::BuildLibrariesListBox(), FOOTPRINT_EDIT_FRAME::buildSaveAsDialog(), EXPORTER_STEP::composePCB(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), FOOTPRINT_PREVIEW_PANEL::DisplayFootprint(), CVPCB_MAINFRAME::DisplayStatus(), FOOTPRINT_EDIT_FRAME::DuplicateFootprint(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), idf_export_footprint(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), InvokePcbLibTableEditor(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_SELECT_WIDGET::Load(), RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_OPENGL::load3dModels(), PCB_BASE_FRAME::loadFootprint(), CVPCB_MAINFRAME::LoadFootprintFiles(), FOOTPRINT_VIEWER_FRAME::OnActivate(), PCB_EDIT_FRAME::OpenProjectFiles(), FOOTPRINT_EDITOR_CONTROL::PasteFootprint(), CVPCB_MAINFRAME::readNetListAndFpFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), FOOTPRINT_EDITOR_CONTROL::RenameFootprint(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), PCB_BASE_FRAME::SelectLibrary(), PCB_BASE_EDIT_FRAME::selectLibTable(), FOOTPRINT_VIEWER_FRAME::ShowModal(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), and PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists().

◆ PinLibrary()

void PROJECT::PinLibrary ( const wxString &  aLibrary,
bool  isSymbolLibrary 
)

Definition at line 156 of file project.cpp.

157{
158 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
159 std::vector<wxString>* pinnedLibs = isSymbolLibrary ? &m_projectFile->m_PinnedSymbolLibs
161
162 if( !alg::contains( *pinnedLibs, aLibrary ) )
163 pinnedLibs->push_back( aLibrary );
164
165 Pgm().GetSettingsManager().SaveProject();
166
167 pinnedLibs = isSymbolLibrary ? &cfg->m_Session.pinned_symbol_libs
169
170 if( !alg::contains( *pinnedLibs, aLibrary ) )
171 pinnedLibs->push_back( aLibrary );
172
173 cfg->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( cfg ) );
174}
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
std::vector< wxString > m_PinnedFootprintLibs
The list of pinned footprint libraries.
Definition: project_file.h:118
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Definition: project_file.h:115
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
SETTINGS_MANAGER * GetSettingsManager()
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
std::vector< wxString > pinned_fp_libs
std::vector< wxString > pinned_symbol_libs

References alg::contains(), GetSettingsManager(), PROJECT_FILE::m_PinnedFootprintLibs, PROJECT_FILE::m_PinnedSymbolLibs, m_projectFile, COMMON_SETTINGS::m_Session, Pgm(), COMMON_SETTINGS::SESSION::pinned_fp_libs, COMMON_SETTINGS::SESSION::pinned_symbol_libs, and JSON_SETTINGS::SaveToFile().

Referenced by SYMBOL_EDITOR_CONTROL::PinLibrary(), FOOTPRINT_EDITOR_CONTROL::PinLibrary(), and LIB_TREE_MODEL_ADAPTER::PinLibrary().

◆ SetElem()

void PROJECT::SetElem ( ELEM_T  aIndex,
_ELEM aElem 
)
virtual

◆ setLocalSettings()

virtual void PROJECT::setLocalSettings ( PROJECT_LOCAL_SETTINGS aSettings)
inlineprivatevirtual

Set the local settings backing store.

This should only be called by SETTINGS_MANAGER on load.

Parameters
aSettingsis the local settings object (may or may not exist on disk at this point)

Definition at line 338 of file project.h.

339 {
340 m_localSettings = aSettings;
341 }

References m_localSettings.

◆ setProjectFile()

virtual void PROJECT::setProjectFile ( PROJECT_FILE aFile)
inlineprivatevirtual

Set the backing store file for this project.

This should only be called by #SETTINGS_MANGER on load.

Parameters
aFileis a loaded PROJECT_FILE.

Definition at line 326 of file project.h.

327 {
328 m_projectFile = aFile;
329 }

References m_projectFile.

Referenced by SETTINGS_MANAGER::loadProjectFile().

◆ setProjectFullName()

void PROJECT::setProjectFullName ( const wxString &  aFullPathAndName)
privatevirtual

Set the full directory, basename, and extension of the project.

This is the name of the project file with full absolute path and it also defines the name of the project. The project name and the project file names are exactly the same, providing the project filename is absolute.

Definition at line 88 of file project.cpp.

89{
90 // Compare paths, rather than inodes, to be less surprising to the user.
91 // Create a temporary wxFileName to normalize the path
92 wxFileName candidate_path( aFullPathAndName );
93
94 // Edge transitions only. This is what clears the project
95 // data using the Clear() function.
96 if( m_project_name.GetFullPath() != candidate_path.GetFullPath() )
97 {
98 Clear(); // clear the data when the project changes.
99
100 wxLogTrace( tracePathsAndFiles, "%s: old:'%s' new:'%s'", __func__,
101 TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) );
102
103 m_project_name = aFullPathAndName;
104
105 wxASSERT( m_project_name.IsAbsolute() );
106
107 wxASSERT( m_project_name.GetExt() == ProjectFileExtension );
108
109 // until multiple projects are in play, set an environment variable for the
110 // the project pointer.
111 {
112 wxString path = m_project_name.GetPath();
113
114 wxSetEnv( PROJECT_VAR_NAME, path );
115 }
116 }
117}
void Clear()
Clear the _ELEMs and RSTRINGs.
Definition: project.h:239
const std::string ProjectFileExtension
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:39

References Clear(), GetProjectFullName(), m_project_name, path, PROJECT_VAR_NAME, ProjectFileExtension, TO_UTF8, and tracePathsAndFiles.

Referenced by SETTINGS_MANAGER::SaveProjectAs().

◆ SetReadOnly()

virtual void PROJECT::SetReadOnly ( bool  aReadOnly = true)
inlinevirtual

◆ SetRString()

void PROJECT::SetRString ( RSTRING_T  aStringId,
const wxString &  aString 
)
virtual

Store a "retained string", which is any session and project specific string identified in enum RSTRING_T.

Retained strings are not written to disk, and are therefore good only for the current session.

Definition at line 254 of file project.cpp.

255{
256 unsigned ndx = unsigned( aIndex );
257
258 if( ndx < arrayDim( m_rstrings ) )
259 m_rstrings[ndx] = aString;
260 else
261 wxASSERT( 0 ); // bad index
262}

References arrayDim(), and m_rstrings.

Referenced by Clear(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), SYMBOL_EDIT_FRAME::GetCurLib(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SYMBOL_EDIT_FRAME::saveLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), SYMBOL_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), and SYMBOL_EDIT_FRAME::SetCurSymbol().

◆ SymbolLibTableName()

const wxString PROJECT::SymbolLibTableName ( ) const
virtual

Return the path and file name of this projects symbol library table.

Definition at line 144 of file project.cpp.

145{
146 return libTableName( wxS( "sym-lib-table" ) );
147}

References libTableName().

◆ TextVarResolver()

bool PROJECT::TextVarResolver ( wxString *  aToken) const
virtual

Definition at line 70 of file project.cpp.

71{
72 if( GetTextVars().count( *aToken ) > 0 )
73 {
74 *aToken = GetTextVars().at( *aToken );
75 return true;
76 }
77
78 return false;
79}
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:82

References GetTextVars().

Referenced by ExpandTextVars(), KIwxExpandEnvVars(), and BOARD::ResolveTextVar().

◆ UnpinLibrary()

void PROJECT::UnpinLibrary ( const wxString &  aLibrary,
bool  isSymbolLibrary 
)

Definition at line 177 of file project.cpp.

178{
179 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
180 std::vector<wxString>* pinnedLibs = isSymbolLibrary ? &m_projectFile->m_PinnedSymbolLibs
182
183 alg::delete_matching( *pinnedLibs, aLibrary );
184 Pgm().GetSettingsManager().SaveProject();
185
186 pinnedLibs = isSymbolLibrary ? &cfg->m_Session.pinned_symbol_libs
188
189 alg::delete_matching( *pinnedLibs, aLibrary );
190 cfg->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( cfg ) );
191}
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
Definition: kicad_algo.h:164

References alg::delete_matching(), GetSettingsManager(), PROJECT_FILE::m_PinnedFootprintLibs, PROJECT_FILE::m_PinnedSymbolLibs, m_projectFile, COMMON_SETTINGS::m_Session, Pgm(), COMMON_SETTINGS::SESSION::pinned_fp_libs, COMMON_SETTINGS::SESSION::pinned_symbol_libs, and JSON_SETTINGS::SaveToFile().

Referenced by SYMBOL_EDITOR_CONTROL::UnpinLibrary(), FOOTPRINT_EDITOR_CONTROL::UnpinLibrary(), and LIB_TREE_MODEL_ADAPTER::UnpinLibrary().

Friends And Related Function Documentation

◆ SETTINGS_MANAGER

friend class SETTINGS_MANAGER
friend

Definition at line 307 of file project.h.

◆ TEST_NETLISTS_FIXTURE

friend class TEST_NETLISTS_FIXTURE
friend

Definition at line 308 of file project.h.

Member Data Documentation

◆ m_elems

_ELEM* PROJECT::m_elems[ELEM_COUNT]
private
See also
this::Elem() and enum ELEM_T.

Definition at line 366 of file project.h.

Referenced by ElemsClear(), GetElem(), PROJECT(), and SetElem().

◆ m_localSettings

PROJECT_LOCAL_SETTINGS* PROJECT::m_localSettings
private

Backing store for project local settings – owned by SETTINGS_MANAGER.

Definition at line 358 of file project.h.

Referenced by GetLocalSettings(), and setLocalSettings().

◆ m_pro_date_and_time

wxString PROJECT::m_pro_date_and_time
private

True if the project is read-only: no project files will be written.

Definition at line 349 of file project.h.

◆ m_project_name

wxFileName PROJECT::m_project_name
private

<fullpath>/<basename>.pro

Definition at line 348 of file project.h.

Referenced by GetProjectFullName(), GetProjectName(), GetProjectPath(), IsNullProject(), and setProjectFullName().

◆ m_projectFile

PROJECT_FILE* PROJECT::m_projectFile
private

Backing store for project data – owned by SETTINGS_MANAGER.

Definition at line 355 of file project.h.

Referenced by GetProjectFile(), PinLibrary(), setProjectFile(), and UnpinLibrary().

◆ m_readOnly

bool PROJECT::m_readOnly
private

Definition at line 352 of file project.h.

Referenced by IsReadOnly(), and SetReadOnly().

◆ m_rstrings

wxString PROJECT::m_rstrings[RSTRING_COUNT]
private
See also
this::SetRString(), GetRString(), and enum RSTRING_T.

Definition at line 363 of file project.h.

Referenced by GetRString(), and SetRString().

◆ m_sheetNames

std::map<KIID, wxString> PROJECT::m_sheetNames
private

Definition at line 360 of file project.h.

Referenced by GetSheetName().


The documentation for this class was generated from the following files: