Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
fff54d75
Commit
fff54d75
authored
Feb 08, 2014
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the environment variable KYSYS3DMOD to define a default path for 3D models.
parent
6a9771f2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
7 deletions
+143
-7
3d_read_mesh.cpp
3d-viewer/3d_read_mesh.cpp
+34
-2
3d_struct.h
3d-viewer/3d_struct.h
+8
-0
3d_viewer.h
3d-viewer/3d_viewer.h
+3
-0
edaappl.cpp
common/edaappl.cpp
+66
-0
cvpcb.cpp
cvpcb/cvpcb.cpp
+4
-0
appl_wxstruct.h
include/appl_wxstruct.h
+20
-0
export_vrml.cpp
pcbnew/exporters/export_vrml.cpp
+1
-2
pcbnew.cpp
pcbnew/pcbnew.cpp
+7
-3
No files found.
3d-viewer/3d_read_mesh.cpp
View file @
fff54d75
...
...
@@ -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
()
{
...
...
@@ -67,8 +100,7 @@ int S3D_MASTER::ReadData()
return
1
;
}
// Expand any environment variables embedded in footprint's m_Shape3DName field.
wxString
filename
=
wxExpandEnvVars
(
m_Shape3DName
);
wxString
filename
=
GetShape3DFullFilename
();
#ifdef __WINDOWS__
filename
.
Replace
(
wxT
(
"/"
),
wxT
(
"
\\
"
)
);
...
...
3d-viewer/3d_struct.h
View file @
fff54d75
...
...
@@ -144,6 +144,14 @@ public:
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
);
};
...
...
3d-viewer/3d_viewer.h
View file @
fff54d75
...
...
@@ -48,6 +48,9 @@
# include <GL/glu.h>
#endif
#define KISYS3DMOD "KISYS3DMOD"
#include <3d_struct.h>
class
EDA_3D_CANVAS
;
...
...
common/edaappl.cpp
View file @
fff54d75
...
...
@@ -1196,3 +1196,69 @@ bool EDA_APP::SetFootprintLibTablePath()
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
View file @
fff54d75
...
...
@@ -33,6 +33,7 @@
#include <confirm.h>
#include <gestfich.h>
#include <3d_viewer.h>
#include <cvpcb.h>
#include <zones.h>
#include <cvpcb_mainframe.h>
...
...
@@ -102,6 +103,9 @@ bool EDA_APP::OnInit()
SetFootprintLibTablePath
();
// Set 3D shape path from environment variable KISYS3DMOD
Set3DShapesPath
(
wxT
(
KISYS3DMOD
)
);
if
(
m_Checker
&&
m_Checker
->
IsAnotherRunning
()
)
{
if
(
!
IsOK
(
NULL
,
_
(
"CvPcb is already running, Continue?"
)
)
)
...
...
include/appl_wxstruct.h
View file @
fff54d75
...
...
@@ -456,6 +456,26 @@ public:
*/
bool
SetFootprintLibTablePath
();
/**
* 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
Set3DShapesPath
(
const
wxString
&
aKiSys3Dmod
);
const
wxString
&
GetModuleLibraryNickname
()
{
return
m_module_nickname
;
}
void
SetModuleLibraryNickname
(
const
wxString
&
aNickname
)
{
m_module_nickname
=
aNickname
;
}
};
...
...
pcbnew/exporters/export_vrml.cpp
View file @
fff54d75
...
...
@@ -1154,8 +1154,7 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
if
(
!
vrmlm
->
Is3DType
(
S3D_MASTER
::
FILE3D_VRML
)
)
continue
;
// expand environment variables
wxString
fname
=
wxExpandEnvVars
(
vrmlm
->
GetShape3DName
()
);
wxString
fname
=
vrmlm
->
GetShape3DFullFilename
();
fname
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
wxString
source_fname
=
fname
;
...
...
pcbnew/pcbnew.cpp
View file @
fff54d75
...
...
@@ -42,6 +42,7 @@
#include <pcbcommon.h>
#include <colors_selection.h>
#include <gr_basic.h>
#include <3d_viewer.h>
#include <wx/stdpaths.h>
#include <wx/file.h>
...
...
@@ -233,6 +234,9 @@ bool EDA_APP::OnInit()
// Set any environment variables before loading FP_LIB_TABLE
SetFootprintLibTablePath
();
// Set 3D shape path from environment variable KISYS3DMOD
Set3DShapesPath
(
wxT
(
KISYS3DMOD
)
);
frame
=
new
PCB_EDIT_FRAME
(
NULL
,
wxT
(
"Pcbnew"
),
wxPoint
(
0
,
0
),
wxSize
(
600
,
400
)
);
#ifdef KICAD_SCRIPTING
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment