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 (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 (LAYER_ID aLayerID, float aZPosition, bool aIsRenderingOnPreviewMode)
 
void get_layer_z_pos (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 ()
 
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 (LAYER_ID aLayerID)
 
SFVEC3F get_layer_color (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(), 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
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 671 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().

677 {
678  aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
679  SFVEC3F( v1.x, v1.y, bot ),
680  SFVEC3F( v2.x, v2.y, bot ) );
681 
682  aDst->m_layer_top_triangles->AddTriangle( SFVEC3F( v2.x, v2.y, top ),
683  SFVEC3F( v1.x, v1.y, top ),
684  SFVEC3F( v0.x, v0.y, top ) );
685 }
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 746 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::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, SHAPE_POLY_SET::RemoveAllContours(), wxPoint::x, and wxPoint::y.

Referenced by reload().

747 {
749  {
750  const unsigned int reserve_nr_triangles_estimation =
752  8 *
754 
755  CLAYER_TRIANGLES *layerTriangleVIA = new CLAYER_TRIANGLES( reserve_nr_triangles_estimation );
756 
757  // Insert plated vertical holes inside the board
758  // /////////////////////////////////////////////////////////////////////////
759 
760  // Insert vias holes (vertical cylinders)
761  for( const TRACK* track = m_settings.GetBoard()->m_Track;
762  track;
763  track = track->Next() )
764  {
765  if( track->Type() == PCB_VIA_T )
766  {
767  const VIA *via = static_cast<const VIA*>(track);
768 
769  const float holediameter = via->GetDrillValue() * m_settings.BiuTo3Dunits();
770  const float thickness = m_settings.GetCopperThickness3DU();
771  const float hole_inner_radius = ( holediameter / 2.0f );
772 
773  const SFVEC2F via_center( via->GetStart().x * m_settings.BiuTo3Dunits(),
774  -via->GetStart().y * m_settings.BiuTo3Dunits() );
775 
776  LAYER_ID top_layer, bottom_layer;
777  via->LayerPair( &top_layer, &bottom_layer );
778 
779  float ztop, zbot, dummy;
780 
781  get_layer_z_pos( top_layer, ztop, dummy );
782  get_layer_z_pos( bottom_layer, dummy, zbot );
783 
784  wxASSERT( zbot < ztop );
785 
786  generate_cylinder( via_center,
787  hole_inner_radius,
788  hole_inner_radius + thickness,
789  ztop,
790  zbot,
792  layerTriangleVIA );
793  }
794  }
795 
796  m_ogl_disp_list_via = new CLAYERS_OGL_DISP_LISTS( *layerTriangleVIA,
797  0,
798  0.0f,
799  0.0f );
800 
801  delete layerTriangleVIA;
802  }
803 
804 
805  if( m_settings.GetStats_Nr_Holes() > 0 )
806  {
807  SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
808  SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
809 
810  tht_outer_holes_poly.RemoveAllContours();
811  tht_inner_holes_poly.RemoveAllContours();
812 
813  // Insert pads holes (vertical cylinders)
814  for( const MODULE* module = m_settings.GetBoard()->m_Modules;
815  module;
816  module = module->Next() )
817  {
818  for( const D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
819  {
820  if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
821  {
822  const wxSize drillsize = pad->GetDrillSize();
823  const bool hasHole = drillsize.x && drillsize.y;
824 
825  if( !hasHole )
826  continue;
827 
828  // we use the hole diameter to calculate the seg count.
829  // for round holes, drillsize.x == drillsize.y
830  // for oblong holes, the diameter is the smaller of
831  // (drillsize.x, drillsize.y)
832  const int diam = std::min( drillsize.x, drillsize.y ) +
834 
835  const int segmentsPerCircle = m_settings.GetNrSegmentsCircle( diam );
836 
837  pad->BuildPadDrillShapePolygon( tht_outer_holes_poly,
839  segmentsPerCircle );
840 
841  pad->BuildPadDrillShapePolygon( tht_inner_holes_poly,
842  0,
843  segmentsPerCircle );
844  }
845  }
846  }
847 
848  // Subtract the holes
849  tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
850 
851 
852  CCONTAINER2D holesContainer;
853 
854  Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly,
855  holesContainer,
857  (const BOARD_ITEM &)*m_settings.GetBoard() );
858 
859  const LIST_OBJECT2D &listHolesObject2d = holesContainer.GetList();
860 
861  if( listHolesObject2d.size() > 0 )
862  {
863  float layer_z_top, layer_z_bot, dummy;
864 
865  get_layer_z_pos( F_Cu, layer_z_top, dummy );
866  get_layer_z_pos( B_Cu, dummy, layer_z_bot );
867 
868  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listHolesObject2d.size() );
869 
870  // Convert the list of objects(triangles) to triangle layer structure
871  for( LIST_OBJECT2D::const_iterator itemOnLayer = listHolesObject2d.begin();
872  itemOnLayer != listHolesObject2d.end();
873  ++itemOnLayer )
874  {
875  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
876 
877  wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE );
878 
879  const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
880 
881  const SFVEC2F &v1 = tri->GetP1();
882  const SFVEC2F &v2 = tri->GetP2();
883  const SFVEC2F &v3 = tri->GetP3();
884 
885  add_triangle_top_bot( layerTriangles,
886  v1,
887  v2,
888  v3,
889  layer_z_top,
890  layer_z_bot );
891  }
892 
893  wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
894 
895  if( tht_outer_holes_poly.OutlineCount() > 0 )
896  {
897  layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
898  layer_z_bot,
899  layer_z_top,
901  false );
902 
904  *layerTriangles,
905  m_ogl_circle_texture, // not need
906  layer_z_top,
907  layer_z_top );
908  }
909 
910  delete layerTriangles;
911  }
912  }
913 }
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:62
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:63
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:99
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
void get_layer_z_pos(LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
const wxPoint & GetStart() const
Definition: class_track.h:120
void Convert_shape_line_polygon_to_triangles(const SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
D_PAD * Next() const
Definition: class_pad.h:106
OBJECT2D_TYPE GetObjectType() const
Definition: cobject2d.h:125
void AddToMiddleContourns(const SHAPE_LINE_CHAIN &outlinePath, float zBot, float zTop, double aBiuTo3Du, bool aInvertFaceDirection)
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...
void LayerPair(LAYER_ID *top_layer, LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
TRACK * Next() const
Definition: class_track.h:97
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:36
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
DLIST< MODULE > m_Modules
Definition: class_board.h:243
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:108
DLIST< TRACK > m_Track
Definition: class_board.h:244
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 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 704 of file c3d_render_createscene_ogl_legacy.cpp.

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

Referenced by generate_3D_Vias_and_Pads().

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

Referenced by Redraw().

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

Definition at line 363 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().

364 {
365  SFVEC3F layerColor = m_settings.GetLayerColor( aLayerID );
366 
368  {
369  switch( aLayerID )
370  {
371  case B_Adhes:
372  case F_Adhes:
373  break;
374 
375  case B_Mask:
376  case F_Mask:
377  layerColor = m_settings.m_SolderMaskColor;
378  break;
379 
380  case B_Paste:
381  case F_Paste:
382  layerColor = m_settings.m_SolderPasteColor;
383  break;
384 
385  case B_SilkS:
386  case F_SilkS:
387  layerColor = m_settings.m_SilkScreenColor;
388  break;
389 
390  case Dwgs_User:
391  case Cmts_User:
392  case Eco1_User:
393  case Eco2_User:
394  case Edge_Cuts:
395  case Margin:
396  break;
397 
398  case B_CrtYd:
399  case F_CrtYd:
400  break;
401 
402  case B_Fab:
403  case F_Fab:
404  break;
405 
406  default:
407  layerColor = m_settings.m_CopperColor;
408  break;
409  }
410  }
411 
412  return layerColor;
413 }
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
SFVEC3F GetLayerColor(LAYER_ID aLayerId) const
GetLayerColor - get the technical color of a layer.
void C3D_RENDER_OGL_LEGACY::get_layer_z_pos ( LAYER_ID  aLayerID,
float &  aOutZtop,
float &  aOutZbot 
) const
private

Definition at line 688 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().

691 {
692  aOutZbot = m_settings.GetLayerBottomZpos3DU( aLayerID );
693  aOutZtop = m_settings.GetLayerTopZpos3DU( aLayerID );
694 
695  if( aOutZtop < aOutZbot )
696  {
697  float tmpFloat = aOutZbot;
698  aOutZbot = aOutZtop;
699  aOutZtop = tmpFloat;
700  }
701 }
float GetLayerBottomZpos3DU(LAYER_ID aLayerId) const
GetLayerBottomZpos3DU - Get the bottom z position.
Definition: cinfo3d_visu.h:287
CINFO3D_VISU & m_settings
settings refrence in use for this render
float GetLayerTopZpos3DU(LAYER_ID aLayerId) const
GetLayerTopZpos3DU - Get the top z position.
Definition: cinfo3d_visu.h:280
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 ( 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 767 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().

768 {
769  glEnable( GL_LINE_SMOOTH );
770  glShadeModel( GL_SMOOTH );
771 
772  // 4-byte pixel alignment
773  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
774 
775  // Initialize the open GL texture to draw the filled semi-circle of the segments
777 
778  if( !circleImage )
779  return false;
780 
781  circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
782  (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
783  (SIZE_OF_CIRCLE_TEXTURE / 2) - 4,
784  0xFF );
785 
786  //circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
787  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
788  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 2, 0xFF );
789 
790  CIMAGE *circleImage_Copy = new CIMAGE( *circleImage );
791 
792  circleImage->EfxFilter( circleImage_Copy, FILTER_BLUR_3X3 );
793 
794  m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
795 
796  //circleImage_Copy->SaveAsPNG("circleImage.png");
797  delete circleImage_Copy;
798  circleImage_Copy = 0;
799 
800  //circleImage->SaveAsPNG("circleImage_blured.png");
801  delete circleImage;
802  circleImage = 0;
803 
804  init_lights();
805 
806  // Use this mode if you want see the triangle lines (debug proposes)
807  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
808 
810 
811  return true;
812 }
void init_lights(void)
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
CircleFilled.
Definition: cimage.cpp:168
GLuint OGL_LoadTexture(const CIMAGE &aImage)
OGL_LoadTexture - generate a new OpenGL texture.
Definition: ogl_utils.cpp:77
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:465
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::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 ( )
private

Definition at line 922 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(), and MODULE::Next().

Referenced by reload().

923 {
927  return;
928 
929  // Go for all modules
930  for( const MODULE* module = m_settings.GetBoard()->m_Modules;
931  module;
932  module = module->Next() )
933  {
934  if( !module->Models().empty() )
935  {
936  // Get the list of model files for this model
937  std::list<S3D_INFO>::const_iterator sM = module->Models().begin();
938  std::list<S3D_INFO>::const_iterator eM = module->Models().end();
939 
940  while( sM != eM )
941  {
942  if( !sM->m_Filename.empty() )
943  {
944  // Check if the model is not present in our cache map
945  if( m_3dmodel_map.find( sM->m_Filename ) == m_3dmodel_map.end() )
946  {
947  // It is not present, try get it from cache
948  const S3DMODEL *modelPtr =
949  m_settings.Get3DCacheManager()->GetModel( sM->m_Filename );
950 
951  // only add it if the return is not NULL
952  if( modelPtr )
953  {
954  C_OGL_3DMODEL* ogl_model =
955  new C_OGL_3DMODEL( *modelPtr,
957 
958  if( ogl_model )
959  m_3dmodel_map[ sM->m_Filename ] = ogl_model;
960  }
961  }
962  }
963 
964  ++sM;
965  }
966  }
967  }
968 }
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:99
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:781
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
DLIST< MODULE > m_Modules
Definition: class_board.h:243
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 834 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().

835 {
836  if( glIsList( m_ogl_disp_list_grid ) )
837  glDeleteLists( m_ogl_disp_list_grid, 1 );
838 
840 
841  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
842  ii != m_ogl_disp_lists_layers.end();
843  ++ii )
844  {
845  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
846  delete pLayerDispList;
847  }
848 
849  m_ogl_disp_lists_layers.clear();
850 
851 
852  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin();
854  ++ii )
855  {
856  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
857  delete pLayerDispList;
858  }
859 
861 
862 
863  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin();
865  ++ii )
866  {
867  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
868  delete pLayerDispList;
869  }
870 
872 
873  for( MAP_TRIANGLES::const_iterator ii = m_triangles.begin();
874  ii != m_triangles.end();
875  ++ii )
876  {
877  CLAYER_TRIANGLES *pointer = static_cast<CLAYER_TRIANGLES*>(ii->second);
878  delete pointer;
879  }
880 
881  m_triangles.clear();
882 
883 
884  for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin();
885  ii != m_3dmodel_map.end();
886  ++ii )
887  {
888  C_OGL_3DMODEL *pointer = static_cast<C_OGL_3DMODEL*>(ii->second);
889  delete pointer;
890  }
891 
892  m_3dmodel_map.clear();
893 
894 
895  delete m_ogl_disp_list_board;
897 
900 
903 
906 
909 
910  delete m_ogl_disp_list_via;
912 
915 
918 }
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 815 of file c3d_render_ogl_legacy.cpp.

