Set reasonable 3D model select dialog default path.
Passing an empty path to the 3D model select dialog results in the file select control displaying the root path which requires the user to drill down to get to the 3D models. Use the KISYS3DMOD path as the default and fall back to the project path as required for the initial file select control path. Clean up some coding policy violations. Fixes lp:1737094 https://bugs.launchpad.net/kicad/+bug/1737094
This commit is contained in:
parent
5102c8ac1f
commit
4d64a2f53f
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -54,7 +55,7 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
m_model( aModelItem ), m_cache( aCacheManager ), m_previousDir( prevModelSelectDir ),
|
||||
m_previousFilterIndex( prevModelWildcard )
|
||||
{
|
||||
this->SetSizeHints( wxSize( 500,200 ), wxDefaultSize );
|
||||
SetSizeHints( wxSize( 500,200 ), wxDefaultSize );
|
||||
|
||||
if( NULL != m_cache )
|
||||
m_resolver = m_cache->GetResolver();
|
||||
|
@ -155,9 +156,9 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
|
||||
updateDirChoiceList();
|
||||
|
||||
this->SetSizerAndFit( bSizer0 );
|
||||
this->Layout();
|
||||
this->Centre( wxBOTH );
|
||||
SetSizerAndFit( bSizer0 );
|
||||
Layout();
|
||||
Centre( wxBOTH );
|
||||
|
||||
m_modelViewer->Refresh();
|
||||
m_modelViewer->SetFocus();
|
||||
|
|
|
@ -532,6 +532,14 @@ void DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile()
|
|||
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
|
||||
int filter = 0;
|
||||
|
||||
// If the PROJECT::VIEWER_3D_PATH hasn't been set yet, use the KISYS3DMOD environment
|
||||
// varaible and fall back to the project path if necessary.
|
||||
if( initialpath.IsEmpty() )
|
||||
{
|
||||
if( !wxGetEnv( "KISYS3DMOD", &initialpath ) || initialpath.IsEmpty() )
|
||||
initialpath = prj.GetProjectPath();
|
||||
}
|
||||
|
||||
if( !sidx.empty() )
|
||||
{
|
||||
long tmp;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
|
||||
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -132,6 +132,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
|
|||
// Display the default path, given by environment variable KISYS3DMOD
|
||||
wxString default_path;
|
||||
wxGetEnv( KISYS3DMOD, &default_path );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
default_path.Replace( wxT( "/" ), wxT( "\\" ) );
|
||||
#endif
|
||||
|
@ -144,7 +145,6 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
|
|||
auto eM = m_currentModule->Models().end();
|
||||
m_shapes3D_list.clear();
|
||||
|
||||
|
||||
wxString origPath;
|
||||
wxString alias;
|
||||
wxString shortPath;
|
||||
|
@ -274,6 +274,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
|
|||
{
|
||||
if( m_PreviewPane )
|
||||
m_PreviewPane->ResetModelData();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -292,7 +293,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event)
|
||||
void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape( wxCommandEvent& event )
|
||||
{
|
||||
int ii = m_3D_ShapeNameListBox->GetSelection();
|
||||
|
||||
|
@ -390,6 +391,14 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile()
|
|||
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
|
||||
int filter = 0;
|
||||
|
||||
// If the PROJECT::VIEWER_3D_PATH hasn't been set yet, use the KISYS3DMOD environment
|
||||
// varaible and fall back to the project path if necessary.
|
||||
if( initialpath.IsEmpty() )
|
||||
{
|
||||
if( !wxGetEnv( "KISYS3DMOD", &initialpath ) || initialpath.IsEmpty() )
|
||||
initialpath = prj.GetProjectPath();
|
||||
}
|
||||
|
||||
if( !sidx.empty() )
|
||||
{
|
||||
long tmp;
|
||||
|
@ -422,10 +431,10 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile()
|
|||
|
||||
m_3D_ShapeNameListBox->Append( origPath );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef __WINDOWS__
|
||||
// In Kicad files, filenames and paths are stored using Unix notation
|
||||
model.m_Filename.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
m_shapes3D_list.push_back( model );
|
||||
m_lastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
|
||||
|
@ -533,7 +542,7 @@ bool DIALOG_MODULE_MODULE_EDITOR::TransferDataFromWindow()
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnEditReference( wxCommandEvent& event )
|
||||
{
|
||||
wxPoint tmp = m_parent->GetCrossHairPosition();
|
||||
m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPos() );
|
||||
|
@ -543,7 +552,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event)
|
||||
void DIALOG_MODULE_MODULE_EDITOR::OnEditValue( wxCommandEvent& event )
|
||||
{
|
||||
wxPoint tmp = m_parent->GetCrossHairPosition();
|
||||
m_parent->SetCrossHairPosition( m_valueCopy->GetTextPos() );
|
||||
|
|
Loading…
Reference in New Issue