KiCad PCB EDA Suite
RENDER_3D_LEGACY Class Reference

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

#include <render_3d_legacy.h>

Inheritance diagram for RENDER_3D_LEGACY:
RENDER_3D_BASE

Public Member Functions

 RENDER_3D_LEGACY (EDA_3D_CANVAS *aCanvas, BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
 
 ~RENDER_3D_LEGACY ()
 
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)
 
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
 
MAP_3DMODEL m_3dModelMap
 
BOARD_ITEMm_currentRollOverItem
 
SHAPE_POLY_SET m_antiBoardPolys
 The negative polygon representation of the board outline. More...
 

Detailed Description

Object to render the board using openGL legacy mode.

Definition at line 58 of file render_3d_legacy.h.

Constructor & Destructor Documentation

◆ RENDER_3D_LEGACY()

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

Definition at line 42 of file render_3d_legacy.cpp.

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

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_LEGACY()

RENDER_3D_LEGACY::~RENDER_3D_LEGACY ( )

Definition at line 73 of file render_3d_legacy.cpp.

74 {
75  wxLogTrace( m_logTrace, wxT( "RENDER_3D_LEGACY::~RENDER_3D_LEGACY" ) );
76 
77  freeAllLists();
78 
79  glDeleteTextures( 1, &m_circleTexture );
80 }
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.

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

Member Function Documentation

◆ addObjectTriangles() [1/5]

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

Definition at line 115 of file legacy/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 }
BOARD_ADAPTER & m_boardAdapter
float GetInnerRadius() const
Definition: ring_2d.h:47
TRIANGLE_LIST * m_layer_top_triangles
float GetOuterRadius() const
Definition: ring_2d.h:48
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)
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
TRIANGLE_LIST * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
const SFVEC2F & GetCenter() const
Definition: ring_2d.h:46
unsigned int GetCircleSegmentCount(float aDiameter3DU) const

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() [2/5]

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

Definition at line 67 of file legacy/create_scene.cpp.

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

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

◆ addObjectTriangles() [3/5]

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

Definition at line 37 of file legacy/create_scene.cpp.

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

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() [4/5]

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

Definition at line 150 of file legacy/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 }
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
const SFVEC2F & GetP1() const
Definition: triangle_2d.h:44
const SFVEC2F & GetP2() const
Definition: triangle_2d.h:45
void addTopAndBottomTriangles(TRIANGLE_DISPLAY_LIST *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
const SFVEC2F & GetP3() const
Definition: triangle_2d.h:46

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

◆ addObjectTriangles() [5/5]

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

Definition at line 162 of file legacy/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 }
float GetRadiusSquared() const
float GetRadius() const
TRIANGLE_LIST * m_layer_top_triangles
#define SIZE_OF_CIRCLE_TEXTURE
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
const SFVEC2F & GetLeftEnd() const
const SFVEC2F & GetEnd() const
const SFVEC2F & GetLeftStar() const
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
const SFVEC2F & GetRightDir() const
TRIANGLE_LIST * m_layer_bot_triangles
const SFVEC2F & GetLeftDir() const
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
const SFVEC2F & GetRightEnd() const
TRIANGLE_LIST * m_layer_bot_segment_ends
const SFVEC2F & GetStart() const
TRIANGLE_LIST * m_layer_top_segment_ends
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.

◆ addTopAndBottomTriangles()

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

Definition at line 665 of file legacy/create_scene.cpp.

668 {
669  aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
670  SFVEC3F( v1.x, v1.y, bot ),
671  SFVEC3F( v2.x, v2.y, bot ) );
672 
673  aDst->m_layer_top_triangles->AddTriangle( SFVEC3F( v2.x, v2.y, top ),
674  SFVEC3F( v1.x, v1.y, top ),
675  SFVEC3F( v0.x, v0.y, top ) );
676 }
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
TRIANGLE_LIST * m_layer_top_triangles
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
TRIANGLE_LIST * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44

References TRIANGLE_LIST::AddTriangle(), TRIANGLE_DISPLAY_LIST::m_layer_bot_triangles, TRIANGLE_DISPLAY_LIST::m_layer_top_triangles, v2, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by addObjectTriangles(), createBoard(), and generateViasAndPads().

◆ createBoard()

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

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

380 {
381  OPENGL_RENDER_LIST* dispLists = nullptr;
382  CONTAINER_2D boardContainer;
383  SHAPE_POLY_SET brd_outlines = aBoardPoly;
384 
385  ConvertPolygonToTriangles( brd_outlines, boardContainer, m_boardAdapter.BiuTo3dUnits(),
386  (const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
387 
388  const LIST_OBJECT2D& listBoardObject2d = boardContainer.GetList();
389 
390  if( listBoardObject2d.size() > 0 )
391  {
392  // We will set a unitary Z so it will in future used with transformations
393  // since the board poly will be used not only to draw itself but also the
394  // solder mask layers.
395  const float layer_z_top = 1.0f;
396  const float layer_z_bot = 0.0f;
397 
398  TRIANGLE_DISPLAY_LIST* layerTriangles =
399  new TRIANGLE_DISPLAY_LIST( listBoardObject2d.size() );
400 
401  // Convert the list of objects(triangles) to triangle layer structure
402  for( const OBJECT_2D* itemOnLayer : listBoardObject2d )
403  {
404  const OBJECT_2D* object2d_A = itemOnLayer;
405 
406  wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
407 
408  const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
409 
410  const SFVEC2F& v1 = tri->GetP1();
411  const SFVEC2F& v2 = tri->GetP2();
412  const SFVEC2F& v3 = tri->GetP3();
413 
414  addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
415  }
416 
417  if( aBoardPoly.OutlineCount() > 0 )
418  {
419  layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top,
420  m_boardAdapter.BiuTo3dUnits(), false,
421  aThroughHoles );
422 
423  dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
424  layer_z_top, layer_z_top );
425  }
426 
427  delete layerTriangles;
428  }
429 
430  return dispLists;
431 }
BOARD_ADAPTER & m_boardAdapter
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Store arrays of triangles to be used to create display lists.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void addTopAndBottomTriangles(TRIANGLE_DISPLAY_LIST *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
const LIST_OBJECT2D & GetList() const
Definition: container_2d.h:66
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
Represent a set of closed polygons.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
const BOARD * GetBoard() const noexcept
Get current board to be rendered.
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OBJECT_2D_TYPE GetObjectType() const
Definition: object_2d.h:107
Store the OpenGL display lists to related with a layer.
std::list< OBJECT_2D * > LIST_OBJECT2D
Definition: container_2d.h:36

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

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 disply the scene

Definition at line 70 of file render_3d_base.cpp.

71 {
72  std::unique_ptr<BUSY_INDICATOR> busy;
73 
75  busy = m_busyIndicatorFactory();
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_LEGACY::freeAllLists ( )
private

Definition at line 1038 of file render_3d_legacy.cpp.

1039 {
1040  if( glIsList( m_grid ) )
1041  glDeleteLists( m_grid, 1 );
1042 
1043  m_grid = 0;
1044 
1045  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii )
1046  {
1047  OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
1048  delete pLayerDispList;
1049  }
1050 
1051  m_layers.clear();
1052 
1053  delete m_platedPadsFront;
1054  m_platedPadsFront = nullptr;
1055 
1056  delete m_platedPadsBack;
1057  m_platedPadsBack = nullptr;
1058 
1059  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_outerLayerHoles.begin();
1060  ii != m_outerLayerHoles.end();
1061  ++ii )
1062  {
1063  OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
1064  delete pLayerDispList;
1065  }
1066 
1067  m_outerLayerHoles.clear();
1068 
1069  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_innerLayerHoles.begin();
1070  ii != m_innerLayerHoles.end();
1071  ++ii )
1072  {
1073  OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
1074  delete pLayerDispList;
1075  }
1076 
1077  m_innerLayerHoles.clear();
1078 
1079  for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin(); ii != m_triangles.end(); ++ii )
1080  {
1081  delete *ii;
1082  }
1083 
1084  m_triangles.clear();
1085 
1086  for( MAP_3DMODEL::const_iterator ii = m_3dModelMap.begin(); ii != m_3dModelMap.end(); ++ii )
1087  {
1088  MODEL_3D* pointer = static_cast<MODEL_3D*>(ii->second);
1089  delete pointer;
1090  }
1091 
1092  m_3dModelMap.clear();
1093 
1094  delete m_board;
1095  m_board = nullptr;
1096 
1097  delete m_boardWithHoles;
1098  m_boardWithHoles = nullptr;
1099 
1100  delete m_antiBoard;
1101  m_antiBoard = nullptr;
1102 
1103  delete m_outerThroughHoles;
1104  m_outerThroughHoles = nullptr;
1105 
1106  delete m_outerViaThroughHoles;
1107  m_outerViaThroughHoles = nullptr;
1108 
1109  delete m_outerThroughHoleRings;
1110  m_outerThroughHoleRings = nullptr;
1111 
1112  delete m_vias;
1113  m_vias = nullptr;
1114 
1115  delete m_padHoles;
1116  m_padHoles = nullptr;
1117 }
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
MAP_OGL_DISP_LISTS m_layers
OPENGL_RENDER_LIST * m_platedPadsFront
MAP_3DMODEL m_3dModelMap
OPENGL_RENDER_LIST * m_outerThroughHoles
OPENGL_RENDER_LIST * m_outerThroughHoleRings
OPENGL_RENDER_LIST * m_boardWithHoles
MAP_OGL_DISP_LISTS m_outerLayerHoles
OPENGL_RENDER_LIST * m_antiBoard
OPENGL_RENDER_LIST * m_board
Store the OpenGL display lists to related with a layer.
GLuint m_grid
oGL list that stores current grid
OPENGL_RENDER_LIST * m_platedPadsBack
MAP_OGL_DISP_LISTS m_innerLayerHoles
OPENGL_RENDER_LIST * m_vias
OPENGL_RENDER_LIST * m_padHoles
OPENGL_RENDER_LIST * m_outerViaThroughHoles

References m_3dModelMap, 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_LEGACY().

◆ generate3dGrid()

void RENDER_3D_LEGACY::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 1327 of file render_3d_legacy.cpp.

