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 (CINFO3D_VISU &aSettings)
 
 ~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 *aStatusTextReporter) 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...
 
const MAP_OGL_DISP_LISTSGetLayerDispListMap () const
 
const CLAYERS_OGL_DISP_LISTSGetLayerDispList (PCB_LAYER_ID aLayerId) const
 
const CLAYERS_OGL_DISP_LISTSGetBoardDispList () const
 
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...
 

Protected Attributes

CINFO3D_VISUm_settings
 settings refrence in use for this render More...
 
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 ()
 
void reload (REPORTER *aStatusTextReporter)
 
void ogl_set_arrow_material ()
 
void ogl_free_all_display_lists ()
 
void generate_through_outer_holes ()
 
void generate_through_inner_holes ()
 
CLAYERS_OGL_DISP_LISTSgenerate_holes_display_list (const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces)
 
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 aIsRenderingOnPreviewMode)
 
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 *aStatusTextReporter)
 
void render_3D_models (bool aRenderTopOrBot, bool aRenderTransparentOnly)
 render_3D_models More...
 
void render_3D_module (const MODULE *module, bool aRenderTransparentOnly)
 
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 set_layer_material (PCB_LAYER_ID aLayerID)
 
SFVEC3F get_layer_color (PCB_LAYER_ID aLayerID)
 

Private Attributes

MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
 
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_through_holes_outer
 
CLAYERS_OGL_DISP_LISTSm_ogl_disp_list_through_holes_inner
 
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_vias_and_pad_holes_outer_contourn_and_caps
 
MAP_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
 
struct {
   SMATERIAL   m_Paste
 
   SMATERIAL   m_SilkS
 
   SMATERIAL   m_SolderMask
 
   SMATERIAL   m_EpoxyBoard
 
   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 ( CINFO3D_VISU aSettings)
explicit

Definition at line 46 of file c3d_render_ogl_legacy.cpp.

References GRID3D_NONE, m_3dmodel_map, m_last_grid_type, C3D_RENDER_BASE::m_logTrace, m_ogl_circle_texture, m_ogl_disp_list_board, m_ogl_disp_list_grid, m_ogl_disp_list_pads_holes, m_ogl_disp_list_through_holes_inner, m_ogl_disp_list_through_holes_outer, 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, and m_triangles.

46  :
47  C3D_RENDER_BASE( aSettings )
48 {
49  wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY" ) );
50 
54  m_triangles.clear();
55  m_ogl_disp_list_board = NULL;
56 
61  //m_ogl_disp_list_through_holes_vias_inner = NULL;
62  m_ogl_disp_list_via = NULL;
65 
69 
70  m_3dmodel_map.clear();
71 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
GRID3D_TYPE m_last_grid_type
Stores the last grid computed.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_inner
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
C3D_RENDER_BASE(CINFO3D_VISU &aSettings)
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
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.
C3D_RENDER_OGL_LEGACY::~C3D_RENDER_OGL_LEGACY ( )

Definition at line 74 of file c3d_render_ogl_legacy.cpp.

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

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

Member Function Documentation

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.

References CLAYER_TRIANGLE_CONTAINER::AddQuad(), generate_ring_contour(), CRING2D::GetCenter(), CRING2D::GetInnerRadius(), CINFO3D_VISU::GetNrSegmentsCircle(), CRING2D::GetOuterRadius(), i, CLAYER_TRIANGLES::m_layer_bot_triangles, CLAYER_TRIANGLES::m_layer_top_triangles, and C3D_RENDER_BASE::m_settings.

Referenced by generate_holes_display_list(), and reload().

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_settings.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)
CINFO3D_VISU & m_settings
settings refrence in use for this render
const SFVEC2F & GetCenter() const
Definition: cring2d.h:38
float GetOuterRadius() const
Definition: cring2d.h:40
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
CLAYER_TRIANGLE_CONTAINER * m_layer_top_triangles
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
size_t i
Definition: json11.cpp:597
float GetInnerRadius() const
Definition: cring2d.h:39
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
AddQuad.
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.

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

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 & GetV2() const
const SFVEC2F & GetV3() const
const SFVEC2F & GetV1() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const SFVEC2F & GetV0() const
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
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.

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.

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 }
const SFVEC2F & GetCenter() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
AddTriangle.
float GetRadius() const
#define SIZE_OF_CIRCLE_TEXTURE
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_segment_ends
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
CLAYER_TRIANGLE_CONTAINER * m_layer_top_segment_ends
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.

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

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 & GetP1() const
Definition: ctriangle2d.h:58
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const SFVEC2F & GetP2() const
Definition: ctriangle2d.h:59
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)
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.

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.

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
float GetRadiusSquared() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
float GetRadius() const
CLAYER_TRIANGLE_CONTAINER * m_layer_top_triangles
const SFVEC2F & GetEnd() const
const SFVEC2F & GetLeftEnd() const
const SFVEC2F & GetRightStar() const
void AddTriangle(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
AddTriangle.
#define SIZE_OF_CIRCLE_TEXTURE
const SFVEC2F & GetLeftStar() const
const SFVEC2F & GetRightDir() const
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_segment_ends
CLAYER_TRIANGLE_CONTAINER * m_layer_bot_triangles
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const SFVEC2F & GetLeftDir() const
CLAYER_TRIANGLE_CONTAINER * m_layer_top_segment_ends
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
AddQuad.
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 672 of file c3d_render_createscene_ogl_legacy.cpp.

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(), generate_3D_Vias_and_Pads(), and reload().

678 {
679  aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
680  SFVEC3F( v1.x, v1.y, bot ),
681  SFVEC3F( v2.x, v2.y, bot ) );
682 
683  aDst->m_layer_top_triangles->AddTriangle( SFVEC3F( v2.x, v2.y, top ),
684  SFVEC3F( v1.x, v1.y, top ),
685  SFVEC3F( v0.x, v0.y, top ) );
686 }
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
void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads ( )
private

Definition at line 747 of file c3d_render_createscene_ogl_legacy.cpp.

References add_triangle_top_bot(), CLAYER_TRIANGLES::AddToMiddleContourns(), B_Cu, CINFO3D_VISU::BiuTo3Dunits(), SHAPE_POLY_SET::BooleanSubtract(), Convert_shape_line_polygon_to_triangles(), dummy(), F_Cu, generate_cylinder(), get_layer_z_pos(), CINFO3D_VISU::GetBoard(), CINFO3D_VISU::GetCircleCorrectionFactor(), CINFO3D_VISU::GetCopperThickness3DU(), CINFO3D_VISU::GetCopperThicknessBIU(), VIA::GetDrillValue(), CGENERICCONTAINER2D::GetList(), CINFO3D_VISU::GetNrSegmentsCircle(), COBJECT2D::GetObjectType(), TRACK::GetStart(), CINFO3D_VISU::GetStats_Med_Via_Hole_Diameter3DU(), CINFO3D_VISU::GetStats_Nr_Holes(), CINFO3D_VISU::GetStats_Nr_Vias(), VIA::LayerPair(), BOARD::m_Modules, m_ogl_circle_texture, m_ogl_disp_list_pads_holes, m_ogl_disp_list_via, C3D_RENDER_BASE::m_settings, BOARD::m_Track, min, TRACK::Next(), MODULE::Next(), D_PAD::Next(), OBJ2D_TRIANGLE, SHAPE_POLY_SET::OutlineCount(), PAD_ATTRIB_HOLE_NOT_PLATED, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by reload().

748 {
750  {
751  const unsigned int reserve_nr_triangles_estimation =
753  8 *
755 
756  CLAYER_TRIANGLES *layerTriangleVIA = new CLAYER_TRIANGLES( reserve_nr_triangles_estimation );
757 
758  // Insert plated vertical holes inside the board
759  // /////////////////////////////////////////////////////////////////////////
760 
761  // Insert vias holes (vertical cylinders)
762  for( const TRACK* track = m_settings.GetBoard()->m_Track;
763  track;
764  track = track->Next() )
765  {
766  if( track->Type() == PCB_VIA_T )
767  {
768  const VIA *via = static_cast<const VIA*>(track);
769 
770  const float holediameter = via->GetDrillValue() * m_settings.BiuTo3Dunits();
771  const float thickness = m_settings.GetCopperThickness3DU();
772  const int nrSegments = m_settings.GetNrSegmentsCircle( via->GetDrillValue() );
773  const double correctionFactor = m_settings.GetCircleCorrectionFactor( nrSegments );
774  const float hole_inner_radius = ( holediameter / 2.0f ) * correctionFactor;
775 
776  const SFVEC2F via_center( via->GetStart().x * m_settings.BiuTo3Dunits(),
777  -via->GetStart().y * m_settings.BiuTo3Dunits() );
778 
779  PCB_LAYER_ID top_layer, bottom_layer;
780  via->LayerPair( &top_layer, &bottom_layer );
781 
782  float ztop, zbot, dummy;
783 
784  get_layer_z_pos( top_layer, ztop, dummy );
785  get_layer_z_pos( bottom_layer, dummy, zbot );
786 
787  wxASSERT( zbot < ztop );
788 
789  generate_cylinder( via_center,
790  hole_inner_radius,
791  hole_inner_radius + thickness,
792  ztop,
793  zbot,
794  nrSegments,
795  layerTriangleVIA );
796  }
797  }
798 
799  m_ogl_disp_list_via = new CLAYERS_OGL_DISP_LISTS( *layerTriangleVIA,
800  0,
801  0.0f,
802  0.0f );
803 
804  delete layerTriangleVIA;
805  }
806 
807 
808  if( m_settings.GetStats_Nr_Holes() > 0 )
809  {
810  SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
811  SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
812 
813  tht_outer_holes_poly.RemoveAllContours();
814  tht_inner_holes_poly.RemoveAllContours();
815 
816  // Insert pads holes (vertical cylinders)
817  for( const MODULE* module = m_settings.GetBoard()->m_Modules;
818  module;
819  module = module->Next() )
820  {
821  for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
822  {
823  if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
824  {
825  const wxSize drillsize = pad->GetDrillSize();
826  const bool hasHole = drillsize.x && drillsize.y;
827 
828  if( !hasHole )
829  continue;
830 
831  // we use the hole diameter to calculate the seg count.
832  // for round holes, drillsize.x == drillsize.y
833  // for slots, the diameter is the smaller of (drillsize.x, drillsize.y)
834  int copperThickness = m_settings.GetCopperThicknessBIU();
835  int radius = std::min( drillsize.x, drillsize.y ) / 2 + copperThickness;
836  int nrSegments = m_settings.GetNrSegmentsCircle( radius * 2 );
837  double correctionFactor = m_settings.GetCircleCorrectionFactor( nrSegments );
838  int correction = radius * ( correctionFactor - 1 );
839 
840  pad->BuildPadDrillShapePolygon( tht_outer_holes_poly,
841  copperThickness + correction,
842  nrSegments );
843 
844  pad->BuildPadDrillShapePolygon( tht_inner_holes_poly,
845  correction,
846  nrSegments );
847  }
848  }
849  }
850 
851  // Subtract the holes
852  tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
853 
854 
855  CCONTAINER2D holesContainer;
856 
857  Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly,
858  holesContainer,
860  (const BOARD_ITEM &)*m_settings.GetBoard() );
861 
862  const LIST_OBJECT2D &listHolesObject2d = holesContainer.GetList();
863 
864  if( listHolesObject2d.size() > 0 )
865  {
866  float layer_z_top, layer_z_bot, dummy;
867 
868  get_layer_z_pos( F_Cu, layer_z_top, dummy );
869  get_layer_z_pos( B_Cu, dummy, layer_z_bot );
870 
871  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listHolesObject2d.size() );
872 
873  // Convert the list of objects(triangles) to triangle layer structure
874  for( LIST_OBJECT2D::const_iterator itemOnLayer = listHolesObject2d.begin();
875  itemOnLayer != listHolesObject2d.end();
876  ++itemOnLayer )
877  {
878  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
879 
880  wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE );
881 
882  const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
883 
884  const SFVEC2F &v1 = tri->GetP1();
885  const SFVEC2F &v2 = tri->GetP2();
886  const SFVEC2F &v3 = tri->GetP3();
887 
888  add_triangle_top_bot( layerTriangles,
889  v1,
890  v2,
891  v3,
892  layer_z_top,
893  layer_z_bot );
894  }
895 
896  wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
897 
898  if( tht_outer_holes_poly.OutlineCount() > 0 )
899  {
900  layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
901  layer_z_bot,
902  layer_z_top,
904  false );
905 
907  *layerTriangles,
908  m_ogl_circle_texture, // not need
909  layer_z_top,
910  layer_z_top );
911  }
912 
913  delete layerTriangles;
914  }
915  }
916 }
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:64
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists...
float GetCopperThickness3DU() const
GetCopperThickness3DU - Get the current copper layer thickness.
Definition: cinfo3d_visu.h:165
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
MODULE * Next() const
Definition: class_module.h:122
int GetCopperThicknessBIU() const
GetCopperThicknessBIU - Get the current copper layer thickness.
int OutlineCount() const
Returns the number of outlines in the set
float GetStats_Med_Via_Hole_Diameter3DU() const
GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes.
Definition: cinfo3d_visu.h:374
CINFO3D_VISU & m_settings
settings refrence in use for this render
PCB_LAYER_ID
A quick note on layer IDs:
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
const wxPoint & GetStart() const
Definition: class_track.h:126
D_PAD * Next() const
Definition: class_pad.h:160
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)
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...
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer...
TRACK * Next() const
Definition: class_track.h:103
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:37
DLIST< MODULE > m_Modules
Definition: class_board.h:249
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
unsigned int GetStats_Nr_Vias() const
GetStats_Nr_Vias - Get statistics of the nr of vias.
Definition: cinfo3d_visu.h:362
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
DLIST< TRACK > m_Track
Definition: class_board.h:250
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 BOARD * GetBoard() const
GetBoard - Get current board to be rendered.
Definition: cinfo3d_visu.h:128
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
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)
#define min(a, b)
Definition: auxiliary.h:85
unsigned int GetStats_Nr_Holes() const
GetStats_Nr_Holes - Get statistics of the nr of holes.
Definition: cinfo3d_visu.h:368
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 705 of file c3d_render_createscene_ogl_legacy.cpp.

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

Referenced by generate_3D_Vias_and_Pads().

712 {
713  std::vector< SFVEC2F > innerContour;
714  std::vector< SFVEC2F > outerContour;
715 
716  generate_ring_contour( aCenter,
717  aInnerRadius,
718  aOuterRadius,
719  aNr_sides_per_circle,
720  innerContour,
721  outerContour,
722  false );
723 
724  for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
725  {
726  const SFVEC2F &vi0 = innerContour[i + 0];
727  const SFVEC2F &vi1 = innerContour[i + 1];
728  const SFVEC2F &vo0 = outerContour[i + 0];
729  const SFVEC2F &vo1 = outerContour[i + 1];
730 
731  aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
732  SFVEC3F( vi0.x, vi0.y, aZtop ),
733  SFVEC3F( vo0.x, vo0.y, aZtop ),
734  SFVEC3F( vo1.x, vo1.y, aZtop ) );
735 
736  aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
737  SFVEC3F( vo1.x, vo1.y, aZbot ),
738  SFVEC3F( vo0.x, vo0.y, aZbot ),
739  SFVEC3F( vi0.x, vi0.y, aZbot ) );
740  }
741 
742  aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
743  aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
744 }
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
size_t i
Definition: json11.cpp:597
void AddQuad(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3, const SFVEC3F &aV4)
AddQuad.
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.

References add_object_to_triangle_layer(), CLAYER_TRIANGLES::AddToMiddleContourns(), CINFO3D_VISU::BiuTo3Dunits(), COBJECT2D::GetObjectType(), m_ogl_circle_texture, C3D_RENDER_BASE::m_settings, OBJ2D_FILLED_CIRCLE, OBJ2D_ROUNDSEG, and SHAPE_POLY_SET::OutlineCount().

Referenced by reload().

