57 wxWindow* aParent, wxWindowID aId,
const wxPoint& aPos,
const wxSize& aSize,
long aStyle,
58 const wxString& aName ) :
60 m_parentDialog( aDialogParent ),
62 m_footprint( aFootprint ),
82 wxGridCellAttr* attr =
new wxGridCellAttr;
87 attr =
new wxGridCellAttr;
93 attr =
new wxGridCellAttr;
94 attr->SetRenderer(
new wxGridCellBoolRenderer() );
96 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
100 m_frame->
Prj().Get3DCacheManager()->GetResolver()->SetProgramBase( &
Pgm() );
120 m_frame->
Prj().Get3DCacheManager()->FlushCache(
false );
146 wxString default_path;
150 default_path.Replace( wxT(
"/" ), wxT(
"\\" ) );
156 wxString origPath, alias, shortPath;
162 origPath = model.m_Filename;
164 if(
res &&
res->SplitAlias( origPath, alias, shortPath ) )
165 origPath = alias + wxT(
":" ) + shortPath;
189 aModelIdx = std::max( 0, aModelIdx );
190 aModelIdx = std::min( aModelIdx,
m_modelsGrid->GetNumberRows() - 1 );
215 bool hasAlias =
false;
220 if( !filename.empty() )
222 filename.Replace( wxT(
"\n" ), wxT(
"" ) );
223 filename.Replace( wxT(
"\r" ), wxT(
"" ) );
224 filename.Replace( wxT(
"\t" ), wxT(
"" ) );
226 res->ValidateFileName( filename, hasAlias );
230 filename.insert( 0, wxT(
":" ) );
234 filename.Replace( wxT(
"\\" ), wxT(
"/" ) );
251 m_shapes3D_list[ aEvent.GetRow() ].m_Show = ( showValue == wxT(
"1" ) );
296 if( initialpath.IsEmpty() )
298 if( !wxGetEnv( wxT(
"KICAD7_3DMODEL_DIR" ), &initialpath ) || initialpath.IsEmpty() )
307 if( tmp > 0 && tmp <= INT_MAX )
320 sidx = wxString::Format( wxT(
"%i" ),
filter );
327 if(
res &&
res->SplitAlias( filename, alias, shortPath ) )
328 filename = alias + wxT(
":" ) + shortPath;
332 model.
m_Filename.Replace( wxT(
"\\" ), wxT(
"/" ) );
385 case MODEL_VALIDATE_ERRORS::MODEL_NO_ERROR:
390 case MODEL_VALIDATE_ERRORS::NO_FILENAME:
391 icon = wxICON_WARNING;
392 errStr =
_(
"No filename entered" );
395 case MODEL_VALIDATE_ERRORS::ILLEGAL_FILENAME:
397 errStr =
_(
"Illegal filename" );
400 case MODEL_VALIDATE_ERRORS::RESOLVE_FAIL:
402 errStr =
_(
"File not found" );
405 case MODEL_VALIDATE_ERRORS::OPEN_FAIL:
407 errStr =
_(
"Unable to open file" );
412 errStr =
_(
"Unknown error" );
424 if( aFilename.empty() )
425 return MODEL_VALIDATE_ERRORS::NO_FILENAME;
427 bool hasAlias =
false;
431 return MODEL_VALIDATE_ERRORS::RESOLVE_FAIL;
434 return MODEL_VALIDATE_ERRORS::ILLEGAL_FILENAME;
447 wxString footprintBasePath = wxEmptyString;
450 footprintBasePath = fpRow->
GetFullURI(
true );
452 wxString fullPath = resolv->
ResolvePath( aFilename, footprintBasePath );
454 if( fullPath.IsEmpty() )
455 return MODEL_VALIDATE_ERRORS::RESOLVE_FAIL;
457 if( !wxFileName::IsFileReadable( fullPath ) )
458 return MODEL_VALIDATE_ERRORS::OPEN_FAIL;
460 return MODEL_VALIDATE_ERRORS::MODEL_NO_ERROR;
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
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
Returns true if the given path is a valid aliased relative path.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath)
Determines the full path of the given file name.
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 th...
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.
void SetReadOnly(bool aReadOnly)
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...
Class PANEL_FP_PROPERTIES_3D_MODEL_BASE.
STD_BITMAP_BUTTON * m_button3DShapeBrowse
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
void On3DModelCellChanged(wxGridEvent &aEvent) override
PANEL_FP_PROPERTIES_3D_MODEL(PCB_BASE_EDIT_FRAME *aFrame, FOOTPRINT *aFootprint, DIALOG_SHIM *aDialogParent, wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxTAB_TRAVERSAL, const wxString &aName=wxEmptyString)
~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 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
std::vector< FP_3DMODEL > m_shapes3D_list
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.
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
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...
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates the specified column based on the actual size of the text on screen.
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.
#define KICAD7_3DMODEL_DIR
A variable name whose value holds the path of 3D shape files.
bool Configure3DPaths(wxWindow *aParent, FILENAME_RESOLVER *aResolver)
bool Select3DModel(wxWindow *aParent, S3D_CACHE *aCache, wxString &prevModelSelectDir, int &prevModelWildcard, FP_3DMODEL *aModel)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.