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
5e032ef0
Commit
5e032ef0
authored
Aug 20, 2014
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3d-viewer: code cleaning and minor bug fix.
parent
259425a2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
178 additions
and
127 deletions
+178
-127
3d_canvas.cpp
3d-viewer/3d_canvas.cpp
+25
-2
3d_canvas.h
3d-viewer/3d_canvas.h
+20
-6
3d_draw.cpp
3d-viewer/3d_draw.cpp
+70
-78
3d_draw_basic_functions.cpp
3d-viewer/3d_draw_basic_functions.cpp
+7
-0
3d_draw_basic_functions.h
3d-viewer/3d_draw_basic_functions.h
+7
-0
3d_draw_helper_functions.cpp
3d-viewer/3d_draw_helper_functions.cpp
+49
-41
text_pcb.h
3d-viewer/textures/text_pcb.h
+0
-0
text_silk.h
3d-viewer/textures/text_silk.h
+0
-0
No files found.
3d-viewer/3d_canvas.cpp
View file @
5e032ef0
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
/**
* @file 3d_canvas.cpp
* @file 3d_canvas.cpp
*/
*/
...
@@ -26,8 +49,8 @@
...
@@ -26,8 +49,8 @@
#include <trackball.h>
#include <trackball.h>
#include <3d_viewer_id.h>
#include <3d_viewer_id.h>
#include <textures/text_silk.
c
>
#include <textures/text_silk.
h
>
#include <textures/text_pcb.
c
>
#include <textures/text_pcb.
h
>
// -----------------
// -----------------
// helper function (from wxWidgets, opengl/cube.cpp sample
// helper function (from wxWidgets, opengl/cube.cpp sample
...
...
3d-viewer/3d_canvas.h
View file @
5e032ef0
...
@@ -142,48 +142,62 @@ public:
...
@@ -142,48 +142,62 @@ public:
m_draw3dOffset
.
y
=
aPosY
;
m_draw3dOffset
.
y
=
aPosY
;
}
}
INFO3D_VISU
&
GetPrm3DVisu
()
const
;
private
:
private
:
/**
/**
* return true if we are in realistic mode render
* return true if we are in realistic mode render
*/
*/
bool
isRealisticMode
()
const
;
bool
isRealisticMode
()
const
;
/**
/**
* return true if aItem should be displayed
*
@
return true if aItem should be displayed
* @param aItem = an item of DISPLAY3D_FLG enum
* @param aItem = an item of DISPLAY3D_FLG enum
*/
*/
bool
isEnabled
(
DISPLAY3D_FLG
aItem
)
const
;
bool
isEnabled
(
DISPLAY3D_FLG
aItem
)
const
;
/* Helper function
/*
*
Helper function
* @return true if aLayer should be displayed, false otherwise
* @return true if aLayer should be displayed, false otherwise
*/
*/
bool
is3DLayerEnabled
(
LAYER_ID
aLayer
)
const
;
bool
is3DLayerEnabled
(
LAYER_ID
aLayer
)
const
;
/**
* @return the size of the board in pcb units
*/
wxSize
getBoardSize
()
const
;
/**
* @return the position of the board center in pcb units
*/
wxPoint
getBoardCenter
()
const
;
/**
/**
* Helper function SetGLTechLayersColor
* Helper function SetGLTechLayersColor
* Initialize the color to draw the non copper layers
* Initialize the color to draw the non copper layers
* in realistic mode and normal mode.
* in realistic mode and normal mode.
*/
*/
void
S
etGLTechLayersColor
(
LAYER_NUM
aLayer
);
void
s
etGLTechLayersColor
(
LAYER_NUM
aLayer
);
/**
/**
* Helper function SetGLCopperColor
* Helper function SetGLCopperColor
* Initialize the copper color to draw the board
* Initialize the copper color to draw the board
* in realistic mode (a golden yellow color )
* in realistic mode (a golden yellow color )
*/
*/
void
S
etGLCopperColor
();
void
s
etGLCopperColor
();
/**
/**
* Helper function SetGLEpoxyColor
* Helper function SetGLEpoxyColor
* Initialize the color to draw the epoxy body board in realistic mode.
* Initialize the color to draw the epoxy body board in realistic mode.
*/
*/
void
S
etGLEpoxyColor
(
double
aTransparency
=
1
.
0
);
void
s
etGLEpoxyColor
(
double
aTransparency
=
1
.
0
);
/**
/**
* Helper function SetGLSolderMaskColor
* Helper function SetGLSolderMaskColor
* Initialize the color to draw the solder mask layers in realistic mode.
* Initialize the color to draw the solder mask layers in realistic mode.
*/
*/
void
S
etGLSolderMaskColor
(
double
aTransparency
=
1
.
0
);
void
s
etGLSolderMaskColor
(
double
aTransparency
=
1
.
0
);
/**
/**
* Function BuildBoard3DView
* Function BuildBoard3DView
...
...
3d-viewer/3d_draw.cpp
View file @
5e032ef0
...
@@ -159,8 +159,8 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture,
...
@@ -159,8 +159,8 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture,
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
// move the board in order to draw it with its center at 0,0 3D coordinates
// move the board in order to draw it with its center at 0,0 3D coordinates
glTranslatef
(
-
g_Parm_3D_Visu
.
m_BoardPos
.
x
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
,
glTranslatef
(
-
GetPrm3DVisu
().
m_BoardPos
.
x
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
,
-
g_Parm_3D_Visu
.
m_BoardPos
.
y
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
,
-
GetPrm3DVisu
().
m_BoardPos
.
y
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
,
0.0
F
);
0.0
F
);
if
(
aDraw_body
)
if
(
aDraw_body
)
...
@@ -268,11 +268,11 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
...
@@ -268,11 +268,11 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
glMatrixMode
(
GL_PROJECTION
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
glLoadIdentity
();
const
double
ZDIST_MAX
=
Millimeter2iu
(
3.5
)
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
const
double
ZDIST_MAX
=
Millimeter2iu
(
3.5
)
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
;
glOrtho
(
-
g_Parm_3D_Visu
.
m_BoardSize
.
x
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
glOrtho
(
-
GetPrm3DVisu
().
m_BoardSize
.
x
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
g_Parm_3D_Visu
.
m_BoardSize
.
x
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
GetPrm3DVisu
().
m_BoardSize
.
x
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
-
g_Parm_3D_Visu
.
m_BoardSize
.
y
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
-
GetPrm3DVisu
().
m_BoardSize
.
y
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
g_Parm_3D_Visu
.
m_BoardSize
.
y
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
GetPrm3DVisu
().
m_BoardSize
.
y
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
0.0
,
ZDIST_MAX
);
0.0
,
ZDIST_MAX
);
// Render FRONT shadow
// Render FRONT shadow
...
@@ -295,10 +295,10 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
...
@@ -295,10 +295,10 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
// Render ALL BOARD shadow
// Render ALL BOARD shadow
glMatrixMode
(
GL_PROJECTION
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
glLoadIdentity
();
glOrtho
(
-
g_Parm_3D_Visu
.
m_BoardSize
.
x
*
SHADOW_BOARD_SCALE
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
glOrtho
(
-
GetPrm3DVisu
().
m_BoardSize
.
x
*
SHADOW_BOARD_SCALE
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
g_Parm_3D_Visu
.
m_BoardSize
.
x
*
SHADOW_BOARD_SCALE
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
GetPrm3DVisu
().
m_BoardSize
.
x
*
SHADOW_BOARD_SCALE
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
-
g_Parm_3D_Visu
.
m_BoardSize
.
y
*
SHADOW_BOARD_SCALE
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
-
GetPrm3DVisu
().
m_BoardSize
.
y
*
SHADOW_BOARD_SCALE
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
g_Parm_3D_Visu
.
m_BoardSize
.
y
*
SHADOW_BOARD_SCALE
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
/
2.0
f
,
GetPrm3DVisu
().
m_BoardSize
.
y
*
SHADOW_BOARD_SCALE
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
/
2.0
f
,
0.0
,
6.0
f
*
ZDIST_MAX
);
0.0
,
6.0
f
*
ZDIST_MAX
);
glMatrixMode
(
GL_MODELVIEW
);
glMatrixMode
(
GL_MODELVIEW
);
...
@@ -366,23 +366,14 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -366,23 +366,14 @@ void EDA_3D_CANVAS::Redraw()
// Draw the background ( rectangle with color gradient)
// Draw the background ( rectangle with color gradient)
glBegin
(
GL_QUADS
);
glBegin
(
GL_QUADS
);
glColor4f
(
g_Parm_3D_Visu
.
m_BgColor_Top
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_BgColor_Top
,
1.0
);
g_Parm_3D_Visu
.
m_BgColor_Top
.
m_Green
,
g_Parm_3D_Visu
.
m_BgColor_Top
.
m_Blue
,
1.0
);
glVertex2f
(
-
1.0
,
1.0
);
// Top left corner
glVertex2f
(
-
1.0
,
1.0
);
// Top left corner
glColor4f
(
g_Parm_3D_Visu
.
m_BgColor
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_BgColor
,
1.0
);
g_Parm_3D_Visu
.
m_BgColor
.
m_Green
,
g_Parm_3D_Visu
.
m_BgColor
.
m_Blue
,
1.0
);
glVertex2f
(
-
1.0
,
-
1.0
);
// bottom left corner
glVertex2f
(
-
1.0
,
-
1.0
);
// bottom left corner
glVertex2f
(
1.0
,
-
1.0
);
// bottom right corner
glVertex2f
(
1.0
,
-
1.0
);
// bottom right corner
glColor4f
(
g_Parm_3D_Visu
.
m_BgColor_Top
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_BgColor_Top
,
1.0
);
g_Parm_3D_Visu
.
m_BgColor_Top
.
m_Green
,
g_Parm_3D_Visu
.
m_BgColor_Top
.
m_Blue
,
1.0
);
glVertex2f
(
1.0
,
1.0
);
// top right corner
glVertex2f
(
1.0
,
1.0
);
// top right corner
glEnd
();
glEnd
();
...
@@ -394,14 +385,14 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -394,14 +385,14 @@ void EDA_3D_CANVAS::Redraw()
glLoadIdentity
();
glLoadIdentity
();
#define MAX_VIEW_ANGLE 160.0 / 45.0
#define MAX_VIEW_ANGLE 160.0 / 45.0
if
(
g_Parm_3D_Visu
.
m_Zoom
>
MAX_VIEW_ANGLE
)
if
(
GetPrm3DVisu
()
.
m_Zoom
>
MAX_VIEW_ANGLE
)
g_Parm_3D_Visu
.
m_Zoom
=
MAX_VIEW_ANGLE
;
GetPrm3DVisu
()
.
m_Zoom
=
MAX_VIEW_ANGLE
;
if
(
Parent
()
->
ModeIsOrtho
()
)
if
(
Parent
()
->
ModeIsOrtho
()
)
{
{
// OrthoReductionFactor is chosen to provide roughly the same size as
// OrthoReductionFactor is chosen to provide roughly the same size as
// Perspective View
// Perspective View
const
double
orthoReductionFactor
=
400
/
g_Parm_3D_Visu
.
m_Zoom
;
const
double
orthoReductionFactor
=
400
/
GetPrm3DVisu
()
.
m_Zoom
;
// Initialize Projection Matrix for Ortographic View
// Initialize Projection Matrix for Ortographic View
glOrtho
(
-
size
.
x
/
orthoReductionFactor
,
size
.
x
/
orthoReductionFactor
,
glOrtho
(
-
size
.
x
/
orthoReductionFactor
,
size
.
x
/
orthoReductionFactor
,
...
@@ -413,7 +404,7 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -413,7 +404,7 @@ void EDA_3D_CANVAS::Redraw()
double
ratio_HV
=
(
double
)
size
.
x
/
size
.
y
;
double
ratio_HV
=
(
double
)
size
.
x
/
size
.
y
;
// Initialize Projection Matrix for Perspective View
// Initialize Projection Matrix for Perspective View
gluPerspective
(
45.0
*
g_Parm_3D_Visu
.
m_Zoom
,
ratio_HV
,
1
,
100
);
gluPerspective
(
45.0
*
GetPrm3DVisu
()
.
m_Zoom
,
ratio_HV
,
1
,
100
);
}
}
// position viewer
// position viewer
...
@@ -434,12 +425,12 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -434,12 +425,12 @@ void EDA_3D_CANVAS::Redraw()
// Translate motion first, so rotations don't mess up the orientation...
// Translate motion first, so rotations don't mess up the orientation...
glTranslatef
(
m_draw3dOffset
.
x
,
m_draw3dOffset
.
y
,
0.0
F
);
glTranslatef
(
m_draw3dOffset
.
x
,
m_draw3dOffset
.
y
,
0.0
F
);
build_rotmatrix
(
mat
,
g_Parm_3D_Visu
.
m_Quat
);
build_rotmatrix
(
mat
,
GetPrm3DVisu
()
.
m_Quat
);
glMultMatrixf
(
&
mat
[
0
][
0
]
);
glMultMatrixf
(
&
mat
[
0
][
0
]
);
glRotatef
(
g_Parm_3D_Visu
.
m_Rot
[
0
],
1.0
,
0.0
,
0.0
);
glRotatef
(
GetPrm3DVisu
()
.
m_Rot
[
0
],
1.0
,
0.0
,
0.0
);
glRotatef
(
g_Parm_3D_Visu
.
m_Rot
[
1
],
0.0
,
1.0
,
0.0
);
glRotatef
(
GetPrm3DVisu
()
.
m_Rot
[
1
],
0.0
,
1.0
,
0.0
);
glRotatef
(
g_Parm_3D_Visu
.
m_Rot
[
2
],
0.0
,
0.0
,
1.0
);
glRotatef
(
GetPrm3DVisu
()
.
m_Rot
[
2
],
0.0
,
0.0
,
1.0
);
if
(
!
m_glLists
[
GL_ID_BOARD
]
||
!
m_glLists
[
GL_ID_TECH_LAYERS
]
)
if
(
!
m_glLists
[
GL_ID_BOARD
]
||
!
m_glLists
[
GL_ID_TECH_LAYERS
]
)
...
@@ -449,8 +440,8 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -449,8 +440,8 @@ void EDA_3D_CANVAS::Redraw()
glCallList
(
m_glLists
[
GL_ID_AXIS
]
);
glCallList
(
m_glLists
[
GL_ID_AXIS
]
);
// move the board in order to draw it with its center at 0,0 3D coordinates
// move the board in order to draw it with its center at 0,0 3D coordinates
glTranslatef
(
-
g_Parm_3D_Visu
.
m_BoardPos
.
x
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
,
glTranslatef
(
-
GetPrm3DVisu
().
m_BoardPos
.
x
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
,
-
g_Parm_3D_Visu
.
m_BoardPos
.
y
*
g_Parm_3D_Visu
.
m_BiuTo3Dunits
,
-
GetPrm3DVisu
().
m_BoardPos
.
y
*
GetPrm3DVisu
()
.
m_BiuTo3Dunits
,
0.0
F
);
0.0
F
);
// draw all objects in lists
// draw all objects in lists
...
@@ -467,7 +458,8 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -467,7 +458,8 @@ void EDA_3D_CANVAS::Redraw()
if
(
isEnabled
(
FL_SHOW_BOARD_BODY
)
)
if
(
isEnabled
(
FL_SHOW_BOARD_BODY
)
)
{
{
if
(
isEnabled
(
FL_SOLDERMASK
)
||
!
isRealisticMode
()
)
if
(
!
isEnabled
(
FL_RENDER_TEXTURES
)
||
isEnabled
(
FL_SOLDERMASK
)
||
!
isRealisticMode
()
)
{
{
glDisable
(
GL_TEXTURE_2D
);
glDisable
(
GL_TEXTURE_2D
);
}
}
...
@@ -488,9 +480,9 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -488,9 +480,9 @@ void EDA_3D_CANVAS::Redraw()
glEnable
(
GL_COLOR_MATERIAL
);
glEnable
(
GL_COLOR_MATERIAL
);
SetOpenGlDefaultMaterial
();
SetOpenGlDefaultMaterial
();
glm
::
vec4
specular
(
g_Parm_3D_Visu
.
m_CopperColor
.
m_Red
*
0.3
,
glm
::
vec4
specular
(
GetPrm3DVisu
()
.
m_CopperColor
.
m_Red
*
0.3
,
g_Parm_3D_Visu
.
m_CopperColor
.
m_Green
*
0.3
,
GetPrm3DVisu
()
.
m_CopperColor
.
m_Green
*
0.3
,
g_Parm_3D_Visu
.
m_CopperColor
.
m_Blue
*
0.3
,
1.0
);
GetPrm3DVisu
()
.
m_CopperColor
.
m_Blue
*
0.3
,
1.0
);
GLint
shininess_value
=
8
;
GLint
shininess_value
=
8
;
glMateriali
(
GL_FRONT_AND_BACK
,
GL_SHININESS
,
shininess_value
);
glMateriali
(
GL_FRONT_AND_BACK
,
GL_SHININESS
,
shininess_value
);
...
@@ -609,20 +601,20 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -609,20 +601,20 @@ void EDA_3D_CANVAS::Redraw()
void
EDA_3D_CANVAS
::
BuildShadowList
(
GLuint
aFrontList
,
GLuint
aBacklist
,
GLuint
aBoardList
)
void
EDA_3D_CANVAS
::
BuildShadowList
(
GLuint
aFrontList
,
GLuint
aBacklist
,
GLuint
aBoardList
)
{
{
// Use similar calculation as Grid limits, in 3D units
// Use similar calculation as Grid limits, in 3D units
wxSize
brd_size
=
g
_Parm_3D_Visu
.
m_BoardSize
;
wxSize
brd_size
=
g
etBoardSize
()
;
wxPoint
brd_center_pos
=
g
_Parm_3D_Visu
.
m_BoardPos
;
wxPoint
brd_center_pos
=
g
etBoardCenter
()
;
float
xsize
=
brd_size
.
x
;
float
xsize
=
brd_size
.
x
;
float
ysize
=
brd_size
.
y
;
float
ysize
=
brd_size
.
y
;
float
scale
=
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
float
scale
=
GetPrm3DVisu
()
.
m_BiuTo3Dunits
;
float
xmin
=
(
brd_center_pos
.
x
-
xsize
/
2.0
)
*
scale
;
float
xmin
=
(
brd_center_pos
.
x
-
xsize
/
2.0
)
*
scale
;
float
xmax
=
(
brd_center_pos
.
x
+
xsize
/
2.0
)
*
scale
;
float
xmax
=
(
brd_center_pos
.
x
+
xsize
/
2.0
)
*
scale
;
float
ymin
=
(
brd_center_pos
.
y
-
ysize
/
2.0
)
*
scale
;
float
ymin
=
(
brd_center_pos
.
y
-
ysize
/
2.0
)
*
scale
;
float
ymax
=
(
brd_center_pos
.
y
+
ysize
/
2.0
)
*
scale
;
float
ymax
=
(
brd_center_pos
.
y
+
ysize
/
2.0
)
*
scale
;
float
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
F_Paste
);
float
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
F_Paste
);
zpos
*=
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
zpos
*=
GetPrm3DVisu
()
.
m_BiuTo3Dunits
;
// Shadow FRONT
// Shadow FRONT
glNewList
(
aFrontList
,
GL_COMPILE
);
glNewList
(
aFrontList
,
GL_COMPILE
);
...
@@ -640,8 +632,8 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint
...
@@ -640,8 +632,8 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint
// Shadow BACK
// Shadow BACK
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Paste
);
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Paste
);
zpos
*=
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
zpos
*=
GetPrm3DVisu
()
.
m_BiuTo3Dunits
;
glNewList
(
aBacklist
,
GL_COMPILE
);
glNewList
(
aBacklist
,
GL_COMPILE
);
...
@@ -661,7 +653,7 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint
...
@@ -661,7 +653,7 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint
xsize
=
brd_size
.
x
*
SHADOW_BOARD_SCALE
;
xsize
=
brd_size
.
x
*
SHADOW_BOARD_SCALE
;
ysize
=
brd_size
.
y
*
SHADOW_BOARD_SCALE
;
ysize
=
brd_size
.
y
*
SHADOW_BOARD_SCALE
;
scale
=
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
scale
=
GetPrm3DVisu
()
.
m_BiuTo3Dunits
;
xmin
=
(
brd_center_pos
.
x
-
xsize
/
2.0
)
*
scale
;
xmin
=
(
brd_center_pos
.
x
-
xsize
/
2.0
)
*
scale
;
xmax
=
(
brd_center_pos
.
x
+
xsize
/
2.0
)
*
scale
;
xmax
=
(
brd_center_pos
.
x
+
xsize
/
2.0
)
*
scale
;
ymin
=
(
brd_center_pos
.
y
-
ysize
/
2.0
)
*
scale
;
ymin
=
(
brd_center_pos
.
y
-
ysize
/
2.0
)
*
scale
;
...
@@ -731,7 +723,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -731,7 +723,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
CPOLYGONS_LIST
currLayerHoles
;
// Contains holes for the current layer
CPOLYGONS_LIST
currLayerHoles
;
// Contains holes for the current layer
bool
throughHolesListBuilt
=
false
;
// flag to build the through hole polygon list only once
bool
throughHolesListBuilt
=
false
;
// flag to build the through hole polygon list only once
LSET
cu_set
=
LSET
::
AllCuMask
(
g_Parm_3D_Visu
.
m_CopperLayersCount
);
LSET
cu_set
=
LSET
::
AllCuMask
(
GetPrm3DVisu
()
.
m_CopperLayersCount
);
#if 1
#if 1
LAYER_ID
cu_seq
[
MAX_CU_LAYERS
];
// preferred sequence, could have called CuStack()
LAYER_ID
cu_seq
[
MAX_CU_LAYERS
];
// preferred sequence, could have called CuStack()
...
@@ -774,7 +766,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -774,7 +766,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
VIA
*
via
=
static_cast
<
VIA
*>
(
track
);
VIA
*
via
=
static_cast
<
VIA
*>
(
track
);
VIATYPE_T
viatype
=
via
->
GetViaType
();
VIATYPE_T
viatype
=
via
->
GetViaType
();
int
holediameter
=
via
->
GetDrillValue
();
int
holediameter
=
via
->
GetDrillValue
();
int
thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
int
hole_outer_radius
=
(
holediameter
+
thickness
)
/
2
;
int
hole_outer_radius
=
(
holediameter
+
thickness
)
/
2
;
if
(
viatype
!=
VIA_THROUGH
)
if
(
viatype
!=
VIA_THROUGH
)
...
@@ -875,12 +867,12 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -875,12 +867,12 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
// Merge polygons, remove holes
// Merge polygons, remove holes
currLayerPolyset
-=
polysetHoles
;
currLayerPolyset
-=
polysetHoles
;
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
int
thickness
=
GetPrm3DVisu
()
.
GetLayerObjectThicknessBIU
(
layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
int
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
layer
);
if
(
realistic_mode
)
if
(
realistic_mode
)
{
{
S
etGLCopperColor
();
s
etGLCopperColor
();
}
}
else
else
{
{
...
@@ -894,7 +886,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -894,7 +886,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
thickness
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
if
(
isEnabled
(
FL_USE_COPPER_THICKNESS
)
==
true
)
if
(
isEnabled
(
FL_USE_COPPER_THICKNESS
)
==
true
)
{
{
...
@@ -906,13 +898,13 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -906,13 +898,13 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if
(
bufferZonesPolys
.
GetCornersCount
()
)
if
(
bufferZonesPolys
.
GetCornersCount
()
)
Draw3D_SolidHorizontalPolyPolygons
(
bufferZonesPolys
,
zpos
,
Draw3D_SolidHorizontalPolyPolygons
(
bufferZonesPolys
,
zpos
,
thickness
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
throughHolesListBuilt
=
true
;
throughHolesListBuilt
=
true
;
}
}
if
(
!
isEnabled
(
FL_SHOW_BOARD_BODY
)
)
if
(
!
isEnabled
(
FL_SHOW_BOARD_BODY
)
)
{
{
S
etGLCopperColor
();
s
etGLCopperColor
();
// Draw vias holes (vertical cylinders)
// Draw vias holes (vertical cylinders)
for
(
const
TRACK
*
track
=
pcb
->
m_Track
;
track
;
track
=
track
->
Next
()
)
for
(
const
TRACK
*
track
=
pcb
->
m_Track
;
track
;
track
=
track
->
Next
()
)
...
@@ -938,7 +930,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -938,7 +930,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if
(
isRealisticMode
()
)
if
(
isRealisticMode
()
)
{
{
S
etGLEpoxyColor
(
0.95
);
s
etGLEpoxyColor
(
0.95
);
}
}
else
else
{
{
...
@@ -946,14 +938,14 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -946,14 +938,14 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
SetGLColor
(
color
,
0.7
);
SetGLColor
(
color
,
0.7
);
}
}
float
copper_thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
float
copper_thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
// a small offset between substrate and external copper layer to avoid artifacts
// a small offset between substrate and external copper layer to avoid artifacts
// when drawing copper items on board
// when drawing copper items on board
float
epsilon
=
Millimeter2iu
(
0.01
);
float
epsilon
=
Millimeter2iu
(
0.01
);
float
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
);
float
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
);
float
board_thickness
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
F_Cu
)
float
board_thickness
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
F_Cu
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
);
-
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
);
// items on copper layers and having a thickness = copper_thickness
// items on copper layers and having a thickness = copper_thickness
// are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
// are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
...
@@ -981,7 +973,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
...
@@ -981,7 +973,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if
(
bufferPcbOutlines
.
GetCornersCount
()
)
if
(
bufferPcbOutlines
.
GetCornersCount
()
)
{
{
Draw3D_SolidHorizontalPolyPolygons
(
bufferPcbOutlines
,
zpos
+
board_thickness
/
2.0
,
Draw3D_SolidHorizontalPolyPolygons
(
bufferPcbOutlines
,
zpos
+
board_thickness
/
2.0
,
board_thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
board_thickness
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
}
glEndList
();
glEndList
();
...
@@ -1019,7 +1011,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
...
@@ -1019,7 +1011,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
wxMessageBox
(
msg
);
wxMessageBox
(
msg
);
}
}
int
thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
// Add via holes
// Add via holes
for
(
VIA
*
via
=
GetFirstVia
(
pcb
->
m_Track
);
via
;
for
(
VIA
*
via
=
GetFirstVia
(
pcb
->
m_Track
);
via
;
...
@@ -1165,14 +1157,14 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
...
@@ -1165,14 +1157,14 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
currLayerPolyset
+=
polyset
;
currLayerPolyset
+=
polyset
;
}
}
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
int
thickness
=
GetPrm3DVisu
()
.
GetLayerObjectThicknessBIU
(
layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
int
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
layer
);
if
(
layer
==
Edge_Cuts
)
if
(
layer
==
Edge_Cuts
)
{
{
thickness
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
F_Cu
)
thickness
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
F_Cu
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
);
-
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
);
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
)
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
)
+
(
thickness
/
2
);
+
(
thickness
/
2
);
}
}
else
else
...
@@ -1190,10 +1182,10 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
...
@@ -1190,10 +1182,10 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
bufferPolys
.
RemoveAllContours
();
bufferPolys
.
RemoveAllContours
();
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
S
etGLTechLayersColor
(
layer
);
s
etGLTechLayersColor
(
layer
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
thickness
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
}
}
}
...
@@ -1278,8 +1270,8 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
...
@@ -1278,8 +1270,8 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
bufferPolys
.
ExportTo
(
polyset
);
bufferPolys
.
ExportTo
(
polyset
);
currLayerPolyset
+=
polyset
;
currLayerPolyset
+=
polyset
;
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
int
thickness
=
GetPrm3DVisu
()
.
GetLayerObjectThicknessBIU
(
layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
int
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
layer
);
// for Draw3D_SolidHorizontalPolyPolygons,
// for Draw3D_SolidHorizontalPolyPolygons,
// zpos it the middle between bottom and top sides.
// zpos it the middle between bottom and top sides.
// However for top layers, zpos should be the bottom layer pos,
// However for top layers, zpos should be the bottom layer pos,
...
@@ -1292,10 +1284,10 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
...
@@ -1292,10 +1284,10 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
bufferPolys
.
RemoveAllContours
();
bufferPolys
.
RemoveAllContours
();
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
bufferPolys
.
ImportFrom
(
currLayerPolyset
);
S
etGLTechLayersColor
(
layer
);
s
etGLTechLayersColor
(
layer
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
Draw3D_SolidHorizontalPolyPolygons
(
bufferPolys
,
zpos
,
thickness
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
thickness
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
}
}
}
...
@@ -1306,7 +1298,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
...
@@ -1306,7 +1298,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
wxBusyCursor
dummy
;
wxBusyCursor
dummy
;
// Build 3D board parameters:
// Build 3D board parameters:
g_Parm_3D_Visu
.
InitSettings
(
pcb
);
GetPrm3DVisu
()
.
InitSettings
(
pcb
);
glColorMaterial
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
);
glColorMaterial
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
);
...
@@ -1319,7 +1311,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
...
@@ -1319,7 +1311,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
m_glLists
[
GL_ID_GRID
]
=
glGenLists
(
1
);
m_glLists
[
GL_ID_GRID
]
=
glGenLists
(
1
);
glNewList
(
m_glLists
[
GL_ID_GRID
],
GL_COMPILE
);
glNewList
(
m_glLists
[
GL_ID_GRID
],
GL_COMPILE
);
Draw3DGrid
(
g_Parm_3D_Visu
.
m_3D_Grid
);
Draw3DGrid
(
GetPrm3DVisu
()
.
m_3D_Grid
);
glEndList
();
glEndList
();
}
}
...
@@ -1428,12 +1420,12 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas,
...
@@ -1428,12 +1420,12 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas,
// Read from disk and draws the footprint 3D shapes if exists
// Read from disk and draws the footprint 3D shapes if exists
S3D_MASTER
*
shape3D
=
m_3D_Drawings
;
S3D_MASTER
*
shape3D
=
m_3D_Drawings
;
double
zpos
=
g
_Parm_3D_Visu
.
GetModulesZcoord3DIU
(
IsFlipped
()
);
double
zpos
=
g
lcanvas
->
GetPrm3DVisu
()
.
GetModulesZcoord3DIU
(
IsFlipped
()
);
glPushMatrix
();
glPushMatrix
();
glTranslatef
(
m_Pos
.
x
*
g
_Parm_3D_Visu
.
m_BiuTo3Dunits
,
glTranslatef
(
m_Pos
.
x
*
g
lcanvas
->
GetPrm3DVisu
()
.
m_BiuTo3Dunits
,
-
m_Pos
.
y
*
g
_Parm_3D_Visu
.
m_BiuTo3Dunits
,
-
m_Pos
.
y
*
g
lcanvas
->
GetPrm3DVisu
()
.
m_BiuTo3Dunits
,
zpos
);
zpos
);
if
(
m_Orient
)
if
(
m_Orient
)
...
@@ -1504,7 +1496,7 @@ bool EDA_3D_CANVAS::is3DLayerEnabled( LAYER_ID aLayer ) const
...
@@ -1504,7 +1496,7 @@ bool EDA_3D_CANVAS::is3DLayerEnabled( LAYER_ID aLayer ) const
case
B_Cu
:
case
B_Cu
:
case
F_Cu
:
case
F_Cu
:
return
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
)
return
GetPrm3DVisu
()
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
)
||
isRealisticMode
();
||
isRealisticMode
();
break
;
break
;
...
@@ -1514,7 +1506,7 @@ bool EDA_3D_CANVAS::is3DLayerEnabled( LAYER_ID aLayer ) const
...
@@ -1514,7 +1506,7 @@ bool EDA_3D_CANVAS::is3DLayerEnabled( LAYER_ID aLayer ) const
if
(
isRealisticMode
()
)
if
(
isRealisticMode
()
)
return
false
;
return
false
;
return
g_Parm_3D_Visu
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
);
return
GetPrm3DVisu
()
.
m_BoardSettings
->
IsLayerVisible
(
aLayer
);
}
}
// The layer has a flag, return the flag
// The layer has a flag, return the flag
...
...
3d-viewer/3d_draw_basic_functions.cpp
View file @
5e032ef0
...
@@ -130,6 +130,13 @@ void SetGLColor( EDA_COLOR_T color, double alpha )
...
@@ -130,6 +130,13 @@ void SetGLColor( EDA_COLOR_T color, double alpha )
glColor4f
(
red
,
green
,
blue
,
alpha
);
glColor4f
(
red
,
green
,
blue
,
alpha
);
}
}
void
SetGLColor
(
S3D_COLOR
&
aColor
,
float
aTransparency
)
{
glColor4f
(
aColor
.
m_Red
,
aColor
.
m_Green
,
aColor
.
m_Blue
,
aTransparency
);
}
static
float
m_texture_scale
;
static
float
m_texture_scale
;
void
SetGLTexture
(
GLuint
text_id
,
float
scale
)
void
SetGLTexture
(
GLuint
text_id
,
float
scale
)
...
...
3d-viewer/3d_draw_basic_functions.h
View file @
5e032ef0
...
@@ -125,6 +125,13 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
...
@@ -125,6 +125,13 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
*/
*/
void
SetGLColor
(
EDA_COLOR_T
aColor
,
double
aTransparency
=
1
.
0
);
void
SetGLColor
(
EDA_COLOR_T
aColor
,
double
aTransparency
=
1
.
0
);
/**
* Set the current 3D color from a S3D_COLOR color, with optional transparency
* @param aColor = a S3D_COLOR RGB color index
* @param aTransparency = the color transparency (default = 1.0 = no transparency)
*/
void
SetGLColor
(
S3D_COLOR
&
aColor
,
float
aTransparency
);
/**
/**
* Set a texture id and a scale to apply when rendering the polygons
* Set a texture id and a scale to apply when rendering the polygons
...
...
3d-viewer/3d_draw_helper_functions.cpp
View file @
5e032ef0
...
@@ -42,41 +42,54 @@
...
@@ -42,41 +42,54 @@
#define TEXTURE_PCB_SCALE 5.0
#define TEXTURE_PCB_SCALE 5.0
INFO3D_VISU
&
EDA_3D_CANVAS
::
GetPrm3DVisu
()
const
{
return
g_Parm_3D_Visu
;
}
wxSize
EDA_3D_CANVAS
::
getBoardSize
()
const
{
// return the size of the board in pcb units
return
GetPrm3DVisu
().
m_BoardSize
;
}
wxPoint
EDA_3D_CANVAS
::
getBoardCenter
()
const
{
// return the position of the board center in pcb units
return
GetPrm3DVisu
().
m_BoardPos
;
}
// return true if we are in realistic mode render
// return true if we are in realistic mode render
bool
EDA_3D_CANVAS
::
isRealisticMode
()
const
bool
EDA_3D_CANVAS
::
isRealisticMode
()
const
{
{
return
g_Parm_3D_Visu
.
IsRealisticMode
();
return
GetPrm3DVisu
()
.
IsRealisticMode
();
}
}
// return true if aItem should be displayed
// return true if aItem should be displayed
bool
EDA_3D_CANVAS
::
isEnabled
(
DISPLAY3D_FLG
aItem
)
const
bool
EDA_3D_CANVAS
::
isEnabled
(
DISPLAY3D_FLG
aItem
)
const
{
{
return
g_Parm_3D_Visu
.
GetFlag
(
aItem
);
return
GetPrm3DVisu
()
.
GetFlag
(
aItem
);
}
}
// Helper function: initialize the copper color to draw the board
// Helper function: initialize the copper color to draw the board
// in realistic mode.
// in realistic mode.
void
EDA_3D_CANVAS
::
S
etGLCopperColor
()
void
EDA_3D_CANVAS
::
s
etGLCopperColor
()
{
{
glDisable
(
GL_TEXTURE_2D
);
glDisable
(
GL_TEXTURE_2D
);
glColor4f
(
g_Parm_3D_Visu
.
m_CopperColor
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_CopperColor
,
1.0
);
g_Parm_3D_Visu
.
m_CopperColor
.
m_Green
,
g_Parm_3D_Visu
.
m_CopperColor
.
m_Blue
,
1.0
);
}
}
// Helper function: initialize the color to draw the epoxy
// Helper function: initialize the color to draw the epoxy
// body board in realistic mode.
// body board in realistic mode.
void
EDA_3D_CANVAS
::
S
etGLEpoxyColor
(
double
aTransparency
)
void
EDA_3D_CANVAS
::
s
etGLEpoxyColor
(
double
aTransparency
)
{
{
// Generates an epoxy color, near board color
// Generates an epoxy color, near board color
glColor4f
(
g_Parm_3D_Visu
.
m_BoardBodyColor
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_BoardBodyColor
,
aTransparency
);
g_Parm_3D_Visu
.
m_BoardBodyColor
.
m_Green
,
g_Parm_3D_Visu
.
m_BoardBodyColor
.
m_Blue
,
aTransparency
);
if
(
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_TEXTURES
)
)
if
(
isEnabled
(
FL_RENDER_TEXTURES
)
)
{
{
SetGLTexture
(
m_text_pcb
,
TEXTURE_PCB_SCALE
);
SetGLTexture
(
m_text_pcb
,
TEXTURE_PCB_SCALE
);
}
}
...
@@ -84,15 +97,12 @@ void EDA_3D_CANVAS::SetGLEpoxyColor( double aTransparency )
...
@@ -84,15 +97,12 @@ void EDA_3D_CANVAS::SetGLEpoxyColor( double aTransparency )
// Helper function: initialize the color to draw the
// Helper function: initialize the color to draw the
// solder mask layers in realistic mode.
// solder mask layers in realistic mode.
void
EDA_3D_CANVAS
::
S
etGLSolderMaskColor
(
double
aTransparency
)
void
EDA_3D_CANVAS
::
s
etGLSolderMaskColor
(
double
aTransparency
)
{
{
// Generates a solder mask color
// Generates a solder mask color
glColor4f
(
g_Parm_3D_Visu
.
m_SolderMaskColor
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_SolderMaskColor
,
aTransparency
);
g_Parm_3D_Visu
.
m_SolderMaskColor
.
m_Green
,
g_Parm_3D_Visu
.
m_SolderMaskColor
.
m_Blue
,
aTransparency
);
if
(
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_TEXTURES
)
)
if
(
isEnabled
(
FL_RENDER_TEXTURES
)
)
{
{
SetGLTexture
(
m_text_pcb
,
TEXTURE_PCB_SCALE
);
SetGLTexture
(
m_text_pcb
,
TEXTURE_PCB_SCALE
);
}
}
...
@@ -100,7 +110,7 @@ void EDA_3D_CANVAS::SetGLSolderMaskColor( double aTransparency )
...
@@ -100,7 +110,7 @@ void EDA_3D_CANVAS::SetGLSolderMaskColor( double aTransparency )
// Helper function: initialize the color to draw the non copper layers
// Helper function: initialize the color to draw the non copper layers
// in realistic mode and normal mode.
// in realistic mode and normal mode.
void
EDA_3D_CANVAS
::
S
etGLTechLayersColor
(
LAYER_NUM
aLayer
)
void
EDA_3D_CANVAS
::
s
etGLTechLayersColor
(
LAYER_NUM
aLayer
)
{
{
EDA_COLOR_T
color
;
EDA_COLOR_T
color
;
...
@@ -115,11 +125,9 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
...
@@ -115,11 +125,9 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
case
B_SilkS
:
case
B_SilkS
:
case
F_SilkS
:
case
F_SilkS
:
glColor4f
(
g_Parm_3D_Visu
.
m_SilkScreenColor
.
m_Red
,
SetGLColor
(
GetPrm3DVisu
().
m_SilkScreenColor
,
0.96
);
g_Parm_3D_Visu
.
m_SilkScreenColor
.
m_Green
,
g_Parm_3D_Visu
.
m_SilkScreenColor
.
m_Blue
,
0.96
);
if
(
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_TEXTURES
)
)
if
(
isEnabled
(
FL_RENDER_TEXTURES
)
)
{
{
SetGLTexture
(
m_text_silk
,
10.0
f
);
SetGLTexture
(
m_text_silk
,
10.0
f
);
}
}
...
@@ -128,7 +136,7 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
...
@@ -128,7 +136,7 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
case
B_Mask
:
case
B_Mask
:
case
F_Mask
:
case
F_Mask
:
S
etGLSolderMaskColor
(
0.90
);
s
etGLSolderMaskColor
(
0.90
);
break
;
break
;
default
:
default
:
...
@@ -175,13 +183,13 @@ void EDA_3D_CANVAS::Draw3DGrid( double aGriSizeMM )
...
@@ -175,13 +183,13 @@ void EDA_3D_CANVAS::Draw3DGrid( double aGriSizeMM )
double
zpos
=
0.0
;
double
zpos
=
0.0
;
EDA_COLOR_T
gridcolor
=
DARKGRAY
;
// Color of grid lines
EDA_COLOR_T
gridcolor
=
DARKGRAY
;
// Color of grid lines
EDA_COLOR_T
gridcolor_marker
=
LIGHTGRAY
;
// Color of grid lines every 5 lines
EDA_COLOR_T
gridcolor_marker
=
LIGHTGRAY
;
// Color of grid lines every 5 lines
const
double
scale
=
g_Parm_3D_Visu
.
m_BiuTo3Dunits
;
const
double
scale
=
GetPrm3DVisu
()
.
m_BiuTo3Dunits
;
const
double
transparency
=
0.3
;
const
double
transparency
=
0.3
;
glNormal3f
(
0.0
,
0.0
,
1.0
);
glNormal3f
(
0.0
,
0.0
,
1.0
);
wxSize
brd_size
=
g
_Parm_3D_Visu
.
m_BoardSize
;
wxSize
brd_size
=
g
etBoardSize
()
;
wxPoint
brd_center_pos
=
g
_Parm_3D_Visu
.
m_BoardPos
;
wxPoint
brd_center_pos
=
g
etBoardCenter
()
;
NEGATE
(
brd_center_pos
.
y
);
NEGATE
(
brd_center_pos
.
y
);
int
xsize
=
std
::
max
(
brd_size
.
x
,
Millimeter2iu
(
100
)
);
int
xsize
=
std
::
max
(
brd_size
.
x
,
Millimeter2iu
(
100
)
);
...
@@ -317,23 +325,23 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
...
@@ -317,23 +325,23 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
// Store here the points to approximate hole by segments
// Store here the points to approximate hole by segments
CPOLYGONS_LIST
holecornersBuffer
;
CPOLYGONS_LIST
holecornersBuffer
;
int
thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
int
height
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
F_Cu
)
-
int
height
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
F_Cu
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
);
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
);
if
(
isRealisticMode
()
)
if
(
isRealisticMode
()
)
S
etGLCopperColor
();
s
etGLCopperColor
();
else
else
SetGLColor
(
DARKGRAY
);
SetGLColor
(
DARKGRAY
);
int
holeZpoz
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
)
+
thickness
/
2
;
int
holeZpoz
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
)
+
thickness
/
2
;
int
holeHeight
=
height
-
thickness
;
int
holeHeight
=
height
-
thickness
;
if
(
drillsize
.
x
==
drillsize
.
y
)
// usual round hole
if
(
drillsize
.
x
==
drillsize
.
y
)
// usual round hole
{
{
Draw3D_ZaxisCylinder
(
aPad
->
GetPosition
(),
Draw3D_ZaxisCylinder
(
aPad
->
GetPosition
(),
(
drillsize
.
x
+
thickness
)
/
2
,
holeHeight
,
(
drillsize
.
x
+
thickness
)
/
2
,
holeHeight
,
thickness
,
holeZpoz
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
thickness
,
holeZpoz
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
}
else
// Oblong hole
else
// Oblong hole
{
{
...
@@ -359,7 +367,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
...
@@ -359,7 +367,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
// Draw the hole
// Draw the hole
Draw3D_ZaxisOblongCylinder
(
start
,
end
,
hole_radius
,
holeHeight
,
Draw3D_ZaxisOblongCylinder
(
start
,
end
,
hole_radius
,
holeHeight
,
thickness
,
holeZpoz
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
thickness
,
holeZpoz
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
}
}
}
...
@@ -368,25 +376,25 @@ void EDA_3D_CANVAS::Draw3DViaHole( const VIA* aVia )
...
@@ -368,25 +376,25 @@ void EDA_3D_CANVAS::Draw3DViaHole( const VIA* aVia )
{
{
LAYER_ID
top_layer
,
bottom_layer
;
LAYER_ID
top_layer
,
bottom_layer
;
int
inner_radius
=
aVia
->
GetDrillValue
()
/
2
;
int
inner_radius
=
aVia
->
GetDrillValue
()
/
2
;
int
thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
aVia
->
LayerPair
(
&
top_layer
,
&
bottom_layer
);
aVia
->
LayerPair
(
&
top_layer
,
&
bottom_layer
);
// Drawing via hole:
// Drawing via hole:
if
(
isRealisticMode
()
)
if
(
isRealisticMode
()
)
S
etGLCopperColor
();
s
etGLCopperColor
();
else
else
{
{
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetItemColor
(
VIAS_VISIBLE
+
aVia
->
GetViaType
()
);
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetItemColor
(
VIAS_VISIBLE
+
aVia
->
GetViaType
()
);
SetGLColor
(
color
);
SetGLColor
(
color
);
}
}
int
height
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
top_layer
)
-
int
height
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
top_layer
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
bottom_layer
)
-
thickness
;
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
bottom_layer
)
-
thickness
;
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
bottom_layer
)
+
thickness
/
2
;
int
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
bottom_layer
)
+
thickness
/
2
;
Draw3D_ZaxisCylinder
(
aVia
->
GetStart
(),
inner_radius
+
thickness
/
2
,
height
,
Draw3D_ZaxisCylinder
(
aVia
->
GetStart
(),
inner_radius
+
thickness
/
2
,
height
,
thickness
,
zpos
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
thickness
,
zpos
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
}
/* Build a pad outline as non filled polygon, to draw pads on silkscreen layer
/* Build a pad outline as non filled polygon, to draw pads on silkscreen layer
...
...
3d-viewer/textures/text_pcb.
c
→
3d-viewer/textures/text_pcb.
h
View file @
5e032ef0
File moved
3d-viewer/textures/text_silk.
c
→
3d-viewer/textures/text_silk.
h
View file @
5e032ef0
File moved
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