KiCad PCB EDA Suite
RENDER_3D_OPENGL Class Reference

Object to render the board using openGL. More...

#include <render_3d_opengl.h>

Inheritance diagram for RENDER_3D_OPENGL:
RENDER_3D_BASE

Public Member Functions

 RENDER_3D_OPENGL (EDA_3D_CANVAS *aCanvas, BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
 
 ~RENDER_3D_OPENGL ()
 
void SetCurWindowSize (const wxSize &aSize) override
 Before each render, the canvas will tell the render what is the size of its windows, so render can take actions if it changed. More...
 
bool Redraw (bool aIsMoving, REPORTER *aStatusReporter, REPORTER *aWarningReporter) override
 Redraw the view. More...
 
int GetWaitForEditingTimeOut () override
 Give the interface the time (in ms) that it should wait for editing or movements before (this works for display preview mode). More...
 
void SetCurrentRollOverItem (BOARD_ITEM *aRollOverItem)
 
void Load3dModelsIfNeeded ()
 Load footprint models if they are not already loaded, i.e. More...
 
void ReloadRequest ()
 
bool IsReloadRequestPending () const
 Query if there is a pending reload request. More...
 
void SetBusyIndicatorFactory (BUSY_INDICATOR::FACTORY aNewFactory)
 Set a new busy indicator factory. More...
 

Protected Member Functions

std::unique_ptr< BUSY_INDICATORCreateBusyIndicator () const
 Return a created busy indicator, if a factory has been set, else a null pointer. More...
 

Protected Attributes

EDA_3D_CANVASm_canvas
 Settings reference in use for this render. More...
 
BOARD_ADAPTERm_boardAdapter
 
CAMERAm_camera
 Flag if the opengl specific for this render was already initialized. More...
 
bool m_is_opengl_initialized
 
bool m_reloadRequested
 The window size that this camera is working. More...
 
wxSize m_windowSize
 

Static Protected Attributes

static const wxChar * m_logTrace = wxT( "KI_TRACE_3D_RENDER" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Private Member Functions

OPENGL_RENDER_LISTgenerateHoles (const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
 
OPENGL_RENDER_LISTgenerateLayerList (const BVH_CONTAINER_2D *aContainer, const SHAPE_POLY_SET *aPolyList, PCB_LAYER_ID aLayerId, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
 
OPENGL_RENDER_LISTgenerateEmptyLayerList (PCB_LAYER_ID aLayerId)
 
void addTopAndBottomTriangles (TRIANGLE_DISPLAY_LIST *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
 
void addObjectTriangles (const RING_2D *aRing, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
 
void addObjectTriangles (const POLYGON_4PT_2D *aPoly, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
 
void addObjectTriangles (const FILLED_CIRCLE_2D *aFilledCircle, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
 
void addObjectTriangles (const TRIANGLE_2D *aTri, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
 
void addObjectTriangles (const ROUND_SEGMENT_2D *aSeg, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
 
void renderSolderMaskLayer (PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
 
void renderBoardBody (bool aSkipRenderHoles)
 
void getLayerZPos (PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
 
void generateRing (const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, bool aInvertOrder)
 
void generateCylinder (const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST *aDstLayer)
 
void generateViasAndPads ()
 
void load3dModels (REPORTER *aStatusReporter)
 Load footprint models from the cache and load it to openGL lists in the form of MODEL_3D objects. More...
 
void render3dModels (bool aRenderTopOrBot, bool aRenderTransparentOnly)
 
void render3dModelsSelected (bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)
 
void renderFootprint (const FOOTPRINT *aFootprint, bool aRenderTransparentOnly, bool aIsSelected)
 
void setLightFront (bool enabled)
 
void setLightTop (bool enabled)
 
void setLightBottom (bool enabled)
 
void render3dArrows ()
 
void generate3dGrid (GRID3D_TYPE aGridType)
 Create a 3D grid to an OpenGL display list. More...
 
void setupMaterials ()
 
void setCopperMaterial ()
 
void setPlatedCopperAndDepthOffset (PCB_LAYER_ID aLayer_id)
 
void unsetDepthOffset ()
 
void setLayerMaterial (PCB_LAYER_ID aLayerID)
 
SFVEC4F getLayerColor (PCB_LAYER_ID aLayerID)
 
bool initializeOpenGL ()
 
OPENGL_RENDER_LISTcreateBoard (const SHAPE_POLY_SET &aBoardPoly, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
 
void reload (REPORTER *aStatusReporter, REPORTER *aWarningReporter)
 
void setArrowMaterial ()
 
void freeAllLists ()
 

Private Attributes

struct {
   SMATERIAL   m_Paste
 
   SMATERIAL   m_SilkSBot
 
   SMATERIAL   m_SilkSTop
 
   SMATERIAL   m_SolderMask
 
   SMATERIAL   m_EpoxyBoard
 
   SMATERIAL   m_NonPlatedCopper
 
   SMATERIAL   m_Copper
 
   SMATERIAL   m_Plastic
 
   SMATERIAL   m_GrayMaterial
 
m_materials
 
MAP_OGL_DISP_LISTS m_layers
 
OPENGL_RENDER_LISTm_platedPadsFront
 
OPENGL_RENDER_LISTm_platedPadsBack
 
MAP_OGL_DISP_LISTS m_outerLayerHoles
 
MAP_OGL_DISP_LISTS m_innerLayerHoles
 
OPENGL_RENDER_LISTm_board
 
OPENGL_RENDER_LISTm_boardWithHoles
 
OPENGL_RENDER_LISTm_antiBoard
 
OPENGL_RENDER_LISTm_outerThroughHoles
 
OPENGL_RENDER_LISTm_outerViaThroughHoles
 
OPENGL_RENDER_LISTm_outerThroughHoleRings
 
LIST_TRIANGLES m_triangles
 store pointers so can be deleted latter More...
 
GLuint m_circleTexture
 
GLuint m_grid
 oGL list that stores current grid More...
 
GRID3D_TYPE m_lastGridType
 Stores the last grid type. More...
 
OPENGL_RENDER_LISTm_vias
 
OPENGL_RENDER_LISTm_padHoles
 
std::map< wxString, MODEL_3D * > m_3dModelMap
 
std::map< std::vector< double >, glm::mat4 > m_3dModelMatrixMap
 
BOARD_ITEMm_currentRollOverItem
 
SHAPE_POLY_SET m_antiBoardPolys
 The negative polygon representation of the board outline. More...
 
BUSY_INDICATOR::FACTORY m_busyIndicatorFactory
 < Factory that returns a suitable busy indicator for the context. More...
 

Detailed Description

Object to render the board using openGL.

Definition at line 52 of file render_3d_opengl.h.

Constructor & Destructor Documentation

◆ RENDER_3D_OPENGL()

RENDER_3D_OPENGL::RENDER_3D_OPENGL ( EDA_3D_CANVAS aCanvas,
BOARD_ADAPTER aAdapter,
CAMERA aCamera 
)
explicit

Definition at line 42 of file render_3d_opengl.cpp.

43 :
44 RENDER_3D_BASE( aCanvas, aAdapter, aCamera )
45{
46 wxLogTrace( m_logTrace, wxT( "RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
47
48 m_layers.clear();
49 m_outerLayerHoles.clear();
50 m_innerLayerHoles.clear();
51 m_triangles.clear();
52 m_board = nullptr;
53 m_antiBoard = nullptr;
54
55 m_platedPadsFront = nullptr;
56 m_platedPadsBack = nullptr;
57
58 m_outerThroughHoles = nullptr;
60 m_outerViaThroughHoles = nullptr;
61 m_vias = nullptr;
62 m_padHoles = nullptr;
63
65 m_grid = 0;
67 m_currentRollOverItem = nullptr;
68 m_boardWithHoles = nullptr;
69
70 m_3dModelMap.clear();
71}
RENDER_3D_BASE(EDA_3D_CANVAS *aCanvas, BOARD_ADAPTER &aBoardAdapter, CAMERA &aCamera)
OPENGL_RENDER_LIST * m_board
OPENGL_RENDER_LIST * m_vias
OPENGL_RENDER_LIST * m_outerThroughHoleRings
GRID3D_TYPE m_lastGridType
Stores the last grid type.
MAP_OGL_DISP_LISTS m_layers
MAP_OGL_DISP_LISTS m_innerLayerHoles
OPENGL_RENDER_LIST * m_boardWithHoles
MAP_OGL_DISP_LISTS m_outerLayerHoles
BOARD_ITEM * m_currentRollOverItem
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
OPENGL_RENDER_LIST * m_outerViaThroughHoles
OPENGL_RENDER_LIST * m_outerThroughHoles
std::map< wxString, MODEL_3D * > m_3dModelMap
OPENGL_RENDER_LIST * m_platedPadsFront
OPENGL_RENDER_LIST * m_antiBoard
OPENGL_RENDER_LIST * m_padHoles
GLuint m_grid
oGL list that stores current grid
OPENGL_RENDER_LIST * m_platedPadsBack
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.

References m_3dModelMap, m_antiBoard, m_board, m_boardWithHoles, m_circleTexture, m_currentRollOverItem, m_grid, m_innerLayerHoles, m_lastGridType, m_layers, RENDER_3D_BASE::m_logTrace, m_outerLayerHoles, m_outerThroughHoleRings, m_outerThroughHoles, m_outerViaThroughHoles, m_padHoles, m_platedPadsBack, m_platedPadsFront, m_triangles, m_vias, and NONE.

◆ ~RENDER_3D_OPENGL()

RENDER_3D_OPENGL::~RENDER_3D_OPENGL ( )

Definition at line 74 of file render_3d_opengl.cpp.

75{
76 wxLogTrace( m_logTrace, wxT( "RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
77
79
80 glDeleteTextures( 1, &m_circleTexture );
81}

References freeAllLists(), m_circleTexture, and RENDER_3D_BASE::m_logTrace.

Member Function Documentation

◆ addObjectTriangles() [1/5]

void RENDER_3D_OPENGL::addObjectTriangles ( const FILLED_CIRCLE_2D aFilledCircle,
TRIANGLE_DISPLAY_LIST aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 38 of file opengl/create_scene.cpp.

41{
42 const SFVEC2F& center = aFilledCircle->GetCenter();
43 const float radius = aFilledCircle->GetRadius() * 2.0f; // Double because the render triangle
44
45 // This is a small adjustment to the circle texture
46 const float texture_factor = ( 8.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
47 const float f = ( sqrtf( 2.0f ) / 2.0f ) * radius * texture_factor;
48
49 // Top and Bot segments ends are just triangle semi-circles, so need to add it in duplicated.
50 aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZtop ),
51 SFVEC3F( center.x - f, center.y, aZtop ),
52 SFVEC3F( center.x, center.y - f, aZtop ) );
53
54 aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZtop ),
55 SFVEC3F( center.x + f, center.y, aZtop ),
56 SFVEC3F( center.x, center.y + f, aZtop ) );
57
58 aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZbot ),
59 SFVEC3F( center.x + f, center.y, aZbot ),
60 SFVEC3F( center.x, center.y - f, aZbot ) );
61
62 aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZbot ),
63 SFVEC3F( center.x - f, center.y, aZbot ),
64 SFVEC3F( center.x, center.y + f, aZbot ) );
65}
const SFVEC2F & GetCenter() const
float GetRadius() const
TRIANGLE_LIST * m_layer_bot_segment_ends
TRIANGLE_LIST * m_layer_top_segment_ends
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
#define SIZE_OF_CIRCLE_TEXTURE
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44

References TRIANGLE_LIST::AddTriangle(), FILLED_CIRCLE_2D::GetCenter(), FILLED_CIRCLE_2D::GetRadius(), TRIANGLE_DISPLAY_LIST::m_layer_bot_segment_ends, TRIANGLE_DISPLAY_LIST::m_layer_top_segment_ends, and SIZE_OF_CIRCLE_TEXTURE.

◆ addObjectTriangles() [2/5]

void RENDER_3D_OPENGL::addObjectTriangles ( const POLYGON_4PT_2D aPoly,
TRIANGLE_DISPLAY_LIST aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 68 of file opengl/create_scene.cpp.

71{
72 const SFVEC2F& v0 = aPoly->GetV0();
73 const SFVEC2F& v1 = aPoly->GetV1();
74 const SFVEC2F& v2 = aPoly->GetV2();
75 const SFVEC2F& v3 = aPoly->GetV3();
76
77 addTopAndBottomTriangles( aDstLayer, v0, v2, v1, aZtop, aZbot );
78 addTopAndBottomTriangles( aDstLayer, v2, v0, v3, aZtop, aZbot );
79}
const SFVEC2F & GetV3() const
const SFVEC2F & GetV0() const
const SFVEC2F & GetV1() const
const SFVEC2F & GetV2() const
void addTopAndBottomTriangles(TRIANGLE_DISPLAY_LIST *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
VECTOR3I v1(5, 5, 5)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
VECTOR3I v3(1, 1, 1)

References addTopAndBottomTriangles(), POLYGON_4PT_2D::GetV0(), POLYGON_4PT_2D::GetV1(), POLYGON_4PT_2D::GetV2(), POLYGON_4PT_2D::GetV3(), v1, v2, and v3.

◆ addObjectTriangles() [3/5]

void RENDER_3D_OPENGL::addObjectTriangles ( const RING_2D aRing,
TRIANGLE_DISPLAY_LIST aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 116 of file opengl/create_scene.cpp.

118{
119 const SFVEC2F& center = aRing->GetCenter();
120 const float inner = aRing->GetInnerRadius();
121 const float outer = aRing->GetOuterRadius();
122
123 std::vector< SFVEC2F > innerContour;
124 std::vector< SFVEC2F > outerContour;
125
126 generateRing( center, inner, outer, m_boardAdapter.GetCircleSegmentCount( outer * 2.0f ),
127 innerContour, outerContour, false );
128
129 // This will add the top and bot quads that will form the approximated ring
130 for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
131 {
132 const SFVEC2F& vi0 = innerContour[i + 0];
133 const SFVEC2F& vi1 = innerContour[i + 1];
134 const SFVEC2F& vo0 = outerContour[i + 0];
135 const SFVEC2F& vo1 = outerContour[i + 1];
136
137 aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
138 SFVEC3F( vi0.x, vi0.y, aZtop ),
139 SFVEC3F( vo0.x, vo0.y, aZtop ),
140 SFVEC3F( vo1.x, vo1.y, aZtop ) );
141
142 aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
143 SFVEC3F( vo1.x, vo1.y, aZbot ),
144 SFVEC3F( vo0.x, vo0.y, aZbot ),
145 SFVEC3F( vi0.x, vi0.y, aZbot ) );
146 }
147}
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
BOARD_ADAPTER & m_boardAdapter
void generateRing(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, bool aInvertOrder)
float GetOuterRadius() const
Definition: ring_2d.h:48
float GetInnerRadius() const
Definition: ring_2d.h:47
const SFVEC2F & GetCenter() const
Definition: ring_2d.h:46
TRIANGLE_LIST * m_layer_bot_triangles
TRIANGLE_LIST * m_layer_top_triangles
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)

References TRIANGLE_LIST::AddQuad(), generateRing(), RING_2D::GetCenter(), BOARD_ADAPTER::GetCircleSegmentCount(), RING_2D::GetInnerRadius(), RING_2D::GetOuterRadius(), RENDER_3D_BASE::m_boardAdapter, TRIANGLE_DISPLAY_LIST::m_layer_bot_triangles, and TRIANGLE_DISPLAY_LIST::m_layer_top_triangles.

Referenced by generateHoles(), and generateLayerList().

◆ addObjectTriangles() [4/5]

void RENDER_3D_OPENGL::addObjectTriangles ( const ROUND_SEGMENT_2D aSeg,
TRIANGLE_DISPLAY_LIST aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 162 of file opengl/create_scene.cpp.

165{
166 const SFVEC2F& leftStart = aSeg->GetLeftStar();
167 const SFVEC2F& leftEnd = aSeg->GetLeftEnd();
168 const SFVEC2F& leftDir = aSeg->GetLeftDir();
169
170 const SFVEC2F& rightStart = aSeg->GetRightStar();
171 const SFVEC2F& rightEnd = aSeg->GetRightEnd();
172 const SFVEC2F& rightDir = aSeg->GetRightDir();
173 const float radius = aSeg->GetRadius();
174
175 const SFVEC2F& start = aSeg->GetStart();
176 const SFVEC2F& end = aSeg->GetEnd();
177
178 const float texture_factor = ( 12.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
179 const float texture_factorF = ( 6.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
180
181 const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f );
182 const float radius_triangle_factor = ( radius_of_the_square - radius ) / radius;
183
184 const SFVEC2F factorS = SFVEC2F( -rightDir.y * radius * radius_triangle_factor,
185 rightDir.x * radius * radius_triangle_factor );
186
187 const SFVEC2F factorE = SFVEC2F( -leftDir.y * radius * radius_triangle_factor,
188 leftDir.x * radius * radius_triangle_factor );
189
190 // Top end segment triangles (semi-circles)
192 SFVEC3F( rightEnd.x + texture_factor * factorS.x,
193 rightEnd.y + texture_factor * factorS.y,
194 aZtop ),
195 SFVEC3F( leftStart.x + texture_factor * factorE.x,
196 leftStart.y + texture_factor * factorE.y,
197 aZtop ),
198 SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
199 start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
200 aZtop ) );
201
203 SFVEC3F( leftEnd.x + texture_factor * factorE.x,
204 leftEnd.y + texture_factor * factorE.y, aZtop ),
205 SFVEC3F( rightStart.x + texture_factor * factorS.x,
206 rightStart.y + texture_factor * factorS.y, aZtop ),
207 SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
208 end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
209 aZtop ) );
210
211 // Bot end segment triangles (semi-circles)
213 SFVEC3F( leftStart.x + texture_factor * factorE.x,
214 leftStart.y + texture_factor * factorE.y,
215 aZbot ),
216 SFVEC3F( rightEnd.x + texture_factor * factorS.x,
217 rightEnd.y + texture_factor * factorS.y,
218 aZbot ),
219 SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
220 start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
221 aZbot ) );
222
224 SFVEC3F( rightStart.x + texture_factor * factorS.x,
225 rightStart.y + texture_factor * factorS.y, aZbot ),
226 SFVEC3F( leftEnd.x + texture_factor * factorE.x,
227 leftEnd.y + texture_factor * factorE.y, aZbot ),
228 SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
229 end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
230 aZbot ) );
231
232 // Segment top and bot planes
233 aDstLayer->m_layer_top_triangles->AddQuad(
234 SFVEC3F( rightEnd.x, rightEnd.y, aZtop ),
235 SFVEC3F( rightStart.x, rightStart.y, aZtop ),
236 SFVEC3F( leftEnd.x, leftEnd.y, aZtop ),
237 SFVEC3F( leftStart.x, leftStart.y, aZtop ) );
238
239 aDstLayer->m_layer_bot_triangles->AddQuad(
240 SFVEC3F( rightEnd.x, rightEnd.y, aZbot ),
241 SFVEC3F( leftStart.x, leftStart.y, aZbot ),
242 SFVEC3F( leftEnd.x, leftEnd.y, aZbot ),
243 SFVEC3F( rightStart.x, rightStart.y, aZbot ) );
244}
const SFVEC2F & GetLeftEnd() const
const SFVEC2F & GetRightEnd() const
const SFVEC2F & GetLeftStar() const
const SFVEC2F & GetLeftDir() const
const SFVEC2F & GetEnd() const
float GetRadius() const
float GetRadiusSquared() const
const SFVEC2F & GetStart() const
const SFVEC2F & GetRightDir() const
const SFVEC2F & GetRightStar() const

References TRIANGLE_LIST::AddQuad(), TRIANGLE_LIST::AddTriangle(), ROUND_SEGMENT_2D::GetEnd(), ROUND_SEGMENT_2D::GetLeftDir(), ROUND_SEGMENT_2D::GetLeftEnd(), ROUND_SEGMENT_2D::GetLeftStar(), ROUND_SEGMENT_2D::GetRadius(), ROUND_SEGMENT_2D::GetRadiusSquared(), ROUND_SEGMENT_2D::GetRightDir(), ROUND_SEGMENT_2D::GetRightEnd(), ROUND_SEGMENT_2D::GetRightStar(), ROUND_SEGMENT_2D::GetStart(), TRIANGLE_DISPLAY_LIST::m_layer_bot_segment_ends, TRIANGLE_DISPLAY_LIST::m_layer_bot_triangles, TRIANGLE_DISPLAY_LIST::m_layer_top_segment_ends, TRIANGLE_DISPLAY_LIST::m_layer_top_triangles, and SIZE_OF_CIRCLE_TEXTURE.

◆ addObjectTriangles() [5/5]

void RENDER_3D_OPENGL::addObjectTriangles ( const TRIANGLE_2D aTri,
TRIANGLE_DISPLAY_LIST aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 150 of file opengl/create_scene.cpp.

153{
154 const SFVEC2F& v1 = aTri->GetP1();
155 const SFVEC2F& v2 = aTri->GetP2();
156 const SFVEC2F& v3 = aTri->GetP3();
157
158 addTopAndBottomTriangles( aDstLayer, v1, v2, v3, aZtop, aZbot );
159}
const SFVEC2F & GetP2() const
Definition: triangle_2d.h:45
const SFVEC2F & GetP3() const
Definition: triangle_2d.h:46
const SFVEC2F & GetP1() const
Definition: triangle_2d.h:44

References addTopAndBottomTriangles(), TRIANGLE_2D::GetP1(), TRIANGLE_2D::GetP2(), TRIANGLE_2D::GetP3(), v1, v2, and v3.

◆ addTopAndBottomTriangles()

void RENDER_3D_OPENGL::addTopAndBottomTriangles ( TRIANGLE_DISPLAY_LIST aDst,
const SFVEC2F v0,
const SFVEC2F v1,
const SFVEC2F v2,
float  top,
float  bot 
)
private

◆ createBoard()

OPENGL_RENDER_LIST * RENDER_3D_OPENGL::createBoard ( const SHAPE_POLY_SET aBoardPoly,
const BVH_CONTAINER_2D aThroughHoles = nullptr 
)
private

Definition at line 394 of file opengl/create_scene.cpp.

396{
397 OPENGL_RENDER_LIST* dispLists = nullptr;
398 CONTAINER_2D boardContainer;
399
400 ConvertPolygonToTriangles( aBoardPoly, boardContainer, m_boardAdapter.BiuTo3dUnits(),
401 (const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
402
403 const LIST_OBJECT2D& listBoardObject2d = boardContainer.GetList();
404
405 if( listBoardObject2d.size() > 0 )
406 {
407 // We will set a unitary Z so it will in future used with transformations since the
408 // board poly will be used not only to draw itself but also the solder mask layers.
409 const float layer_z_top = 1.0f;
410 const float layer_z_bot = 0.0f;
411
412 TRIANGLE_DISPLAY_LIST* layerTriangles =
413 new TRIANGLE_DISPLAY_LIST( listBoardObject2d.size() );
414
415 // Convert the list of objects(triangles) to triangle layer structure
416 for( const OBJECT_2D* itemOnLayer : listBoardObject2d )
417 {
418 const OBJECT_2D* object2d_A = itemOnLayer;
419
420 wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
421
422 const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
423
424 const SFVEC2F& v1 = tri->GetP1();
425 const SFVEC2F& v2 = tri->GetP2();
426 const SFVEC2F& v3 = tri->GetP3();
427
428 addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
429 }
430
431 if( aBoardPoly.OutlineCount() > 0 )
432 {
433 layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top,
435 aThroughHoles );
436
437 dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
438 layer_z_top, layer_z_top );
439 }
440
441 delete layerTriangles;
442 }
443
444 return dispLists;
445}
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
const BOARD * GetBoard() const noexcept
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
const LIST_OBJECT2D & GetList() const
Definition: container_2d.h:66
OBJECT_2D_TYPE GetObjectType() const
Definition: object_2d.h:107
Store the OpenGL display lists to related with a layer.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Store arrays of triangles to be used to create display lists.
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
std::list< OBJECT_2D * > LIST_OBJECT2D
Definition: container_2d.h:38
void ConvertPolygonToTriangles(const SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)

References TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), addTopAndBottomTriangles(), BOARD_ADAPTER::BiuTo3dUnits(), ConvertPolygonToTriangles(), BOARD_ADAPTER::GetBoard(), CONTAINER_2D_BASE::GetList(), OBJECT_2D::GetObjectType(), TRIANGLE_2D::GetP1(), TRIANGLE_2D::GetP2(), TRIANGLE_2D::GetP3(), RENDER_3D_BASE::m_boardAdapter, m_circleTexture, SHAPE_POLY_SET::OutlineCount(), TRIANGLE, v1, v2, and v3.

Referenced by reload().

◆ CreateBusyIndicator()

std::unique_ptr< BUSY_INDICATOR > RENDER_3D_BASE::CreateBusyIndicator ( ) const
protectedinherited

Return a created busy indicator, if a factory has been set, else a null pointer.

the canvas to display the scene

Definition at line 70 of file render_3d_base.cpp.

71{
72 std::unique_ptr<BUSY_INDICATOR> busy;
73
76
77 return busy;
78}
BUSY_INDICATOR::FACTORY m_busyIndicatorFactory
< Factory that returns a suitable busy indicator for the context.

References RENDER_3D_BASE::m_busyIndicatorFactory.

Referenced by Redraw(), and RENDER_3D_RAYTRACE::Redraw().

◆ freeAllLists()

void RENDER_3D_OPENGL::freeAllLists ( )
private

Definition at line 1018 of file render_3d_opengl.cpp.

1019{
1020 if( glIsList( m_grid ) )
1021 glDeleteLists( m_grid, 1 );
1022
1023 m_grid = 0;
1024
1025 for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii )
1026 {
1027 OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
1028 delete pLayerDispList;
1029 }
1030
1031 m_layers.clear();
1032
1033 delete m_platedPadsFront;
1034 m_platedPadsFront = nullptr;
1035
1036 delete m_platedPadsBack;
1037 m_platedPadsBack = nullptr;
1038
1039
1040 for( const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry : m_outerLayerHoles )
1041 delete entry.second;
1042
1043 m_outerLayerHoles.clear();
1044
1045 for( const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry : m_innerLayerHoles )
1046 delete entry.second;
1047
1048 m_innerLayerHoles.clear();
1049
1050 for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin(); ii != m_triangles.end(); ++ii )
1051 delete *ii;
1052
1053 m_triangles.clear();
1054
1055 for( const std::pair<const wxString, MODEL_3D*>& entry : m_3dModelMap )
1056 delete entry.second;
1057
1058 m_3dModelMap.clear();
1059
1060 m_3dModelMatrixMap.clear();
1061
1062 delete m_board;
1063 m_board = nullptr;
1064
1065 delete m_boardWithHoles;
1066 m_boardWithHoles = nullptr;
1067
1068 delete m_antiBoard;
1069 m_antiBoard = nullptr;
1070
1071 delete m_outerThroughHoles;
1072 m_outerThroughHoles = nullptr;
1073
1075 m_outerViaThroughHoles = nullptr;
1076
1078 m_outerThroughHoleRings = nullptr;
1079
1080 delete m_vias;
1081 m_vias = nullptr;
1082
1083 delete m_padHoles;
1084 m_padHoles = nullptr;
1085}
std::map< std::vector< double >, glm::mat4 > m_3dModelMatrixMap

References m_3dModelMap, m_3dModelMatrixMap, m_antiBoard, m_board, m_boardWithHoles, m_grid, m_innerLayerHoles, m_layers, m_outerLayerHoles, m_outerThroughHoleRings, m_outerThroughHoles, m_outerViaThroughHoles, m_padHoles, m_platedPadsBack, m_platedPadsFront, m_triangles, and m_vias.

Referenced by reload(), and ~RENDER_3D_OPENGL().

◆ generate3dGrid()

void RENDER_3D_OPENGL::generate3dGrid ( GRID3D_TYPE  aGridType)
private

Create a 3D grid to an OpenGL display list.

A horizontal grid (XY plane and Z = 0, and a vertical grid (XZ plane and Y = 0).

Definition at line 1310 of file render_3d_opengl.cpp.

1311{
1312 if( glIsList( m_grid ) )
1313 glDeleteLists( m_grid, 1 );
1314
1315 m_grid = 0;
1316
1317 if( aGridType == GRID3D_TYPE::NONE )
1318 return;
1319
1320 m_grid = glGenLists( 1 );
1321
1322 if( !glIsList( m_grid ) )
1323 return;
1324
1325 glNewList( m_grid, GL_COMPILE );
1326
1327 glEnable( GL_BLEND );
1328 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1329
1330 const double zpos = 0.0;
1331
1332 // Color of grid lines
1333 const SFVEC3F gridColor = m_boardAdapter.GetColor( DARKGRAY );
1334
1335 // Color of grid lines every 5 lines
1336 const SFVEC3F gridColor_marker = m_boardAdapter.GetColor( LIGHTBLUE );
1337 const double scale = m_boardAdapter.BiuTo3dUnits();
1338 const GLfloat transparency = 0.35f;
1339
1340 double griSizeMM = 0.0;
1341
1342 switch( aGridType )
1343 {
1344 default:
1345 case GRID3D_TYPE::NONE:
1346 return;
1348 griSizeMM = 1.0;
1349 break;
1351 griSizeMM = 2.5;
1352 break;
1354 griSizeMM = 5.0;
1355 break;
1357 griSizeMM = 10.0;
1358 break;
1359 }
1360
1361 glNormal3f( 0.0, 0.0, 1.0 );
1362
1363 const VECTOR2I brd_size = m_boardAdapter.GetBoardSize();
1364 VECTOR2I brd_center_pos = m_boardAdapter.GetBoardPos();
1365
1366 brd_center_pos.y = -brd_center_pos.y;
1367
1368 const int xsize = std::max( brd_size.x, pcbIUScale.mmToIU( 100 ) ) * 1.2;
1369 const int ysize = std::max( brd_size.y, pcbIUScale.mmToIU( 100 ) ) * 1.2;
1370
1371 // Grid limits, in 3D units
1372 double xmin = ( brd_center_pos.x - xsize / 2 ) * scale;
1373 double xmax = ( brd_center_pos.x + xsize / 2 ) * scale;
1374 double ymin = ( brd_center_pos.y - ysize / 2 ) * scale;
1375 double ymax = ( brd_center_pos.y + ysize / 2 ) * scale;
1376 double zmin = pcbIUScale.mmToIU( -50 ) * scale;
1377 double zmax = pcbIUScale.mmToIU( 100 ) * scale;
1378
1379 // Set rasterised line width (min value = 1)
1380 glLineWidth( 1 );
1381
1382 // Draw horizontal grid centered on 3D origin (center of the board)
1383 for( int ii = 0; ; ii++ )
1384 {
1385 if( (ii % 5) )
1386 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1387 else
1388 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1389 transparency );
1390
1391 const int delta = KiROUND( ii * griSizeMM * pcbIUScale.IU_PER_MM );
1392
1393 if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1394 {
1395 glBegin( GL_LINES );
1396 glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1397 glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1398 glEnd();
1399
1400 if( ii != 0 )
1401 {
1402 glBegin( GL_LINES );
1403 glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1404 glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1405 glEnd();
1406 }
1407 }
1408
1409 if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1410 {
1411 glBegin( GL_LINES );
1412 glVertex3f( xmin, -( brd_center_pos.y + delta ) * scale, zpos );
1413 glVertex3f( xmax, -( brd_center_pos.y + delta ) * scale, zpos );
1414 glEnd();
1415
1416 if( ii != 0 )
1417 {
1418 glBegin( GL_LINES );
1419 glVertex3f( xmin, -( brd_center_pos.y - delta ) * scale, zpos );
1420 glVertex3f( xmax, -( brd_center_pos.y - delta ) * scale, zpos );
1421 glEnd();
1422 }
1423 }
1424
1425 if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1426 break;
1427 }
1428
1429 // Draw vertical grid on Z axis
1430 glNormal3f( 0.0, -1.0, 0.0 );
1431
1432 // Draw vertical grid lines (parallel to Z axis)
1433 double posy = -brd_center_pos.y * scale;
1434
1435 for( int ii = 0; ; ii++ )
1436 {
1437 if( (ii % 5) )
1438 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1439 else
1440 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1441 transparency );
1442
1443 const double delta = ii * griSizeMM * pcbIUScale.IU_PER_MM;
1444
1445 glBegin( GL_LINES );
1446 xmax = ( brd_center_pos.x + delta ) * scale;
1447
1448 glVertex3f( xmax, posy, zmin );
1449 glVertex3f( xmax, posy, zmax );
1450 glEnd();
1451
1452 if( ii != 0 )
1453 {
1454 glBegin( GL_LINES );
1455 xmin = ( brd_center_pos.x - delta ) * scale;
1456 glVertex3f( xmin, posy, zmin );
1457 glVertex3f( xmin, posy, zmax );
1458 glEnd();
1459 }
1460
1461 if( delta > xsize / 2.0f )
1462 break;
1463 }
1464
1465 // Draw horizontal grid lines on Z axis (parallel to X axis)
1466 for( int ii = 0; ; ii++ )
1467 {
1468 if( ii % 5 )
1469 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1470 else
1471 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
1472
1473 const double delta = ii * griSizeMM * pcbIUScale.IU_PER_MM * scale;
1474
1475 if( delta <= zmax )
1476 {
1477 // Draw grid lines on Z axis (positive Z axis coordinates)
1478 glBegin( GL_LINES );
1479 glVertex3f( xmin, posy, delta );
1480 glVertex3f( xmax, posy, delta );
1481 glEnd();
1482 }
1483
1484 if( delta <= -zmin && ( ii != 0 ) )
1485 {
1486 // Draw grid lines on Z axis (negative Z axis coordinates)
1487 glBegin( GL_LINES );
1488 glVertex3f( xmin, posy, -delta );
1489 glVertex3f( xmax, posy, -delta );
1490 glEnd();
1491 }
1492
1493 if( ( delta > zmax ) && ( delta > -zmin ) )
1494 break;
1495 }
1496
1497 glDisable( GL_BLEND );
1498
1499 glEndList();
1500}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
VECTOR2I GetBoardSize() const noexcept
Get the board size.
VECTOR2I GetBoardPos() const noexcept
Get the board center.
SFVEC4F GetColor(const COLOR4D &aColor) const
@ LIGHTBLUE
Definition: color4d.h:62
@ DARKGRAY
Definition: color4d.h:46
const int scale
const double IU_PER_MM
Definition: base_units.h:77
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
constexpr int delta
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References BOARD_ADAPTER::BiuTo3dUnits(), DARKGRAY, delta, BOARD_ADAPTER::GetBoardPos(), BOARD_ADAPTER::GetBoardSize(), BOARD_ADAPTER::GetColor(), GRID_10MM, GRID_1MM, GRID_2P5MM, GRID_5MM, EDA_IU_SCALE::IU_PER_MM, KiROUND(), LIGHTBLUE, RENDER_3D_BASE::m_boardAdapter, m_grid, EDA_IU_SCALE::mmToIU(), NONE, pcbIUScale, scale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Redraw().

◆ generateCylinder()

void RENDER_3D_OPENGL::generateCylinder ( const SFVEC2F aCenter,
float  aInnerRadius,
float  aOuterRadius,
float  aZtop,
float  aZbot,
unsigned int  aNr_sides_per_circle,
TRIANGLE_DISPLAY_LIST aDstLayer 
)
private

Definition at line 719 of file opengl/create_scene.cpp.

723{
724 std::vector< SFVEC2F > innerContour;
725 std::vector< SFVEC2F > outerContour;
726
727 generateRing( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle, innerContour,
728 outerContour, false );
729
730 for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
731 {
732 const SFVEC2F& vi0 = innerContour[i + 0];
733 const SFVEC2F& vi1 = innerContour[i + 1];
734 const SFVEC2F& vo0 = outerContour[i + 0];
735 const SFVEC2F& vo1 = outerContour[i + 1];
736
737 aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
738 SFVEC3F( vi0.x, vi0.y, aZtop ),
739 SFVEC3F( vo0.x, vo0.y, aZtop ),
740 SFVEC3F( vo1.x, vo1.y, aZtop ) );
741
742 aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
743 SFVEC3F( vo1.x, vo1.y, aZbot ),
744 SFVEC3F( vo0.x, vo0.y, aZbot ),
745 SFVEC3F( vi0.x, vi0.y, aZbot ) );
746 }
747
748 aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
749 aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
750}

References TRIANGLE_LIST::AddQuad(), TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), generateRing(), TRIANGLE_DISPLAY_LIST::m_layer_bot_triangles, and TRIANGLE_DISPLAY_LIST::m_layer_top_triangles.