1328 {
1329  if( glIsList( m_grid ) )
1330  glDeleteLists( m_grid, 1 );
1331 
1332  m_grid = 0;
1333 
1334  if( aGridType == GRID3D_TYPE::NONE )
1335  return;
1336 
1337  m_grid = glGenLists( 1 );
1338 
1339  if( !glIsList( m_grid ) )
1340  return;
1341 
1342  glNewList( m_grid, GL_COMPILE );
1343 
1344  glEnable( GL_BLEND );
1345  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1346 
1347  const double zpos = 0.0;
1348 
1349  // Color of grid lines
1350  const SFVEC3F gridColor = m_boardAdapter.GetColor( DARKGRAY );
1351 
1352  // Color of grid lines every 5 lines
1353  const SFVEC3F gridColor_marker = m_boardAdapter.GetColor( LIGHTBLUE );
1354  const double scale = m_boardAdapter.BiuTo3dUnits();
1355  const GLfloat transparency = 0.35f;
1356 
1357  double griSizeMM = 0.0;
1358 
1359  switch( aGridType )
1360  {
1361  default:
1362  case GRID3D_TYPE::NONE:
1363  return;
1364  case GRID3D_TYPE::GRID_1MM:
1365  griSizeMM = 1.0;
1366  break;
1368  griSizeMM = 2.5;
1369  break;
1370  case GRID3D_TYPE::GRID_5MM:
1371  griSizeMM = 5.0;
1372  break;
1374  griSizeMM = 10.0;
1375  break;
1376  }
1377 
1378  glNormal3f( 0.0, 0.0, 1.0 );
1379 
1380  const wxSize brd_size = m_boardAdapter.GetBoardSize();
1381  wxPoint brd_center_pos = m_boardAdapter.GetBoardPos();
1382 
1383  brd_center_pos.y = -brd_center_pos.y;
1384 
1385  const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
1386  const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
1387 
1388  // Grid limits, in 3D units
1389  double xmin = ( brd_center_pos.x - xsize / 2 ) * scale;
1390  double xmax = ( brd_center_pos.x + xsize / 2 ) * scale;
1391  double ymin = ( brd_center_pos.y - ysize / 2 ) * scale;
1392  double ymax = ( brd_center_pos.y + ysize / 2 ) * scale;
1393  double zmin = Millimeter2iu( -50 ) * scale;
1394  double zmax = Millimeter2iu( 100 ) * scale;
1395 
1396  // Set rasterised line width (min value = 1)
1397  glLineWidth( 1 );
1398 
1399  // Draw horizontal grid centered on 3D origin (center of the board)
1400  for( int ii = 0; ; ii++ )
1401  {
1402  if( (ii % 5) )
1403  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1404  else
1405  glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1406  transparency );
1407 
1408  const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
1409 
1410  if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1411  {
1412  glBegin( GL_LINES );
1413  glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1414  glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1415  glEnd();
1416 
1417  if( ii != 0 )
1418  {
1419  glBegin( GL_LINES );
1420  glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1421  glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1422  glEnd();
1423  }
1424  }
1425 
1426  if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1427  {
1428  glBegin( GL_LINES );
1429  glVertex3f( xmin, -( brd_center_pos.y + delta ) * scale, zpos );
1430  glVertex3f( xmax, -( brd_center_pos.y + delta ) * scale, zpos );
1431  glEnd();
1432 
1433  if( ii != 0 )
1434  {
1435  glBegin( GL_LINES );
1436  glVertex3f( xmin, -( brd_center_pos.y - delta ) * scale, zpos );
1437  glVertex3f( xmax, -( brd_center_pos.y - delta ) * scale, zpos );
1438  glEnd();
1439  }
1440  }
1441 
1442  if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1443  break;
1444  }
1445 
1446  // Draw vertical grid on Z axis
1447  glNormal3f( 0.0, -1.0, 0.0 );
1448 
1449  // Draw vertical grid lines (parallel to Z axis)
1450  double posy = -brd_center_pos.y * scale;
1451 
1452  for( int ii = 0; ; ii++ )
1453  {
1454  if( (ii % 5) )
1455  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1456  else
1457  glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1458  transparency );
1459 
1460  const double delta = ii * griSizeMM * IU_PER_MM;
1461 
1462  glBegin( GL_LINES );
1463  xmax = ( brd_center_pos.x + delta ) * scale;
1464 
1465  glVertex3f( xmax, posy, zmin );
1466  glVertex3f( xmax, posy, zmax );
1467  glEnd();
1468 
1469  if( ii != 0 )
1470  {
1471  glBegin( GL_LINES );
1472  xmin = ( brd_center_pos.x - delta ) * scale;
1473  glVertex3f( xmin, posy, zmin );
1474  glVertex3f( xmin, posy, zmax );
1475  glEnd();
1476  }
1477 
1478  if( delta > xsize / 2.0f )
1479  break;
1480  }
1481 
1482  // Draw horizontal grid lines on Z axis (parallel to X axis)
1483  for( int ii = 0; ; ii++ )
1484  {
1485  if( ii % 5 )
1486  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1487  else
1488  glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
1489 
1490  const double delta = ii * griSizeMM * IU_PER_MM * scale;
1491 
1492  if( delta <= zmax )
1493  {
1494  // Draw grid lines on Z axis (positive Z axis coordinates)
1495  glBegin( GL_LINES );
1496  glVertex3f( xmin, posy, delta );
1497  glVertex3f( xmax, posy, delta );
1498  glEnd();
1499  }
1500 
1501  if( delta <= -zmin && ( ii != 0 ) )
1502  {
1503  // Draw grid lines on Z axis (negative Z axis coordinates)
1504  glBegin( GL_LINES );
1505  glVertex3f( xmin, posy, -delta );
1506  glVertex3f( xmax, posy, -delta );
1507  glEnd();
1508  }
1509 
1510  if( ( delta > zmax ) && ( delta > -zmin ) )
1511  break;
1512  }
1513 
1514  glDisable( GL_BLEND );
1515 
1516  glEndList();
1517 }
BOARD_ADAPTER & m_boardAdapter
static constexpr double IU_PER_MM
Mock up a conversion function.
SFVEC4F GetColor(const COLOR4D &aColor) const
wxPoint GetBoardPos() const noexcept
Get the board center.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
const int scale
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
GLuint m_grid
oGL list that stores current grid
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:73
constexpr int delta
static constexpr int Millimeter2iu(double mm)
wxSize GetBoardSize() const noexcept
Get the board size.

References BOARD_ADAPTER::BiuTo3dUnits(), DARKGRAY, delta, BOARD_ADAPTER::GetBoardPos(), BOARD_ADAPTER::GetBoardSize(), BOARD_ADAPTER::GetColor(), GRID_10MM, GRID_1MM, GRID_2P5MM, GRID_5MM, IU_PER_MM, KiROUND(), LIGHTBLUE, RENDER_3D_BASE::m_boardAdapter, m_grid, Millimeter2iu(), NONE, and scale.

Referenced by Redraw().

◆ generateCylinder()

void RENDER_3D_LEGACY::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 694 of file legacy/create_scene.cpp.

698 {
699  std::vector< SFVEC2F > innerContour;
700  std::vector< SFVEC2F > outerContour;
701 
702  generateRing( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle, innerContour,
703  outerContour, false );
704 
705  for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
706  {
707  const SFVEC2F& vi0 = innerContour[i + 0];
708  const SFVEC2F& vi1 = innerContour[i + 1];
709  const SFVEC2F& vo0 = outerContour[i + 0];
710  const SFVEC2F& vo1 = outerContour[i + 1];
711 
712  aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
713  SFVEC3F( vi0.x, vi0.y, aZtop ),
714  SFVEC3F( vo0.x, vo0.y, aZtop ),
715  SFVEC3F( vo1.x, vo1.y, aZtop ) );
716 
717  aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
718  SFVEC3F( vo1.x, vo1.y, aZbot ),
719  SFVEC3F( vo0.x, vo0.y, aZbot ),
720  SFVEC3F( vi0.x, vi0.y, aZbot ) );
721  }
722 
723  aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
724  aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
725 }
TRIANGLE_LIST * m_layer_top_triangles
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)
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
TRIANGLE_LIST * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44

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().

◆ generateHoles()

