KiCad PCB EDA Suite
C3D_RENDER_OGL_LEGACY Class Reference

The C3D_RENDER_OGL_LEGACY class render the board using openGL legacy mode. More...

#include <c3d_render_ogl_legacy.h>

Inheritance diagram for C3D_RENDER_OGL_LEGACY:
C3D_RENDER_BASE

Public Member Functions

 C3D_RENDER_OGL_LEGACY (BOARD_ADAPTER &aAdapter, CCAMERA &aCamera)
 
 ~C3D_RENDER_OGL_LEGACY ()
 
void SetCurWindowSize (const wxSize &aSize) override
 SetCurWindowSize - 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 - Ask to redraw the view. More...
 
int GetWaitForEditingTimeOut () override
 GetWaitForEditingTimeOut - Give the interface the time (in ms) that it should wait for editing or movements before (this works for display preview mode) More...
 
void SetCurrentIntersectedBoardItem (BOARD_ITEM *aCurrentIntersectedBoardItem)
 
void ReloadRequest ()
 ReloadRequest - !TODO: this must be reviewed to add flags to improve specific render. More...
 
bool IsReloadRequestPending () const
 IsReloadRequestPending - 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

BOARD_ADAPTERm_boardAdapter
 settings refrence in use for this render More...
 
CCAMERAm_camera
 
bool m_is_opengl_initialized
 flag if the opengl specific for this render was already initialized More...
 
bool m_reloadRequested
 !TODO: this must be reviewed in order to flag change types More...
 
wxSize m_windowSize
 The window size that this camera is working. More...
 

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

bool initializeOpenGL ()
 
CLAYERS_OGL_DISP_LISTScreateBoard (const SHAPE_POLY_SET &aBoardPoly)
 
void reload (REPORTER *aStatusReporter, REPORTER *aWarningReporter)
 
void ogl_set_arrow_material ()
 
void ogl_free_all_display_lists ()
 
CLAYERS_OGL_DISP_LISTSgenerate_holes_display_list (const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces)
 
CLAYERS_OGL_DISP_LISTSgenerateLayerListFromContainer (const CBVHCONTAINER2D *aContainer, const SHAPE_POLY_SET *aPolyList, PCB_LAYER_ID aLayerId)
 
