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_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
}
 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...
 
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 62 of file project.h.

Member Enumeration Documentation

◆ ELEM_T

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

Constructor & Destructor Documentation

◆ PROJECT()

PROJECT::PROJECT ( )

Definition at line 41 of file project.cpp.

41  :
42  m_readOnly( false ),
43  m_projectFile( nullptr ),
44  m_localSettings( nullptr )
45 {
46  memset( m_elems, 0, sizeof(m_elems) );
47 }
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:360
bool m_readOnly
Definition: project.h:346
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:349
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:352

References m_elems.

◆ ~PROJECT()

PROJECT::~PROJECT ( )
virtual

Definition at line 61 of file project.cpp.

62 {
63  ElemsClear();
64 }
virtual void ElemsClear()
Delete all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:50

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

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

References GetProjectFullName().

Referenced by DIALOG_PLOT_SCHEMATIC::createPlotFileName(), 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_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Print(), SCH_EDIT_FRAME::PrintPage(), SCH_EDIT_FRAME::SaveEEFile(), SCH_EDIT_FRAME::SaveProject(), and WriteDRCReport().

◆ Clear()

void PROJECT::Clear ( )
inline

Clear the _ELEMs and RSTRINGs.

Definition at line 235 of file project.h.

236  {
237  ElemsClear();
238 
239  for( unsigned i = 0; i<RSTRING_COUNT; ++i )
240  SetRString( RSTRING_T( i ), wxEmptyString );
241  }
virtual void ElemsClear()
Delete all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:50
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:213
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:158

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

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

References arrayDim(), m_elems, NULL, 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 147 of file project.cpp.

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

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

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

References arrayDim(), m_elems, and NULL.

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

◆ GetLocalSettings()

◆ GetProjectFile()

◆ GetProjectFullName()

◆ GetProjectName()

const wxString PROJECT::GetProjectName ( ) const
virtual

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

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

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(), SETTINGS_MANAGER::GetPathForSettingsFile(), SETTINGS_MANAGER::GetProjectBackupsPath(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), EDA_DRAW_FRAME::LibraryFileBrowser(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), 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_PROPERTIES_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_PROPERTIES::OnAdd3DModel(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), DIALOG_SPICE_MODEL::onSelectLibrary(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE(), SCH_EDITOR_CONTROL::Paste(), PathIsInsideProject(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), 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)
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 228 of file project.cpp.

229 {
230  unsigned ndx = unsigned( aIndex );
231 
232  if( ndx < arrayDim( m_rstrings ) )
233  {
234  return m_rstrings[ndx];
235  }
236  else
237  {
238  static wxString no_cookie_for_you;
239 
240  wxASSERT( 0 ); // bad index
241 
242  return no_cookie_for_you;
243  }
244 }
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:357

References arrayDim(), and m_rstrings.

Referenced by PCB_EDIT_FRAME::ExportFootprintsToLibrary(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), SYMBOL_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_PROPERTIES::OnAdd3DModel(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), SYMBOL_EDIT_FRAME::saveLibrary(), and SYMBOL_EDIT_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 198 of file project.cpp.

199 {
200  if( m_sheetNames.empty() )
201  {
202  for( auto pair : GetProjectFile().GetSheets() )
203  m_sheetNames[pair.first] = pair.second;
204  }
205 
206  if( m_sheetNames.count( aSheetID ) )
207  return m_sheetNames.at( aSheetID );
208  else
209  return aSheetID.AsString();
210 }
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
wxString AsString() const
Definition: kiid.cpp:218
std::vector< FILE_INFO_PAIR > & GetSheets()
Definition: project_file.h:84
std::map< KIID, wxString > m_sheetNames
Definition: project.h:354

References KIID::AsString(), GetProjectFile(), PROJECT_FILE::GetSheets(), 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 135 of file project.cpp.

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

References m_project_name.

Referenced by AskSaveBoardFileName(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), IsReadOnly(), EDA_DRAW_FRAME::LibraryFileBrowser(), SCH_EDIT_FRAME::SaveProject(), PANEL_SETUP_RULES::TransferDataFromWindow(), and PANEL_SETUP_RULES::TransferDataToWindow().

◆ IsReadOnly()

virtual bool PROJECT::IsReadOnly ( ) const
inlinevirtual

Definition at line 124 of file project.h.

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

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

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

References GetProjectFullName(), 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 285 of file project.cpp.

286 {
287  // This is a lazy loading function, it loads the project specific table when
288  // that table is asked for, not before.
289 
291 
292  if( tbl )
293  {
294  wxASSERT( tbl->Type() == FP_LIB_TABLE_T );
295  }
296  else
297  {
298  try
299  {
300  // Build a new project specific FP_LIB_TABLE with the global table as a fallback.
301  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
302  // stack this way, all using the same global fallback table.
303  KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB );
304 
305  tbl = (FP_LIB_TABLE*) kiface->IfaceOrAddress( KIFACE_NEW_FOOTPRINT_TABLE );
306  tbl->Load( FootprintLibTblName() );
307 
308  SetElem( ELEM_FPTBL, tbl );
309  }
310  catch( const IO_ERROR& ioe )
311  {
312  DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ),
313  ioe.What() );
314  }
315  catch( ... )
316  {
317  DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ) );
318  }
319  }
320 
321  return tbl;
322 }
BITMAP2CMP_SETTINGS kiface
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:265
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:247
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:259
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
pcbnew DSO
Definition: kiway.h:269
Return a new FP_LIB_TABLE with the global table installed as a fallback.
Definition: kiface_ids.h:46
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return 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:99
#define _(s)
Definition: 3d_actions.cpp:33
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:147
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:147

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(), CVPCB_MAINFRAME::BuildLibrariesListBox(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), FOOTPRINT_PREVIEW_PANEL::DisplayFootprint(), CVPCB_MAINFRAME::DisplayStatus(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), InvokePcbLibTableEditor(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), PCB_BASE_FRAME::loadFootprint(), CVPCB_MAINFRAME::LoadFootprintFiles(), PCB_EDIT_FRAME::LoadFootprints(), FOOTPRINT_VIEWER_FRAME::OnActivate(), PCB_EDIT_FRAME::OpenProjectFiles(), FOOTPRINT_EDITOR_CONTROL::PasteFootprint(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), 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_VIEWER_FRAME::UpdateTitle(), and FOOTPRINT_EDIT_FRAME::UpdateTitle().

◆ SetElem()

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

Definition at line 259 of file project.cpp.

260 {
261  // This is virtual, so implement it out of line
262 
263  if( unsigned( aIndex ) < arrayDim( m_elems ) )
264  {
265  delete m_elems[aIndex];
266  m_elems[aIndex] = aElem;
267  }
268 }
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:360
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31

References arrayDim(), and m_elems.

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

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

333  {
334  m_localSettings = aSettings;
335  }
PROJECT_LOCAL_SETTINGS * m_localSettings
Backing store for project local settings – owned by SETTINGS_MANAGER.
Definition: project.h:352

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

321  {
322  m_projectFile = aFile;
323  }
PROJECT_FILE * m_projectFile
Backing store for project data – owned by SETTINGS_MANAGER.
Definition: project.h:349

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

86 {
87  // Compare paths, rather than inodes, to be less surprising to the user.
88  // Create a temporary wxFileName to normalize the path
89  wxFileName candidate_path( aFullPathAndName );
90 
91  // Edge transitions only. This is what clears the project
92  // data using the Clear() function.
93  if( m_project_name.GetFullPath() != candidate_path.GetFullPath() )
94  {
95  Clear(); // clear the data when the project changes.
96 
97  wxLogTrace( tracePathsAndFiles, "%s: old:'%s' new:'%s'", __func__,
98  TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) );
99 
100  m_project_name = aFullPathAndName;
101 
102  wxASSERT( m_project_name.IsAbsolute() );
103 
104  wxASSERT( m_project_name.GetExt() == ProjectFileExtension );
105 
106  // until multiple projects are in play, set an environment variable for the
107  // the project pointer.
108  {
109  wxString path = m_project_name.GetPath();
110 
111  wxSetEnv( PROJECT_VAR_NAME, path );
112  }
113  }
114 }
void Clear()
Clear the _ELEMs and RSTRINGs.
Definition: project.h:235
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)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:342
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:117

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

Definition at line 126 of file project.h.

126 { m_readOnly = aReadOnly; }
bool m_readOnly
Definition: project.h:346

References m_readOnly.

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

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

214 {
215  unsigned ndx = unsigned( aIndex );
216 
217  if( ndx < arrayDim( m_rstrings ) )
218  {
219  m_rstrings[ndx] = aString;
220  }
221  else
222  {
223  wxASSERT( 0 ); // bad index
224  }
225 }
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:357

References arrayDim(), and m_rstrings.

Referenced by Clear(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), SYMBOL_EDIT_FRAME::GetCurLib(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_PROPERTIES::OnAdd3DModel(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SYMBOL_EDIT_FRAME::saveLibrary(), SYMBOL_EDIT_FRAME::SelectLibraryFromList(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), SYMBOL_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), and SYMBOL_EDIT_FRAME::SetCurPart().

◆ SymbolLibTableName()

const wxString PROJECT::SymbolLibTableName ( ) const
virtual

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

Definition at line 141 of file project.cpp.

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

References libTableName().

◆ TextVarResolver()

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

Definition at line 67 of file project.cpp.

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

References GetTextVars().

Referenced by ExpandTextVars(), and KIwxExpandEnvVars().

Friends And Related Function Documentation

◆ SETTINGS_MANAGER

friend class SETTINGS_MANAGER
friend

Definition at line 301 of file project.h.

◆ TEST_NETLISTS_FIXTURE

friend class TEST_NETLISTS_FIXTURE
friend

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

◆ m_project_name

wxFileName PROJECT::m_project_name
private

<fullpath>/<basename>.pro

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

Referenced by GetProjectFile(), and setProjectFile().

◆ m_readOnly

bool PROJECT::m_readOnly
private

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

Referenced by GetRString(), and SetRString().

◆ m_sheetNames

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

Definition at line 354 of file project.h.

Referenced by GetSheetName().


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