68 wxWindow* aParent, wxWindowID aId,
70 const wxSize& aSize,
long aStyle,
71 const wxString& aName ) :
73 m_parentDialog( aDialogParent ),
75 m_footprint( aFootprint ),
76 m_filesPanel( aFilesPanel ),
100 wxGridCellAttr* attr =
new wxGridCellAttr;
105 attr =
new wxGridCellAttr;
117 attr =
new wxGridCellAttr;
118 attr->SetRenderer(
new wxGridCellBoolRenderer() );
120 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
171 wxString default_path;
175 default_path.Replace( wxT(
"/" ), wxT(
"\\" ) );
181 wxString origPath, alias, shortPath;
187 origPath = model.m_Filename;
189 if(
res &&
res->SplitAlias( origPath, alias, shortPath ) )
190 origPath = alias + wxT(
":" ) + shortPath;
214 aModelIdx = std::max( 0, aModelIdx );
215 aModelIdx = std::min( aModelIdx,
m_modelsGrid->GetNumberRows() - 1 );
240 bool hasAlias =
false;
245 if( !filename.empty() )
247 filename.Replace( wxT(
"\n" ), wxT(
"" ) );
248 filename.Replace( wxT(
"\r" ), wxT(
"" ) );
249 filename.Replace( wxT(
"\t" ), wxT(
"" ) );
251 res->ValidateFileName( filename, hasAlias );
255 filename.insert( 0, wxT(
":" ) );
259 filename.Replace( wxT(
"\\" ), wxT(
"/" ) );
276 m_shapes3D_list[ aEvent.GetRow() ].m_Show = ( showValue == wxT(
"1" ) );
328 if( initialpath.IsEmpty() )
331 || initialpath.IsEmpty() )
342 if( tmp > 0 && tmp <= INT_MAX )
351 if( retval != wxID_OK || model.
m_Filename.empty() )
367 wxString footprintBasePath = wxEmptyString;
374 footprintBasePath = fpRow->
GetFullURI(
true );
381 std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
385 wxString fullPath =
res->ResolvePath( model.
m_Filename, footprintBasePath, embeddedFilesStack );
386 wxFileName fname( fullPath );
393 wxString msg = wxString::Format(
_(
"Error adding 3D model" ) );
394 wxMessageBox( msg,
_(
"Error" ), wxICON_ERROR | wxOK,
this );
402 sidx = wxString::Format( wxT(
"%i" ),
filter );
409 if(
res &&
res->SplitAlias( filename, alias, shortPath ) )
410 filename = alias + wxT(
":" ) + shortPath;
414 model.
m_Filename.Replace( wxT(
"\\" ), wxT(
"/" ) );
436 [&]() -> std::pair<int, int>
464 case MODEL_VALIDATE_ERRORS::MODEL_NO_ERROR:
469 case MODEL_VALIDATE_ERRORS::NO_FILENAME:
470 icon = wxICON_WARNING;
471 errStr =
_(
"No filename entered" );
474 case MODEL_VALIDATE_ERRORS::ILLEGAL_FILENAME:
476 errStr =
_(
"Illegal filename" );
479 case MODEL_VALIDATE_ERRORS::RESOLVE_FAIL:
481 errStr =
_(
"File not found" );
484 case MODEL_VALIDATE_ERRORS::OPEN_FAIL:
486 errStr =
_(
"Unable to open file" );
491 errStr =
_(
"Unknown error" );
502 if( aFilename.empty() )
503 return MODEL_VALIDATE_ERRORS::NO_FILENAME;
505 bool hasAlias =
false;
509 return MODEL_VALIDATE_ERRORS::RESOLVE_FAIL;
512 return MODEL_VALIDATE_ERRORS::ILLEGAL_FILENAME;
526 wxString footprintBasePath = wxEmptyString;
529 footprintBasePath = fpRow->
GetFullURI(
true );
531 std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
535 wxString fullPath = resolv->
ResolvePath( aFilename, footprintBasePath, embeddedFilesStack );
537 if( fullPath.IsEmpty() )
538 return MODEL_VALIDATE_ERRORS::RESOLVE_FAIL;
540 if( !wxFileName::IsFileReadable( fullPath ) )
541 return MODEL_VALIDATE_ERRORS::OPEN_FAIL;
543 return MODEL_VALIDATE_ERRORS::MODEL_NO_ERROR;
605 wxCommandEvent event( wxCUSTOM_PANEL_SHOWN_EVENT );
607 event.SetInt(
static_cast<int>( predicate ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
EMBEDDED_FILES * GetEmbeddedFiles() override
bool IsEmbedded3DModel() const
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Provide an extensible class to resolve 3D model paths.
bool ValidateFileName(const wxString &aFileName, bool &hasAlias) const
Return true if the given path is a valid aliased relative path.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, std::vector< const EMBEDDED_FILES * > aEmbeddedFilesStack)
Determine the full path of the given file name.
void SetProgramBase(PGM_BASE *aBase)
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
wxString m_Filename
The 3D shape filename in 3D library.
bool m_Show
Include model in rendering.
Hold a record identifying a library accessed by the appropriate footprint library #PLUGIN object in t...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
void SetTooltipEnable(int aCol, bool aEnable=true)
Enable the tooltip for a column.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
bool RemoveEmbeddedFile(const wxString &aFileName)
EMBEDDED_FILES * GetLocalFiles()
EMBEDDED_FILES::EMBEDDED_FILE * AddEmbeddedFile(const wxString &aFileName)
Class PANEL_FP_PROPERTIES_3D_MODEL_BASE.
STD_BITMAP_BUTTON * m_button3DShapeBrowse
wxSplitterWindow * m_splitter1
STD_BITMAP_BUTTON * m_button3DShapeAdd
STD_BITMAP_BUTTON * m_button3DShapeRemove
wxBoxSizer * m_LowerSizer3D
void OnUpdateUI(wxUpdateUIEvent &event) override
void Cfg3DPath(wxCommandEvent &event) override
void OnRemove3DModel(wxCommandEvent &event) override
virtual void onShowEvent(wxShowEvent &aEvent)
void On3DModelCellChanged(wxGridEvent &aEvent) override
virtual void onDialogActivateEvent(wxActivateEvent &aEvent)
~PANEL_FP_PROPERTIES_3D_MODEL() override
PCB_BASE_EDIT_FRAME * m_frame
void ReloadModelsFromFootprint()
DIALOG_SHIM * m_parentDialog
bool TransferDataToWindow() override
PANEL_PREVIEW_3D_MODEL * m_previewPane
void OnGridSize(wxSizeEvent &event) override
void postCustomPanelShownEventWithPredicate(bool predicate)
void updateValidateStatus(int aRow)
void AdjustGridColumnWidths()
bool TransferDataFromWindow() override
MODEL_VALIDATE_ERRORS validateModelExists(const wxString &aFilename)
void OnAdd3DModel(wxCommandEvent &event) override
void OnAdd3DRow(wxCommandEvent &event) override
PANEL_EMBEDDED_FILES * m_filesPanel
std::vector< FP_3DMODEL > m_shapes3D_list
PANEL_FP_PROPERTIES_3D_MODEL(PCB_BASE_EDIT_FRAME *aFrame, FOOTPRINT *aFootprint, DIALOG_SHIM *aDialogParent, PANEL_EMBEDDED_FILES *aFilesPanel, wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxTAB_TRAVERSAL, const wxString &aName=wxEmptyString)
void On3DModelSelected(wxGridEvent &) override
void select3DModel(int aModelIdx)
void UpdateDummyFootprint(bool aRelaodRequired=true)
Copy shapes from the current shape list which are flagged for preview to the copy of footprint that i...
void SetSelectedModel(int idx)
Set the currently selected index in the model list so that the scale/rotation/offset controls can be ...
wxString m_LastFootprint3dDir
Common, abstract interface for edit frames.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
static FILENAME_RESOLVER * Get3DFilenameResolver(PROJECT *aProject)
Accessor for 3D path resolver.
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
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...
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Cache for storing the 3D shapes.
void FlushCache(bool closePlugins=true)
Free all data in the cache and by default closes all plugins.
FILENAME_RESOLVER * GetResolver() noexcept
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate the specified column based on the actual size of the text on screen.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Declaration of the eda_3d_viewer class.
Functions related to environment variables, including help functions.
KICOMMON_API wxString GetVersionedEnvVarName(const wxString &aBaseName)
Construct a versioned environment variable based on this KiCad major version.
wxDEFINE_EVENT(wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent)
PGM_BASE & Pgm()
The global program "get" accessor.