276 {
277  CLAYERS_OGL_DISP_LISTS *ret = NULL;
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() == OBJ2D_FILLED_CIRCLE) ||
291  (object2d_A->GetObjectType() == OBJ2D_ROUNDSEG) );
292 
293  switch( object2d_A->GetObjectType() )
294  {
295  case OBJ2D_FILLED_CIRCLE:
296  add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
297  layerTriangles,
298  aZtop, aZbot );
299  break;
300 
301  case OBJ2D_ROUNDSEG:
302  add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
303  layerTriangles,
304  aZtop, aZbot );
305  break;
306 
307  default:
308  wxFAIL_MSG("C3D_RENDER_OGL_LEGACY::generate_holes_display_list: Object type is not implemented");
309  break;
310  }
311  }
312 
313  // Note: he can have a aListHolesObject2d whith holes but without countours
314  // eg: when there are only NPTH on the list and the contours were not
315  // added
316 
317  if( aPoly.OutlineCount() > 0 )
318  {
319  layerTriangles->AddToMiddleContourns( aPoly,
320  aZbot,
321  aZtop,
323  aInvertFaces );
324  }
325 
326  ret = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
328  aZbot,
329  aZtop );
330 
331  delete layerTriangles;
332  }
333 
334  return ret;
335 }
void add_object_to_triangle_layer(const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists...
int OutlineCount() const
Returns the number of outlines in the set
CINFO3D_VISU & m_settings
settings refrence in use for this render
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer...
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid ( GRID3D_TYPE  aGridType)
private

Definition at line 1097 of file c3d_render_ogl_legacy.cpp.

References CINFO3D_VISU::BiuTo3Dunits(), DARKGRAY, delta, CINFO3D_VISU::GetBoardPosBIU(), CINFO3D_VISU::GetBoardSizeBIU(), CINFO3D_VISU::GetColor(), GRID3D_10MM, GRID3D_1MM, GRID3D_2P5MM, GRID3D_5MM, GRID3D_NONE, KiROUND(), LIGHTGRAY, m_ogl_disp_list_grid, C3D_RENDER_BASE::m_settings, max, and scale.

Referenced by Redraw().

1098 {
1099  if( glIsList( m_ogl_disp_list_grid ) )
1100  glDeleteLists( m_ogl_disp_list_grid, 1 );
1101 
1103 
1104  if( aGridType == GRID3D_NONE )
1105  return;
1106 
1107  m_ogl_disp_list_grid = glGenLists( 1 );
1108 
1109  if( !glIsList( m_ogl_disp_list_grid ) )
1110  return;
1111 
1112  glNewList( m_ogl_disp_list_grid, GL_COMPILE );
1113 
1114  glEnable( GL_BLEND );
1115  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1116 
1117  const double zpos = 0.0;
1118 
1119  // Color of grid lines
1120  const SFVEC3F gridColor = m_settings.GetColor( DARKGRAY );
1121 
1122  // Color of grid lines every 5 lines
1123  const SFVEC3F gridColor_marker = m_settings.GetColor( LIGHTGRAY );
1124  const double scale = m_settings.BiuTo3Dunits();
1125  const double transparency = 0.35;
1126 
1127  double griSizeMM = 0.0;
1128 
1129  switch( aGridType )
1130  {
1131  default:
1132  case GRID3D_NONE:
1133  return;
1134  case GRID3D_1MM:
1135  griSizeMM = 1.0;
1136  break;
1137  case GRID3D_2P5MM:
1138  griSizeMM = 2.5;
1139  break;
1140  case GRID3D_5MM:
1141  griSizeMM = 5.0;
1142  break;
1143  case GRID3D_10MM:
1144  griSizeMM = 10.0;
1145  break;
1146  }
1147 
1148  glNormal3f( 0.0, 0.0, 1.0 );
1149 
1150  const wxSize brd_size = m_settings.GetBoardSizeBIU();
1151  wxPoint brd_center_pos = m_settings.GetBoardPosBIU();
1152 
1153  brd_center_pos.y = -brd_center_pos.y;
1154 
1155  const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
1156  const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
1157 
1158  // Grid limits, in 3D units
1159  double xmin = (brd_center_pos.x - xsize / 2) * scale;
1160  double xmax = (brd_center_pos.x + xsize / 2) * scale;
1161  double ymin = (brd_center_pos.y - ysize / 2) * scale;
1162  double ymax = (brd_center_pos.y + ysize / 2) * scale;
1163  double zmin = Millimeter2iu( -50 ) * scale;
1164  double zmax = Millimeter2iu( 100 ) * scale;
1165 
1166  // Draw horizontal grid centered on 3D origin (center of the board)
1167  for( int ii = 0; ; ii++ )
1168  {
1169  if( (ii % 5) )
1170  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1171  else
1172  glColor4f( gridColor_marker.r,
1173  gridColor_marker.g,
1174  gridColor_marker.b,
1175  transparency );
1176 
1177  const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
1178 
1179  if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1180  {
1181  glBegin( GL_LINES );
1182  glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1183  glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1184  glEnd();
1185 
1186  if( ii != 0 )
1187  {
1188  glBegin( GL_LINES );
1189  glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1190  glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1191  glEnd();
1192  }
1193  }
1194 
1195  if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1196  {
1197  glBegin( GL_LINES );
1198  glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
1199  glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
1200  glEnd();
1201 
1202  if( ii != 0 )
1203  {
1204  glBegin( GL_LINES );
1205  glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
1206  glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
1207  glEnd();
1208  }
1209  }
1210 
1211  if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1212  break;
1213  }
1214 
1215  // Draw vertical grid on Z axis
1216  glNormal3f( 0.0, -1.0, 0.0 );
1217 
1218  // Draw vertical grid lines (parallel to Z axis)
1219  double posy = -brd_center_pos.y * scale;
1220 
1221  for( int ii = 0; ; ii++ )
1222  {
1223  if( (ii % 5) )
1224  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1225  else
1226  glColor4f( gridColor_marker.r,
1227  gridColor_marker.g,
1228  gridColor_marker.b,
1229  transparency );
1230 
1231  const double delta = ii * griSizeMM * IU_PER_MM;
1232 
1233  glBegin( GL_LINES );
1234  xmax = (brd_center_pos.x + delta) * scale;
1235 
1236  glVertex3f( xmax, posy, zmin );
1237  glVertex3f( xmax, posy, zmax );
1238  glEnd();
1239 
1240  if( ii != 0 )
1241  {
1242  glBegin( GL_LINES );
1243  xmin = (brd_center_pos.x - delta) * scale;
1244  glVertex3f( xmin, posy, zmin );
1245  glVertex3f( xmin, posy, zmax );
1246  glEnd();
1247  }
1248 
1249  if( delta > xsize / 2.0f )
1250  break;
1251  }
1252 
1253  // Draw horizontal grid lines on Z axis (parallel to X axis)
1254  for( int ii = 0; ; ii++ )
1255  {
1256  if( (ii % 5) )
1257  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1258  else
1259  glColor4f( gridColor_marker.r,
1260  gridColor_marker.g,
1261  gridColor_marker.b,
1262  transparency );
1263 
1264  const double delta = ii * griSizeMM * IU_PER_MM * scale;
1265 
1266  if( delta <= zmax )
1267  {
1268  // Draw grid lines on Z axis (positive Z axis coordinates)
1269  glBegin( GL_LINES );
1270  glVertex3f( xmin, posy, delta );
1271  glVertex3f( xmax, posy, delta );
1272  glEnd();
1273  }
1274 
1275  if( delta <= -zmin && ( ii != 0 ) )
1276  {
1277  // Draw grid lines on Z axis (negative Z axis coordinates)
1278  glBegin( GL_LINES );
1279  glVertex3f( xmin, posy, -delta );
1280  glVertex3f( xmax, posy, -delta );
1281  glEnd();
1282  }
1283 
1284  if( ( delta > zmax ) && ( delta > -zmin ) )
1285  break;
1286  }
1287 
1288  glDisable( GL_BLEND );
1289 
1290  glEndList();
1291 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
CINFO3D_VISU & m_settings
settings refrence in use for this render
static const int delta[8][2]
Definition: solve.cpp:112
wxPoint GetBoardPosBIU() const
GetBoardPosBIU - Get the board size.
Definition: cinfo3d_visu.h:183
SFVEC3F GetColor(COLOR4D aColor) const
GetColor.
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
const int scale
#define max(a, b)
Definition: auxiliary.h:86
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
wxSize GetBoardSizeBIU() const
GetBoardSizeBIU - Get the board size.
Definition: cinfo3d_visu.h:177
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
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.

References PNS::angle(), and delta.

Referenced by add_object_to_triangle_layer(), and generate_cylinder().

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.push_back( SFVEC2F( aCenter.x + rotatedDir.x * aInnerRadius,
116  aCenter.y + rotatedDir.y * aInnerRadius ) );
117 
118  aOuterContourResult.push_back( SFVEC2F( 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 }
static const int delta[8][2]
Definition: solve.cpp:112
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void C3D_RENDER_OGL_LEGACY::generate_through_inner_holes ( )
private
void C3D_RENDER_OGL_LEGACY::generate_through_outer_holes ( )
private
SFVEC3F C3D_RENDER_OGL_LEGACY::get_layer_color ( PCB_LAYER_ID  aLayerID)
private

Definition at line 362 of file c3d_render_ogl_legacy.cpp.

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, CINFO3D_VISU::GetFlag(), CINFO3D_VISU::GetLayerColor(), CINFO3D_VISU::m_CopperColor, C3D_RENDER_BASE::m_settings, CINFO3D_VISU::m_SilkScreenColor, CINFO3D_VISU::m_SolderMaskColor, CINFO3D_VISU::m_SolderPasteColor, and Margin.

Referenced by set_layer_material().

363 {
364  SFVEC3F layerColor = m_settings.GetLayerColor( aLayerID );
365 
367  {
368  switch( aLayerID )
369  {
370  case B_Adhes:
371  case F_Adhes:
372  break;
373 
374  case B_Mask:
375  case F_Mask:
376  layerColor = m_settings.m_SolderMaskColor;
377  break;
378 
379  case B_Paste:
380  case F_Paste:
381  layerColor = m_settings.m_SolderPasteColor;
382  break;
383 
384  case B_SilkS:
385  case F_SilkS:
386  layerColor = m_settings.m_SilkScreenColor;
387  break;
388 
389  case Dwgs_User:
390  case Cmts_User:
391  case Eco1_User:
392  case Eco2_User:
393  case Edge_Cuts:
394  case Margin:
395  break;
396 
397  case B_CrtYd:
398  case F_CrtYd:
399  break;
400 
401  case B_Fab:
402  case F_Fab:
403  break;
404 
405  default:
406  layerColor = m_settings.m_CopperColor;
407  break;
408  }
409  }
410 
411  return layerColor;
412 }
SFVEC3F GetLayerColor(PCB_LAYER_ID aLayerId) const
GetLayerColor - get the technical color of a layer.
SFVEC3D m_CopperColor
in realistic mode: copper color
Definition: cinfo3d_visu.h:509
CINFO3D_VISU & m_settings
settings refrence in use for this render
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:507
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:506
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
SFVEC3D m_SilkScreenColor
in realistic mode: SilkScreen color
Definition: cinfo3d_visu.h:508
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void C3D_RENDER_OGL_LEGACY::get_layer_z_pos ( PCB_LAYER_ID  aLayerID,
float &  aOutZtop,
float &  aOutZbot 
) const
private

Definition at line 689 of file c3d_render_createscene_ogl_legacy.cpp.

References CINFO3D_VISU::GetLayerBottomZpos3DU(), CINFO3D_VISU::GetLayerTopZpos3DU(), and C3D_RENDER_BASE::m_settings.

Referenced by generate_3D_Vias_and_Pads(), and reload().

692 {
693  aOutZbot = m_settings.GetLayerBottomZpos3DU( aLayerID );
694  aOutZtop = m_settings.GetLayerTopZpos3DU( aLayerID );
695 
696  if( aOutZtop < aOutZbot )
697  {
698  float tmpFloat = aOutZbot;
699  aOutZbot = aOutZtop;
700  aOutZtop = tmpFloat;
701  }
702 }
CINFO3D_VISU & m_settings
settings refrence in use for this render
float GetLayerTopZpos3DU(PCB_LAYER_ID aLayerId) const
GetLayerTopZpos3DU - Get the top z position.
Definition: cinfo3d_visu.h:280
float GetLayerBottomZpos3DU(PCB_LAYER_ID aLayerId) const
GetLayerBottomZpos3DU - Get the bottom z position.
Definition: cinfo3d_visu.h:287
const CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::GetBoardDispList ( ) const
inline

Definition at line 217 of file c3d_render_ogl_legacy.h.

References m_ogl_disp_list_board.

217 { return m_ogl_disp_list_board; }
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
const CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::GetLayerDispList ( PCB_LAYER_ID  aLayerId) const
inline

Definition at line 216 of file c3d_render_ogl_legacy.h.

216 { return m_ogl_disp_lists_layers.at( aLayerId ); }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
const MAP_OGL_DISP_LISTS& C3D_RENDER_OGL_LEGACY::GetLayerDispListMap ( ) const
inline

Definition at line 215 of file c3d_render_ogl_legacy.h.

References m_ogl_disp_lists_layers.

215 { return m_ogl_disp_lists_layers; }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
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 84 of file c3d_render_ogl_legacy.cpp.

85 {
86  return 50; // ms
87 }
bool C3D_RENDER_OGL_LEGACY::initializeOpenGL ( )
private

Definition at line 768 of file c3d_render_ogl_legacy.cpp.

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

Referenced by Redraw().

769 {
770  glEnable( GL_LINE_SMOOTH );
771  glShadeModel( GL_SMOOTH );
772 
773  // 4-byte pixel alignment
774  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
775 
776  // Initialize the open GL texture to draw the filled semi-circle of the segments
778 
779  if( !circleImage )
780  return false;
781 
782  circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
783  (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
784  (SIZE_OF_CIRCLE_TEXTURE / 2) - 4,
785  0xFF );
786 
787  //circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
788  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
789  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 2, 0xFF );
790 
791  CIMAGE *circleImage_Copy = new CIMAGE( *circleImage );
792 
793  circleImage->EfxFilter( circleImage_Copy, FILTER_BLUR_3X3 );
794 
795  m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
796 
797  //circleImage_Copy->SaveAsPNG("circleImage.png");
798  delete circleImage_Copy;
799  circleImage_Copy = 0;
800 
801  //circleImage->SaveAsPNG("circleImage_blured.png");
802  delete circleImage;
803  circleImage = 0;
804 
805  init_lights();
806 
807  // Use this mode if you want see the triangle lines (debug proposes)
808  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
809 
811 
812  return true;
813 }
void init_lights(void)
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
CircleFilled.
Definition: cimage.cpp:172
GLuint OGL_LoadTexture(const CIMAGE &aImage)
OGL_LoadTexture - generate a new OpenGL texture.
Definition: ogl_utils.cpp:80
bool m_is_opengl_initialized
flag if the opengl specific for this render was already initialized
#define SIZE_OF_CIRCLE_TEXTURE
Class CIMAGE manages a 8-bit channel image.
Definition: cimage.h:86
void EfxFilter(CIMAGE *aInImg, E_FILTER aFilterType)
Function EfxFilter apply a filter to the input image and stores it in the image class this <- FilterT...
Definition: cimage.cpp:469
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 79 of file c3d_render_base.h.

References C3D_RENDER_BASE::GetWaitForEditingTimeOut(), and C3D_RENDER_BASE::m_reloadRequested.

Referenced by EDA_3D_CANVAS::IsReloadRequestPending().

79 { return m_reloadRequested; }
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
void C3D_RENDER_OGL_LEGACY::load_3D_models ( REPORTER aStatusTextReporter)
private

Definition at line 925 of file c3d_render_createscene_ogl_legacy.cpp.

References FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, CINFO3D_VISU::Get3DCacheManager(), CINFO3D_VISU::GetBoard(), CINFO3D_VISU::GetFlag(), S3D_CACHE::GetModel(), m_3dmodel_map, BOARD::m_Modules, C3D_RENDER_BASE::m_settings, CINFO3D_VISU::MaterialModeGet(), MODULE::Next(), and REPORTER::Report().

Referenced by reload().

926 {
930  return;
931 
932  // Go for all modules
933  for( const MODULE* module = m_settings.GetBoard()->m_Modules;
934  module;
935  module = module->Next() )
936  {
937  if( !module->Models().empty() )
938  {
939  // Get the list of model files for this model
940  auto sM = module->Models().begin();
941  auto eM = module->Models().end();
942 
943  while( sM != eM )
944  {
945  if( !sM->m_Filename.empty() )
946  {
947  if( aStatusTextReporter )
948  {
949  // Display the short filename of the 3D model loaded:
950  // (the full name is usually too long to be displayed)
951  wxFileName fn( sM->m_Filename );
952  wxString msg;
953  msg.Printf( _( "Loading %s" ), fn.GetFullName() );
954  aStatusTextReporter->Report( msg );
955  }
956 
957  // Check if the model is not present in our cache map
958  // (Not already loaded in memory)
959  if( m_3dmodel_map.find( sM->m_Filename ) == m_3dmodel_map.end() )
960  {
961  // It is not present, try get it from cache
962  const S3DMODEL *modelPtr =
963  m_settings.Get3DCacheManager()->GetModel( sM->m_Filename );
964 
965  // only add it if the return is not NULL
966  if( modelPtr )
967  {
968  C_OGL_3DMODEL* ogl_model =
969  new C_OGL_3DMODEL( *modelPtr,
971 
972  if( ogl_model )
973  m_3dmodel_map[ sM->m_Filename ] = ogl_model;
974  }
975  }
976  }
977 
978  ++sM;
979  }
980  }
981  }
982 }
S3D_CACHE * Get3DCacheManager() const
Get3DCacheManager - Return the 3d cache manager pointer.
Definition: cinfo3d_visu.h:88
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:246
MODULE * Next() const
Definition: class_module.h:122
CINFO3D_VISU & m_settings
settings refrence in use for this render
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:725
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
DLIST< MODULE > m_Modules
Definition: class_board.h:249
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
Store the a model based on meshes and materials.
Definition: c3dmodel.h:90
const BOARD * GetBoard() const
GetBoard - Get current board to be rendered.
Definition: cinfo3d_visu.h:128
void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists ( )
private

Definition at line 835 of file c3d_render_ogl_legacy.cpp.

References m_3dmodel_map, m_ogl_disp_list_board, m_ogl_disp_list_grid, m_ogl_disp_list_pads_holes, m_ogl_disp_list_through_holes_inner, m_ogl_disp_list_through_holes_outer, 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, and m_triangles.

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

836 {
837  if( glIsList( m_ogl_disp_list_grid ) )
838  glDeleteLists( m_ogl_disp_list_grid, 1 );
839 
841 
842  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
843  ii != m_ogl_disp_lists_layers.end();
844  ++ii )
845  {
846  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
847  delete pLayerDispList;
848  }
849 
850  m_ogl_disp_lists_layers.clear();
851 
852 
853  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin();
855  ++ii )
856  {
857  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
858  delete pLayerDispList;
859  }
860 
862 
863 
864  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin();
866  ++ii )
867  {
868  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
869  delete pLayerDispList;
870  }
871 
873 
874  for( MAP_TRIANGLES::const_iterator ii = m_triangles.begin();
875  ii != m_triangles.end();
876  ++ii )
877  {
878  CLAYER_TRIANGLES *pointer = static_cast<CLAYER_TRIANGLES*>(ii->second);
879  delete pointer;
880  }
881 
882  m_triangles.clear();
883 
884 
885  for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin();
886  ii != m_3dmodel_map.end();
887  ++ii )
888  {
889  C_OGL_3DMODEL *pointer = static_cast<C_OGL_3DMODEL*>(ii->second);
890  delete pointer;
891  }
892 
893  m_3dmodel_map.clear();
894 
895 
896  delete m_ogl_disp_list_board;
898 
901 
904 
907 
910 
911  delete m_ogl_disp_list_via;
913 
916 
919 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists...
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_inner
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
void C3D_RENDER_OGL_LEGACY::ogl_set_arrow_material ( )
private

Definition at line 816 of file c3d_render_ogl_legacy.cpp.

Referenced by render_3D_arrows().

817 {
818  glEnable( GL_COLOR_MATERIAL );
819  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
820 
821  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
822  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
823  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
824  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
825 
826  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
827  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
828 
829  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
830  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
831  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
832 }
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
bool C3D_RENDER_OGL_LEGACY::Redraw ( bool  aIsMoving,
REPORTER aStatusTextReporter 
)
overridevirtual

Redraw - Ask to redraw the view.

Parameters
aIsMovingif the user is moving the scene, it should be render in preview mode
aStatusTextReportera 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 463 of file c3d_render_ogl_legacy.cpp.

References CLAYERS_OGL_DISP_LISTS::ApplyScalePosition(), B_Cu, B_Mask, CINFO3D_VISU::CameraGet(), CLAYERS_OGL_DISP_LISTS::DrawAll(), CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulled(), CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer(), dummy(), F_Cu, F_Mask, FL_AXIS, FL_SHOW_BOARD_BODY, FL_SOLDERMASK, FL_USE_REALISTIC_MODE, generate_new_3DGrid(), CINFO3D_VISU::GetEpoxyThickness3DU(), CINFO3D_VISU::GetFlag(), CINFO3D_VISU::GetLayerBottomZpos3DU(), CINFO3D_VISU::GetLayerTopZpos3DU(), CCAMERA::GetPos(), CCAMERA::GetProjectionMatrix(), CCAMERA::GetViewMatrix(), CLAYERS_OGL_DISP_LISTS::GetZBot(), CLAYERS_OGL_DISP_LISTS::GetZTop(), GRID3D_NONE, CINFO3D_VISU::GridGet(), initializeOpenGL(), CINFO3D_VISU::m_BgColorBot, CINFO3D_VISU::m_BgColorTop, C3D_RENDER_BASE::m_is_opengl_initialized, m_last_grid_type, m_materials, 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_with_npth, m_ogl_disp_list_via, m_ogl_disp_lists_layers, m_ogl_disp_lists_layers_holes_outer, C3D_RENDER_BASE::m_reloadRequested, C3D_RENDER_BASE::m_settings, C3D_RENDER_BASE::m_windowSize, max, min, OGL_DrawBackground(), OGL_SetMaterial(), reload(), render_3D_arrows(), render_3D_models(), render_solder_mask_layer(), REPORTER::Report(), set_layer_material(), CLAYERS_OGL_DISP_LISTS::SetItIsTransparent(), setLight_Bottom(), setLight_Front(), setLight_Top(), and setupMaterials().

465 {
466  // Initialize openGL
468  {
469  if( !initializeOpenGL() )
470  return false;
471  }
472 
473  if( m_reloadRequested )
474  {
475  wxBusyCursor dummy;
476 
477  if( aStatusTextReporter )
478  aStatusTextReporter->Report( _( "Loading..." ) );
479 
480  reload( aStatusTextReporter );
481  setupMaterials();
482 
483  // generate a new 3D grid as the size of the board may had changed
486  }
487  else
488  {
489  // Check if grid was changed
491  {
492  // and generate a new one
495  }
496  }
497 
498  // Initial setup
499  // /////////////////////////////////////////////////////////////////////////
500  glDepthFunc( GL_LESS );
501  glEnable( GL_CULL_FACE );
502  glFrontFace( GL_CCW ); // This is the openGL default
503  glEnable( GL_NORMALIZE ); // This allow openGL to normalize the normals after transformations
504 
505  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
506 
507 
508  // clear color and depth buffers
509  // /////////////////////////////////////////////////////////////////////////
510  glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
511  glClearDepth( 1.0f );
512  glClearStencil( 0x00 );
513  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
514 
515 
516  // Draw the background ( rectangle with color gradient)
517  // /////////////////////////////////////////////////////////////////////////
520 
521  glEnable( GL_DEPTH_TEST );
522 
523 
524  // Set projection and modelview matrixes
525  // /////////////////////////////////////////////////////////////////////////
526  glMatrixMode( GL_PROJECTION );
527  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetProjectionMatrix() ) );
528 
529  glMatrixMode( GL_MODELVIEW );
530  glLoadIdentity();
531  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetViewMatrix() ) );
532 
533 
534  // Position the headlight
535  // /////////////////////////////////////////////////////////////////////////
536 
537  setLight_Front( true );
538  setLight_Top( true );
539  setLight_Bottom( true );
540 
541  glEnable( GL_LIGHTING );
542 
543  {
544  const SFVEC3F &cameraPos = m_settings.CameraGet().GetPos();
545 
546  // Place the light at a minimun Z so the diffuse factor will not drop
547  // and the board will still look with good light.
548  float zpos;
549 
550  if( cameraPos.z > 0.0f )
551  {
552  zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
553  }
554  else
555  {
556  zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
557  }
558 
559  const GLfloat headlight_pos[] = { cameraPos.x,
560  cameraPos.y,
561  zpos,
562  1.0f }; // This is a point light
563 
564  glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
565  }
566 
567 
568  // Display board body
569  // /////////////////////////////////////////////////////////////////////////
571  {
573  {
576 
577  OGL_SetMaterial( m_materials.m_EpoxyBoard );
578 
580 
582  {
586 
589  NULL );
590  }
591  else
592  {
594  }
595  }
596  }
597 
598 
600  {
601  // Draw vias and pad holes with copper material
603  }
604  else
605  {
606  OGL_SetMaterial( m_materials.m_GrayMaterial );
607  }
608 
609  if( m_ogl_disp_list_via )
610  {
612  }
613 
615  {
617  }
618 
619 
620  // Display copper and tech layers
621  // /////////////////////////////////////////////////////////////////////////
622  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
623  ii != m_ogl_disp_lists_layers.end();
624  ++ii )
625  {
626 
627  const PCB_LAYER_ID layer_id = (PCB_LAYER_ID)(ii->first);
628 
629  // Mask kayers are not processed here because they are a special case
630  if( (layer_id == B_Mask) || (layer_id == F_Mask) )
631  continue;
632 
633  // Do not show inner layers when it is displaying the board
635  {
636  if( (layer_id > F_Cu) && (layer_id < B_Cu) )
637  continue;
638  }
639 
640  glPushMatrix();
641 
642  // !TODO: if we want to increase the separation between layers
643  //glScalef( 1.0f, 1.0f, 3.0f );
644 
645 
646  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
647  set_layer_material( layer_id );
648 
651  pLayerDispList->GetZBot(),
652  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
653 
654  if( (layer_id >= F_Cu) && (layer_id <= B_Cu) )
655  {
656  if( m_ogl_disp_lists_layers_holes_outer.find( layer_id ) !=
658  {
659  const CLAYERS_OGL_DISP_LISTS* viasHolesLayer =
661 
662  wxASSERT( viasHolesLayer != NULL );
663 
664  if( viasHolesLayer != NULL )
665  {
666  pLayerDispList->DrawAllCameraCulledSubtractLayer(
668  viasHolesLayer,
669  (aIsMoving == false) );
670  }
671  }
672  else
673  {
674  pLayerDispList->DrawAllCameraCulledSubtractLayer(
676  NULL,
677  (aIsMoving == false) );
678  }
679  }
680  else
681  {
682  pLayerDispList->DrawAllCameraCulled( m_settings.CameraGet().GetPos().z,
683  (aIsMoving == false) );
684  }
685 
686  glPopMatrix();
687  }
688 
689 
690  // Render 3D Models (Non-transparent)
691  // /////////////////////////////////////////////////////////////////////////
692 
693  //setLight_Top( false );
694  //setLight_Bottom( true );
695  render_3D_models( false, false );
696 
697  //setLight_Top( true );
698  //setLight_Bottom( false );
699  render_3D_models( true, false );
700 
701 
702  // Display transparent mask layers
703  // /////////////////////////////////////////////////////////////////////////
705  {
706  //setLight_Top( true );
707  //setLight_Bottom( true );
708 
709  if( m_settings.CameraGet().GetPos().z > 0 )
710  {
712  aIsMoving );
713 
715  aIsMoving );
716  }
717  else
718  {
720  aIsMoving );
721 
723  aIsMoving );
724  }
725  }
726 
727 
728  // Render 3D Models (Transparent)
729  // /////////////////////////////////////////////////////////////////////////
730 
731  //setLight_Top( false );
732  //setLight_Bottom( true );
733  render_3D_models( false, true );
734 
735  //setLight_Top( true );
736  //setLight_Bottom( false );
737  render_3D_models( true, true );
738 
739 
740  // Render Grid
741  // /////////////////////////////////////////////////////////////////////////
742 
743  if( m_settings.GridGet() != GRID3D_NONE )
744  {
745  glDisable( GL_LIGHTING );
746 
747  if( glIsList( m_ogl_disp_list_grid ) )
748  glCallList( m_ogl_disp_list_grid );
749 
750  glEnable( GL_LIGHTING );
751  }
752 
753 
754  // Render 3D arrows
755  // /////////////////////////////////////////////////////////////////////////
756  if( m_settings.GetFlag( FL_AXIS ) )
758 
759  // Return back to the original viewport (this is important if we want
760  // to take a screenshot after the render)
761  // /////////////////////////////////////////////////////////////////////////
762  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
763 
764  return false;
765 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
void generate_new_3DGrid(GRID3D_TYPE aGridType)
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
void render_3D_models(bool aRenderTopOrBot, bool aRenderTransparentOnly)
render_3D_models
const glm::mat4 & GetProjectionMatrix() const
Definition: ccamera.cpp:359
const glm::mat4 & GetViewMatrix() const
Definition: ccamera.cpp:389
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:503
CINFO3D_VISU & m_settings
settings refrence in use for this render
float GetLayerTopZpos3DU(PCB_LAYER_ID aLayerId) const
GetLayerTopZpos3DU - Get the top z position.
Definition: cinfo3d_visu.h:280
SFVEC3D m_BgColorTop
background top color
Definition: cinfo3d_visu.h:504
void ApplyScalePosition(float aZposition, float aZscale)
void setLight_Top(bool enabled)
GRID3D_TYPE m_last_grid_type
Stores the last grid computed.
void OGL_DrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
OGL_DrawBackground.
Definition: ogl_utils.cpp:179
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
void OGL_SetMaterial(const SMATERIAL &aMaterial)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:144
PCB_LAYER_ID
A quick note on layer IDs:
struct C3D_RENDER_OGL_LEGACY::@34 m_materials
void setLight_Front(bool enabled)
float GetLayerBottomZpos3DU(PCB_LAYER_ID aLayerId) const
GetLayerBottomZpos3DU - Get the bottom z position.
Definition: cinfo3d_visu.h:287
void setLight_Bottom(bool enabled)
bool m_is_opengl_initialized
flag if the opengl specific for this render was already initialized
void render_solder_mask_layer(PCB_LAYER_ID aLayerID, float aZPosition, bool aIsRenderingOnPreviewMode)
void reload(REPORTER *aStatusTextReporter)
wxSize m_windowSize
The window size that this camera is working.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
float GetEpoxyThickness3DU() const
GetEpoxyThickness3DU - Get the current epoxy thickness.
Definition: cinfo3d_visu.h:153
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer...
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
void DrawAllCameraCulledSubtractLayer(const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB, bool aDrawMiddle=true) const
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
void DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
DrawAllCameraCulled - Draw all layers if they are visible by the camera.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
#define max(a, b)
Definition: auxiliary.h:86
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void SetItIsTransparent(bool aSetTransparent)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
void set_layer_material(PCB_LAYER_ID aLayerID)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_pads_holes
const SFVEC3F & GetPos() const
Definition: ccamera.h:110
void DrawAll(bool aDrawMiddle=true) const
DrawAll - This function calls all the display lists.
#define min(a, b)
Definition: auxiliary.h:85
void C3D_RENDER_OGL_LEGACY::reload ( REPORTER aStatusTextReporter)
private

