|
|
|
@ -225,6 +225,14 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() |
|
|
|
m_3D_ShapeNameListBox->SetSelection( m_lastSelected3DShapeIndex ); |
|
|
|
Transfert3DValuesToDisplay( m_shapes3D_list[m_lastSelected3DShapeIndex] ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
S3D_INFO params; |
|
|
|
params.scale.x = 1.0; |
|
|
|
params.scale.y = 1.0; |
|
|
|
params.scale.z = 1.0; |
|
|
|
m_PreviewPane->SetModelData( ¶ms ); |
|
|
|
} |
|
|
|
|
|
|
|
// We have modified the UI, so call Fit() for m_Panel3D
|
|
|
|
// to be sure the m_Panel3D sizers are initialized before opening the dialog
|
|
|
|
@ -348,69 +356,49 @@ void DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName() |
|
|
|
// ensure any updated parameters are not discarded
|
|
|
|
TransfertDisplayTo3DValues( idx ); |
|
|
|
|
|
|
|
PROJECT& prj = Prj(); |
|
|
|
S3D_INFO model; |
|
|
|
|
|
|
|
wxString oldPath = m_shapes3D_list[idx]->GetShape3DFullFilename(); |
|
|
|
wxString initialpath; |
|
|
|
// Edit filename
|
|
|
|
wxString filename = m_3D_ShapeNameListBox->GetStringSelection(); |
|
|
|
wxTextEntryDialog dlg( this, wxEmptyString, wxEmptyString, filename ); |
|
|
|
|
|
|
|
if( !oldPath.empty() ) |
|
|
|
{ |
|
|
|
wxFileName fname( oldPath ); |
|
|
|
initialpath = fname.GetPath(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH ); |
|
|
|
} |
|
|
|
bool hasAlias; |
|
|
|
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); |
|
|
|
|
|
|
|
int filter = 0; |
|
|
|
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX ); |
|
|
|
if( dlg.ShowModal() != wxID_OK ) |
|
|
|
return; |
|
|
|
|
|
|
|
if( !sidx.empty() ) |
|
|
|
{ |
|
|
|
long tmp; |
|
|
|
sidx.ToLong( &tmp ); |
|
|
|
filename = dlg.GetValue(); |
|
|
|
|
|
|
|
if( tmp > 0 && tmp <= 0x7FFFFFFF ) |
|
|
|
filter = (int) tmp; |
|
|
|
} |
|
|
|
if( filename.empty() ) |
|
|
|
return; |
|
|
|
|
|
|
|
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(), |
|
|
|
initialpath, filter, &model ) ) |
|
|
|
if( !res->ValidateFileName( filename, hasAlias ) ) |
|
|
|
{ |
|
|
|
wxString msg = _( "Invalid filename: " ); |
|
|
|
msg.append( filename ); |
|
|
|
wxMessageBox( msg, _T( "Edit 3D file name" ) ); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath ); |
|
|
|
sidx = wxString::Format( wxT( "%i" ), filter ); |
|
|
|
prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx ); |
|
|
|
wxString alias; |
|
|
|
wxString shortPath; |
|
|
|
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); |
|
|
|
oldPath = model.filename; |
|
|
|
|
|
|
|
if( res && res->SplitAlias( oldPath, alias, shortPath ) ) |
|
|
|
{ |
|
|
|
oldPath = alias; |
|
|
|
oldPath.append( wxT( ":" ) ); |
|
|
|
oldPath.append( shortPath ); |
|
|
|
} |
|
|
|
m_3D_ShapeNameListBox->SetString( idx, filename ); |
|
|
|
|
|
|
|
m_3D_ShapeNameListBox->SetString( idx, oldPath ); |
|
|
|
// if the user has specified an alias in the name then prepend ':'
|
|
|
|
if( hasAlias ) |
|
|
|
filename.insert( 0, wxT( ":" ) ); |
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
// In Kicad files, filenames and paths are stored using Unix notation
|
|
|
|
model.filename.Replace( wxT( "\\" ), wxT( "/" ) ); |
|
|
|
#endif
|
|
|
|
filename.Replace( wxT( "\\" ), wxT( "/" ) ); |
|
|
|
#endif
|
|
|
|
|
|
|
|
S3D_MASTER* new3DShape = new S3D_MASTER( NULL ); |
|
|
|
new3DShape->SetShape3DName( model.filename ); |
|
|
|
new3DShape->SetShape3DName( filename ); |
|
|
|
new3DShape->m_MatPosition = m_shapes3D_list[idx]->m_MatPosition; |
|
|
|
new3DShape->m_MatRotation = m_shapes3D_list[idx]->m_MatRotation; |
|
|
|
new3DShape->m_MatScale = m_shapes3D_list[idx]->m_MatScale; |
|
|
|
delete m_shapes3D_list[idx]; |
|
|
|
m_shapes3D_list[idx] = new3DShape; |
|
|
|
|
|
|
|
Transfert3DValuesToDisplay( m_shapes3D_list[idx] ); |
|
|
|
|
|
|
|
return; |
|
|
|
@ -421,6 +409,9 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile() |
|
|
|
{ |
|
|
|
PROJECT& prj = Prj(); |
|
|
|
S3D_INFO model; |
|
|
|
model.scale.x = 1.0; |
|
|
|
model.scale.y = 1.0; |
|
|
|
model.scale.z = 1.0; |
|
|
|
|
|
|
|
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH ); |
|
|
|
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX ); |
|
|
|
|