KiCad PCB EDA Suite
PROJECT Class Reference

PROJECT holds 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_PART, 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_PART_LIBS, ELEM_SCH_SEARCH_STACK, ELEM_3DCACHE,
  ELEM_SYMBOL_LIB_TABLE, ELEM_COUNT
}
 Enum ELEM_T is the set of _ELEMs that a PROJECT can hold. More...
 

Public Member Functions

 PROJECT ()
 
VTBL_ENTRY ~PROJECT ()
 
VTBL_ENTRY bool TextVarResolver (wxString *aToken) const
 
VTBL_ENTRY std::map< wxString, wxString > & GetTextVars () const
 
VTBL_ENTRY const wxString GetProjectFullName () const
 Function GetProjectFullName returns the full path and name of the project. More...
 
VTBL_ENTRY const wxString GetProjectPath () const
 Function GetProjectPath returns the full path of the project. More...
 
VTBL_ENTRY const wxString GetProjectName () const
 Function GetProjectName returns the short name of the project. More...
 
VTBL_ENTRY bool IsNullProject () const
 Checks if this project is a null project (i.e. More...
 
VTBL_ENTRY bool IsReadOnly () const
 
VTBL_ENTRY void SetReadOnly (bool aReadOnly=true)
 
VTBL_ENTRY const wxString GetSheetName (const KIID &aSheetID)
 Return the name of the sheet identified by the given UUID. More...
 
VTBL_ENTRY const wxString FootprintLibTblName () const
 Function FootprintLibTblName returns the path and filename of this project's fp-lib-table, i.e. More...
 
VTBL_ENTRY const wxString SymbolLibTableName () const
 Return the path and file name of this projects symbol library table. More...
 
VTBL_ENTRY PROJECT_FILEGetProjectFile () const
 
VTBL_ENTRY PROJECT_LOCAL_SETTINGSGetLocalSettings () const
 
VTBL_ENTRY const wxString & GetRString (RSTRING_T aStringId)
 Function GetRString returns a "retained string", which is any session and project specific string identified in enum RSTRING_T. More...
 
VTBL_ENTRY void SetRString (RSTRING_T aStringId, const wxString &aString)
 Function SetRString stores a "retained string", which is any session and project specific string identified in enum RSTRING_T. More...
 
VTBL_ENTRY _ELEMGetElem (ELEM_T aIndex)
 Typically wrapped somewhere else in a more meaningful function wrapper. More...
 
VTBL_ENTRY void SetElem (ELEM_T aIndex, _ELEM *aElem)
 
VTBL_ENTRY void ElemsClear ()
 Function ElemsClear deletes all the _ELEMs and set their pointers to NULL. More...
 
void Clear ()
 Function Clear clears the _ELEMs and RSTRINGs. More...
 
VTBL_ENTRY const wxString AbsolutePath (const wxString &aFileName) const
 Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolute path and filename. More...
 
VTBL_ENTRY FP_LIB_TABLEPcbFootprintLibs (KIWAY &aKiway)
 Return the table of footprint libraries. More...
 

Private Member Functions

VTBL_ENTRY void setProjectFullName (const wxString &aFullPathAndName)
 Sets the: 1) full directory, 2) basename, and 3) extension of the project. More...
 
VTBL_ENTRY void setProjectFile (PROJECT_FILE *aFile)
 Sets the backing store file for this project Should only be called by SETTINGS_MANGER on load. More...
 
VTBL_ENTRY void setLocalSettings (PROJECT_LOCAL_SETTINGS *aSettings)
 Sets 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
 
bool m_readOnly
 

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

More...
 
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

PROJECT holds project specific data.

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

Definition at line 61 of file project.h.

Member Enumeration Documentation

◆ ELEM_T

Enum ELEM_T is the set of _ELEMs that a PROJECT can hold.

Enumerator
ELEM_FPTBL 
ELEM_SCH_PART_LIBS 
ELEM_SCH_SEARCH_STACK 
ELEM_3DCACHE 
ELEM_SYMBOL_LIB_TABLE 
ELEM_COUNT 

Definition at line 195 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_PART 
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 154 of file project.h.

Constructor & Destructor Documentation

◆ PROJECT()

PROJECT::PROJECT ( )

Definition at line 42 of file project.cpp.

42  :
43  m_readOnly( false ),
44  m_projectFile( nullptr ),
45  m_localSettings( nullptr )
46 {
47  memset( m_elems, 0, sizeof(m_elems) );
48 }
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:354
bool m_readOnly
True if the project is read-only: no project files will be written
Definition: project.h:340
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:343
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:346

References m_elems.

◆ ~PROJECT()

PROJECT::~PROJECT ( )

Definition at line 62 of file project.cpp.

63 {
64  ElemsClear();
65 }
VTBL_ENTRY void ElemsClear()
Function ElemsClear deletes all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:51

References ElemsClear().

Member Function Documentation

◆ AbsolutePath()

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

Function AbsolutePath fixes 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 272 of file project.cpp.

273 {
274  wxFileName fn = aFileName;
275 
276  if( !fn.IsAbsolute() )
277  {
278  wxString pro_dir = wxPathOnly( GetProjectFullName() );
279  fn.Normalize( wxPATH_NORM_ALL, pro_dir );
280  }
281 
282  return fn.GetFullPath();
283 }
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:118

References GetProjectFullName().

Referenced by DIALOG_PLOT_SCHEMATIC::createPlotFileName(), PCB_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::doCloseWindow(), PCB_EDIT_FRAME::Files_io_from_id(), main(), DIALOG_GENDRILL::OnGenReportFile(), SCH_EDIT_FRAME::OnOpenCvpcb(), SCH_EDIT_FRAME::OnOpenPcbnew(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Print(), SCH_EDIT_FRAME::PrintPage(), PCB_INSPECTION_TOOL::reportCopperClearance(), DRC_TOOL::RunTests(), SCH_EDIT_FRAME::SaveEEFile(), SCH_EDIT_FRAME::SaveProject(), PANEL_SETUP_RULES::TransferDataFromWindow(), and PANEL_SETUP_RULES::TransferDataToWindow().

◆ Clear()

void PROJECT::Clear ( )
inline

Function Clear clears the _ELEMs and RSTRINGs.

Definition at line 229 of file project.h.

230  {
231  ElemsClear();
232 
233  for( unsigned i = 0; i<RSTRING_COUNT; ++i )
234  SetRString( RSTRING_T( i ), wxEmptyString );
235  }
VTBL_ENTRY void ElemsClear()
Function ElemsClear deletes all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:51
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:214
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:154

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

Referenced by setProjectFullName().

◆ ElemsClear()

void PROJECT::ElemsClear ( )

Function ElemsClear deletes all the _ELEMs and set their pointers to NULL.

Definition at line 51 of file project.cpp.

52 {
53  // careful here, this should work, but the virtual destructor may not
54  // be in the same link image as PROJECT.
55  for( unsigned i = 0; i < arrayDim( m_elems ); ++i )
56  {
57  SetElem( ELEM_T( i ), NULL );
58  }
59 }
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:354
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:260
#define NULL
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
ELEM_T
Enum ELEM_T is the set of _ELEMs that a PROJECT can hold.
Definition: project.h:195

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

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

◆ FootprintLibTblName()

const wxString PROJECT::FootprintLibTblName ( ) const

Function FootprintLibTblName returns the path and filename of this project's fp-lib-table, i.e.

the project specific one, not the global one.

Definition at line 148 of file project.cpp.

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

References libTableName().

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

◆ GetElem()

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

Typically wrapped somewhere else in a more meaningful function wrapper.

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: 1) cross module API, 2) PROJECT knows nothing about _ELEM objects, except how to delete them and set and get pointers to them.

Definition at line 248 of file project.cpp.

249 {
250  // This is virtual, so implement it out of line
251 
252  if( unsigned( aIndex ) < arrayDim( m_elems ) )
253  {
254  return m_elems[aIndex];
255  }
256  return NULL;
257 }
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:354
#define NULL
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160

References arrayDim(), m_elems, and NULL.

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

◆ GetLocalSettings()

◆ GetProjectFile()

◆ GetProjectFullName()

◆ GetProjectName()

const wxString PROJECT::GetProjectName ( ) const

Function GetProjectName returns the short name of the project.

This is the file name without extension or path.

Definition at line 130 of file project.cpp.

131 {
132  return m_project_name.GetName();
133 }
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:336

References m_project_name.

Referenced by SCH_ALTIUM_PLUGIN::getLibName(), SETTINGS_MANAGER::GetProjectBackupsPath(), KICAD_MANAGER_CONTROL::SaveProjectAs(), DIALOG_BOARD_STATISTICS::saveReportClicked(), PROJECT_LOCAL_SETTINGS::SaveToFile(), PROJECT_FILE::SaveToFile(), and SETTINGS_MANAGER::TriggerBackupIfNeeded().

◆ GetProjectPath()

const wxString PROJECT::GetProjectPath ( ) const

Function GetProjectPath returns the full path of the project.

This is the path of the *.pro file and will always be an absolute path, ending by a dir separator.

Definition at line 124 of file project.cpp.

125 {
126  return m_project_name.GetPathWithSep();
127 }
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:336

References m_project_name.

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), KICAD_MANAGER_CONTROL::Execute(), PCB_EDIT_FRAME::ExportVRML_File(), FOOTPRINT_LIST::GetInstance(), SCH_ALTIUM_PLUGIN::getLibFileName(), SETTINGS_MANAGER::GetPathForSettingsFile(), SETTINGS_MANAGER::GetProjectBackupsPath(), PCB_EDIT_FRAME::importFile(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), EDA_DRAW_FRAME::LibraryFileBrowser(), SCH_ALTIUM_PLUGIN::Load(), SCH_SEXPR_PLUGIN::Load(), SCH_LEGACY_PLUGIN::Load(), KICAD_MANAGER_FRAME::LoadProject(), SCH_EDIT_FRAME::LoadProject(), SCH_EDIT_FRAME::LoadSheetFromFile(), NormalizePath(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), DIALOG_SPICE_MODEL::onSelectLibrary(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), SCH_EDITOR_CONTROL::Paste(), PathIsInsideProject(), ResolveFile(), FILENAME_RESOLVER::SetProject(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), SCH_EDIT_FRAME::WriteNetListFile(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

◆ GetRString()

const wxString & PROJECT::GetRString ( RSTRING_T  aStringId)

Function GetRString returns 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 229 of file project.cpp.

230 {
231  unsigned ndx = unsigned( aIndex );
232 
233  if( ndx < arrayDim( m_rstrings ) )
234  {
235  return m_rstrings[ndx];
236  }
237  else
238  {
239  static wxString no_cookie_for_you;
240 
241  wxASSERT( 0 ); // bad index
242 
243  return no_cookie_for_you;
244  }
245 }
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:351

References arrayDim(), and m_rstrings.

Referenced by PCB_EDIT_FRAME::ArchiveModulesOnBoard(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), LIB_EDIT_FRAME::LoadOneSymbol(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), LIB_EDIT_FRAME::saveLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), and LIB_EDIT_FRAME::SelectLibraryFromList().

◆ GetSheetName()

const wxString PROJECT::GetSheetName ( const KIID aSheetID)

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

Definition at line 199 of file project.cpp.

200 {
201  if( m_sheetNames.empty() )
202  {
203  for( auto pair : GetProjectFile().GetSheets() )
204  m_sheetNames[pair.first] = pair.second;
205  }
206 
207  if( m_sheetNames.count( aSheetID ) )
208  return m_sheetNames.at( aSheetID );
209  else
210  return aSheetID.AsString();
211 }
wxString AsString() const
Definition: common.cpp:165
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:141
std::vector< FILE_INFO_PAIR > & GetSheets()
Definition: project_file.h:82
std::map< KIID, wxString > m_sheetNames
Definition: project.h:348

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

◆ GetTextVars()

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

◆ IsNullProject()

bool PROJECT::IsNullProject ( ) const

Checks 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 a bull project

Definition at line 136 of file project.cpp.

137 {
138  return m_project_name.GetName().IsEmpty();
139 }
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:336

References m_project_name.

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), AskSaveBoardFileName(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), IsReadOnly(), EDA_DRAW_FRAME::LibraryFileBrowser(), SCH_EDIT_FRAME::OnImportProject(), and SCH_EDIT_FRAME::SaveProject().

◆ IsReadOnly()

VTBL_ENTRY bool PROJECT::IsReadOnly ( ) const
inline

Definition at line 120 of file project.h.

120 { return m_readOnly || IsNullProject(); }
bool m_readOnly
True if the project is read-only: no project files will be written
Definition: project.h:340
VTBL_ENTRY bool IsNullProject() const
Checks if this project is a null project (i.e.
Definition: project.cpp:136

References IsNullProject(), and m_readOnly.

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

155 {
156  wxFileName fn = GetProjectFullName();
157  wxString path = fn.GetPath();
158 
159  // if there's no path to the project name, or the name as a whole is bogus or its not
160  // write-able then use a template file.
161  if( !fn.GetDirCount() || !fn.IsOk() || !wxFileName::IsDirWritable( path ) )
162  {
163  // return a template filename now.
164 
165  // this next line is likely a problem now, since it relies on an
166  // application title which is no longer constant or known. This next line needs
167  // to be re-thought out.
168 
169 #ifndef __WXMAC__
170  fn.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
171 #else
172  // don't pollute home folder, temp folder seems to be more appropriate
173  fn.AssignDir( wxStandardPaths::Get().GetTempDir() );
174 #endif
175 
176 #if defined( __WINDOWS__ )
177  fn.AppendDir( wxT( "kicad" ) );
178 #endif
179 
180  /*
181  * The library table name used when no project file is passed to the appropriate
182  * code. This is used temporarily to store the project specific library table
183  * until the project file being edited is saved. It is then moved to the correct
184  * file in the folder where the project file is saved.
185  */
186  fn.SetName( "prj-" + aLibTableName );
187  }
188  else // normal path.
189  {
190  fn.SetName( aLibTableName );
191  }
192 
193  fn.ClearExt();
194 
195  return fn.GetFullPath();
196 }
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:118

References GetProjectFullName().

Referenced by FootprintLibTblName(), and SymbolLibTableName().

◆ PcbFootprintLibs()

FP_LIB_TABLE * PROJECT::PcbFootprintLibs ( KIWAY aKiway)

Return the table of footprint libraries.

Requires an active Kiway as this is fetched from pcbnew.

Definition at line 286 of file project.cpp.

287 {
288  // This is a lazy loading function, it loads the project specific table when
289  // that table is asked for, not before.
290 
292 
293  if( tbl )
294  {
295  wxASSERT( tbl->Type() == FP_LIB_TABLE_T );
296  }
297  else
298  {
299  try
300  {
301  // Build a new project specific FP_LIB_TABLE with the global table as a fallback.
302  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
303  // stack this way, all using the same global fallback table.
304  KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB );
305 
306  tbl = (FP_LIB_TABLE*) kiface->IfaceOrAddress( KIFACE_NEW_FOOTPRINT_TABLE );
307  tbl->Load( FootprintLibTblName() );
308 
309  SetElem( ELEM_FPTBL, tbl );
310  }
311  catch( const IO_ERROR& ioe )
312  {
313  DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ),
314  ioe.What() );
315  }
316  catch( ... )
317  {
318  DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ) );
319  }
320  }
321 
322  return tbl;
323 }
BITMAP2CMP_SETTINGS kiface
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:248
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:260
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
pcbnew DSO
Definition: kiway.h:282
Return a new FP_LIB_TABLE with the global table installed as a fallback.
Definition: kiface_ids.h:46
VTBL_ENTRY KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Function KiFACE returns the KIFACE* given a FACE_T.
Definition: kiway.cpp:179
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
KICAD_T Type() override
Definition: fp_lib_table.h:108
#define _(s)
Definition: 3d_actions.cpp:33
KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:150
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table,...
Definition: project.cpp:148

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

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), CVPCB_MAINFRAME::DisplayStatus(), GetFootprintLibraryTable(), DISPLAY_FOOTPRINTS_FRAME::GetModule(), FP_THREAD_IFACE::GetTable(), PCB_EDIT_FRAME::importFile(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), InvokePcbLibTableEditor(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_SELECT_WIDGET::Load(), PCB_BASE_FRAME::loadFootprint(), CVPCB_MAINFRAME::LoadFootprintFiles(), PCB_EDIT_FRAME::LoadFootprints(), FOOTPRINT_VIEWER_FRAME::OnActivate(), FOOTPRINT_EDITOR_TOOLS::PasteFootprint(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), PCB_BASE_FRAME::SelectLibrary(), FOOTPRINT_VIEWER_FRAME::ShowModal(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), and FOOTPRINT_EDIT_FRAME::updateTitle().

◆ SetElem()

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

Definition at line 260 of file project.cpp.

261 {
262  // This is virtual, so implement it out of line
263 
264  if( unsigned( aIndex ) < arrayDim( m_elems ) )
265  {
266  delete m_elems[aIndex];
267  m_elems[aIndex] = aElem;
268  }
269 }
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:354
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160

References arrayDim(), and m_elems.

Referenced by ElemsClear(), SCH_ALTIUM_PLUGIN::Load(), TEST_NETLISTS_FIXTURE::loadSchematic(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OpenProjectFiles(), PcbFootprintLibs(), LEGACY_RESCUER::WriteRescueLibrary(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

◆ setLocalSettings()

VTBL_ENTRY void PROJECT::setLocalSettings ( PROJECT_LOCAL_SETTINGS aSettings)
inlineprivate

Sets the local settings backing store.

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

327  {
328  m_localSettings = aSettings;
329  }
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:346

References m_localSettings.

◆ setProjectFile()

VTBL_ENTRY void PROJECT::setProjectFile ( PROJECT_FILE aFile)
inlineprivate

Sets the backing store file for this project Should only be called by SETTINGS_MANGER on load.

Parameters
aFileis a loaded PROJECT_FILE

Definition at line 317 of file project.h.

318  {
319  m_projectFile = aFile;
320  }
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:343

References m_projectFile.

Referenced by SETTINGS_MANAGER::loadProjectFile().

◆ setProjectFullName()

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

Sets the: 1) full directory, 2) basename, and 3) extension of the project.

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

Definition at line 86 of file project.cpp.

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

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

◆ SetReadOnly()

VTBL_ENTRY void PROJECT::SetReadOnly ( bool  aReadOnly = true)
inline

Definition at line 122 of file project.h.

122 { m_readOnly = aReadOnly; }
bool m_readOnly
True if the project is read-only: no project files will be written
Definition: project.h:340

References m_readOnly.

Referenced by SCH_EDIT_FRAME::OpenProjectFiles(), and PCB_EDIT_FRAME::OpenProjectFiles().

◆ SetRString()

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

Function SetRString stores 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 214 of file project.cpp.

215 {
216  unsigned ndx = unsigned( aIndex );
217 
218  if( ndx < arrayDim( m_rstrings ) )
219  {
220  m_rstrings[ndx] = aString;
221  }
222  else
223  {
224  wxASSERT( 0 ); // bad index
225  }
226 }
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:351

References arrayDim(), and m_rstrings.

Referenced by PCB_EDIT_FRAME::ArchiveModulesOnBoard(), Clear(), LIB_EDIT_FRAME::GetCurLib(), LIB_EDIT_FRAME::LoadOneSymbol(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), LIB_EDIT_FRAME::saveLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), LIB_EDIT_FRAME::SelectLibraryFromList(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), and LIB_EDIT_FRAME::SetCurPart().

◆ SymbolLibTableName()

const wxString PROJECT::SymbolLibTableName ( ) const

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

Definition at line 142 of file project.cpp.

143 {
144  return libTableName( "sym-lib-table" );
145 }
const wxString libTableName(const wxString &aLibTableName) const
Return the full path and file name of the project specific library table aLibTableName.
Definition: project.cpp:154

References libTableName().

◆ TextVarResolver()

bool PROJECT::TextVarResolver ( wxString *  aToken) const

Definition at line 68 of file project.cpp.

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

References GetTextVars().

Referenced by ExpandTextVars(), and KIwxExpandEnvVars().

Friends And Related Function Documentation

◆ SETTINGS_MANAGER

friend class SETTINGS_MANAGER
friend

Definition at line 63 of file project.h.

◆ TEST_NETLISTS_FIXTURE

friend class TEST_NETLISTS_FIXTURE
friend

Definition at line 64 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 354 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 346 of file project.h.

Referenced by GetLocalSettings(), and setLocalSettings().

◆ m_pro_date_and_time

wxString PROJECT::m_pro_date_and_time
private

Definition at line 337 of file project.h.

◆ m_project_name

wxFileName PROJECT::m_project_name
private

<fullpath>/<basename>.pro

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

Referenced by GetProjectFile(), and setProjectFile().

◆ m_readOnly

bool PROJECT::m_readOnly
private

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

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

Referenced by GetRString(), and SetRString().

◆ m_sheetNames

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

Definition at line 348 of file project.h.

Referenced by GetSheetName().


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