Definition at line 338 of file c3d_render_createscene_ogl_legacy.cpp.

References add_object_to_triangle_layer(), add_triangle_top_bot(), CLAYER_TRIANGLES::AddToMiddleContourns(), CINFO3D_VISU::BiuTo3Dunits(), SHAPE_POLY_SET::BooleanAdd(), CINFO3D_VISU::CameraGet(), Convert_shape_line_polygon_to_triangles(), Format(), generate_3D_Vias_and_Pads(), generate_holes_display_list(), get_layer_z_pos(), CINFO3D_VISU::GetBoard(), CINFO3D_VISU::GetBoardCenter3DU(), CINFO3D_VISU::GetBoardPoly(), CGENERICCONTAINER2D::GetList(), CINFO3D_VISU::GetMapLayers(), CINFO3D_VISU::GetMapLayersHoles(), COBJECT2D::GetObjectType(), CINFO3D_VISU::GetPolyMap(), CINFO3D_VISU::GetPolyMapHoles_Inner(), CINFO3D_VISU::GetPolyMapHoles_Outer(), GetRunningMicroSecs(), CINFO3D_VISU::GetThroughHole_Inner(), CINFO3D_VISU::GetThroughHole_Inner_poly(), CINFO3D_VISU::GetThroughHole_Outer(), CINFO3D_VISU::GetThroughHole_Outer_poly(), CINFO3D_VISU::GetThroughHole_Outer_poly_NPTH(), CINFO3D_VISU::GetThroughHole_Vias_Outer(), CINFO3D_VISU::GetThroughHole_Vias_Outer_poly(), CINFO3D_VISU::InitSettings(), COBJECT2D_STATS::Instance(), CINFO3D_VISU::Is3DLayerEnabled(), load_3D_models(), m_ogl_circle_texture, m_ogl_disp_list_board, m_ogl_disp_list_through_holes_inner, m_ogl_disp_list_through_holes_outer, 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, C3D_RENDER_BASE::m_reloadRequested, C3D_RENDER_BASE::m_settings, m_triangles, OBJ2D_FILLED_CIRCLE, OBJ2D_POLYGON4PT, OBJ2D_RING, OBJ2D_ROUNDSEG, OBJ2D_TRIANGLE, ogl_free_all_display_lists(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, COBJECT2D_STATS::PrintStats(), REPORTER::Report(), COBJECT2D_STATS::ResetStats(), and CCAMERA::SetBoardLookAtPos().

Referenced by Redraw().

339 {
340  m_reloadRequested = false;
341 
343 
345 
346 #ifdef PRINT_STATISTICS_3D_VIEWER
347  printf("InitSettings...\n");
348 #endif
349 
350  unsigned stats_startReloadTime = GetRunningMicroSecs();
351 
352  m_settings.InitSettings( aStatusTextReporter );
353 
354 #ifdef PRINT_STATISTICS_3D_VIEWER
355  unsigned stats_endReloadTime = GetRunningMicroSecs();
356 #endif
357 
358  SFVEC3F camera_pos = m_settings.GetBoardCenter3DU();
359  m_settings.CameraGet().SetBoardLookAtPos( camera_pos );
360 
361 #ifdef PRINT_STATISTICS_3D_VIEWER
362  unsigned stats_start_OpenGL_Load_Time = GetRunningMicroSecs();
363 #endif
364 
365  if( aStatusTextReporter )
366  aStatusTextReporter->Report( _( "Load OpenGL: board" ) );
367 
368  // Create Board
369  // /////////////////////////////////////////////////////////////////////////
370 
371  CCONTAINER2D boardContainer;
374  boardContainer,
376  (const BOARD_ITEM &)*m_settings.GetBoard() );
377 
378  const LIST_OBJECT2D &listBoardObject2d = boardContainer.GetList();
379 
380  if( listBoardObject2d.size() > 0 )
381  {
382  // We will set a unitary Z so it will in future used with transformations
383  // since the board poly will be used not only to draw itself but also the
384  // solder mask layers.
385  const float layer_z_top = 1.0f;
386  const float layer_z_bot = 0.0f;
387 
388  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listBoardObject2d.size() );
389 
390  // Convert the list of objects(triangles) to triangle layer structure
391  for( LIST_OBJECT2D::const_iterator itemOnLayer = listBoardObject2d.begin();
392  itemOnLayer != listBoardObject2d.end();
393  ++itemOnLayer )
394  {
395  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
396 
397  wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE );
398 
399  const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
400 
401  const SFVEC2F &v1 = tri->GetP1();
402  const SFVEC2F &v2 = tri->GetP2();
403  const SFVEC2F &v3 = tri->GetP3();
404 
405  add_triangle_top_bot( layerTriangles,
406  v1,
407  v2,
408  v3,
409  layer_z_top,
410  layer_z_bot );
411  }
412 
413  const SHAPE_POLY_SET &boardPoly = m_settings.GetBoardPoly();
414 
415  wxASSERT( boardPoly.OutlineCount() > 0 );
416 
417  if( boardPoly.OutlineCount() > 0 )
418  {
419  layerTriangles->AddToMiddleContourns( boardPoly,
420  layer_z_bot,
421  layer_z_top,
423  false );
424 
425  m_ogl_disp_list_board = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
427  layer_z_top,
428  layer_z_top );
429  }
430 
431  delete layerTriangles;
432  }
433 
434  // Create Through Holes and vias
435  // /////////////////////////////////////////////////////////////////////////
436 
437  if( aStatusTextReporter )
438  aStatusTextReporter->Report( _( "Load OpenGL: holes and vias" ) );
439 
443  1.0f,
444  0.0f,
445  false );
446 
448 
451 
454  bodyHoles,
455  1.0f,
456  0.0f,
457  false );
458 
462  1.0f,
463  0.0f,
464  true );
465 
466 
470  1.0f,
471  0.0f,
472  false );
473 
474  // Not in use
475  //m_ogl_disp_list_through_holes_vias_inner = generate_holes_display_list(
476  // m_settings.GetThroughHole_Vias_Inner().GetList(),
477  // m_settings.GetThroughHole_Vias_Inner_poly(),
478  // 1.0f, 0.0f,
479  // false );
480 
481  const MAP_POLY & innerMapHoles = m_settings.GetPolyMapHoles_Inner();
482  const MAP_POLY & outerMapHoles = m_settings.GetPolyMapHoles_Outer();
483 
484  wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
485 
486  const MAP_CONTAINER_2D &map_holes = m_settings.GetMapLayersHoles();
487 
488  if( outerMapHoles.size() > 0 )
489  {
490  float layer_z_bot = 0.0f;
491  float layer_z_top = 0.0f;
492 
493  for( MAP_POLY::const_iterator ii = outerMapHoles.begin();
494  ii != outerMapHoles.end();
495  ++ii )
496  {
497  PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
498  const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
499  const CBVHCONTAINER2D *container = map_holes.at( layer_id );
500 
501  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
502 
504  container->GetList(),
505  *poly,
506  layer_z_top,
507  layer_z_bot,
508  false );
509  }
510 
511  for( MAP_POLY::const_iterator ii = innerMapHoles.begin();
512  ii != innerMapHoles.end();
513  ++ii )
514  {
515  PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
516  const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
517  const CBVHCONTAINER2D *container = map_holes.at( layer_id );
518 
519  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
520 
522  container->GetList(),
523  *poly,
524  layer_z_top,
525  layer_z_bot,
526  false );
527  }
528  }
529 
530  // Generate vertical cylinders of vias and pads (copper)
532 
533  // Add layers maps
534  // /////////////////////////////////////////////////////////////////////////
535 
536  if( aStatusTextReporter )
537  aStatusTextReporter->Report( _( "Load OpenGL: layers" ) );
538 
539  for( MAP_CONTAINER_2D::const_iterator ii = m_settings.GetMapLayers().begin();
540  ii != m_settings.GetMapLayers().end();
541  ++ii )
542  {
543  PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
544 
545  if( !m_settings.Is3DLayerEnabled( layer_id ) )
546  continue;
547 
548  const CBVHCONTAINER2D *container2d = static_cast<const CBVHCONTAINER2D *>(ii->second);
549  const LIST_OBJECT2D &listObject2d = container2d->GetList();
550 
551  if( listObject2d.size() == 0 )
552  continue;
553 
554  float layer_z_bot = 0.0f;
555  float layer_z_top = 0.0f;
556 
557  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
558 
559  // Calculate an estimation for the nr of triangles based on the nr of objects
560  unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
561 
562  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( nrTrianglesEstimation );
563 
564  m_triangles[layer_id] = layerTriangles;
565 
566  // Load the 2D (X,Y axis) component of shapes
567  for( LIST_OBJECT2D::const_iterator itemOnLayer = listObject2d.begin();
568  itemOnLayer != listObject2d.end();
569  ++itemOnLayer )
570  {
571  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
572 
573  switch( object2d_A->GetObjectType() )
574  {
575  case OBJ2D_FILLED_CIRCLE:
576  add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
577  layerTriangles,
578  layer_z_top, layer_z_bot );
579  break;
580 
581  case OBJ2D_POLYGON4PT:
582  add_object_to_triangle_layer( (const CPOLYGON4PTS2D *)object2d_A,
583  layerTriangles,
584  layer_z_top, layer_z_bot );
585  break;
586 
587  case OBJ2D_RING:
588  add_object_to_triangle_layer( (const CRING2D *)object2d_A,
589  layerTriangles,
590  layer_z_top, layer_z_bot );
591  break;
592 
593  case OBJ2D_TRIANGLE:
594  add_object_to_triangle_layer( (const CTRIANGLE2D *)object2d_A,
595  layerTriangles,
596  layer_z_top, layer_z_bot );
597  break;
598 
599  case OBJ2D_ROUNDSEG:
600  add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
601  layerTriangles,
602  layer_z_top, layer_z_bot );
603  break;
604 
605  default:
606  wxFAIL_MSG("C3D_RENDER_OGL_LEGACY: Object type is not implemented");
607  break;
608  }
609  }
610 
611  const MAP_POLY &map_poly = m_settings.GetPolyMap();
612 
613  // Load the vertical (Z axis) component of shapes
614  if( map_poly.find( layer_id ) != map_poly.end() )
615  {
616  const SHAPE_POLY_SET *polyList = map_poly.at( layer_id );
617 
618  if( polyList->OutlineCount() > 0 )
619  layerTriangles->AddToMiddleContourns( *polyList, layer_z_bot, layer_z_top,
620  m_settings.BiuTo3Dunits(), false );
621  }
622 
623  // Create display list
624  // /////////////////////////////////////////////////////////////////////
625  m_ogl_disp_lists_layers[layer_id] = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
627  layer_z_bot,
628  layer_z_top );
629  }// for each layer on map
630 
631 #ifdef PRINT_STATISTICS_3D_VIEWER
632  unsigned stats_end_OpenGL_Load_Time = GetRunningMicroSecs();
633 #endif
634 
635  // Load 3D models
636  // /////////////////////////////////////////////////////////////////////////
637 #ifdef PRINT_STATISTICS_3D_VIEWER
638  unsigned stats_start_models_Load_Time = GetRunningMicroSecs();
639 #endif
640 
641  if( aStatusTextReporter )
642  aStatusTextReporter->Report( _( "Loading 3D models" ) );
643 
644  load_3D_models( aStatusTextReporter );
645 
646 #ifdef PRINT_STATISTICS_3D_VIEWER
647  unsigned stats_end_models_Load_Time = GetRunningMicroSecs();
648 
649 
650  printf( "C3D_RENDER_OGL_LEGACY::reload times:\n" );
651  printf( " Reload board: %.3f ms\n",
652  (float)( stats_endReloadTime - stats_startReloadTime ) / 1000.0f );
653  printf( " Loading to openGL: %.3f ms\n",
654  (float)( stats_end_OpenGL_Load_Time - stats_start_OpenGL_Load_Time ) / 1000.0f );
655  printf( " Loading 3D models: %.3f ms\n",
656  (float)( stats_end_models_Load_Time - stats_start_models_Load_Time ) / 1000.0f );
658 #endif
659 
660  if( aStatusTextReporter )
661  {
662  // Calculation time in seconds
663  const double calculation_time = (double)( GetRunningMicroSecs() -
664  stats_startReloadTime) / 1e6;
665 
666  aStatusTextReporter->Report( wxString::Format( _( "Reload time %.3f s" ),
667  calculation_time ) );
668  }
669 }
std::map< PCB_LAYER_ID, CBVHCONTAINER2D * > MAP_CONTAINER_2D
A type that stores a container of 2d objects for each layer id.
Definition: cinfo3d_visu.h:55
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
std::map< PCB_LAYER_ID, SHAPE_POLY_SET * > MAP_POLY
A type that stores polysets for each layer id.
Definition: cinfo3d_visu.h:58
void add_object_to_triangle_layer(const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:64
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists...
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset union For aFastMode meaning, see function booleanOp
void PrintStats()
Definition: cobject2d.cpp:60
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
const SHAPE_POLY_SET & GetThroughHole_Vias_Outer_poly() const
GetThroughHole_Vias_Outer_poly -.
Definition: cinfo3d_visu.h:336
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
const SHAPE_POLY_SET & GetBoardPoly() const
GetBoardPoly - Get the current polygon of the epoxy board.
Definition: cinfo3d_visu.h:252
const SHAPE_POLY_SET & GetThroughHole_Outer_poly_NPTH() const
GetThroughHole_Outer_poly_NPTH -.
Definition: cinfo3d_visu.h:317
int OutlineCount() const
Returns the number of outlines in the set
CINFO3D_VISU & m_settings
settings refrence in use for this render
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_inner
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
const MAP_CONTAINER_2D & GetMapLayersHoles() const
GetMapLayersHoles -Get the map of container that have the holes per layer.
Definition: cinfo3d_visu.h:299
PCB_LAYER_ID
A quick note on layer IDs:
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const SFVEC3F & GetBoardCenter3DU() const
GetBoardCenter - the board center position in 3d units.
Definition: cinfo3d_visu.h:189
Class SHAPE_POLY_SET.
const SHAPE_POLY_SET & GetThroughHole_Outer_poly() const
GetThroughHole_Outer_poly -.
Definition: cinfo3d_visu.h:311
const MAP_POLY & GetPolyMapHoles_Outer() const
Definition: cinfo3d_visu.h:418
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
void get_layer_z_pos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
const CBVHCONTAINER2D & GetThroughHole_Vias_Outer() const
GetThroughHole_Vias_Outer -.
Definition: cinfo3d_visu.h:324
const MAP_POLY & GetPolyMap() const
GetPolyMap - Get maps of polygons&#39;s layers.
Definition: cinfo3d_visu.h:414
bool Is3DLayerEnabled(PCB_LAYER_ID aLayer) const
Is3DLayerEnabled - Check if a layer is enabled.
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
const CBVHCONTAINER2D & GetThroughHole_Inner() const
GetThroughHole_Inner - Get the ThroughHole container.
Definition: cinfo3d_visu.h:350
static COBJECT2D_STATS & Instance()
Definition: cobject2d.h:146
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)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
This handles simple polygons with 4 points.
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:205
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
void load_3D_models(REPORTER *aStatusTextReporter)
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:37
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const MAP_POLY & GetPolyMapHoles_Inner() const
Definition: cinfo3d_visu.h:416
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: ccamera.h:115
void ResetStats()
Definition: cobject2d.h:135
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
const SHAPE_POLY_SET & GetThroughHole_Inner_poly() const
GetThroughHole_Inner_poly -.
Definition: cinfo3d_visu.h:356
const CBVHCONTAINER2D & GetThroughHole_Outer() const
GetThroughHole_Outer - Get the inflated ThroughHole container.
Definition: cinfo3d_visu.h:305
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
const BOARD * GetBoard() const
GetBoard - Get current board to be rendered.
Definition: cinfo3d_visu.h:128
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
const MAP_CONTAINER_2D & GetMapLayers() const
GetMapLayers - Get the map of container that have the objects per layer.
Definition: cinfo3d_visu.h:293
void InitSettings(REPORTER *aStatusTextReporter)
InitSettings - Function to be called by the render when it need to reload the settings for the board...
void C3D_RENDER_BASE::ReloadRequest ( )
inlineinherited

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