Referenced by render_3D_arrows().

816 {
817  glEnable( GL_COLOR_MATERIAL );
818  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
819 
820  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
821  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
822  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
823  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
824 
825  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
826  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
827 
828  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
829  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
830  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
831 }
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 464 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(), 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().

466 {
467  // Initialize openGL
469  {
470  if( !initializeOpenGL() )
471  return false;
472  }
473 
474  if( m_reloadRequested )
475  {
476  if( aStatusTextReporter )
477  aStatusTextReporter->Report( _( "Loading..." ) );
478 
479  reload( aStatusTextReporter );
480  setupMaterials();
481 
482  // generate a new 3D grid as the size of the board may had changed
485  }
486  else
487  {
488  // Check if grid was changed
490  {
491  // and generate a new one
494  }
495  }
496 
497  // Initial setup
498  // /////////////////////////////////////////////////////////////////////////
499  glDepthFunc( GL_LESS );
500  glEnable( GL_CULL_FACE );
501  glFrontFace( GL_CCW ); // This is the openGL default
502  glEnable( GL_NORMALIZE ); // This allow openGL to normalize the normals after transformations
503 
504  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
505 
506 
507  // clear color and depth buffers
508  // /////////////////////////////////////////////////////////////////////////
509  glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
510  glClearDepth( 1.0f );
511  glClearStencil( 0x00 );
512  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
513 
514 
515  // Draw the background ( rectangle with color gradient)
516  // /////////////////////////////////////////////////////////////////////////
519 
520  glEnable( GL_DEPTH_TEST );
521 
522 
523  // Set projection and modelview matrixes
524  // /////////////////////////////////////////////////////////////////////////
525  glMatrixMode( GL_PROJECTION );
526  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetProjectionMatrix() ) );
527 
528  glMatrixMode( GL_MODELVIEW );
529  glLoadIdentity();
530  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetViewMatrix() ) );
531 
532 
533  // Position the headlight
534  // /////////////////////////////////////////////////////////////////////////
535 
536  setLight_Front( true );
537  setLight_Top( true );
538  setLight_Bottom( true );
539 
540  glEnable( GL_LIGHTING );
541 
542  {
543  const SFVEC3F &cameraPos = m_settings.CameraGet().GetPos();
544 
545  // Place the light at a minimun Z so the diffuse factor will not drop
546  // and the board will still look with good light.
547  float zpos;
548 
549  if( cameraPos.z > 0.0f )
550  {
551  zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
552  }
553  else
554  {
555  zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
556  }
557 
558  const GLfloat headlight_pos[] = { cameraPos.x,
559  cameraPos.y,
560  zpos,
561  1.0f }; // This is a point light
562 
563  glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
564  }
565 
566 
567  // Display board body
568  // /////////////////////////////////////////////////////////////////////////
570  {
572  {
575 
576  OGL_SetMaterial( m_materials.m_EpoxyBoard );
577 
579 
581  {
585 
588  NULL );
589  }
590  else
591  {
593  }
594  }
595  }
596 
597 
599  {
600  // Draw vias and pad holes with copper material
602  }
603  else
604  {
605  OGL_SetMaterial( m_materials.m_GrayMaterial );
606  }
607 
608  if( m_ogl_disp_list_via )
609  {
611  }
612 
614  {
616  }
617 
618 
619  // Display copper and tech layers
620  // /////////////////////////////////////////////////////////////////////////
621  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
622  ii != m_ogl_disp_lists_layers.end();
623  ++ii )
624  {
625 
626  const LAYER_ID layer_id = (LAYER_ID)(ii->first);
627 
628  // Mask kayers are not processed here because they are a special case
629  if( (layer_id == B_Mask) || (layer_id == F_Mask) )
630  continue;
631 
632  // Do not show inner layers when it is displaying the board
634  {
635  if( (layer_id > F_Cu) && (layer_id < B_Cu) )
636  continue;
637  }
638 
639  glPushMatrix();
640 
641  // !TODO: if we want to increase the separation between layers
642  //glScalef( 1.0f, 1.0f, 3.0f );
643 
644 
645  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
646  set_layer_material( layer_id );
647 
650  pLayerDispList->GetZBot(),
651  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
652 
653  if( (layer_id >= F_Cu) && (layer_id <= B_Cu) )
654  {
655  if( m_ogl_disp_lists_layers_holes_outer.find( layer_id ) !=
657  {
658  const CLAYERS_OGL_DISP_LISTS* viasHolesLayer =
660 
661  wxASSERT( viasHolesLayer != NULL );
662 
663  if( viasHolesLayer != NULL )
664  {
665  pLayerDispList->DrawAllCameraCulledSubtractLayer(
667  viasHolesLayer,
668  (aIsMoving == false) );
669  }
670  }
671  else
672  {
673  pLayerDispList->DrawAllCameraCulledSubtractLayer(
675  NULL,
676  (aIsMoving == false) );
677  }
678  }
679  else
680  {
681  pLayerDispList->DrawAllCameraCulled( m_settings.CameraGet().GetPos().z,
682  (aIsMoving == false) );
683  }
684 
685  glPopMatrix();
686  }
687 
688 
689  // Render 3D Models (Non-transparent)
690  // /////////////////////////////////////////////////////////////////////////
691 
692  //setLight_Top( false );
693  //setLight_Bottom( true );
694  render_3D_models( false, false );
695 
696  //setLight_Top( true );
697  //setLight_Bottom( false );
698  render_3D_models( true, false );
699 
700 
701  // Display transparent mask layers
702  // /////////////////////////////////////////////////////////////////////////
704  {
705  //setLight_Top( true );
706  //setLight_Bottom( true );
707 
708  if( m_settings.CameraGet().GetPos().z > 0 )
709  {
711  aIsMoving );
712 
714  aIsMoving );
715  }
716  else
717  {
719  aIsMoving );
720 
722  aIsMoving );
723  }
724  }
725 
726 
727  // Render 3D Models (Transparent)
728  // /////////////////////////////////////////////////////////////////////////
729 
730  //setLight_Top( false );
731  //setLight_Bottom( true );
732  render_3D_models( false, true );
733 
734  //setLight_Top( true );
735  //setLight_Bottom( false );
736  render_3D_models( true, true );
737 
738 
739  // Render Grid
740  // /////////////////////////////////////////////////////////////////////////
741 
742  if( m_settings.GridGet() != GRID3D_NONE )
743  {
744  glDisable( GL_LIGHTING );
745 
746  if( glIsList( m_ogl_disp_list_grid ) )
747  glCallList( m_ogl_disp_list_grid );
748 
749  glEnable( GL_LIGHTING );
750  }
751 
752 
753  // Render 3D arrows
754  // /////////////////////////////////////////////////////////////////////////
755  if( m_settings.GetFlag( FL_AXIS ) )
757 
758  // Return back to the original viewport (this is important if we want
759  // to take a screenshot after the render)
760  // /////////////////////////////////////////////////////////////////////////
761  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
762 
763  return false;
764 }
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)
void set_layer_material(LAYER_ID aLayerID)
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
void render_3D_models(bool aRenderTopOrBot, bool aRenderTransparentOnly)
render_3D_models
float GetLayerBottomZpos3DU(LAYER_ID aLayerId) const
GetLayerBottomZpos3DU - Get the bottom z position.
Definition: cinfo3d_visu.h:287
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
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:176
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:141
void setLight_Front(bool enabled)
void render_solder_mask_layer(LAYER_ID aLayerID, float aZPosition, bool aIsRenderingOnPreviewMode)
void setLight_Bottom(bool enabled)
bool m_is_opengl_initialized
flag if the opengl specific for this render was already initialized
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
struct C3D_RENDER_OGL_LEGACY::@38 m_materials
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
float GetLayerTopZpos3DU(LAYER_ID aLayerId) const
GetLayerTopZpos3DU - Get the top z position.
Definition: cinfo3d_visu.h:280
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.
#define max(a, b)
Definition: auxiliary.h:86
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
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.
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;
373  boardContainer,
375  (const BOARD_ITEM &)*m_settings.GetBoard() );
376 
377  const LIST_OBJECT2D &listBoardObject2d = boardContainer.GetList();
378 
379  if( listBoardObject2d.size() > 0 )
380  {
381  // We will set a unitary Z so it will in future used with transformations
382  // since the board poly will be used not only to draw itself but also the
383  // solder mask layers.
384  const float layer_z_top = 1.0f;
385  const float layer_z_bot = 0.0f;
386 
387  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listBoardObject2d.size() );
388 
389  // Convert the list of objects(triangles) to triangle layer structure
390  for( LIST_OBJECT2D::const_iterator itemOnLayer = listBoardObject2d.begin();
391  itemOnLayer != listBoardObject2d.end();
392  ++itemOnLayer )
393  {
394  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
395 
396  wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE );
397 
398  const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
399 
400  const SFVEC2F &v1 = tri->GetP1();
401  const SFVEC2F &v2 = tri->GetP2();
402  const SFVEC2F &v3 = tri->GetP3();
403 
404  add_triangle_top_bot( layerTriangles,
405  v1,
406  v2,
407  v3,
408  layer_z_top,
409  layer_z_bot );
410  }
411 
412  const SHAPE_POLY_SET &boardPoly = m_settings.GetBoardPoly();
413 
414  wxASSERT( boardPoly.OutlineCount() > 0 );
415 
416  if( boardPoly.OutlineCount() > 0 )
417  {
418  layerTriangles->AddToMiddleContourns( boardPoly,
419  layer_z_bot,
420  layer_z_top,
422  false );
423 
424  m_ogl_disp_list_board = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
426  layer_z_top,
427  layer_z_top );
428  }
429 
430  delete layerTriangles;
431  }
432 
433  // Create Through Holes and vias
434  // /////////////////////////////////////////////////////////////////////////
435 
436  if( aStatusTextReporter )
437  aStatusTextReporter->Report( _( "Load OpenGL: holes and vias" ) );
438 
442  1.0f,
443  0.0f,
444  false );
445 
447 
450 
453  bodyHoles,
454  1.0f,
455  0.0f,
456  false );
457 
461  1.0f,
462  0.0f,
463  true );
464 
465 
469  1.0f,
470  0.0f,
471  false );
472 
473  // Not in use
474  //m_ogl_disp_list_through_holes_vias_inner = generate_holes_display_list(
475  // m_settings.GetThroughHole_Vias_Inner().GetList(),
476  // m_settings.GetThroughHole_Vias_Inner_poly(),
477  // 1.0f, 0.0f,
478  // false );
479 
480  const MAP_POLY & innerMapHoles = m_settings.GetPolyMapHoles_Inner();
481  const MAP_POLY & outerMapHoles = m_settings.GetPolyMapHoles_Outer();
482 
483  wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
484 
485  const MAP_CONTAINER_2D &map_holes = m_settings.GetMapLayersHoles();
486 
487  if( outerMapHoles.size() > 0 )
488  {
489  float layer_z_bot = 0.0f;
490  float layer_z_top = 0.0f;
491 
492  for( MAP_POLY::const_iterator ii = outerMapHoles.begin();
493  ii != outerMapHoles.end();
494  ++ii )
495  {
496  LAYER_ID layer_id = static_cast<LAYER_ID>(ii->first);
497  const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
498  const CBVHCONTAINER2D *container = map_holes.at( layer_id );
499 
500  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
501 
503  container->GetList(),
504  *poly,
505  layer_z_top,
506  layer_z_bot,
507  false );
508  }
509 
510  for( MAP_POLY::const_iterator ii = innerMapHoles.begin();
511  ii != innerMapHoles.end();
512  ++ii )
513  {
514  LAYER_ID layer_id = static_cast<LAYER_ID>(ii->first);
515  const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
516  const CBVHCONTAINER2D *container = map_holes.at( layer_id );
517 
518  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
519 
521  container->GetList(),
522  *poly,
523  layer_z_top,
524  layer_z_bot,
525  false );
526  }
527  }
528 
529  // Generate vertical cylinders of vias and pads (copper)
531 
532  // Add layers maps
533  // /////////////////////////////////////////////////////////////////////////
534 
535  if( aStatusTextReporter )
536  aStatusTextReporter->Report( _( "Load OpenGL: layers" ) );
537 
538  for( MAP_CONTAINER_2D::const_iterator ii = m_settings.GetMapLayers().begin();
539  ii != m_settings.GetMapLayers().end();
540  ++ii )
541  {
542  LAYER_ID layer_id = static_cast<LAYER_ID>(ii->first);
543 
544  if( !m_settings.Is3DLayerEnabled( layer_id ) )
545  continue;
546 
547  const CBVHCONTAINER2D *container2d = static_cast<const CBVHCONTAINER2D *>(ii->second);
548  const LIST_OBJECT2D &listObject2d = container2d->GetList();
549 
550  if( listObject2d.size() == 0 )
551  continue;
552 
553  float layer_z_bot = 0.0f;
554  float layer_z_top = 0.0f;
555 
556  get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
557 
558  // Calculate an estimation for the nr of triangles based on the nr of objects
559  unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
560 
561  CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( nrTrianglesEstimation );
562 
563  m_triangles[layer_id] = layerTriangles;
564 
565  for( LIST_OBJECT2D::const_iterator itemOnLayer = listObject2d.begin();
566  itemOnLayer != listObject2d.end();
567  ++itemOnLayer )
568  {
569  const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
570 
571  switch( object2d_A->GetObjectType() )
572  {
573  case OBJ2D_FILLED_CIRCLE:
574  add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
575  layerTriangles,
576  layer_z_top, layer_z_bot );
577  break;
578 
579  case OBJ2D_POLYGON4PT:
580  add_object_to_triangle_layer( (const CPOLYGON4PTS2D *)object2d_A,
581  layerTriangles,
582  layer_z_top, layer_z_bot );
583  break;
584 
585  case OBJ2D_RING:
586  add_object_to_triangle_layer( (const CRING2D *)object2d_A,
587  layerTriangles,
588  layer_z_top, layer_z_bot );
589  break;
590 
591  case OBJ2D_TRIANGLE:
592  add_object_to_triangle_layer( (const CTRIANGLE2D *)object2d_A,
593  layerTriangles,
594  layer_z_top, layer_z_bot );
595  break;
596 
597  case OBJ2D_ROUNDSEG:
598  add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
599  layerTriangles,
600  layer_z_top, layer_z_bot );
601  break;
602 
603  default:
604  wxFAIL_MSG("C3D_RENDER_OGL_LEGACY: Object type is not implemented");
605  break;
606  }
607  }
608 
609  const MAP_POLY &map_poly = m_settings.GetPolyMap();
610 
611  if( map_poly.find( layer_id ) != map_poly.end() )
612  {
613  const SHAPE_POLY_SET *polyList = map_poly.at( layer_id );
614 
615  layerTriangles->AddToMiddleContourns( *polyList,
616  layer_z_bot,
617  layer_z_top,
619  false );
620  }
621 
622  // Create display list
623  // /////////////////////////////////////////////////////////////////////
624  m_ogl_disp_lists_layers[layer_id] = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
626  layer_z_bot,
627  layer_z_top );
628  }// for each layer on map
629 
630 #ifdef PRINT_STATISTICS_3D_VIEWER
631  unsigned stats_end_OpenGL_Load_Time = GetRunningMicroSecs();
632 #endif
633 
634  // Load 3D models
635  // /////////////////////////////////////////////////////////////////////////
636 #ifdef PRINT_STATISTICS_3D_VIEWER
637  unsigned stats_start_models_Load_Time = GetRunningMicroSecs();
638 #endif
639 
640  if( aStatusTextReporter )
641  aStatusTextReporter->Report( _( "Loading 3D models" ) );
642 
643  load_3D_models();
644 
645 #ifdef PRINT_STATISTICS_3D_VIEWER
646  unsigned stats_end_models_Load_Time = GetRunningMicroSecs();
647 
648 
649  printf( "C3D_RENDER_OGL_LEGACY::reload times:\n" );
650  printf( " Reload board: %.3f ms\n",
651  (float)( stats_endReloadTime - stats_startReloadTime ) / 1000.0f );
652  printf( " Loading to openGL: %.3f ms\n",
653  (float)( stats_end_OpenGL_Load_Time - stats_start_OpenGL_Load_Time ) / 1000.0f );
654  printf( " Loading 3D models: %.3f ms\n",
655  (float)( stats_end_models_Load_Time - stats_start_models_Load_Time ) / 1000.0f );
657 #endif
658 
659  if( aStatusTextReporter )
660  {
661  // Calculation time in seconds
662  const double calculation_time = (double)( GetRunningMicroSecs() -
663  stats_startReloadTime) / 1e6;
664 
665  aStatusTextReporter->Report( wxString::Format( _( "Reload time %.3f s" ),
666  calculation_time ) );
667  }
668 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
void add_object_to_triangle_layer(const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
const LIST_OBJECT2D & GetList() const
Definition: ccontainer2d.h:62
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
void get_layer_z_pos(LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
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
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.
void Convert_shape_line_polygon_to_triangles(const SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
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
const CBVHCONTAINER2D & GetThroughHole_Vias_Outer() const
GetThroughHole_Vias_Outer -.
Definition: cinfo3d_visu.h:324
const MAP_POLY & GetPolyMap() const
GetPolyMap - Get maps of polygons's layers.
Definition: cinfo3d_visu.h:414
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
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:36
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
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
std::map< LAYER_ID, SHAPE_POLY_SET * > MAP_POLY
A type that stores polysets for each layer id.
Definition: cinfo3d_visu.h:58
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.
std::map< LAYER_ID, CBVHCONTAINER2D * > MAP_CONTAINER_2D
A type that stores a container of 2d objects for each layer id.
Definition: cinfo3d_visu.h:55
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)
bool Is3DLayerEnabled(LAYER_ID aLayer) const
Is3DLayerEnabled - Check if a layer is enabled.
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
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 978 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().

980 {
981  // Go for all modules
983  {
984  for( const MODULE* module = m_settings.GetBoard()->m_Modules;
985  module;
986  module = module->Next() )
987  {
988  if( !module->Models().empty() )
989  if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T)module->GetAttributes() ) )
990  if( ( aRenderTopOrBot && !module->IsFlipped()) ||
991  (!aRenderTopOrBot && module->IsFlipped()) )
992  render_3D_module( module, aRenderTransparentOnly );
993  }
994  }
995 }
MODULE * Next() const
Definition: class_module.h:99
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:243
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 998 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(), UNITS3D_TO_UNITSPCB, wxPoint::x, and wxPoint::y.

