| 
    KiCad PCB EDA Suite
    
   | 
 
Provide an extensible class to resolve 3D model paths. More...
#include <filename_resolver.h>
Public Member Functions | |
| FILENAME_RESOLVER () | |
| bool | Set3DConfigDir (const wxString &aConfigDir) | 
| Set the user's configuration directory for 3D models.   | |
| bool | SetProject (const PROJECT *aProject, bool *flgChanged=nullptr) | 
| Set the current KiCad project directory as the first entry in the model path list.   | |
| wxString | GetProjectDir () const | 
| void | SetProgramBase (PGM_BASE *aBase) | 
| Set a pointer to the application's PGM_BASE instance used to extract the local env vars.   | |
| bool | UpdatePathList (const std::vector< SEARCH_PATH > &aPathList) | 
| Clear the current path list and substitutes the given path list and update the path configuration file on success.   | |
| wxString | ResolvePath (const wxString &aFileName, const wxString &aWorkingPath, std::vector< const EMBEDDED_FILES * > aEmbeddedFilesStack) | 
| Determine the full path of the given file name.   | |
| wxString | ShortenPath (const wxString &aFullPathName) | 
| Produce a relative path based on the existing search directories or returns the same path if the path is not a superset of an existing search path.   | |
| const std::list< SEARCH_PATH > * | GetPaths () const | 
| Return a pointer to the internal path list; the items in:load.   | |
| bool | SplitAlias (const wxString &aFileName, wxString &anAlias, wxString &aRelPath) const | 
| Return true if the given name contains an alias and populates the string anAlias with the alias and aRelPath with the relative path.   | |
| bool | ValidateFileName (const wxString &aFileName, bool &hasAlias) const | 
| Return true if the given path is a valid aliased relative path.   | |
| bool | GetKicadPaths (std::list< wxString > &paths) const | 
| Return a list of path environment variables local to KiCad.   | |
Private Member Functions | |
| bool | createPathList (void) | 
| Build the path list using available information such as KICAD7_3DMODEL_DIR and the 3d_path_list configuration file.   | |
| bool | addPath (const SEARCH_PATH &aPath) | 
| Check that a path is valid and adds it to the search list.   | |
| void | checkEnvVarPath (const wxString &aPath) | 
| Check the ${ENV_VAR} component of a path and adds it to the resolver's path list if it is not yet in the list.   | |
Private Attributes | |
| wxString | m_configDir | 
| 3D configuration directory.   | |
| std::list< SEARCH_PATH > | m_paths | 
| List of base paths to search from.   | |
| int | m_errflags | 
| PGM_BASE * | m_pgm | 
| const PROJECT * | m_project | 
| wxString | m_curProjDir | 
Provide an extensible class to resolve 3D model paths.
Initially the legacy behavior will be implemented and an incomplete path would be checked against the project directory or the KICAD7_3DMODEL_DIR environment variable. In the future a configurable set of search paths may be specified.
Definition at line 57 of file filename_resolver.h.
| FILENAME_RESOLVER::FILENAME_RESOLVER | ( | ) | 
Definition at line 54 of file filename_resolver.cpp.
References m_errflags, m_pgm, and m_project.
      
  | 
  private | 
Check that a path is valid and adds it to the search list.
| aPath | is the alias set to be checked and added. | 
Definition at line 459 of file filename_resolver.cpp.
References _, DisplayErrorMessage(), ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, ENV_VAR::GetVersionedEnvVarName(), SEARCH_PATH::m_Alias, SEARCH_PATH::m_Pathexp, m_paths, SEARCH_PATH::m_Pathvar, m_project, mutex_resolver, and path.
Referenced by UpdatePathList().
      
  | 
  private | 
Check the ${ENV_VAR} component of a path and adds it to the resolver's path list if it is not yet in the list.
Definition at line 542 of file filename_resolver.cpp.
References ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, SEARCH_PATH::m_Alias, SEARCH_PATH::m_Pathexp, m_paths, SEARCH_PATH::m_Pathvar, and m_project.
Referenced by ResolvePath().
      
  | 
  private | 
Build the path list using available information such as KICAD7_3DMODEL_DIR and the 3d_path_list configuration file.
Definition at line 159 of file filename_resolver.cpp.
References ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, GetKicadPaths(), SEARCH_PATH::m_Alias, m_curProjDir, SEARCH_PATH::m_Pathexp, m_paths, SEARCH_PATH::m_Pathvar, m_project, and MASK_3D_RESOLVER.
Referenced by ResolvePath(), Set3DConfigDir(), SetProgramBase(), and ShortenPath().
| bool FILENAME_RESOLVER::GetKicadPaths | ( | std::list< wxString > & | paths | ) | const | 
Return a list of path environment variables local to KiCad.
This list always includes KICAD7_3DMODEL_DIR even if it is not defined locally.
Definition at line 832 of file filename_resolver.cpp.
References ENV_VAR::GetVersionedEnvVarName(), and m_pgm.
Referenced by createPathList().
| const std::list< SEARCH_PATH > * FILENAME_RESOLVER::GetPaths | ( | ) | const | 
Return a pointer to the internal path list; the items in:load.
The list can be used to set up the list of search paths available to a 3D file browser.
Definition at line 692 of file filename_resolver.cpp.
References m_paths.
| wxString FILENAME_RESOLVER::GetProjectDir | ( | ) | const | 
Definition at line 140 of file filename_resolver.cpp.
References m_curProjDir.
| wxString FILENAME_RESOLVER::ResolvePath | ( | const wxString & | aFileName, | 
| const wxString & | aWorkingPath, | ||
| std::vector< const EMBEDDED_FILES * > | aEmbeddedFilesStack ) | 
Determine the full path of the given file name.
In the future remote files may be supported, in which case it is best to require a full URI in which case ResolvePath should check that the URI conforms to RFC-2396 and related documents and copies aFileName into aResolvedName if the URI is valid.
| aFileName | The configured file path to resolve. | 
| aWorkingPath | The current working path for relative path resolutions. | 
| aEmbeddedFilesStack | is a list of pointers to the embedded files list. They will be searched from the front of the list. | 
Definition at line 246 of file filename_resolver.cpp.
References checkEnvVarPath(), createPathList(), ERRFLG_ALIAS, ERRFLG_ENVPATH, ERRFLG_RELPATH, ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, ENV_VAR::GetVersionedEnvVarName(), FILEEXT::KiCadUriPrefix, m_errflags, m_paths, m_project, mutex_resolver, path, SplitAlias(), and tracePathsAndFiles.
Referenced by EESCHEMA_JOBS_HANDLER::InitRenderSettings(), SCH_EDIT_FRAME::saveProjectSettings(), and PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists().
| bool FILENAME_RESOLVER::Set3DConfigDir | ( | const wxString & | aConfigDir | ) | 
Set the user's configuration directory for 3D models.
| aConfigDir | 
Definition at line 62 of file filename_resolver.cpp.
References createPathList(), ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, m_configDir, and m_project.
| void FILENAME_RESOLVER::SetProgramBase | ( | PGM_BASE * | aBase | ) | 
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
Definition at line 146 of file filename_resolver.cpp.
References createPathList(), m_paths, and m_pgm.
Referenced by EESCHEMA_JOBS_HANDLER::InitRenderSettings(), and SCH_EDIT_FRAME::saveProjectSettings().
| bool FILENAME_RESOLVER::SetProject | ( | const PROJECT * | aProject, | 
| bool * | flgChanged = nullptr ) | 
Set the current KiCad project directory as the first entry in the model path list.
| [in] | aProjDir | current project directory. | 
| [out] | flgChanged | optional, set to true if directory was changed. | 
| true | success. | 
| false | failure. | 
Definition at line 81 of file filename_resolver.cpp.
References ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, PROJECT::GetProjectPath(), SEARCH_PATH::m_Alias, m_curProjDir, SEARCH_PATH::m_Pathexp, m_paths, SEARCH_PATH::m_Pathvar, m_project, and MASK_3D_RESOLVER.
Referenced by EESCHEMA_JOBS_HANDLER::InitRenderSettings(), and SCH_EDIT_FRAME::saveProjectSettings().
| wxString FILENAME_RESOLVER::ShortenPath | ( | const wxString & | aFullPathName | ) | 
Produce a relative path based on the existing search directories or returns the same path if the path is not a superset of an existing search path.
| aFullPathName | is an absolute path to shorten. | 
Definition at line 602 of file filename_resolver.cpp.
References createPathList(), ExpandEnvVarSubstitutions(), m_paths, m_project, and mutex_resolver.
| bool FILENAME_RESOLVER::SplitAlias | ( | const wxString & | aFileName, | 
| wxString & | anAlias, | ||
| wxString & | aRelPath ) const | 
Return true if the given name contains an alias and populates the string anAlias with the alias and aRelPath with the relative path.
Definition at line 698 of file filename_resolver.cpp.
Referenced by ResolvePath().
| bool FILENAME_RESOLVER::UpdatePathList | ( | const std::vector< SEARCH_PATH > & | aPathList | ) | 
Clear the current path list and substitutes the given path list and update the path configuration file on success.
Definition at line 232 of file filename_resolver.cpp.
| bool FILENAME_RESOLVER::ValidateFileName | ( | const wxString & | aFileName, | 
| bool & | hasAlias ) const | 
Return true if the given path is a valid aliased relative path.
If the path contains an alias then hasAlias is set true.
Definition at line 724 of file filename_resolver.cpp.
References FILEEXT::KiCadUriPrefix.
Referenced by PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists().
      
  | 
  private | 
3D configuration directory.
Definition at line 172 of file filename_resolver.h.
Referenced by Set3DConfigDir().
      
  | 
  private | 
Definition at line 177 of file filename_resolver.h.
Referenced by createPathList(), GetProjectDir(), and SetProject().
      
  | 
  private | 
Definition at line 174 of file filename_resolver.h.
Referenced by FILENAME_RESOLVER(), and ResolvePath().
      
  | 
  private | 
List of base paths to search from.
Definition at line 173 of file filename_resolver.h.
Referenced by addPath(), checkEnvVarPath(), createPathList(), GetPaths(), ResolvePath(), SetProgramBase(), SetProject(), ShortenPath(), and UpdatePathList().
      
  | 
  private | 
Definition at line 175 of file filename_resolver.h.
Referenced by FILENAME_RESOLVER(), GetKicadPaths(), and SetProgramBase().
      
  | 
  private | 
Definition at line 176 of file filename_resolver.h.
Referenced by addPath(), checkEnvVarPath(), createPathList(), FILENAME_RESOLVER(), ResolvePath(), Set3DConfigDir(), SetProject(), and ShortenPath().