Definition at line 73 of file c3d_render_base.h.

References C3D_RENDER_BASE::m_reloadRequested.

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

73 { m_reloadRequested = true; }
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
void C3D_RENDER_OGL_LEGACY::render_3D_arrows ( )
private

Definition at line 129 of file c3d_render_ogl_legacy.cpp.

References CINFO3D_VISU::CameraGet(), CCAMERA::GetRotationMatrix(), C3D_RENDER_BASE::m_settings, C3D_RENDER_BASE::m_windowSize, OGL_draw_arrow(), ogl_set_arrow_material(), and RANGE_SCALE_3D.

Referenced by Redraw().

130 {
131  const float arrow_size = RANGE_SCALE_3D * 0.30f;
132 
133  glDisable( GL_CULL_FACE );
134 
135  // YxY squared view port, this is on propose
136  glViewport( 4, 4, m_windowSize.y / 8 , m_windowSize.y / 8 );
137  glClear( GL_DEPTH_BUFFER_BIT );
138 
139  glMatrixMode( GL_PROJECTION );
140  glLoadIdentity();
141  gluPerspective( 45.0f, 1.0f, 0.001f, RANGE_SCALE_3D );
142 
143  glMatrixMode( GL_MODELVIEW );
144  glLoadIdentity();
145 
146  const glm::mat4 TranslationMatrix = glm::translate(
147  glm::mat4(1.0f),
148  SFVEC3F( 0.0f, 0.0f, -(arrow_size * 2.75f) ) );
149 
150  const glm::mat4 ViewMatrix = TranslationMatrix *
152 
153  glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
154 
156 
157  glColor3f( 0.9f, 0.0f, 0.0f );
158  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
159  SFVEC3F( arrow_size, 0.0f, 0.0f ),
160  0.275f );
161 
162  glColor3f( 0.0f, 0.9f, 0.0f );
163  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
164  SFVEC3F( 0.0f, arrow_size, 0.0f ),
165  0.275f );
166 
167  glColor3f( 0.0f, 0.0f, 0.9f );
168  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
169  SFVEC3F( 0.0f, 0.0f, arrow_size ),
170  0.275f );
171 
172  glEnable( GL_CULL_FACE );
173 }
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: cinfo3d_visu.h:63
CINFO3D_VISU & m_settings
settings refrence in use for this render
wxSize m_windowSize
The window size that this camera is working.
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const glm::mat4 GetRotationMatrix() const
Function GetRotationMatrix Get the rotation matrix to be applied in a transformation camera...
Definition: ccamera.cpp:130
void OGL_draw_arrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
OGL_draw_arrow - draw a round arrow.
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 979 of file c3d_render_ogl_legacy.cpp.