void add_triangle_top_bot (CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
 
void add_object_to_triangle_layer (const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
 
void add_object_to_triangle_layer (const CPOLYGON4PTS2D *aPoly, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
 
void add_object_to_triangle_layer (const CFILLEDCIRCLE2D *aFilledCircle, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
 
void add_object_to_triangle_layer (const CTRIANGLE2D *aTri, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
 
void add_object_to_triangle_layer (const CROUNDSEGMENT2D *aSeg, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
 
void render_solder_mask_layer (PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
 
void render_board_body (bool aSkipRenderHoles)
 
void get_layer_z_pos (PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
 
void generate_ring_contour (const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, bool aInvertOrder)
 
void generate_cylinder (const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, CLAYER_TRIANGLES *aDstLayer)
 
void generate_3D_Vias_and_Pads ()
 
void load_3D_models (REPORTER *aStatusReporter)
 
void render_3D_models (bool aRenderTopOrBot, bool aRenderTransparentOnly)
 render_3D_models More...
 
void render_3D_models_selected (bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)
 
void render_3D_module (const MODULE *module, bool aRenderTransparentOnly, bool aIsSelected)
 
void setLight_Front (bool enabled)
 
void setLight_Top (bool enabled)
 
void setLight_Bottom (bool enabled)
 
void render_3D_arrows ()
 
void generate_new_3DGrid (GRID3D_TYPE aGridType)
 
void setupMaterials ()
 
void setCopperMaterial ()
 
void setPlatedCopperAndDepthOffset (PCB_LAYER_ID aLayer_id)
 
void unsetDepthOffset ()
 
void set_layer_material (PCB_LAYER_ID aLayerID)
 
SFVEC4F get_layer_color (PCB_LAYER_ID aLayerID)
 

Private Attributes

MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_lists_platedPads_F_Cu
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_lists_platedPads_B_Cu
 
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
 
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_board
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_anti_board
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_through_holes_outer
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_through_holes_outer_with_npth
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_through_holes_vias_outer
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_through_holes_outer_ring
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
 
LIST_TRIANGLES m_triangles
 
GLuint m_ogl_circle_texture
 
GLuint m_ogl_disp_list_grid
 oGL list that stores current grid More...
 
GRID3D_TYPE m_last_grid_type
 Stores the last grid computed. More...
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_via
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_pads_holes
 
MAP_3DMODEL m_3dmodel_map
 
BOARD_ITEMm_currentIntersectedBoardItem
 
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
 

Detailed Description

The C3D_RENDER_OGL_LEGACY class render the board using openGL legacy mode.

Definition at line 59 of file c3d_render_ogl_legacy.h.

Constructor & Destructor Documentation

◆ C3D_RENDER_OGL_LEGACY()

C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY ( BOARD_ADAPTER aAdapter,
CCAMERA aCamera 
)
explicit

Definition at line 52 of file c3d_render_ogl_legacy.cpp.

52  :
53  C3D_RENDER_BASE( aAdapter, aCamera )
54 {
55  wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY" ) );
56 
60  m_triangles.clear();
63 
66 
71  //m_ogl_disp_list_through_holes_vias_inner = NULL;
75 
80 
81  m_3dmodel_map.clear();
82 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_F_Cu
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_B_Cu
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_anti_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_ring
GRID3D_TYPE m_last_grid_type
Stores the last grid computed.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
#define NULL
C3D_RENDER_BASE(BOARD_ADAPTER &aBoardAdapter, CCAMERA &aCamera)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
BOARD_ITEM * m_currentIntersectedBoardItem
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_pads_holes
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.

References m_3dmodel_map, m_currentIntersectedBoardItem, m_last_grid_type, C3D_RENDER_BASE::m_logTrace, m_ogl_circle_texture, m_ogl_disp_list_anti_board, m_ogl_disp_list_board, m_ogl_disp_list_grid, m_ogl_disp_list_pads_holes, m_ogl_disp_list_through_holes_outer, m_ogl_disp_list_through_holes_outer_ring, m_ogl_disp_list_through_holes_outer_with_npth, m_ogl_disp_list_through_holes_vias_outer, m_ogl_disp_list_via, m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps, m_ogl_disp_lists_layers, m_ogl_disp_lists_layers_holes_inner, m_ogl_disp_lists_layers_holes_outer, m_ogl_disp_lists_platedPads_B_Cu, m_ogl_disp_lists_platedPads_F_Cu, m_triangles, NONE, and NULL.

◆ ~C3D_RENDER_OGL_LEGACY()

C3D_RENDER_OGL_LEGACY::~C3D_RENDER_OGL_LEGACY ( )

Definition at line 85 of file c3d_render_ogl_legacy.cpp.

86 {
87  wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::~C3D_RENDER_OGL_LEGACY" ) );
88 
90 
91  glDeleteTextures( 1, &m_ogl_circle_texture );
92 }
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.

References C3D_RENDER_BASE::m_logTrace, m_ogl_circle_texture, and ogl_free_all_display_lists().

Member Function Documentation

◆ add_object_to_triangle_layer() [1/5]

void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer ( const CRING2D aRing,
CLAYER_TRIANGLES aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 129 of file c3d_render_createscene_ogl_legacy.cpp.

133 {
134  const SFVEC2F &center = aRing->GetCenter();
135  const float inner = aRing->GetInnerRadius();
136  const float outer = aRing->GetOuterRadius();
137 
138  std::vector< SFVEC2F > innerContour;
139  std::vector< SFVEC2F > outerContour;
140 
141  generate_ring_contour( center,
142  inner,
143  outer,
144  m_boardAdapter.GetNrSegmentsCircle( outer * 2.0f ),
145  innerContour,
146  outerContour,
147  false );
148 
149  // This will add the top and bot quads that will form the approximated ring
150 
151  for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
152  {
153  const SFVEC2F &vi0 = innerContour[i + 0];
154  const SFVEC2F &vi1 = innerContour[i + 1];
155  const SFVEC2F &vo0 = outerContour[i + 0];
156  const SFVEC2F &vo1 = outerContour[i + 1];
157 
158  aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
159  SFVEC3F( vi0.x, vi0.y, aZtop ),
160  SFVEC3F( vo0.x, vo0.y, aZtop ),
161  SFVEC3F( vo1.x, vo1.y, aZtop ) );
162 
163  aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
164  SFVEC3F( vo1.x, vo1.y, aZbot ),
165  SFVEC3F( vo0.x, vo0.y, aZbot ),
166  SFVEC3F( vi0.x, vi0.y, aZbot ) );
167  }
168 }
void generate_ring_contour(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, bool aInvertOrder)
float GetOuterRadius() const
Definition: cring2d.h:40
float GetInnerRadius() const
Definition: cring2d.h:39
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const SFVEC2F & GetCenter() const
Definition: cring2d.h:38
CLAYER_TRIANGLE_CONTAINER * m_layer_top_triangles
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
AddQuad.

References CLAYER_TRIANGLE_CONTAINER::AddQuad(), generate_ring_contour(), CRING2D::GetCenter(), CRING2D::GetInnerRadius(), BOARD_ADAPTER::GetNrSegmentsCircle(), CRING2D::GetOuterRadius(), C3D_RENDER_BASE::m_boardAdapter, CLAYER_TRIANGLES::m_layer_bot_triangles, and CLAYER_TRIANGLES::m_layer_top_triangles.

Referenced by generate_holes_display_list(), and generateLayerListFromContainer().

◆ add_object_to_triangle_layer() [2/5]

void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer ( const CPOLYGON4PTS2D aPoly,
CLAYER_TRIANGLES aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 78 of file c3d_render_createscene_ogl_legacy.cpp.

82 {
83  const SFVEC2F &v0 = aPoly->GetV0();
84  const SFVEC2F &v1 = aPoly->GetV1();
85  const SFVEC2F &v2 = aPoly->GetV2();
86  const SFVEC2F &v3 = aPoly->GetV3();
87 
88  add_triangle_top_bot( aDstLayer, v0, v2, v1, aZtop, aZbot );
89  add_triangle_top_bot( aDstLayer, v2, v0, v3, aZtop, aZbot );
90 }
const SFVEC2F & GetV0() const
const SFVEC2F & GetV3() const
const SFVEC2F & GetV2() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const SFVEC2F & GetV1() const
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)

References add_triangle_top_bot(), CPOLYGON4PTS2D::GetV0(), CPOLYGON4PTS2D::GetV1(), CPOLYGON4PTS2D::GetV2(), and CPOLYGON4PTS2D::GetV3().

◆ add_object_to_triangle_layer() [3/5]

void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer ( const CFILLEDCIRCLE2D aFilledCircle,
CLAYER_TRIANGLES aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 41 of file c3d_render_createscene_ogl_legacy.cpp.

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

References CLAYER_TRIANGLE_CONTAINER::AddTriangle(), CFILLEDCIRCLE2D::GetCenter(), CFILLEDCIRCLE2D::GetRadius(), CLAYER_TRIANGLES::m_layer_bot_segment_ends, CLAYER_TRIANGLES::m_layer_top_segment_ends, and SIZE_OF_CIRCLE_TEXTURE.

◆ add_object_to_triangle_layer() [4/5]

void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer ( const CTRIANGLE2D aTri,
CLAYER_TRIANGLES aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 171 of file c3d_render_createscene_ogl_legacy.cpp.

175 {
176  const SFVEC2F &v1 = aTri->GetP1();
177  const SFVEC2F &v2 = aTri->GetP2();
178  const SFVEC2F &v3 = aTri->GetP3();
179 
180  add_triangle_top_bot( aDstLayer, v1, v2, v3, aZtop, aZbot );
181 }
const SFVEC2F & GetP2() const
Definition: ctriangle2d.h:59
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const SFVEC2F & GetP1() const
Definition: ctriangle2d.h:58
const SFVEC2F & GetP3() const
Definition: ctriangle2d.h:60
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)

References add_triangle_top_bot(), CTRIANGLE2D::GetP1(), CTRIANGLE2D::GetP2(), and CTRIANGLE2D::GetP3().

◆ add_object_to_triangle_layer() [5/5]

void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer ( const CROUNDSEGMENT2D aSeg,
CLAYER_TRIANGLES aDstLayer,
float  aZtop,
float  aZbot 
)
private

Definition at line 184 of file c3d_render_createscene_ogl_legacy.cpp.

188 {
189  const SFVEC2F& leftStart = aSeg->GetLeftStar();
190  const SFVEC2F& leftEnd = aSeg->GetLeftEnd();
191  const SFVEC2F& leftDir = aSeg->GetLeftDir();
192 
193  const SFVEC2F& rightStart = aSeg->GetRightStar();
194  const SFVEC2F& rightEnd = aSeg->GetRightEnd();
195  const SFVEC2F& rightDir = aSeg->GetRightDir();
196  const float radius = aSeg->GetRadius();
197 
198  const SFVEC2F& start = aSeg->GetStart();
199  const SFVEC2F& end = aSeg->GetEnd();
200 
201  const float texture_factor = (12.0f / (float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
202  const float texture_factorF= ( 6.0f / (float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
203 
204  const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f );
205  const float radius_triangle_factor = (radius_of_the_square - radius) / radius;
206 
207  const SFVEC2F factorS = SFVEC2F( -rightDir.y * radius * radius_triangle_factor,
208  rightDir.x * radius * radius_triangle_factor );
209 
210  const SFVEC2F factorE = SFVEC2F( -leftDir.y * radius * radius_triangle_factor,
211  leftDir.x * radius * radius_triangle_factor );
212 
213  // Top end segment triangles (semi-circles)
215  SFVEC3F( rightEnd.x + texture_factor * factorS.x,
216  rightEnd.y + texture_factor * factorS.y,
217  aZtop ),
218  SFVEC3F( leftStart.x + texture_factor * factorE.x,
219  leftStart.y + texture_factor * factorE.y,
220  aZtop ),
221  SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
222  start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
223  aZtop ) );
224 
226  SFVEC3F( leftEnd.x + texture_factor * factorE.x,
227  leftEnd.y + texture_factor * factorE.y, aZtop ),
228  SFVEC3F( rightStart.x + texture_factor * factorS.x,
229  rightStart.y + texture_factor * factorS.y, aZtop ),
230  SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
231  end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
232  aZtop ) );
233 
234  // Bot end segment triangles (semi-circles)
236  SFVEC3F( leftStart.x + texture_factor * factorE.x,
237  leftStart.y + texture_factor * factorE.y,
238  aZbot ),
239  SFVEC3F( rightEnd.x + texture_factor * factorS.x,
240  rightEnd.y + texture_factor * factorS.y,
241  aZbot ),
242  SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
243  start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
244  aZbot ) );
245 
247  SFVEC3F( rightStart.x + texture_factor * factorS.x,
248  rightStart.y + texture_factor * factorS.y, aZbot ),
249  SFVEC3F( leftEnd.x + texture_factor * factorE.x,
250  leftEnd.y + texture_factor * factorE.y, aZbot ),
251  SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
252  end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
253  aZbot ) );
254 
255  // Segment top and bot planes
256  aDstLayer->m_layer_top_triangles->AddQuad(
257  SFVEC3F( rightEnd.x, rightEnd.y, aZtop ),
258  SFVEC3F( rightStart.x, rightStart.y, aZtop ),
259  SFVEC3F( leftEnd.x, leftEnd.y, aZtop ),
260  SFVEC3F( leftStart.x, leftStart.y, aZtop ) );
261 
262  aDstLayer->m_layer_bot_triangles->AddQuad(
263  SFVEC3F( rightEnd.x, rightEnd.y, aZbot ),
264  SFVEC3F( leftStart.x, leftStart.y, aZbot ),
265  SFVEC3F( leftEnd.x, leftEnd.y, aZbot ),
266  SFVEC3F( rightStart.x, rightStart.y, aZbot ) );
267 }
const SFVEC2F & GetRightEnd() const
const SFVEC2F & GetStart() const
const SFVEC2F & GetLeftStar() const
float GetRadius() const
const SFVEC2F & GetRightStar() const
const SFVEC2F & GetLeftEnd() const
const SFVEC2F & GetEnd() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
CLAYER_TRIANGLE_CONTAINER * m_layer_top_triangles
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
AddTriangle.
float GetRadiusSquared() const
const SFVEC2F & GetRightDir() const
const SFVEC2F & GetLeftDir() const
#define SIZE_OF_CIRCLE_TEXTURE
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_segment_ends
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
CLAYER_TRIANGLE_CONTAINER * m_layer_top_segment_ends
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
AddQuad.

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

◆ add_triangle_top_bot()

void C3D_RENDER_OGL_LEGACY::add_triangle_top_bot ( CLAYER_TRIANGLES aDst,
const SFVEC2F v0,
const SFVEC2F v1,
const SFVEC2F v2,
float  top,
float  bot 
)
private

Definition at line 670 of file c3d_render_createscene_ogl_legacy.cpp.

676 {
677  aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
678  SFVEC3F( v1.x, v1.y, bot ),
679  SFVEC3F( v2.x, v2.y, bot ) );
680 
681  aDst->m_layer_top_triangles->AddTriangle( SFVEC3F( v2.x, v2.y, top ),
682  SFVEC3F( v1.x, v1.y, top ),
683  SFVEC3F( v0.x, v0.y, top ) );
684 }
CLAYER_TRIANGLE_CONTAINER * m_layer_top_triangles
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
AddTriangle.
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47

References CLAYER_TRIANGLE_CONTAINER::AddTriangle(), CLAYER_TRIANGLES::m_layer_bot_triangles, and CLAYER_TRIANGLES::m_layer_top_triangles.

Referenced by add_object_to_triangle_layer(), createBoard(), and generate_3D_Vias_and_Pads().

◆ createBoard()

CLAYERS_OGL_DISP_LISTS * C3D_RENDER_OGL_LEGACY::createBoard ( const SHAPE_POLY_SET aBoardPoly)
private

Definition at line 413 of file c3d_render_createscene_ogl_legacy.cpp.

414 {
415  CLAYERS_OGL_DISP_LISTS* dispLists = nullptr;
416  CCONTAINER2D boardContainer;
417  SHAPE_POLY_SET brd_outlines = aBoardPoly;
418 
419  Convert_shape_line_polygon_to_triangles( brd_outlines, boardContainer,
421  (const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
422 
423  const LIST_OBJECT2D &listBoardObject2d = boardContainer.GetList();
424 
425  if( listBoardObject2d.size() > 0 )
426  {
427  // We will set a unitary Z so it will in future used with transformations
428  // since the board poly will be used not only to draw itself but also the
429  // solder mask layers.
430  const float layer_z_top = 1.0f;
431  const float layer_z_bot = 0.0f;
432 
433  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listBoardObject2d.size() );
434 
435  // Convert the list of objects(triangles) to triangle layer structure
436  for( LIST_OBJECT2D::const_iterator itemOnLayer = listBoardObject2d.begin();
437  itemOnLayer != listBoardObject2d.end();
438  ++itemOnLayer )
439  {
440  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
441 
442  wxASSERT( object2d_A->GetObjectType() == OBJECT2D_TYPE::TRIANGLE );
443 
444  const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
445 
446  const SFVEC2F &v1 = tri->GetP1();
447  const SFVEC2F &v2 = tri->GetP2();
448  const SFVEC2F &v3 = tri->GetP3();
449 
450  add_triangle_top_bot( layerTriangles,
451  v1,
452  v2,
453  v3,
454  layer_z_top,
455  layer_z_bot );
456  }
457 
458  const SHAPE_POLY_SET &boardPoly = m_boardAdapter.GetBoardPoly();
459 
460  if( boardPoly.OutlineCount() > 0 )
461  {
462  layerTriangles->AddToMiddleContourns( boardPoly,
463  layer_z_bot,
464  layer_z_top,
466  false );
467 
468  dispLists = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
470  layer_z_top,
471  layer_z_top );
472  }
473 
474  delete layerTriangles;
475  }
476 
477  return dispLists;
478 }
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
int OutlineCount() const
Returns the number of outlines in the set
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists.
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SHAPE_POLY_SET.
const BOARD * GetBoard() const noexcept
GetBoard - Get current board to be rendered.
const SHAPE_POLY_SET & GetBoardPoly() const noexcept
GetBoardPoly - Get the current polygon of the epoxy board.
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:37
const SFVEC2F & GetP1() const
Definition: ctriangle2d.h:58
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:64
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)

References add_triangle_top_bot(), CLAYER_TRIANGLES::AddToMiddleContourns(), BOARD_ADAPTER::BiuTo3Dunits(), Convert_shape_line_polygon_to_triangles(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetBoardPoly(), CGENERICCONTAINER2D::GetList(), COBJECT2D::GetObjectType(), C3D_RENDER_BASE::m_boardAdapter, m_ogl_circle_texture, SHAPE_POLY_SET::OutlineCount(), and TRIANGLE.

Referenced by reload().

◆ CreateBusyIndicator()

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

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

Definition at line 65 of file c3d_render_base.cpp.

66 {
67  std::unique_ptr<BUSY_INDICATOR> busy;
68 
70  busy = m_busyIndicatorFactory();
71 
72  return busy;
73 }
BUSY_INDICATOR::FACTORY m_busyIndicatorFactory
Factory that returns a suitable busy indicator for the context.

References C3D_RENDER_BASE::m_busyIndicatorFactory.

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

◆ generate_3D_Vias_and_Pads()

void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads ( )
private

Definition at line 745 of file c3d_render_createscene_ogl_legacy.cpp.

746 {
748  {
749  const unsigned int reserve_nr_triangles_estimation =
751  8 *
753 
754  CLAYER_TRIANGLES *layerTriangleVIA = new CLAYER_TRIANGLES( reserve_nr_triangles_estimation );
755 
756  // Insert plated vertical holes inside the board
757  // /////////////////////////////////////////////////////////////////////////
758 
759  // Insert vias holes (vertical cylinders)
760  for( auto track : m_boardAdapter.GetBoard()->Tracks() )
761  {
762  if( track->Type() == PCB_VIA_T )
763  {
764  const VIA *via = static_cast<const VIA*>(track);
765 
766  const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3Dunits();
767  const float thickness = m_boardAdapter.GetCopperThickness3DU();
768  const int nrSegments = m_boardAdapter.GetNrSegmentsCircle( via->GetDrillValue() );
769  const float hole_inner_radius = holediameter / 2.0f;
770 
771  const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3Dunits(),
772  -via->GetStart().y * m_boardAdapter.BiuTo3Dunits() );
773 
774  PCB_LAYER_ID top_layer, bottom_layer;
775  via->LayerPair( &top_layer, &bottom_layer );
776 
777  float ztop, zbot, dummy;
778 
779  get_layer_z_pos( top_layer, ztop, dummy );
780  get_layer_z_pos( bottom_layer, dummy, zbot );
781 
782  wxASSERT( zbot < ztop );
783 
784  generate_cylinder( via_center,
785  hole_inner_radius,
786  hole_inner_radius + thickness,
787  ztop,
788  zbot,
789  nrSegments,
790  layerTriangleVIA );
791  }
792  }
793 
794  m_ogl_disp_list_via = new CLAYERS_OGL_DISP_LISTS( *layerTriangleVIA,
795  0,
796  0.0f,
797  0.0f );
798 
799  delete layerTriangleVIA;
800  }
801 
802 
804  {
805  SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
806  SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
807 
808  tht_outer_holes_poly.RemoveAllContours();
809  tht_inner_holes_poly.RemoveAllContours();
810 
811  // Insert pads holes (vertical cylinders)
812  for( const auto module : m_boardAdapter.GetBoard()->Modules() )
813  {
814  for( auto pad : module->Pads() )
815  {
816  if( pad->GetAttribute() != PAD_ATTRIB_NPTH )
817  {
818  const wxSize drillsize = pad->GetDrillSize();
819  const bool hasHole = drillsize.x && drillsize.y;
820 
821  if( !hasHole )
822  continue;
823 
824  const int copperThickness = m_boardAdapter.GetHolePlatingThicknessBIU();
825 
826  pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly,
827  copperThickness,
828  ARC_LOW_DEF, ERROR_INSIDE );
829  pad->TransformHoleWithClearanceToPolygon( tht_inner_holes_poly, 0,
830  ARC_LOW_DEF, ERROR_INSIDE );
831  }
832  }
833  }
834 
835  // Subtract the holes
836  tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
837 
838 
839  CCONTAINER2D holesContainer;
840 
841  Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly,
842  holesContainer,
844  (const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
845 
846  const LIST_OBJECT2D &listHolesObject2d = holesContainer.GetList();
847 
848  if( listHolesObject2d.size() > 0 )
849  {
850  float layer_z_top, layer_z_bot, dummy;
851 
852  get_layer_z_pos( F_Cu, layer_z_top, dummy );
853  get_layer_z_pos( B_Cu, dummy, layer_z_bot );
854 
855  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listHolesObject2d.size() );
856 
857  // Convert the list of objects(triangles) to triangle layer structure
858  for( LIST_OBJECT2D::const_iterator itemOnLayer = listHolesObject2d.begin();
859  itemOnLayer != listHolesObject2d.end();
860  ++itemOnLayer )
861  {
862  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
863 
864  wxASSERT( object2d_A->GetObjectType() == OBJECT2D_TYPE::TRIANGLE );
865 
866  const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
867 
868  const SFVEC2F &v1 = tri->GetP1();
869  const SFVEC2F &v2 = tri->GetP2();
870  const SFVEC2F &v3 = tri->GetP3();
871 
872  add_triangle_top_bot( layerTriangles, v1, v2, v3,
873  layer_z_top, layer_z_bot );
874  }
875 
876  wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
877 
878  if( tht_outer_holes_poly.OutlineCount() > 0 )
879  {
880  layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
881  layer_z_bot, layer_z_top,
883  false );
884 
886  *layerTriangles,
887  m_ogl_circle_texture, // not need
888  layer_z_top, layer_z_top );
889  }
890 
891  delete layerTriangles;
892  }
893  }
894 }
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
int OutlineCount() const
Returns the number of outlines in the set
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists.
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
const wxPoint & GetStart() const
Definition: class_track.h:116
float GetCopperThickness3DU() const noexcept
GetCopperThickness3DU - Get the current copper layer thickness.
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
void get_layer_z_pos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
PCB_LAYER_ID
A quick note on layer IDs:
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
int GetHolePlatingThicknessBIU() const noexcept
GetCopperThicknessBIU - Get the current copper layer thickness.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
MODULES & Modules()
Definition: class_board.h:284
SHAPE_POLY_SET.
const BOARD * GetBoard() const noexcept
GetBoard - Get current board to be rendered.
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:37
const SFVEC2F & GetP1() const
Definition: ctriangle2d.h:58
unsigned int GetStats_Nr_Holes() const noexcept
GetStats_Nr_Holes - Get statistics of the nr of holes.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
unsigned int GetStats_Nr_Vias() const noexcept
GetStats_Nr_Vias - Get statistics of the nr of vias.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
float GetStats_Med_Via_Hole_Diameter3DU() const noexcept
GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_pads_holes
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:64
TRACKS & Tracks()
Definition: class_board.h:281
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
void generate_cylinder(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, CLAYER_TRIANGLES *aDstLayer)

References add_triangle_top_bot(), CLAYER_TRIANGLES::AddToMiddleContourns(), B_Cu, BOARD_ADAPTER::BiuTo3Dunits(), SHAPE_POLY_SET::BooleanSubtract(), Convert_shape_line_polygon_to_triangles(), dummy(), ERROR_INSIDE, F_Cu, generate_cylinder(), get_layer_z_pos(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetCopperThickness3DU(), VIA::GetDrillValue(), BOARD_ADAPTER::GetHolePlatingThicknessBIU(), CGENERICCONTAINER2D::GetList(), BOARD_ADAPTER::GetNrSegmentsCircle(), COBJECT2D::GetObjectType(), TRACK::GetStart(), BOARD_ADAPTER::GetStats_Med_Via_Hole_Diameter3DU(), BOARD_ADAPTER::GetStats_Nr_Holes(), BOARD_ADAPTER::GetStats_Nr_Vias(), VIA::LayerPair(), C3D_RENDER_BASE::m_boardAdapter, m_ogl_circle_texture, m_ogl_disp_list_pads_holes, m_ogl_disp_list_via, BOARD::Modules(), SHAPE_POLY_SET::OutlineCount(), PAD_ATTRIB_NPTH, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::RemoveAllContours(), BOARD::Tracks(), and TRIANGLE.

Referenced by reload().

◆ generate_cylinder()

void C3D_RENDER_OGL_LEGACY::generate_cylinder ( const SFVEC2F aCenter,
float  aInnerRadius,
float  aOuterRadius,
float  aZtop,
float  aZbot,
unsigned int  aNr_sides_per_circle,
CLAYER_TRIANGLES aDstLayer 
)
private

Definition at line 703 of file c3d_render_createscene_ogl_legacy.cpp.

710 {
711  std::vector< SFVEC2F > innerContour;
712  std::vector< SFVEC2F > outerContour;
713 
714  generate_ring_contour( aCenter,
715  aInnerRadius,
716  aOuterRadius,
717  aNr_sides_per_circle,
718  innerContour,
719  outerContour,
720  false );
721 
722  for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
723  {
724  const SFVEC2F &vi0 = innerContour[i + 0];
725  const SFVEC2F &vi1 = innerContour[i + 1];
726  const SFVEC2F &vo0 = outerContour[i + 0];
727  const SFVEC2F &vo1 = outerContour[i + 1];
728 
729  aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
730  SFVEC3F( vi0.x, vi0.y, aZtop ),
731  SFVEC3F( vo0.x, vo0.y, aZtop ),
732  SFVEC3F( vo1.x, vo1.y, aZtop ) );
733 
734  aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
735  SFVEC3F( vo1.x, vo1.y, aZbot ),
736  SFVEC3F( vo0.x, vo0.y, aZbot ),
737  SFVEC3F( vi0.x, vi0.y, aZbot ) );
738  }
739 
740  aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
741  aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
742 }
void generate_ring_contour(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:45
CLAYER_TRIANGLE_CONTAINER * m_layer_top_triangles
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
AddQuad.

References CLAYER_TRIANGLE_CONTAINER::AddQuad(), CLAYER_TRIANGLES::AddToMiddleContourns(), generate_ring_contour(), CLAYER_TRIANGLES::m_layer_bot_triangles, and CLAYER_TRIANGLES::m_layer_top_triangles.

Referenced by generate_3D_Vias_and_Pads().

◆ generate_holes_display_list()

CLAYERS_OGL_DISP_LISTS * C3D_RENDER_OGL_LEGACY::generate_holes_display_list ( const LIST_OBJECT2D aListHolesObject2d,
const SHAPE_POLY_SET aPoly,
float  aZtop,
float  aZbot,
bool  aInvertFaces 
)
private

Definition at line 270 of file c3d_render_createscene_ogl_legacy.cpp.

276 {
278 
279  if( aListHolesObject2d.size() > 0 )
280  {
281  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( aListHolesObject2d.size() * 2 );
282 
283  // Convert the list of objects(filled circles) to triangle layer structure
284  for( LIST_OBJECT2D::const_iterator itemOnLayer = aListHolesObject2d.begin();
285  itemOnLayer != aListHolesObject2d.end();
286  ++itemOnLayer )
287  {
288  const COBJECT2D* object2d_A = static_cast<const COBJECT2D*>( *itemOnLayer );
289 
290  wxASSERT( ( object2d_A->GetObjectType() == OBJECT2D_TYPE::FILLED_CIRCLE )
291  || ( object2d_A->GetObjectType() == OBJECT2D_TYPE::ROUNDSEG ) );
292 
293  switch( object2d_A->GetObjectType() )
294  {
296  add_object_to_triangle_layer( static_cast<const CFILLEDCIRCLE2D*>( object2d_A ),
297  layerTriangles, aZtop, aZbot );
298  break;
299 
301  add_object_to_triangle_layer( static_cast<const CROUNDSEGMENT2D*>( object2d_A ),
302  layerTriangles, aZtop, aZbot );
303  break;
304 
305  default:
306  wxFAIL_MSG(
307  "C3D_RENDER_OGL_LEGACY::generate_holes_display_list: Object type is not implemented" );
308  break;
309  }
310  }
311 
312  // Note: he can have a aListHolesObject2d whith holes but without countours
313  // eg: when there are only NPTH on the list and the contours were not
314  // added
315 
316  if( aPoly.OutlineCount() > 0 )
317  {
318  layerTriangles->AddToMiddleContourns( aPoly,
319  aZbot,
320  aZtop,
322  aInvertFaces );
323  }
324 
325  ret = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
327  aZbot,
328  aZtop );
329 
330  delete layerTriangles;
331  }
332 
333  return ret;
334 }
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
void add_object_to_triangle_layer(const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
int OutlineCount() const
Returns the number of outlines in the set
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists.
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
#define NULL
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.

References add_object_to_triangle_layer(), CLAYER_TRIANGLES::AddToMiddleContourns(), BOARD_ADAPTER::BiuTo3Dunits(), FILLED_CIRCLE, COBJECT2D::GetObjectType(), C3D_RENDER_BASE::m_boardAdapter, m_ogl_circle_texture, NULL, SHAPE_POLY_SET::OutlineCount(), and ROUNDSEG.

Referenced by reload().

◆ generate_new_3DGrid()

void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid ( GRID3D_TYPE  aGridType)
private

Definition at line 1407 of file c3d_render_ogl_legacy.cpp.

1408 {
1409  if( glIsList( m_ogl_disp_list_grid ) )
1410  glDeleteLists( m_ogl_disp_list_grid, 1 );
1411 
1413 
1414  if( aGridType == GRID3D_TYPE::NONE )
1415  return;
1416 
1417  m_ogl_disp_list_grid = glGenLists( 1 );
1418 
1419  if( !glIsList( m_ogl_disp_list_grid ) )
1420  return;
1421 
1422  glNewList( m_ogl_disp_list_grid, GL_COMPILE );
1423 
1424  glEnable( GL_BLEND );
1425  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1426 
1427  const double zpos = 0.0;
1428 
1429  // Color of grid lines
1430  const SFVEC3F gridColor = m_boardAdapter.GetColor( DARKGRAY );
1431 
1432  // Color of grid lines every 5 lines
1433  const SFVEC3F gridColor_marker = m_boardAdapter.GetColor( LIGHTGRAY );
1434  const double scale = m_boardAdapter.BiuTo3Dunits();
1435  const GLfloat transparency = 0.35f;
1436 
1437  double griSizeMM = 0.0;
1438 
1439  switch( aGridType )
1440  {
1441  default:
1442  case GRID3D_TYPE::NONE:
1443  return;
1444  case GRID3D_TYPE::GRID_1MM:
1445  griSizeMM = 1.0;
1446  break;
1448  griSizeMM = 2.5;
1449  break;
1450  case GRID3D_TYPE::GRID_5MM:
1451  griSizeMM = 5.0;
1452  break;
1454  griSizeMM = 10.0;
1455  break;
1456  }
1457 
1458  glNormal3f( 0.0, 0.0, 1.0 );
1459 
1460  const wxSize brd_size = m_boardAdapter.GetBoardSizeBIU();
1461  wxPoint brd_center_pos = m_boardAdapter.GetBoardPosBIU();
1462 
1463  brd_center_pos.y = -brd_center_pos.y;
1464 
1465  const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
1466  const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
1467 
1468  // Grid limits, in 3D units
1469  double xmin = (brd_center_pos.x - xsize / 2) * scale;
1470  double xmax = (brd_center_pos.x + xsize / 2) * scale;
1471  double ymin = (brd_center_pos.y - ysize / 2) * scale;
1472  double ymax = (brd_center_pos.y + ysize / 2) * scale;
1473  double zmin = Millimeter2iu( -50 ) * scale;
1474  double zmax = Millimeter2iu( 100 ) * scale;
1475 
1476  // Draw horizontal grid centered on 3D origin (center of the board)
1477  for( int ii = 0; ; ii++ )
1478  {
1479  if( (ii % 5) )
1480  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1481  else
1482  glColor4f( gridColor_marker.r,
1483  gridColor_marker.g,
1484  gridColor_marker.b,
1485  transparency );
1486 
1487  const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
1488 
1489  if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1490  {
1491  glBegin( GL_LINES );
1492  glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1493  glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1494  glEnd();
1495 
1496  if( ii != 0 )
1497  {
1498  glBegin( GL_LINES );
1499  glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1500  glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1501  glEnd();
1502  }
1503  }
1504 
1505  if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1506  {
1507  glBegin( GL_LINES );
1508  glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
1509  glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
1510  glEnd();
1511 
1512  if( ii != 0 )
1513  {
1514  glBegin( GL_LINES );
1515  glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
1516  glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
1517  glEnd();
1518  }
1519  }
1520 
1521  if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1522  break;
1523  }
1524 
1525  // Draw vertical grid on Z axis
1526  glNormal3f( 0.0, -1.0, 0.0 );
1527 
1528  // Draw vertical grid lines (parallel to Z axis)
1529  double posy = -brd_center_pos.y * scale;
1530 
1531  for( int ii = 0; ; ii++ )
1532  {
1533  if( (ii % 5) )
1534  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1535  else
1536  glColor4f( gridColor_marker.r,
1537  gridColor_marker.g,
1538  gridColor_marker.b,
1539  transparency );
1540 
1541  const double delta = ii * griSizeMM * IU_PER_MM;
1542 
1543  glBegin( GL_LINES );
1544  xmax = (brd_center_pos.x + delta) * scale;
1545 
1546  glVertex3f( xmax, posy, zmin );
1547  glVertex3f( xmax, posy, zmax );
1548  glEnd();
1549 
1550  if( ii != 0 )
1551  {
1552  glBegin( GL_LINES );
1553  xmin = (brd_center_pos.x - delta) * scale;
1554  glVertex3f( xmin, posy, zmin );
1555  glVertex3f( xmin, posy, zmax );
1556  glEnd();
1557  }
1558 
1559  if( delta > xsize / 2.0f )
1560  break;
1561  }
1562 
1563  // Draw horizontal grid lines on Z axis (parallel to X axis)
1564  for( int ii = 0; ; ii++ )
1565  {
1566  if( (ii % 5) )
1567  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1568  else
1569  glColor4f( gridColor_marker.r,
1570  gridColor_marker.g,
1571  gridColor_marker.b,
1572  transparency );
1573 
1574  const double delta = ii * griSizeMM * IU_PER_MM * scale;
1575 
1576  if( delta <= zmax )
1577  {
1578  // Draw grid lines on Z axis (positive Z axis coordinates)
1579  glBegin( GL_LINES );
1580  glVertex3f( xmin, posy, delta );
1581  glVertex3f( xmax, posy, delta );
1582  glEnd();
1583  }
1584 
1585  if( delta <= -zmin && ( ii != 0 ) )
1586  {
1587  // Draw grid lines on Z axis (negative Z axis coordinates)
1588  glBegin( GL_LINES );
1589  glVertex3f( xmin, posy, -delta );
1590  glVertex3f( xmax, posy, -delta );
1591  glEnd();
1592  }
1593 
1594  if( ( delta > zmax ) && ( delta > -zmin ) )
1595  break;
1596  }
1597 
1598  glDisable( GL_BLEND );
1599 
1600  glEndList();
1601 }
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
SFVEC4F GetColor(COLOR4D aColor) const
GetColor.
static constexpr double IU_PER_MM
Mock up a conversion function.
wxSize GetBoardSizeBIU() const noexcept
GetBoardSizeBIU - Get the board size.
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
const int scale
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
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:68
wxPoint GetBoardPosBIU() const noexcept
GetBoardPosBIU - Get the board size.
static constexpr int Millimeter2iu(double mm)

References BOARD_ADAPTER::BiuTo3Dunits(), DARKGRAY, BOARD_ADAPTER::GetBoardPosBIU(), BOARD_ADAPTER::GetBoardSizeBIU(), BOARD_ADAPTER::GetColor(), GRID_10MM, GRID_1MM, GRID_2P5MM, GRID_5MM, IU_PER_MM, KiROUND(), LIGHTGRAY, C3D_RENDER_BASE::m_boardAdapter, m_ogl_disp_list_grid, Millimeter2iu(), NONE, and scale.

Referenced by Redraw().

◆ generate_ring_contour()

void C3D_RENDER_OGL_LEGACY::generate_ring_contour ( 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 93 of file c3d_render_createscene_ogl_legacy.cpp.

100 {
101  aInnerContourResult.clear();
102  aInnerContourResult.reserve( aNr_sides_per_circle + 2 );
103 
104  aOuterContourResult.clear();
105  aOuterContourResult.reserve( aNr_sides_per_circle + 2 );
106 
107  const int delta = 3600 / aNr_sides_per_circle;
108 
109  for( int ii = 0; ii < 3600; ii += delta )
110  {
111  float angle = (float)( aInvertOrder ? ( 3600 - ii ) : ii )
112  * 2.0f * glm::pi<float>() / 3600.0f;
113  const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) );
114 
115  aInnerContourResult.emplace_back( aCenter.x + rotatedDir.x * aInnerRadius,
116  aCenter.y + rotatedDir.y * aInnerRadius );
117 
118  aOuterContourResult.emplace_back( aCenter.x + rotatedDir.x * aOuterRadius,
119  aCenter.y + rotatedDir.y * aOuterRadius );
120  }
121 
122  aInnerContourResult.push_back( aInnerContourResult[0] );
123  aOuterContourResult.push_back( aOuterContourResult[0] );
124 
125  wxASSERT( aInnerContourResult.size() == aOuterContourResult.size() );
126 }
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle().

Referenced by add_object_to_triangle_layer(), and generate_cylinder().

◆ generateLayerListFromContainer()

CLAYERS_OGL_DISP_LISTS * C3D_RENDER_OGL_LEGACY::generateLayerListFromContainer ( const CBVHCONTAINER2D aContainer,
const SHAPE_POLY_SET aPolyList,
PCB_LAYER_ID  aLayerId 
)
private

Definition at line 337 of file c3d_render_createscene_ogl_legacy.cpp.

340 {
341  if( aContainer == nullptr )
342  return nullptr;
343 
344  const LIST_OBJECT2D &listObject2d = aContainer->GetList();
345 
346  if( listObject2d.size() == 0 )
347  return nullptr;
348 
349  float layer_z_bot = 0.0f;
350  float layer_z_top = 0.0f;
351 
352  get_layer_z_pos( aLayerId, layer_z_top, layer_z_bot );
353 
354  // Calculate an estimation for the nr of triangles based on the nr of objects
355  unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
356 
357  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( nrTrianglesEstimation );
358 
359  // store in a list so it will be latter deleted
360  m_triangles.push_back( layerTriangles );
361 
362  // Load the 2D (X,Y axis) component of shapes
363  for( LIST_OBJECT2D::const_iterator itemOnLayer = listObject2d.begin();
364  itemOnLayer != listObject2d.end();
365  ++itemOnLayer )
366  {
367  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
368 
369  switch( object2d_A->GetObjectType() )
370  {
372  add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
373  layerTriangles, layer_z_top, layer_z_bot );
374  break;
375 
377  add_object_to_triangle_layer( (const CPOLYGON4PTS2D *)object2d_A,
378  layerTriangles, layer_z_top, layer_z_bot );
379  break;
380 
381  case OBJECT2D_TYPE::RING:
382  add_object_to_triangle_layer( (const CRING2D *)object2d_A,
383  layerTriangles, layer_z_top, layer_z_bot );
384  break;
385 
387  add_object_to_triangle_layer( (const CTRIANGLE2D *)object2d_A,
388  layerTriangles, layer_z_top, layer_z_bot );
389  break;
390 
392  add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
393  layerTriangles, layer_z_top, layer_z_bot );
394  break;
395 
396  default:
397  wxFAIL_MSG("C3D_RENDER_OGL_LEGACY: Object type is not implemented");
398  break;
399  }
400  }
401 
402  if( aPolyList )
403  if( aPolyList->OutlineCount() > 0 )
404  layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top,
405  m_boardAdapter.BiuTo3Dunits(), false );
406  // Create display list
407  // /////////////////////////////////////////////////////////////////////
408  return new CLAYERS_OGL_DISP_LISTS( *layerTriangles, m_ogl_circle_texture,
409  layer_z_bot, layer_z_top );
410 }
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
void add_object_to_triangle_layer(const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
int OutlineCount() const
Returns the number of outlines in the set
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists.
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
void get_layer_z_pos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
This handles simple polygons with 4 points.
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:37
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:64

References add_object_to_triangle_layer(), CLAYER_TRIANGLES::AddToMiddleContourns(), BOARD_ADAPTER::BiuTo3Dunits(), FILLED_CIRCLE, get_layer_z_pos(), CGENERICCONTAINER2D::GetList(), COBJECT2D::GetObjectType(), C3D_RENDER_BASE::m_boardAdapter, m_ogl_circle_texture, m_triangles, SHAPE_POLY_SET::OutlineCount(), POLYGON4PT, RING, ROUNDSEG, and TRIANGLE.

Referenced by reload().

◆ get_layer_color()

SFVEC4F C3D_RENDER_OGL_LEGACY::get_layer_color ( PCB_LAYER_ID  aLayerID)
private

Definition at line 408 of file c3d_render_ogl_legacy.cpp.

409 {
410  SFVEC4F layerColor = m_boardAdapter.GetLayerColor( aLayerID );
411 
413  {
414  switch( aLayerID )
415  {
416  case B_Adhes:
417  case F_Adhes:
418  break;
419 
420  case B_Mask:
422  break;
423  case F_Mask:
425  break;
426 
427  case B_Paste:
428  case F_Paste:
429  layerColor = m_boardAdapter.m_SolderPasteColor;
430  break;
431 
432  case B_SilkS:
434  break;
435  case F_SilkS:
437  break;
438 
439  case Dwgs_User:
440  case Cmts_User:
441  case Eco1_User:
442  case Eco2_User:
443  case Edge_Cuts:
444  case Margin:
445  break;
446 
447  case B_CrtYd:
448  case F_CrtYd:
449  break;
450 
451  case B_Fab:
452  case F_Fab:
453  break;
454 
455  default:
456  layerColor = m_boardAdapter.m_CopperColor;
457  break;
458  }
459  }
460 
461  return layerColor;
462 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
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 )
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
GetLayerColor - 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(), C3D_RENDER_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 set_layer_material().

◆ get_layer_z_pos()

void C3D_RENDER_OGL_LEGACY::get_layer_z_pos ( PCB_LAYER_ID  aLayerID,
float &  aOutZtop,
float &  aOutZbot 
) const
private

Definition at line 687 of file c3d_render_createscene_ogl_legacy.cpp.

690 {
691  aOutZbot = m_boardAdapter.GetLayerBottomZpos3DU( aLayerID );
692  aOutZtop = m_boardAdapter.GetLayerTopZpos3DU( aLayerID );
693 
694  if( aOutZtop < aOutZbot )
695  {
696  float tmpFloat = aOutZbot;
697  aOutZbot = aOutZtop;
698  aOutZtop = tmpFloat;
699  }
700 }
float GetLayerTopZpos3DU(PCB_LAYER_ID aLayerId) const noexcept
GetLayerTopZpos3DU - Get the top z position.
float GetLayerBottomZpos3DU(PCB_LAYER_ID aLayerId) const noexcept
GetLayerBottomZpos3DU - Get the bottom z position.
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render

References BOARD_ADAPTER::GetLayerBottomZpos3DU(), BOARD_ADAPTER::GetLayerTopZpos3DU(), and C3D_RENDER_BASE::m_boardAdapter.

Referenced by generate_3D_Vias_and_Pads(), generateLayerListFromContainer(), and reload().

◆ GetWaitForEditingTimeOut()

int C3D_RENDER_OGL_LEGACY::GetWaitForEditingTimeOut ( )
overridevirtual

GetWaitForEditingTimeOut - 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 miliseconds

Implements C3D_RENDER_BASE.

Definition at line 95 of file c3d_render_ogl_legacy.cpp.

96 {
97  return 50; // ms
98 }

◆ initializeOpenGL()

bool C3D_RENDER_OGL_LEGACY::initializeOpenGL ( )
private

Definition at line 1019 of file c3d_render_ogl_legacy.cpp.

1020 {
1021  glEnable( GL_LINE_SMOOTH );
1022  glShadeModel( GL_SMOOTH );
1023 
1024  // 4-byte pixel alignment
1025  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
1026 
1027  // Initialize the open GL texture to draw the filled semi-circle of the segments
1029 
1030  if( !circleImage )
1031  return false;
1032 
1033  circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
1034  (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
1035  (SIZE_OF_CIRCLE_TEXTURE / 2) - 4,
1036  0xFF );
1037 
1038  //circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
1039  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
1040  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 2, 0xFF );
1041 
1042  CIMAGE *circleImage_Copy = new CIMAGE( *circleImage );
1043 
1044  circleImage->EfxFilter( circleImage_Copy, IMAGE_FILTER::BLUR_3X3 );
1045 
1046  m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
1047 
1048  //circleImage_Copy->SaveAsPNG("circleImage.png");
1049  delete circleImage_Copy;
1050  circleImage_Copy = 0;
1051 
1052  //circleImage->SaveAsPNG("circleImage_blured.png");
1053  delete circleImage;
1054  circleImage = 0;
1055 
1056  init_lights();
1057 
1058  // Use this mode if you want see the triangle lines (debug proposes)
1059  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
1060 
1061  m_is_opengl_initialized = true;
1062 
1063  return true;
1064 }
void init_lights(void)
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
CircleFilled.
Definition: cimage.cpp:173
GLuint OGL_LoadTexture(const CIMAGE &aImage)
OGL_LoadTexture - generate a new OpenGL texture.
Definition: ogl_utils.cpp:81
bool m_is_opengl_initialized
flag if the opengl specific for this render was already initialized
#define SIZE_OF_CIRCLE_TEXTURE
CIMAGE manages a 8-bit channel image.
Definition: cimage.h:89
void EfxFilter(CIMAGE *aInImg, IMAGE_FILTER aFilterType)
Function EfxFilter apply a filter to the input image and stores it in the image class this <- FilterT...
Definition: cimage.cpp:472

References BLUR_3X3, CIMAGE::CircleFilled(), CIMAGE::EfxFilter(), init_lights(), C3D_RENDER_BASE::m_is_opengl_initialized, m_ogl_circle_texture, OGL_LoadTexture(), and SIZE_OF_CIRCLE_TEXTURE.

Referenced by Redraw().

◆ IsReloadRequestPending()

bool C3D_RENDER_BASE::IsReloadRequestPending ( ) const
inlineinherited

IsReloadRequestPending - 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 82 of file c3d_render_base.h.

82 { return m_reloadRequested; }
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types

References C3D_RENDER_BASE::m_reloadRequested.

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

◆ load_3D_models()

void C3D_RENDER_OGL_LEGACY::load_3D_models ( REPORTER aStatusReporter)
private

Definition at line 903 of file c3d_render_createscene_ogl_legacy.cpp.

904 {
908  return;
909 
910  // Go for all footprints
911  for( MODULE* module : m_boardAdapter.GetBoard()->Modules() )
912  {
913  for( const MODULE_3D_SETTINGS& model : module->Models() )
914  {
915  if( model.m_Show && !model.m_Filename.empty() )
916  {
917  if( aStatusReporter )
918  {
919  // Display the short filename of the 3D model loaded:
920  // (the full name is usually too long to be displayed)
921  wxFileName fn( model.m_Filename );
922  wxString msg;
923  msg.Printf( _( "Loading %s" ), fn.GetFullName() );
924  aStatusReporter->Report( msg );
925  }
926 
927  // Check if the model is not present in our cache map
928  // (Not already loaded in memory)
929  if( m_3dmodel_map.find( model.m_Filename ) == m_3dmodel_map.end() )
930  {
931  // It is not present, try get it from cache
932  const S3DMODEL* modelPtr =
933  m_boardAdapter.Get3DCacheManager()->GetModel( model.m_Filename );
934 
935  // only add it if the return is not NULL
936  if( modelPtr )
937  {
939  C_OGL_3DMODEL* ogl_model = new C_OGL_3DMODEL( *modelPtr, materialMode );
940 
941  if( ogl_model )
942  m_3dmodel_map[ model.m_Filename ] = ogl_model;
943  }
944  }
945  }
946  }
947  }
948 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
S3DMODEL * GetModel(const wxString &aModelFileName)
Function GetModel attempts to load the scene data for a model and to translate it into an S3D_MODEL s...
Definition: 3d_cache.cpp:664
MODULES & Modules()
Definition: class_board.h:284
S3D_CACHE * Get3DCacheManager() const noexcept
Get3DCacheManager - Return the 3d cache manager pointer.
Definition: board_adapter.h:89
const BOARD * GetBoard() const noexcept
GetBoard - Get current board to be rendered.
MATERIAL_MODE
Render 3d model shape materials mode.
Definition: 3d_enums.h:117
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
#define _(s)
Definition: 3d_actions.cpp:33
Store the a model based on meshes and materials.
Definition: c3dmodel.h:90
MATERIAL_MODE MaterialModeGet() const noexcept
MaterialModeGet.

References _, FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, BOARD_ADAPTER::Get3DCacheManager(), BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetFlag(), S3D_CACHE::GetModel(), m_3dmodel_map, C3D_RENDER_BASE::m_boardAdapter, BOARD_ADAPTER::MaterialModeGet(), BOARD::Modules(), and REPORTER::Report().

Referenced by reload().

◆ ogl_free_all_display_lists()

void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists ( )
private

Definition at line 1086 of file c3d_render_ogl_legacy.cpp.

1087 {
1088  if( glIsList( m_ogl_disp_list_grid ) )
1089  glDeleteLists( m_ogl_disp_list_grid, 1 );
1090 
1092 
1093  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
1094  ii != m_ogl_disp_lists_layers.end();
1095  ++ii )
1096  {
1097  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
1098  delete pLayerDispList;
1099  }
1100 
1101  m_ogl_disp_lists_layers.clear();
1102 
1105 
1108 
1109 
1110  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin();
1112  ++ii )
1113  {
1114  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
1115  delete pLayerDispList;
1116  }
1117 
1119 
1120 
1121  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin();
1123  ++ii )
1124  {
1125  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
1126  delete pLayerDispList;
1127  }
1128 
1130 
1131  for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin();
1132  ii != m_triangles.end();
1133  ++ii )
1134  {
1135  delete *ii;
1136  }
1137 
1138  m_triangles.clear();
1139 
1140 
1141  for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin();
1142  ii != m_3dmodel_map.end();
1143  ++ii )
1144  {
1145  C_OGL_3DMODEL *pointer = static_cast<C_OGL_3DMODEL*>(ii->second);
1146  delete pointer;
1147  }
1148 
1149  m_3dmodel_map.clear();
1150 
1151 
1152  delete m_ogl_disp_list_board;
1153  m_ogl_disp_list_board = nullptr;
1154 
1156  m_ogl_disp_list_anti_board = nullptr;
1157 
1160 
1163 
1166 
1169 
1170  delete m_ogl_disp_list_via;
1171  m_ogl_disp_list_via = nullptr;
1172 
1174  m_ogl_disp_list_pads_holes = nullptr;
1175 
1178 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_F_Cu
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_B_Cu
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_anti_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_ring
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_pads_holes

References m_3dmodel_map, m_ogl_disp_list_anti_board, m_ogl_disp_list_board, m_ogl_disp_list_grid, m_ogl_disp_list_pads_holes, m_ogl_disp_list_through_holes_outer, m_ogl_disp_list_through_holes_outer_ring, m_ogl_disp_list_through_holes_outer_with_npth, m_ogl_disp_list_through_holes_vias_outer, m_ogl_disp_list_via, m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps, m_ogl_disp_lists_layers, m_ogl_disp_lists_layers_holes_inner, m_ogl_disp_lists_layers_holes_outer, m_ogl_disp_lists_platedPads_B_Cu, m_ogl_disp_lists_platedPads_F_Cu, and m_triangles.

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

◆ ogl_set_arrow_material()

void C3D_RENDER_OGL_LEGACY::ogl_set_arrow_material ( )
private

Definition at line 1067 of file c3d_render_ogl_legacy.cpp.

