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
Expand all
Hide 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
*/
...
...
@@ -26,8 +49,8 @@
#include <trackball.h>
#include <3d_viewer_id.h>
#include <textures/text_silk.
c
>
#include <textures/text_pcb.
c
>
#include <textures/text_silk.
h
>
#include <textures/text_pcb.
h
>
// -----------------
// helper function (from wxWidgets, opengl/cube.cpp sample
...
...
3d-viewer/3d_canvas.h
View file @
5e032ef0
...
...
@@ -142,48 +142,62 @@ public:
m_draw3dOffset
.
y
=
aPosY
;
}
INFO3D_VISU
&
GetPrm3DVisu
()
const
;
private
:
/**
* return true if we are in realistic mode render
*/
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
*/
bool
isEnabled
(
DISPLAY3D_FLG
aItem
)
const
;
/* Helper function
/*
*
Helper function
* @return true if aLayer should be displayed, false otherwise
*/
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
* Initialize the color to draw the non copper layers
* in realistic mode and normal mode.
*/
void
S
etGLTechLayersColor
(
LAYER_NUM
aLayer
);
void
s
etGLTechLayersColor
(
LAYER_NUM
aLayer
);
/**
* Helper function SetGLCopperColor
* Initialize the copper color to draw the board
* in realistic mode (a golden yellow color )
*/
void
S
etGLCopperColor
();
void
s
etGLCopperColor
();
/**
* Helper function SetGLEpoxyColor
* 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
* 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
...
...
3d-viewer/3d_draw.cpp
View file @
5e032ef0
This diff is collapsed.
Click to expand it.
3d-viewer/3d_draw_basic_functions.cpp
View file @
5e032ef0
...
...
@@ -130,6 +130,13 @@ void SetGLColor( EDA_COLOR_T color, double 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
;
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,
*/
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
...
...
3d-viewer/3d_draw_helper_functions.cpp
View file @
5e032ef0
...
...
@@ -42,41 +42,54 @@
#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
bool
EDA_3D_CANVAS
::
isRealisticMode
()
const
{
return
g_Parm_3D_Visu
.
IsRealisticMode
();
return
GetPrm3DVisu
()
.
IsRealisticMode
();
}
// return true if aItem should be displayed
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
// in realistic mode.
void
EDA_3D_CANVAS
::
S
etGLCopperColor
()
void
EDA_3D_CANVAS
::
s
etGLCopperColor
()
{
glDisable
(
GL_TEXTURE_2D
);
glColor4f
(
g_Parm_3D_Visu
.
m_CopperColor
.
m_Red
,
g_Parm_3D_Visu
.
m_CopperColor
.
m_Green
,
g_Parm_3D_Visu
.
m_CopperColor
.
m_Blue
,
1.0
);
SetGLColor
(
GetPrm3DVisu
().
m_CopperColor
,
1.0
);
}
// Helper function: initialize the color to draw the epoxy
// 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
glColor4f
(
g_Parm_3D_Visu
.
m_BoardBodyColor
.
m_Red
,
g_Parm_3D_Visu
.
m_BoardBodyColor
.
m_Green
,
g_Parm_3D_Visu
.
m_BoardBodyColor
.
m_Blue
,
aTransparency
);
SetGLColor
(
GetPrm3DVisu
().
m_BoardBodyColor
,
aTransparency
);
if
(
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_TEXTURES
)
)
if
(
isEnabled
(
FL_RENDER_TEXTURES
)
)
{
SetGLTexture
(
m_text_pcb
,
TEXTURE_PCB_SCALE
);
}
...
...
@@ -84,15 +97,12 @@ void EDA_3D_CANVAS::SetGLEpoxyColor( double aTransparency )
// Helper function: initialize the color to draw the
// 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
glColor4f
(
g_Parm_3D_Visu
.
m_SolderMaskColor
.
m_Red
,
g_Parm_3D_Visu
.
m_SolderMaskColor
.
m_Green
,
g_Parm_3D_Visu
.
m_SolderMaskColor
.
m_Blue
,
aTransparency
);
SetGLColor
(
GetPrm3DVisu
().
m_SolderMaskColor
,
aTransparency
);
if
(
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_TEXTURES
)
)
if
(
isEnabled
(
FL_RENDER_TEXTURES
)
)
{
SetGLTexture
(
m_text_pcb
,
TEXTURE_PCB_SCALE
);
}
...
...
@@ -100,7 +110,7 @@ void EDA_3D_CANVAS::SetGLSolderMaskColor( double aTransparency )
// Helper function: initialize the color to draw the non copper layers
// 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
;
...
...
@@ -115,11 +125,9 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
case
B_SilkS
:
case
F_SilkS
:
glColor4f
(
g_Parm_3D_Visu
.
m_SilkScreenColor
.
m_Red
,
g_Parm_3D_Visu
.
m_SilkScreenColor
.
m_Green
,
g_Parm_3D_Visu
.
m_SilkScreenColor
.
m_Blue
,
0.96
);
SetGLColor
(
GetPrm3DVisu
().
m_SilkScreenColor
,
0.96
);
if
(
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_TEXTURES
)
)
if
(
isEnabled
(
FL_RENDER_TEXTURES
)
)
{
SetGLTexture
(
m_text_silk
,
10.0
f
);
}
...
...
@@ -128,7 +136,7 @@ void EDA_3D_CANVAS::SetGLTechLayersColor( LAYER_NUM aLayer )
case
B_Mask
:
case
F_Mask
:
S
etGLSolderMaskColor
(
0.90
);
s
etGLSolderMaskColor
(
0.90
);
break
;
default
:
...
...
@@ -175,13 +183,13 @@ void EDA_3D_CANVAS::Draw3DGrid( double aGriSizeMM )
double
zpos
=
0.0
;
EDA_COLOR_T
gridcolor
=
DARKGRAY
;
// Color of grid 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
;
glNormal3f
(
0.0
,
0.0
,
1.0
);
wxSize
brd_size
=
g
_Parm_3D_Visu
.
m_BoardSize
;
wxPoint
brd_center_pos
=
g
_Parm_3D_Visu
.
m_BoardPos
;
wxSize
brd_size
=
g
etBoardSize
()
;
wxPoint
brd_center_pos
=
g
etBoardCenter
()
;
NEGATE
(
brd_center_pos
.
y
);
int
xsize
=
std
::
max
(
brd_size
.
x
,
Millimeter2iu
(
100
)
);
...
...
@@ -317,23 +325,23 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
// Store here the points to approximate hole by segments
CPOLYGONS_LIST
holecornersBuffer
;
int
thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
height
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
F_Cu
)
-
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
B_Cu
);
int
thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
int
height
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
F_Cu
)
-
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
B_Cu
);
if
(
isRealisticMode
()
)
S
etGLCopperColor
();
s
etGLCopperColor
();
else
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
;
if
(
drillsize
.
x
==
drillsize
.
y
)
// usual round hole
{
Draw3D_ZaxisCylinder
(
aPad
->
GetPosition
(),
(
drillsize
.
x
+
thickness
)
/
2
,
holeHeight
,
thickness
,
holeZpoz
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
thickness
,
holeZpoz
,
GetPrm3DVisu
()
.
m_BiuTo3Dunits
);
}
else
// Oblong hole
{
...
...
@@ -359,7 +367,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
// Draw the hole
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 )
{
LAYER_ID
top_layer
,
bottom_layer
;
int
inner_radius
=
aVia
->
GetDrillValue
()
/
2
;
int
thickness
=
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
int
thickness
=
GetPrm3DVisu
()
.
GetCopperThicknessBIU
();
aVia
->
LayerPair
(
&
top_layer
,
&
bottom_layer
);
// Drawing via hole:
if
(
isRealisticMode
()
)
S
etGLCopperColor
();
s
etGLCopperColor
();
else
{
EDA_COLOR_T
color
=
g_ColorsSettings
.
GetItemColor
(
VIAS_VISIBLE
+
aVia
->
GetViaType
()
);
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
;
int
height
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
top_layer
)
-
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
bottom_layer
)
-
thickness
;
int
zpos
=
GetPrm3DVisu
()
.
GetLayerZcoordBIU
(
bottom_layer
)
+
thickness
/
2
;
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
...
...
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