References CINFO3D_VISU::GetBoard(), DHEAD::GetCount(), BOARD::m_Modules, C3D_RENDER_BASE::m_settings, MODULE::Next(), render_3D_module(), and CINFO3D_VISU::ShouldModuleBeDisplayed().

Referenced by Redraw().

981 {
982  // Go for all modules
984  {
985  for( const MODULE* module = m_settings.GetBoard()->m_Modules;
986  module;
987  module = module->Next() )
988  {
989  if( !module->Models().empty() )
990  if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T)module->GetAttributes() ) )
991  if( ( aRenderTopOrBot && !module->IsFlipped()) ||
992  (!aRenderTopOrBot && module->IsFlipped()) )
993  render_3D_module( module, aRenderTransparentOnly );
994  }
995  }
996 }
MODULE * Next() const
Definition: class_module.h:122
CINFO3D_VISU & m_settings
settings refrence in use for this render
void render_3D_module(const MODULE *module, bool aRenderTransparentOnly)
MODULE_ATTR_T
Enum MODULE_ATTR_T is the set of attributes allowed within a MODULE, using MODULE::SetAttributes() an...
Definition: class_module.h:73
bool ShouldModuleBeDisplayed(MODULE_ATTR_T aModuleAttributs) const
ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs and the flags...
DLIST< MODULE > m_Modules
Definition: class_board.h:249
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
const BOARD * GetBoard() const
GetBoard - Get current board to be rendered.
Definition: cinfo3d_visu.h:128
void C3D_RENDER_OGL_LEGACY::render_3D_module ( const MODULE module,
bool  aRenderTransparentOnly 
)
private

Definition at line 999 of file c3d_render_ogl_legacy.cpp.

References CINFO3D_VISU::BiuTo3Dunits(), C_OGL_3DMODEL::Draw_bbox(), C_OGL_3DMODEL::Draw_bboxes(), C_OGL_3DMODEL::Draw_opaque(), C_OGL_3DMODEL::Draw_transparent(), FL_RENDER_OPENGL_SHOW_MODEL_BBOX, CINFO3D_VISU::GetFlag(), CINFO3D_VISU::GetModulesZcoord3DIU(), MODULE::GetOrientation(), MODULE::GetPosition(), C_OGL_3DMODEL::Have_opaque(), C_OGL_3DMODEL::Have_transparent(), MODULE::IsFlipped(), m_3dmodel_map, C3D_RENDER_BASE::m_settings, MODULE::Models(), and UNITS3D_TO_UNITSPCB.

Referenced by render_3D_models().

1001 {
1002  if( !module->Models().empty() )
1003  {
1004  const double zpos = m_settings.GetModulesZcoord3DIU( module->IsFlipped() );
1005 
1006  glPushMatrix();
1007 
1008  wxPoint pos = module->GetPosition();
1009 
1010  glTranslatef( pos.x * m_settings.BiuTo3Dunits(),
1011  -pos.y * m_settings.BiuTo3Dunits(),
1012  zpos );
1013 
1014  if( module->GetOrientation() )
1015  glRotated( (double) module->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
1016 
1017  if( module->IsFlipped() )
1018  {
1019  glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1020  glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1021  }
1022 
1023  double modelunit_to_3d_units_factor = m_settings.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
1024 
1025  glScaled( modelunit_to_3d_units_factor,
1026  modelunit_to_3d_units_factor,
1027  modelunit_to_3d_units_factor );
1028 
1029  // Get the list of model files for this model
1030  auto sM = module->Models().begin();
1031  auto eM = module->Models().end();
1032 
1033  while( sM != eM )
1034  {
1035  if( !sM->m_Filename.empty() )
1036  {
1037  // Check if the model is present in our cache map
1038  if( m_3dmodel_map.find( sM->m_Filename ) != m_3dmodel_map.end() )
1039  {
1040  // It is not present, try get it from cache
1041  const C_OGL_3DMODEL *modelPtr = m_3dmodel_map[ sM->m_Filename ];
1042 
1043  if( modelPtr )
1044  {
1045  if( ( (!aRenderTransparentOnly) && modelPtr->Have_opaque() ) ||
1046  ( aRenderTransparentOnly && modelPtr->Have_transparent() ) )
1047  {
1048  glPushMatrix();
1049 
1050  glTranslatef( sM->m_Offset.x, sM->m_Offset.y, sM->m_Offset.z );
1051 
1052  glRotatef( -sM->m_Rotation.z, 0.0f, 0.0f, 1.0f );
1053  glRotatef( -sM->m_Rotation.y, 0.0f, 1.0f, 0.0f );
1054  glRotatef( -sM->m_Rotation.x, 1.0f, 0.0f, 0.0f );
1055 
1056  glScalef( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z );
1057 
1058  if( aRenderTransparentOnly )
1059  modelPtr->Draw_transparent();
1060  else
1061  modelPtr->Draw_opaque();
1062 
1064  {
1065  glEnable( GL_BLEND );
1066  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1067 
1068  glLineWidth( 1 );
1069  modelPtr->Draw_bboxes();
1070 
1071  glDisable( GL_LIGHTING );
1072 
1073  glColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
1074 
1075  glLineWidth( 4 );
1076  modelPtr->Draw_bbox();
1077 
1078  glEnable( GL_LIGHTING );
1079  }
1080 
1081  glPopMatrix();
1082  }
1083  }
1084  }
1085  }
1086 
1087  ++sM;
1088  }
1089 
1090  glPopMatrix();
1091  }
1092 }
bool Have_transparent() const
Have_transparent - return true if have transparent meshs to render.
void Draw_transparent() const
Draw_transparent - render the model into the current context.
void Draw_opaque() const
Draw_opaque - render the model into the current context.
CINFO3D_VISU & m_settings
settings refrence in use for this render
void Draw_bbox() const
Draw_bbox - draw main bounding box of the model.
#define UNITS3D_TO_UNITSPCB
Scale convertion from 3d model units to pcb units.
bool Have_opaque() const
Have_opaque - return true if have opaque meshs to render.
double GetOrientation() const
Definition: class_module.h:188
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:258
void Draw_bboxes() const
Draw_bboxes - draw individual bounding boxes of each mesh.
float GetModulesZcoord3DIU(bool aIsFlipped) const
GetModulesZcoord3DIU - Get the position of the module in 3d integer units considering if it is flippe...
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:178
const wxPoint GetPosition() const override
Definition: class_module.h:183
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer ( PCB_LAYER_ID  aLayerID,
float  aZPosition,
bool  aIsRenderingOnPreviewMode 
)
private

Definition at line 922 of file c3d_render_ogl_legacy.cpp.

References CLAYERS_OGL_DISP_LISTS::ApplyScalePosition(), B_Mask, CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer(), F_Mask, CINFO3D_VISU::GetNonCopperLayerThickness3DU(), m_ogl_disp_list_board, m_ogl_disp_list_through_holes_vias_outer, m_ogl_disp_lists_layers, C3D_RENDER_BASE::m_settings, set_layer_material(), and CLAYERS_OGL_DISP_LISTS::SetItIsTransparent().

Referenced by Redraw().

925 {
926  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
927 
929  {
930  if( m_ogl_disp_lists_layers.find( aLayerID ) !=
932  {
933  CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID );
934 
937  aZPosition,
939 
941  aZPosition,
943 
944  set_layer_material( aLayerID );
945 
947 
949  pLayerDispListMask,
951  !aIsRenderingOnPreviewMode );
952  }
953  else
954  {
955  // This case there is no layer with mask, so we will render the full board as mask
956 
959  aZPosition,
961 
963  aZPosition,
965 
966  set_layer_material( aLayerID );
967 
969 
971  NULL,
973  !aIsRenderingOnPreviewMode );
974  }
975  }
976 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
float GetNonCopperLayerThickness3DU() const
GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.
Definition: cinfo3d_visu.h:159
CINFO3D_VISU & m_settings
settings refrence in use for this render
void ApplyScalePosition(float aZposition, float aZscale)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer...
void DrawAllCameraCulledSubtractLayer(const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB, bool aDrawMiddle=true) const
void SetItIsTransparent(bool aSetTransparent)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
void set_layer_material(PCB_LAYER_ID aLayerID)
void C3D_RENDER_OGL_LEGACY::set_layer_material ( PCB_LAYER_ID  aLayerID)
private

Definition at line 304 of file c3d_render_ogl_legacy.cpp.

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, get_layer_color(), m_materials, Margin, and OGL_SetMaterial().

Referenced by Redraw(), and render_solder_mask_layer().