Referenced by generateViasAndPads().

◆ generateEmptyLayerList()

OPENGL_RENDER_LIST * RENDER_3D_OPENGL::generateEmptyLayerList ( PCB_LAYER_ID  aLayerId)
private

Definition at line 378 of file opengl/create_scene.cpp.

379{
380 float layer_z_bot = 0.0f;
381 float layer_z_top = 0.0f;
382
383 getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
384
385 TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( 1 );
386
387 // store in a list so it will be latter deleted
388 m_triangles.push_back( layerTriangles );
389
390 return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
391}
void getLayerZPos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const

References getLayerZPos(), m_circleTexture, and m_triangles.

Referenced by reload().

◆ generateHoles()

OPENGL_RENDER_LIST * RENDER_3D_OPENGL::generateHoles ( const LIST_OBJECT2D aListHolesObject2d,
const SHAPE_POLY_SET aPoly,
float  aZtop,
float  aZbot,
bool  aInvertFaces,
const BVH_CONTAINER_2D aThroughHoles = nullptr 
)
private

Definition at line 247 of file opengl/create_scene.cpp.

251{
252 OPENGL_RENDER_LIST* ret = nullptr;
253
254 if( aListHolesObject2d.size() > 0 )
255 {
256 TRIANGLE_DISPLAY_LIST* layerTriangles =
257 new TRIANGLE_DISPLAY_LIST( aListHolesObject2d.size() * 2 );
258
259 // Convert the list of objects(filled circles) to triangle layer structure
260 for( const OBJECT_2D* itemOnLayer : aListHolesObject2d )
261 {
262 const OBJECT_2D* object2d_A = itemOnLayer;
263
264 wxASSERT( ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::FILLED_CIRCLE )
265 || ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::ROUNDSEG ) );
266
267 switch( object2d_A->GetObjectType() )
268 {
270 addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
271 layerTriangles, aZtop, aZbot );
272 break;
273
275 addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
276 layerTriangles, aZtop, aZbot );
277 break;
278
279 default:
280 wxFAIL_MSG( wxT( "RENDER_3D_OPENGL::generateHoles: Object type not implemented" ) );
281 break;
282 }
283 }
284
285 // Note: he can have a aListHolesObject2d with holes but without contours
286 // eg: when there are only NPTH on the list and the contours were not added
287 if( aPoly.OutlineCount() > 0 )
288 {
289 layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop,
291 aInvertFaces, aThroughHoles );
292 }
293
294 ret = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, aZbot, aZtop );
295
296 delete layerTriangles;
297 }
298
299 return ret;
300}
void addObjectTriangles(const RING_2D *aRing, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)

