Commit 142782b4 authored by Dick Hollenbeck's avatar Dick Hollenbeck

remove wxApp()::FindLibraryPath() usages from Pcbnew. Use environment variable substitution.

parent 33e26b27
...@@ -62,52 +62,43 @@ S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster, ...@@ -62,52 +62,43 @@ S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster,
int S3D_MASTER::ReadData() int S3D_MASTER::ReadData()
{ {
wxFileName fn;
wxString FullFilename;
if( m_Shape3DName.IsEmpty() ) if( m_Shape3DName.IsEmpty() )
{ {
return 1; return 1;
} }
wxString shape3DNname = m_Shape3DName; // Expand any environment variables embedded in footprint's m_Shape3DName field.
wxString filename = wxExpandEnvVars( m_Shape3DName );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
shape3DNname.Replace( wxT( "/" ), wxT( "\\" ) ); filename.Replace( wxT( "/" ), wxT( "\\" ) );
#else #else
shape3DNname.Replace( wxT( "\\" ), wxT( "/" ) ); filename.Replace( wxT( "\\" ), wxT( "/" ) );
#endif #endif
if( wxFileName::FileExists( shape3DNname ) ) if( !wxFileName::FileExists( filename ) )
{
FullFilename = shape3DNname;
fn.Assign( FullFilename );
}
else
{
fn = shape3DNname;
FullFilename = wxGetApp().FindLibraryPath( fn );
if( FullFilename.IsEmpty() )
{ {
wxLogDebug( wxT( "3D part library <%s> could not be found." ), wxLogDebug( wxT( "3D shape '%s' not found, even tried '%s' after env var substitution." ),
GetChars( fn.GetFullPath() ) ); GetChars( m_Shape3DName ),
GetChars( filename )
);
return -1; return -1;
} }
}
wxFileName fn( filename );
wxString extension = fn.GetExt(); wxString extension = fn.GetExt();
S3D_MODEL_PARSER* parser = S3D_MODEL_PARSER::Create( this, extension ); S3D_MODEL_PARSER* parser = S3D_MODEL_PARSER::Create( this, extension );
if( parser ) if( parser )
{ {
parser->Load( FullFilename ); parser->Load( filename );
delete parser; delete parser;
return 0; return 0;
} }
else else
{ {
wxLogDebug( wxT( "Unknown file type <%s>" ), GetChars( extension ) ); wxLogDebug( wxT( "Unknown file type '%s'" ), GetChars( extension ) );
} }
return -1; return -1;
......
...@@ -27,7 +27,7 @@ add_custom_target( ...@@ -27,7 +27,7 @@ add_custom_target(
DEPENDS gal/opengl/shader_src.h DEPENDS gal/opengl/shader_src.h
) )
set(GAL_SRCS set( GAL_SRCS
# Common part # Common part
drawpanel_gal.cpp drawpanel_gal.cpp
painter.cpp painter.cpp
...@@ -54,13 +54,13 @@ set(GAL_SRCS ...@@ -54,13 +54,13 @@ set(GAL_SRCS
gal/cairo/cairo_compositor.cpp gal/cairo/cairo_compositor.cpp
) )
add_library(gal STATIC ${GAL_SRCS}) add_library( gal STATIC ${GAL_SRCS} )
add_dependencies(gal shader_headers) add_dependencies( gal shader_headers )
# Only for win32 cross compilation using MXE # Only for win32 cross compilation using MXE
if(WIN32 AND MSYS) if( WIN32 AND MSYS )
add_definitions(-DGLEW_STATIC) add_definitions( -DGLEW_STATIC )
endif(WIN32 AND MSYS) endif()
set( COMMON_ABOUT_DLG_SRCS set( COMMON_ABOUT_DLG_SRCS
dialog_about/AboutDialog_main.cpp dialog_about/AboutDialog_main.cpp
...@@ -120,7 +120,6 @@ set( COMMON_SRCS ...@@ -120,7 +120,6 @@ set( COMMON_SRCS
drawpanel.cpp drawpanel.cpp
drawtxt.cpp drawtxt.cpp
dsnlexer.cpp dsnlexer.cpp
edaappl.cpp
eda_dde.cpp eda_dde.cpp
eda_doc.cpp eda_doc.cpp
filter_reader.cpp filter_reader.cpp
...@@ -150,8 +149,13 @@ set( COMMON_SRCS ...@@ -150,8 +149,13 @@ set( COMMON_SRCS
zoom.cpp zoom.cpp
) )
# We will not want edaappl.cpp linked into the KIFACE, only into the KIWAY.
if( TRUE OR NOT USE_KIWAY_DLLS )
list( APPEND COMMON_SRCS edaappl.cpp )
endif()
if( NOT HAVE_STRTOKR ) if( NOT HAVE_STRTOKR )
set( COMMON_SRCS ${COMMON_SRCS} strtok_r.c ) list( APPEND COMMON_SRCS strtok_r.c )
endif() endif()
......
...@@ -1149,26 +1149,18 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule ...@@ -1149,26 +1149,18 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
bool isFlipped = aModule->GetLayer() == LAYER_N_BACK; bool isFlipped = aModule->GetLayer() == LAYER_N_BACK;
// Export the object VRML model(s) // Export the object VRML model(s)
for( S3D_MASTER* vrmlm = aModule->Models(); vrmlm != 0; vrmlm = vrmlm->Next() ) for( S3D_MASTER* vrmlm = aModule->Models(); vrmlm; vrmlm = vrmlm->Next() )
{ {
if( !vrmlm->Is3DType( S3D_MASTER::FILE3D_VRML ) ) if( !vrmlm->Is3DType( S3D_MASTER::FILE3D_VRML ) )
continue; continue;
wxString fname = vrmlm->GetShape3DName(); // expand environment variables
wxString fname = wxExpandEnvVars( vrmlm->GetShape3DName() );
if( !wxFileName::FileExists( fname ) )
{
wxFileName fn = fname;
fname = wxGetApp().FindLibraryPath( fn );
if( fname.IsEmpty() ) // keep "short" name if full filename not found
fname = vrmlm->GetShape3DName();
}
fname.Replace( wxT( "\\" ), wxT( "/" ) ); fname.Replace( wxT( "\\" ), wxT( "/" ) );
wxString source_fname = fname; wxString source_fname = fname;
if( aExport3DFiles ) // Change illegal characters in short filename if( aExport3DFiles ) // Change illegal characters
{ {
ChangeIllegalCharacters( fname, true ); ChangeIllegalCharacters( fname, true );
fname = a3D_Subdir + wxT( "/" ) + fname; fname = a3D_Subdir + wxT( "/" ) + fname;
...@@ -1295,6 +1287,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, ...@@ -1295,6 +1287,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName,
// Global VRML scale to export to a different scale. // Global VRML scale to export to a different scale.
model3d.scale = aMMtoWRMLunit / MM_PER_IU; model3d.scale = aMMtoWRMLunit / MM_PER_IU;
// Set the mechanical deviation limit (in this case 0.02mm) // Set the mechanical deviation limit (in this case 0.02mm)
// XXX - NOTE: the value should be set via the GUI // XXX - NOTE: the value should be set via the GUI
model3d.SetMaxDev( 20000 * model3d.scale ); model3d.SetMaxDev( 20000 * model3d.scale );
......
...@@ -1146,7 +1146,7 @@ bool IDF_COMP::PlaceComponent( const wxString aComponentFile, const std::string ...@@ -1146,7 +1146,7 @@ bool IDF_COMP::PlaceComponent( const wxString aComponentFile, const std::string
componentFile = aComponentFile; componentFile = aComponentFile;
refdes = aRefDes; refdes = aRefDes;
if( refdes.empty() || !refdes.compare("~") || !refdes.compare("0") ) if( refdes.empty() || !refdes.compare( "~" ) || !refdes.compare( "0" ) )
refdes = "NOREFDES"; refdes = "NOREFDES";
loc_x = aXLoc; loc_x = aXLoc;
...@@ -1155,16 +1155,12 @@ bool IDF_COMP::PlaceComponent( const wxString aComponentFile, const std::string ...@@ -1155,16 +1155,12 @@ bool IDF_COMP::PlaceComponent( const wxString aComponentFile, const std::string
rotation = aRotation; rotation = aRotation;
top = isOnTop; top = isOnTop;
if( !wxFileName::FileExists( aComponentFile ) ) wxString fname = wxExpandEnvVars( aComponentFile );
{
wxFileName fn = aComponentFile;
wxString fname = wxGetApp().FindLibraryPath( fn );
if( fname.IsEmpty() ) if( !wxFileName::FileExists( fname ) )
return false; return false;
else
componentFile = fname; componentFile = fname;
}
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment