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
5614ba00
Commit
5614ba00
authored
Oct 07, 2013
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pcbnew: 3D view: Better 3D rendering (fix some artifact issues). Add a realistic rendering mode.
parent
191cc6d1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
249 additions
and
92 deletions
+249
-92
3d_draw.cpp
3d-viewer/3d_draw.cpp
+176
-52
3d_draw_basic_functions.h
3d-viewer/3d_draw_basic_functions.h
+1
-1
3d_frame.cpp
3d-viewer/3d_frame.cpp
+17
-0
3d_toolbar.cpp
3d-viewer/3d_toolbar.cpp
+27
-14
3d_viewer_id.h
3d-viewer/3d_viewer_id.h
+2
-0
info3d_visu.cpp
3d-viewer/info3d_visu.cpp
+14
-22
info3d_visu.h
3d-viewer/info3d_visu.h
+12
-3
No files found.
3d-viewer/3d_draw.cpp
View file @
5614ba00
...
...
@@ -146,11 +146,69 @@ void EDA_3D_CANVAS::Redraw( bool finish )
SwapBuffers
();
}
// Helper function: initialize the copper color to draw the board
// in realistic mode.
static
inline
void
SetGLCopperColor
()
{
// Generates a golden yellow color, near board "copper" color
const
double
lum
=
0.7
/
255.0
;
glColor4f
(
255.0
*
lum
,
223.0
*
lum
,
0.0
*
lum
,
1.0
);
}
// Helper function: initialize the color to draw the epoxy layers
// ( body board and solder mask layers) in realistic mode.
static
inline
void
SetGLEpoxyColor
(
double
aTransparency
=
1.0
)
{
// Generates an epoxy color, near board color
const
double
lum
=
0.2
/
255.0
;
glColor4f
(
100.0
*
lum
,
255.0
*
lum
,
180.0
*
lum
,
aTransparency
);
}
// Helper function: initialize the color to draw the non copper layers
// in realistic mode and normal mode.
static
inline
void
SetGLTechLayersColor
(
LAYER_NUM
aLayer
)
{
// Generates an epoxy color, near board color
// const double lum = 0.2/255.0;
if
(
g_Parm_3D_Visu
.
IsRealisticMode
()
)
{
switch
(
aLayer
)
{
case
SOLDERPASTE_N_BACK
:
case
SOLDERPASTE_N_FRONT
:
SetGLColor
(
DARKGRAY
,
0.7
);
break
;
case
SILKSCREEN_N_BACK
:
case
SILKSCREEN_N_FRONT
:
SetGLColor
(
LIGHTGRAY
,
0.9
);
break
;
case
SOLDERMASK_N_BACK
:
case
SOLDERMASK_N_FRONT
:
SetGLEpoxyColor
(
0.7
);
break
;
default
:
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayerColor
(
aLayer
);
SetGLColor
(
color
,
0.7
);
break
;
}
}
else
{
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayerColor
(
aLayer
);
SetGLColor
(
color
,
0.7
);
}
}
void
EDA_3D_CANVAS
::
BuildBoard3DView
()
{
PCB_BASE_FRAME
*
pcbframe
=
Parent
()
->
Parent
();
BOARD
*
pcb
=
pcbframe
->
GetBoard
();
bool
realistic_mode
=
g_Parm_3D_Visu
.
IsRealisticMode
();
// Number of segments to draw a circle using segments
const
int
segcountforcircle
=
16
;
...
...
@@ -170,6 +228,8 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Build a polygon from edge cut items
wxString
msg
;
if
(
realistic_mode
||
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_SHOW_BOARD_BODY
]
)
{
if
(
!
pcb
->
GetBoardPolygonOutlines
(
bufferPcbOutlines
,
allLayerHoles
,
&
msg
)
)
{
...
...
@@ -177,6 +237,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
_
(
"Unable to calculate the board outlines, will use the outlines boundary box"
);
wxMessageBox
(
msg
);
}
}
CPOLYGONS_LIST
bufferZonesPolys
;
bufferZonesPolys
.
reserve
(
500000
);
// Reserve for large board ( copper zones mainly )
...
...
@@ -192,7 +253,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
&&
layer
>=
g_Parm_3D_Visu
.
m_CopperLayersCount
)
continue
;
if
(
!
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
layer
)
)
if
(
!
Is3DLayerEnabled
(
layer
)
)
continue
;
bufferPolys
.
RemoveAllContours
();
...
...
@@ -315,11 +376,17 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Merge polygons, remove holes
currLayerPolyset
-=
polysetHoles
;
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
if
(
realistic_mode
)
SetGLCopperColor
();
else
{
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
SetGLColor
(
color
);
}
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
bufferPolys
.
RemoveAllContours
();
...
...
@@ -350,6 +417,53 @@ void EDA_3D_CANVAS::BuildBoard3DView()
Draw3DPadHole
(
pad
);
}
// Draw board substrate:
if
(
bufferPcbOutlines
.
GetCornersCount
()
)
{
int
copper_thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
// a small offset between substrate and external copper layer to avoid artifacts
// when drawing copper items on board
int
epsilon
=
Millimeter2iu
(
0.01
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
);
int
board_thickness
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_FRONT
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
);
// items on copper layers and having a thickness = copper_thickness
// are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
// therefore substrate position is copper_thickness/2 to
// substrate_height - copper_thickness/2
zpos
+=
(
copper_thickness
+
epsilon
)
/
2
;
board_thickness
-=
copper_thickness
+
epsilon
;
if
(
realistic_mode
)
SetGLEpoxyColor
();
else
{
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayerColor
(
EDGE_N
);
SetGLColor
(
color
,
0.7
);
}
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
LAYER_N_FRONT
)
);
KI_POLYGON_SET
currLayerPolyset
;
KI_POLYGON_SET
polysetHoles
;
// Add polygons, without holes
bufferPcbOutlines
.
ExportTo
(
currLayerPolyset
);
// Build holes list
allLayerHoles
.
ExportTo
(
polysetHoles
);
// remove holes
currLayerPolyset
-=
polysetHoles
;
bufferPcbOutlines
.
RemoveAllContours
();
bufferPcbOutlines
.
ImportFrom
(
currLayerPolyset
);
// for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
// sides
Draw3D_SolidHorizontalPolyPolygons
(
bufferPcbOutlines
,
zpos
+
board_thickness
/
2
,
board_thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
// draw graphic items, not on copper layers
for
(
LAYER_NUM
layer
=
FIRST_NON_COPPER_LAYER
;
layer
<=
LAST_NON_COPPER_LAYER
;
layer
++
)
...
...
@@ -357,10 +471,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
if
(
!
Is3DLayerEnabled
(
layer
)
)
continue
;
if
(
!
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
layer
)
)
continue
;
if
(
layer
==
EDGE_N
)
if
(
layer
==
EDGE_N
&&
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_SHOW_BOARD_BODY
]
)
continue
;
bufferPolys
.
RemoveAllContours
();
...
...
@@ -442,47 +553,33 @@ void EDA_3D_CANVAS::BuildBoard3DView()
currLayerPolyset
+=
polyset
;
}
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayer
Color
(
layer
);
SetGLTechLayers
Color
(
layer
);
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
SetGLColor
(
color
,
0.7
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
bufferPolys
.
RemoveAllContours
();
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
// Draw board substrate:
if
(
bufferPcbOutlines
.
GetCornersCount
()
)
if
(
layer
==
EDGE_N
)
{
int
copper_thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
LAYER_N_BACK
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
);
int
thickness
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_FRONT
)
thickness
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_FRONT
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
);
zpos
+=
(
thickness
/
2
)
+
(
copper_thickness
/
2
);
thickness
-=
copper_thickness
;
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetLayerColor
(
EDGE_N
);
SetGLColor
(
color
,
0.8
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
LAYER_N_FRONT
)
);
KI_POLYGON_SET
currLayerPolyset
;
KI_POLYGON_SET
polysetHoles
;
// Add polygons, without holes
bufferPcbOutlines
.
ExportTo
(
currLayerPolyset
);
// Build holes list
allLayerHoles
.
ExportTo
(
polysetHoles
);
// remove holes
currLayerPolyset
-=
polysetHoles
;
bufferPcbOutlines
.
RemoveAllContours
();
bufferPcbOutlines
.
ImportFrom
(
currLayerPolyset
);
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
)
+
(
thickness
/
2
);
}
else
{
// for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
// sides.
// However for top layers, zpos should be the bottom layer pos,
// and for bottom layers, zpos should be the top layer pos.
if
(
Get3DLayer_Z_Orientation
(
layer
)
>
0
)
zpos
+=
thickness
/
2
;
else
zpos
-=
thickness
/
2
;
}
Draw3D_SolidHorizontalPolyPolygons
(
bufferPcbOutlines
,
zpos
,
bufferPolys
.
RemoveAllContours
();
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
...
...
@@ -706,8 +803,14 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia )
aVia
->
ReturnLayerPair
(
&
top_layer
,
&
bottom_layer
);
// Drawing via hole:
if
(
g_Parm_3D_Visu
.
IsRealisticMode
()
)
SetGLCopperColor
();
else
{
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetItemColor
(
VIAS_VISIBLE
+
aVia
->
GetShape
()
);
SetGLColor
(
color
);
}
int
height
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
top_layer
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
bottom_layer
)
-
thickness
;
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
bottom_layer
)
+
thickness
/
2
;
...
...
@@ -773,7 +876,11 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
int
height
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_FRONT
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
);
if
(
g_Parm_3D_Visu
.
IsRealisticMode
()
)
SetGLCopperColor
();
else
SetGLColor
(
DARKGRAY
);
int
holeZpoz
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
LAYER_N_BACK
)
+
thickness
/
2
;
int
holeHeight
=
height
-
thickness
;
...
...
@@ -815,6 +922,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
bool
Is3DLayerEnabled
(
LAYER_NUM
aLayer
)
{
int
flg
;
bool
realistic_mode
=
g_Parm_3D_Visu
.
IsRealisticMode
();
// see if layer needs to be shown
// check the flags
...
...
@@ -842,21 +950,37 @@ bool Is3DLayerEnabled( LAYER_NUM aLayer )
case
DRAW_N
:
case
COMMENT_N
:
if
(
realistic_mode
)
return
false
;
flg
=
g_Parm_3D_Visu
.
FL_COMMENTS
;
break
;
case
ECO1_N
:
case
ECO2_N
:
if
(
realistic_mode
)
return
false
;
flg
=
g_Parm_3D_Visu
.
FL_ECO
;
break
;
case
LAYER_N_BACK
:
case
LAYER_N_FRONT
:
return
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
)
||
realistic_mode
;
break
;
default
:
// the layer was not a layer with a flag, so show it
return
true
;
// the layer is an internal copper layer
if
(
realistic_mode
)
return
false
;
return
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
);
}
// if the layer has a flag, return the flag
return
g_Parm_3D_Visu
.
m_DrawFlags
[
flg
];
return
g_Parm_3D_Visu
.
m_DrawFlags
[
flg
]
&&
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
);
}
...
...
3d-viewer/3d_draw_basic_functions.h
View file @
5614ba00
...
...
@@ -37,7 +37,7 @@
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness
1
0, a solid object is drawn.
* If aThickness
>
0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
...
...
3d-viewer/3d_frame.cpp
View file @
5614ba00
...
...
@@ -47,6 +47,7 @@ static const wxString keySizey( wxT( "Size_y" ) );
static
const
wxString
keyBgColor_Red
(
wxT
(
"BgColor_Red"
)
);
static
const
wxString
keyBgColor_Green
(
wxT
(
"BgColor_Green"
)
);
static
const
wxString
keyBgColor_Blue
(
wxT
(
"BgColor_Blue"
)
);
static
const
wxString
keyShowRealisticMode
(
wxT
(
"ShowRealisticMode"
)
);
static
const
wxString
keyShowAxis
(
wxT
(
"ShowAxis"
)
);
static
const
wxString
keyShowZones
(
wxT
(
"ShowZones"
)
);
static
const
wxString
keyShowFootprints
(
wxT
(
"ShowFootprints"
)
);
...
...
@@ -56,6 +57,7 @@ static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) )
static
const
wxString
keyShowSolderMaskLayers
(
wxT
(
"ShowSolderMasLayers"
)
);
static
const
wxString
keyShowSolderPasteLayers
(
wxT
(
"ShowSolderPasteLayers"
)
);
static
const
wxString
keyShowCommentsLayer
(
wxT
(
"ShowCommentsLayers"
)
);
static
const
wxString
keyShowBoardBody
(
wxT
(
"ShowBoardBody"
)
);
static
const
wxString
keyShowEcoLayers
(
wxT
(
"ShowEcoLayers"
)
);
BEGIN_EVENT_TABLE
(
EDA_3D_FRAME
,
wxFrame
)
...
...
@@ -167,6 +169,8 @@ void EDA_3D_FRAME::GetSettings()
config
->
Read
(
keyBgColor_Green
,
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
,
0.0
);
config
->
Read
(
keyBgColor_Blue
,
&
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
,
0.0
);
class
INFO3D_VISU
&
prms
=
g_Parm_3D_Visu
;
config
->
Read
(
keyShowRealisticMode
,
&
prms
.
m_DrawFlags
[
prms
.
FL_USE_REALISTIC_MODE
],
false
);
config
->
Read
(
keyShowAxis
,
&
prms
.
m_DrawFlags
[
prms
.
FL_AXIS
],
true
);
config
->
Read
(
keyShowFootprints
,
&
prms
.
m_DrawFlags
[
prms
.
FL_MODULE
],
true
);
config
->
Read
(
keyShowCopperThickness
,
...
...
@@ -179,6 +183,7 @@ void EDA_3D_FRAME::GetSettings()
config
->
Read
(
keyShowSolderPasteLayers
,
&
prms
.
m_DrawFlags
[
prms
.
FL_SOLDERPASTE
],
true
);
config
->
Read
(
keyShowCommentsLayer
,
&
prms
.
m_DrawFlags
[
prms
.
FL_COMMENTS
],
true
);
config
->
Read
(
keyShowEcoLayers
,
&
prms
.
m_DrawFlags
[
prms
.
FL_ECO
],
true
);
config
->
Read
(
keyShowBoardBody
,
&
prms
.
m_DrawFlags
[
prms
.
FL_SHOW_BOARD_BODY
],
true
);
}
}
...
...
@@ -195,6 +200,7 @@ void EDA_3D_FRAME::SaveSettings()
config
->
Write
(
keyBgColor_Green
,
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
);
config
->
Write
(
keyBgColor_Blue
,
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
);
class
INFO3D_VISU
&
prms
=
g_Parm_3D_Visu
;
config
->
Write
(
keyShowRealisticMode
,
prms
.
m_DrawFlags
[
prms
.
FL_USE_REALISTIC_MODE
]
);
config
->
Write
(
keyShowAxis
,
prms
.
m_DrawFlags
[
prms
.
FL_AXIS
]
);
config
->
Write
(
keyShowFootprints
,
prms
.
m_DrawFlags
[
prms
.
FL_MODULE
]
);
config
->
Write
(
keyShowCopperThickness
,
prms
.
m_DrawFlags
[
prms
.
FL_USE_COPPER_THICKNESS
]
);
...
...
@@ -205,6 +211,7 @@ void EDA_3D_FRAME::SaveSettings()
config
->
Write
(
keyShowSolderPasteLayers
,
prms
.
m_DrawFlags
[
prms
.
FL_SOLDERPASTE
]
);
config
->
Write
(
keyShowCommentsLayer
,
prms
.
m_DrawFlags
[
prms
.
FL_COMMENTS
]
);
config
->
Write
(
keyShowEcoLayers
,
prms
.
m_DrawFlags
[
prms
.
FL_ECO
]
);
config
->
Write
(
keyShowBoardBody
,
prms
.
m_DrawFlags
[
prms
.
FL_SHOW_BOARD_BODY
]
);
if
(
IsIconized
()
)
return
;
...
...
@@ -355,6 +362,16 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
Set3DBgColor
();
return
;
case
ID_MENU3D_REALISTIC_MODE
:
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_USE_REALISTIC_MODE
]
=
isChecked
;
NewDisplay
();
return
;
case
ID_MENU3D_SHOW_BOARD_BODY
:
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_SHOW_BOARD_BODY
]
=
isChecked
;
NewDisplay
();
return
;
case
ID_MENU3D_AXIS_ONOFF
:
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_AXIS
]
=
isChecked
;
NewDisplay
();
...
...
3d-viewer/3d_toolbar.cpp
View file @
5614ba00
...
...
@@ -158,17 +158,19 @@ void EDA_3D_FRAME::CreateMenuBar()
menuBar
->
Append
(
prefsMenu
,
_
(
"&Preferences"
)
);
AddMenuItem
(
prefsMenu
,
ID_MENU3D_REALISTIC_MODE
,
_
(
"Realistic Mode"
),
KiBitmap
(
use_3D_copper_thickness_xpm
),
wxITEM_CHECK
);
prefsMenu
->
AppendSeparator
();
AddMenuItem
(
prefsMenu
,
ID_MENU3D_BGCOLOR_SELECTION
,
_
(
"Choose background color"
),
KiBitmap
(
palette_xpm
)
);
wxMenuItem
*
item
;
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_AXIS_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_AXIS_ONOFF
,
_
(
"Show 3D &Axis"
),
KiBitmap
(
axis3d_front_xpm
),
wxITEM_CHECK
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_AXIS
]);
// Creates grid menu
wxMenu
*
gridlistMenu
=
new
wxMenu
;
item
=
AddMenuItem
(
prefsMenu
,
gridlistMenu
,
ID_MENU3D_GRID
,
AddMenuItem
(
prefsMenu
,
gridlistMenu
,
ID_MENU3D_GRID
,
_
(
"3D Grid"
),
KiBitmap
(
grid_xpm
)
);
gridlistMenu
->
Append
(
ID_MENU3D_GRID_NOGRID
,
_
(
"No 3D Grid"
),
wxEmptyString
,
true
);
gridlistMenu
->
Check
(
ID_MENU3D_GRID_NOGRID
,
true
);
...
...
@@ -178,32 +180,34 @@ void EDA_3D_FRAME::CreateMenuBar()
gridlistMenu
->
Append
(
ID_MENU3D_GRID_2P5_MM
,
_
(
"3D Grid 2.5 mm"
),
wxEmptyString
,
true
);
gridlistMenu
->
Append
(
ID_MENU3D_GRID_1_MM
,
_
(
"3D Grid 1 mm"
),
wxEmptyString
,
true
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_USE_COPPER_THICKNESS
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SHOW_BOARD_BODY
,
_
(
"Show Board Body"
),
KiBitmap
(
use_3D_copper_thickness_xpm
),
wxITEM_CHECK
);
AddMenuItem
(
prefsMenu
,
ID_MENU3D_USE_COPPER_THICKNESS
,
_
(
"Show Copper Thickness"
),
KiBitmap
(
use_3D_copper_thickness_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_MODULE_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_MODULE_ONOFF
,
_
(
"Show 3D F&ootprints"
),
KiBitmap
(
shape_3d_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_ZONE_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_ZONE_ONOFF
,
_
(
"Show Zone &Filling"
),
KiBitmap
(
add_zone_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_ADHESIVE_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_ADHESIVE_ONOFF
,
_
(
"Show &Adhesive Layers"
),
KiBitmap
(
tools_xpm
),
wxITEM_CHECK
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_ADHESIVE
]);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SILKSCREEN_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SILKSCREEN_ONOFF
,
_
(
"Show &Silkscreen Layer"
),
KiBitmap
(
add_text_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SOLDER_MASK_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SOLDER_MASK_ONOFF
,
_
(
"Show Solder &Mask Layers"
),
KiBitmap
(
pads_mask_layers_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SOLDER_PASTE_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_SOLDER_PASTE_ONOFF
,
_
(
"Show Solder &Paste Layers"
),
KiBitmap
(
pads_mask_layers_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_COMMENTS_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_COMMENTS_ONOFF
,
_
(
"Show &Comments and Drawings Layer"
),
KiBitmap
(
edit_sheet_xpm
),
wxITEM_CHECK
);
item
=
AddMenuItem
(
prefsMenu
,
ID_MENU3D_ECO_ONOFF
,
AddMenuItem
(
prefsMenu
,
ID_MENU3D_ECO_ONOFF
,
_
(
"Show &Eco Layers"
),
KiBitmap
(
edit_sheet_xpm
),
wxITEM_CHECK
);
SetMenuBar
(
menuBar
);
...
...
@@ -219,6 +223,12 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
wxMenuItem
*
item
;
// Set the state of toggle menus according to the current display options
item
=
menuBar
->
FindItem
(
ID_MENU3D_REALISTIC_MODE
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_USE_REALISTIC_MODE
]);
item
=
menuBar
->
FindItem
(
ID_MENU3D_SHOW_BOARD_BODY
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_SHOW_BOARD_BODY
]);
item
=
menuBar
->
FindItem
(
ID_MENU3D_USE_COPPER_THICKNESS
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_USE_COPPER_THICKNESS
]);
...
...
@@ -228,6 +238,9 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
item
=
menuBar
->
FindItem
(
ID_MENU3D_ZONE_ONOFF
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_ZONE
]);
item
=
menuBar
->
FindItem
(
ID_MENU3D_AXIS_ONOFF
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_AXIS
]);
item
=
menuBar
->
FindItem
(
ID_MENU3D_ADHESIVE_ONOFF
);
item
->
Check
(
g_Parm_3D_Visu
.
m_DrawFlags
[
g_Parm_3D_Visu
.
FL_ADHESIVE
]);
...
...
3d-viewer/3d_viewer_id.h
View file @
5614ba00
...
...
@@ -39,6 +39,8 @@ enum id_3dview_frm
ID_MENU3D_SOLDER_MASK_ONOFF
,
ID_MENU3D_COMMENTS_ONOFF
,
ID_MENU3D_ECO_ONOFF
,
ID_MENU3D_SHOW_BOARD_BODY
,
ID_MENU3D_REALISTIC_MODE
,
ID_END_COMMAND_3D
,
ID_TOOL_SET_VISIBLE_ITEMS
,
...
...
3d-viewer/info3d_visu.cpp
View file @
5614ba00
...
...
@@ -39,7 +39,7 @@
// Thickness of copper
// TODO: define the actual copper thickness by user
#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35
µ
m
#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35
u
m
#define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM )
#define EPOXY_THICKNESS KiROUND( 1.6 * IU_PER_MM ) // for 1.6 mm
...
...
@@ -124,8 +124,10 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
m_EpoxyThickness
*
layer
/
(
copper_layers_cnt
-
1
);
}
double
zpos_copper_back
=
m_LayerZcoord
[
0
];
double
zpos_copper_front
=
m_EpoxyThickness
;
#define layerThicknessMargin 1.1
double
zpos_offset
=
m_NonCopperLayerThickness
*
layerThicknessMargin
;
double
zpos_copper_back
=
m_LayerZcoord
[
0
]
-
layerThicknessMargin
*
m_CopperThickness
/
2
;
double
zpos_copper_front
=
m_EpoxyThickness
+
layerThicknessMargin
*
m_CopperThickness
/
2
;
// Fill remaining unused copper layers and front layer zpos
// with m_EpoxyThickness
...
...
@@ -138,54 +140,44 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
for
(
int
layer_id
=
FIRST_NON_COPPER_LAYER
;
layer_id
<
NB_PCB_LAYERS
;
layer_id
++
)
{
double
zpos
;
#define NonCopperLayerThicknessMargin 1.1
switch
(
layer_id
)
{
case
ADHESIVE_N_BACK
:
zpos
=
zpos_copper_back
-
4
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_back
-
4
*
zpos_offset
;
break
;
case
ADHESIVE_N_FRONT
:
zpos
=
zpos_copper_front
+
4
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_front
+
4
*
zpos_offset
;
break
;
case
SOLDERPASTE_N_BACK
:
zpos
=
zpos_copper_back
-
3
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_back
-
3
*
zpos_offset
;
break
;
case
SOLDERPASTE_N_FRONT
:
zpos
=
zpos_copper_front
+
3
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_front
+
3
*
zpos_offset
;
break
;
case
SOLDERMASK_N_BACK
:
zpos
=
zpos_copper_back
-
1
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_back
-
1
*
zpos_offset
;
break
;
case
SOLDERMASK_N_FRONT
:
zpos
=
zpos_copper_front
+
1
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_front
+
2
*
zpos_offset
;
break
;
case
SILKSCREEN_N_BACK
:
zpos
=
zpos_copper_back
-
2
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_back
-
2
*
zpos_offset
;
break
;
case
SILKSCREEN_N_FRONT
:
zpos
=
zpos_copper_front
+
2
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
zpos
=
zpos_copper_front
+
2
*
zpos_offset
;
break
;
default
:
zpos
=
zpos_copper_front
+
(
layer_id
-
FIRST_NON_COPPER_LAYER
+
5
)
*
m_NonCopperLayerThickness
*
NonCopperLayerThicknessMargin
;
(
layer_id
-
FIRST_NON_COPPER_LAYER
+
5
)
*
zpos_offset
;
break
;
}
...
...
3d-viewer/info3d_visu.h
View file @
5614ba00
...
...
@@ -72,6 +72,8 @@ public:
FL_COMMENTS
,
FL_ECO
,
FL_GRID
,
FL_USE_COPPER_THICKNESS
,
FL_SHOW_BOARD_BODY
,
FL_USE_REALISTIC_MODE
,
FL_LAST
};
...
...
@@ -133,11 +135,14 @@ public: INFO3D_VISU();
* note: the thickness (Z size) of the copper is not the thickness
* of the layer (the thickness of the layer is the epoxy thickness / layer count)
*
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set,
* and normal mode, returns 0
*/
int
GetCopperThicknessBIU
()
const
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
bool
use_copper_thickness
=
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
||
m_DrawFlags
[
FL_USE_REALISTIC_MODE
];
return
use_copper_thickness
?
KiROUND
(
m_CopperThickness
/
m_BiuTo3Dunits
)
:
0
;
}
...
...
@@ -160,7 +165,9 @@ public: INFO3D_VISU();
*/
int
GetNonCopperLayerThicknessBIU
()
const
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
bool
use_copper_thickness
=
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
||
m_DrawFlags
[
FL_USE_REALISTIC_MODE
];
return
use_copper_thickness
?
KiROUND
(
m_NonCopperLayerThickness
/
m_BiuTo3Dunits
)
:
0
;
}
...
...
@@ -178,6 +185,8 @@ public: INFO3D_VISU();
GetNonCopperLayerThicknessBIU
()
:
GetCopperThicknessBIU
();
}
bool
IsRealisticMode
()
{
return
m_DrawFlags
[
FL_USE_REALISTIC_MODE
];
}
};
extern
INFO3D_VISU
g_Parm_3D_Visu
;
...
...
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