KiCad PCB EDA Suite
PANEL_FP_PROPERTIES_3D_MODEL Class Reference

#include <panel_fp_properties_3d_model.h>

Inheritance diagram for PANEL_FP_PROPERTIES_3D_MODEL:
PANEL_FP_PROPERTIES_3D_MODEL_BASE

Public Member Functions

 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
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void ReloadModelsFromFootprint ()
 
void AdjustGridColumnWidths ()
 
std::vector< FP_3DMODEL > & GetModelList ()
 

Protected Attributes

wxBoxSizer * bSizerMain3D
 
WX_GRIDm_modelsGrid
 
wxBitmapButton * m_button3DShapeAdd
 
wxBitmapButton * m_button3DShapeBrowse
 
wxBitmapButton * m_button3DShapeRemove
 
wxButton * m_buttonConfig3DPaths
 
wxBoxSizer * m_LowerSizer3D
 

Private Member Functions

void On3DModelSelected (wxGridEvent &) override
 
void On3DModelCellChanged (wxGridEvent &aEvent) override
 
void OnRemove3DModel (wxCommandEvent &event) override
 
void OnAdd3DModel (wxCommandEvent &event) override
 
void OnAdd3DRow (wxCommandEvent &event) override
 
void Cfg3DPath (wxCommandEvent &event) override
 
void OnGridSize (wxSizeEvent &event) override
 
void OnUpdateUI (wxUpdateUIEvent &event) override
 
void updateValidateStatus (int aRow)
 
MODEL_VALIDATE_ERRORS validateModelExists (const wxString &aFilename)
 
void select3DModel (int aModelIdx)
 

Private Attributes

DIALOG_SHIMm_parentDialog
 
PCB_BASE_EDIT_FRAMEm_frame
 
FOOTPRINTm_footprint
 
std::vector< FP_3DMODELm_shapes3D_list
 
PANEL_PREVIEW_3D_MODELm_previewPane
 
bool m_inSelect
 

Detailed Description

Definition at line 45 of file panel_fp_properties_3d_model.h.

Constructor & Destructor Documentation

◆ PANEL_FP_PROPERTIES_3D_MODEL()

PANEL_FP_PROPERTIES_3D_MODEL::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 
)

Definition at line 54 of file panel_fp_properties_3d_model.cpp.

57 :
58 PANEL_FP_PROPERTIES_3D_MODEL_BASE( aParent, aId, aPos, aSize, aStyle, aName ),
59 m_parentDialog( aDialogParent ),
60 m_frame( aFrame ),
61 m_footprint( aFootprint ),
62 m_inSelect( false )
63{
64 m_modelsGrid->SetDefaultRowSize( m_modelsGrid->GetDefaultRowSize() + 4 );
65
66 GRID_TRICKS* trick = new GRID_TRICKS( m_modelsGrid, [this]( wxCommandEvent& aEvent )
67 {
68 OnAdd3DRow( aEvent );
69 } );
71
72 m_modelsGrid->PushEventHandler( trick );
73
74 // Get the last 3D directory
75 PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
76
77 if( cfg->m_lastFootprint3dDir.IsEmpty() )
79
80 // Icon showing warning/error information
81 wxGridCellAttr* attr = new wxGridCellAttr;
82 attr->SetReadOnly();
83 m_modelsGrid->SetColAttr( COL_PROBLEM, attr );
84
85 // Filename
86 attr = new wxGridCellAttr;
88 wxT( "*.*" ), true, m_frame->Prj().GetProjectPath() ) );
89 m_modelsGrid->SetColAttr( COL_FILENAME, attr );
90
91 // Show checkbox
92 attr = new wxGridCellAttr;
93 attr->SetRenderer( new wxGridCellBoolRenderer() );
94 attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
95 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
96 m_modelsGrid->SetColAttr( COL_SHOWN, attr );
97 m_modelsGrid->SetWindowStyleFlag( m_modelsGrid->GetWindowStyle() & ~wxHSCROLL );
98
99 m_frame->Prj().Get3DCacheManager()->GetResolver()->SetProgramBase( &Pgm() );
100
102
103 m_LowerSizer3D->Add( m_previewPane, 1, wxEXPAND, 5 );
104
105 // Configure button logos
109}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ small_folder
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.
Definition: grid_tricks.h:61
void SetTooltipEnable(int aCol, bool aEnable=true)
Enable the tooltip for a column.
Definition: grid_tricks.h:75
void SetReadOnly(bool aReadOnly)
Definition: json_settings.h:85
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
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)
void OnAdd3DRow(wxCommandEvent &event) override
std::vector< FP_3DMODEL > m_shapes3D_list
wxString m_lastFootprint3dDir
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
#define KICAD6_3DMODEL_DIR
A variable name whose value holds the path of 3D shape files.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References COL_FILENAME, COL_PROBLEM, COL_SHOWN, PROJECT::GetProjectPath(), KiBitmap(), KICAD6_3DMODEL_DIR, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_button3DShapeAdd, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_button3DShapeBrowse, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_button3DShapeRemove, m_footprint, m_frame, PCBNEW_SETTINGS::m_lastFootprint3dDir, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_LowerSizer3D, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_parentDialog, m_previewPane, m_shapes3D_list, OnAdd3DRow(), Pgm(), KIWAY_HOLDER::Prj(), JSON_SETTINGS::SetReadOnly(), GRID_TRICKS::SetTooltipEnable(), small_folder, small_plus, and small_trash.

◆ ~PANEL_FP_PROPERTIES_3D_MODEL()

PANEL_FP_PROPERTIES_3D_MODEL::~PANEL_FP_PROPERTIES_3D_MODEL ( )
override

Definition at line 112 of file panel_fp_properties_3d_model.cpp.

113{
114 // Delete the GRID_TRICKS.
115 m_modelsGrid->PopEventHandler( true );
116
117 // free the memory used by all models, otherwise models which were
118 // browsed but not used would consume memory
119 m_frame->Prj().Get3DCacheManager()->FlushCache( false );
120
121 delete m_previewPane;
122}

References m_frame, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_previewPane, and KIWAY_HOLDER::Prj().

Member Function Documentation

◆ AdjustGridColumnWidths()

void PANEL_FP_PROPERTIES_3D_MODEL::AdjustGridColumnWidths ( )

Definition at line 466 of file panel_fp_properties_3d_model.cpp.

467{
468 // Account for scroll bars
469 int modelsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_modelsGrid ).x;
470
471 int width = modelsWidth - m_modelsGrid->GetColSize( COL_SHOWN )
472 - m_modelsGrid->GetColSize( COL_PROBLEM );
473
474 if( width > 0 )
475 m_modelsGrid->SetColSize( COL_FILENAME, width );
476}
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: gtk/ui.cpp:126

References COL_FILENAME, COL_PROBLEM, COL_SHOWN, KIPLATFORM::UI::GetUnobscuredSize(), and PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid.

Referenced by DIALOG_FOOTPRINT_PROPERTIES::adjustGridColumns(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::adjustGridColumns(), and OnGridSize().

◆ Cfg3DPath()

void PANEL_FP_PROPERTIES_3D_MODEL::Cfg3DPath ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 459 of file panel_fp_properties_3d_model.cpp.

460{
461 if( S3D::Configure3DPaths( this, m_frame->Prj().Get3DCacheManager()->GetResolver() ) )
463}
void UpdateDummyFootprint(bool aRelaodRequired=true)
Copy shapes from the current shape list which are flagged for preview to the copy of footprint that i...
bool Configure3DPaths(wxWindow *aParent, FILENAME_RESOLVER *aResolver)

References S3D::Configure3DPaths(), m_frame, m_previewPane, KIWAY_HOLDER::Prj(), and PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint().

◆ GetModelList()

std::vector< FP_3DMODEL > & PANEL_FP_PROPERTIES_3D_MODEL::GetModelList ( )
inline

◆ On3DModelCellChanged()

void PANEL_FP_PROPERTIES_3D_MODEL::On3DModelCellChanged ( wxGridEvent &  aEvent)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 210 of file panel_fp_properties_3d_model.cpp.

211{
212 if( aEvent.GetCol() == COL_FILENAME )
213 {
214 bool hasAlias = false;
215 FILENAME_RESOLVER* res = m_frame->Prj().Get3DCacheManager()->GetResolver();
216 wxString filename = m_modelsGrid->GetCellValue( aEvent.GetRow(), COL_FILENAME );
217
218 // Perform cleanup and validation on the filename if it isn't empty
219 if( !filename.empty() )
220 {
221 filename.Replace( wxT( "\n" ), wxT( "" ) );
222 filename.Replace( wxT( "\r" ), wxT( "" ) );
223 filename.Replace( wxT( "\t" ), wxT( "" ) );
224
225 res->ValidateFileName( filename, hasAlias );
226
227 // If the user has specified an alias in the name then prepend ':'
228 if( hasAlias )
229 filename.insert( 0, wxT( ":" ) );
230
231#ifdef __WINDOWS__
232 // In KiCad files, filenames and paths are stored using Unix notation
233 filename.Replace( wxT( "\\" ), wxT( "/" ) );
234#endif
235
236 // Update the grid with the modified filename
237 m_modelsGrid->SetCellValue( aEvent.GetRow(), COL_FILENAME, filename );
238 }
239
240 // Save the filename in the 3D shapes table
241 m_shapes3D_list[ aEvent.GetRow() ].m_Filename = filename;
242
243 // Update the validation status
244 updateValidateStatus( aEvent.GetRow() );
245 }
246 else if( aEvent.GetCol() == COL_SHOWN )
247 {
248 wxString showValue = m_modelsGrid->GetCellValue( aEvent.GetRow(), COL_SHOWN );
249
250 m_shapes3D_list[ aEvent.GetRow() ].m_Show = ( showValue == wxT( "1" ) );
251 }
252
254}
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.

References COL_FILENAME, COL_SHOWN, m_frame, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_previewPane, m_shapes3D_list, KIWAY_HOLDER::Prj(), PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint(), updateValidateStatus(), and FILENAME_RESOLVER::ValidateFileName().

◆ On3DModelSelected()

void PANEL_FP_PROPERTIES_3D_MODEL::On3DModelSelected ( wxGridEvent &  aEvent)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 203 of file panel_fp_properties_3d_model.cpp.

204{
205 if( !m_inSelect )
206 select3DModel( aEvent.GetRow() );
207}

References m_inSelect, and select3DModel().

◆ OnAdd3DModel()

void PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DModel ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 275 of file panel_fp_properties_3d_model.cpp.

276{
278 return;
279
280 int selected = m_modelsGrid->GetGridCursorRow();
281
282 PROJECT& prj = m_frame->Prj();
283 FP_3DMODEL model;
284
285 wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
286 wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
287 int filter = 0;
288
289 // If the PROJECT::VIEWER_3D_PATH hasn't been set yet, use the KICAD6_3DMODEL_DIR environment
290 // variable and fall back to the project path if necessary.
291 if( initialpath.IsEmpty() )
292 {
293 if( !wxGetEnv( wxT( "KICAD6_3DMODEL_DIR" ), &initialpath ) || initialpath.IsEmpty() )
294 initialpath = prj.GetProjectPath();
295 }
296
297 if( !sidx.empty() )
298 {
299 long tmp;
300 sidx.ToLong( &tmp );
301
302 if( tmp > 0 && tmp <= INT_MAX )
303 filter = (int) tmp;
304 }
305
306 if( !S3D::Select3DModel( this, m_frame->Prj().Get3DCacheManager(), initialpath, filter, &model )
307 || model.m_Filename.empty() )
308 {
309 select3DModel( selected );
310 updateValidateStatus( selected );
311 return;
312 }
313
314 prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath );
315 sidx = wxString::Format( wxT( "%i" ), filter );
317 FILENAME_RESOLVER* res = m_frame->Prj().Get3DCacheManager()->GetResolver();
318 wxString alias;
319 wxString shortPath;
320 wxString filename = model.m_Filename;
321
322 if( res && res->SplitAlias( filename, alias, shortPath ) )
323 filename = alias + wxT( ":" ) + shortPath;
324
325#ifdef __WINDOWS__
326 // In KiCad files, filenames and paths are stored using Unix notation
327 model.m_Filename.Replace( wxT( "\\" ), wxT( "/" ) );
328#endif
329
330 model.m_Show = true;
331 m_shapes3D_list.push_back( model );
332
333 int idx = m_modelsGrid->GetNumberRows();
334 m_modelsGrid->AppendRows( 1 );
335 m_modelsGrid->SetCellValue( idx, COL_FILENAME, filename );
336 m_modelsGrid->SetCellValue( idx, COL_SHOWN, wxT( "1" ) );
337
338 select3DModel( idx );
340
342}
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 a...
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:95
bool m_Show
Include model in rendering.
Definition: footprint.h:96
Container for project specific data.
Definition: project.h:64
@ VIEWER_3D_FILTER_INDEX
Definition: project.h:171
@ VIEWER_3D_PATH
Definition: project.h:170
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...
Definition: project.cpp:254
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:265
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:280
bool Select3DModel(wxWindow *aParent, S3D_CACHE *aCache, wxString &prevModelSelectDir, int &prevModelWildcard, FP_3DMODEL *aModel)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References COL_FILENAME, COL_SHOWN, WX_GRID::CommitPendingChanges(), filter, Format(), PROJECT::GetProjectPath(), PROJECT::GetRString(), FP_3DMODEL::m_Filename, m_frame, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_previewPane, m_shapes3D_list, FP_3DMODEL::m_Show, KIWAY_HOLDER::Prj(), select3DModel(), S3D::Select3DModel(), PROJECT::SetRString(), FILENAME_RESOLVER::SplitAlias(), PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint(), updateValidateStatus(), PROJECT::VIEWER_3D_FILTER_INDEX, and PROJECT::VIEWER_3D_PATH.

◆ OnAdd3DRow()

void PANEL_FP_PROPERTIES_3D_MODEL::OnAdd3DRow ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 345 of file panel_fp_properties_3d_model.cpp.

346{
348 return;
349
350 FP_3DMODEL model;
351
352 model.m_Show = true;
353 m_shapes3D_list.push_back( model );
354
355 int row = m_modelsGrid->GetNumberRows();
356 m_modelsGrid->AppendRows( 1 );
357 m_modelsGrid->SetCellValue( row, COL_SHOWN, wxT( "1" ) );
358 m_modelsGrid->SetCellValue( row, COL_PROBLEM, "" );
359
360 select3DModel( row );
361
362 m_modelsGrid->SetFocus();
363 m_modelsGrid->MakeCellVisible( row, COL_FILENAME );
364 m_modelsGrid->SetGridCursor( row, COL_FILENAME );
365
366 m_modelsGrid->EnableCellEditControl( true );
367 m_modelsGrid->ShowCellEditControl();
368
370}

References COL_FILENAME, COL_PROBLEM, COL_SHOWN, WX_GRID::CommitPendingChanges(), PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_shapes3D_list, FP_3DMODEL::m_Show, select3DModel(), and updateValidateStatus().

Referenced by PANEL_FP_PROPERTIES_3D_MODEL().

◆ OnGridSize()

void PANEL_FP_PROPERTIES_3D_MODEL::OnGridSize ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 479 of file panel_fp_properties_3d_model.cpp.

480{
482
483 event.Skip();
484}

References AdjustGridColumnWidths().

◆ OnRemove3DModel()

void PANEL_FP_PROPERTIES_3D_MODEL::OnRemove3DModel ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_FP_PROPERTIES_3D_MODEL_BASE.

Definition at line 257 of file panel_fp_properties_3d_model.cpp.

258{
260 return;
261
262 int idx = m_modelsGrid->GetGridCursorRow();
263
264 if( idx >= 0 && m_modelsGrid->GetNumberRows() && !m_shapes3D_list.empty() )
265 {
266 m_shapes3D_list.erase( m_shapes3D_list.begin() + idx );
267 m_modelsGrid->DeleteRows( idx );
268
269 select3DModel( idx ); // will clamp idx within bounds
271 }
272}

References WX_GRID::CommitPendingChanges(), PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_previewPane, m_shapes3D_list, select3DModel(), and PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint().

◆ OnUpdateUI()

void PANEL_FP_PROPERTIES_3D_MODEL::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

◆ ReloadModelsFromFootprint()

void PANEL_FP_PROPERTIES_3D_MODEL::ReloadModelsFromFootprint ( )

Definition at line 143 of file panel_fp_properties_3d_model.cpp.

144{
145 wxString default_path;
146 wxGetEnv( KICAD6_3DMODEL_DIR, &default_path );
147
148#ifdef __WINDOWS__
149 default_path.Replace( wxT( "/" ), wxT( "\\" ) );
150#endif
151
152 m_shapes3D_list.clear();
154
155 wxString origPath, alias, shortPath;
156 FILENAME_RESOLVER* res = m_frame->Prj().Get3DCacheManager()->GetResolver();
157
158 for( const FP_3DMODEL& model : m_footprint->Models() )
159 {
160 m_shapes3D_list.push_back( model );
161 origPath = model.m_Filename;
162
163 if( res && res->SplitAlias( origPath, alias, shortPath ) )
164 origPath = alias + wxT( ":" ) + shortPath;
165
166 m_modelsGrid->AppendRows( 1 );
167 int row = m_modelsGrid->GetNumberRows() - 1;
168 m_modelsGrid->SetCellValue( row, COL_FILENAME, origPath );
169 m_modelsGrid->SetCellValue( row, COL_SHOWN, model.m_Show ? wxT( "1" ) : wxT( "0" ) );
170
171 // Must be after the filename is set
173 }
174
175 select3DModel( 0 );
176
178 m_modelsGrid->SetColSize( COL_SHOWN, m_modelsGrid->GetVisibleWidth( COL_SHOWN, true, false ) );
179
180 Layout();
181}
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:184
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.
Definition: wx_grid.cpp:377
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:133

References WX_GRID::ClearRows(), COL_FILENAME, COL_SHOWN, WX_GRID::GetVisibleWidth(), KICAD6_3DMODEL_DIR, m_footprint, m_frame, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_previewPane, m_shapes3D_list, FOOTPRINT::Models(), KIWAY_HOLDER::Prj(), select3DModel(), FILENAME_RESOLVER::SplitAlias(), PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint(), and updateValidateStatus().

Referenced by TransferDataToWindow().

◆ select3DModel()

void PANEL_FP_PROPERTIES_3D_MODEL::select3DModel ( int  aModelIdx)
private

Definition at line 184 of file panel_fp_properties_3d_model.cpp.

185{
186 m_inSelect = true;
187
188 aModelIdx = std::max( 0, aModelIdx );
189 aModelIdx = std::min( aModelIdx, m_modelsGrid->GetNumberRows() - 1 );
190
191 if( m_modelsGrid->GetNumberRows() )
192 {
193 m_modelsGrid->SelectRow( aModelIdx );
194 m_modelsGrid->SetGridCursor( aModelIdx, COL_FILENAME );
195 }
196
197 m_previewPane->SetSelectedModel( aModelIdx );
198
199 m_inSelect = false;
200}
void SetSelectedModel(int idx)
Set the currently selected index in the model list so that the scale/rotation/offset controls can be ...

References COL_FILENAME, m_inSelect, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, m_previewPane, and PANEL_PREVIEW_3D_MODEL::SetSelectedModel().

Referenced by On3DModelSelected(), OnAdd3DModel(), OnAdd3DRow(), OnRemove3DModel(), and ReloadModelsFromFootprint().

◆ TransferDataFromWindow()

bool PANEL_FP_PROPERTIES_3D_MODEL::TransferDataFromWindow ( )
override

Definition at line 131 of file panel_fp_properties_3d_model.cpp.

132{
133 // Only commit changes in the editor, not the models
134 // The container dialog is responsible for moving the new models into
135 // the footprint inside a commit.
137 return false;
138
139 return true;
140}

References WX_GRID::CommitPendingChanges(), and PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid.

Referenced by DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow().

◆ TransferDataToWindow()

bool PANEL_FP_PROPERTIES_3D_MODEL::TransferDataToWindow ( )
override

◆ updateValidateStatus()

void PANEL_FP_PROPERTIES_3D_MODEL::updateValidateStatus ( int  aRow)
private

Definition at line 373 of file panel_fp_properties_3d_model.cpp.

374{
375 int icon = 0;
376 wxString errStr;
377
378 switch( validateModelExists( m_modelsGrid->GetCellValue( aRow, COL_FILENAME) ) )
379 {
381 icon = 0;
382 errStr = "";
383 break;
384
386 icon = wxICON_WARNING;
387 errStr = _( "No filename entered" );
388 break;
389
391 icon = wxICON_ERROR;
392 errStr = _( "Illegal filename" );
393 break;
394
396 icon = wxICON_ERROR;
397 errStr = _( "File not found" );
398 break;
399
401 icon = wxICON_ERROR;
402 errStr = _( "Unable to open file" );
403 break;
404
405 default:
406 icon = wxICON_ERROR;
407 errStr = _( "Unknown error" );
408 break;
409 }
410
411 m_modelsGrid->SetCellValue( aRow, COL_PROBLEM, errStr );
412 m_modelsGrid->SetCellRenderer( aRow, COL_PROBLEM,
413 new GRID_CELL_STATUS_ICON_RENDERER( icon ) );
414}
MODEL_VALIDATE_ERRORS validateModelExists(const wxString &aFilename)
#define _(s)

References _, COL_FILENAME, COL_PROBLEM, ILLEGAL_FILENAME, PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_modelsGrid, MODEL_NO_ERROR, NO_FILENAME, OPEN_FAIL, RESOLVE_FAIL, and validateModelExists().

Referenced by On3DModelCellChanged(), OnAdd3DModel(), OnAdd3DRow(), and ReloadModelsFromFootprint().

◆ validateModelExists()

MODEL_VALIDATE_ERRORS PANEL_FP_PROPERTIES_3D_MODEL::validateModelExists ( const wxString &  aFilename)
private

Definition at line 417 of file panel_fp_properties_3d_model.cpp.

418{
419 if( aFilename.empty() )
421
422 bool hasAlias = false;
423 FILENAME_RESOLVER* resolv = m_frame->Prj().Get3DFilenameResolver();
424
425 if( !resolv )
427
428 if( !resolv->ValidateFileName( aFilename, hasAlias ) )
430
431 wxString libraryName = m_footprint->GetFPID().GetLibNickname();
432 const FP_LIB_TABLE_ROW* fpRow = nullptr;
433 try
434 {
435 fpRow = m_frame->Prj().PcbFootprintLibs()->FindRow( libraryName, false );
436 }
437 catch( ... )
438 {
439 // if libraryName is not found in table, do nothing
440 }
441
442 wxString footprintBasePath = wxEmptyString;
443
444 if( fpRow )
445 footprintBasePath = fpRow->GetFullURI( true );
446
447 wxString fullPath = resolv->ResolvePath( aFilename, footprintBasePath );
448
449 if( fullPath.IsEmpty() )
451
452 if( !wxFileName::IsFileReadable( fullPath ) )
454
456}
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath)
Determines the full path of the given file name.
const LIB_ID & GetFPID() const
Definition: footprint.h:212
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
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...
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
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...
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:319

References FP_LIB_TABLE::FindRow(), FOOTPRINT::GetFPID(), LIB_TABLE_ROW::GetFullURI(), LIB_ID::GetLibNickname(), ILLEGAL_FILENAME, m_footprint, m_frame, MODEL_NO_ERROR, NO_FILENAME, OPEN_FAIL, PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), RESOLVE_FAIL, FILENAME_RESOLVER::ResolvePath(), and FILENAME_RESOLVER::ValidateFileName().

Referenced by updateValidateStatus().

Member Data Documentation

◆ bSizerMain3D

wxBoxSizer* PANEL_FP_PROPERTIES_3D_MODEL_BASE::bSizerMain3D
protectedinherited

◆ m_button3DShapeAdd

wxBitmapButton* PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_button3DShapeAdd
protectedinherited

◆ m_button3DShapeBrowse

wxBitmapButton* PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_button3DShapeBrowse
protectedinherited

◆ m_button3DShapeRemove

wxBitmapButton* PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_button3DShapeRemove
protectedinherited

◆ m_buttonConfig3DPaths

wxButton* PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_buttonConfig3DPaths
protectedinherited

◆ m_footprint

FOOTPRINT* PANEL_FP_PROPERTIES_3D_MODEL::m_footprint
private

◆ m_frame

◆ m_inSelect

bool PANEL_FP_PROPERTIES_3D_MODEL::m_inSelect
private

Definition at line 98 of file panel_fp_properties_3d_model.h.

Referenced by On3DModelSelected(), and select3DModel().

◆ m_LowerSizer3D

wxBoxSizer* PANEL_FP_PROPERTIES_3D_MODEL_BASE::m_LowerSizer3D
protectedinherited

◆ m_modelsGrid

◆ m_parentDialog

DIALOG_SHIM* PANEL_FP_PROPERTIES_3D_MODEL::m_parentDialog
private

Definition at line 91 of file panel_fp_properties_3d_model.h.

Referenced by PANEL_FP_PROPERTIES_3D_MODEL().

◆ m_previewPane

◆ m_shapes3D_list

std::vector<FP_3DMODEL> PANEL_FP_PROPERTIES_3D_MODEL::m_shapes3D_list
private

The documentation for this class was generated from the following files: