98 wxGridCellAttr* attr =
new wxGridCellAttr;
103 attr =
new wxGridCellAttr;
108 wxT(
"*.*" ),
true,
m_frame->Prj().GetProjectPath(),
109 [
this](
const wxString& aFile ) -> wxString
111 EMBEDDED_FILES::EMBEDDED_FILE* result = m_filesPanel->AddEmbeddedFile( aFile );
115 wxString msg = wxString::Format( _(
"Error adding 3D model" ) );
116 wxMessageBox( msg, _(
"Error" ), wxICON_ERROR | wxOK, this );
127 attr =
new wxGridCellAttr;
128 attr->SetRenderer(
new wxGridCellBoolRenderer() );
130 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
131 m_modelsGrid->SetColAttr(
COL_SHOWN, attr );
132 m_modelsGrid->SetWindowStyleFlag( m_modelsGrid->GetWindowStyle() & ~wxHSCROLL );
138 m_previewPane->SetEmbeddedFilesDelegate( m_filesPanel->GetLocalFiles() );
140 m_LowerSizer3D->Add( m_previewPane, 1, wxEXPAND, 5 );
183 wxString default_path;
187 default_path.Replace( wxT(
"/" ), wxT(
"\\" ) );
193 wxString origPath, alias, shortPath;
199 origPath = model.m_Filename;
201 if(
res &&
res->SplitAlias( origPath, alias, shortPath ) )
202 origPath = alias + wxT(
":" ) + shortPath;
226 aModelIdx = std::max( 0, aModelIdx );
227 aModelIdx = std::min( aModelIdx,
m_modelsGrid->GetNumberRows() - 1 );
252 bool hasAlias =
false;
257 if( !filename.empty() )
259 filename.Replace( wxT(
"\n" ), wxT(
"" ) );
260 filename.Replace( wxT(
"\r" ), wxT(
"" ) );
261 filename.Replace( wxT(
"\t" ), wxT(
"" ) );
263 res->ValidateFileName( filename, hasAlias );
267 filename.insert( 0, wxT(
":" ) );
271 filename.Replace( wxT(
"\\" ), wxT(
"/" ) );
288 m_shapes3D_list[ aEvent.GetRow() ].m_Show = ( showValue == wxT(
"1" ) );
304 wxArrayInt selectedRows =
m_modelsGrid->GetSelectedRows();
305 wxGridCellCoordsArray selectedCells =
m_modelsGrid->GetSelectedCells();
306 wxGridCellCoordsArray blockTopLeft =
m_modelsGrid->GetSelectionBlockTopLeft();
307 wxGridCellCoordsArray blockBottomRight =
m_modelsGrid->GetSelectionBlockBottomRight();
309 for(
unsigned ii = 0; ii < selectedCells.GetCount(); ++ii )
310 selectedRows.Add( selectedCells[ii].GetRow() );
312 if( !blockTopLeft.IsEmpty() && !blockBottomRight.IsEmpty() )
314 for(
int row = blockTopLeft[0].GetRow(); row <= blockBottomRight[0].GetRow(); ++row )
315 selectedRows.Add( row );
318 if( selectedRows.empty() &&
m_modelsGrid->GetGridCursorRow() >= 0 )
321 if( selectedRows.empty() )
327 std::sort( selectedRows.begin(), selectedRows.end() );
329 int nextSelection = selectedRows.front();
338 for(
int ii = selectedRows.size() - 1; ii >= 0; --ii )
340 int row = selectedRows[ii];
357 nextSelection = std::min( nextSelection,
m_modelsGrid->GetNumberRows() - 1 );
387 if( initialpath.IsEmpty() )
390 || initialpath.IsEmpty() )
401 if( tmp > 0 && tmp <= INT_MAX )
410 if( retval != wxID_OK || model.
m_Filename.empty() )
423 wxString libraryName =
m_footprint->GetFPID().GetLibNickname();
426 wxString footprintBasePath = wxEmptyString;
433 footprintBasePath = fpRow->
GetFullURI(
true );
440 std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
441 embeddedFilesStack.push_back(
m_filesPanel->GetLocalFiles() );
442 embeddedFilesStack.push_back(
m_frame->GetBoard()->GetEmbeddedFiles() );
444 wxString fullPath =
res->ResolvePath( model.
m_Filename, footprintBasePath, std::move( embeddedFilesStack ) );
445 wxFileName fname( fullPath );
452 wxString msg = wxString::Format(
_(
"Error adding 3D model" ) );
453 wxMessageBox( msg,
_(
"Error" ), wxICON_ERROR | wxOK,
this );
461 sidx = wxString::Format( wxT(
"%i" ),
filter );
468 if(
res &&
res->SplitAlias( filename, alias, shortPath ) )
469 filename = alias + wxT(
":" ) + shortPath;
473 model.
m_Filename.Replace( wxT(
"\\" ), wxT(
"/" ) );
495 [&]() -> std::pair<int, int>
529 icon = wxICON_WARNING;
530 errStr =
_(
"No filename entered" );
535 errStr =
_(
"Illegal filename" );
540 errStr =
_(
"File not found" );
545 errStr =
_(
"Unable to open file" );
550 errStr =
_(
"Unknown error" );
561 if( aFilename.empty() )
564 bool hasAlias =
false;
573 wxString libraryName =
m_footprint->GetFPID().GetLibNickname();
585 wxString footprintBasePath = wxEmptyString;
588 footprintBasePath = fpRow->
GetFullURI(
true );
590 std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
591 embeddedFilesStack.push_back(
m_filesPanel->GetLocalFiles() );
592 embeddedFilesStack.push_back(
m_frame->GetBoard()->GetEmbeddedFiles() );
594 wxString fullPath = resolv->
ResolvePath( aFilename, footprintBasePath, std::move( embeddedFilesStack ) );
596 if( fullPath.IsEmpty() )
599 if( !wxFileName::IsFileReadable( fullPath ) )
644 wxCommandEvent event( wxCUSTOM_PANEL_SHOWN_EVENT );
646 event.SetInt(
static_cast<int>( predicate ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
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.
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...
wxSplitterWindow * m_splitter1
PANEL_FP_PROPERTIES_3D_MODEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(778, 286), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_button3DShapeRemove
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
PANEL_FP_PROPERTIES_3D_MODEL(PCB_BASE_EDIT_FRAME *aFrame, FOOTPRINT *aFootprint, DIALOG_SHIM *aDialogParent, PANEL_EMBEDDED_FILES *aFilesPanel, wxWindow *aParent)
void postCustomPanelShownEventWithPredicate(bool predicate)
void updateValidateStatus(int aRow)
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
void On3DModelSelected(wxGridEvent &) override
void select3DModel(int aModelIdx)
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
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.
T * GetAppSettings(const char *aFilename)
wxString result
Test unit parsing edge cases and error handling.