Referenced by render_3D_models().

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

Definition at line 921 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().

924 {
925  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
926 
928  {
929  if( m_ogl_disp_lists_layers.find( aLayerID ) !=
931  {
932  CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID );
933 
936  aZPosition,
938 
940  aZPosition,
942 
943  set_layer_material( aLayerID );
944 
946 
948  pLayerDispListMask,
950  !aIsRenderingOnPreviewMode );
951  }
952  else
953  {
954  // This case there is no layer with mask, so we will render the full board as mask
955 
958  aZPosition,
960 
962  aZPosition,
964 
965  set_layer_material( aLayerID );
966 
968 
970  NULL,
972  !aIsRenderingOnPreviewMode );
973  }
974  }
975 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
void set_layer_material(LAYER_ID aLayerID)
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 C3D_RENDER_OGL_LEGACY::set_layer_material ( LAYER_ID  aLayerID)
private

Definition at line 305 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().

306 {
307  switch( aLayerID )
308  {
309  case B_Mask:
310  case F_Mask:
311  m_materials.m_SolderMask.m_Diffuse = get_layer_color( aLayerID );
312  OGL_SetMaterial( m_materials.m_SolderMask );
313  break;
314 
315  case B_Paste:
316  case F_Paste:
317  m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
318  OGL_SetMaterial( m_materials.m_Paste );
319  break;
320 
321  case B_SilkS:
322  case F_SilkS:
323  m_materials.m_SilkS.m_Diffuse = get_layer_color( aLayerID );
324  OGL_SetMaterial( m_materials.m_SilkS );
325  break;
326 
327  case B_Adhes:
328  case F_Adhes:
329  case Dwgs_User:
330  case Cmts_User:
331  case Eco1_User:
332  case Eco2_User:
333  case Edge_Cuts:
334  case Margin:
335  case B_CrtYd:
336  case F_CrtYd:
337  case B_Fab:
338  case F_Fab:
339  m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID );
340  m_materials.m_Plastic.m_Ambient = SFVEC3F(
341  m_materials.m_Plastic.m_Diffuse.r * 0.05f,
342  m_materials.m_Plastic.m_Diffuse.g * 0.05f,
343  m_materials.m_Plastic.m_Diffuse.b * 0.05f );
344 
345  m_materials.m_Plastic.m_Specular = SFVEC3F(
346  m_materials.m_Plastic.m_Diffuse.r * 0.7f,
347  m_materials.m_Plastic.m_Diffuse.g * 0.7f,
348  m_materials.m_Plastic.m_Diffuse.b * 0.7f );
349 
350  m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
351  OGL_SetMaterial( m_materials.m_Plastic );
352  break;
353 
354  default:
355  m_materials.m_Copper.m_Diffuse = get_layer_color( aLayerID );
356  OGL_SetMaterial( m_materials.m_Copper );
357 
358  break;
359  }
360 }
SFVEC3F get_layer_color(LAYER_ID aLayerID)
void OGL_SetMaterial(const SMATERIAL &aMaterial)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:141
struct C3D_RENDER_OGL_LEGACY::@38 m_materials
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
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 
179  memset( &m_materials, 0, sizeof( m_materials ) );
180 
182  {
183  // http://devernay.free.fr/cours/opengl/materials.html
184 
185  // Copper material mixed with the copper color
186  m_materials.m_Copper.m_Ambient = SFVEC3F( m_settings.m_CopperColor.r * 0.1f,
187  m_settings.m_CopperColor.g * 0.1f,
188  m_settings.m_CopperColor.b * 0.1f);
189 
190  m_materials.m_Copper.m_Specular = SFVEC3F( m_settings.m_CopperColor.r * 0.75f + 0.25f,
191  m_settings.m_CopperColor.g * 0.75f + 0.25f,
192  m_settings.m_CopperColor.b * 0.75f + 0.25f );
193 
194  // This guess the material type(ex: copper vs gold) to determine the
195  // shininess factor between 0.1 and 0.4
196  float shininessfactor = 0.40f - mapf( fabs( m_settings.m_CopperColor.r -
198  0.15f, 1.00f,
199  0.00f, 0.30f );
200 
201  m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
202 
203 
204  // Paste material mixed with paste color
205  m_materials.m_Paste.m_Ambient = SFVEC3F( m_settings.m_SolderPasteColor.r,
208 
209  m_materials.m_Paste.m_Specular = SFVEC3F( m_settings.m_SolderPasteColor.r *
215 
216  m_materials.m_Paste.m_Shininess = 0.1f * 128.0f;
217 
218 
219  // Silk screen material mixed with silk screen color
220  m_materials.m_SilkS.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColor.r,
223 
224  m_materials.m_SilkS.m_Specular = SFVEC3F( m_settings.m_SilkScreenColor.r *
225  m_settings.m_SilkScreenColor.r + 0.10f,
227  m_settings.m_SilkScreenColor.g + 0.10f,
229  m_settings.m_SilkScreenColor.b + 0.10f );
230 
231  m_materials.m_SilkS.m_Shininess = 0.078125f * 128.0f;
232 
233 
234  // Solder mask material mixed with solder mask color
235  m_materials.m_SolderMask.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColor.r * 0.3f,
236  m_settings.m_SolderMaskColor.g * 0.3f,
237  m_settings.m_SolderMaskColor.b * 0.3f );
238 
239  m_materials.m_SolderMask.m_Specular = SFVEC3F( m_settings.m_SolderMaskColor.r *
245 
246  m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
247  m_materials.m_SolderMask.m_Transparency = 0.17f;
248 
249 
250  // Epoxy material
251  m_materials.m_EpoxyBoard.m_Ambient = SFVEC3F( 117.0f / 255.0f,
252  97.0f / 255.0f,
253  47.0f / 255.0f );
254 
255  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
256 
257  m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f,
258  3.0f / 255.0f,
259  20.0f / 255.0f );
260 
261  m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
262  }
263  else // Technical Mode
264  {
265  const SFVEC3F matAmbientColor = SFVEC3F( 0.10f );
266  const SFVEC3F matSpecularColor = SFVEC3F( 0.10f );
267  const float matShininess = 0.1f * 128.0f;
268 
269  // Copper material
270  m_materials.m_Copper.m_Ambient = matAmbientColor;
271  m_materials.m_Copper.m_Specular = matSpecularColor;
272  m_materials.m_Copper.m_Shininess = matShininess;
273 
274  // Paste material
275  m_materials.m_Paste.m_Ambient = matAmbientColor;
276  m_materials.m_Paste.m_Specular = matSpecularColor;
277  m_materials.m_Paste.m_Shininess = matShininess;
278 
279  // Silk screen material
280  m_materials.m_SilkS.m_Ambient = matAmbientColor;
281  m_materials.m_SilkS.m_Specular = matSpecularColor;
282  m_materials.m_SilkS.m_Shininess = matShininess;
283 
284  // Solder mask material
285  m_materials.m_SolderMask.m_Ambient = matAmbientColor;
286  m_materials.m_SolderMask.m_Specular = matSpecularColor;
287  m_materials.m_SolderMask.m_Shininess = matShininess;
288  m_materials.m_SolderMask.m_Transparency = 0.17f;
289 
290  // Epoxy material
291  m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
292  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
293  m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
294  m_materials.m_EpoxyBoard.m_Shininess = matShininess;
295 
296  // Gray material (used for example in technical vias and pad holes)
297  m_materials.m_GrayMaterial.m_Ambient = SFVEC3F( 0.8f, 0.8f, 0.8f );
298  m_materials.m_GrayMaterial.m_Diffuse = SFVEC3F( 0.3f, 0.3f, 0.3f );
299  m_materials.m_GrayMaterial.m_Specular = SFVEC3F( 0.4f, 0.4f, 0.4f );
300  m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
301  }
302 }
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
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
struct C3D_RENDER_OGL_LEGACY::@38 m_materials
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: