KiCad PCB EDA Suite
|
Cache for storing the 3D shapes. More...
#include <3d_cache.h>
Public Member Functions | |
S3D_CACHE () | |
virtual | ~S3D_CACHE () |
KICAD_T | Type () noexcept override |
bool | Set3DConfigDir (const wxString &aConfigDir) |
Sets the configuration directory to be used by the model manager for storing 3D model manager configuration data and the model cache. More... | |
bool | SetProject (PROJECT *aProject) |
Set the current project's working directory; this affects the model search path. More... | |
void | SetProgramBase (PGM_BASE *aBase) |
Set the filename resolver's pointer to the application's PGM_BASE instance. More... | |
SCENEGRAPH * | Load (const wxString &aModelFile, const wxString &aBasePath) |
Attempt to load the scene data for a model. More... | |
FILENAME_RESOLVER * | GetResolver () noexcept |
std::list< wxString > const * | GetFileFilters () const |
Return the list of file filters retrieved from the plugins. More... | |
void | FlushCache (bool closePlugins=true) |
Free all data in the cache and by default closes all plugins. More... | |
void | ClosePlugins () |
Unload plugins to free memory. More... | |
S3DMODEL * | GetModel (const wxString &aModelFileName, const wxString &aBasePath) |
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for display by a renderer. More... | |
void | CleanCacheDir (int aNumDaysOld) |
Delete up old cache files in cache directory. More... | |
Private Member Functions | |
SCENEGRAPH * | checkCache (const wxString &aFileName, S3D_CACHE_ENTRY **aCachePtr=nullptr) |
Find or create cache entry for file name. More... | |
bool | getSHA1 (const wxString &aFileName, unsigned char *aSHA1Sum) |
Calculate the SHA1 hash of the given file. More... | |
bool | loadCacheData (S3D_CACHE_ENTRY *aCacheItem) |
bool | saveCacheData (S3D_CACHE_ENTRY *aCacheItem) |
SCENEGRAPH * | load (const wxString &aModelFile, const wxString &aBasePath, S3D_CACHE_ENTRY **aCachePtr=nullptr) |
Private Attributes | |
std::list< S3D_CACHE_ENTRY * > | m_CacheList |
cache entries More... | |
std::map< wxString, S3D_CACHE_ENTRY *, rsort_wxString > | m_CacheMap |
mapping of file names to cache names and data More... | |
FILENAME_RESOLVER * | m_FNResolver |
S3D_PLUGIN_MANAGER * | m_Plugins |
PROJECT * | m_project |
wxString | m_CacheDir |
wxString | m_ConfigDir |
Cache for storing the 3D shapes.
This cache is able to be stored as a project element (since it inherits from PROJECT::_ELEM).
Definition at line 52 of file 3d_cache.h.
S3D_CACHE::S3D_CACHE | ( | ) |
Definition at line 187 of file 3d_cache.cpp.
References m_FNResolver, m_Plugins, and m_project.
|
virtual |
Definition at line 195 of file 3d_cache.cpp.
References FlushCache(), m_FNResolver, and m_Plugins.
|
private |
Find or create cache entry for file name.
Searches the cache list for the given filename and retrieves the cache data; a cache entry is created if one does not already exist.
aFileName | is the file name (full or partial path). |
aCachePtr | is an optional return address for cache entry pointer. |
Definition at line 281 of file 3d_cache.cpp.
References S3D_CACHE_ENTRY::GetCacheBaseName(), ADVANCED_CFG::GetCfg(), getSHA1(), S3D_PLUGIN_MANAGER::Load3DModel(), loadCacheData(), m_CacheDir, m_CacheList, m_CacheMap, m_Plugins, MASK_3D_CACHE, S3D_CACHE_ENTRY::modTime, S3D_CACHE_ENTRY::pluginInfo, saveCacheData(), S3D_CACHE_ENTRY::sceneData, and S3D_CACHE_ENTRY::SetSHA1().
Referenced by load().
void S3D_CACHE::CleanCacheDir | ( | int | aNumDaysOld | ) |
Delete up old cache files in cache directory.
Deletes ".3dc" files in the cache directory that are older than aNumDaysOld.
aNumDaysOld | is age threshold to delete ".3dc" cache files. |
Definition at line 660 of file 3d_cache.cpp.
References m_CacheDir.
Referenced by PROJECT_PCB::Cleanup3DCache().
void S3D_CACHE::ClosePlugins | ( | ) |
Unload plugins to free memory.
Definition at line 627 of file 3d_cache.cpp.
References S3D_PLUGIN_MANAGER::ClosePlugins(), and m_Plugins.
Referenced by FlushCache().
void S3D_CACHE::FlushCache | ( | bool | closePlugins = true | ) |
Free all data in the cache and by default closes all plugins.
Definition at line 608 of file 3d_cache.cpp.
References ClosePlugins(), m_CacheList, and m_CacheMap.
Referenced by DIALOG_FOOTPRINT_PROPERTIES::~DIALOG_FOOTPRINT_PROPERTIES(), PANEL_FP_PROPERTIES_3D_MODEL::~PANEL_FP_PROPERTIES_3D_MODEL(), and ~S3D_CACHE().
std::list< wxString > const * S3D_CACHE::GetFileFilters | ( | ) | const |
Return the list of file filters retrieved from the plugins.
This will contain at least the default "All Files (*.*)|*.*"
Definition at line 602 of file 3d_cache.cpp.
References S3D_PLUGIN_MANAGER::GetFileFilters(), and m_Plugins.
Referenced by DIALOG_SELECT_3DMODEL::DIALOG_SELECT_3DMODEL().
S3DMODEL * S3D_CACHE::GetModel | ( | const wxString & | aModelFileName, |
const wxString & | aBasePath | ||
) |
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for display by a renderer.
aModelFileName | is the full path to the model to be loaded. |
Definition at line 634 of file 3d_cache.cpp.
References S3D::GetModel(), load(), MASK_3D_CACHE, and S3D_CACHE_ENTRY::renderData.
Referenced by RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_OPENGL::load3dModels(), and EDA_3D_MODEL_VIEWER::Set3DModel().
|
noexcept |
Definition at line 596 of file 3d_cache.cpp.
References m_FNResolver.
Referenced by PANEL_FP_PROPERTIES_3D_MODEL::Cfg3DPath(), PCB_EDIT_FRAME::Export_IDF3(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), PROJECT_PCB::Get3DFilenameResolver(), PANEL_FP_PROPERTIES_3D_MODEL::On3DModelCellChanged(), PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel(), PANEL_FP_PROPERTIES_3D_MODEL::PANEL_FP_PROPERTIES_3D_MODEL(), and PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint().
|
private |
Calculate the SHA1 hash of the given file.
aFileName | file name (full path). |
aSHA1Sum | a 20 byte character array to hold the SHA1 hash. |
Definition at line 348 of file 3d_cache.cpp.
References MASK_3D_CACHE.
Referenced by checkCache(), and load().
SCENEGRAPH * S3D_CACHE::Load | ( | const wxString & | aModelFile, |
const wxString & | aBasePath | ||
) |
Attempt to load the scene data for a model.
It will consult the internal cache list and load from cache if possible before invoking the load() function of the available plugins. The model may fail to load if, for example, the plugin does not support rendering of the 3D model.
aModelFile | is the partial or full path to the model to be loaded. |
aBasePath | is the path to search for any relative files |
Definition at line 275 of file 3d_cache.cpp.
References load().
Referenced by EXPORTER_PCB_VRML::ExportVrmlFootprint().
|
private |
Definition at line 204 of file 3d_cache.cpp.
References checkCache(), S3D::Destroy3DModel(), S3D::DestroyNode(), ADVANCED_CFG::GetCfg(), getSHA1(), isSHA1Same(), S3D_PLUGIN_MANAGER::Load3DModel(), m_CacheMap, m_FNResolver, m_Plugins, ADVANCED_CFG::m_Skip3DModelMemoryCache, MASK_3D_CACHE, mutex3D_cache, reload, FILENAME_RESOLVER::ResolvePath(), and S3D_CACHE_ENTRY::sceneData.
Referenced by GetModel(), and Load().
|
private |
Definition at line 404 of file 3d_cache.cpp.
References checkTag(), S3D::DestroyNode(), S3D_CACHE_ENTRY::GetCacheBaseName(), m_CacheDir, m_Plugins, MASK_3D_CACHE, S3D::ReadCache(), and S3D_CACHE_ENTRY::sceneData.
Referenced by checkCache().
|
private |
Definition at line 444 of file 3d_cache.cpp.
References S3D_CACHE_ENTRY::GetCacheBaseName(), m_CacheDir, MASK_3D_CACHE, S3D_CACHE_ENTRY::pluginInfo, S3D_CACHE_ENTRY::sceneData, and S3D::WriteCache().
Referenced by checkCache().
bool S3D_CACHE::Set3DConfigDir | ( | const wxString & | aConfigDir | ) |
Sets the configuration directory to be used by the model manager for storing 3D model manager configuration data and the model cache.
The config directory may only be set once in the lifetime of the object.
aConfigDir | is the configuration directory to use for 3D model manager data |
Definition at line 498 of file 3d_cache.cpp.
References ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, PATHS::GetUserCachePath(), m_CacheDir, m_ConfigDir, m_FNResolver, m_project, MASK_3D_CACHE, and FILENAME_RESOLVER::Set3DConfigDir().
Referenced by PROJECT_PCB::Get3DCacheManager().
void S3D_CACHE::SetProgramBase | ( | PGM_BASE * | aBase | ) |
Set the filename resolver's pointer to the application's PGM_BASE instance.
The pointer is used to extract the local environment variables.
Definition at line 590 of file 3d_cache.cpp.
References m_FNResolver, and FILENAME_RESOLVER::SetProgramBase().
Referenced by PROJECT_PCB::Get3DCacheManager().
bool S3D_CACHE::SetProject | ( | PROJECT * | aProject | ) |
Set the current project's working directory; this affects the model search path.
Definition at line 562 of file 3d_cache.cpp.
References m_CacheList, m_CacheMap, m_FNResolver, m_project, and FILENAME_RESOLVER::SetProject().
Referenced by PROJECT_PCB::Get3DCacheManager().
|
inlineoverridevirtualnoexcept |
|
private |
Definition at line 181 of file 3d_cache.h.
Referenced by checkCache(), CleanCacheDir(), loadCacheData(), saveCacheData(), and Set3DConfigDir().
|
private |
cache entries
Definition at line 171 of file 3d_cache.h.
Referenced by checkCache(), FlushCache(), and SetProject().
|
private |
mapping of file names to cache names and data
Definition at line 174 of file 3d_cache.h.
Referenced by checkCache(), FlushCache(), load(), and SetProject().
|
private |
Definition at line 182 of file 3d_cache.h.
Referenced by Set3DConfigDir().
|
private |
Definition at line 176 of file 3d_cache.h.
Referenced by GetResolver(), load(), S3D_CACHE(), Set3DConfigDir(), SetProgramBase(), SetProject(), and ~S3D_CACHE().
|
private |
Definition at line 178 of file 3d_cache.h.
Referenced by checkCache(), ClosePlugins(), GetFileFilters(), load(), loadCacheData(), S3D_CACHE(), and ~S3D_CACHE().
|
private |
Definition at line 180 of file 3d_cache.h.
Referenced by S3D_CACHE(), Set3DConfigDir(), and SetProject().