OPENGL_RENDER_LIST * RENDER_3D_LEGACY::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 legacy/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( "RENDER_3D_LEGACY::generateHoles: Object type is 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 }
BOARD_ADAPTER & m_boardAdapter
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Store arrays of triangles to be used to create display lists.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
void addObjectTriangles(const RING_2D *aRing, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OBJECT_2D_TYPE GetObjectType() const
Definition: object_2d.h:107
Store the OpenGL display lists to related with a layer.

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_LEGACY::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 legacy/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( "RENDER_3D_LEGACY: 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 }
BOARD_ADAPTER & m_boardAdapter
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Store arrays of triangles to be used to create display lists.
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
void getLayerZPos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
const LIST_OBJECT2D & GetList() const
Definition: container_2d.h:66
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
void addObjectTriangles(const RING_2D *aRing, TRIANGLE_DISPLAY_LIST *aDstLayer, float aZtop, float aZbot)
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OBJECT_2D_TYPE GetObjectType() const
Definition: object_2d.h:107
Store the OpenGL display lists to related with a layer.
std::list< OBJECT_2D * > LIST_OBJECT2D
Definition: container_2d.h:36

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_LEGACY::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 81 of file legacy/create_scene.cpp.

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

References PNS::angle(), and delta.

Referenced by addObjectTriangles(), and generateCylinder().

◆ generateViasAndPads()

void RENDER_3D_LEGACY::generateViasAndPads ( )
private

Definition at line 728 of file legacy/create_scene.cpp.

729 {
730  if( !m_boardAdapter.GetBoard() )
731  return;
732 
733  const int platingThickness = m_boardAdapter.GetHolePlatingThickness();
734  const float platingThickness3d = platingThickness * m_boardAdapter.BiuTo3dUnits();
735 
736  if( m_boardAdapter.GetViaCount() > 0 )
737  {
738  const unsigned int reserve_nr_triangles_estimation =
742 
743  TRIANGLE_DISPLAY_LIST* layerTriangleVIA =
744  new TRIANGLE_DISPLAY_LIST( reserve_nr_triangles_estimation );
745 
746  // Insert plated vertical holes inside the board
747 
748  // Insert vias holes (vertical cylinders)
749  for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
750  {
751  if( track->Type() == PCB_VIA_T )
752  {
753  const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
754 
755  const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
756  const int nrSegments = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
757  const float hole_inner_radius = holediameter / 2.0f;
758 
759  const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
760  -via->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
761 
762  PCB_LAYER_ID top_layer, bottom_layer;
763  via->LayerPair( &top_layer, &bottom_layer );
764 
765  float ztop, zbot, dummy;
766 
767  getLayerZPos( top_layer, ztop, dummy );
768  getLayerZPos( bottom_layer, dummy, zbot );
769 
770  wxASSERT( zbot < ztop );
771 
772  generateCylinder( via_center, hole_inner_radius,
773  hole_inner_radius + platingThickness3d,
774  ztop, zbot, nrSegments, layerTriangleVIA );
775  }
776  }
777 
778  m_vias = new OPENGL_RENDER_LIST( *layerTriangleVIA, 0, 0.0f, 0.0f );
779 
780  delete layerTriangleVIA;
781  }
782 
783 
784  if( m_boardAdapter.GetHoleCount() > 0 )
785  {
786  SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
787  SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
788 
789  tht_outer_holes_poly.RemoveAllContours();
790  tht_inner_holes_poly.RemoveAllContours();
791 
792  // Insert pads holes (vertical cylinders)
793  for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
794  {
795  for( const PAD* pad : footprint->Pads() )
796  {
797  if( pad->GetAttribute() != PAD_ATTRIB::NPTH )
798  {
799  const wxSize drillsize = pad->GetDrillSize();
800  const bool hasHole = drillsize.x && drillsize.y;
801 
802  if( !hasHole )
803  continue;
804 
805  pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly,
806  platingThickness,
807  ARC_HIGH_DEF, ERROR_INSIDE );
808  pad->TransformHoleWithClearanceToPolygon( tht_inner_holes_poly, 0,
809  ARC_HIGH_DEF, ERROR_INSIDE );
810  }
811  }
812  }
813 
814  // Subtract the holes
815  tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
816 
819 
820  CONTAINER_2D holesContainer;
821 
822  ConvertPolygonToTriangles( tht_outer_holes_poly, holesContainer,
824  (const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
825 
826  const LIST_OBJECT2D& listHolesObject2d = holesContainer.GetList();
827 
828  if( listHolesObject2d.size() > 0 )
829  {
830  float layer_z_top, layer_z_bot, dummy;
831 
832  getLayerZPos( F_Cu, layer_z_top, dummy );
833  getLayerZPos( B_Cu, dummy, layer_z_bot );
834 
835  TRIANGLE_DISPLAY_LIST* layerTriangles =
836  new TRIANGLE_DISPLAY_LIST( listHolesObject2d.size() );
837 
838  // Convert the list of objects(triangles) to triangle layer structure
839  for( const OBJECT_2D* itemOnLayer : listHolesObject2d )
840  {
841  const OBJECT_2D* object2d_A = itemOnLayer;
842 
843  wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
844 
845  const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
846 
847  const SFVEC2F& v1 = tri->GetP1();
848  const SFVEC2F& v2 = tri->GetP2();
849  const SFVEC2F& v3 = tri->GetP3();
850 
851  addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
852  }
853 
854  wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
855 
856  if( tht_outer_holes_poly.OutlineCount() > 0 )
857  {
858  layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
859  layer_z_bot, layer_z_top,
860  m_boardAdapter.BiuTo3dUnits(), false );
861 
862  m_padHoles = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
863  layer_z_top, layer_z_top );
864  }
865 
866  delete layerTriangles;
867  }
868  }
869 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Store arrays of triangles to be used to create display lists.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void addTopAndBottomTriangles(TRIANGLE_DISPLAY_LIST *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
void getLayerZPos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
void generateCylinder(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, TRIANGLE_DISPLAY_LIST *aDstLayer)
const LIST_OBJECT2D & GetList() const
Definition: container_2d.h:66
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
like PAD_PTH, but not plated
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
Represent a set of closed polygons.
FOOTPRINTS & Footprints()
Definition: board.h:233
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
const BOARD * GetBoard() const noexcept
Get current board to be rendered.
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
OBJECT_2D_TYPE GetObjectType() const
Definition: object_2d.h:107
Store the OpenGL display lists to related with a layer.
unsigned int GetViaCount() const noexcept
Get number of vias in this board.
unsigned int GetHoleCount() const noexcept
Get number of holes in this board.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
SHAPE_POLY_SET m_antiBoardPolys
The negative polygon representation of the board outline.
float GetAverageViaHoleDiameter() const noexcept
Thee average diameter of the via holes.
std::list< OBJECT_2D * > LIST_OBJECT2D
Definition: container_2d.h:36
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
Definition: pad.h:57
OPENGL_RENDER_LIST * m_vias
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
OPENGL_RENDER_LIST * m_padHoles
TRACKS & Tracks()
Definition: board.h:230
int GetHolePlatingThickness() const noexcept
Get the current copper layer thickness.

References TRIANGLE_DISPLAY_LIST::AddToMiddleContourns(), addTopAndBottomTriangles(), B_Cu, BOARD_ADAPTER::BiuTo3dUnits(), SHAPE_POLY_SET::BooleanSubtract(), ConvertPolygonToTriangles(), dummy(), ERROR_INSIDE, F_Cu, FL_USE_REALISTIC_MODE, BOARD::Footprints(), generateCylinder(), BOARD_ADAPTER::GetAverageViaHoleDiameter(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetCircleSegmentCount(), BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetHoleCount(), BOARD_ADAPTER::GetHolePlatingThickness(), getLayerZPos(), CONTAINER_2D_BASE::GetList(), OBJECT_2D::GetObjectType(), BOARD_ADAPTER::GetViaCount(), m_antiBoardPolys, RENDER_3D_BASE::m_boardAdapter, m_circleTexture, m_padHoles, m_vias, NPTH, SHAPE_POLY_SET::OutlineCount(), pad, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::RemoveAllContours(), BOARD::Tracks(), TRIANGLE, v2, and via.

Referenced by reload().

◆ getLayerColor()

SFVEC4F RENDER_3D_LEGACY::getLayerColor ( PCB_LAYER_ID  aLayerID)
private

Definition at line 393 of file render_3d_legacy.cpp.

394 {
395  SFVEC4F layerColor = m_boardAdapter.GetLayerColor( aLayerID );
396 
398  {
399  switch( aLayerID )
400  {
401  case B_Adhes:
402  case F_Adhes:
403  break;
404 
405  case B_Mask:
407  break;
408  case F_Mask:
410  break;
411 
412  case B_Paste:
413  case F_Paste:
414  layerColor = m_boardAdapter.m_SolderPasteColor;
415  break;
416 
417  case B_SilkS:
419  break;
420  case F_SilkS:
422  break;
423 
424  case Dwgs_User:
425  case Cmts_User:
426  case Eco1_User:
427  case Eco2_User:
428  case Edge_Cuts:
429  case Margin:
430  break;
431 
432  case B_CrtYd:
433  case F_CrtYd:
434  break;
435 
436  case B_Fab:
437  case F_Fab:
438  break;
439 
440  default:
441  layerColor = m_boardAdapter.m_CopperColor;
442  break;
443  }
444  }
445 
446  return layerColor;
447 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
SFVEC4F m_CopperColor
in realistic mode: copper color
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )

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, FL_USE_REALISTIC_MODE, BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetLayerColor(), RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_CopperColor, BOARD_ADAPTER::m_SilkScreenColorBot, BOARD_ADAPTER::m_SilkScreenColorTop, BOARD_ADAPTER::m_SolderMaskColorBot, BOARD_ADAPTER::m_SolderMaskColorTop, BOARD_ADAPTER::m_SolderPasteColor, and Margin.

Referenced by setLayerMaterial().

◆ getLayerZPos()

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

Definition at line 679 of file legacy/create_scene.cpp.

681 {
682  aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayerID );
683  aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayerID );
684 
685  if( aOutZtop < aOutZbot )
686  {
687  float tmpFloat = aOutZbot;
688  aOutZbot = aOutZtop;
689  aOutZtop = tmpFloat;
690  }
691 }
BOARD_ADAPTER & m_boardAdapter
float GetLayerTopZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the top z position.
float GetLayerBottomZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the bottom z position.

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

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

◆ GetWaitForEditingTimeOut()

int RENDER_3D_LEGACY::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 83 of file render_3d_legacy.cpp.

84 {
85  return 50; // ms
86 }

◆ initializeOpenGL()

bool RENDER_3D_LEGACY::initializeOpenGL ( )
private

Definition at line 976 of file render_3d_legacy.cpp.

977 {
978  glEnable( GL_LINE_SMOOTH );
979  glShadeModel( GL_SMOOTH );
980 
981  // 4-byte pixel alignment
982  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
983 
984  // Initialize the open GL texture to draw the filled semi-circle of the segments
986 
987  if( !circleImage )
988  return false;
989 
990  unsigned int circleRadius = ( SIZE_OF_CIRCLE_TEXTURE / 2 ) - 4;
991 
992  circleImage->CircleFilled( ( SIZE_OF_CIRCLE_TEXTURE / 2 ) - 0,
993  ( SIZE_OF_CIRCLE_TEXTURE / 2 ) - 0,
994  circleRadius,
995  0xFF );
996 
997  IMAGE* circleImageBlured = new IMAGE( circleImage->GetWidth(), circleImage->GetHeight() );
998 
999  circleImageBlured->EfxFilter_SkipCenter( circleImage, IMAGE_FILTER::GAUSSIAN_BLUR, circleRadius - 8 );
1000 
1001  m_circleTexture = OglLoadTexture( *circleImageBlured );
1002 
1003  delete circleImageBlured;
1004  circleImageBlured = nullptr;
1005 
1006  delete circleImage;
1007  circleImage = nullptr;
1008 
1009  init_lights();
1010 
1011  // Use this mode if you want see the triangle lines (debug proposes)
1012  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
1013  m_is_opengl_initialized = true;
1014 
1015  return true;
1016 }
void init_lights(void)
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
#define SIZE_OF_CIRCLE_TEXTURE
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
Definition: image.cpp:173
bool m_is_opengl_initialized
unsigned int GetHeight() const
Definition: image.h:214
Manage an 8-bit channel image.
Definition: image.h:89
unsigned int GetWidth() const
Definition: image.h:213
GLuint OglLoadTexture(const IMAGE &aImage)
Generate a new OpenGL texture.
Definition: ogl_utils.cpp:71

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_LEGACY::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 890 of file legacy/create_scene.cpp.

891 {
892  if( !m_boardAdapter.GetBoard() )
893  return;
894 
898  {
899  return;
900  }
901 
902  // Go for all footprints
903  for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
904  {
905  for( const FP_3DMODEL& model : footprint->Models() )
906  {
907  if( model.m_Show && !model.m_Filename.empty() )
908  {
909  if( aStatusReporter )
910  {
911  // Display the short filename of the 3D model loaded:
912  // (the full name is usually too long to be displayed)
913  wxFileName fn( model.m_Filename );
914  aStatusReporter->Report( wxString::Format( _( "Loading %s..." ),
915  fn.GetFullName() ) );
916  }
917 
918  // Check if the model is not present in our cache map
919  // (Not already loaded in memory)
920  if( m_3dModelMap.find( model.m_Filename ) == m_3dModelMap.end() )
921  {
922  // It is not present, try get it from cache
923  const S3DMODEL* modelPtr =
924  m_boardAdapter.Get3dCacheManager()->GetModel( model.m_Filename );
925 
926  // only add it if the return is not NULL
927  if( modelPtr )
928  {
930  MODEL_3D* ogl_model = new MODEL_3D( *modelPtr, materialMode );
931 
932  if( ogl_model )
933  m_3dModelMap[ model.m_Filename ] = ogl_model;
934  }
935  }
936  }
937  }
938  }
939 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
MAP_3DMODEL m_3dModelMap
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
S3DMODEL * GetModel(const wxString &aModelFileName)
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for displa...
Definition: 3d_cache.cpp:643
S3D_CACHE * Get3dCacheManager() const noexcept
Return the 3D cache manager pointer.
Definition: board_adapter.h:88
FOOTPRINTS & Footprints()
Definition: board.h:233
MATERIAL_MODE GetMaterialMode() const noexcept
const BOARD * GetBoard() const noexcept
Get current board to be rendered.
#define _(s)
MATERIAL_MODE
Render 3d model shape materials mode.
Definition: 3d_enums.h:118
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:90

References _, FL_FP_ATTRIBUTES_NORMAL, FL_FP_ATTRIBUTES_NORMAL_INSERT, FL_FP_ATTRIBUTES_VIRTUAL, BOARD::Footprints(), Format(), BOARD_ADAPTER::Get3dCacheManager(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetMaterialMode(), S3D_CACHE::GetModel(), m_3dModelMap, RENDER_3D_BASE::m_boardAdapter, and REPORTER::Report().

Referenced by Load3dModelsIfNeeded(), and reload().

◆ Load3dModelsIfNeeded()

void RENDER_3D_LEGACY::Load3dModelsIfNeeded ( )

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

if m_3dModelMap is empty

Definition at line 872 of file legacy/create_scene.cpp.

873 {
874  if( m_3dModelMap.size() > 0 )
875  return;
876 
877  wxFrame* frame = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_canvas->GetParent() );
878 
879  if( frame )
880  {
881  STATUSBAR_REPORTER activityReporter( frame->GetStatusBar(),
883  load3dModels( &activityReporter );
884  }
885  else
886  load3dModels( nullptr );
887 }
A wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:286
EDA_3D_CANVAS * m_canvas
Settings reference in use for this render.
MAP_3DMODEL m_3dModelMap
void load3dModels(REPORTER *aStatusReporter)
Load footprint models from the cache and load it to openGL lists in the form of MODEL_3D objects.

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

Referenced by EDA_3D_CONTROLLER::ToggleVisibility().

◆ Redraw()

bool RENDER_3D_LEGACY::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 545 of file render_3d_legacy.cpp.

547 {
548  // Initialize OpenGL
550  {
551  if( !initializeOpenGL() )
552  return false;
553  }
554 
555  if( m_reloadRequested )
556  {
557  std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
558 
559  if( aStatusReporter )
560  aStatusReporter->Report( _( "Loading..." ) );
561 
562  reload( aStatusReporter, aWarningReporter );
563 
564  // generate a new 3D grid as the size of the board may had changed
567  }
568  else
569  {
570  // Check if grid was changed
572  {
573  // and generate a new one
576  }
577  }
578 
579  setupMaterials();
580 
581  // Initial setup
582  glDepthFunc( GL_LESS );
583  glEnable( GL_CULL_FACE );
584  glFrontFace( GL_CCW ); // This is the OpenGL default
585  glEnable( GL_NORMALIZE ); // This allow OpenGL to normalize the normals after transformations
586  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
587 
589  glDisable( GL_MULTISAMPLE );
590  else
591  glEnable( GL_MULTISAMPLE );
592 
593  // clear color and depth buffers
594  glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
595  glClearDepth( 1.0f );
596  glClearStencil( 0x00 );
597  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
598 
600 
601  // Draw the background ( rectangle with color gradient)
604 
605  glEnable( GL_DEPTH_TEST );
606 
607  // Set projection and modelview matrixes
608  glMatrixMode( GL_PROJECTION );
609  glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) );
610  glMatrixMode( GL_MODELVIEW );
611  glLoadIdentity();
612  glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
613 
614  // Position the headlight
615  setLightFront( true );
616  setLightTop( true );
617  setLightBottom( true );
618 
619  glEnable( GL_LIGHTING );
620 
621  {
622  const SFVEC3F& cameraPos = m_camera.GetPos();
623 
624  // Place the light at a minimum Z so the diffuse factor will not drop
625  // and the board will still look with good light.
626  float zpos;
627 
628  if( cameraPos.z > 0.0f )
629  {
630  zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
631  }
632  else
633  {
634  zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
635  }
636 
637  // This is a point light.
638  const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
639 
640  glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
641  }
642 
643  const bool drawMiddleSegments = !( aIsMoving &&
645 
646  const bool skipRenderHoles = aIsMoving &&
648 
649  const bool skipRenderVias = aIsMoving &&
651 
653  {
654  // Draw vias and pad holes with copper material
656  }
657  else
658  {
659  OglSetMaterial( m_materials.m_GrayMaterial, 1.0f );
660  }
661 
662  if( !( skipRenderVias || skipRenderHoles ) && m_vias )
663  m_vias->DrawAll();
664 
665  if( !skipRenderHoles && m_padHoles )
666  m_padHoles->DrawAll();
667 
668  // Display copper and tech layers
669  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii )
670  {
671  const PCB_LAYER_ID layer_id = ( PCB_LAYER_ID )( ii->first );
672 
673  // Mask layers are not processed here because they are a special case
674  if( ( layer_id == B_Mask ) || ( layer_id == F_Mask ) )
675  continue;
676 
677  // Do not show inner layers when it is displaying the board and board body is opaque
678  // enough: the time to create inner layers can be *really significant*.
679  // So avoid creating them is they are not very visible
680  const double opacity_min = 0.8;
681 
683  ( m_boardAdapter.m_BoardBodyColor.a > opacity_min ) )
684  {
685  if( ( layer_id > F_Cu ) && ( layer_id < B_Cu ) )
686  continue;
687  }
688 
689  glPushMatrix();
690 
691  OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
692 
693  if( ( layer_id >= F_Cu ) && ( layer_id <= B_Cu ) )
694  {
698  setLayerMaterial( layer_id );
699  else
701 
702  if( skipRenderHoles )
703  {
704  pLayerDispList->DrawAllCameraCulled( m_camera.GetPos().z, drawMiddleSegments );
705 
706  // Draw copper plated pads
707  if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
709  setPlatedCopperAndDepthOffset( layer_id );
710 
711  if( layer_id == F_Cu && m_platedPadsFront )
712  {
714  drawMiddleSegments );
715  }
716  else if( layer_id == B_Cu && m_platedPadsBack )
717  {
719  drawMiddleSegments );
720  }
721 
723  }
724  else
725  {
726  if( m_outerThroughHoles )
727  {
728  m_outerThroughHoles->ApplyScalePosition( pLayerDispList->GetZBot(),
729  pLayerDispList->GetZTop()
730  - pLayerDispList->GetZBot() );
731  }
732 
733  if( m_antiBoard )
734  {
735  m_antiBoard->ApplyScalePosition( pLayerDispList->GetZBot(),
736  pLayerDispList->GetZTop()
737  - pLayerDispList->GetZBot() );
738  }
739 
740  if( m_outerLayerHoles.find( layer_id ) != m_outerLayerHoles.end() )
741  {
742  const OPENGL_RENDER_LIST* viasHolesLayer = m_outerLayerHoles.at( layer_id );
743 
744  wxASSERT( viasHolesLayer != nullptr );
745 
746  if( viasHolesLayer != nullptr )
747  {
748  pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
750  viasHolesLayer,
751  m_antiBoard );
752 
753  // Draw copper plated pads
754 
755  if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
757  {
758  setPlatedCopperAndDepthOffset( layer_id );
759  }
760 
761  if( layer_id == F_Cu && m_platedPadsFront )
762  {
764  drawMiddleSegments,
766  viasHolesLayer,
767  m_antiBoard );
768  }
769  else if( layer_id == B_Cu && m_platedPadsBack )
770  {
772  drawMiddleSegments,
774  viasHolesLayer,
775  m_antiBoard );
776  }
777 
779  }
780  }
781  else
782  {
783  pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
785  m_antiBoard );
786 
787  // Draw copper plated pads
788  if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
790  {
791  setPlatedCopperAndDepthOffset( layer_id );
792  }
793 
794  if( layer_id == F_Cu && m_platedPadsFront )
795  {
798  m_antiBoard );
799  }
800  else if( layer_id == B_Cu && m_platedPadsBack )
801  {
804  m_antiBoard );
805  }
806 
808  }
809  }
810  }
811  else
812  {
813  setLayerMaterial( layer_id );
814 
815  OPENGL_RENDER_LIST* throughHolesOuter =
818  && ( layer_id == B_SilkS || layer_id == F_SilkS )
821 
822  if( throughHolesOuter )
823  {
824  throughHolesOuter->ApplyScalePosition(
825  pLayerDispList->GetZBot(),
826  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
827  }
828 
829  OPENGL_RENDER_LIST* anti_board = m_antiBoard;
830 
831  if( ( layer_id == B_Paste ) || ( layer_id == F_Paste ) )
832  anti_board = nullptr;
833 
834  if( anti_board )
835  {
836  anti_board->ApplyScalePosition(
837  pLayerDispList->GetZBot(),
838  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
839  }
840 
841  if( !skipRenderHoles
844  && ( ( layer_id == B_SilkS && m_layers.find( B_Mask ) != m_layers.end() )
845  || ( layer_id == F_SilkS && m_layers.find( F_Mask ) != m_layers.end() ) ) )
846  {
847  const PCB_LAYER_ID layerMask_id = (layer_id == B_SilkS) ? B_Mask : F_Mask;
848 
849  const OPENGL_RENDER_LIST* pLayerDispListMask = m_layers.at( layerMask_id );
850 
851  pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
852  pLayerDispListMask,
853  throughHolesOuter, anti_board );
854  }
855  else
856  {
857  if( !skipRenderHoles && throughHolesOuter
858  && ( layer_id == B_SilkS || layer_id == F_SilkS ) )
859  {
860  pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, nullptr,
861  throughHolesOuter,
862  anti_board );
863  }
864  else
865  {
866  // Do not render Paste layers when skipRenderHoles is enabled
867  // otherwise it will cause z-fight issues
868  if( !( skipRenderHoles && ( layer_id == B_Paste || layer_id == F_Paste ) ) )
869  {
870  pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
871  anti_board );
872  }
873  }
874  }
875  }
876 
877  glPopMatrix();
878  }
879 
880  // Render 3D Models (Non-transparent)
881  render3dModels( false, false );
882  render3dModels( true, false );
883 
884  // Display board body
886  {
887  renderBoardBody( skipRenderHoles );
888  }
889 
890  // Display transparent mask layers
892  {
893  // add a depth buffer offset, it will help to hide some artifacts
894  // on silkscreen where the SolderMask is removed
895  glEnable( GL_POLYGON_OFFSET_FILL );
896  glPolygonOffset( 0.0f, -2.0f );
897 
898  if( m_camera.GetPos().z > 0 )
899  {
901  drawMiddleSegments, skipRenderHoles );
902 
904  drawMiddleSegments, skipRenderHoles );
905  }
906  else
907  {
909  drawMiddleSegments, skipRenderHoles );
910 
912  drawMiddleSegments, skipRenderHoles );
913  }
914 
915  glDisable( GL_POLYGON_OFFSET_FILL );
916  glPolygonOffset( 0.0f, 0.0f );
917  }
918 
919  // Render 3D Models (Transparent)
920  // !TODO: this can be optimized. If there are no transparent models (or no opacity),
921  // then there is no need to make this function call.
922  glDepthMask( GL_FALSE );
923  glEnable( GL_BLEND );
924  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
925 
926  // Enables Texture Env so it can combine model transparency with each footprint opacity
927  glEnable( GL_TEXTURE_2D );
928  glActiveTexture( GL_TEXTURE0 );
929 
930  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
931  glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
932  glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
933 
934  glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
935  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
936 
937  glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
938  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
939 
940  glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
941  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
942  glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
943  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_CONSTANT );
944 
945  render3dModels( false, true );
946  render3dModels( true, true );
947 
948  glDisable( GL_BLEND );
950 
951  glDepthMask( GL_TRUE );
952 
953  // Render Grid
955  {
956  glDisable( GL_LIGHTING );
957 
958  if( glIsList( m_grid ) )
959  glCallList( m_grid );
960 
961  glEnable( GL_LIGHTING );
962  }
963 
964  // Render 3D arrows
966  render3dArrows();
967 
968  // Return back to the original viewport (this is important if we want
969  // to take a screenshot after the render)
970  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
971 
972  return false;
973 }
GRID3D_TYPE GetGridType() const noexcept
Get the current grid.
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
void render3dModels(bool aRenderTopOrBot, bool aRenderTransparentOnly)
void reload(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
Definition: ogl_utils.cpp:119
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
float GetZBot() 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.
MAP_OGL_DISP_LISTS m_layers
const glm::mat4 & GetProjectionMatrix() const
Definition: camera.cpp:377
const SFVEC3F & GetPos() const
Definition: camera.h:109
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
OPENGL_RENDER_LIST * m_platedPadsFront
void setLightBottom(bool enabled)
void generate3dGrid(GRID3D_TYPE aGridType)
Create a 3D grid to an OpenGL display list.
void setPlatedCopperAndDepthOffset(PCB_LAYER_ID aLayer_id)
void OglResetTextureState()
Reset to default state the texture settings.
Definition: ogl_utils.cpp:189
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void setLayerMaterial(PCB_LAYER_ID aLayerID)
OPENGL_RENDER_LIST * m_outerThroughHoles
OPENGL_RENDER_LIST * m_outerThroughHoleRings
SFVEC4F m_BgColorTop
background top color
MAP_OGL_DISP_LISTS m_outerLayerHoles
OPENGL_RENDER_LIST * m_antiBoard
float GetLayerTopZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the top z position.
float GetLayerBottomZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the bottom z position.
const glm::mat4 & GetViewMatrix() const
Definition: camera.cpp:407
#define _(s)
SFVEC4F m_BgColorBot
background bottom color
void ApplyScalePosition(float aZposition, float aZscale)
GRID3D_TYPE m_lastGridType
Stores the last grid type.
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
bool m_is_opengl_initialized
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
Store the OpenGL display lists to related with a layer.
bool m_reloadRequested
The window size that this camera is working.
void renderBoardBody(bool aSkipRenderHoles)
void OglDrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
Definition: ogl_utils.cpp:160
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
GLuint m_grid
oGL list that stores current grid
Definition: layer_ids.h:71
void setLightFront(bool enabled)
void renderSolderMaskLayer(PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
float GetZTop() const
OPENGL_RENDER_LIST * m_platedPadsBack
OPENGL_RENDER_LIST * m_vias
void setLightTop(bool enabled)
OPENGL_RENDER_LIST * m_padHoles
struct RENDER_3D_LEGACY::@5 m_materials

References _, OPENGL_RENDER_LIST::ApplyScalePosition(), B_Cu, B_Mask, B_Paste, B_SilkS, RENDER_3D_BASE::CreateBusyIndicator(), OPENGL_RENDER_LIST::DrawAll(), OPENGL_RENDER_LIST::DrawAllCameraCulled(), OPENGL_RENDER_LIST::DrawAllCameraCulledSubtractLayer(), F_Cu, F_Mask, F_Paste, F_SilkS, FL_AXIS, FL_CLIP_SILK_ON_VIA_ANNULUS, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, FL_RENDER_PLATED_PADS_AS_PLATED, FL_SHOW_BOARD_BODY, FL_SOLDERMASK, FL_SUBTRACT_MASK_FROM_SILK, FL_USE_REALISTIC_MODE, generate3dGrid(), BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetGridType(), BOARD_ADAPTER::GetLayerBottomZPos(), BOARD_ADAPTER::GetLayerTopZPos(), CAMERA::GetPos(), CAMERA::GetProjectionMatrix(), CAMERA::GetViewMatrix(), OPENGL_RENDER_LIST::GetZBot(), OPENGL_RENDER_LIST::GetZTop(), 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, 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, m_vias, RENDER_3D_BASE::m_windowSize, NONE, OglDrawBackground(), OglResetTextureState(), OglSetMaterial(), reload(), render3dArrows(), render3dModels(), renderBoardBody(), renderSolderMaskLayer(), REPORTER::Report(), setCopperMaterial(), setLayerMaterial(), setLightBottom(), setLightFront(), setLightTop(), setPlatedCopperAndDepthOffset(), setupMaterials(), and unsetDepthOffset().

◆ reload()

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

Definition at line 434 of file legacy/create_scene.cpp.

435 {
436  m_reloadRequested = false;
437 
438  freeAllLists();
439 
441 
442  unsigned stats_startReloadTime = GetRunningMicroSecs();
443 
444  m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
445 
446  SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter();
447  m_camera.SetBoardLookAtPos( camera_pos );
448 
449  if( aStatusReporter )
450  aStatusReporter->Report( _( "Load OpenGL: board" ) );
451 
452  // Create Board
454 
456  {
459  m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
460  m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
461  m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
462  m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
463  m_antiBoardPolys.Outline( 0 ).SetClosed( true );
464 
468  }
469 
470  SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly();
471  board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
475 
476  m_boardWithHoles = createBoard( board_poly_with_holes );
477 
478  if( m_antiBoard )
480 
481  // Create Through Holes and vias
482  if( aStatusReporter )
483  aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
484 
486 
490 
492  outerPolyTHT, 1.0f, 0.0f, false,
494 
497  m_boardAdapter.GetThroughHoleViaOdPolys(), 1.0f, 0.0f, false );
498 
501  {
504  m_boardAdapter.GetThroughHoleAnnularRingPolys(), 1.0f, 0.0f, false );
505  }
506 
507  const MAP_POLY& innerMapHoles = m_boardAdapter.GetHoleIdPolysMap();
508  const MAP_POLY& outerMapHoles = m_boardAdapter.GetHoleOdPolysMap();
509 
510  wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
511 
513 
514  if( outerMapHoles.size() > 0 )
515  {
516  float layer_z_bot = 0.0f;
517  float layer_z_top = 0.0f;
518 
519  for( const auto ii : outerMapHoles )
520  {
521  const PCB_LAYER_ID layer_id = ii.first;
522  const SHAPE_POLY_SET* poly = ii.second;
523  const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
524 
525  getLayerZPos( layer_id, layer_z_top, layer_z_bot );
526 
527  m_outerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
528  layer_z_top, layer_z_bot, false );
529  }
530 
531  for( const auto ii : innerMapHoles )
532  {
533  const PCB_LAYER_ID layer_id = ii.first;
534  const SHAPE_POLY_SET* poly = ii.second;
535  const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
536 
537  getLayerZPos( layer_id, layer_z_top, layer_z_bot );
538 
539  m_innerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
540  layer_z_top, layer_z_bot, false );
541  }
542  }
543 
544  // Generate vertical cylinders of vias and pads (copper)
546 
547  // Add layers maps
548  if( aStatusReporter )
549  aStatusReporter->Report( _( "Load OpenGL: layers" ) );
550 
551  const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
552 
553  for( const auto ii : m_boardAdapter.GetLayerMap() )
554  {
555  const PCB_LAYER_ID layer_id = ii.first;
556 
557  if( !m_boardAdapter.Is3dLayerEnabled( layer_id ) )
558  continue;
559 
560  if( aStatusReporter )
561  aStatusReporter->Report( wxString::Format(
562  _( "Load OpenGL layer %d" ), (int)layer_id ) );
563 
564  const BVH_CONTAINER_2D* container2d = ii.second;
565 
566  SHAPE_POLY_SET polyListSubtracted;
567  SHAPE_POLY_SET* aPolyList = nullptr;
568 
569  // Load the vertical (Z axis) component of shapes
570 
571  if( map_poly.find( layer_id ) != map_poly.end() )
572  {
573  polyListSubtracted = *map_poly.at( layer_id );;
574 
575  if( ( layer_id != B_Paste ) && ( layer_id != F_Paste ) &&
577  {
578  polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
580 
581  if( ( layer_id != B_Mask ) && ( layer_id != F_Mask ) )
582  {
585  polyListSubtracted.BooleanSubtract(
588  }
589 
591  {
592  if( layer_id == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() )
593  {
594  polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ),
596  }
597  else if( layer_id == F_SilkS && map_poly.find( F_Mask ) != map_poly.end() )
598  {
599  polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ),
601  }
602  }
603  }
604 
605  aPolyList = &polyListSubtracted;
606  }
607 
608  OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, aPolyList, layer_id,
610 
611  if( oglList != nullptr )
612  m_layers[layer_id] = oglList;
613 
614  }
615 
618  {
620  {
628 
630  &polySubtracted, F_Cu );
631  }
632 
634  {
642 
644  &polySubtracted, B_Cu );
645  }
646  }
647 
648  // Load 3D models
649  if( aStatusReporter )
650  aStatusReporter->Report( _( "Loading 3D models..." ) );
651 
652  load3dModels( aStatusReporter );
653 
654  if( aStatusReporter )
655  {
656  // Calculation time in seconds
657  const double calculation_time = (double)( GetRunningMicroSecs() -
658  stats_startReloadTime) / 1e6;
659 
660  aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
661  }
662 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: camera.h:114
BOARD_ADAPTER & m_boardAdapter
OPENGL_RENDER_LIST * createBoard(const SHAPE_POLY_SET &aBoardPoly, const BVH_CONTAINER_2D *aThroughHoles=nullptr)
std::map< PCB_LAYER_ID, SHAPE_POLY_SET * > MAP_POLY
A type that stores polysets for each layer id.
Definition: board_adapter.h:57
const SHAPE_POLY_SET & GetOuterNonPlatedThroughHolePoly() const noexcept
MAP_OGL_DISP_LISTS m_layers
const BVH_CONTAINER_2D & GetThroughHoleAnnularRings() const noexcept
Get the through hole annular rings container.
const SHAPE_POLY_SET & GetThroughHoleOdPolys() const noexcept
Get through hole outside diameter 2D polygons.
const MAP_CONTAINER_2D_BASE & GetLayerMap() const noexcept
Get the map of containers that have the objects per layer.
void InitSettings(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
Function to be called by the render when it need to reload the settings for the board.
OPENGL_RENDER_LIST * m_platedPadsFront
const SHAPE_POLY_SET & GetThroughHoleViaOdPolys() const noexcept
const SHAPE_POLY_SET * GetFrontPlatedPadPolys()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void getLayerZPos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
const SHAPE_POLY_SET * GetBackPlatedPadPolys()
OPENGL_RENDER_LIST * m_outerThroughHoles
const SHAPE_POLY_SET & GetThroughHoleAnnularRingPolys() const noexcept
const LIST_OBJECT2D & GetList() const
Definition: container_2d.h:66
const BVH_CONTAINER_2D & GetThroughHoleIds() const noexcept
Get the through hole inner diameter container.
OPENGL_RENDER_LIST * m_outerThroughHoleRings
OPENGL_RENDER_LIST * m_boardWithHoles
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
const BVH_CONTAINER_2D * GetPlatedPadsBack() const noexcept
MAP_OGL_DISP_LISTS m_outerLayerHoles
OPENGL_RENDER_LIST * m_antiBoard
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
static OBJECT_2D_STATS & Instance()
Definition: object_2d.h:137
OPENGL_RENDER_LIST * m_board
const MAP_POLY & GetHoleIdPolysMap() const noexcept
#define _(s)
const BVH_CONTAINER_2D & GetThroughHoleOds() const noexcept
Get the inflated through hole outside diameters container.
const MAP_POLY & GetHoleOdPolysMap() const noexcept
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)
const SHAPE_POLY_SET & GetBoardPoly() const noexcept
Get the current polygon of the epoxy board.
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:51
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 NewOutline()
Creates a new hole in a given outline.
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 load3dModels(REPORTER *aStatusReporter)
Load footprint models from the cache and load it to openGL lists in the form of MODEL_3D objects.
const MAP_POLY & GetPolyMap() const noexcept
Get map of polygon's layers.
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 OpenGL display lists to related with a layer.
bool m_reloadRequested
The window size that this camera is working.
const BVH_CONTAINER_2D * GetPlatedPadsFront() const noexcept
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapset time (in microsecondes) to class PROF_COUNTER.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
const BVH_CONTAINER_2D & GetThroughHoleViaOds() const noexcept
Definition: layer_ids.h:71
SHAPE_POLY_SET m_antiBoardPolys
The negative polygon representation of the board outline.
const SFVEC3F & GetBoardCenter() const noexcept
The board center position in 3D units.
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
void SetItIsTransparent(bool aSetTransparent)
OPENGL_RENDER_LIST * m_platedPadsBack
MAP_OGL_DISP_LISTS m_innerLayerHoles
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
void ResetStats()
Definition: object_2d.h:122
const MAP_CONTAINER_2D_BASE & GetLayerHoleMap() const noexcept
Get the map of container that have the holes per layer.
OPENGL_RENDER_LIST * m_outerViaThroughHoles
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...

References _, SHAPE_POLY_SET::Append(), B_Cu, B_Mask, B_Paste, B_SilkS, SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::BooleanSubtract(), createBoard(), F_Cu, F_Mask, F_Paste, F_SilkS, FL_CLIP_SILK_ON_VIA_ANNULUS, FL_RENDER_PLATED_PADS_AS_PLATED, FL_SUBTRACT_MASK_FROM_SILK, FL_USE_REALISTIC_MODE, Format(), freeAllLists(), generateHoles(), generateLayerList(), generateViasAndPads(), BOARD_ADAPTER::GetBackPlatedPadPolys(), BOARD_ADAPTER::GetBoardCenter(), BOARD_ADAPTER::GetBoardPoly(), BOARD_ADAPTER::GetFlag(), 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, m_innerLayerHoles, m_layers, m_outerLayerHoles, m_outerThroughHoleRings, m_outerThroughHoles, m_outerViaThroughHoles, m_platedPadsBack, m_platedPadsFront, RENDER_3D_BASE::m_reloadRequested, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_POLY_SET::RemoveAllContours(), REPORTER::Report(), OBJECT_2D_STATS::ResetStats(), CAMERA::SetBoardLookAtPos(), SHAPE_LINE_CHAIN::SetClosed(), and OPENGL_RENDER_LIST::SetItIsTransparent().

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; }
bool m_reloadRequested
The window size that this camera is working.

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_LEGACY::render3dArrows ( )
private

Definition at line 128 of file render_3d_legacy.cpp.

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

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_LEGACY::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 1217 of file render_3d_legacy.cpp.

1218 {
1220  render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, true );
1221 
1222  render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, false );
1223 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
void render3dModelsSelected(bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)

References FL_USE_SELECTION, BOARD_ADAPTER::GetFlag(), RENDER_3D_BASE::m_boardAdapter, and render3dModelsSelected().

Referenced by Redraw().

◆ render3dModelsSelected()

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

Definition at line 1178 of file render_3d_legacy.cpp.

1180 {
1181  if( !m_boardAdapter.GetBoard() )
1182  return;
1183 
1184  MODEL_3D::BeginDrawMulti( !aRenderSelectedOnly );
1185 
1186  // Go for all footprints
1187  for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() )
1188  {
1189  bool highlight = false;
1190 
1192  {
1193  if( fp->IsSelected() )
1194  highlight = true;
1195 
1197  highlight = true;
1198 
1199  if( aRenderSelectedOnly != highlight )
1200  continue;
1201  }
1202 
1203  if( !fp->Models().empty() )
1204  {
1205  if( m_boardAdapter.IsFootprintShown( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
1206  {
1207  if( aRenderTopOrBot == !fp->IsFlipped() )
1208  renderFootprint( fp, aRenderTransparentOnly, highlight );
1209  }
1210  }
1211  }
1212 
1214 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
bool IsFootprintShown(FOOTPRINT_ATTR_T aFPAttributes) const
Test if footprint should be displayed in relation to attributes and the flags.
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:66
FOOTPRINTS & Footprints()
Definition: board.h:233
const BOARD * GetBoard() const noexcept
Get current board to be rendered.
BOARD_ITEM * m_currentRollOverItem
static void EndDrawMulti()
Cleanup render states after drawing multiple models.
Definition: 3d_model.cpp:390
static void BeginDrawMulti(bool aUseColorInformation)
Set some basic render states before drawing multiple models.
Definition: 3d_model.cpp:374

References MODEL_3D::BeginDrawMulti(), MODEL_3D::EndDrawMulti(), FL_HIGHLIGHT_ROLLOVER_ITEM, FL_USE_SELECTION, BOARD::Footprints(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::IsFootprintShown(), RENDER_3D_BASE::m_boardAdapter, m_currentRollOverItem, and renderFootprint().

Referenced by render3dModels().

◆ renderBoardBody()

void RENDER_3D_LEGACY::renderBoardBody ( bool  aSkipRenderHoles)
private

Definition at line 517 of file render_3d_legacy.cpp.

518 {
519  m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
520 
521  // opacity to transparency
522  m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a;
523 
524  OglSetMaterial( m_materials.m_EpoxyBoard, 1.0f );
525 
526  OPENGL_RENDER_LIST* ogl_disp_list = nullptr;
527 
528  if( aSkipRenderHoles )
529  ogl_disp_list = m_board;
530  else
531  ogl_disp_list = m_boardWithHoles;
532 
533  if( ogl_disp_list )
534  {
535  ogl_disp_list->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness() / 2.0f,
537 
538  ogl_disp_list->SetItIsTransparent( true );
539 
540  ogl_disp_list->DrawAll();
541  }
542 }
BOARD_ADAPTER & m_boardAdapter
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
Definition: ogl_utils.cpp:119
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
OPENGL_RENDER_LIST * m_boardWithHoles
OPENGL_RENDER_LIST * m_board
void ApplyScalePosition(float aZposition, float aZscale)
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
Store the OpenGL display lists to related with a layer.
void SetItIsTransparent(bool aSetTransparent)
float GetEpoxyThickness() const noexcept
Get the current epoxy thickness.
struct RENDER_3D_LEGACY::@5 m_materials

References OPENGL_RENDER_LIST::ApplyScalePosition(), OPENGL_RENDER_LIST::DrawAll(), BOARD_ADAPTER::GetEpoxyThickness(), 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_LEGACY::renderFootprint ( const FOOTPRINT aFootprint,
bool  aRenderTransparentOnly,
bool  aIsSelected 
)
private

Definition at line 1226 of file render_3d_legacy.cpp.

1228 {
1229  if( !aFootprint->Models().empty() )
1230  {
1231  const double zpos = m_boardAdapter.GetFootprintZPos( aFootprint->IsFlipped() );
1232 
1233  glPushMatrix();
1234 
1235  wxPoint pos = aFootprint->GetPosition();
1236 
1237  glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
1238  zpos );
1239 
1240  if( aFootprint->GetOrientation() )
1241  glRotated( (double) aFootprint->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
1242 
1243  if( aFootprint->IsFlipped() )
1244  {
1245  glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1246  glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1247  }
1248 
1249  double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3dUnits() * UNITS3D_TO_UNITSPCB;
1250 
1251  glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
1252  modelunit_to_3d_units_factor );
1253 
1254  // Get the list of model files for this model
1255  for( const FP_3DMODEL& sM : aFootprint->Models() )
1256  {
1257  if( !sM.m_Show || sM.m_Filename.empty() )
1258  continue;
1259 
1260  // Check if the model is present in our cache map
1261  auto cache_i = m_3dModelMap.find( sM.m_Filename );
1262 
1263  if( cache_i == m_3dModelMap.end() )
1264  continue;
1265 
1266  if( const MODEL_3D* modelPtr = cache_i->second )
1267  {
1268  bool opaque = sM.m_Opacity >= 1.0;
1269 
1270  if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
1271  ( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
1272  {
1273  glPushMatrix();
1274 
1275  // FIXME: don't do this over and over again unless the
1276  // values have changed. cache the matrix somewhere.
1277  glm::mat4 mtx( 1 );
1278  mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
1279  mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.z ),
1280  { 0.0f, 0.0f, 1.0f } );
1281  mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.y ),
1282  { 0.0f, 1.0f, 0.0f } );
1283  mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.x ),
1284  { 1.0f, 0.0f, 0.0f } );
1285  mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
1286  glMultMatrixf( glm::value_ptr( mtx ) );
1287 
1288  if( aRenderTransparentOnly )
1289  {
1290  modelPtr->DrawTransparent( sM.m_Opacity,
1291  aFootprint->IsSelected() || aIsSelected,
1293  }
1294  else
1295  {
1296  modelPtr->DrawOpaque( aFootprint->IsSelected() || aIsSelected,
1298  }
1299 
1301  {
1302  glEnable( GL_BLEND );
1303  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1304 
1305  glDisable( GL_LIGHTING );
1306 
1307  glLineWidth( 1 );
1308  modelPtr->DrawBboxes();
1309 
1310  glLineWidth( 4 );
1311  modelPtr->DrawBbox();
1312 
1313  glEnable( GL_LIGHTING );
1314  glDisable( GL_BLEND );
1315  }
1316 
1317  glPopMatrix();
1318  }
1319  }
1320  }
1321 
1322  glPopMatrix();
1323  }
1324 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:182
bool IsSelected() const
Definition: eda_item.h:123
double GetOrientation() const
Definition: footprint.h:190
MAP_3DMODEL m_3dModelMap
#define UNITS3D_TO_UNITSPCB
Scale conversion from 3d model units to pcb units.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
float GetFootprintZPos(bool aIsFlipped) const
Get the position of the footprint in 3d integer units considering if it is flipped or not.
bool IsFlipped() const
Definition: footprint.h:277
const int scale
wxPoint GetPosition() const override
Definition: footprint.h:186
SFVEC3F m_OpenGlSelectionColor

References BOARD_ADAPTER::BiuTo3dUnits(), FL_RENDER_OPENGL_SHOW_MODEL_BBOX, BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetFootprintZPos(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), FOOTPRINT::IsFlipped(), EDA_ITEM::IsSelected(), m_3dModelMap, RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_OpenGlSelectionColor, FOOTPRINT::Models(), scale, and UNITS3D_TO_UNITSPCB.

Referenced by render3dModelsSelected().

◆ renderSolderMaskLayer()

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

Definition at line 1120 of file render_3d_legacy.cpp.

1122 {
1123  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
1124 
1125  float nonCopperThickness = m_boardAdapter.GetNonCopperLayerThickness();
1126 
1127  if( m_board )
1128  {
1129  if( m_layers.find( aLayerID ) != m_layers.end() )
1130  {
1131  OPENGL_RENDER_LIST* pLayerDispListMask = m_layers.at( aLayerID );
1132 
1134  m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
1135 
1136  m_board->ApplyScalePosition( aZPosition, nonCopperThickness );
1137 
1138  setLayerMaterial( aLayerID );
1139 
1140  m_board->SetItIsTransparent( true );
1141 
1142  if( aSkipRenderHoles )
1143  {
1144  m_board->DrawAllCameraCulled( m_camera.GetPos().z, aDrawMiddleSegments );
1145  }
1146  else
1147  {
1148  m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments, pLayerDispListMask,
1150  }
1151  }
1152  else
1153  {
1154  // This case there is no layer with mask, so we will render the full board as mask
1156  m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
1157 
1158  m_board->ApplyScalePosition( aZPosition, nonCopperThickness );
1159 
1160  setLayerMaterial( aLayerID );
1161 
1162  m_board->SetItIsTransparent( true );
1163 
1164  if( aSkipRenderHoles )
1165  {
1166  m_board->DrawAllCameraCulled( m_camera.GetPos().z, aDrawMiddleSegments );
1167  }
1168  else
1169  {
1170  m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments,
1172  }
1173  }
1174  }
1175 }
BOARD_ADAPTER & m_boardAdapter
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.
MAP_OGL_DISP_LISTS m_layers
float GetNonCopperLayerThickness() const noexcept
Get the current non copper layers thickness.
const SFVEC3F & GetPos() const
Definition: camera.h:109
void setLayerMaterial(PCB_LAYER_ID aLayerID)
OPENGL_RENDER_LIST * m_board
void ApplyScalePosition(float aZposition, float aZscale)
Store the OpenGL display lists to related with a layer.
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
void SetItIsTransparent(bool aSetTransparent)
OPENGL_RENDER_LIST * m_outerViaThroughHoles

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_LEGACY::setArrowMaterial ( )
private

Definition at line 1019 of file render_3d_legacy.cpp.

1020 {
1021  glEnable( GL_COLOR_MATERIAL );
1022  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
1023 
1024  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1025  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1026  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1027  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
1028 
1029  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
1030  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
1031 
1032  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
1033  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
1034  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
1035 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46

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 }
BUSY_INDICATOR::FACTORY m_busyIndicatorFactory
< Factory that returns a suitable busy indicator for the context.

References RENDER_3D_BASE::m_busyIndicatorFactory.

◆ setCopperMaterial()

void RENDER_3D_LEGACY::setCopperMaterial ( )
private

Definition at line 497 of file render_3d_legacy.cpp.

498 {
499  OglSetMaterial( m_materials.m_NonPlatedCopper, 1.0f );
500 }
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
Definition: ogl_utils.cpp:119
struct RENDER_3D_LEGACY::@5 m_materials

References m_materials, and OglSetMaterial().

Referenced by Redraw().

◆ SetCurrentRollOverItem()

void RENDER_3D_LEGACY::SetCurrentRollOverItem ( BOARD_ITEM aRollOverItem)
inline

Definition at line 70 of file render_3d_legacy.h.

71  {
72  m_currentRollOverItem = aRollOverItem;
73  }
BOARD_ITEM * m_currentRollOverItem

References m_currentRollOverItem.

Referenced by EDA_3D_CANVAS::OnMouseMove().

◆ SetCurWindowSize()

void RENDER_3D_LEGACY::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 89 of file render_3d_legacy.cpp.

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

References RENDER_3D_BASE::m_windowSize.

◆ setLayerMaterial()

void RENDER_3D_LEGACY::setLayerMaterial ( PCB_LAYER_ID  aLayerID)
private

Definition at line 316 of file render_3d_legacy.cpp.

317 {
318  switch( aLayerID )
319  {
320  case F_Mask:
321  case B_Mask:
322  {
323  const SFVEC4F layerColor = getLayerColor( aLayerID );
324 
325  m_materials.m_SolderMask.m_Diffuse = layerColor;
326 
327  // Convert Opacity to Transparency
328  m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a;
329 
331  {
332  m_materials.m_SolderMask.m_Ambient = m_materials.m_SolderMask.m_Diffuse * 0.3f;
333 
334  m_materials.m_SolderMask.m_Specular =
335  m_materials.m_SolderMask.m_Diffuse * m_materials.m_SolderMask.m_Diffuse;
336  }
337 
338  OglSetMaterial( m_materials.m_SolderMask, 1.0f );
339  break;
340  }
341 
342  case B_Paste:
343  case F_Paste:
344  m_materials.m_Paste.m_Diffuse = getLayerColor( aLayerID );
345  OglSetMaterial( m_materials.m_Paste, 1.0f );
346  break;
347 
348  case B_SilkS:
349  m_materials.m_SilkSBot.m_Diffuse = getLayerColor( aLayerID );
350  OglSetMaterial( m_materials.m_SilkSBot, 1.0f );
351  break;
352 
353  case F_SilkS:
354  m_materials.m_SilkSTop.m_Diffuse = getLayerColor( aLayerID );
355  OglSetMaterial( m_materials.m_SilkSTop, 1.0f );
356  break;
357 
358  case B_Adhes:
359  case F_Adhes:
360  case Dwgs_User:
361  case Cmts_User:
362  case Eco1_User:
363  case Eco2_User:
364  case Edge_Cuts:
365  case Margin:
366  case B_CrtYd:
367  case F_CrtYd:
368  case B_Fab:
369  case F_Fab:
370  m_materials.m_Plastic.m_Diffuse = getLayerColor( aLayerID );
371 
372  m_materials.m_Plastic.m_Ambient = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.05f,
373  m_materials.m_Plastic.m_Diffuse.g * 0.05f,
374  m_materials.m_Plastic.m_Diffuse.b * 0.05f );
375 
376  m_materials.m_Plastic.m_Specular = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.7f,
377  m_materials.m_Plastic.m_Diffuse.g * 0.7f,
378  m_materials.m_Plastic.m_Diffuse.b * 0.7f );
379 
380  m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
381  m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
382  OglSetMaterial( m_materials.m_Plastic, 1.0f );
383  break;
384 
385  default:
386  m_materials.m_Copper.m_Diffuse = getLayerColor( aLayerID );
387  OglSetMaterial( m_materials.m_Copper, 1.0f );
388  break;
389  }
390 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BOARD_ADAPTER & m_boardAdapter
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
Definition: ogl_utils.cpp:119
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
SFVEC4F getLayerColor(PCB_LAYER_ID aLayerID)
struct RENDER_3D_LEGACY::@5 m_materials

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, FL_USE_REALISTIC_MODE, BOARD_ADAPTER::GetFlag(), getLayerColor(), RENDER_3D_BASE::m_boardAdapter, m_materials, Margin, and OglSetMaterial().

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

◆ setLightBottom()

void RENDER_3D_LEGACY::setLightBottom ( bool  enabled)
private

Definition at line 119 of file render_3d_legacy.cpp.

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

Referenced by Redraw().

◆ setLightFront()

void RENDER_3D_LEGACY::setLightFront ( bool  enabled)
private

Definition at line 101 of file render_3d_legacy.cpp.

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

Referenced by Redraw().

◆ setLightTop()

void RENDER_3D_LEGACY::setLightTop ( bool  enabled)
private

Definition at line 110 of file render_3d_legacy.cpp.

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

Referenced by Redraw().

◆ setPlatedCopperAndDepthOffset()

void RENDER_3D_LEGACY::setPlatedCopperAndDepthOffset ( PCB_LAYER_ID  aLayer_id)
private

Definition at line 503 of file render_3d_legacy.cpp.

504 {
505  glEnable( GL_POLYGON_OFFSET_FILL );
506  glPolygonOffset(-0.1f, -2.0f );
507  setLayerMaterial( aLayer_id );
508 }
void setLayerMaterial(PCB_LAYER_ID aLayerID)

References setLayerMaterial().

Referenced by Redraw().

◆ setupMaterials()

void RENDER_3D_LEGACY::setupMaterials ( )
private

Definition at line 167 of file render_3d_legacy.cpp.

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

References FL_USE_REALISTIC_MODE, BOARD_ADAPTER::GetFlag(), RENDER_3D_BASE::m_boardAdapter, BOARD_ADAPTER::m_CopperColor, m_materials, BOARD_ADAPTER::m_SilkScreenColorBot, BOARD_ADAPTER::m_SilkScreenColorTop, BOARD_ADAPTER::m_SolderPasteColor, and mapf().

Referenced by Redraw().

◆ unsetDepthOffset()

void RENDER_3D_LEGACY::unsetDepthOffset ( )
private

Definition at line 511 of file render_3d_legacy.cpp.

512 {
513  glDisable( GL_POLYGON_OFFSET_FILL );
514 }

Referenced by Redraw().

Member Data Documentation

◆ m_3dModelMap

MAP_3DMODEL RENDER_3D_LEGACY::m_3dModelMap
private

◆ m_antiBoard

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_antiBoard
private

Definition at line 201 of file render_3d_legacy.h.

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

◆ m_antiBoardPolys

SHAPE_POLY_SET RENDER_3D_LEGACY::m_antiBoardPolys
private

The negative polygon representation of the board outline.

Definition at line 219 of file render_3d_legacy.h.

Referenced by generateViasAndPads(), and reload().

◆ m_board

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_board
private

◆ m_boardAdapter

◆ m_boardWithHoles

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_boardWithHoles
private

Definition at line 200 of file render_3d_legacy.h.

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

◆ m_camera

CAMERA& RENDER_3D_BASE::m_camera
protectedinherited

◆ 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

GLuint RENDER_3D_LEGACY::m_circleTexture
private

◆ m_Copper

SMATERIAL RENDER_3D_LEGACY::m_Copper

Definition at line 189 of file render_3d_legacy.h.

◆ m_currentRollOverItem

BOARD_ITEM* RENDER_3D_LEGACY::m_currentRollOverItem
private

◆ m_EpoxyBoard

SMATERIAL RENDER_3D_LEGACY::m_EpoxyBoard

Definition at line 187 of file render_3d_legacy.h.

◆ m_GrayMaterial

SMATERIAL RENDER_3D_LEGACY::m_GrayMaterial

Definition at line 191 of file render_3d_legacy.h.

◆ m_grid

GLuint RENDER_3D_LEGACY::m_grid
private

oGL list that stores current grid

Definition at line 209 of file render_3d_legacy.h.

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

◆ m_innerLayerHoles

MAP_OGL_DISP_LISTS RENDER_3D_LEGACY::m_innerLayerHoles
private

Definition at line 198 of file render_3d_legacy.h.

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

◆ 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 RENDER_3D_RAYTRACE::initializeOpenGL(), initializeOpenGL(), Redraw(), RENDER_3D_RAYTRACE::Redraw(), and RENDER_3D_BASE::RENDER_3D_BASE().

◆ m_lastGridType

GRID3D_TYPE RENDER_3D_LEGACY::m_lastGridType
private

Stores the last grid type.

Definition at line 210 of file render_3d_legacy.h.

Referenced by Redraw(), and RENDER_3D_LEGACY().

◆ m_layers

MAP_OGL_DISP_LISTS RENDER_3D_LEGACY::m_layers
private

◆ m_materials

struct { ... } RENDER_3D_LEGACY::m_materials

◆ m_NonPlatedCopper

SMATERIAL RENDER_3D_LEGACY::m_NonPlatedCopper

Definition at line 188 of file render_3d_legacy.h.

◆ m_outerLayerHoles

MAP_OGL_DISP_LISTS RENDER_3D_LEGACY::m_outerLayerHoles
private

Definition at line 197 of file render_3d_legacy.h.

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

◆ m_outerThroughHoleRings

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_outerThroughHoleRings
private

Definition at line 204 of file render_3d_legacy.h.

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

◆ m_outerThroughHoles

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_outerThroughHoles
private

Definition at line 202 of file render_3d_legacy.h.

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

◆ m_outerViaThroughHoles

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_outerViaThroughHoles
private

Definition at line 203 of file render_3d_legacy.h.

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

◆ m_padHoles

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_padHoles
private

Definition at line 213 of file render_3d_legacy.h.

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

◆ m_Paste

SMATERIAL RENDER_3D_LEGACY::m_Paste

Definition at line 183 of file render_3d_legacy.h.

◆ m_Plastic

SMATERIAL RENDER_3D_LEGACY::m_Plastic

Definition at line 190 of file render_3d_legacy.h.

◆ m_platedPadsBack

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_platedPadsBack
private

Definition at line 196 of file render_3d_legacy.h.

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

◆ m_platedPadsFront

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_platedPadsFront
private

Definition at line 195 of file render_3d_legacy.h.

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

◆ m_reloadRequested

bool RENDER_3D_BASE::m_reloadRequested
protectedinherited

◆ m_SilkSBot

SMATERIAL RENDER_3D_LEGACY::m_SilkSBot

Definition at line 184 of file render_3d_legacy.h.

◆ m_SilkSTop

SMATERIAL RENDER_3D_LEGACY::m_SilkSTop

Definition at line 185 of file render_3d_legacy.h.

◆ m_SolderMask

SMATERIAL RENDER_3D_LEGACY::m_SolderMask

Definition at line 186 of file render_3d_legacy.h.

◆ m_triangles

LIST_TRIANGLES RENDER_3D_LEGACY::m_triangles
private

store pointers so can be deleted latter

Definition at line 206 of file render_3d_legacy.h.

Referenced by freeAllLists(), generateLayerList(), and RENDER_3D_LEGACY().

◆ m_vias

OPENGL_RENDER_LIST* RENDER_3D_LEGACY::m_vias
private

Definition at line 212 of file render_3d_legacy.h.

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

◆ m_windowSize


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