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
20acc9a9
Commit
20acc9a9
authored
Aug 27, 2012
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3D viewer: fix a very minor issue, and more code cleaning.
parent
55429109
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
346 deletions
+187
-346
3d_draw.cpp
3d-viewer/3d_draw.cpp
+39
-55
3d_draw_basic_functions.cpp
3d-viewer/3d_draw_basic_functions.cpp
+109
-269
3d_draw_basic_functions.h
3d-viewer/3d_draw_basic_functions.h
+2
-18
info3d_visu.h
3d-viewer/info3d_visu.h
+37
-4
No files found.
3d-viewer/3d_draw.cpp
View file @
20acc9a9
...
@@ -236,9 +236,7 @@ void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
...
@@ -236,9 +236,7 @@ void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
{
{
int
layer
=
aZone
->
GetLayer
();
int
layer
=
aZone
->
GetLayer
();
int
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
thickness
=
layer
>=
FIRST_NO_COPPER_LAYER
?
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
if
(
layer
==
LAST_COPPER_LAYER
)
if
(
layer
==
LAST_COPPER_LAYER
)
layer
=
g_Parm_3D_Visu
.
m_CopperLayersCount
-
1
;
layer
=
g_Parm_3D_Visu
.
m_CopperLayersCount
-
1
;
...
@@ -532,9 +530,7 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
...
@@ -532,9 +530,7 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
{
{
int
layer
=
segment
->
GetLayer
();
int
layer
=
segment
->
GetLayer
();
int
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
color
=
g_ColorsSettings
.
GetLayerColor
(
layer
);
int
thickness
=
layer
>=
FIRST_NO_COPPER_LAYER
?
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
SetGLColor
(
color
);
SetGLColor
(
color
);
...
@@ -633,9 +629,7 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
...
@@ -633,9 +629,7 @@ void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
s_Text3DWidth
=
text
->
GetThickness
();
s_Text3DWidth
=
text
->
GetThickness
();
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
glNormal3f
(
0.0
,
0.0
,
Get3DLayer_Z_Orientation
(
layer
)
);
wxSize
size
=
text
->
m_Size
;
wxSize
size
=
text
->
m_Size
;
s_thickness
=
layer
>=
FIRST_NO_COPPER_LAYER
?
s_thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
layer
);
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
if
(
text
->
m_Mirror
)
if
(
text
->
m_Mirror
)
NEGATE
(
size
.
x
);
NEGATE
(
size
.
x
);
...
@@ -752,15 +746,41 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
...
@@ -752,15 +746,41 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
int
color
=
g_ColorsSettings
.
GetLayerColor
(
m_Layer
);
int
color
=
g_ColorsSettings
.
GetLayerColor
(
m_Layer
);
SetGLColor
(
color
);
SetGLColor
(
color
);
// for outline shape = S_POLYGON:
// We must compute true coordinates from m_PolyPoints
// which are relative to module position and module orientation = 0
std
::
vector
<
CPolyPt
>
polycorners
;
if
(
m_Shape
==
S_POLYGON
)
{
polycorners
.
reserve
(
m_PolyPoints
.
size
()
);
MODULE
*
module
=
(
MODULE
*
)
m_Parent
;
CPolyPt
corner
;
for
(
unsigned
ii
=
0
;
ii
<
m_PolyPoints
.
size
();
ii
++
)
{
corner
.
x
=
m_PolyPoints
[
ii
].
x
;
corner
.
y
=
m_PolyPoints
[
ii
].
y
;
RotatePoint
(
&
corner
.
x
,
&
corner
.
y
,
module
->
GetOrientation
()
);
if
(
module
)
{
corner
.
x
+=
module
->
m_Pos
.
x
;
corner
.
y
+=
module
->
m_Pos
.
y
;
}
polycorners
.
push_back
(
corner
);
}
polycorners
.
back
().
end_contour
=
true
;
}
if
(
m_Layer
==
EDGE_N
)
if
(
m_Layer
==
EDGE_N
)
{
{
for
(
int
layer
=
0
;
layer
<
g_Parm_3D_Visu
.
m_CopperLayersCount
;
layer
++
)
for
(
int
layer
=
0
;
layer
<
g_Parm_3D_Visu
.
m_CopperLayersCount
;
layer
++
)
{
{
glNormal3f
(
0.0
,
0.0
,
(
layer
==
LAYER_N_BACK
)
?
-
1.0
:
1.0
);
glNormal3f
(
0.0
,
0.0
,
(
layer
==
LAYER_N_BACK
)
?
-
1.0
:
1.0
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
layer
);
int
thickness
=
m_Layer
>=
FIRST_NO_COPPER_LAYER
?
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
m_Layer
);
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
switch
(
m_Shape
)
switch
(
m_Shape
)
{
{
...
@@ -788,25 +808,8 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
...
@@ -788,25 +808,8 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
break
;
break
;
case
S_POLYGON
:
case
S_POLYGON
:
{
Draw3D_SolidHorizontalPolyPolygons
(
polycorners
,
zpos
,
thickness
,
// We must compute true coordinates from m_PolyPoints
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
// which are relative to module position and module orientation = 0
std
::
vector
<
wxPoint
>
points
=
m_PolyPoints
;
MODULE
*
module
=
(
MODULE
*
)
m_Parent
;
if
(
module
==
NULL
)
break
;
for
(
unsigned
ii
=
0
;
ii
<
points
.
size
();
ii
++
)
{
wxPoint
&
pt
=
points
[
ii
];
RotatePoint
(
&
pt
.
x
,
&
pt
.
y
,
module
->
GetOrientation
()
);
pt
+=
module
->
m_Pos
;
}
Draw3D_HorizontalPolygon
(
points
,
zpos
,
0
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
break
;
break
;
default
:
default
:
...
@@ -817,9 +820,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
...
@@ -817,9 +820,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
}
}
else
else
{
{
int
thickness
=
m_Layer
>=
FIRST_NO_COPPER_LAYER
?
int
thickness
=
g_Parm_3D_Visu
.
GetLayerObjectThicknessBIU
(
m_Layer
);
g_Parm_3D_Visu
.
GetNonCopperLayerThicknessBIU
()
:
g_Parm_3D_Visu
.
GetCopperThicknessBIU
();
glNormal3f
(
0.0
,
0.0
,
(
m_Layer
==
LAYER_N_BACK
)
?
-
1.0
:
1.0
);
glNormal3f
(
0.0
,
0.0
,
(
m_Layer
==
LAYER_N_BACK
)
?
-
1.0
:
1.0
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
m_Layer
);
int
zpos
=
g_Parm_3D_Visu
.
GetLayerZcoordBIU
(
m_Layer
);
...
@@ -849,25 +850,8 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
...
@@ -849,25 +850,8 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
break
;
break
;
case
S_POLYGON
:
case
S_POLYGON
:
{
Draw3D_SolidHorizontalPolyPolygons
(
polycorners
,
zpos
,
thickness
,
// We must compute true coordinates from m_PolyPoints
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
// which are relative to module position and module orientation = 0
std
::
vector
<
wxPoint
>
points
=
m_PolyPoints
;
MODULE
*
module
=
(
MODULE
*
)
m_Parent
;
if
(
module
==
NULL
)
break
;
for
(
unsigned
ii
=
0
;
ii
<
points
.
size
();
ii
++
)
{
wxPoint
&
pt
=
points
[
ii
];
RotatePoint
(
&
pt
.
x
,
&
pt
.
y
,
module
->
GetOrientation
()
);
pt
+=
module
->
m_Pos
;
}
Draw3D_HorizontalPolygon
(
points
,
zpos
,
0
,
g_Parm_3D_Visu
.
m_BiuTo3Dunits
);
}
break
;
break
;
default
:
default
:
...
...
3d-viewer/3d_draw_basic_functions.cpp
View file @
20acc9a9
This diff is collapsed.
Click to expand it.
3d-viewer/3d_draw_basic_functions.h
View file @
20acc9a9
...
@@ -31,22 +31,6 @@
...
@@ -31,22 +31,6 @@
// angle increment to draw a circle, approximated by segments
// angle increment to draw a circle, approximated by segments
#define ANGLE_INC( x ) ( 3600 / (x) )
#define ANGLE_INC( x ) ( 3600 / (x) )
/**
* Function Draw3D_HorizontalPolygon
* draw one solid polygon
* @param aCornersList = a std::vector<wxPoint> list of corners, in board internal units
* @param aZpos = z position in board internal units
* @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.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void
Draw3D_HorizontalPolygon
(
std
::
vector
<
wxPoint
>&
aCornersList
,
int
aZpos
,
int
aThickness
,
double
aBiuTo3DUnits
);
/** draw all solid polygons found in aPolysList
/** draw all solid polygons found in aPolysList
* @param aPolysList = the poligon list to draw
* @param aPolysList = the poligon list to draw
* @param aZpos = z position in board internal units
* @param aZpos = z position in board internal units
...
@@ -67,7 +51,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi
...
@@ -67,7 +51,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysLi
* @param aThickness = thickness in board internal units
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* @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 = 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 top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
*/
...
@@ -82,7 +66,7 @@ void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPol
...
@@ -82,7 +66,7 @@ void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPol
* @param aZpos = z position of segment in board units
* @param aZpos = z position of segment in board units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* @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 = 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 top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
*/
...
...
3d-viewer/info3d_visu.h
View file @
20acc9a9
...
@@ -109,15 +109,23 @@ public: INFO3D_VISU();
...
@@ -109,15 +109,23 @@ public: INFO3D_VISU();
void
InitSettings
(
BOARD
*
aBoard
);
void
InitSettings
(
BOARD
*
aBoard
);
/**
/**
* function
m_BiuTo3Dunits
* function
GetLayerZcoordBIU
* @return the Z coordinate of the layer aLayer, in Board Internal Units
* @return the Z coordinate of the layer aLayer, in Board Internal Units
* @param aLayer: the layer number
* @param aLayer
Id
: the layer number
*/
*/
int
GetLayerZcoordBIU
(
int
aLayer
)
int
GetLayerZcoordBIU
(
int
aLayer
Id
)
{
{
return
(
int
)
(
m_LayerZcoord
[
aLayer
]
/
m_BiuTo3Dunits
);
return
(
int
)
(
m_LayerZcoord
[
aLayer
Id
]
/
m_BiuTo3Dunits
);
}
}
/**
* function GetCopperThicknessBIU
* @return the thickness (Z size) of the copper, in Board Internal Units
* 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
*/
int
GetCopperThicknessBIU
()
const
int
GetCopperThicknessBIU
()
const
{
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
...
@@ -125,17 +133,42 @@ public: INFO3D_VISU();
...
@@ -125,17 +133,42 @@ public: INFO3D_VISU();
:
0
;
:
0
;
}
}
/**
* function GetEpoxyThicknessBIU
* @return the thickness (Z size) of the epoxy board, in Board Internal Units
*/
int
GetEpoxyThicknessBIU
()
const
int
GetEpoxyThicknessBIU
()
const
{
{
return
(
int
)
(
m_EpoxyThickness
/
m_BiuTo3Dunits
);
return
(
int
)
(
m_EpoxyThickness
/
m_BiuTo3Dunits
);
}
}
/**
* function GetNonCopperLayerThicknessBIU
* @return the thickness (Z size) of a technical layer,
* in Board Internal Units
*
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int
GetNonCopperLayerThicknessBIU
()
const
int
GetNonCopperLayerThicknessBIU
()
const
{
{
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
return
m_DrawFlags
[
FL_USE_COPPER_THICKNESS
]
?
(
int
)
(
m_NonCopperLayerThickness
/
m_BiuTo3Dunits
)
(
int
)
(
m_NonCopperLayerThickness
/
m_BiuTo3Dunits
)
:
0
;
:
0
;
}
}
/**
* function GetNonCopperLayerThicknessBIU
* @return the thickness (Z size) of the copper or a technical layer,
* in Board Internal Units, depending on the layer id
*
* Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int
GetLayerObjectThicknessBIU
(
int
aLayerId
)
const
{
return
aLayerId
>=
FIRST_NO_COPPER_LAYER
?
GetNonCopperLayerThicknessBIU
()
:
GetCopperThicknessBIU
();
}
};
};
extern
INFO3D_VISU
g_Parm_3D_Visu
;
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