KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 class  ELEM {
  FPTBL , LEGACY_SYMBOL_LIBS , SCH_SEARCH_STACK , S3DCACHE ,
  SYMBOL_LIB_TABLE , SEARCH_STACK , DESIGN_BLOCK_LIB_TABLE , SCHEMATIC ,
  BOARD , COUNT
}
 The set of #_ELEMs that a PROJECT can hold. More...
 
enum  LIB_TYPE_T { SYMBOL_LIB , FOOTPRINT_LIB , DESIGN_BLOCK_LIB , LIB_TYPE_COUNT }
 
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_PATH ,
  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...
 

Public Member Functions

 PROJECT ()
 
virtual ~PROJECT ()
 
virtual bool TextVarResolver (wxString *aToken) const
 
virtual std::map< wxString, wxString > & GetTextVars () const
 
virtual void ApplyTextVars (const std::map< wxString, wxString > &aVarsMap)
 Applies the given var map, it will create or update existing vars.
 
int GetTextVarsTicker () const
 
void IncrementTextVarsTicker ()
 
int GetNetclassesTicker () const
 
void IncrementNetclassesTicker ()
 
virtual const wxString GetProjectFullName () const
 Return the full path and name of the project.
 
virtual const wxString GetProjectPath () const
 Return the full path of the project.
 
virtual const wxString GetProjectDirectory () const
 Return the full path of the project DIRECTORY.
 
virtual const wxString GetProjectName () const
 Return the short name of the project.
 
virtual bool IsNullProject () const
 Check if this project is a null project (i.e.
 
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.
 
virtual const wxString FootprintLibTblName () const
 Returns the path and filename of this project's footprint library table.
 
virtual const wxString SymbolLibTableName () const
 Return the path and file name of this projects symbol library table.
 
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)
 
void UnpinLibrary (const wxString &aLibrary, enum LIB_TYPE_T aLibType)
 
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.
 
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.
 
virtual _ELEMGetElem (PROJECT::ELEM aIndex)
 Get and set the elements for this project.
 
virtual void SetElem (PROJECT::ELEM aIndex, _ELEM *aElem)
 
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.
 
virtual FP_LIB_TABLEPcbFootprintLibs (KIWAY &aKiway)
 Return the table of footprint libraries.
 
virtual DESIGN_BLOCK_LIBRARY_ADAPTERDesignBlockLibs ()
 Return the table of design block libraries.
 
void SetProjectLock (LOCKFILE *aLockFile)
 
LOCKFILEGetProjectLock () const
 
void SaveToHistory (const wxString &aProjectPath, std::vector< wxString > &aFiles)
 Save project files (.kicad_pro and .kicad_prl) to the .history directory.
 

Private Member Functions

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

Private Attributes

wxFileName m_project_name
 <fullpath>/<basename>.pro
 
bool m_readOnly
 No project files will be written to disk.
 
int m_textVarsTicker
 Update counter on text vars.
 
int m_netclassesTicker
 Update counter on netclasses.
 
PROJECT_FILEm_projectFile
 Backing store for project data – owned by SETTINGS_MANAGER.
 
PROJECT_LOCAL_SETTINGSm_localSettings
 Backing store for project local settings – owned by SETTINGS_MANAGER.
 
std::map< KIID, wxString > m_sheetNames
 
std::array< wxString, RSTRING_COUNTm_rstrings
 
std::array< _ELEM *, static_cast< unsigned int >(PROJECT::ELEM::COUNT)> m_elems
 
std::unique_ptr< LOCKFILEm_project_lock
 Lock.
 
std::mutex m_designBlockLibsMutex
 Synchronise access to DesignBlockLibs()
 

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 65 of file project.h.

Member Enumeration Documentation

◆ ELEM

enum class PROJECT::ELEM
strong

The set of #_ELEMs that a PROJECT can hold.

Enumerator
FPTBL 
LEGACY_SYMBOL_LIBS 
SCH_SEARCH_STACK 
S3DCACHE 
SYMBOL_LIB_TABLE 
SEARCH_STACK 
DESIGN_BLOCK_LIB_TABLE 
SCHEMATIC 
BOARD 
COUNT 

Definition at line 71 of file project.h.

◆ LIB_TYPE_T

Enumerator
SYMBOL_LIB 
FOOTPRINT_LIB 
DESIGN_BLOCK_LIB 
LIB_TYPE_COUNT 

Definition at line 193 of file project.h.

◆ 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_PATH 
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 218 of file project.h.

Constructor & Destructor Documentation

◆ PROJECT()

PROJECT::PROJECT ( )

◆ ~PROJECT()

PROJECT::~PROJECT ( )
virtual

Definition at line 76 of file project.cpp.

References elemsClear().

Member Function Documentation

◆ AbsolutePath()

◆ ApplyTextVars()

void PROJECT::ApplyTextVars ( const std::map< wxString, wxString > & aVarsMap)
virtual

◆ Clear()

void PROJECT::Clear ( )
inline

Clear the _ELEMs and RSTRINGs.

Definition at line 276 of file project.h.

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

Referenced by setProjectFullName().

◆ DesignBlockLibs()

◆ DesignBlockLibTblName()

const wxString PROJECT::DesignBlockLibTblName ( ) const
virtual

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

Definition at line 201 of file project.cpp.

References FILEEXT::DesignBlockLibraryTableFileName, and libTableName().

Referenced by InvokeEditDesignBlockLibTable().

◆ elemsClear()

void PROJECT::elemsClear ( )
privatevirtual

Delete all the _ELEMs and set their pointers to NULL.

Definition at line 65 of file project.cpp.

References m_elems, and SetElem().

Referenced by Clear(), TEST_NETLISTS_FIXTURE, 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 195 of file project.cpp.

References FILEEXT::FootprintLibraryTableFileName, and libTableName().

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

◆ GetElem()

PROJECT::_ELEM * PROJECT::GetElem ( PROJECT::ELEM 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 367 of file project.cpp.

References m_elems.

Referenced by PROJECT_PCB::Cleanup3DCache(), PROJECT_PCB::Get3DCacheManager(), PROJECT_SCH::LegacySchLibs(), PcbFootprintLibs(), PROJECT_PCB::PcbFootprintLibs(), and PROJECT_SCH::SchSearchS().

◆ GetLocalSettings()

◆ GetNetclassesTicker()

int PROJECT::GetNetclassesTicker ( ) const
inline

Definition at line 122 of file project.h.

References m_netclassesTicker.

◆ GetProjectDirectory()

const wxString PROJECT::GetProjectDirectory ( ) const
virtual

Return the full path of the project DIRECTORY.

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

Definition at line 171 of file project.cpp.

References m_project_name.

Referenced by PROJECT_SCH::SchSearchS().

◆ GetProjectFile()

virtual PROJECT_FILE & PROJECT::GetProjectFile ( ) const
inlinevirtual

Definition at line 205 of file project.h.

References m_projectFile.

Referenced by DESIGN_BLOCK_TREE_MODEL_ADAPTER::AddLibraries(), FP_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), CVPCB_MAINFRAME::buildEquivalenceList(), CVPCB_MAINFRAME::BuildLibrariesList(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), EVT_UPDATE_UI_RANGE(), SCH_ITEM::GetEffectiveNetClass(), PCB_EDIT_FRAME::GetLastPath(), LEGACY_SYMBOL_LIBS::GetLibNamesAndPaths(), PCB_BASE_FRAME::GetLibraryItemsForListDialog(), SCH_BASE_FRAME::GetLibraryItemsForListDialog(), SCH_EDIT_FRAME::GetSchematicHopOverScale(), SCH_EDIT_FRAME::GetSchematicJunctionSize(), GetSheetName(), GetTextVars(), API_HANDLER_COMMON::handleGetNetClasses(), API_HANDLER_COMMON::handleSetNetClasses(), FIELDS_GRID_TABLE::initGrid(), PCB_EDIT_FRAME::LoadDrawingSheet(), PCBNEW_JOBS_HANDLER::loadOverrideDrawingSheet(), PCB_EDIT_FRAME::LoadProjectSettings(), SIMULATOR_FRAME::LoadSettings(), DIALOG_BOARD_SETUP::onAuxiliaryAction(), DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), PCB_EDIT_FRAME::OnBoardLoaded(), DIALOG_CONFIG_EQUFILES::OnOkClick(), SCH_EDIT_FRAME::OpenProjectFiles(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), SCH_EDIT_FRAME::SaveProject(), KICAD_MANAGER_CONTROL::SaveProjectAs(), PCB_EDIT_FRAME::SaveProjectLocalSettings(), SCH_EDIT_FRAME::saveProjectSettings(), ROUTER_TOOL::saveRouterDebugLog(), SIMULATOR_FRAME::SaveSettings(), PCB_EDIT_FRAME::SetLastPath(), LEGACY_SYMBOL_LIBS::SetLibNamesAndPaths(), BOARD::SetProject(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), SIMULATOR_FRAME::SIMULATOR_FRAME(), BOARD::SynchronizeComponentClasses(), DIALOG_EXPORT_2581::TransferDataFromWindow(), DIALOG_EXPORT_2581::TransferDataToWindow(), SIMULATOR_FRAME::UpdateTitle(), and EDA_3D_VIEWER_FRAME::~EDA_3D_VIEWER_FRAME().

◆ GetProjectFullName()

◆ GetProjectLock()

LOCKFILE * PROJECT::GetProjectLock ( ) const

Definition at line 470 of file project.cpp.

References m_project_lock.

◆ GetProjectName()

const wxString PROJECT::GetProjectName ( ) const
virtual

Return the short name of the project.

This is the file name without extension or path.

Definition at line 177 of file project.cpp.

References m_project_name.

Referenced by SETTINGS_MANAGER::GetProjectBackupsPath(), PCBNEW_JOBS_HANDLER::JobExportStats(), BOARD::ResolveTextVar(), KICAD_MANAGER_CONTROL::SaveProjectAs(), TextVarResolver(), and SETTINGS_MANAGER::TriggerBackupIfNeeded().

◆ GetProjectPath()

const wxString PROJECT::GetProjectPath ( ) const
virtual

◆ 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 348 of file project.cpp.

References m_rstrings.

Referenced by 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(), PCB_BASE_EDIT_FRAME::SelectLibrary(), and SCH_BASE_FRAME::SelectLibrary().

◆ GetSheetName()

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

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

Definition at line 322 of file project.cpp.

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

◆ GetTextVars()

std::map< wxString, wxString > & PROJECT::GetTextVars ( ) const
virtual

◆ GetTextVarsTicker()

int PROJECT::GetTextVarsTicker ( ) const
inline

Definition at line 119 of file project.h.

References m_textVarsTicker.

◆ IncrementNetclassesTicker()

void PROJECT::IncrementNetclassesTicker ( )
inline

◆ IncrementTextVarsTicker()

void PROJECT::IncrementTextVarsTicker ( )
inline

◆ 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 183 of file project.cpp.

References m_project_name.

Referenced by AskSaveBoardFileName(), IsReadOnly(), and LEGACY_SYMBOL_LIBS::LoadAllLibraries().

◆ IsReadOnly()

virtual bool PROJECT::IsReadOnly ( ) const
inlinevirtual

Definition at line 167 of file project.h.

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 277 of file project.cpp.

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

Referenced by DesignBlockLibTblName(), 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 408 of file project.cpp.

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

Referenced by FOOTPRINT_SELECT_WIDGET::Load().

◆ PinLibrary()

◆ SaveToHistory()

void PROJECT::SaveToHistory ( const wxString & aProjectPath,
std::vector< wxString > & aFiles )