305 {
306  switch( aLayerID )
307  {
308  case B_Mask:
309  case F_Mask:
310  m_materials.m_SolderMask.m_Diffuse = get_layer_color( aLayerID );
311  OGL_SetMaterial( m_materials.m_SolderMask );
312  break;
313 
314  case B_Paste:
315  case F_Paste:
316  m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
317  OGL_SetMaterial( m_materials.m_Paste );
318  break;
319 
320  case B_SilkS:
321  case F_SilkS:
322  m_materials.m_SilkS.m_Diffuse = get_layer_color( aLayerID );
323  OGL_SetMaterial( m_materials.m_SilkS );
324  break;
325 
326  case B_Adhes:
327  case F_Adhes:
328  case Dwgs_User:
329  case Cmts_User:
330  case Eco1_User:
331  case Eco2_User:
332  case Edge_Cuts:
333  case Margin:
334  case B_CrtYd:
335  case F_CrtYd:
336  case B_Fab:
337  case F_Fab:
338  m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID );
339  m_materials.m_Plastic.m_Ambient = SFVEC3F(
340  m_materials.m_Plastic.m_Diffuse.r * 0.05f,
341  m_materials.m_Plastic.m_Diffuse.g * 0.05f,
342  m_materials.m_Plastic.m_Diffuse.b * 0.05f );
343 
344  m_materials.m_Plastic.m_Specular = SFVEC3F(
345  m_materials.m_Plastic.m_Diffuse.r * 0.7f,
346  m_materials.m_Plastic.m_Diffuse.g * 0.7f,
347  m_materials.m_Plastic.m_Diffuse.b * 0.7f );
348 
349  m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
350  OGL_SetMaterial( m_materials.m_Plastic );
351  break;
352 
353  default:
354  m_materials.m_Copper.m_Diffuse = get_layer_color( aLayerID );
355  OGL_SetMaterial( m_materials.m_Copper );
356 
357  break;
358  }
359 }
void OGL_SetMaterial(const SMATERIAL &aMaterial)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:144
struct C3D_RENDER_OGL_LEGACY::@34 m_materials
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F get_layer_color(PCB_LAYER_ID aLayerID)
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 90 of file c3d_render_ogl_legacy.cpp.

References C3D_RENDER_BASE::m_windowSize.

91 {
92  if( m_windowSize != aSize )
93  {
94  m_windowSize = aSize;
95  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
96 
97  // Initialize here any screen dependent data here
98  }
99 }
wxSize m_windowSize
The window size that this camera is working.
void C3D_RENDER_OGL_LEGACY::setLight_Bottom ( bool  enabled)
private

Definition at line 120 of file c3d_render_ogl_legacy.cpp.

Referenced by Redraw().

121 {
122  if( enabled )
123  glEnable( GL_LIGHT2 );
124  else
125  glDisable( GL_LIGHT2 );
126 }
void C3D_RENDER_OGL_LEGACY::setLight_Front ( bool  enabled)
private

Definition at line 102 of file c3d_render_ogl_legacy.cpp.

Referenced by Redraw().

103 {
104  if( enabled )
105  glEnable( GL_LIGHT0 );
106  else
107  glDisable( GL_LIGHT0 );
108 }
void C3D_RENDER_OGL_LEGACY::setLight_Top ( bool  enabled)
private

Definition at line 111 of file c3d_render_ogl_legacy.cpp.

Referenced by Redraw().

112 {
113  if( enabled )
114  glEnable( GL_LIGHT1 );
115  else
116  glDisable( GL_LIGHT1 );
117 }
void C3D_RENDER_OGL_LEGACY::setupMaterials ( )
private

Definition at line 176 of file c3d_render_ogl_legacy.cpp.

References FL_USE_REALISTIC_MODE, CINFO3D_VISU::GetFlag(), CINFO3D_VISU::m_BoardBodyColor, CINFO3D_VISU::m_CopperColor, m_materials, C3D_RENDER_BASE::m_settings, CINFO3D_VISU::m_SilkScreenColor, CINFO3D_VISU::m_SolderMaskColor, CINFO3D_VISU::m_SolderPasteColor, and mapf().

Referenced by Redraw().

177 {
178  m_materials = {};
179 
181  {
182  // http://devernay.free.fr/cours/opengl/materials.html
183 
184  // Copper material mixed with the copper color
185  m_materials.m_Copper.m_Ambient = SFVEC3F( m_settings.m_CopperColor.r * 0.1f,
186  m_settings.m_CopperColor.g * 0.1f,
187  m_settings.m_CopperColor.b * 0.1f);
188 
189  m_materials.m_Copper.m_Specular = SFVEC3F( m_settings.m_CopperColor.r * 0.75f + 0.25f,
190  m_settings.m_CopperColor.g * 0.75f + 0.25f,
191  m_settings.m_CopperColor.b * 0.75f + 0.25f );
192 
193  // This guess the material type(ex: copper vs gold) to determine the
194  // shininess factor between 0.1 and 0.4
195  float shininessfactor = 0.40f - mapf( fabs( m_settings.m_CopperColor.r -
197  0.15f, 1.00f,
198  0.00f, 0.30f );
199 
200  m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
201 
202 
203  // Paste material mixed with paste color
204  m_materials.m_Paste.m_Ambient = SFVEC3F( m_settings.m_SolderPasteColor.r,
207 
208  m_materials.m_Paste.m_Specular = SFVEC3F( m_settings.m_SolderPasteColor.r *
214 
215  m_materials.m_Paste.m_Shininess = 0.1f * 128.0f;
216 
217 
218  // Silk screen material mixed with silk screen color
219  m_materials.m_SilkS.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColor.r,
222 
223  m_materials.m_SilkS.m_Specular = SFVEC3F( m_settings.m_SilkScreenColor.r *
224  m_settings.m_SilkScreenColor.r + 0.10f,
226  m_settings.m_SilkScreenColor.g + 0.10f,
228  m_settings.m_SilkScreenColor.b + 0.10f );
229 
230  m_materials.m_SilkS.m_Shininess = 0.078125f * 128.0f;
231 
232 
233  // Solder mask material mixed with solder mask color
234  m_materials.m_SolderMask.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColor.r * 0.3f,
235  m_settings.m_SolderMaskColor.g * 0.3f,
236  m_settings.m_SolderMaskColor.b * 0.3f );
237 
238  m_materials.m_SolderMask.m_Specular = SFVEC3F( m_settings.m_SolderMaskColor.r *
244 
245  m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
246  m_materials.m_SolderMask.m_Transparency = 0.17f;
247 
248 
249  // Epoxy material
250  m_materials.m_EpoxyBoard.m_Ambient = SFVEC3F( 117.0f / 255.0f,
251  97.0f / 255.0f,
252  47.0f / 255.0f );
253 
254  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
255 
256  m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f,
257  3.0f / 255.0f,
258  20.0f / 255.0f );
259 
260  m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
261  }
262  else // Technical Mode
263  {
264  const SFVEC3F matAmbientColor = SFVEC3F( 0.10f );
265  const SFVEC3F matSpecularColor = SFVEC3F( 0.10f );
266  const float matShininess = 0.1f * 128.0f;
267 
268  // Copper material
269  m_materials.m_Copper.m_Ambient = matAmbientColor;
270  m_materials.m_Copper.m_Specular = matSpecularColor;
271  m_materials.m_Copper.m_Shininess = matShininess;
272 
273  // Paste material
274  m_materials.m_Paste.m_Ambient = matAmbientColor;
275  m_materials.m_Paste.m_Specular = matSpecularColor;
276  m_materials.m_Paste.m_Shininess = matShininess;
277 
278  // Silk screen material
279  m_materials.m_SilkS.m_Ambient = matAmbientColor;
280  m_materials.m_SilkS.m_Specular = matSpecularColor;
281  m_materials.m_SilkS.m_Shininess = matShininess;
282 
283  // Solder mask material
284  m_materials.m_SolderMask.m_Ambient = matAmbientColor;
285  m_materials.m_SolderMask.m_Specular = matSpecularColor;
286  m_materials.m_SolderMask.m_Shininess = matShininess;
287  m_materials.m_SolderMask.m_Transparency = 0.17f;
288 
289  // Epoxy material
290  m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
291  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
292  m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
293  m_materials.m_EpoxyBoard.m_Shininess = matShininess;
294 
295  // Gray material (used for example in technical vias and pad holes)
296  m_materials.m_GrayMaterial.m_Ambient = SFVEC3F( 0.8f, 0.8f, 0.8f );
297  m_materials.m_GrayMaterial.m_Diffuse = SFVEC3F( 0.3f, 0.3f, 0.3f );
298  m_materials.m_GrayMaterial.m_Specular = SFVEC3F( 0.4f, 0.4f, 0.4f );
299  m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
300  }
301 }
SFVEC3D m_CopperColor
in realistic mode: copper color
Definition: cinfo3d_visu.h:509
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
Definition: 3d_math.h:136
CINFO3D_VISU & m_settings
settings refrence in use for this render
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
Definition: cinfo3d_visu.h:505
struct C3D_RENDER_OGL_LEGACY::@34 m_materials
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:507
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:506
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
SFVEC3D m_SilkScreenColor
in realistic mode: SilkScreen color
Definition: cinfo3d_visu.h:508
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47

Member Data Documentation

MAP_3DMODEL C3D_RENDER_OGL_LEGACY::m_3dmodel_map
private
SMATERIAL C3D_RENDER_OGL_LEGACY::m_Copper

Definition at line 206 of file c3d_render_ogl_legacy.h.

SMATERIAL C3D_RENDER_OGL_LEGACY::m_EpoxyBoard

Definition at line 205 of file c3d_render_ogl_legacy.h.

SMATERIAL C3D_RENDER_OGL_LEGACY::m_GrayMaterial

Definition at line 208 of file c3d_render_ogl_legacy.h.

bool C3D_RENDER_BASE::m_is_opengl_initialized
protectedinherited

flag if the opengl specific for this render was already initialized

Definition at line 97 of file c3d_render_base.h.

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

GRID3D_TYPE C3D_RENDER_OGL_LEGACY::m_last_grid_type
private

Stores the last grid computed.

Definition at line 102 of file c3d_render_ogl_legacy.h.

Referenced by C3D_RENDER_OGL_LEGACY(), and Redraw().

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

struct { ... } C3D_RENDER_OGL_LEGACY::m_materials
GLuint C3D_RENDER_OGL_LEGACY::m_ogl_circle_texture
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_board
private
GLuint C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_grid
private

oGL list that stores current grid

Definition at line 100 of file c3d_render_ogl_legacy.h.

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

CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_pads_holes
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_inner
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_outer
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_outer_with_npth
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_through_holes_vias_outer
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_via
private
CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
private

Definition at line 94 of file c3d_render_ogl_legacy.h.

Referenced by C3D_RENDER_OGL_LEGACY(), and ogl_free_all_display_lists().

MAP_OGL_DISP_LISTS C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_layers
private
MAP_OGL_DISP_LISTS C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_layers_holes_inner
private
MAP_OGL_DISP_LISTS C3D_RENDER_OGL_LEGACY::m_ogl_disp_lists_layers_holes_outer
private
SMATERIAL C3D_RENDER_OGL_LEGACY::m_Paste

Definition at line 202 of file c3d_render_ogl_legacy.h.

SMATERIAL C3D_RENDER_OGL_LEGACY::m_Plastic

Definition at line 207 of file c3d_render_ogl_legacy.h.

bool C3D_RENDER_BASE::m_reloadRequested
protectedinherited
SMATERIAL C3D_RENDER_OGL_LEGACY::m_SilkS

Definition at line 203 of file c3d_render_ogl_legacy.h.

SMATERIAL C3D_RENDER_OGL_LEGACY::m_SolderMask

Definition at line 204 of file c3d_render_ogl_legacy.h.

MAP_TRIANGLES C3D_RENDER_OGL_LEGACY::m_triangles
private

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