1068 {
1069  glEnable( GL_COLOR_MATERIAL );
1070  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
1071 
1072  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1073  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1074  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
1075  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
1076 
1077  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
1078  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
1079 
1080  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
1081  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
1082  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
1083 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49

Referenced by render_3D_arrows().

◆ Redraw()

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

Redraw - Ask to 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
it will return true if the render would like to redraw again

Implements C3D_RENDER_BASE.

Definition at line 561 of file c3d_render_ogl_legacy.cpp.

563 {
564  // Initialize openGL
566  {
567  if( !initializeOpenGL() )
568  return false;
569  }
570 
571  if( m_reloadRequested )
572  {
573  std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
574 
575  if( aStatusReporter )
576  aStatusReporter->Report( _( "Loading..." ) );
577 
578  reload( aStatusReporter, aWarningReporter );
579 
580  // generate a new 3D grid as the size of the board may had changed
583  }
584  else
585  {
586  // Check if grid was changed
588  {
589  // and generate a new one
592  }
593  }
594 
595  setupMaterials();
596 
597  // Initial setup
598  // /////////////////////////////////////////////////////////////////////////
599  glDepthFunc( GL_LESS );
600  glEnable( GL_CULL_FACE );
601  glFrontFace( GL_CCW ); // This is the openGL default
602  glEnable( GL_NORMALIZE ); // This allow openGL to normalize the normals after transformations
603 
604  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
605 
607  {
608  if( !aIsMoving )
609  {
610  glEnable( GL_MULTISAMPLE );
611  }
612  else
613  {
614  glDisable( GL_MULTISAMPLE );
615  }
616  }
617 
618  // clear color and depth buffers
619  // /////////////////////////////////////////////////////////////////////////
620  glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
621  glClearDepth( 1.0f );
622  glClearStencil( 0x00 );
623  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
624 
626 
627  // Draw the background ( rectangle with color gradient)
628  // /////////////////////////////////////////////////////////////////////////
631 
632  glEnable( GL_DEPTH_TEST );
633 
634 
635  // Set projection and modelview matrixes
636  // /////////////////////////////////////////////////////////////////////////
637  glMatrixMode( GL_PROJECTION );
638  glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) );
639 
640  glMatrixMode( GL_MODELVIEW );
641  glLoadIdentity();
642  glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
643 
644 
645  // Position the headlight
646  // /////////////////////////////////////////////////////////////////////////
647 
648  setLight_Front( true );
649  setLight_Top( true );
650  setLight_Bottom( true );
651 
652  glEnable( GL_LIGHTING );
653 
654  {
655  const SFVEC3F &cameraPos = m_camera.GetPos();
656 
657  // Place the light at a minimun Z so the diffuse factor will not drop
658  // and the board will still look with good light.
659  float zpos;
660 
661  if( cameraPos.z > 0.0f )
662  {
663  zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
664  }
665  else
666  {
667  zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
668  }
669 
670  const GLfloat headlight_pos[] = { cameraPos.x,
671  cameraPos.y,
672  zpos,
673  1.0f }; // This is a point light
674 
675  glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
676  }
677 
678  const bool drawMiddleSegments = !( aIsMoving &&
680 
681  const bool skipRenderHoles = aIsMoving &&
683 
684  const bool skipRenderVias = aIsMoving &&
686 
688  {
689  // Draw vias and pad holes with copper material
691  }
692  else
693  {
694  OGL_SetMaterial( m_materials.m_GrayMaterial, 1.0f );
695  }
696 
697  if( (!( skipRenderVias || skipRenderHoles ) ) && m_ogl_disp_list_via )
698  {
700  }
701 
702  if( ( !skipRenderHoles ) && m_ogl_disp_list_pads_holes )
703  {
705  }
706 
707 
708  // Display copper and tech layers
709  // /////////////////////////////////////////////////////////////////////////
710  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
711  ii != m_ogl_disp_lists_layers.end();
712  ++ii )
713  {
714  const PCB_LAYER_ID layer_id = (PCB_LAYER_ID)(ii->first);
715 
716  // Mask layers are not processed here because they are a special case
717  if( (layer_id == B_Mask) || (layer_id == F_Mask) )
718  continue;
719 
720  // Do not show inner layers when it is displaying the board
721  // and board body is full opaque
723  ( m_boardAdapter.m_BoardBodyColor.a > 0.99f ) )
724  {
725  if( (layer_id > F_Cu) && (layer_id < B_Cu) )
726  continue;
727  }
728 
729  glPushMatrix();
730 
731  // !TODO: if we want to increase the separation between layers
732  //glScalef( 1.0f, 1.0f, 3.0f );
733 
734 
735  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
736 
737  if( (layer_id >= F_Cu) && (layer_id <= B_Cu) )
738  {
741  set_layer_material( layer_id );
742  else
744 
745  if( skipRenderHoles )
746  {
747  pLayerDispList->DrawAllCameraCulled( m_camera.GetPos().z, drawMiddleSegments );
748 
749  // Draw copper plated pads
750 
751  if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
753  setPlatedCopperAndDepthOffset( layer_id );
754 
755  if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu )
757  else
758  if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu )
760 
762  }
763  else
764  {
767  pLayerDispList->GetZBot(),
768  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
769 
770  if( m_ogl_disp_lists_layers_holes_outer.find( layer_id ) !=
772  {
773  const CLAYERS_OGL_DISP_LISTS* viasHolesLayer =
775 
776  wxASSERT( viasHolesLayer != NULL );
777 
778  if( viasHolesLayer != NULL )
779  {
780  pLayerDispList->DrawAllCameraCulledSubtractLayer(
781  drawMiddleSegments,
783  viasHolesLayer );
784 
785  // Draw copper plated pads
786 
787  if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
789  setPlatedCopperAndDepthOffset( layer_id );
790 
791  if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu )
792  {
794  drawMiddleSegments,
796  viasHolesLayer );
797  }
798  else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu )
799  {
801  drawMiddleSegments,
803  viasHolesLayer );
804  }
805 
807  }
808  }
809  else
810  {
811  pLayerDispList->DrawAllCameraCulledSubtractLayer(
812  drawMiddleSegments,
814 
815  // Draw copper plated pads
816 
817  if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
819  {
820  setPlatedCopperAndDepthOffset( layer_id );
821  }
822 
823  if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu )
824  {
826  drawMiddleSegments,
828  }
829  else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu )
830  {
832  drawMiddleSegments,
834  }
835 
837  }
838  }
839  }
840  else
841  {
842  set_layer_material( layer_id );
843 
844  CLAYERS_OGL_DISP_LISTS* dispListThroughHolesOuter =
846  && ( ( layer_id == B_SilkS ) || ( layer_id == F_SilkS ) ) ) ?
849 
850  if( dispListThroughHolesOuter )
851  {
852  dispListThroughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(),
853  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
854  }
855 
857  {
859  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
860  }
861 
862  if( (!skipRenderHoles) &&
864  ( ( ( layer_id == B_SilkS ) &&
865  ( m_ogl_disp_lists_layers.find( B_Mask ) != m_ogl_disp_lists_layers.end() ) ) ||
866  ( ( layer_id == F_SilkS ) &&
867  ( m_ogl_disp_lists_layers.find( F_Mask ) != m_ogl_disp_lists_layers.end() ) ) ) )
868  {
869  const PCB_LAYER_ID layerMask_id = (layer_id == B_SilkS) ? B_Mask : F_Mask;
870 
871  const CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( layerMask_id );
872 
873  pLayerDispList->DrawAllCameraCulledSubtractLayer(
874  drawMiddleSegments,
875  pLayerDispListMask,
876  dispListThroughHolesOuter,
878  }
879  else
880  {
881  if( !skipRenderHoles &&
882  dispListThroughHolesOuter && ( layer_id == B_SilkS || layer_id == F_SilkS ) )
883  {
884  pLayerDispList->DrawAllCameraCulledSubtractLayer(
885  drawMiddleSegments,
886  nullptr,
887  dispListThroughHolesOuter,
889  }
890  else
891  {
892  // Do not render Paste layers when skipRenderHoles is enabled
893  // otherwise it will cause z-fight issues
894  if( !( skipRenderHoles && ( layer_id == B_Paste || layer_id == F_Paste ) ) )
895  {
896  pLayerDispList->DrawAllCameraCulledSubtractLayer(
897  drawMiddleSegments,
899  }
900  }
901  }
902  }
903 
904  glPopMatrix();
905  }
906 
907  // Render 3D Models (Non-transparent)
908  // /////////////////////////////////////////////////////////////////////////
909  render_3D_models( false, false );
910  render_3D_models( true, false );
911 
912  // Display board body
913  // /////////////////////////////////////////////////////////////////////////
915  {
916  render_board_body( skipRenderHoles );
917  }
918 
919  // Display transparent mask layers
920  // /////////////////////////////////////////////////////////////////////////
922  {
923  //setLight_Top( true );
924  //setLight_Bottom( true );
925 
926  // add a depth buffer offset, it will help to hide some artifacts
927  // on silkscreen where the SolderMask is removed
928  glEnable( GL_POLYGON_OFFSET_FILL );
929  glPolygonOffset( 0.0f, -2.0f );
930 
931  if( m_camera.GetPos().z > 0 )
932  {
934  drawMiddleSegments, skipRenderHoles );
935 
937  drawMiddleSegments, skipRenderHoles );
938  }
939  else
940  {
942  drawMiddleSegments, skipRenderHoles );
943 
945  drawMiddleSegments, skipRenderHoles );
946  }
947 
948  glDisable( GL_POLYGON_OFFSET_FILL );
949  glPolygonOffset( 0.0f, 0.0f );
950  }
951 
952 
953  // Render 3D Models (Transparent)
954  // /////////////////////////////////////////////////////////////////////////
955  // !TODO: this can be optimized. If there are no transparent models (or no opacity),
956  // then there is no need to make this function call.
957 
958  glDepthMask( GL_FALSE );
959 
960  glEnable( GL_BLEND );
961  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
962 
963  // Enables Texture Env so it can combine model transparency with
964  // each module opacity setting
965  glEnable( GL_TEXTURE_2D );
966  glActiveTexture( GL_TEXTURE0 );
967 
968  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
969  glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
970  glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
971 
972  glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
973  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
974 
975  glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
976  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
977 
978  glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
979  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
980  glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
981  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_CONSTANT );
982 
983  render_3D_models( false, true );
984  render_3D_models( true, true );
985 
986  glDisable( GL_BLEND );
988 
989  glDepthMask( GL_TRUE );
990 
991  // Render Grid
992  // /////////////////////////////////////////////////////////////////////////
993 
995  {
996  glDisable( GL_LIGHTING );
997 
998  if( glIsList( m_ogl_disp_list_grid ) )
999  glCallList( m_ogl_disp_list_grid );
1000 
1001  glEnable( GL_LIGHTING );
1002  }
1003 
1004 
1005  // Render 3D arrows
1006  // /////////////////////////////////////////////////////////////////////////
1007  if( m_boardAdapter.GetFlag( FL_AXIS ) )
1008  render_3D_arrows();
1009 
1010  // Return back to the original viewport (this is important if we want
1011  // to take a screenshot after the render)
1012  // /////////////////////////////////////////////////////////////////////////
1013  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
1014 
1015  return false;
1016 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_F_Cu
void generate_new_3DGrid(GRID3D_TYPE aGridType)
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_B_Cu
void render_3D_models(bool aRenderTopOrBot, bool aRenderTransparentOnly)
render_3D_models
void OGL_SetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:145
float GetLayerTopZpos3DU(PCB_LAYER_ID aLayerId) const noexcept
GetLayerTopZpos3DU - Get the top z position.
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
const SFVEC3F & GetPos() const
Definition: ccamera.h:113
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_anti_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_ring
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
void ApplyScalePosition(float aZposition, float aZscale)
void setLight_Top(bool enabled)
GRID3D_TYPE m_last_grid_type
Stores the last grid computed.
void render_solder_mask_layer(PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
void OGL_DrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
OGL_DrawBackground.
Definition: ogl_utils.cpp:184
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
void setPlatedCopperAndDepthOffset(PCB_LAYER_ID aLayer_id)
PCB_LAYER_ID
A quick note on layer IDs:
SFVEC4F m_BgColorTop
background top color
void setLight_Front(bool enabled)
float GetLayerBottomZpos3DU(PCB_LAYER_ID aLayerId) const noexcept
GetLayerBottomZpos3DU - Get the bottom z position.
#define NULL
void setLight_Bottom(bool enabled)
bool m_is_opengl_initialized
flag if the opengl specific for this render was already initialized
void OGL_ResetTextureStateDefaults()
OGL_ResetTextureStateDefaults - resets to default state the texture settings.
Definition: ogl_utils.cpp:213
SFVEC4F m_BgColorBot
background bottom color
wxSize m_windowSize
The window size that this camera is working.
void DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
DrawAllCameraCulled - Draw all layers if they are visible by the camera.
struct C3D_RENDER_OGL_LEGACY::@0 m_materials
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
void reload(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
void DrawAll(bool aDrawMiddle=true) const
DrawAll - This function calls all the display lists.
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
const glm::mat4 & GetViewMatrix() const
Definition: ccamera.cpp:423
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
#define _(s)
Definition: 3d_actions.cpp:33
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const glm::mat4 & GetProjectionMatrix() const
Definition: ccamera.cpp:393
void set_layer_material(PCB_LAYER_ID aLayerID)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_pads_holes
GRID3D_TYPE GridGet() const noexcept
GridGet - get the current grid.
void render_board_body(bool aSkipRenderHoles)
void DrawAllCameraCulledSubtractLayer(bool aDrawMiddle, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA=nullptr, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB=nullptr, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractC=nullptr) const

References _, CLAYERS_OGL_DISP_LISTS::ApplyScalePosition(), B_Cu, B_Mask, B_Paste, B_SilkS, C3D_RENDER_BASE::CreateBusyIndicator(), CLAYERS_OGL_DISP_LISTS::DrawAll(), CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulled(), CLAYERS_OGL_DISP_LISTS::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, generate_new_3DGrid(), BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetLayerBottomZpos3DU(), BOARD_ADAPTER::GetLayerTopZpos3DU(), CCAMERA::GetPos(), CCAMERA::GetProjectionMatrix(), CCAMERA::GetViewMatrix(), CLAYERS_OGL_DISP_LISTS::GetZBot(), CLAYERS_OGL_DISP_LISTS::GetZTop(), BOARD_ADAPTER::GridGet(), initializeOpenGL(), BOARD_ADAPTER::m_BgColorBot, BOARD_ADAPTER::m_BgColorTop, C3D_RENDER_BASE::m_boardAdapter, BOARD_ADAPTER::m_BoardBodyColor, C3D_RENDER_BASE::m_camera, C3D_RENDER_BASE::m_is_opengl_initialized, m_last_grid_type, m_materials, m_ogl_disp_list_anti_board, m_ogl_disp_list_grid, m_ogl_disp_list_pads_holes, m_ogl_disp_list_through_holes_outer, m_ogl_disp_list_through_holes_outer_ring, m_ogl_disp_list_via, m_ogl_disp_lists_layers, m_ogl_disp_lists_layers_holes_outer, m_ogl_disp_lists_platedPads_B_Cu, m_ogl_disp_lists_platedPads_F_Cu, C3D_RENDER_BASE::m_reloadRequested, C3D_RENDER_BASE::m_windowSize, NONE, NULL, OGL_DrawBackground(), OGL_ResetTextureStateDefaults(), OGL_SetMaterial(), reload(), render_3D_arrows(), render_3D_models(), render_board_body(), render_solder_mask_layer(), REPORTER::Report(), set_layer_material(), setCopperMaterial(), setLight_Bottom(), setLight_Front(), setLight_Top(), setPlatedCopperAndDepthOffset(), setupMaterials(), and unsetDepthOffset().

◆ reload()

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

Definition at line 481 of file c3d_render_createscene_ogl_legacy.cpp.

482 {
483  m_reloadRequested = false;
484 
486 
488 
489  unsigned stats_startReloadTime = GetRunningMicroSecs();
490 
491  m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
492 
494  m_camera.SetBoardLookAtPos( camera_pos );
495 
496  if( aStatusReporter )
497  aStatusReporter->Report( _( "Load OpenGL: board" ) );
498 
499  // Create Board
500  // /////////////////////////////////////////////////////////////////////////
501 
503 
504  SHAPE_POLY_SET anti_board;
505  anti_board.NewOutline();
506  anti_board.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
507  anti_board.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
508  anti_board.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
509  anti_board.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
510  anti_board.Outline( 0 ).SetClosed( true );
511 
512  anti_board.BooleanSubtract( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_FAST );
513  m_ogl_disp_list_anti_board = createBoard( anti_board );
514 
517 
518  // Create Through Holes and vias
519  // /////////////////////////////////////////////////////////////////////////
520 
521  if( aStatusReporter )
522  aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
523 
527  1.0f,
528  0.0f,
529  false );
530 
532 
535 
538  bodyHoles,
539  1.0f,
540  0.0f,
541  false );
542 
546  1.0f,
547  0.0f,
548  false );
549 
551  {
555  1.0f,
556  0.0f,
557  false );
558  }
559 
560  // Not in use
561  //m_ogl_disp_list_through_holes_vias_inner = generate_holes_display_list(
562  // m_boardAdapter.GetThroughHole_Vias_Inner().GetList(),
563  // m_boardAdapter.GetThroughHole_Vias_Inner_poly(),
564  // 1.0f, 0.0f,
565  // false );
566 
567  const MAP_POLY & innerMapHoles = m_boardAdapter.GetPolyMapHoles_Inner();
568  const MAP_POLY & outerMapHoles = m_boardAdapter.GetPolyMapHoles_Outer();
569 
570  wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
571 
573 
574  if( outerMapHoles.size() > 0 )
575  {
576  float layer_z_bot = 0.0f;
577  float layer_z_top = 0.0f;
578 
579  for( MAP_POLY::const_iterator ii = outerMapHoles.begin();
580  ii != outerMapHoles.end();
581  ++ii )
582  {
583  PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
584  const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
585  const CBVHCONTAINER2D *container = map_holes.at( layer_id );
586 
587  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
588 
590  container->GetList(), *poly, layer_z_top, layer_z_bot, false );
591  }
592 
593  for( MAP_POLY::const_iterator ii = innerMapHoles.begin();
594  ii != innerMapHoles.end();
595  ++ii )
596  {
597  PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
598  const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
599  const CBVHCONTAINER2D *container = map_holes.at( layer_id );
600 
601  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
602 
604  container->GetList(), *poly, layer_z_top, layer_z_bot, false );
605  }
606  }
607 
608  // Generate vertical cylinders of vias and pads (copper)
610 
611  // Add layers maps
612 
613  if( aStatusReporter )
614  aStatusReporter->Report( _( "Load OpenGL: layers" ) );
615 
616  const MAP_POLY &map_poly = m_boardAdapter.GetPolyMap();
617 
618  for( MAP_CONTAINER_2D::const_iterator ii = m_boardAdapter.GetMapLayers().begin();
619  ii != m_boardAdapter.GetMapLayers().end();
620  ++ii )
621  {
622  PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
623 
624  if( !m_boardAdapter.Is3DLayerEnabled( layer_id ) )
625  continue;
626 
627  const CBVHCONTAINER2D *container2d = static_cast<const CBVHCONTAINER2D *>(ii->second);
628 
629  // Load the vertical (Z axis) component of shapes
630  const SHAPE_POLY_SET *aPolyList = nullptr;
631 
632  if( map_poly.find( layer_id ) != map_poly.end() )
633  {
634  aPolyList = map_poly.at( layer_id );
635  }
636 
637  CLAYERS_OGL_DISP_LISTS* oglList = generateLayerListFromContainer( container2d, aPolyList, layer_id );
638 
639  if( oglList != nullptr )
640  m_ogl_disp_lists_layers[layer_id] = oglList;
641 
642  }// for each layer on
643 
645  {
650  }
651 
652  // Load 3D models
653  // /////////////////////////////////////////////////////////////////////////
654  if( aStatusReporter )
655  aStatusReporter->Report( _( "Loading 3D models" ) );
656 
657  load_3D_models( aStatusReporter );
658 
659  if( aStatusReporter )
660  {
661  // Calculation time in seconds
662  const double calculation_time = (double)( GetRunningMicroSecs() -
663  stats_startReloadTime) / 1e6;
664 
665  aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
666  }
667 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_F_Cu
std::map< PCB_LAYER_ID, CBVHCONTAINER2D * > MAP_CONTAINER_2D
A type that stores a container of 2d objects for each layer id.
Definition: board_adapter.h:50
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset union For aFastMode meaning, see function booleanOp
std::map< PCB_LAYER_ID, SHAPE_POLY_SET * > MAP_POLY
A type that stores polysets for each layer id.
Definition: board_adapter.h:56
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_lists_platedPads_B_Cu
CLAYERS_OGL_DISP_LISTS * generateLayerListFromContainer(const CBVHCONTAINER2D *aContainer, const SHAPE_POLY_SET *aPolyList, PCB_LAYER_ID aLayerId)
const MAP_CONTAINER_2D & GetMapLayersHoles() const noexcept
GetMapLayersHoles -Get the map of container that have the holes per layer.
void InitSettings(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
InitSettings - Function to be called by the render when it need to reload the settings for the board.
const MAP_POLY & GetPolyMapHoles_Outer() const noexcept
const CBVHCONTAINER2D & GetThroughHole_Vias_Outer() const noexcept
GetThroughHole_Vias_Outer -.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_anti_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_ring
const CBVHCONTAINER2D * GetPlatedPads_Front() const noexcept
const SHAPE_POLY_SET * GetPolyPlatedPads_Front()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
const MAP_CONTAINER_2D & GetMapLayers() const noexcept
GetMapLayers - Get the map of container that have the objects per layer.
const SHAPE_POLY_SET & GetThroughHole_Outer_poly_NPTH() const noexcept
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
void get_layer_z_pos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
PCB_LAYER_ID
A quick note on layer IDs:
const CBVHCONTAINER2D & GetThroughHole_Outer() const noexcept
GetThroughHole_Outer - Get the inflated ThroughHole container.
const CBVHCONTAINER2D * GetPlatedPads_Back() const noexcept
const MAP_POLY & GetPolyMapHoles_Inner() const noexcept
SHAPE_POLY_SET.
const SHAPE_POLY_SET * GetPolyPlatedPads_Back()
bool Is3DLayerEnabled(PCB_LAYER_ID aLayer) const
Is3DLayerEnabled - Check if a layer is enabled.
CLAYERS_OGL_DISP_LISTS * createBoard(const SHAPE_POLY_SET &aBoardPoly)
void load_3D_models(REPORTER *aStatusReporter)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
const SHAPE_POLY_SET & GetBoardPoly() const noexcept
GetBoardPoly - Get the current polygon of the epoxy board.
int NewOutline()
Creates a new empty polygon in the set and returns its index
const SHAPE_POLY_SET & GetThroughHole_Outer_Ring_poly() const noexcept
static COBJECT2D_STATS & Instance()
Definition: cobject2d.h:152
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
const MAP_POLY & GetPolyMap() const noexcept
GetPolyMap - Get maps of polygons's layers.
const CBVHCONTAINER2D & GetThroughHole_Outer_Ring() const noexcept
GetThroughHole_Outer_Ring - Get the ThroughHole container that include the width of the annular ring.
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
CLAYERS_OGL_DISP_LISTS * generate_holes_display_list(const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces)
const SHAPE_POLY_SET & GetThroughHole_Outer_poly() const noexcept
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
const SFVEC3F & GetBoardCenter3DU() const noexcept
GetBoardCenter - the board center position in 3d units.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
#define _(s)
Definition: 3d_actions.cpp:33
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void SetItIsTransparent(bool aSetTransparent)
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: ccamera.h:118
void ResetStats()
Definition: cobject2d.h:135
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
const SHAPE_POLY_SET & GetThroughHole_Vias_Outer_poly() const noexcept
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:64

References _, B_Cu, SHAPE_POLY_SET::BooleanAdd(), createBoard(), F_Cu, FL_CLIP_SILK_ON_VIA_ANNULUS, FL_RENDER_PLATED_PADS_AS_PLATED, Format(), generate_3D_Vias_and_Pads(), generate_holes_display_list(), generateLayerListFromContainer(), get_layer_z_pos(), BOARD_ADAPTER::GetBoardCenter3DU(), BOARD_ADAPTER::GetBoardPoly(), BOARD_ADAPTER::GetFlag(), CGENERICCONTAINER2D::GetList(), BOARD_ADAPTER::GetMapLayers(), BOARD_ADAPTER::GetMapLayersHoles(), BOARD_ADAPTER::GetPlatedPads_Back(), BOARD_ADAPTER::GetPlatedPads_Front(), BOARD_ADAPTER::GetPolyMap(), BOARD_ADAPTER::GetPolyMapHoles_Inner(), BOARD_ADAPTER::GetPolyMapHoles_Outer(), BOARD_ADAPTER::GetPolyPlatedPads_Back(), BOARD_ADAPTER::GetPolyPlatedPads_Front(), GetRunningMicroSecs(), BOARD_ADAPTER::GetThroughHole_Outer(), BOARD_ADAPTER::GetThroughHole_Outer_poly(), BOARD_ADAPTER::GetThroughHole_Outer_poly_NPTH(), BOARD_ADAPTER::GetThroughHole_Outer_Ring(), BOARD_ADAPTER::GetThroughHole_Outer_Ring_poly(), BOARD_ADAPTER::GetThroughHole_Vias_Outer(), BOARD_ADAPTER::GetThroughHole_Vias_Outer_poly(), BOARD_ADAPTER::InitSettings(), COBJECT2D_STATS::Instance(), BOARD_ADAPTER::Is3DLayerEnabled(), load_3D_models(), C3D_RENDER_BASE::m_boardAdapter, C3D_RENDER_BASE::m_camera, m_ogl_disp_list_anti_board, m_ogl_disp_list_board, m_ogl_disp_list_through_holes_outer, m_ogl_disp_list_through_holes_outer_ring, m_ogl_disp_list_through_holes_outer_with_npth, m_ogl_disp_list_through_holes_vias_outer, m_ogl_disp_lists_layers, m_ogl_disp_lists_layers_holes_inner, m_ogl_disp_lists_layers_holes_outer, m_ogl_disp_lists_platedPads_B_Cu, m_ogl_disp_lists_platedPads_F_Cu, C3D_RENDER_BASE::m_reloadRequested, SHAPE_POLY_SET::NewOutline(), ogl_free_all_display_lists(), SHAPE_POLY_SET::PM_FAST, REPORTER::Report(), COBJECT2D_STATS::ResetStats(), CCAMERA::SetBoardLookAtPos(), and CLAYERS_OGL_DISP_LISTS::SetItIsTransparent().

Referenced by Redraw().

◆ ReloadRequest()

void C3D_RENDER_BASE::ReloadRequest ( )
inlineinherited

ReloadRequest - !TODO: this must be reviewed to add flags to improve specific render.

Definition at line 76 of file c3d_render_base.h.

76 { m_reloadRequested = true; }
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types

References C3D_RENDER_BASE::m_reloadRequested.

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

◆ render_3D_arrows()

void C3D_RENDER_OGL_LEGACY::render_3D_arrows ( )
private

Definition at line 140 of file c3d_render_ogl_legacy.cpp.

141 {
142  const float arrow_size = RANGE_SCALE_3D * 0.30f;
143 
144  glDisable( GL_CULL_FACE );
145 
146  // YxY squared view port, this is on propose
147  glViewport( 4, 4, m_windowSize.y / 8 , m_windowSize.y / 8 );
148  glClear( GL_DEPTH_BUFFER_BIT );
149 
150  glMatrixMode( GL_PROJECTION );
151  glLoadIdentity();
152  gluPerspective( 45.0f, 1.0f, 0.001f, RANGE_SCALE_3D );
153 
154  glMatrixMode( GL_MODELVIEW );
155  glLoadIdentity();
156 
157  const glm::mat4 TranslationMatrix = glm::translate(
158  glm::mat4(1.0f),
159  SFVEC3F( 0.0f, 0.0f, -(arrow_size * 2.75f) ) );
160 
161  const glm::mat4 ViewMatrix = TranslationMatrix * m_camera.GetRotationMatrix();
162 
163  glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
164 
166 
167  glColor3f( 0.9f, 0.0f, 0.0f );
168  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
169  SFVEC3F( arrow_size, 0.0f, 0.0f ),
170  0.275f );
171 
172  glColor3f( 0.0f, 0.9f, 0.0f );
173  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
174  SFVEC3F( 0.0f, arrow_size, 0.0f ),
175  0.275f );
176 
177  glColor3f( 0.0f, 0.0f, 0.9f );
178  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
179  SFVEC3F( 0.0f, 0.0f, arrow_size ),
180  0.275f );
181 
182  glEnable( GL_CULL_FACE );
183 }
const glm::mat4 GetRotationMatrix() const
Function GetRotationMatrix Get the rotation matrix to be applied in a transformation camera.
Definition: ccamera.cpp:157
wxSize m_windowSize
The window size that this camera is working.
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:61
void OGL_draw_arrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
OGL_draw_arrow - draw a round arrow.

References CCAMERA::GetRotationMatrix(), C3D_RENDER_BASE::m_camera, C3D_RENDER_BASE::m_windowSize, OGL_draw_arrow(), ogl_set_arrow_material(), and RANGE_SCALE_3D.

Referenced by Redraw().

◆ render_3D_models()

void C3D_RENDER_OGL_LEGACY::render_3D_models ( bool  aRenderTopOrBot,
bool  aRenderTransparentOnly 
)
private

render_3D_models

Parameters
aRenderTopOrBot- true will render Top, false will render bottom
aRenderTransparentOnly- true will render only the transparent objects, false will render opaque

Definition at line 1295 of file c3d_render_ogl_legacy.cpp.

1297 {
1299  render_3D_models_selected( aRenderTopOrBot, aRenderTransparentOnly, true );
1300 
1301  render_3D_models_selected( aRenderTopOrBot, aRenderTransparentOnly, false );
1302 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
void render_3D_models_selected(bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render

References FL_USE_SELECTION, BOARD_ADAPTER::GetFlag(), C3D_RENDER_BASE::m_boardAdapter, and render_3D_models_selected().

Referenced by Redraw().

◆ render_3D_models_selected()

void C3D_RENDER_OGL_LEGACY::render_3D_models_selected ( bool  aRenderTopOrBot,
bool  aRenderTransparentOnly,
bool  aRenderSelectedOnly 
)
private

Definition at line 1253 of file c3d_render_ogl_legacy.cpp.

1254 {
1255 
1256  C_OGL_3DMODEL::BeginDrawMulti( !aRenderSelectedOnly );
1257 
1258  // Go for all footprints
1259  for( auto module : m_boardAdapter.GetBoard()->Modules() )
1260  {
1261  const bool isIntersected = ( module == m_currentIntersectedBoardItem );
1262 
1264  !isIntersected &&
1265  ( ( aRenderSelectedOnly && !module->IsSelected() ) ||
1266  ( !aRenderSelectedOnly && module->IsSelected() ) ) )
1267  continue;
1268 
1269  if( isIntersected && aRenderSelectedOnly )
1270  {
1271  glEnable( GL_POLYGON_OFFSET_LINE );
1272  glPolygonOffset( 8.0, 1.0 );
1273 
1274  glPolygonMode( GL_FRONT, GL_LINE );
1275  glLineWidth( 6 );
1276  }
1277 
1278  if( !module->Models().empty() )
1279  if( m_boardAdapter.ShouldModuleBeDisplayed((MODULE_ATTR_T) module->GetAttributes() ) )
1280  if( ( aRenderTopOrBot && !module->IsFlipped() )
1281  || ( !aRenderTopOrBot && module->IsFlipped() ) )
1282  render_3D_module( module, aRenderTransparentOnly, isIntersected );
1283 
1284  if( isIntersected && aRenderSelectedOnly )
1285  {
1286  // Restore
1287  glDisable( GL_POLYGON_OFFSET_LINE );
1288  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
1289  }
1290  }
1291 
1293 }
static void EndDrawMulti()
EndDrawMulti - cleanup render states after drawing multiple models.
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
void render_3D_module(const MODULE *module, bool aRenderTransparentOnly, bool aIsSelected)
MODULES & Modules()
Definition: class_board.h:284
const BOARD * GetBoard() const noexcept
GetBoard - Get current board to be rendered.
MODULE_ATTR_T
Enum MODULE_ATTR_T is the set of attributes allowed within a MODULE, using MODULE::SetAttributes() an...
Definition: class_module.h:66
BOARD_ITEM * m_currentIntersectedBoardItem
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
bool ShouldModuleBeDisplayed(MODULE_ATTR_T aModuleAttributs) const
ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs and the flags.
static void BeginDrawMulti(bool aUseColorInformation)
BeginDrawMulti - set some basic render states before drawing multiple models.

References C_OGL_3DMODEL::BeginDrawMulti(), C_OGL_3DMODEL::EndDrawMulti(), FL_USE_SELECTION, BOARD_ADAPTER::GetBoard(), BOARD_ADAPTER::GetFlag(), C3D_RENDER_BASE::m_boardAdapter, m_currentIntersectedBoardItem, BOARD::Modules(), render_3D_module(), and BOARD_ADAPTER::ShouldModuleBeDisplayed().

Referenced by render_3D_models().

◆ render_3D_module()

void C3D_RENDER_OGL_LEGACY::render_3D_module ( const MODULE module,
bool  aRenderTransparentOnly,
bool  aIsSelected 
)
private

Definition at line 1305 of file c3d_render_ogl_legacy.cpp.

1308 {
1309  if( !module->Models().empty() )
1310  {
1311  const double zpos = m_boardAdapter.GetModulesZcoord3DIU( module->IsFlipped() );
1312 
1313  glPushMatrix();
1314 
1315  wxPoint pos = module->GetPosition();
1316 
1317  glTranslatef( pos.x * m_boardAdapter.BiuTo3Dunits(),
1318  -pos.y * m_boardAdapter.BiuTo3Dunits(),
1319  zpos );
1320 
1321  if( module->GetOrientation() )
1322  glRotated( (double) module->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
1323 
1324  if( module->IsFlipped() )
1325  {
1326  glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1327  glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1328  }
1329 
1330  double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
1331 
1332  glScaled( modelunit_to_3d_units_factor,
1333  modelunit_to_3d_units_factor,
1334  modelunit_to_3d_units_factor );
1335 
1336  // Get the list of model files for this model
1337  for( const MODULE_3D_SETTINGS& sM : module->Models() )
1338  {
1339  if( !sM.m_Show || sM.m_Filename.empty() )
1340  continue;
1341 
1342  // Check if the model is present in our cache map
1343  auto cache_i = m_3dmodel_map.find( sM.m_Filename );
1344 
1345  if( cache_i == m_3dmodel_map.end() )
1346  continue;
1347 
1348  if( const C_OGL_3DMODEL *modelPtr = cache_i->second )
1349  {
1350  bool opaque = sM.m_Opacity >= 1.0;
1351 
1352  if( ( !aRenderTransparentOnly && modelPtr->Have_opaque() && opaque ) ||
1353  ( aRenderTransparentOnly && ( modelPtr->Have_transparent() || !opaque ) ) )
1354  {
1355  glPushMatrix();
1356 
1357  // FIXME: don't do this over and over again unless the
1358  // values have changed. cache the matrix somewhere.
1359  glm::mat4 mtx( 1 );
1360  mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
1361  mtx = glm::rotate(
1362  mtx, glm::radians( (float) -sM.m_Rotation.z ), { 0.0f, 0.0f, 1.0f } );
1363  mtx = glm::rotate(
1364  mtx, glm::radians( (float) -sM.m_Rotation.y ), { 0.0f, 1.0f, 0.0f } );
1365  mtx = glm::rotate(
1366  mtx, glm::radians( (float) -sM.m_Rotation.x ), { 1.0f, 0.0f, 0.0f } );
1367  mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
1368  glMultMatrixf( glm::value_ptr( mtx ) );
1369 
1370  if( aRenderTransparentOnly )
1371  modelPtr->Draw_transparent( sM.m_Opacity,
1372  module->IsSelected() || aIsSelected,
1374  else
1375  modelPtr->Draw_opaque( module->IsSelected() || aIsSelected,
1377 
1379  {
1380  glEnable( GL_BLEND );
1381  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1382 
1383  glDisable( GL_LIGHTING );
1384 
1385  glLineWidth( 1 );
1386  modelPtr->Draw_bboxes();
1387 
1388  glLineWidth( 4 );
1389  modelPtr->Draw_bbox();
1390 
1391  glEnable( GL_LIGHTING );
1392  glDisable( GL_BLEND );
1393  }
1394 
1395  glPopMatrix();
1396  }
1397  }
1398  }
1399 
1400  glPopMatrix();
1401  }
1402 }
double BiuTo3Dunits() const noexcept
BiuTo3Dunits - Board integer units To 3D units.
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
double GetOrientation() const
Definition: class_module.h:206
bool IsSelected() const
Definition: eda_item.h:192
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:284
#define UNITS3D_TO_UNITSPCB
Scale convertion from 3d model units to pcb units.
SFVEC3F m_opengl_selectionColor
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:196
const int scale
float GetModulesZcoord3DIU(bool aIsFlipped) const
GetModulesZcoord3DIU - Get the position of the module in 3d integer units considering if it is flippe...
wxPoint GetPosition() const override
Definition: class_module.h:201

References BOARD_ADAPTER::BiuTo3Dunits(), FL_RENDER_OPENGL_SHOW_MODEL_BBOX, BOARD_ADAPTER::GetFlag(), BOARD_ADAPTER::GetModulesZcoord3DIU(), MODULE::GetOrientation(), MODULE::GetPosition(), MODULE::IsFlipped(), EDA_ITEM::IsSelected(), m_3dmodel_map, C3D_RENDER_BASE::m_boardAdapter, BOARD_ADAPTER::m_opengl_selectionColor, MODULE::Models(), scale, and UNITS3D_TO_UNITSPCB.

Referenced by render_3D_models_selected().

◆ render_board_body()

void C3D_RENDER_OGL_LEGACY::render_board_body ( bool  aSkipRenderHoles)
private

Definition at line 529 of file c3d_render_ogl_legacy.cpp.

530 {
532  {
535 
536 
537  m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
538  m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a; // opacity to transparency
539 
540  OGL_SetMaterial( m_materials.m_EpoxyBoard, 1.0f );
541 
543 
544  if( (m_ogl_disp_list_through_holes_outer_with_npth) && (!aSkipRenderHoles) )
545  {
549 
551  true,
553  }
554  else
555  {
557  }
558  }
559 }
void OGL_SetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:145
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
void ApplyScalePosition(float aZposition, float aZscale)
struct C3D_RENDER_OGL_LEGACY::@0 m_materials
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
void DrawAll(bool aDrawMiddle=true) const
DrawAll - This function calls all the display lists.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
void SetItIsTransparent(bool aSetTransparent)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
float GetEpoxyThickness3DU() const noexcept
GetEpoxyThickness3DU - Get the current epoxy thickness.
void DrawAllCameraCulledSubtractLayer(bool aDrawMiddle, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA=nullptr, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB=nullptr, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractC=nullptr) const

References CLAYERS_OGL_DISP_LISTS::ApplyScalePosition(), CLAYERS_OGL_DISP_LISTS::DrawAll(), CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer(), BOARD_ADAPTER::GetEpoxyThickness3DU(), C3D_RENDER_BASE::m_boardAdapter, BOARD_ADAPTER::m_BoardBodyColor, m_materials, m_ogl_disp_list_board, m_ogl_disp_list_through_holes_outer_with_npth, OGL_SetMaterial(), and CLAYERS_OGL_DISP_LISTS::SetItIsTransparent().

Referenced by Redraw().

◆ render_solder_mask_layer()

void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer ( PCB_LAYER_ID  aLayerID,
float  aZPosition,
bool  aDrawMiddleSegments,
bool  aSkipRenderHoles 
)
private

Definition at line 1181 of file c3d_render_ogl_legacy.cpp.

1185 {
1186  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
1187 
1188  if( m_ogl_disp_list_board )
1189  {
1190  if( m_ogl_disp_lists_layers.find( aLayerID ) !=
1191  m_ogl_disp_lists_layers.end() )
1192  {
1193  CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID );
1194 
1197  aZPosition,
1199 
1201  aZPosition,
1203 
1204  set_layer_material( aLayerID );
1205 
1207 
1208  if( aSkipRenderHoles )
1209  {
1211  aDrawMiddleSegments );
1212  }
1213  else
1214  {
1216  aDrawMiddleSegments,
1217  pLayerDispListMask,
1219  }
1220  }
1221  else
1222  {
1223  // This case there is no layer with mask, so we will render the full board as mask
1224 
1227  aZPosition,
1229 
1231  aZPosition,
1233 
1234  set_layer_material( aLayerID );
1235 
1237 
1238  if( aSkipRenderHoles )
1239  {
1241  aDrawMiddleSegments );
1242  }
1243  else
1244  {
1246  aDrawMiddleSegments,
1248  }
1249  }
1250  }
1251 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
const SFVEC3F & GetPos() const
Definition: ccamera.h:113
void ApplyScalePosition(float aZposition, float aZscale)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
void DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
DrawAllCameraCulled - Draw all layers if they are visible by the camera.
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer.
void SetItIsTransparent(bool aSetTransparent)
float GetNonCopperLayerThickness3DU() const noexcept
GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
void set_layer_material(PCB_LAYER_ID aLayerID)
void DrawAllCameraCulledSubtractLayer(bool aDrawMiddle, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA=nullptr, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB=nullptr, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractC=nullptr) const

References CLAYERS_OGL_DISP_LISTS::ApplyScalePosition(), B_Mask, CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulled(), CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer(), F_Mask, BOARD_ADAPTER::GetNonCopperLayerThickness3DU(), CCAMERA::GetPos(), C3D_RENDER_BASE::m_boardAdapter, C3D_RENDER_BASE::m_camera, m_ogl_disp_list_board, m_ogl_disp_list_through_holes_vias_outer, m_ogl_disp_lists_layers, set_layer_material(), and CLAYERS_OGL_DISP_LISTS::SetItIsTransparent().

Referenced by Redraw().

◆ set_layer_material()

void C3D_RENDER_OGL_LEGACY::set_layer_material ( PCB_LAYER_ID  aLayerID)
private

Definition at line 331 of file c3d_render_ogl_legacy.cpp.

332 {
333  switch( aLayerID )
334  {
335  case F_Mask:
336  case B_Mask:
337  {
338  const SFVEC4F layerColor = get_layer_color( aLayerID );
339 
340  m_materials.m_SolderMask.m_Diffuse = layerColor;
341  m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a; // Convert Opacity to Transparency
342 
344  {
345  m_materials.m_SolderMask.m_Ambient = m_materials.m_SolderMask.m_Diffuse * 0.3f;
346 
347  m_materials.m_SolderMask.m_Specular = m_materials.m_SolderMask.m_Diffuse *
348  m_materials.m_SolderMask.m_Diffuse;
349  }
350 
351  OGL_SetMaterial( m_materials.m_SolderMask, 1.0f );
352  break;
353  }
354 
355  case B_Paste:
356  case F_Paste:
357  m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
358  OGL_SetMaterial( m_materials.m_Paste, 1.0f );
359  break;
360 
361  case B_SilkS:
362  m_materials.m_SilkSBot.m_Diffuse = get_layer_color( aLayerID );
363  OGL_SetMaterial( m_materials.m_SilkSBot, 1.0f );
364  break;
365 
366  case F_SilkS:
367  m_materials.m_SilkSTop.m_Diffuse = get_layer_color( aLayerID );
368  OGL_SetMaterial( m_materials.m_SilkSTop, 1.0f );
369  break;
370 
371  case B_Adhes:
372  case F_Adhes:
373  case Dwgs_User:
374  case Cmts_User:
375  case Eco1_User:
376  case Eco2_User:
377  case Edge_Cuts:
378  case Margin:
379  case B_CrtYd:
380  case F_CrtYd:
381  case B_Fab:
382  case F_Fab:
383  m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID );
384  m_materials.m_Plastic.m_Ambient = SFVEC3F(
385  m_materials.m_Plastic.m_Diffuse.r * 0.05f,
386  m_materials.m_Plastic.m_Diffuse.g * 0.05f,
387  m_materials.m_Plastic.m_Diffuse.b * 0.05f );
388 
389  m_materials.m_Plastic.m_Specular = SFVEC3F(
390  m_materials.m_Plastic.m_Diffuse.r * 0.7f,
391  m_materials.m_Plastic.m_Diffuse.g * 0.7f,
392  m_materials.m_Plastic.m_Diffuse.b * 0.7f );
393 
394  m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
395  m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
396  OGL_SetMaterial( m_materials.m_Plastic, 1.0f );
397  break;
398 
399  default:
400  m_materials.m_Copper.m_Diffuse = get_layer_color( aLayerID );
401  OGL_SetMaterial( m_materials.m_Copper, 1.0f );
402 
403  break;
404  }
405 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
void OGL_SetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:145
struct C3D_RENDER_OGL_LEGACY::@0 m_materials
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC4F get_layer_color(PCB_LAYER_ID aLayerID)

References B_Adhes, B_CrtYd, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Fab, F_Mask, F_Paste, F_SilkS, FL_USE_REALISTIC_MODE, get_layer_color(), BOARD_ADAPTER::GetFlag(), C3D_RENDER_BASE::m_boardAdapter, m_materials, Margin, and OGL_SetMaterial().

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

◆ SetBusyIndicatorFactory()

void C3D_RENDER_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 59 of file c3d_render_base.cpp.

60 {
61  m_busyIndicatorFactory = aNewFactory;
62 }
BUSY_INDICATOR::FACTORY m_busyIndicatorFactory
Factory that returns a suitable busy indicator for the context.

References C3D_RENDER_BASE::m_busyIndicatorFactory.

◆ setCopperMaterial()

void C3D_RENDER_OGL_LEGACY::setCopperMaterial ( )
private

Definition at line 512 of file c3d_render_ogl_legacy.cpp.

513 {
514  OGL_SetMaterial( m_materials.m_NonPlatedCopper, 1.0f );
515 }
void OGL_SetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:145
struct C3D_RENDER_OGL_LEGACY::@0 m_materials

References m_materials, and OGL_SetMaterial().

Referenced by Redraw().

◆ SetCurrentIntersectedBoardItem()

void C3D_RENDER_OGL_LEGACY::SetCurrentIntersectedBoardItem ( BOARD_ITEM aCurrentIntersectedBoardItem)
inline

Definition at line 72 of file c3d_render_ogl_legacy.h.

72 { m_currentIntersectedBoardItem = aCurrentIntersectedBoardItem; }
BOARD_ITEM * m_currentIntersectedBoardItem

References m_currentIntersectedBoardItem.

Referenced by EDA_3D_CANVAS::OnMouseMove().

◆ SetCurWindowSize()

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

SetCurWindowSize - 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 C3D_RENDER_BASE.

Definition at line 101 of file c3d_render_ogl_legacy.cpp.

102 {
103  if( m_windowSize != aSize )
104  {
105  m_windowSize = aSize;
106  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
107 
108  // Initialize here any screen dependent data here
109  }
110 }
wxSize m_windowSize
The window size that this camera is working.

References C3D_RENDER_BASE::m_windowSize.

◆ setLight_Bottom()

void C3D_RENDER_OGL_LEGACY::setLight_Bottom ( bool  enabled)
private

Definition at line 131 of file c3d_render_ogl_legacy.cpp.

132 {
133  if( enabled )
134  glEnable( GL_LIGHT2 );
135  else
136  glDisable( GL_LIGHT2 );
137 }

Referenced by Redraw().

◆ setLight_Front()

void C3D_RENDER_OGL_LEGACY::setLight_Front ( bool  enabled)
private

Definition at line 113 of file c3d_render_ogl_legacy.cpp.

114 {
115  if( enabled )
116  glEnable( GL_LIGHT0 );
117  else
118  glDisable( GL_LIGHT0 );
119 }

Referenced by Redraw().

◆ setLight_Top()

void C3D_RENDER_OGL_LEGACY::setLight_Top ( bool  enabled)
private

Definition at line 122 of file c3d_render_ogl_legacy.cpp.

123 {
124  if( enabled )
125  glEnable( GL_LIGHT1 );
126  else
127  glDisable( GL_LIGHT1 );
128 }

Referenced by Redraw().

◆ setPlatedCopperAndDepthOffset()

void C3D_RENDER_OGL_LEGACY::setPlatedCopperAndDepthOffset ( PCB_LAYER_ID  aLayer_id)
private

Definition at line 517 of file c3d_render_ogl_legacy.cpp.

518 {
519  glEnable( GL_POLYGON_OFFSET_FILL );
520  glPolygonOffset( 0.0f, -2.0f );
521  set_layer_material( aLayer_id );
522 }
void set_layer_material(PCB_LAYER_ID aLayerID)

References set_layer_material().

Referenced by Redraw().

◆ setupMaterials()

void C3D_RENDER_OGL_LEGACY::setupMaterials ( )
private

Definition at line 186 of file c3d_render_ogl_legacy.cpp.

187 {
188  m_materials = {};
189 
191  {
192  // http://devernay.free.fr/cours/opengl/materials.html
193 
194  // Plated copper
195  // Copper material mixed with the copper color
196  m_materials.m_Copper.m_Ambient = SFVEC3F( m_boardAdapter.m_CopperColor.r * 0.1f,
197  m_boardAdapter.m_CopperColor.g * 0.1f,
198  m_boardAdapter.m_CopperColor.b * 0.1f);
199 
200  m_materials.m_Copper.m_Specular = SFVEC3F( m_boardAdapter.m_CopperColor.r * 0.75f + 0.25f,
201  m_boardAdapter.m_CopperColor.g * 0.75f + 0.25f,
202  m_boardAdapter.m_CopperColor.b * 0.75f + 0.25f );
203 
204  // This guess the material type(ex: copper vs gold) to determine the
205  // shininess factor between 0.1 and 0.4
206  float shininessfactor = 0.40f - mapf( fabs( m_boardAdapter.m_CopperColor.r -
208  0.15f, 1.00f,
209  0.00f, 0.30f );
210 
211  m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
212  m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
213 
214 
215  // Non plated copper (raw copper)
216  m_materials.m_NonPlatedCopper.m_Ambient = SFVEC3F( 0.191f, 0.073f, 0.022f );
217  m_materials.m_NonPlatedCopper.m_Diffuse = SFVEC3F( 184.0f / 255.0f, 115.0f / 255.0f, 50.0f / 255.0f );
218  m_materials.m_NonPlatedCopper.m_Specular = SFVEC3F( 0.256f, 0.137f, 0.086f );
219  m_materials.m_NonPlatedCopper.m_Shininess = 0.1f * 128.0f;
220  m_materials.m_NonPlatedCopper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
221 
222  // Paste material mixed with paste color
223  m_materials.m_Paste.m_Ambient = SFVEC3F( m_boardAdapter.m_SolderPasteColor.r,
226 
227  m_materials.m_Paste.m_Specular = SFVEC3F( m_boardAdapter.m_SolderPasteColor.r *
233 
234  m_materials.m_Paste.m_Shininess = 0.1f * 128.0f;
235  m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
236 
237 
238  // Silk screen material mixed with silk screen color
239  m_materials.m_SilkSTop.m_Ambient = SFVEC3F( m_boardAdapter.m_SilkScreenColorTop.r,
242 
243  m_materials.m_SilkSTop.m_Specular = SFVEC3F(
247 
248  m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
249  m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
250 
251  // Silk screen material mixed with silk screen color
252  m_materials.m_SilkSBot.m_Ambient = SFVEC3F( m_boardAdapter.m_SilkScreenColorBot.r,
255 
256  m_materials.m_SilkSBot.m_Specular = SFVEC3F(
260 
261  m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
262  m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
263 
264  m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
265  m_materials.m_SolderMask.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
266 
267  // Epoxy material
268  m_materials.m_EpoxyBoard.m_Ambient = SFVEC3F( 117.0f / 255.0f,
269  97.0f / 255.0f,
270  47.0f / 255.0f );
271 
272  m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f,
273  3.0f / 255.0f,
274  20.0f / 255.0f );
275 
276  m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
277  m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
278  }
279  else // Technical Mode
280  {
281  const SFVEC3F matAmbientColor = SFVEC3F( 0.10f );
282  const SFVEC3F matSpecularColor = SFVEC3F( 0.10f );
283  const float matShininess = 0.1f * 128.0f;
284 
285  // Copper material
286  m_materials.m_Copper.m_Ambient = matAmbientColor;
287  m_materials.m_Copper.m_Specular = matSpecularColor;
288  m_materials.m_Copper.m_Shininess = matShininess;
289  m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
290 
291  // Paste material
292  m_materials.m_Paste.m_Ambient = matAmbientColor;
293  m_materials.m_Paste.m_Specular = matSpecularColor;
294  m_materials.m_Paste.m_Shininess = matShininess;
295  m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
296 
297  // Silk screen material
298  m_materials.m_SilkSTop.m_Ambient = matAmbientColor;
299  m_materials.m_SilkSTop.m_Specular = matSpecularColor;
300  m_materials.m_SilkSTop.m_Shininess = matShininess;
301  m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
302 
303  // Silk screen material
304  m_materials.m_SilkSBot.m_Ambient = matAmbientColor;
305  m_materials.m_SilkSBot.m_Specular = matSpecularColor;
306  m_materials.m_SilkSBot.m_Shininess = matShininess;
307  m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
308 
309  // Solder mask material
310  m_materials.m_SolderMask.m_Ambient = matAmbientColor;
311  m_materials.m_SolderMask.m_Specular = matSpecularColor;
312  m_materials.m_SolderMask.m_Shininess = matShininess;
313  m_materials.m_SolderMask.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
314 
315  // Epoxy material
316  m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
317  m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
318  m_materials.m_EpoxyBoard.m_Shininess = matShininess;
319  m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
320 
321  // Gray material (used for example in technical vias and pad holes)
322  m_materials.m_GrayMaterial.m_Ambient = SFVEC3F( 0.8f, 0.8f, 0.8f );
323  m_materials.m_GrayMaterial.m_Diffuse = SFVEC3F( 0.3f, 0.3f, 0.3f );
324  m_materials.m_GrayMaterial.m_Specular = SFVEC3F( 0.4f, 0.4f, 0.4f );
325  m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
326  m_materials.m_GrayMaterial.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
327  }
328 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
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:136
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
struct C3D_RENDER_OGL_LEGACY::@0 m_materials
BOARD_ADAPTER & m_boardAdapter
settings refrence in use for this render
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC4F m_CopperColor
in realistic mode: copper color
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )

References FL_USE_REALISTIC_MODE, BOARD_ADAPTER::GetFlag(), C3D_RENDER_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 C3D_RENDER_OGL_LEGACY::unsetDepthOffset ( )
private

Definition at line 524 of file c3d_render_ogl_legacy.cpp.

525 {
526  glDisable( GL_POLYGON_OFFSET_FILL );
527 }

Referenced by Redraw().

Member Data Documentation

◆ m_3dmodel_map

MAP_3DMODEL C3D_RENDER_OGL_LEGACY::m_3dmodel_map
private

◆ m_boardAdapter

◆ m_camera

◆ m_Copper

SMATERIAL C3D_RENDER_OGL_LEGACY::m_Copper

Definition at line 226 of file c3d_render_ogl_legacy.h.

◆ m_currentIntersectedBoardItem

BOARD_ITEM* C3D_RENDER_OGL_LEGACY::m_currentIntersectedBoardItem
private

◆ m_EpoxyBoard

SMATERIAL C3D_RENDER_OGL_LEGACY::m_EpoxyBoard

Definition at line 224 of file c3d_render_ogl_legacy.h.

◆ m_GrayMaterial

SMATERIAL C3D_RENDER_OGL_LEGACY::m_GrayMaterial

Definition at line 228 of file c3d_render_ogl_legacy.h.

◆ m_is_opengl_initialized

bool C3D_RENDER_BASE::m_is_opengl_initialized
protectedinherited

flag if the opengl specific for this render was already initialized

Definition at line 115 of file c3d_render_base.h.

Referenced by C3D_RENDER_BASE::C3D_RENDER_BASE(), initializeOpenGL(), C3D_RENDER_RAYTRACING::initializeOpenGL(), Redraw(), and C3D_RENDER_RAYTRACING::Redraw().

◆ m_last_grid_type

GRID3D_TYPE C3D_RENDER_OGL_LEGACY::m_last_grid_type
private

Stores the last grid computed.

Definition at line 108 of file c3d_render_ogl_legacy.h.

Referenced by C3D_RENDER_OGL_LEGACY(), and Redraw().

◆ m_logTrace

const wxChar * C3D_RENDER_BASE::m_logTrace = wxT( "KI_TRACE_3D_RENDER" )
staticprotectedinherited

Trace mask used to enable or disable the trace output of this class.

The debug output can be turned on by setting the WXTRACE environment variable to "KI_TRACE_3D_RENDER". See the wxWidgets documentation on wxLogTrace for more information.

Definition at line 129 of file c3d_render_base.h.

Referenced by C3D_RENDER_BASE::C3D_RENDER_BASE(), C3D_RENDER_OGL_LEGACY(), C3D_RENDER_RAYTRACING::C3D_RENDER_RAYTRACING(), C3D_RENDER_RAYTRACING::opengl_init_pbo(), ~C3D_RENDER_OGL_LEGACY(), and C3D_RENDER_RAYTRACING::~C3D_RENDER_RAYTRACING().

◆ m_materials

struct { ... } C3D_RENDER_OGL_LEGACY::m_materials

◆ m_NonPlatedCopper

SMATERIAL C3D_RENDER_OGL_LEGACY::m_NonPlatedCopper

Definition at line 225 of file c3d_render_ogl_legacy.h.

◆ m_ogl_circle_texture

◆ m_ogl_disp_list_anti_board

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_anti_board
private

◆ m_ogl_disp_list_board

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_board
private

◆ m_ogl_disp_list_grid

GLuint C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_grid
private

oGL list that stores current grid

Definition at line 106 of file c3d_render_ogl_legacy.h.

Referenced by C3D_RENDER_OGL_LEGACY(), generate_new_3DGrid(), ogl_free_all_display_lists(), and Redraw().

◆ m_ogl_disp_list_pads_holes

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_pads_holes
private

◆ m_ogl_disp_list_through_holes_outer

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_outer
private

◆ m_ogl_disp_list_through_holes_outer_ring

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_outer_ring
private

◆ m_ogl_disp_list_through_holes_outer_with_npth

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_outer_with_npth
private

◆ m_ogl_disp_list_through_holes_vias_outer

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_vias_outer
private

◆ m_ogl_disp_list_via

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_via
private

◆ m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
private

Definition at line 100 of file c3d_render_ogl_legacy.h.

Referenced by C3D_RENDER_OGL_LEGACY(), and ogl_free_all_display_lists().

◆ m_ogl_disp_lists_layers

MAP_OGL_DISP_LISTS C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_layers
private

◆ m_ogl_disp_lists_layers_holes_inner

MAP_OGL_DISP_LISTS C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_layers_holes_inner
private

◆ m_ogl_disp_lists_layers_holes_outer

MAP_OGL_DISP_LISTS C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_layers_holes_outer
private

◆ m_ogl_disp_lists_platedPads_B_Cu

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_platedPads_B_Cu
private

◆ m_ogl_disp_lists_platedPads_F_Cu

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_platedPads_F_Cu
private

◆ m_Paste

SMATERIAL C3D_RENDER_OGL_LEGACY::m_Paste

Definition at line 220 of file c3d_render_ogl_legacy.h.

◆ m_Plastic

SMATERIAL C3D_RENDER_OGL_LEGACY::m_Plastic

Definition at line 227 of file c3d_render_ogl_legacy.h.

◆ m_reloadRequested

bool C3D_RENDER_BASE::m_reloadRequested
protectedinherited

◆ m_SilkSBot

SMATERIAL C3D_RENDER_OGL_LEGACY::m_SilkSBot

Definition at line 221 of file c3d_render_ogl_legacy.h.

◆ m_SilkSTop

SMATERIAL C3D_RENDER_OGL_LEGACY::m_SilkSTop

Definition at line 222 of file c3d_render_ogl_legacy.h.

◆ m_SolderMask

SMATERIAL C3D_RENDER_OGL_LEGACY::m_SolderMask

Definition at line 223 of file c3d_render_ogl_legacy.h.

◆ m_triangles

LIST_TRIANGLES C3D_RENDER_OGL_LEGACY::m_triangles
private

◆ m_windowSize


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