Save project files (.kicad_pro and .kicad_prl) to the .history directory.

This method is used as a saver callback for LOCAL_HISTORY during autosave operations.

Parameters
aProjectPathThe path to check against this project's path
aFilesOutput vector to append absolute file paths for history inclusion

Definition at line 482 of file project.cpp.

References GetProjectFullName(), and FILEEXT::ProjectLocalSettingsFileExtension.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

◆ SetElem()

◆ 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 355 of file project.h.

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 343 of file project.h.

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 135 of file project.cpp.

References Clear(), GetProjectFullName(), m_project_name, FILEEXT::ProjectFileExtension, TO_UTF8, and tracePathsAndFiles.

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

◆ SetProjectLock()

void PROJECT::SetProjectLock ( LOCKFILE * aLockFile)

Definition at line 476 of file project.cpp.

References m_project_lock.

Referenced by KICAD_MANAGER_FRAME::ProjectChanged().

◆ SetReadOnly()

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

◆ SetRString()

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

◆ SymbolLibTableName()

const wxString PROJECT::SymbolLibTableName ( ) const
virtual

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

Definition at line 189 of file project.cpp.

References libTableName(), and FILEEXT::SymbolLibraryTableFileName.

◆ TextVarResolver()

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

◆ UnpinLibrary()

Friends And Related Symbol Documentation

◆ SETTINGS_MANAGER

friend class SETTINGS_MANAGER
friend

Definition at line 318 of file project.h.

References SETTINGS_MANAGER.

Referenced by SETTINGS_MANAGER.

◆ TEST_NETLISTS_FIXTURE

friend class TEST_NETLISTS_FIXTURE
friend

Definition at line 319 of file project.h.

References elemsClear(), setProjectFullName(), and TEST_NETLISTS_FIXTURE.

Referenced by TEST_NETLISTS_FIXTURE.

Member Data Documentation

◆ m_designBlockLibsMutex

std::mutex PROJECT::m_designBlockLibsMutex
private

Synchronise access to DesignBlockLibs()

Definition at line 390 of file project.h.

Referenced by DesignBlockLibs().

◆ m_elems

std::array<_ELEM*,static_cast<unsigned int>( PROJECT::ELEM::COUNT )> PROJECT::m_elems
private
See also
this::Elem() and enum ELEM_T.

Definition at line 384 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 376 of file project.h.

Referenced by GetLocalSettings(), PROJECT(), and setLocalSettings().

◆ m_netclassesTicker

int PROJECT::m_netclassesTicker
private

Update counter on netclasses.

Definition at line 370 of file project.h.

Referenced by GetNetclassesTicker(), IncrementNetclassesTicker(), and PROJECT().

◆ m_project_lock

std::unique_ptr<LOCKFILE> PROJECT::m_project_lock
private

Lock.

Definition at line 387 of file project.h.

Referenced by GetProjectLock(), and SetProjectLock().

◆ m_project_name

wxFileName PROJECT::m_project_name
private

<fullpath>/<basename>.pro

Definition at line 366 of file project.h.

Referenced by GetProjectDirectory(), 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 373 of file project.h.

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

◆ m_readOnly

bool PROJECT::m_readOnly
private

No project files will be written to disk.

Definition at line 368 of file project.h.

Referenced by IsReadOnly(), PROJECT(), and SetReadOnly().

◆ m_rstrings

std::array<wxString,RSTRING_COUNT> PROJECT::m_rstrings
private
See also
this::SetRString(), GetRString(), and enum RSTRING_T.

Definition at line 381 of file project.h.

Referenced by GetRString(), and SetRString().

◆ m_sheetNames

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

Definition at line 378 of file project.h.

Referenced by GetSheetName().

◆ m_textVarsTicker

int PROJECT::m_textVarsTicker
private

Update counter on text vars.

Definition at line 369 of file project.h.

Referenced by GetTextVarsTicker(), IncrementTextVarsTicker(), and PROJECT().


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