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

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

parent 33e26b27
Loading
Loading
Loading
Loading
+14 −23
Original line number Original line Diff line number Diff line
@@ -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;
+12 −8
Original line number Original line Diff line number Diff line
@@ -60,7 +60,7 @@ 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
    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
    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()




+8 −15
Original line number Original line Diff line number Diff line
@@ -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,


    // 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 );
+6 −10
Original line number Original line Diff line number Diff line
@@ -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;
}
}