References addObjectTriangles(), TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), BOARD_ADAPTER::BiuTo3dUnits(), FILLED_CIRCLE, OBJECT_2D::GetObjectType(), RENDER_3D_BASE::m_boardAdapter, m_circleTexture, SHAPE_POLY_SET::OutlineCount(), and ROUNDSEG.

Referenced by reload().

◆ generateLayerList()

OPENGL_RENDER_LIST * RENDER_3D_OPENGL::generateLayerList ( const BVH_CONTAINER_2D aContainer,
const SHAPE_POLY_SET aPolyList,
PCB_LAYER_ID  aLayerId,
const BVH_CONTAINER_2D aThroughHoles = nullptr 
)
private

Definition at line 303 of file opengl/create_scene.cpp.

307{
308 if( aContainer == nullptr )
309 return nullptr;
310
311 const LIST_OBJECT2D& listObject2d = aContainer->GetList();
312
313 if( listObject2d.size() == 0 )
314 return nullptr;
315
316 float layer_z_bot = 0.0f;
317 float layer_z_top = 0.0f;
318
319 getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
320
321 // Calculate an estimation for the nr of triangles based on the nr of objects
322 unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
323
324 TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( nrTrianglesEstimation );
325
326 // store in a list so it will be latter deleted
327 m_triangles.push_back( layerTriangles );
328
329 // Load the 2D (X,Y axis) component of shapes
330 for( const OBJECT_2D* itemOnLayer : listObject2d )
331 {
332 const OBJECT_2D* object2d_A = itemOnLayer;
333
334 switch( object2d_A->GetObjectType() )
335 {
337 addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
338 layerTriangles, layer_z_top, layer_z_bot );
339 break;
340
342 addObjectTriangles( static_cast<const POLYGON_4PT_2D*>( object2d_A ),
343 layerTriangles, layer_z_top, layer_z_bot );
344 break;
345
347 addObjectTriangles( static_cast<const RING_2D*>( object2d_A ),
348 layerTriangles, layer_z_top, layer_z_bot );
349 break;
350
352 addObjectTriangles( static_cast<const TRIANGLE_2D*>( object2d_A ),
353 layerTriangles, layer_z_top, layer_z_bot );
354 break;
355
357 addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
358 layerTriangles, layer_z_top, layer_z_bot );
359 break;
360
361 default:
362 wxFAIL_MSG( wxT( "RENDER_3D_OPENGL: Object type is not implemented" ) );
363 break;
364 }
365 }
366
367 if( aPolyList && aPolyList->OutlineCount() > 0 )
368 {
369 layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top,
370 m_boardAdapter.BiuTo3dUnits(), false, aThroughHoles );
371 }
372
373 // Create display list
374 return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
375}
Simple non-intersecting polygon with 4 points.

References addObjectTriangles(), TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), BOARD_ADAPTER::BiuTo3dUnits(), FILLED_CIRCLE, getLayerZPos(), CONTAINER_2D_BASE::GetList(), OBJECT_2D::GetObjectType(), RENDER_3D_BASE::m_boardAdapter, m_circleTexture, m_triangles, SHAPE_POLY_SET::OutlineCount(), POLYGON4PT, RING, ROUNDSEG, and TRIANGLE.

Referenced by reload().

◆ generateRing()

void RENDER_3D_OPENGL::generateRing ( const SFVEC2F aCenter,
float  aInnerRadius,
float  aOuterRadius,
unsigned int  aNr_sides_per_circle,
std::vector< SFVEC2F > &  aInnerContourResult,
std::vector< SFVEC2F > &  aOuterContourResult,
bool  aInvertOrder 
)
private

Definition at line 82 of file opengl/create_scene.cpp.

87{
88 aInnerContourResult.clear();
89 aInnerContourResult.reserve( aNr_sides_per_circle + 2 );
90
91 aOuterContourResult.clear();
92 aOuterContourResult.reserve( aNr_sides_per_circle + 2 );
93
94 const int delta = 3600 / aNr_sides_per_circle;
95
96 for( int ii = 0; ii < 3600; ii += delta )
97 {
98 float angle = (float)( aInvertOrder ? ( 3600 - ii ) : ii )
99 * 2.0f * glm::pi<float>() / 3600.0f;
100 const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) );
101
102 aInnerContourResult.emplace_back( aCenter.x + rotatedDir.x * aInnerRadius,
103 aCenter.y + rotatedDir.y * aInnerRadius );
104
105 aOuterContourResult.emplace_back( aCenter.x + rotatedDir.x * aOuterRadius,
106 aCenter.y + rotatedDir.y * aOuterRadius );
107 }
108
109 aInnerContourResult.push_back( aInnerContourResult[0] );
110 aOuterContourResult.push_back( aOuterContourResult[0] );
111
112 wxASSERT( aInnerContourResult.size() == aOuterContourResult.size() );
113}
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), and delta.

Referenced by addObjectTriangles(), and generateCylinder().

◆ generateViasAndPads()

void RENDER_3D_OPENGL::generateViasAndPads ( )
private

Definition at line 753 of file opengl/create_scene.cpp.

754{
755 if( !m_boardAdapter.GetBoard() )
756 return;
757
758 const int platingThickness = m_boardAdapter.GetHolePlatingThickness();
759 const float platingThickness3d = platingThickness * m_boardAdapter.BiuTo3dUnits();
760
761 if( m_boardAdapter.GetViaCount() > 0 )
762 {
763 float averageDiameter = m_boardAdapter.GetAverageViaHoleDiameter();
764 unsigned int averageSegCount = m_boardAdapter.GetCircleSegmentCount( averageDiameter );
765 unsigned int trianglesEstimate = averageSegCount * 8 * m_boardAdapter.GetViaCount();
766
767 TRIANGLE_DISPLAY_LIST* layerTriangleVIA = new TRIANGLE_DISPLAY_LIST( trianglesEstimate );
768
769 // Insert plated vertical holes inside the board
770
771 // Insert vias holes (vertical cylinders)
772 for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
773 {
774 if( track->Type() == PCB_VIA_T )
775 {
776 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
777
778 const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
779 const int nrSegments = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
780 const float hole_inner_radius = holediameter / 2.0f;
781
782 const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
783 -via->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
784
785 PCB_LAYER_ID top_layer, bottom_layer;
786 via->LayerPair( &top_layer, &bottom_layer );
787
788 float ztop, zbot, dummy;
789
790 getLayerZPos( top_layer, ztop, dummy );
791 getLayerZPos( bottom_layer, dummy, zbot );
792
793 wxASSERT( zbot < ztop );
794
795 generateCylinder( via_center, hole_inner_radius,
796 hole_inner_radius + platingThickness3d,
797 ztop, zbot, nrSegments, layerTriangleVIA );
798 }
799 }
800
801 m_vias = new OPENGL_RENDER_LIST( *layerTriangleVIA, 0, 0.0f, 0.0f );
802
803 delete layerTriangleVIA;
804 }
805
806
807 if( m_boardAdapter.GetHoleCount() > 0 )
808 {
809 SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
810 SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
811
812 tht_outer_holes_poly.RemoveAllContours();
813 tht_inner_holes_poly.RemoveAllContours();
814
815 // Insert pads holes (vertical cylinders)
816 for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
817 {
818 for( const PAD* pad : footprint->Pads() )
819 {
820 if( pad->GetAttribute() != PAD_ATTRIB::NPTH )
821 {
822 const VECTOR2I drillsize = pad->GetDrillSize();
823 const bool hasHole = drillsize.x && drillsize.y;
824
825 if( !hasHole )
826 continue;
827
828 pad->TransformHoleToPolygon( tht_outer_holes_poly, platingThickness,
830 pad->TransformHoleToPolygon( tht_inner_holes_poly, 0, ARC_HIGH_DEF,
831 ERROR_INSIDE );
832 }
833 }
834 }
835
836 // Subtract the holes
837 tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
838
841
842 CONTAINER_2D holesContainer;
843
844 ConvertPolygonToTriangles( tht_outer_holes_poly, holesContainer,
846
847 const LIST_OBJECT2D& holes2D = holesContainer.GetList();
848
849 if( holes2D.size() > 0 )
850 {
851 float layer_z_top, layer_z_bot, dummy;
852
853 getLayerZPos( F_Cu, layer_z_top, dummy );
854 getLayerZPos( B_Cu, dummy, layer_z_bot );
855
856 TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( holes2D.size() );
857
858 // Convert the list of objects(triangles) to triangle layer structure
859 for( const OBJECT_2D* itemOnLayer : holes2D )
860 {
861 const OBJECT_2D* object2d_A = itemOnLayer;
862
863 wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
864
865 const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
866
867 const SFVEC2F& v1 = tri->GetP1();
868 const SFVEC2F& v2 = tri->GetP2();
869 const SFVEC2F& v3 = tri->GetP3();
870
871 addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
872 }
873
874 wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
875
876 if( tht_outer_holes_poly.OutlineCount() > 0 )
877 {
878 layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
879 layer_z_bot, layer_z_top,
880 m_boardAdapter.BiuTo3dUnits(), false );
881
882 m_padHoles = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
883 layer_z_top, layer_z_top );
884 }
885
886 delete layerTriangles;
887 }
888 }
889}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
int GetHolePlatingThickness() const noexcept
Get the hole plating thickness (NB: in BOARD UNITS!).
float GetAverageViaHoleDiameter() const noexcept
unsigned int GetViaCount() const noexcept
EDA_3D_VIEWER_SETTINGS * m_Cfg
unsigned int GetHoleCount() const noexcept
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
Definition: pad.h:59
void generateCylinder(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST *aDstLayer)
SHAPE_POLY_SET m_antiBoardPolys
The negative polygon representation of the board outline.
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
@ ERROR_INSIDE
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ F_Cu
Definition: layer_ids.h:64
@ NPTH
like PAD_PTH, but not plated
std::vector< FAB_LAYER_COLOR > dummy
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102

References TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), addTopAndBottomTriangles(), ARC_HIGH_DEF, B_Cu, BOARD_ADAPTER::BiuTo3dUnits(), SHAPE_POLY_SET::BooleanSubtract(), ConvertPolygonToTriangles(), dummy, ERROR_INSIDE, F_Cu, BOARD::Footprints(), generateCylinder(), BOARD_ADAPTER::GetAverageViaHoleDiameter(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetCircleSegmentCount(), BOARD_ADAPTER::GetHoleCount(), BOARD_ADAPTER::GetHolePlatingThickness(), getLayerZPos(), CONTAINER_2D_BASE::GetList(), OBJECT_2D::GetObjectType(), TRIANGLE_2D::GetP1(), TRIANGLE_2D::GetP2(), TRIANGLE_2D::GetP3(), BOARD_ADAPTER::GetViaCount(), m_antiBoardPolys, RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, m_circleTexture, m_padHoles, EDA_3D_VIEWER_SETTINGS::m_Render, m_vias, NPTH, SHAPE_POLY_SET::OutlineCount(), pad, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic, SHAPE_POLY_SET::RemoveAllContours(), BOARD::Tracks(), TRIANGLE, v1, v2, v3, via, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by reload().

◆ getLayerColor()

SFVEC4F RENDER_3D_OPENGL::getLayerColor ( PCB_LAYER_ID  aLayerID)
private

Definition at line 394 of file render_3d_opengl.cpp.

395{
396 SFVEC4F layerColor = m_boardAdapter.GetLayerColor( aLayerID );
397
399 {
400 switch( aLayerID )
401 {
402 case B_Adhes:
403 case F_Adhes:
404 break;
405
406 case B_Mask:
408 break;
409 case F_Mask:
411 break;
412
413 case B_Paste:
414 case F_Paste:
416 break;
417
418 case B_SilkS:
420 break;
421 case F_SilkS:
423 break;
424
425 case Dwgs_User:
426 case Cmts_User:
427 case Eco1_User:
428 case Eco2_User:
429 case Edge_Cuts:
430 case Margin:
431 break;
432
433 case B_CrtYd:
434 case F_CrtYd:
435 break;
436
437 case B_Fab:
438 case F_Fab:
439 break;
440
441 default:
442 layerColor = m_boardAdapter.m_CopperColor;
443 break;
444 }
445 }
446
447 return layerColor;
448}
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
SFVEC4F m_CopperColor
in realistic mode: copper color
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
@ F_CrtYd
Definition: layer_ids.h:117
@ B_Adhes
Definition: layer_ids.h:97
@ Edge_Cuts
Definition: layer_ids.h:113
@ Dwgs_User
Definition: layer_ids.h:109
@ F_Paste
Definition: layer_ids.h:101
@ Cmts_User
Definition: layer_ids.h:110
@ F_Adhes
Definition: layer_ids.h:98
@ B_Mask
Definition: layer_ids.h:106
@ Eco1_User
Definition: layer_ids.h:111
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ F_Fab
Definition: layer_ids.h:120
@ Margin
Definition: layer_ids.h:114
@ F_SilkS
Definition: layer_ids.h:104
@ B_CrtYd
Definition: layer_ids.h:116
@ Eco2_User
Definition: layer_ids.h:112
@ B_SilkS
Definition: layer_ids.h:103
@ B_Fab
Definition: layer_ids.h:119
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46

References B_Adhes, B_CrtYd, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Fab, F_Mask, F_Paste, F_SilkS, BOARD_ADAPTER::GetLayerColor(), RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, BOARD_ADAPTER::m_CopperColor, EDA_3D_VIEWER_SETTINGS::m_Render, BOARD_ADAPTER::m_SilkScreenColorBot, BOARD_ADAPTER::m_SilkScreenColorTop, BOARD_ADAPTER::m_SolderMaskColorBot, BOARD_ADAPTER::m_SolderMaskColorTop, BOARD_ADAPTER::m_SolderPasteColor, Margin, and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic.

Referenced by setLayerMaterial().

◆ getLayerZPos()

void RENDER_3D_OPENGL::getLayerZPos ( PCB_LAYER_ID  aLayerID,
float &  aOutZtop,
float &  aOutZbot 
) const
private

Definition at line 705 of file opengl/create_scene.cpp.

706{
707 aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayer );
708 aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayer );
709
710 if( aOutZtop < aOutZbot )
711 {
712 float tmpFloat = aOutZbot;
713 aOutZbot = aOutZtop;
714 aOutZtop = tmpFloat;
715 }
716}
float GetLayerBottomZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the bottom z position.
float GetLayerTopZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the top z position.

References BOARD_ADAPTER::GetLayerBottomZPos(), BOARD_ADAPTER::GetLayerTopZPos(), and RENDER_3D_BASE::m_boardAdapter.

Referenced by generateEmptyLayerList(), generateLayerList(), generateViasAndPads(), and reload().

◆ GetWaitForEditingTimeOut()

int RENDER_3D_OPENGL::GetWaitForEditingTimeOut ( )
overridevirtual

Give the interface the time (in ms) that it should wait for editing or movements before (this works for display preview mode).

Returns
a value in milliseconds

Implements RENDER_3D_BASE.

Definition at line 84 of file render_3d_opengl.cpp.

85{
86 return 50; // ms
87}

◆ initializeOpenGL()

bool RENDER_3D_OPENGL::initializeOpenGL ( )
private

Definition at line 956 of file render_3d_opengl.cpp.

957{
958 glEnable( GL_LINE_SMOOTH );
959 glShadeModel( GL_SMOOTH );
960
961 // 4-byte pixel alignment
962 glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
963
964 // Initialize the open GL texture to draw the filled semi-circle of the segments
966
967 if( !circleImage )
968 return false;
969
970 unsigned int circleRadius = ( SIZE_OF_CIRCLE_TEXTURE / 2 ) - 4;
971
972 circleImage->CircleFilled( ( SIZE_OF_CIRCLE_TEXTURE / 2 ) - 0,
973 ( SIZE_OF_CIRCLE_TEXTURE / 2 ) - 0,
974 circleRadius,
975 0xFF );
976
977 IMAGE* circleImageBlured = new IMAGE( circleImage->GetWidth(), circleImage->GetHeight() );
978
979 circleImageBlured->EfxFilter_SkipCenter( circleImage, IMAGE_FILTER::GAUSSIAN_BLUR, circleRadius - 8 );
980
981 m_circleTexture = OglLoadTexture( *circleImageBlured );
982
983 delete circleImageBlured;
984 circleImageBlured = nullptr;
985
986 delete circleImage;
987 circleImage = nullptr;
988
989 init_lights();
990
991 // Use this mode if you want see the triangle lines (debug proposes)
992 //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
994
995 return true;
996}
Manage an 8-bit channel image.
Definition: image.h:90
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
Definition: image.cpp:173
void EfxFilter_SkipCenter(IMAGE *aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius)
Apply a filter to the input image and store it in the image class.
Definition: image.cpp:527
unsigned int GetHeight() const
Definition: image.h:214
unsigned int GetWidth() const
Definition: image.h:213
bool m_is_opengl_initialized
GLuint OglLoadTexture(const IMAGE &aImage)
Generate a new OpenGL texture.
Definition: ogl_utils.cpp:71
void init_lights(void)

References IMAGE::CircleFilled(), IMAGE::EfxFilter_SkipCenter(), GAUSSIAN_BLUR, IMAGE::GetHeight(), IMAGE::GetWidth(), IMAGE, init_lights(), m_circleTexture, RENDER_3D_BASE::m_is_opengl_initialized, OglLoadTexture(), and SIZE_OF_CIRCLE_TEXTURE.

Referenced by Redraw().

◆ IsReloadRequestPending()

bool RENDER_3D_BASE::IsReloadRequestPending ( ) const
inlineinherited

Query if there is a pending reload request.

Returns
true if it wants to reload, false if there is no reload pending

Definition at line 77 of file render_3d_base.h.

77{ return m_reloadRequested; }
bool m_reloadRequested
The window size that this camera is working.

References RENDER_3D_BASE::m_reloadRequested.

Referenced by EDA_3D_CANVAS::DoRePaint(), and EDA_3D_CANVAS::IsReloadRequestPending().

◆ load3dModels()

void RENDER_3D_OPENGL::load3dModels ( REPORTER aStatusReporter)
private

Load footprint models from the cache and load it to openGL lists in the form of MODEL_3D objects.

This map of models will work as a local cache for this render. (cache based on MODEL_3D with associated openGL lists in GPU memory)

Definition at line 910 of file opengl/create_scene.cpp.

911{
912 if( !m_boardAdapter.GetBoard() )
913 return;
914
918 {
919 return;
920 }
921
922 // Go for all footprints
923 for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
924 {
925 wxString libraryName = footprint->GetFPID().GetLibNickname();
926 wxString footprintBasePath = wxEmptyString;
927
929 {
930 try
931 {
932 // FindRow() can throw an exception
933 const FP_LIB_TABLE_ROW* fpRow =
935 libraryName, false );
936
937 if( fpRow )
938 footprintBasePath = fpRow->GetFullURI( true );
939 }
940 catch( ... )
941 {
942 // Do nothing if the libraryName is not found in lib table
943 }
944 }
945
946 for( const FP_3DMODEL& fp_model : footprint->Models() )
947 {
948 if( fp_model.m_Show && !fp_model.m_Filename.empty() )
949 {
950 if( aStatusReporter )
951 {
952 // Display the short filename of the 3D fp_model loaded:
953 // (the full name is usually too long to be displayed)
954 wxFileName fn( fp_model.m_Filename );
955 aStatusReporter->Report( wxString::Format( _( "Loading %s..." ),
956 fn.GetFullName() ) );
957 }
958
959 // Check if the fp_model is not present in our cache map
960 // (Not already loaded in memory)
961 if( m_3dModelMap.find( fp_model.m_Filename ) == m_3dModelMap.end() )
962 {
963 // It is not present, try get it from cache
964 const S3DMODEL* modelPtr =
965 m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename, footprintBasePath );
966
967 // only add it if the return is not NULL
968 if( modelPtr )
969 {
971 MODEL_3D* model = new MODEL_3D( *modelPtr, materialMode );
972
973 m_3dModelMap[ fp_model.m_Filename ] = model;
974 }
975 }
976 }
977 }
978 }
979}
MATERIAL_MODE
Render 3d model shape materials mode.
Definition: 3d_enums.h:71
S3D_CACHE * Get3dCacheManager() const noexcept
Definition: board_adapter.h:81
PROJECT * GetProject() const
Definition: board.h:440
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:324
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
S3DMODEL * GetModel(const wxString &aModelFileName, const wxString &aBasePath)
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for displa...
Definition: 3d_cache.cpp:635
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Store the a model based on meshes and materials.
Definition: c3dmodel.h:91

References _, FP_LIB_TABLE::FindRow(), BOARD::Footprints(), Format(), BOARD_ADAPTER::Get3dCacheManager(), BOARD_ADAPTER::GetBoard(), LIB_TABLE_ROW::GetFullURI(), S3D_CACHE::GetModel(), BOARD::GetProject(), m_3dModelMap, RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, EDA_3D_VIEWER_SETTINGS::m_Render, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::material_mode, PROJECT::PcbFootprintLibs(), REPORTER::Report(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_insert, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_normal, and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_virtual.

Referenced by Load3dModelsIfNeeded(), and reload().

◆ Load3dModelsIfNeeded()

void RENDER_3D_OPENGL::Load3dModelsIfNeeded ( )

Load footprint models if they are not already loaded, i.e.

if m_3dModelMap is empty

Definition at line 892 of file opengl/create_scene.cpp.

893{
894 if( m_3dModelMap.size() > 0 )
895 return;
896
897 wxFrame* frame = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_canvas->GetParent() );
898
899 if( frame )
900 {
901 STATUSBAR_REPORTER activityReporter( frame->GetStatusBar(),
903 load3dModels( &activityReporter );
904 }
905 else
906 load3dModels( nullptr );
907}
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
EDA_3D_CANVAS * m_canvas
Settings reference in use for this render.
void load3dModels(REPORTER *aStatusReporter)
Load footprint models from the cache and load it to openGL lists in the form of MODEL_3D objects.
A wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:287
@ ACTIVITY

References ACTIVITY, load3dModels(), m_3dModelMap, and RENDER_3D_BASE::m_canvas.

Referenced by EDA_3D_CONTROLLER::ToggleVisibility().

◆ Redraw()

bool RENDER_3D_OPENGL::Redraw ( bool  aIsMoving,
REPORTER aStatusReporter,
REPORTER aWarningReporter 
)
overridevirtual

Redraw the view.

Parameters
aIsMovingif the user is moving the scene, it should be render in preview mode.
aStatusReportera pointer to the status progress reporter.
Returns
true if the render would like to redraw again.

Implements RENDER_3D_BASE.

Definition at line 546 of file render_3d_opengl.cpp.

548{
549 // Initialize OpenGL
551 {
552 if( !initializeOpenGL() )
553 return false;
554 }
555
557 {
558 std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
559
560 if( aStatusReporter )
561 aStatusReporter->Report( _( "Loading..." ) );
562
563 reload( aStatusReporter, aWarningReporter );
564
565 // generate a new 3D grid as the size of the board may had changed
568 }
569 else
570 {
571 // Check if grid was changed
573 {
574 // and generate a new one
577 }
578 }
579
581
582 // Initial setup
583 glDepthFunc( GL_LESS );
584 glEnable( GL_CULL_FACE );
585 glFrontFace( GL_CCW ); // This is the OpenGL default
586 glEnable( GL_NORMALIZE ); // This allow OpenGL to normalize the normals after transformations
587 glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
588
590 glDisable( GL_MULTISAMPLE );
591 else
592 glEnable( GL_MULTISAMPLE );
593
594 // clear color and depth buffers
595 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
596 glClearDepth( 1.0f );
597 glClearStencil( 0x00 );
598 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
599
601
602 // Draw the background ( rectangle with color gradient)
605
606 glEnable( GL_DEPTH_TEST );
607
608 // Set projection and modelview matrixes
609 glMatrixMode( GL_PROJECTION );
610 glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) );
611 glMatrixMode( GL_MODELVIEW );
612 glLoadIdentity();
613 glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
614
615 // Position the headlight
616 setLightFront( true );
617 setLightTop( true );
618 setLightBottom( true );
619
620 glEnable( GL_LIGHTING );
621
622 {
623 const SFVEC3F& cameraPos = m_camera.GetPos();
624
625 // Place the light at a minimum Z so the diffuse factor will not drop
626 // and the board will still look with good light.
627 float zpos;
628
629 if( cameraPos.z > 0.0f )
630 zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
631 else
632 zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
633
634 // This is a point light.
635 const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
636
637 glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
638 }
639
640 bool skipThickness = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_thickness_disableOnMove;
641 bool skipRenderHoles = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_holes_disableOnMove;
642 bool skipRenderVias = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_vias_disableOnMove;
643
644 bool drawMiddleSegments = !skipThickness;
645
647 {
648 // Draw vias and pad holes with copper material
650 }
651 else
652 {
653 OglSetMaterial( m_materials.m_GrayMaterial, 1.0f );
654 }
655
656 if( !( skipRenderVias || skipRenderHoles ) && m_vias )
657 m_vias->DrawAll();
658
659 if( !skipRenderHoles && m_padHoles )
661
662 // Display copper and tech layers
663 for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii )
664 {
665 const PCB_LAYER_ID layer_id = ( PCB_LAYER_ID )( ii->first );
666
667 // Mask layers are not processed here because they are a special case
668 if( ( layer_id == B_Mask ) || ( layer_id == F_Mask ) )
669 continue;
670
671 // Do not show inner layers when it is displaying the board and board body is opaque
672 // enough: the time to create inner layers can be *really significant*.
673 // So avoid creating them is they are not very visible
674 const double opacity_min = 0.8;
675
677 && m_boardAdapter.m_BoardBodyColor.a > opacity_min )
678 {
679 if( ( layer_id > F_Cu ) && ( layer_id < B_Cu ) )
680 continue;
681 }
682
683 glPushMatrix();
684
685 OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
686
687 if( ( layer_id >= F_Cu ) && ( layer_id <= B_Cu ) )
688 {
691 {
693 }
694 else
695 {
696 setLayerMaterial( layer_id );
697 }
698
699 if( skipRenderHoles )
700 {
701 pLayerDispList->DrawAllCameraCulled( m_camera.GetPos().z, drawMiddleSegments );
702
703 // Draw plated pads
704 if( layer_id == F_Cu && m_platedPadsFront )
705 {
708 drawMiddleSegments );
709 }
710 else if( layer_id == B_Cu && m_platedPadsBack )
711 {
714 drawMiddleSegments );
715 }
716
718 }
719 else
720 {
722 {
724 pLayerDispList->GetZTop()
725 - pLayerDispList->GetZBot() );
726 }
727
728 if( m_antiBoard )
729 {
730 m_antiBoard->ApplyScalePosition( pLayerDispList->GetZBot(),
731 pLayerDispList->GetZTop()
732 - pLayerDispList->GetZBot() );
733 }
734
735 if( m_outerLayerHoles.find( layer_id ) != m_outerLayerHoles.end() )
736 {
737 const OPENGL_RENDER_LIST* viasHolesLayer = m_outerLayerHoles.at( layer_id );
738
739 wxASSERT( viasHolesLayer != nullptr );
740
741 if( viasHolesLayer != nullptr )
742 {
743 pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
745 viasHolesLayer,
746 m_antiBoard );
747
748 // Draw plated pads
749 if( layer_id == F_Cu && m_platedPadsFront )
750 {
753 drawMiddleSegments,
755 viasHolesLayer,
756 m_antiBoard );
757 }
758 else if( layer_id == B_Cu && m_platedPadsBack )
759 {
762 drawMiddleSegments,
764 viasHolesLayer,
765 m_antiBoard );
766 }
767
769 }
770 }
771 else
772 {
773 pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
775 m_antiBoard );
776
777 if( layer_id == F_Cu && m_platedPadsFront )
778 {
782 m_antiBoard );
783 }
784 else if( layer_id == B_Cu && m_platedPadsBack )
785 {
789 m_antiBoard );
790 }
791
793 }
794 }
795 }
796 else
797 {
798 setLayerMaterial( layer_id );
799
800 OPENGL_RENDER_LIST* throughHolesOuter =
803 && ( layer_id == B_SilkS || layer_id == F_SilkS ) ? m_outerThroughHoleRings
805
806 if( throughHolesOuter )
807 {
808 throughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(),
809 pLayerDispList->GetZTop()
810 - pLayerDispList->GetZBot() );
811 }
812
813 OPENGL_RENDER_LIST* anti_board = m_antiBoard;
814
815 if( anti_board )
816 {
817 anti_board->ApplyScalePosition( pLayerDispList->GetZBot(),
818 pLayerDispList->GetZTop()
819 - pLayerDispList->GetZBot() );
820 }
821
822 if( !skipRenderHoles
825 && ( ( layer_id == B_SilkS && m_layers.find( B_Mask ) != m_layers.end() )
826 || ( layer_id == F_SilkS && m_layers.find( F_Mask ) != m_layers.end() ) ) )
827 {
828 const PCB_LAYER_ID layerMask_id = (layer_id == B_SilkS) ? B_Mask : F_Mask;
829
830 const OPENGL_RENDER_LIST* pLayerDispListMask = m_layers.at( layerMask_id );
831
832 pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
833 pLayerDispListMask,
834 throughHolesOuter, anti_board );
835 }
836 else
837 {
838 if( !skipRenderHoles && throughHolesOuter
839 && ( layer_id == B_SilkS || layer_id == F_SilkS ) )
840 {
841 pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, nullptr,
842 throughHolesOuter,
843 anti_board );
844 }
845 else
846 {
847 // Do not render Paste layers when skipRenderHoles is enabled
848 // otherwise it will cause z-fight issues
849 if( !( skipRenderHoles && ( layer_id == B_Paste || layer_id == F_Paste ) ) )
850 {
851 pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
852 anti_board );
853 }
854 }
855 }
856 }
857
858 glPopMatrix();
859 }
860
861 // Render 3D Models (Non-transparent)
862 render3dModels( false, false );
863 render3dModels( true, false );
864
865 // Display board body
867 renderBoardBody( skipRenderHoles );
868
869 // Display transparent mask layers
871 {
872 // add a depth buffer offset, it will help to hide some artifacts
873 // on silkscreen where the SolderMask is removed
874 glEnable( GL_POLYGON_OFFSET_FILL );
875 glPolygonOffset( 0.0f, -2.0f );
876
877 if( m_camera.GetPos().z > 0 )
878 {
880 drawMiddleSegments, skipRenderHoles );
881
883 drawMiddleSegments, skipRenderHoles );
884 }
885 else
886 {
888 drawMiddleSegments, skipRenderHoles );
889
891 drawMiddleSegments, skipRenderHoles );
892 }
893
894 glDisable( GL_POLYGON_OFFSET_FILL );
895 glPolygonOffset( 0.0f, 0.0f );
896 }
897
898 // Render 3D Models (Transparent)
899 // !TODO: this can be optimized. If there are no transparent models (or no opacity),
900 // then there is no need to make this function call.
901 glDepthMask( GL_FALSE );
902 glEnable( GL_BLEND );
903 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
904
905 // Enables Texture Env so it can combine model transparency with each footprint opacity
906 glEnable( GL_TEXTURE_2D );
907 glActiveTexture( GL_TEXTURE0 );
908 glBindTexture( GL_TEXTURE_2D, m_circleTexture ); // Uses an existent texture so the glTexEnv operations will work
909
910 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
911 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
912 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
913
914 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
915 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
916
917 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
918 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
919
920 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
921 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
922 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
923 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA );
924
925 render3dModels( false, true );
926 render3dModels( true, true );
927
928 glDisable( GL_BLEND );
930
931 glDepthMask( GL_TRUE );
932
933 // Render Grid
935 {
936 glDisable( GL_LIGHTING );
937
938 if( glIsList( m_grid ) )
939 glCallList( m_grid );
940
941 glEnable( GL_LIGHTING );
942 }
943
944 // Render 3D arrows
947
948 // Return back to the original viewport (this is important if we want
949 // to take a screenshot after the render)
950 glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
951
952 return false;
953}
GRID3D_TYPE
Grid types.
Definition: 3d_enums.h:54
SFVEC4F m_BgColorTop
background top color
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_BgColorBot
background bottom color
const glm::mat4 & GetProjectionMatrix() const
Definition: camera.cpp:414
const SFVEC3F & GetPos() const
Definition: camera.h:110
const glm::mat4 & GetViewMatrix() const
Definition: camera.cpp:450
float GetZBot() const
float GetZTop() const
void DrawAllCameraCulledSubtractLayer(bool aDrawMiddle, const OPENGL_RENDER_LIST *aLayerToSubtractA=nullptr, const OPENGL_RENDER_LIST *aLayerToSubtractB=nullptr, const OPENGL_RENDER_LIST *aLayerToSubtractC=nullptr, const OPENGL_RENDER_LIST *aLayerToSubtractD=nullptr) const
void DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
Draw all layers if they are visible by the camera if camera position is above the layer.
void ApplyScalePosition(float aZposition, float aZscale)
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
void reload(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
void generate3dGrid(GRID3D_TYPE aGridType)
Create a 3D grid to an OpenGL display list.
void setLightFront(bool enabled)
void renderBoardBody(bool aSkipRenderHoles)
void setLayerMaterial(PCB_LAYER_ID aLayerID)
void renderSolderMaskLayer(PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
void setPlatedCopperAndDepthOffset(PCB_LAYER_ID aLayer_id)
void render3dModels(bool aRenderTopOrBot, bool aRenderTransparentOnly)
struct RENDER_3D_OPENGL::@2 m_materials
void setLightBottom(bool enabled)
void setLightTop(bool enabled)
void OglResetTextureState()
Reset to default state the texture settings.
Definition: ogl_utils.cpp:189
void OglDrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
Definition: ogl_utils.cpp:160
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
Definition: ogl_utils.cpp:119

References _, OPENGL_RENDER_LIST::ApplyScalePosition(), B_Cu, B_Mask, B_Paste, B_SilkS, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::clip_silk_on_via_annulus, RENDER_3D_BASE::CreateBusyIndicator(), OPENGL_RENDER_LIST::DrawAll(), OPENGL_RENDER_LIST::DrawAllCameraCulled(), OPENGL_RENDER_LIST::DrawAllCameraCulledSubtractLayer(), F_Cu, F_Mask, F_Paste, F_SilkS, generate3dGrid(), BOARD_ADAPTER::GetLayerBottomZPos(), BOARD_ADAPTER::GetLayerTopZPos(), CAMERA::GetPos(), CAMERA::GetProjectionMatrix(), CAMERA::GetViewMatrix(), OPENGL_RENDER_LIST::GetZBot(), OPENGL_RENDER_LIST::GetZTop(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::grid_type, initializeOpenGL(), m_antiBoard, BOARD_ADAPTER::m_BgColorBot, BOARD_ADAPTER::m_BgColorTop, RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_BoardBodyColor, RENDER_3D_BASE::m_camera, BOARD_ADAPTER::m_Cfg, m_circleTexture, m_grid, RENDER_3D_BASE::m_is_opengl_initialized, m_lastGridType, m_layers, m_materials, m_outerLayerHoles, m_outerThroughHoleRings, m_outerThroughHoles, m_padHoles, m_platedPadsBack, m_platedPadsFront, RENDER_3D_BASE::m_reloadRequested, EDA_3D_VIEWER_SETTINGS::m_Render, m_vias, RENDER_3D_BASE::m_windowSize, NONE, OglDrawBackground(), OglResetTextureState(), OglSetMaterial(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_AA_disableOnMove, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_holes_disableOnMove, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_thickness_disableOnMove, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_vias_disableOnMove, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic, reload(), render3dArrows(), render3dModels(), renderBoardBody(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::renderPlatedPadsAsPlated, renderSolderMaskLayer(), REPORTER::Report(), setCopperMaterial(), setLayerMaterial(), setLightBottom(), setLightFront(), setLightTop(), setPlatedCopperAndDepthOffset(), setupMaterials(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_axis, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_board_body, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_soldermask, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::subtract_mask_from_silk, and unsetDepthOffset().

◆ reload()

void RENDER_3D_OPENGL::reload ( REPORTER aStatusReporter,
REPORTER aWarningReporter 
)
private

Definition at line 448 of file opengl/create_scene.cpp.

449{
450 m_reloadRequested = false;
451
452 freeAllLists();
453
455
456 unsigned stats_startReloadTime = GetRunningMicroSecs();
457
458 m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
459
461 m_camera.SetBoardLookAtPos( camera_pos );
462
463 if( aStatusReporter )
464 aStatusReporter->Report( _( "Load OpenGL: board" ) );
465
466 // Create Board
468
470 {
473 m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
474 m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
475 m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
476 m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
478
482 }
483
489
490 m_boardWithHoles = createBoard( board_poly_with_holes );
491
492 if( m_antiBoard )
494
495 // Create Through Holes and vias
496 if( aStatusReporter )
497 aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
498
500
502 {
505 }
506
508 outerPolyTHT, 1.0f, 0.0f, false,
510
513 m_boardAdapter.GetThroughHoleViaOdPolys(), 1.0f, 0.0f, false );
514
517 {
520 m_boardAdapter.GetThroughHoleAnnularRingPolys(), 1.0f, 0.0f, false );
521 }
522
523 const MAP_POLY& innerMapHoles = m_boardAdapter.GetHoleIdPolysMap();
524 const MAP_POLY& outerMapHoles = m_boardAdapter.GetHoleOdPolysMap();
525
526 wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
527
529
530 if( outerMapHoles.size() > 0 )
531 {
532 float layer_z_bot = 0.0f;
533 float layer_z_top = 0.0f;
534
535 for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : outerMapHoles )
536 {
537 const PCB_LAYER_ID layer_id = ii.first;
538 const SHAPE_POLY_SET* poly = ii.second;
539 const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
540
541 getLayerZPos( layer_id, layer_z_top, layer_z_bot );
542
543 m_outerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
544 layer_z_top, layer_z_bot, false );
545 }
546
547 for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : innerMapHoles )
548 {
549 const PCB_LAYER_ID layer_id = ii.first;
550 const SHAPE_POLY_SET* poly = ii.second;
551 const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
552
553 getLayerZPos( layer_id, layer_z_top, layer_z_bot );
554
555 m_innerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
556 layer_z_top, layer_z_bot, false );
557 }
558 }
559
560 // Generate vertical cylinders of vias and pads (copper)
562
563 // Add layers maps
564 if( aStatusReporter )
565 aStatusReporter->Report( _( "Load OpenGL: layers" ) );
566
567 const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
568
569 for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& ii : m_boardAdapter.GetLayerMap() )
570 {
571 const PCB_LAYER_ID layer_id = ii.first;
572
573 if( !m_boardAdapter.Is3dLayerEnabled( layer_id ) )
574 continue;
575
576 if( aStatusReporter )
577 {
578 aStatusReporter->Report( wxString::Format( _( "Load OpenGL layer %d" ),
579 (int) layer_id ) );
580 }
581
582 const BVH_CONTAINER_2D* container2d = ii.second;
583
584 SHAPE_POLY_SET polyListSubtracted;
585 SHAPE_POLY_SET* polyList = nullptr;
586
587 // Load the vertical (Z axis) component of shapes
588
589 if( map_poly.find( layer_id ) != map_poly.end() )
590 {
591 polyListSubtracted = *map_poly.at( layer_id );;
592
594 {
595 polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
597
598 if( layer_id != B_Mask && layer_id != F_Mask )
599 {
604 }
605
607 {
608 if( layer_id == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() )
609 {
610 polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ),
612 }
613 else if( layer_id == F_SilkS && map_poly.find( F_Mask ) != map_poly.end() )
614 {
615 polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ),
617 }
618 }
619 }
620
621 polyList = &polyListSubtracted;
622 }
623
624 OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, polyList, layer_id,
626
627 if( oglList != nullptr )
628 m_layers[layer_id] = oglList;
629
630 }
631
634 {
635 const SHAPE_POLY_SET* frontPlatedPadPolys = m_boardAdapter.GetFrontPlatedPadPolys();
636 const SHAPE_POLY_SET* backPlatedPadPolys = m_boardAdapter.GetBackPlatedPadPolys();
637
638 if( frontPlatedPadPolys )
639 {
640 SHAPE_POLY_SET polySubtracted = frontPlatedPadPolys->CloneDropTriangulation();
647
649 &polySubtracted, F_Cu );
650
651 // An entry for F_Cu must exist in m_layers or we'll never look at m_platedPadsFront
652 if( m_layers.count( F_Cu ) == 0 )
654 }
655
656 if( backPlatedPadPolys )
657 {
658 SHAPE_POLY_SET polySubtracted = backPlatedPadPolys->CloneDropTriangulation();
665
667 &polySubtracted, B_Cu );
668
669 // An entry for B_Cu must exist in m_layers or we'll never look at m_platedPadsBack
670 if( m_layers.count( B_Cu ) == 0 )
672 }
673 }
674
675 // Load 3D models
676 if( aStatusReporter )
677 aStatusReporter->Report( _( "Loading 3D models..." ) );
678
679 load3dModels( aStatusReporter );
680
681 if( aStatusReporter )
682 {
683 // Calculation time in seconds
684 double calculation_time = (double)( GetRunningMicroSecs() - stats_startReloadTime) / 1e6;
685
686 aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
687 }
688}
std::map< PCB_LAYER_ID, SHAPE_POLY_SET * > MAP_POLY
A type that stores polysets for each layer id.
Definition: board_adapter.h:57
std::map< PCB_LAYER_ID, BVH_CONTAINER_2D * > MAP_CONTAINER_2D_BASE
A type that stores a container of 2d objects for each layer id.
Definition: board_adapter.h:54
const BVH_CONTAINER_2D & GetThroughHoleViaOds() const noexcept
const MAP_CONTAINER_2D_BASE & GetLayerHoleMap() const noexcept
const SHAPE_POLY_SET & GetBoardPoly() const noexcept
Get the current polygon of the epoxy board.
const SHAPE_POLY_SET & GetThroughHoleOdPolys() const noexcept
Get through hole outside diameter 2D polygons.
const MAP_POLY & GetPolyMap() const noexcept
Get map of polygon's layers.
const MAP_POLY & GetHoleOdPolysMap() const noexcept
const BVH_CONTAINER_2D & GetThroughHoleIds() const noexcept
void InitSettings(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
Function to be called by the render when it need to reload the settings for the board.
const BVH_CONTAINER_2D * GetPlatedPadsBack() const noexcept
const MAP_POLY & GetHoleIdPolysMap() const noexcept
const SHAPE_POLY_SET * GetFrontPlatedPadPolys()
const SFVEC3F & GetBoardCenter() const noexcept
The board center position in 3D units.
const SHAPE_POLY_SET & GetOuterNonPlatedThroughHolePoly() const noexcept
const SHAPE_POLY_SET * GetBackPlatedPadPolys()
const MAP_CONTAINER_2D_BASE & GetLayerMap() const noexcept
Get the map of containers that have the objects per layer.
const SHAPE_POLY_SET & GetThroughHoleAnnularRingPolys() const noexcept
const BVH_CONTAINER_2D * GetPlatedPadsFront() const noexcept
const BVH_CONTAINER_2D & GetThroughHoleAnnularRings() const noexcept
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
const SHAPE_POLY_SET & GetThroughHoleViaOdPolys() const noexcept
const BVH_CONTAINER_2D & GetThroughHoleOds() const noexcept
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: camera.cpp:123
static OBJECT_2D_STATS & Instance()
Definition: object_2d.h:137
void ResetStats()
Definition: object_2d.h:122
void SetItIsTransparent(bool aSetTransparent)
OPENGL_RENDER_LIST * generateHoles(const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OPENGL_RENDER_LIST * generateEmptyLayerList(PCB_LAYER_ID aLayerId)
OPENGL_RENDER_LIST * createBoard(const SHAPE_POLY_SET &aBoardPoly, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OPENGL_RENDER_LIST * generateLayerList(const BVH_CONTAINER_2D *aContainer, const SHAPE_POLY_SET *aPolyList, PCB_LAYER_ID aLayerId, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union between a and b, store the result in it self For aFastMode meaning,...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
SHAPE_LINE_CHAIN & Outline(int aIndex)
int NewOutline()
Creates a new hole in a given outline.
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References _, SHAPE_POLY_SET::Append(), B_Cu, B_Mask, B_SilkS, SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::BooleanSubtract(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::clip_silk_on_via_annulus, SHAPE_POLY_SET::CloneDropTriangulation(), createBoard(), F_Cu, F_Mask, F_SilkS, Format(), freeAllLists(), generateEmptyLayerList(), generateHoles(), generateLayerList(), generateViasAndPads(), BOARD_ADAPTER::GetBackPlatedPadPolys(), BOARD_ADAPTER::GetBoardCenter(), BOARD_ADAPTER::GetBoardPoly(), BOARD_ADAPTER::GetFrontPlatedPadPolys(), BOARD_ADAPTER::GetHoleIdPolysMap(), BOARD_ADAPTER::GetHoleOdPolysMap(), BOARD_ADAPTER::GetLayerHoleMap(), BOARD_ADAPTER::GetLayerMap(), getLayerZPos(), CONTAINER_2D_BASE::GetList(), BOARD_ADAPTER::GetOuterNonPlatedThroughHolePoly(), BOARD_ADAPTER::GetPlatedPadsBack(), BOARD_ADAPTER::GetPlatedPadsFront(), BOARD_ADAPTER::GetPolyMap(), GetRunningMicroSecs(), BOARD_ADAPTER::GetThroughHoleAnnularRingPolys(), BOARD_ADAPTER::GetThroughHoleAnnularRings(), BOARD_ADAPTER::GetThroughHoleIds(), BOARD_ADAPTER::GetThroughHoleOdPolys(), BOARD_ADAPTER::GetThroughHoleOds(), BOARD_ADAPTER::GetThroughHoleViaOdPolys(), BOARD_ADAPTER::GetThroughHoleViaOds(), BOARD_ADAPTER::InitSettings(), OBJECT_2D_STATS::Instance(), BOARD_ADAPTER::Is3dLayerEnabled(), load3dModels(), m_antiBoard, m_antiBoardPolys, m_board, RENDER_3D_BASE::m_boardAdapter, m_boardWithHoles, RENDER_3D_BASE::m_camera, BOARD_ADAPTER::m_Cfg, m_innerLayerHoles, m_layers, m_outerLayerHoles, m_outerThroughHoleRings, m_outerThroughHoles, m_outerViaThroughHoles, m_platedPadsBack, m_platedPadsFront, RENDER_3D_BASE::m_reloadRequested, EDA_3D_VIEWER_SETTINGS::m_Render, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic, SHAPE_POLY_SET::RemoveAllContours(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::renderPlatedPadsAsPlated, REPORTER::Report(), OBJECT_2D_STATS::ResetStats(), CAMERA::SetBoardLookAtPos(), SHAPE_LINE_CHAIN::SetClosed(), OPENGL_RENDER_LIST::SetItIsTransparent(), and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::subtract_mask_from_silk.

Referenced by Redraw().

◆ ReloadRequest()

void RENDER_3D_BASE::ReloadRequest ( )
inlineinherited
Todo:
This must be reviewed to add flags to improve specific render.

Definition at line 70 of file render_3d_base.h.

70{ m_reloadRequested = true; }

References RENDER_3D_BASE::m_reloadRequested.

Referenced by EDA_3D_CANVAS::ReloadRequest(), EDA_3D_CANVAS::RenderEngineChanged(), and EDA_3D_CANVAS::RenderRaytracingRequest().

◆ render3dArrows()

void RENDER_3D_OPENGL::render3dArrows ( )
private

Definition at line 129 of file render_3d_opengl.cpp.

130{
131 const float arrow_size = RANGE_SCALE_3D * 0.30f;
132
133 glDisable( GL_CULL_FACE );
134
135 // YxY squared view port, this is on propose
136 glViewport( 4, 4, m_windowSize.y / 8 , m_windowSize.y / 8 );
137 glClear( GL_DEPTH_BUFFER_BIT );
138
139 glMatrixMode( GL_PROJECTION );
140 glLoadIdentity();
141 gluPerspective( 45.0f, 1.0f, 0.001f, RANGE_SCALE_3D );
142
143 glMatrixMode( GL_MODELVIEW );
144 glLoadIdentity();
145
146 const glm::mat4 TranslationMatrix =
147 glm::translate( glm::mat4( 1.0f ), SFVEC3F( 0.0f, 0.0f, -( arrow_size * 2.75f ) ) );
148
149 const glm::mat4 ViewMatrix = TranslationMatrix * m_camera.GetRotationMatrix();
150
151 glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
152
154
155 glColor3f( 0.9f, 0.0f, 0.0f );
156 DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( arrow_size, 0.0f, 0.0f ), 0.275f );
157
158 glColor3f( 0.0f, 0.9f, 0.0f );
159 DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( 0.0f, arrow_size, 0.0f ), 0.275f );
160
161 glColor3f( 0.0f, 0.0f, 0.9f );
162 DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( 0.0f, 0.0f, arrow_size ), 0.275f );
163
164 glEnable( GL_CULL_FACE );
165}
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:62
glm::mat4 GetRotationMatrix() const
Get the rotation matrix to be applied in a transformation camera.
Definition: camera.cpp:182
void DrawRoundArrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
Draw a round arrow.

References DrawRoundArrow(), CAMERA::GetRotationMatrix(), RENDER_3D_BASE::m_camera, RENDER_3D_BASE::m_windowSize, RANGE_SCALE_3D, and setArrowMaterial().

Referenced by Redraw().

◆ render3dModels()

void RENDER_3D_OPENGL::render3dModels ( bool  aRenderTopOrBot,
bool  aRenderTransparentOnly 
)
private
Parameters
aRenderTopOrBottrue will render Top, false will render bottom
aRenderTransparentOnlytrue will render only the transparent objects, false will render opaque

Definition at line 1188 of file render_3d_opengl.cpp.

1189{
1191 render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, true );
1192
1193 render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, false );
1194}
void render3dModelsSelected(bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)

References RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_IsBoardView, and render3dModelsSelected().

Referenced by Redraw().

◆ render3dModelsSelected()

void RENDER_3D_OPENGL::render3dModelsSelected ( bool  aRenderTopOrBot,
bool  aRenderTransparentOnly,
bool  aRenderSelectedOnly 
)
private

Definition at line 1146 of file render_3d_opengl.cpp.

1148{
1149 if( !m_boardAdapter.GetBoard() )
1150 return;
1151
1152 MODEL_3D::BeginDrawMulti( !aRenderSelectedOnly );
1153
1154 // Go for all footprints
1156 {
1157 bool highlight = false;
1158
1160 {
1161 if( fp->IsSelected() )
1162 highlight = true;
1163
1165 && fp == m_currentRollOverItem )
1166 {
1167 highlight = true;
1168 }
1169
1170 if( aRenderSelectedOnly != highlight )
1171 continue;
1172 }
1173
1174 if( !fp->Models().empty() )
1175 {
1176 if( m_boardAdapter.IsFootprintShown( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
1177 {
1178 if( aRenderTopOrBot == !fp->IsFlipped() )
1179 renderFootprint( fp, aRenderTransparentOnly, highlight );
1180 }
1181 }
1182 }
1183
1185}
bool IsFootprintShown(FOOTPRINT_ATTR_T aFPAttributes) const
Test if footprint should be displayed in relation to attributes and the flags.
static void EndDrawMulti()
Cleanup render states after drawing multiple models.
Definition: 3d_model.cpp:399
static void BeginDrawMulti(bool aUseColorInformation)
Set some basic render states before drawing multiple models.
Definition: 3d_model.cpp:383
void renderFootprint(const FOOTPRINT *aFootprint, bool aRenderTransparentOnly, bool aIsSelected)
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition: footprint.h:67

References MODEL_3D::BeginDrawMulti(), MODEL_3D::EndDrawMulti(), BOARD::Footprints(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::IsFootprintShown(), RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, m_currentRollOverItem, BOARD_ADAPTER::m_IsBoardView, EDA_3D_VIEWER_SETTINGS::m_Render, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_highlight_on_rollover, and renderFootprint().

Referenced by render3dModels().

◆ renderBoardBody()

void RENDER_3D_OPENGL::renderBoardBody ( bool  aSkipRenderHoles)
private

Definition at line 518 of file render_3d_opengl.cpp.

519{
520 m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
521
522 // opacity to transparency
523 m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a;
524
525 OglSetMaterial( m_materials.m_EpoxyBoard, 1.0f );
526
527 OPENGL_RENDER_LIST* ogl_disp_list = nullptr;
528
529 if( aSkipRenderHoles )
530 ogl_disp_list = m_board;
531 else
532 ogl_disp_list = m_boardWithHoles;
533
534 if( ogl_disp_list )
535 {
538
539 ogl_disp_list->SetItIsTransparent( true );
540
541 ogl_disp_list->DrawAll();
542 }
543}
float GetBoardBodyThickness() const noexcept
Get the board body thickness, including internal copper layers (in 3D units).

References OPENGL_RENDER_LIST::ApplyScalePosition(), OPENGL_RENDER_LIST::DrawAll(), BOARD_ADAPTER::GetBoardBodyThickness(), m_board, RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_BoardBodyColor, m_boardWithHoles, m_materials, OglSetMaterial(), and OPENGL_RENDER_LIST::SetItIsTransparent().

Referenced by Redraw().

◆ renderFootprint()

void RENDER_3D_OPENGL::renderFootprint ( const FOOTPRINT aFootprint,
bool  aRenderTransparentOnly,
bool  aIsSelected 
)
private

Definition at line 1197 of file render_3d_opengl.cpp.

1199{
1200 if( !aFootprint->Models().empty() )
1201 {
1202 const double zpos = m_boardAdapter.GetFootprintZPos( aFootprint->IsFlipped() );
1204
1205
1206 glPushMatrix();
1207
1208 VECTOR2I pos = aFootprint->GetPosition();
1209
1210 glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
1211 zpos );
1212
1213 if( !aFootprint->GetOrientation().IsZero() )
1214 glRotated( aFootprint->GetOrientation().AsDegrees(), 0.0, 0.0, 1.0 );
1215
1216 if( aFootprint->IsFlipped() )
1217 {
1218 glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1219 glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1220 }
1221
1222 double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3dUnits() * UNITS3D_TO_UNITSPCB;
1223
1224 glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
1225 modelunit_to_3d_units_factor );
1226
1227 // Get the list of model files for this model
1228 for( const FP_3DMODEL& sM : aFootprint->Models() )
1229 {
1230 if( !sM.m_Show || sM.m_Filename.empty() )
1231 continue;
1232
1233 // Check if the model is present in our cache map
1234 auto cache_i = m_3dModelMap.find( sM.m_Filename );
1235
1236 if( cache_i == m_3dModelMap.end() )
1237 continue;
1238
1239 if( const MODEL_3D* modelPtr = cache_i->second )
1240 {
1241 bool opaque = sM.m_Opacity >= 1.0;
1242
1243 if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
1244 ( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
1245 {
1246 glPushMatrix();
1247
1248 std::vector<double> key = { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z,
1249 sM.m_Rotation.x, sM.m_Rotation.y, sM.m_Rotation.z,
1250 sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z };
1251
1252 auto it = m_3dModelMatrixMap.find( key );
1253
1254 if( it != m_3dModelMatrixMap.end() )
1255 {
1256 glMultMatrixf( glm::value_ptr( it->second ) );
1257 }
1258 else
1259 {
1260 glm::mat4 mtx( 1 );
1261 mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
1262 mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.z ), { 0.0f, 0.0f, 1.0f } );
1263 mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.y ), { 0.0f, 1.0f, 0.0f } );
1264 mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.x ), { 1.0f, 0.0f, 0.0f } );
1265 mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
1266 m_3dModelMatrixMap[ key ] = mtx;
1267
1268 glMultMatrixf( glm::value_ptr( mtx ) );
1269 }
1270
1271
1272 if( aRenderTransparentOnly )
1273 {
1274 modelPtr->DrawTransparent( sM.m_Opacity,
1275 aFootprint->IsSelected() || aIsSelected,
1276 selColor );
1277 }
1278 else
1279 {
1280 modelPtr->DrawOpaque( aFootprint->IsSelected() || aIsSelected, selColor );
1281 }
1282
1284 {
1285 glEnable( GL_BLEND );
1286 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1287
1288 glDisable( GL_LIGHTING );
1289
1290 glLineWidth( 1 );
1291 modelPtr->DrawBboxes();
1292
1293 glLineWidth( 4 );
1294 modelPtr->DrawBbox();
1295
1296 glEnable( GL_LIGHTING );
1297 glDisable( GL_BLEND );
1298 }
1299
1300 glPopMatrix();
1301 }
1302 }
1303 }
1304
1305 glPopMatrix();
1306 }
1307}
float GetFootprintZPos(bool aIsFlipped) const
Get the position of the footprint in 3d integer units considering if it is flipped or not.
double AsDegrees() const
Definition: eda_angle.h:149
bool IsZero() const
Definition: eda_angle.h:169
bool IsSelected() const
Definition: eda_item.h:106
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
bool IsFlipped() const
Definition: footprint.h:324
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:184
VECTOR2I GetPosition() const override
Definition: footprint.h:188
#define UNITS3D_TO_UNITSPCB
Scale conversion from 3d model units to pcb units.

References EDA_ANGLE::AsDegrees(), BOARD_ADAPTER::BiuTo3dUnits(), BOARD_ADAPTER::GetColor(), BOARD_ADAPTER::GetFootprintZPos(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), FOOTPRINT::IsFlipped(), EDA_ITEM::IsSelected(), EDA_ANGLE::IsZero(), m_3dModelMap, m_3dModelMatrixMap, RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, EDA_3D_VIEWER_SETTINGS::m_Render, FOOTPRINT::Models(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_selection_color, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_show_model_bbox, scale, UNITS3D_TO_UNITSPCB, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by render3dModelsSelected().

◆ renderSolderMaskLayer()

void RENDER_3D_OPENGL::renderSolderMaskLayer ( PCB_LAYER_ID  aLayerID,
float  aZPosition,
bool  aDrawMiddleSegments,
bool  aSkipRenderHoles 
)
private

Definition at line 1088 of file render_3d_opengl.cpp.

1090{
1091 wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
1092
1093 float nonCopperThickness = m_boardAdapter.GetNonCopperLayerThickness();
1094
1095 if( m_board )
1096 {
1097 if( m_layers.find( aLayerID ) != m_layers.end() )
1098 {
1099 OPENGL_RENDER_LIST* pLayerDispListMask = m_layers.at( aLayerID );
1100
1102 m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
1103
1104 m_board->ApplyScalePosition( aZPosition, nonCopperThickness );
1105
1106 setLayerMaterial( aLayerID );
1107
1108 m_board->SetItIsTransparent( true );
1109
1110 if( aSkipRenderHoles )
1111 {
1112 m_board->DrawAllCameraCulled( m_camera.GetPos().z, aDrawMiddleSegments );
1113 }
1114 else
1115 {
1116 m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments, pLayerDispListMask,
1118 }
1119 }
1120 else
1121 {
1122 // This case there is no layer with mask, so we will render the full board as mask
1124 m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
1125
1126 m_board->ApplyScalePosition( aZPosition, nonCopperThickness );
1127
1128 setLayerMaterial( aLayerID );
1129
1130 m_board->SetItIsTransparent( true );
1131
1132 if( aSkipRenderHoles )
1133 {
1134 m_board->DrawAllCameraCulled( m_camera.GetPos().z, aDrawMiddleSegments );
1135 }
1136 else
1137 {
1138 m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments,
1140 }
1141 }
1142 }
1143}
float GetNonCopperLayerThickness() const noexcept
Get the non copper layers thickness (in 3D units).

References OPENGL_RENDER_LIST::ApplyScalePosition(), B_Mask, OPENGL_RENDER_LIST::DrawAllCameraCulled(), OPENGL_RENDER_LIST::DrawAllCameraCulledSubtractLayer(), F_Mask, BOARD_ADAPTER::GetNonCopperLayerThickness(), CAMERA::GetPos(), m_board, RENDER_3D_BASE::m_boardAdapter, RENDER_3D_BASE::m_camera, m_layers, m_outerViaThroughHoles, OPENGL_RENDER_LIST::SetItIsTransparent(), and setLayerMaterial().

Referenced by Redraw().

◆ setArrowMaterial()

void RENDER_3D_OPENGL::setArrowMaterial ( )
private

Definition at line 999 of file render_3d_opengl.cpp.

1000{
1001 glEnable( GL_COLOR_MATERIAL );
1002 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
1003
1004 const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1005 const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1006 const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1007 const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
1008
1009 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
1010 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
1011
1012 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
1013 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
1014 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
1015}

Referenced by render3dArrows().

◆ SetBusyIndicatorFactory()

void RENDER_3D_BASE::SetBusyIndicatorFactory ( BUSY_INDICATOR::FACTORY  aNewFactory)
inherited

Set a new busy indicator factory.

When set, this factory will be used to generate busy indicators when suitable. If not set, no busy indicator will be used.

Definition at line 64 of file render_3d_base.cpp.

65{
66 m_busyIndicatorFactory = aNewFactory;
67}

References RENDER_3D_BASE::m_busyIndicatorFactory.

◆ setCopperMaterial()

void RENDER_3D_OPENGL::setCopperMaterial ( )
private

Definition at line 498 of file render_3d_opengl.cpp.

499{
500 OglSetMaterial( m_materials.m_NonPlatedCopper, 1.0f );
501}

References m_materials, and OglSetMaterial().

Referenced by Redraw().

◆ SetCurrentRollOverItem()

void RENDER_3D_OPENGL::SetCurrentRollOverItem ( BOARD_ITEM aRollOverItem)
inline

Definition at line 64 of file render_3d_opengl.h.

65 {
66 m_currentRollOverItem = aRollOverItem;
67 }

References m_currentRollOverItem.

Referenced by EDA_3D_CANVAS::OnMouseMove().

◆ SetCurWindowSize()

void RENDER_3D_OPENGL::SetCurWindowSize ( const wxSize &  aSize)
overridevirtual

Before each render, the canvas will tell the render what is the size of its windows, so render can take actions if it changed.

Parameters
aSizethe current size of the render window

Implements RENDER_3D_BASE.

Definition at line 90 of file render_3d_opengl.cpp.

91{
92 if( m_windowSize != aSize )
93 {
94 m_windowSize = aSize;
95 glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
96
97 // Initialize here any screen dependent data here
98 }
99}

References RENDER_3D_BASE::m_windowSize.

◆ setLayerMaterial()

void RENDER_3D_OPENGL::setLayerMaterial ( PCB_LAYER_ID  aLayerID)
private

Definition at line 317 of file render_3d_opengl.cpp.

318{
319 switch( aLayerID )
320 {
321 case F_Mask:
322 case B_Mask:
323 {
324 const SFVEC4F layerColor = getLayerColor( aLayerID );
325
326 m_materials.m_SolderMask.m_Diffuse = layerColor;
327
328 // Convert Opacity to Transparency
329 m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a;
330
332 {
333 m_materials.m_SolderMask.m_Ambient = m_materials.m_SolderMask.m_Diffuse * 0.3f;
334
335 m_materials.m_SolderMask.m_Specular =
336 m_materials.m_SolderMask.m_Diffuse * m_materials.m_SolderMask.m_Diffuse;
337 }
338
339 OglSetMaterial( m_materials.m_SolderMask, 1.0f );
340 break;
341 }
342
343 case B_Paste:
344 case F_Paste:
345 m_materials.m_Paste.m_Diffuse = getLayerColor( aLayerID );
346 OglSetMaterial( m_materials.m_Paste, 1.0f );
347 break;
348
349 case B_SilkS:
350 m_materials.m_SilkSBot.m_Diffuse = getLayerColor( aLayerID );
351 OglSetMaterial( m_materials.m_SilkSBot, 1.0f );
352 break;
353
354 case F_SilkS:
355 m_materials.m_SilkSTop.m_Diffuse = getLayerColor( aLayerID );
356 OglSetMaterial( m_materials.m_SilkSTop, 1.0f );
357 break;
358
359 case B_Adhes:
360 case F_Adhes:
361 case Dwgs_User:
362 case Cmts_User:
363 case Eco1_User:
364 case Eco2_User:
365 case Edge_Cuts:
366 case Margin:
367 case B_CrtYd:
368 case F_CrtYd:
369 case B_Fab:
370 case F_Fab:
371 m_materials.m_Plastic.m_Diffuse = getLayerColor( aLayerID );
372
373 m_materials.m_Plastic.m_Ambient = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.05f,
374 m_materials.m_Plastic.m_Diffuse.g * 0.05f,
375 m_materials.m_Plastic.m_Diffuse.b * 0.05f );
376
377 m_materials.m_Plastic.m_Specular = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.7f,
378 m_materials.m_Plastic.m_Diffuse.g * 0.7f,
379 m_materials.m_Plastic.m_Diffuse.b * 0.7f );
380
381 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
382 m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
383 OglSetMaterial( m_materials.m_Plastic, 1.0f );
384 break;
385
386 default:
387 m_materials.m_Copper.m_Diffuse = getLayerColor( aLayerID );
388 OglSetMaterial( m_materials.m_Copper, 1.0f );
389 break;
390 }
391}
SFVEC4F getLayerColor(PCB_LAYER_ID aLayerID)

References B_Adhes, B_CrtYd, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Fab, F_Mask, F_Paste, F_SilkS, getLayerColor(), RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, m_materials, EDA_3D_VIEWER_SETTINGS::m_Render, Margin, OglSetMaterial(), and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic.

Referenced by Redraw(), renderSolderMaskLayer(), and setPlatedCopperAndDepthOffset().

◆ setLightBottom()

void RENDER_3D_OPENGL::setLightBottom ( bool  enabled)
private

Definition at line 120 of file render_3d_opengl.cpp.

121{
122 if( enabled )
123 glEnable( GL_LIGHT2 );
124 else
125 glDisable( GL_LIGHT2 );
126}

Referenced by Redraw().

◆ setLightFront()

void RENDER_3D_OPENGL::setLightFront ( bool  enabled)
private

Definition at line 102 of file render_3d_opengl.cpp.

103{
104 if( enabled )
105 glEnable( GL_LIGHT0 );
106 else
107 glDisable( GL_LIGHT0 );
108}

Referenced by Redraw().

◆ setLightTop()

void RENDER_3D_OPENGL::setLightTop ( bool  enabled)
private

Definition at line 111 of file render_3d_opengl.cpp.

112{
113 if( enabled )
114 glEnable( GL_LIGHT1 );
115 else
116 glDisable( GL_LIGHT1 );
117}

Referenced by Redraw().

◆ setPlatedCopperAndDepthOffset()

void RENDER_3D_OPENGL::setPlatedCopperAndDepthOffset ( PCB_LAYER_ID  aLayer_id)
private

Definition at line 504 of file render_3d_opengl.cpp.

505{
506 glEnable( GL_POLYGON_OFFSET_FILL );
507 glPolygonOffset( -0.1f, -2.0f );
508 setLayerMaterial( aLayer_id );
509}

References setLayerMaterial().

Referenced by Redraw().

◆ setupMaterials()

void RENDER_3D_OPENGL::setupMaterials ( )
private

Definition at line 168 of file render_3d_opengl.cpp.

169{
170 m_materials = {};
171
173 {
174 // http://devernay.free.fr/cours/opengl/materials.html
175
176 // Plated copper
177 // Copper material mixed with the copper color
178 m_materials.m_Copper.m_Ambient = SFVEC3F( m_boardAdapter.m_CopperColor.r * 0.1f,
181
182 m_materials.m_Copper.m_Specular = SFVEC3F( m_boardAdapter.m_CopperColor.r * 0.75f + 0.25f,
183 m_boardAdapter.m_CopperColor.g * 0.75f + 0.25f,
184 m_boardAdapter.m_CopperColor.b * 0.75f + 0.25f );
185
186 // This guess the material type(ex: copper vs gold) to determine the
187 // shininess factor between 0.1 and 0.4
188 float shininessfactor = 0.40f - mapf( fabs( m_boardAdapter.m_CopperColor.r -
190 0.15f, 1.00f,
191 0.00f, 0.30f );
192
193 m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
194 m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
195
196
197 // Non plated copper (raw copper)
198 m_materials.m_NonPlatedCopper.m_Ambient = SFVEC3F( 0.191f, 0.073f, 0.022f );
199 m_materials.m_NonPlatedCopper.m_Diffuse = SFVEC3F( 184.0f / 255.0f, 115.0f / 255.0f,
200 50.0f / 255.0f );
201 m_materials.m_NonPlatedCopper.m_Specular = SFVEC3F( 0.256f, 0.137f, 0.086f );
202 m_materials.m_NonPlatedCopper.m_Shininess = 0.1f * 128.0f;
203 m_materials.m_NonPlatedCopper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
204
205 // Paste material mixed with paste color
209
210 m_materials.m_Paste.m_Specular = SFVEC3F( m_boardAdapter.m_SolderPasteColor.r *
216
217 m_materials.m_Paste.m_Shininess = 0.1f * 128.0f;
218 m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
219
220 // Silk screen material mixed with silk screen color
221 m_materials.m_SilkSTop.m_Ambient = SFVEC3F( m_boardAdapter.m_SilkScreenColorTop.r,
224
225 m_materials.m_SilkSTop.m_Specular = SFVEC3F(
227 0.10f,
229 0.10f,
231 0.10f );
232
233 m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
234 m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
235
236 // Silk screen material mixed with silk screen color
237 m_materials.m_SilkSBot.m_Ambient = SFVEC3F( m_boardAdapter.m_SilkScreenColorBot.r,
240
241 m_materials.m_SilkSBot.m_Specular = SFVEC3F(
243 0.10f,
245 0.10f,
247 0.10f );
248
249 m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
250 m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
251
252 m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
253 m_materials.m_SolderMask.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
254
255 // Epoxy material
256 m_materials.m_EpoxyBoard.m_Ambient = SFVEC3F( 117.0f / 255.0f, 97.0f / 255.0f,
257 47.0f / 255.0f );
258
259 m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f, 3.0f / 255.0f,
260 20.0f / 255.0f );
261
262 m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
263 m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
264 }
265 else // Technical Mode
266 {
267 const SFVEC3F matAmbientColor = SFVEC3F( 0.10f );
268 const SFVEC3F matSpecularColor = SFVEC3F( 0.10f );
269 const float matShininess = 0.1f * 128.0f;
270
271 // Copper material
272 m_materials.m_Copper.m_Ambient = matAmbientColor;
273 m_materials.m_Copper.m_Specular = matSpecularColor;
274 m_materials.m_Copper.m_Shininess = matShininess;
275 m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
276
277 // Paste material
278 m_materials.m_Paste.m_Ambient = matAmbientColor;
279 m_materials.m_Paste.m_Specular = matSpecularColor;
280 m_materials.m_Paste.m_Shininess = matShininess;
281 m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
282
283 // Silk screen material
284 m_materials.m_SilkSTop.m_Ambient = matAmbientColor;
285 m_materials.m_SilkSTop.m_Specular = matSpecularColor;
286 m_materials.m_SilkSTop.m_Shininess = matShininess;
287 m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
288
289 // Silk screen material
290 m_materials.m_SilkSBot.m_Ambient = matAmbientColor;
291 m_materials.m_SilkSBot.m_Specular = matSpecularColor;
292 m_materials.m_SilkSBot.m_Shininess = matShininess;
293 m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
294
295 // Solder mask material
296 m_materials.m_SolderMask.m_Ambient = matAmbientColor;
297 m_materials.m_SolderMask.m_Specular = matSpecularColor;
298 m_materials.m_SolderMask.m_Shininess = matShininess;
299 m_materials.m_SolderMask.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
300
301 // Epoxy material
302 m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
303 m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
304 m_materials.m_EpoxyBoard.m_Shininess = matShininess;
305 m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
306
307 // Gray material (used for example in technical vias and pad holes)
308 m_materials.m_GrayMaterial.m_Ambient = SFVEC3F( 0.8f, 0.8f, 0.8f );
309 m_materials.m_GrayMaterial.m_Diffuse = SFVEC3F( 0.3f, 0.3f, 0.3f );
310 m_materials.m_GrayMaterial.m_Specular = SFVEC3F( 0.4f, 0.4f, 0.4f );
311 m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
312 m_materials.m_GrayMaterial.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
313 }
314}
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
Definition: 3d_math.h:133

References RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_Cfg, BOARD_ADAPTER::m_CopperColor, m_materials, EDA_3D_VIEWER_SETTINGS::m_Render, BOARD_ADAPTER::m_SilkScreenColorBot, BOARD_ADAPTER::m_SilkScreenColorTop, BOARD_ADAPTER::m_SolderPasteColor, mapf(), and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic.

Referenced by Redraw().

◆ unsetDepthOffset()

void RENDER_3D_OPENGL::unsetDepthOffset ( )
private

Definition at line 512 of file render_3d_opengl.cpp.

513{
514 glDisable( GL_POLYGON_OFFSET_FILL );
515}

Referenced by Redraw().

Member Data Documentation

◆ m_3dModelMap

std::map< wxString, MODEL_3D* > RENDER_3D_OPENGL::m_3dModelMap
private

◆ m_3dModelMatrixMap

std::map< std::vector<double>, glm::mat4 > RENDER_3D_OPENGL::m_3dModelMatrixMap
private

Definition at line 213 of file render_3d_opengl.h.

Referenced by freeAllLists(), and renderFootprint().

◆ m_antiBoard

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_antiBoard
private

Definition at line 197 of file render_3d_opengl.h.

Referenced by freeAllLists(), Redraw(), reload(), and RENDER_3D_OPENGL().

◆ m_antiBoardPolys

SHAPE_POLY_SET RENDER_3D_OPENGL::m_antiBoardPolys
private

The negative polygon representation of the board outline.

Definition at line 217 of file render_3d_opengl.h.

Referenced by generateViasAndPads(), and reload().

◆ m_board

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_board
private

◆ m_boardAdapter

◆ m_boardWithHoles

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_boardWithHoles
private

Definition at line 196 of file render_3d_opengl.h.

Referenced by freeAllLists(), reload(), RENDER_3D_OPENGL(), and renderBoardBody().

◆ m_busyIndicatorFactory

BUSY_INDICATOR::FACTORY RENDER_3D_BASE::m_busyIndicatorFactory
privateinherited

< Factory that returns a suitable busy indicator for the context.

Definition at line 128 of file render_3d_base.h.

Referenced by RENDER_3D_BASE::CreateBusyIndicator(), and RENDER_3D_BASE::SetBusyIndicatorFactory().

◆ m_camera

CAMERA& RENDER_3D_BASE::m_camera
protectedinherited

Flag if the opengl specific for this render was already initialized.

Definition at line 107 of file render_3d_base.h.

Referenced by Redraw(), RENDER_3D_RAYTRACE::Redraw(), reload(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_RAYTRACE::render(), render3dArrows(), RENDER_3D_RAYTRACE::renderBlockTracing(), and renderSolderMaskLayer().

◆ m_canvas

EDA_3D_CANVAS* RENDER_3D_BASE::m_canvas
protectedinherited

Settings reference in use for this render.

Definition at line 102 of file render_3d_base.h.

Referenced by Load3dModelsIfNeeded(), and RENDER_3D_BASE::RENDER_3D_BASE().

◆ m_circleTexture

◆ m_Copper

SMATERIAL RENDER_3D_OPENGL::m_Copper

Definition at line 185 of file render_3d_opengl.h.

◆ m_currentRollOverItem

BOARD_ITEM* RENDER_3D_OPENGL::m_currentRollOverItem
private

◆ m_EpoxyBoard

SMATERIAL RENDER_3D_OPENGL::m_EpoxyBoard

Definition at line 183 of file render_3d_opengl.h.

◆ m_GrayMaterial

SMATERIAL RENDER_3D_OPENGL::m_GrayMaterial

Definition at line 187 of file render_3d_opengl.h.

◆ m_grid

GLuint RENDER_3D_OPENGL::m_grid
private

oGL list that stores current grid

Definition at line 205 of file render_3d_opengl.h.

Referenced by freeAllLists(), generate3dGrid(), Redraw(), and RENDER_3D_OPENGL().

◆ m_innerLayerHoles

MAP_OGL_DISP_LISTS RENDER_3D_OPENGL::m_innerLayerHoles
private

Definition at line 194 of file render_3d_opengl.h.

Referenced by freeAllLists(), reload(), and RENDER_3D_OPENGL().

◆ m_is_opengl_initialized

bool RENDER_3D_BASE::m_is_opengl_initialized
protectedinherited
Todo:
This must be reviewed in order to flag change types.

Definition at line 110 of file render_3d_base.h.

Referenced by initializeOpenGL(), RENDER_3D_RAYTRACE::initializeOpenGL(), Redraw(), RENDER_3D_RAYTRACE::Redraw(), and RENDER_3D_BASE::RENDER_3D_BASE().

◆ m_lastGridType

GRID3D_TYPE RENDER_3D_OPENGL::m_lastGridType
private

Stores the last grid type.

Definition at line 206 of file render_3d_opengl.h.

Referenced by Redraw(), and RENDER_3D_OPENGL().

◆ m_layers

MAP_OGL_DISP_LISTS RENDER_3D_OPENGL::m_layers
private

◆ 

struct { ... } RENDER_3D_OPENGL::m_materials

◆ m_NonPlatedCopper

SMATERIAL RENDER_3D_OPENGL::m_NonPlatedCopper

Definition at line 184 of file render_3d_opengl.h.

◆ m_outerLayerHoles

MAP_OGL_DISP_LISTS RENDER_3D_OPENGL::m_outerLayerHoles
private

Definition at line 193 of file render_3d_opengl.h.

Referenced by freeAllLists(), Redraw(), reload(), and RENDER_3D_OPENGL().

◆ m_outerThroughHoleRings

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_outerThroughHoleRings
private

Definition at line 200 of file render_3d_opengl.h.

Referenced by freeAllLists(), Redraw(), reload(), and RENDER_3D_OPENGL().

◆ m_outerThroughHoles

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_outerThroughHoles
private

Definition at line 198 of file render_3d_opengl.h.

Referenced by freeAllLists(), Redraw(), reload(), and RENDER_3D_OPENGL().

◆ m_outerViaThroughHoles

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_outerViaThroughHoles
private

Definition at line 199 of file render_3d_opengl.h.

Referenced by freeAllLists(), reload(), RENDER_3D_OPENGL(), and renderSolderMaskLayer().

◆ m_padHoles

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_padHoles
private

Definition at line 209 of file render_3d_opengl.h.

Referenced by freeAllLists(), generateViasAndPads(), Redraw(), and RENDER_3D_OPENGL().

◆ m_Paste

SMATERIAL RENDER_3D_OPENGL::m_Paste

Definition at line 179 of file render_3d_opengl.h.

◆ m_Plastic

SMATERIAL RENDER_3D_OPENGL::m_Plastic

Definition at line 186 of file render_3d_opengl.h.

◆ m_platedPadsBack

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_platedPadsBack
private

Definition at line 192 of file render_3d_opengl.h.

Referenced by freeAllLists(), Redraw(), reload(), and RENDER_3D_OPENGL().

◆ m_platedPadsFront

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_platedPadsFront
private

Definition at line 191 of file render_3d_opengl.h.

Referenced by freeAllLists(), Redraw(), reload(), and RENDER_3D_OPENGL().

◆ m_reloadRequested

bool RENDER_3D_BASE::m_reloadRequested
protectedinherited

◆ m_SilkSBot

SMATERIAL RENDER_3D_OPENGL::m_SilkSBot

Definition at line 180 of file render_3d_opengl.h.

◆ m_SilkSTop

SMATERIAL RENDER_3D_OPENGL::m_SilkSTop

Definition at line 181 of file render_3d_opengl.h.

◆ m_SolderMask

SMATERIAL RENDER_3D_OPENGL::m_SolderMask

Definition at line 182 of file render_3d_opengl.h.

◆ m_triangles

LIST_TRIANGLES RENDER_3D_OPENGL::m_triangles
private

store pointers so can be deleted latter

Definition at line 202 of file render_3d_opengl.h.

Referenced by freeAllLists(), generateEmptyLayerList(), generateLayerList(), and RENDER_3D_OPENGL().

◆ m_vias

OPENGL_RENDER_LIST* RENDER_3D_OPENGL::m_vias
private

Definition at line 208 of file render_3d_opengl.h.

Referenced by freeAllLists(), generateViasAndPads(), Redraw(), and RENDER_3D_OPENGL().

◆ m_windowSize


The documentation for this class was generated from the following files: