Loading 3d-viewer/3d_read_mesh.cpp +34 −2 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,39 @@ S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster, } } } } const wxString S3D_MASTER::GetShape3DFullFilename() { wxString shapeName; // Expand any environment variables embedded in footprint's m_Shape3DName field. // To ensure compatibility with most of footprint's m_Shape3DName field, // if the m_Shape3DName is not an absolute path the default path // given by the environment variable KISYS3DMOD will be used if( m_Shape3DName.StartsWith( wxT("${") ) ) shapeName = wxExpandEnvVars( m_Shape3DName ); else shapeName = m_Shape3DName; wxFileName fn( shapeName ); if( fn.IsAbsolute() || shapeName.StartsWith( wxT(".") ) ) return shapeName; wxString default_path; wxGetEnv( wxT( KISYS3DMOD ), &default_path ); if( default_path.IsEmpty() ) return shapeName; if( !default_path.EndsWith( wxT("/") ) && !default_path.EndsWith( wxT("\\") ) ) default_path += wxT("/"); default_path += shapeName; return default_path; } int S3D_MASTER::ReadData() int S3D_MASTER::ReadData() { { Loading @@ -67,8 +100,7 @@ int S3D_MASTER::ReadData() return 1; return 1; } } // Expand any environment variables embedded in footprint's m_Shape3DName field. wxString filename = GetShape3DFullFilename(); wxString filename = wxExpandEnvVars( m_Shape3DName ); #ifdef __WINDOWS__ #ifdef __WINDOWS__ filename.Replace( wxT( "/" ), wxT( "\\" ) ); filename.Replace( wxT( "/" ), wxT( "\\" ) ); Loading 3d-viewer/3d_struct.h +8 −0 Original line number Original line Diff line number Diff line Loading @@ -144,6 +144,14 @@ public: return m_Shape3DName; return m_Shape3DName; } } /** * Function GetShape3DFullFilename * @return the full filename of the 3D shape, * expanding environment variable (if any ) and/or adding default 3D path * given by environment variable KISYS3DMOD */ const wxString GetShape3DFullFilename(); void SetShape3DName( const wxString& aShapeName ); void SetShape3DName( const wxString& aShapeName ); }; }; Loading 3d-viewer/3d_viewer.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,9 @@ # include <GL/glu.h> # include <GL/glu.h> #endif #endif #define KISYS3DMOD "KISYS3DMOD" #include <3d_struct.h> #include <3d_struct.h> class EDA_3D_CANVAS; class EDA_3D_CANVAS; Loading common/edaappl.cpp +66 −0 Original line number Original line Diff line number Diff line Loading @@ -1196,3 +1196,69 @@ bool EDA_APP::SetFootprintLibTablePath() return false; return false; } } /** * Function Set3DShapesPath * attempts set the environment variable given by aKiSys3Dmod to a valid path. * (typically "KISYS3DMOD" ) * If the environment variable is already set, * then it left as is to respect the wishes of the user. * * The path is determined by attempting to find the path modules/packages3d * files in kicad tree. * This may or may not be the best path but it provides the best solution for * backwards compatibility with the previous 3D shapes search path implementation. * * @note This must be called after #SetBinDir() is called at least on Windows. * Otherwise, the kicad path is not known (Windows specific) * * @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD" * @return false if the aKiSys3Dmod path is not valid. */ bool EDA_APP::Set3DShapesPath( const wxString& aKiSys3Dmod ) { wxString path; // Set the KISYS3DMOD environment variable for the current process, // if it is not already defined in the user's environment and valid. if( wxGetEnv( aKiSys3Dmod, &path ) && wxFileName::DirExists( path ) ) return true; // Attempt to determine where the 3D shape libraries were installed using the // legacy path: // on Unix: /usr/local/kicad/share/modules/packages3d // or /usr/share/kicad/modules/packages3d // On Windows: bin../share/modules/packages3d wxString relpath( wxT( "modules/packages3d" ) ); // Apple MacOSx #ifdef __APPLE__ // TO DO #elif defined(__UNIX__) // Linux and non-Apple Unix path = wxT("/usr/local/kicad/share/") + relpath; if( wxFileName::DirExists( path ) ) { wxSetEnv( aKiSys3Dmod, path ); return true; } path = wxT("/usr/share/kicad/") + relpath; if( wxFileName::DirExists( path ) ) { wxSetEnv( aKiSys3Dmod, path ); return true; } #else // Windows path = m_BinDir + wxT("../share/") + relpath; if( wxFileName::DirExists( path ) ) { wxSetEnv( aKiSys3Dmod, path ); return true; } #endif return false; } cvpcb/cvpcb.cpp +4 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include <confirm.h> #include <confirm.h> #include <gestfich.h> #include <gestfich.h> #include <3d_viewer.h> #include <cvpcb.h> #include <cvpcb.h> #include <zones.h> #include <zones.h> #include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h> Loading Loading @@ -102,6 +103,9 @@ bool EDA_APP::OnInit() SetFootprintLibTablePath(); SetFootprintLibTablePath(); // Set 3D shape path from environment variable KISYS3DMOD Set3DShapesPath( wxT(KISYS3DMOD) ); if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() ) { { if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) ) if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) ) Loading Loading
3d-viewer/3d_read_mesh.cpp +34 −2 Original line number Original line Diff line number Diff line Loading @@ -59,6 +59,39 @@ S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster, } } } } const wxString S3D_MASTER::GetShape3DFullFilename() { wxString shapeName; // Expand any environment variables embedded in footprint's m_Shape3DName field. // To ensure compatibility with most of footprint's m_Shape3DName field, // if the m_Shape3DName is not an absolute path the default path // given by the environment variable KISYS3DMOD will be used if( m_Shape3DName.StartsWith( wxT("${") ) ) shapeName = wxExpandEnvVars( m_Shape3DName ); else shapeName = m_Shape3DName; wxFileName fn( shapeName ); if( fn.IsAbsolute() || shapeName.StartsWith( wxT(".") ) ) return shapeName; wxString default_path; wxGetEnv( wxT( KISYS3DMOD ), &default_path ); if( default_path.IsEmpty() ) return shapeName; if( !default_path.EndsWith( wxT("/") ) && !default_path.EndsWith( wxT("\\") ) ) default_path += wxT("/"); default_path += shapeName; return default_path; } int S3D_MASTER::ReadData() int S3D_MASTER::ReadData() { { Loading @@ -67,8 +100,7 @@ int S3D_MASTER::ReadData() return 1; return 1; } } // Expand any environment variables embedded in footprint's m_Shape3DName field. wxString filename = GetShape3DFullFilename(); wxString filename = wxExpandEnvVars( m_Shape3DName ); #ifdef __WINDOWS__ #ifdef __WINDOWS__ filename.Replace( wxT( "/" ), wxT( "\\" ) ); filename.Replace( wxT( "/" ), wxT( "\\" ) ); Loading
3d-viewer/3d_struct.h +8 −0 Original line number Original line Diff line number Diff line Loading @@ -144,6 +144,14 @@ public: return m_Shape3DName; return m_Shape3DName; } } /** * Function GetShape3DFullFilename * @return the full filename of the 3D shape, * expanding environment variable (if any ) and/or adding default 3D path * given by environment variable KISYS3DMOD */ const wxString GetShape3DFullFilename(); void SetShape3DName( const wxString& aShapeName ); void SetShape3DName( const wxString& aShapeName ); }; }; Loading
3d-viewer/3d_viewer.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,9 @@ # include <GL/glu.h> # include <GL/glu.h> #endif #endif #define KISYS3DMOD "KISYS3DMOD" #include <3d_struct.h> #include <3d_struct.h> class EDA_3D_CANVAS; class EDA_3D_CANVAS; Loading
common/edaappl.cpp +66 −0 Original line number Original line Diff line number Diff line Loading @@ -1196,3 +1196,69 @@ bool EDA_APP::SetFootprintLibTablePath() return false; return false; } } /** * Function Set3DShapesPath * attempts set the environment variable given by aKiSys3Dmod to a valid path. * (typically "KISYS3DMOD" ) * If the environment variable is already set, * then it left as is to respect the wishes of the user. * * The path is determined by attempting to find the path modules/packages3d * files in kicad tree. * This may or may not be the best path but it provides the best solution for * backwards compatibility with the previous 3D shapes search path implementation. * * @note This must be called after #SetBinDir() is called at least on Windows. * Otherwise, the kicad path is not known (Windows specific) * * @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD" * @return false if the aKiSys3Dmod path is not valid. */ bool EDA_APP::Set3DShapesPath( const wxString& aKiSys3Dmod ) { wxString path; // Set the KISYS3DMOD environment variable for the current process, // if it is not already defined in the user's environment and valid. if( wxGetEnv( aKiSys3Dmod, &path ) && wxFileName::DirExists( path ) ) return true; // Attempt to determine where the 3D shape libraries were installed using the // legacy path: // on Unix: /usr/local/kicad/share/modules/packages3d // or /usr/share/kicad/modules/packages3d // On Windows: bin../share/modules/packages3d wxString relpath( wxT( "modules/packages3d" ) ); // Apple MacOSx #ifdef __APPLE__ // TO DO #elif defined(__UNIX__) // Linux and non-Apple Unix path = wxT("/usr/local/kicad/share/") + relpath; if( wxFileName::DirExists( path ) ) { wxSetEnv( aKiSys3Dmod, path ); return true; } path = wxT("/usr/share/kicad/") + relpath; if( wxFileName::DirExists( path ) ) { wxSetEnv( aKiSys3Dmod, path ); return true; } #else // Windows path = m_BinDir + wxT("../share/") + relpath; if( wxFileName::DirExists( path ) ) { wxSetEnv( aKiSys3Dmod, path ); return true; } #endif return false; }
cvpcb/cvpcb.cpp +4 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include <confirm.h> #include <confirm.h> #include <gestfich.h> #include <gestfich.h> #include <3d_viewer.h> #include <cvpcb.h> #include <cvpcb.h> #include <zones.h> #include <zones.h> #include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h> Loading Loading @@ -102,6 +103,9 @@ bool EDA_APP::OnInit() SetFootprintLibTablePath(); SetFootprintLibTablePath(); // Set 3D shape path from environment variable KISYS3DMOD Set3DShapesPath( wxT(KISYS3DMOD) ); if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() ) { { if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) ) if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) ) Loading