KiCad PCB EDA Suite
c3d_render_ogl_legacy.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #include "c3d_render_ogl_legacy.h"
32 #include "ogl_legacy_utils.h"
33 #include "common_ogl/ogl_utils.h"
34 #include "../cimage.h"
35 #include <class_board.h>
36 #include <class_module.h>
37 #include <3d_math.h>
38 #include <math/util.h> // for KiROUND
39 
40 #include <base_units.h>
41 
45 #define UNITS3D_TO_UNITSPCB (IU_PER_MM)
46 
48  C3D_RENDER_BASE( aSettings )
49 {
50  wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY" ) );
51 
55  m_triangles.clear();
57 
62  //m_ogl_disp_list_through_holes_vias_inner = NULL;
66 
70 
71  m_3dmodel_map.clear();
72 }
73 
74 
76 {
77  wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::~C3D_RENDER_OGL_LEGACY" ) );
78 
80 
81  glDeleteTextures( 1, &m_ogl_circle_texture );
82 }
83 
84 
86 {
87  return 50; // ms
88 }
89 
90 
91 void C3D_RENDER_OGL_LEGACY::SetCurWindowSize( const wxSize &aSize )
92 {
93  if( m_windowSize != aSize )
94  {
95  m_windowSize = aSize;
96  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
97 
98  // Initialize here any screen dependent data here
99  }
100 }
101 
102 
104 {
105  if( enabled )
106  glEnable( GL_LIGHT0 );
107  else
108  glDisable( GL_LIGHT0 );
109 }
110 
111 
113 {
114  if( enabled )
115  glEnable( GL_LIGHT1 );
116  else
117  glDisable( GL_LIGHT1 );
118 }
119 
120 
122 {
123  if( enabled )
124  glEnable( GL_LIGHT2 );
125  else
126  glDisable( GL_LIGHT2 );
127 }
128 
129 
131 {
132  const float arrow_size = RANGE_SCALE_3D * 0.30f;
133 
134  glDisable( GL_CULL_FACE );
135 
136  // YxY squared view port, this is on propose
137  glViewport( 4, 4, m_windowSize.y / 8 , m_windowSize.y / 8 );
138  glClear( GL_DEPTH_BUFFER_BIT );
139 
140  glMatrixMode( GL_PROJECTION );
141  glLoadIdentity();
142  gluPerspective( 45.0f, 1.0f, 0.001f, RANGE_SCALE_3D );
143 
144  glMatrixMode( GL_MODELVIEW );
145  glLoadIdentity();
146 
147  const glm::mat4 TranslationMatrix = glm::translate(
148  glm::mat4(1.0f),
149  SFVEC3F( 0.0f, 0.0f, -(arrow_size * 2.75f) ) );
150 
151  const glm::mat4 ViewMatrix = TranslationMatrix *
153 
154  glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
155 
157 
158  glColor3f( 0.9f, 0.0f, 0.0f );
159  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
160  SFVEC3F( arrow_size, 0.0f, 0.0f ),
161  0.275f );
162 
163  glColor3f( 0.0f, 0.9f, 0.0f );
164  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
165  SFVEC3F( 0.0f, arrow_size, 0.0f ),
166  0.275f );
167 
168  glColor3f( 0.0f, 0.0f, 0.9f );
169  OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
170  SFVEC3F( 0.0f, 0.0f, arrow_size ),
171  0.275f );
172 
173  glEnable( GL_CULL_FACE );
174 }
175 
176 
178 {
179  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  m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
203 
204 
205  // Paste material mixed with paste color
206  m_materials.m_Paste.m_Ambient = SFVEC3F( m_settings.m_SolderPasteColor.r,
209 
210  m_materials.m_Paste.m_Specular = SFVEC3F( m_settings.m_SolderPasteColor.r *
216 
217  m_materials.m_Paste.m_Shininess = 0.1f * 128.0f;
218  m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
219 
220 
221  // Silk screen material mixed with silk screen color
222  m_materials.m_SilkSTop.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColorTop.r,
224 
225  m_materials.m_SilkSTop.m_Specular = SFVEC3F(
229 
230  m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
231  m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
232 
233  // Silk screen material mixed with silk screen color
234  m_materials.m_SilkSBot.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColorBot.r,
236 
237  m_materials.m_SilkSBot.m_Specular = SFVEC3F(
241 
242  m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
243  m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
244 
245 
246  // Solder mask material mixed with solder mask color
247  m_materials.m_SolderMaskTop.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColorTop.r * 0.3f,
249  m_settings.m_SolderMaskColorTop.b * 0.3f );
250 
251  m_materials.m_SolderMaskTop.m_Specular =
255 
256  m_materials.m_SolderMaskTop.m_Shininess = 0.8f * 128.0f;
257  m_materials.m_SolderMaskTop.m_Transparency = 0.17f;
258  m_materials.m_SolderMaskTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
259 
260  // Solder mask material mixed with solder mask color
261  m_materials.m_SolderMaskBot.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColorBot.r * 0.3f,
263  m_settings.m_SolderMaskColorBot.b * 0.3f );
264 
265  m_materials.m_SolderMaskBot.m_Specular =
269 
270  m_materials.m_SolderMaskBot.m_Shininess = 0.8f * 128.0f;
271  m_materials.m_SolderMaskBot.m_Transparency = 0.17f;
272  m_materials.m_SolderMaskBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
273 
274 
275  // Epoxy material
276  m_materials.m_EpoxyBoard.m_Ambient = SFVEC3F( 117.0f / 255.0f,
277  97.0f / 255.0f,
278  47.0f / 255.0f );
279 
280  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
281 
282  m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f,
283  3.0f / 255.0f,
284  20.0f / 255.0f );
285 
286  m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
287  m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
288  }
289  else // Technical Mode
290  {
291  const SFVEC3F matAmbientColor = SFVEC3F( 0.10f );
292  const SFVEC3F matSpecularColor = SFVEC3F( 0.10f );
293  const float matShininess = 0.1f * 128.0f;
294 
295  // Copper material
296  m_materials.m_Copper.m_Ambient = matAmbientColor;
297  m_materials.m_Copper.m_Specular = matSpecularColor;
298  m_materials.m_Copper.m_Shininess = matShininess;
299  m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
300 
301  // Paste material
302  m_materials.m_Paste.m_Ambient = matAmbientColor;
303  m_materials.m_Paste.m_Specular = matSpecularColor;
304  m_materials.m_Paste.m_Shininess = matShininess;
305  m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
306 
307  // Silk screen material
308  m_materials.m_SilkSTop.m_Ambient = matAmbientColor;
309  m_materials.m_SilkSTop.m_Specular = matSpecularColor;
310  m_materials.m_SilkSTop.m_Shininess = matShininess;
311  m_materials.m_SilkSTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
312 
313  // Silk screen material
314  m_materials.m_SilkSBot.m_Ambient = matAmbientColor;
315  m_materials.m_SilkSBot.m_Specular = matSpecularColor;
316  m_materials.m_SilkSBot.m_Shininess = matShininess;
317  m_materials.m_SilkSBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
318 
319  // Solder mask material
320  m_materials.m_SolderMaskTop.m_Ambient = matAmbientColor;
321  m_materials.m_SolderMaskTop.m_Specular = matSpecularColor;
322  m_materials.m_SolderMaskTop.m_Shininess = matShininess;
323  m_materials.m_SolderMaskTop.m_Transparency = 0.17f;
324  m_materials.m_SolderMaskTop.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
325 
326  // Solder mask material
327  m_materials.m_SolderMaskBot.m_Ambient = matAmbientColor;
328  m_materials.m_SolderMaskBot.m_Specular = matSpecularColor;
329  m_materials.m_SolderMaskBot.m_Shininess = matShininess;
330  m_materials.m_SolderMaskBot.m_Transparency = 0.17f;
331  m_materials.m_SolderMaskBot.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
332 
333  // Epoxy material
334  m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
335  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
336  m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
337  m_materials.m_EpoxyBoard.m_Shininess = matShininess;
338  m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
339 
340  // Gray material (used for example in technical vias and pad holes)
341  m_materials.m_GrayMaterial.m_Ambient = SFVEC3F( 0.8f, 0.8f, 0.8f );
342  m_materials.m_GrayMaterial.m_Diffuse = SFVEC3F( 0.3f, 0.3f, 0.3f );
343  m_materials.m_GrayMaterial.m_Specular = SFVEC3F( 0.4f, 0.4f, 0.4f );
344  m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
345  m_materials.m_GrayMaterial.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
346  }
347 }
348 
349 
351 {
352  switch( aLayerID )
353  {
354  case B_Mask:
355  m_materials.m_SolderMaskBot.m_Diffuse = get_layer_color( aLayerID );
356  OGL_SetMaterial( m_materials.m_SolderMaskBot );
357  break;
358  case F_Mask:
359  m_materials.m_SolderMaskTop.m_Diffuse = get_layer_color( aLayerID );
360  OGL_SetMaterial( m_materials.m_SolderMaskTop );
361  break;
362 
363  case B_Paste:
364  case F_Paste:
365  m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
366  OGL_SetMaterial( m_materials.m_Paste );
367  break;
368 
369  case B_SilkS:
370  m_materials.m_SilkSBot.m_Diffuse = get_layer_color( aLayerID );
371  OGL_SetMaterial( m_materials.m_SilkSBot );
372  case F_SilkS:
373  m_materials.m_SilkSTop.m_Diffuse = get_layer_color( aLayerID );
374  OGL_SetMaterial( m_materials.m_SilkSTop );
375  break;
376 
377  case B_Adhes:
378  case F_Adhes:
379  case Dwgs_User:
380  case Cmts_User:
381  case Eco1_User:
382  case Eco2_User:
383  case Edge_Cuts:
384  case Margin:
385  case B_CrtYd:
386  case F_CrtYd:
387  case B_Fab:
388  case F_Fab:
389  m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID );
390  m_materials.m_Plastic.m_Ambient = SFVEC3F(
391  m_materials.m_Plastic.m_Diffuse.r * 0.05f,
392  m_materials.m_Plastic.m_Diffuse.g * 0.05f,
393  m_materials.m_Plastic.m_Diffuse.b * 0.05f );
394 
395  m_materials.m_Plastic.m_Specular = SFVEC3F(
396  m_materials.m_Plastic.m_Diffuse.r * 0.7f,
397  m_materials.m_Plastic.m_Diffuse.g * 0.7f,
398  m_materials.m_Plastic.m_Diffuse.b * 0.7f );
399 
400  m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
401  m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
402  OGL_SetMaterial( m_materials.m_Plastic );
403  break;
404 
405  default:
406  m_materials.m_Copper.m_Diffuse = get_layer_color( aLayerID );
407  OGL_SetMaterial( m_materials.m_Copper );
408 
409  break;
410  }
411 }
412 
413 
415 {
416  SFVEC3F layerColor = m_settings.GetLayerColor( aLayerID );
417 
419  {
420  switch( aLayerID )
421  {
422  case B_Adhes:
423  case F_Adhes:
424  break;
425 
426  case B_Mask:
427  layerColor = m_settings.m_SolderMaskColorBot;
428  break;
429  case F_Mask:
430  layerColor = m_settings.m_SolderMaskColorTop;
431  break;
432 
433  case B_Paste:
434  case F_Paste:
435  layerColor = m_settings.m_SolderPasteColor;
436  break;
437 
438  case B_SilkS:
439  layerColor = m_settings.m_SilkScreenColorBot;
440  break;
441  case F_SilkS:
442  layerColor = m_settings.m_SilkScreenColorTop;
443  break;
444 
445  case Dwgs_User:
446  case Cmts_User:
447  case Eco1_User:
448  case Eco2_User:
449  case Edge_Cuts:
450  case Margin:
451  break;
452 
453  case B_CrtYd:
454  case F_CrtYd:
455  break;
456 
457  case B_Fab:
458  case F_Fab:
459  break;
460 
461  default:
462  layerColor = m_settings.m_CopperColor;
463  break;
464  }
465  }
466 
467  return layerColor;
468 }
469 
470 void init_lights(void)
471 {
472  // Setup light
473  // https://www.opengl.org/sdk/docs/man2/xhtml/glLight.xml
474  // /////////////////////////////////////////////////////////////////////////
475  const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
476  const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
477  const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
478 
479  glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
480  glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
481  glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
482 
483  const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
484  const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
485 
486  // defines a directional light that points along the negative z-axis
487  GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
488 
489  // This makes a vector slight not perpendicular with XZ plane
490  const SFVEC3F vectorLight = SphericalToCartesian( glm::pi<float>() * 0.03f,
491  glm::pi<float>() * 0.25f );
492 
493  position[0] = vectorLight.x;
494  position[1] = vectorLight.y;
495  position[2] = vectorLight.z;
496 
497  glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
498  glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
499  glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
500  glLightfv( GL_LIGHT1, GL_POSITION, position );
501 
502 
503  // defines a directional light that points along the positive z-axis
504  position[2] = -position[2];
505 
506  glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
507  glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
508  glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
509  glLightfv( GL_LIGHT2, GL_POSITION, position );
510 
511  const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
512 
513  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
514 
515  glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
516 }
517 
518 
519 bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving,
520  REPORTER *aStatusTextReporter )
521 {
522  // Initialize openGL
524  {
525  if( !initializeOpenGL() )
526  return false;
527  }
528 
529  if( m_reloadRequested )
530  {
531  std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
532 
533  if( aStatusTextReporter )
534  aStatusTextReporter->Report( _( "Loading..." ) );
535 
536  reload( aStatusTextReporter );
537  setupMaterials();
538 
539  // generate a new 3D grid as the size of the board may had changed
542  }
543  else
544  {
545  // Check if grid was changed
547  {
548  // and generate a new one
551  }
552  }
553 
554  // Initial setup
555  // /////////////////////////////////////////////////////////////////////////
556  glDepthFunc( GL_LESS );
557  glEnable( GL_CULL_FACE );
558  glFrontFace( GL_CCW ); // This is the openGL default
559  glEnable( GL_NORMALIZE ); // This allow openGL to normalize the normals after transformations
560 
561  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
562 
563 
564  // clear color and depth buffers
565  // /////////////////////////////////////////////////////////////////////////
566  glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
567  glClearDepth( 1.0f );
568  glClearStencil( 0x00 );
569  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
570 
571 
572  // Draw the background ( rectangle with color gradient)
573  // /////////////////////////////////////////////////////////////////////////
576 
577  glEnable( GL_DEPTH_TEST );
578 
579 
580  // Set projection and modelview matrixes
581  // /////////////////////////////////////////////////////////////////////////
582  glMatrixMode( GL_PROJECTION );
583  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetProjectionMatrix() ) );
584 
585  glMatrixMode( GL_MODELVIEW );
586  glLoadIdentity();
587  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetViewMatrix() ) );
588 
589 
590  // Position the headlight
591  // /////////////////////////////////////////////////////////////////////////
592 
593  setLight_Front( true );
594  setLight_Top( true );
595  setLight_Bottom( true );
596 
597  glEnable( GL_LIGHTING );
598 
599  {
600  const SFVEC3F &cameraPos = m_settings.CameraGet().GetPos();
601 
602  // Place the light at a minimun Z so the diffuse factor will not drop
603  // and the board will still look with good light.
604  float zpos;
605 
606  if( cameraPos.z > 0.0f )
607  {
608  zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
609  }
610  else
611  {
612  zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
613  }
614 
615  const GLfloat headlight_pos[] = { cameraPos.x,
616  cameraPos.y,
617  zpos,
618  1.0f }; // This is a point light
619 
620  glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
621  }
622 
623 
624  // Display board body
625  // /////////////////////////////////////////////////////////////////////////
627  {
629  {
632 
633  OGL_SetMaterial( m_materials.m_EpoxyBoard );
634 
636 
638  {
642 
645  NULL );
646  }
647  else
648  {
650  }
651  }
652  }
653 
654 
656  {
657  // Draw vias and pad holes with copper material
659  }
660  else
661  {
662  OGL_SetMaterial( m_materials.m_GrayMaterial );
663  }
664 
665  if( m_ogl_disp_list_via )
666  {
668  }
669 
671  {
673  }
674 
675 
676  // Display copper and tech layers
677  // /////////////////////////////////////////////////////////////////////////
678  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
679  ii != m_ogl_disp_lists_layers.end();
680  ++ii )
681  {
682 
683  const PCB_LAYER_ID layer_id = (PCB_LAYER_ID)(ii->first);
684 
685  // Mask kayers are not processed here because they are a special case
686  if( (layer_id == B_Mask) || (layer_id == F_Mask) )
687  continue;
688 
689  // Do not show inner layers when it is displaying the board
691  {
692  if( (layer_id > F_Cu) && (layer_id < B_Cu) )
693  continue;
694  }
695 
696  glPushMatrix();
697 
698  // !TODO: if we want to increase the separation between layers
699  //glScalef( 1.0f, 1.0f, 3.0f );
700 
701 
702  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
703  set_layer_material( layer_id );
704 
707  pLayerDispList->GetZBot(),
708  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
709 
710  if( (layer_id >= F_Cu) && (layer_id <= B_Cu) )
711  {
712  if( m_ogl_disp_lists_layers_holes_outer.find( layer_id ) !=
714  {
715  const CLAYERS_OGL_DISP_LISTS* viasHolesLayer =
717 
718  wxASSERT( viasHolesLayer != NULL );
719 
720  if( viasHolesLayer != NULL )
721  {
722  pLayerDispList->DrawAllCameraCulledSubtractLayer(
724  viasHolesLayer,
725  (aIsMoving == false) );
726  }
727  }
728  else
729  {
730  pLayerDispList->DrawAllCameraCulledSubtractLayer(
732  NULL,
733  (aIsMoving == false) );
734  }
735  }
736  else
737  {
738  pLayerDispList->DrawAllCameraCulled( m_settings.CameraGet().GetPos().z,
739  (aIsMoving == false) );
740  }
741 
742  glPopMatrix();
743  }
744 
745 
746  // Render 3D Models (Non-transparent)
747  // /////////////////////////////////////////////////////////////////////////
748 
749  //setLight_Top( false );
750  //setLight_Bottom( true );
751  render_3D_models( false, false );
752 
753  //setLight_Top( true );
754  //setLight_Bottom( false );
755  render_3D_models( true, false );
756 
757 
758  // Display transparent mask layers
759  // /////////////////////////////////////////////////////////////////////////
761  {
762  //setLight_Top( true );
763  //setLight_Bottom( true );
764 
765  if( m_settings.CameraGet().GetPos().z > 0 )
766  {
768  aIsMoving );
769 
771  aIsMoving );
772  }
773  else
774  {
776  aIsMoving );
777 
779  aIsMoving );
780  }
781  }
782 
783 
784  // Render 3D Models (Transparent)
785  // /////////////////////////////////////////////////////////////////////////
786 
787  //setLight_Top( false );
788  //setLight_Bottom( true );
789  render_3D_models( false, true );
790 
791  //setLight_Top( true );
792  //setLight_Bottom( false );
793  render_3D_models( true, true );
794 
795 
796  // Render Grid
797  // /////////////////////////////////////////////////////////////////////////
798 
800  {
801  glDisable( GL_LIGHTING );
802 
803  if( glIsList( m_ogl_disp_list_grid ) )
804  glCallList( m_ogl_disp_list_grid );
805 
806  glEnable( GL_LIGHTING );
807  }
808 
809 
810  // Render 3D arrows
811  // /////////////////////////////////////////////////////////////////////////
812  if( m_settings.GetFlag( FL_AXIS ) )
814 
815  // Return back to the original viewport (this is important if we want
816  // to take a screenshot after the render)
817  // /////////////////////////////////////////////////////////////////////////
818  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
819 
820  return false;
821 }
822 
823 
825 {
826  glEnable( GL_LINE_SMOOTH );
827  glShadeModel( GL_SMOOTH );
828 
829  // 4-byte pixel alignment
830  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
831 
832  // Initialize the open GL texture to draw the filled semi-circle of the segments
834 
835  if( !circleImage )
836  return false;
837 
838  circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
839  (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
840  (SIZE_OF_CIRCLE_TEXTURE / 2) - 4,
841  0xFF );
842 
843  //circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
844  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
845  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 2, 0xFF );
846 
847  CIMAGE *circleImage_Copy = new CIMAGE( *circleImage );
848 
849  circleImage->EfxFilter( circleImage_Copy, IMAGE_FILTER::BLUR_3X3 );
850 
851  m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
852 
853  //circleImage_Copy->SaveAsPNG("circleImage.png");
854  delete circleImage_Copy;
855  circleImage_Copy = 0;
856 
857  //circleImage->SaveAsPNG("circleImage_blured.png");
858  delete circleImage;
859  circleImage = 0;
860 
861  init_lights();
862 
863  // Use this mode if you want see the triangle lines (debug proposes)
864  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
865 
867 
868  return true;
869 }
870 
871 
873 {
874  glEnable( GL_COLOR_MATERIAL );
875  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
876 
877  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
878  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
879  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
880  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
881 
882  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
883  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
884 
885  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
886  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
887  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
888 }
889 
890 
892 {
893  if( glIsList( m_ogl_disp_list_grid ) )
894  glDeleteLists( m_ogl_disp_list_grid, 1 );
895 
897 
898  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
899  ii != m_ogl_disp_lists_layers.end();
900  ++ii )
901  {
902  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
903  delete pLayerDispList;
904  }
905 
906  m_ogl_disp_lists_layers.clear();
907 
908 
909  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin();
911  ++ii )
912  {
913  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
914  delete pLayerDispList;
915  }
916 
918 
919 
920  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin();
922  ++ii )
923  {
924  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
925  delete pLayerDispList;
926  }
927 
929 
930  for( MAP_TRIANGLES::const_iterator ii = m_triangles.begin();
931  ii != m_triangles.end();
932  ++ii )
933  {
934  CLAYER_TRIANGLES *pointer = static_cast<CLAYER_TRIANGLES*>(ii->second);
935  delete pointer;
936  }
937 
938  m_triangles.clear();
939 
940 
941  for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin();
942  ii != m_3dmodel_map.end();
943  ++ii )
944  {
945  C_OGL_3DMODEL *pointer = static_cast<C_OGL_3DMODEL*>(ii->second);
946  delete pointer;
947  }
948 
949  m_3dmodel_map.clear();
950 
951 
952  delete m_ogl_disp_list_board;
954 
957 
960 
963 
966 
967  delete m_ogl_disp_list_via;
969 
972 
975 }
976 
977 
979  float aZPosition,
980  bool aIsRenderingOnPreviewMode )
981 {
982  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
983 
985  {
986  if( m_ogl_disp_lists_layers.find( aLayerID ) !=
988  {
989  CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID );
990 
993  aZPosition,
995 
997  aZPosition,
999 
1000  set_layer_material( aLayerID );
1001 
1003 
1005  pLayerDispListMask,
1007  !aIsRenderingOnPreviewMode );
1008  }
1009  else
1010  {
1011  // This case there is no layer with mask, so we will render the full board as mask
1012 
1015  aZPosition,
1017 
1019  aZPosition,
1021 
1022  set_layer_material( aLayerID );
1023 
1025 
1027  NULL,
1029  !aIsRenderingOnPreviewMode );
1030  }
1031  }
1032 }
1033 
1034 
1035 void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot,
1036  bool aRenderTransparentOnly )
1037 {
1038  // Go for all modules
1039  for( auto module : m_settings.GetBoard()->Modules() )
1040  {
1041  if( !module->Models().empty() )
1042  if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T) module->GetAttributes() ) )
1043  if( ( aRenderTopOrBot && !module->IsFlipped() )
1044  || ( !aRenderTopOrBot && module->IsFlipped() ) )
1045  render_3D_module( module, aRenderTransparentOnly );
1046  }
1047 }
1048 
1049 
1051  bool aRenderTransparentOnly )
1052 {
1053  if( !module->Models().empty() )
1054  {
1055  const double zpos = m_settings.GetModulesZcoord3DIU( module->IsFlipped() );
1056 
1057  glPushMatrix();
1058 
1059  wxPoint pos = module->GetPosition();
1060 
1061  glTranslatef( pos.x * m_settings.BiuTo3Dunits(),
1062  -pos.y * m_settings.BiuTo3Dunits(),
1063  zpos );
1064 
1065  if( module->GetOrientation() )
1066  glRotated( (double) module->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
1067 
1068  if( module->IsFlipped() )
1069  {
1070  glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1071  glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1072  }
1073 
1074  double modelunit_to_3d_units_factor = m_settings.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
1075 
1076  glScaled( modelunit_to_3d_units_factor,
1077  modelunit_to_3d_units_factor,
1078  modelunit_to_3d_units_factor );
1079 
1080  // Get the list of model files for this model
1081  auto sM = module->Models().begin();
1082  auto eM = module->Models().end();
1083 
1084  while( sM != eM )
1085  {
1086  if( !sM->m_Filename.empty() )
1087  {
1088  // Check if the model is present in our cache map
1089  if( m_3dmodel_map.find( sM->m_Filename ) != m_3dmodel_map.end() )
1090  {
1091  // It is not present, try get it from cache
1092  const C_OGL_3DMODEL *modelPtr = m_3dmodel_map[ sM->m_Filename ];
1093 
1094  if( modelPtr )
1095  {
1096  if( ( (!aRenderTransparentOnly) && modelPtr->Have_opaque() ) ||
1097  ( aRenderTransparentOnly && modelPtr->Have_transparent() ) )
1098  {
1099  glPushMatrix();
1100 
1101  glTranslatef( sM->m_Offset.x, sM->m_Offset.y, sM->m_Offset.z );
1102 
1103  glRotatef( -sM->m_Rotation.z, 0.0f, 0.0f, 1.0f );
1104  glRotatef( -sM->m_Rotation.y, 0.0f, 1.0f, 0.0f );
1105  glRotatef( -sM->m_Rotation.x, 1.0f, 0.0f, 0.0f );
1106 
1107  glScalef( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z );
1108 
1109  if( aRenderTransparentOnly )
1110  modelPtr->Draw_transparent();
1111  else
1112  modelPtr->Draw_opaque();
1113 
1115  {
1116  glEnable( GL_BLEND );
1117  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1118 
1119  glLineWidth( 1 );
1120  modelPtr->Draw_bboxes();
1121 
1122  glDisable( GL_LIGHTING );
1123 
1124  glColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
1125 
1126  glLineWidth( 4 );
1127  modelPtr->Draw_bbox();
1128 
1129  glEnable( GL_LIGHTING );
1130  }
1131 
1132  glPopMatrix();
1133  }
1134  }
1135  }
1136  }
1137 
1138  ++sM;
1139  }
1140 
1141  glPopMatrix();
1142  }
1143 }
1144 
1145 
1146 // create a 3D grid to an openGL display list: an horizontal grid (XY plane and Z = 0,
1147 // and a vertical grid (XZ plane and Y = 0)
1149 {
1150  if( glIsList( m_ogl_disp_list_grid ) )
1151  glDeleteLists( m_ogl_disp_list_grid, 1 );
1152 
1154 
1155  if( aGridType == GRID3D_TYPE::NONE )
1156  return;
1157 
1158  m_ogl_disp_list_grid = glGenLists( 1 );
1159 
1160  if( !glIsList( m_ogl_disp_list_grid ) )
1161  return;
1162 
1163  glNewList( m_ogl_disp_list_grid, GL_COMPILE );
1164 
1165  glEnable( GL_BLEND );
1166  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1167 
1168  const double zpos = 0.0;
1169 
1170  // Color of grid lines
1171  const SFVEC3F gridColor = m_settings.GetColor( DARKGRAY );
1172 
1173  // Color of grid lines every 5 lines
1174  const SFVEC3F gridColor_marker = m_settings.GetColor( LIGHTGRAY );
1175  const double scale = m_settings.BiuTo3Dunits();
1176  const double transparency = 0.35;
1177 
1178  double griSizeMM = 0.0;
1179 
1180  switch( aGridType )
1181  {
1182  default:
1183  case GRID3D_TYPE::NONE:
1184  return;
1185  case GRID3D_TYPE::GRID_1MM:
1186  griSizeMM = 1.0;
1187  break;
1189  griSizeMM = 2.5;
1190  break;
1191  case GRID3D_TYPE::GRID_5MM:
1192  griSizeMM = 5.0;
1193  break;
1195  griSizeMM = 10.0;
1196  break;
1197  }
1198 
1199  glNormal3f( 0.0, 0.0, 1.0 );
1200 
1201  const wxSize brd_size = m_settings.GetBoardSizeBIU();
1202  wxPoint brd_center_pos = m_settings.GetBoardPosBIU();
1203 
1204  brd_center_pos.y = -brd_center_pos.y;
1205 
1206  const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
1207  const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
1208 
1209  // Grid limits, in 3D units
1210  double xmin = (brd_center_pos.x - xsize / 2) * scale;
1211  double xmax = (brd_center_pos.x + xsize / 2) * scale;
1212  double ymin = (brd_center_pos.y - ysize / 2) * scale;
1213  double ymax = (brd_center_pos.y + ysize / 2) * scale;
1214  double zmin = Millimeter2iu( -50 ) * scale;
1215  double zmax = Millimeter2iu( 100 ) * scale;
1216 
1217  // Draw horizontal grid centered on 3D origin (center of the board)
1218  for( int ii = 0; ; ii++ )
1219  {
1220  if( (ii % 5) )
1221  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1222  else
1223  glColor4f( gridColor_marker.r,
1224  gridColor_marker.g,
1225  gridColor_marker.b,
1226  transparency );
1227 
1228  const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
1229 
1230  if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1231  {
1232  glBegin( GL_LINES );
1233  glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1234  glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1235  glEnd();
1236 
1237  if( ii != 0 )
1238  {
1239  glBegin( GL_LINES );
1240  glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1241  glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1242  glEnd();
1243  }
1244  }
1245 
1246  if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1247  {
1248  glBegin( GL_LINES );
1249  glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
1250  glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
1251  glEnd();
1252 
1253  if( ii != 0 )
1254  {
1255  glBegin( GL_LINES );
1256  glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
1257  glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
1258  glEnd();
1259  }
1260  }
1261 
1262  if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1263  break;
1264  }
1265 
1266  // Draw vertical grid on Z axis
1267  glNormal3f( 0.0, -1.0, 0.0 );
1268 
1269  // Draw vertical grid lines (parallel to Z axis)
1270  double posy = -brd_center_pos.y * scale;
1271 
1272  for( int ii = 0; ; ii++ )
1273  {
1274  if( (ii % 5) )
1275  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1276  else
1277  glColor4f( gridColor_marker.r,
1278  gridColor_marker.g,
1279  gridColor_marker.b,
1280  transparency );
1281 
1282  const double delta = ii * griSizeMM * IU_PER_MM;
1283 
1284  glBegin( GL_LINES );
1285  xmax = (brd_center_pos.x + delta) * scale;
1286 
1287  glVertex3f( xmax, posy, zmin );
1288  glVertex3f( xmax, posy, zmax );
1289  glEnd();
1290 
1291  if( ii != 0 )
1292  {
1293  glBegin( GL_LINES );
1294  xmin = (brd_center_pos.x - delta) * scale;
1295  glVertex3f( xmin, posy, zmin );
1296  glVertex3f( xmin, posy, zmax );
1297  glEnd();
1298  }
1299 
1300  if( delta > xsize / 2.0f )
1301  break;
1302  }
1303 
1304  // Draw horizontal grid lines on Z axis (parallel to X axis)
1305  for( int ii = 0; ; ii++ )
1306  {
1307  if( (ii % 5) )
1308  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1309  else
1310  glColor4f( gridColor_marker.r,
1311  gridColor_marker.g,
1312  gridColor_marker.b,
1313  transparency );
1314 
1315  const double delta = ii * griSizeMM * IU_PER_MM * scale;
1316 
1317  if( delta <= zmax )
1318  {
1319  // Draw grid lines on Z axis (positive Z axis coordinates)
1320  glBegin( GL_LINES );
1321  glVertex3f( xmin, posy, delta );
1322  glVertex3f( xmax, posy, delta );
1323  glEnd();
1324  }
1325 
1326  if( delta <= -zmin && ( ii != 0 ) )
1327  {
1328  // Draw grid lines on Z axis (negative Z axis coordinates)
1329  glBegin( GL_LINES );
1330  glVertex3f( xmin, posy, -delta );
1331  glVertex3f( xmax, posy, -delta );
1332  glEnd();
1333  }
1334 
1335  if( ( delta > zmax ) && ( delta > -zmin ) )
1336  break;
1337  }
1338 
1339  glDisable( GL_BLEND );
1340 
1341  glEndList();
1342 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
double GetOrientation() const
Definition: class_module.h:215
void DrawAllCameraCulledSubtractLayer(const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA, const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB, bool aDrawMiddle=true) const
void generate_new_3DGrid(GRID3D_TYPE aGridType)
wxSize GetBoardSizeBIU() const
GetBoardSizeBIU - Get the board size.
Definition: cinfo3d_visu.h:177
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists.
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:292
Implementation of conversion functions that require both schematic and board internal units.
SFVEC3D m_CopperColor
in realistic mode: copper color
Definition: cinfo3d_visu.h:505
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
void render_3D_models(bool aRenderTopOrBot, bool aRenderTransparentOnly)
render_3D_models
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
SFVEC3D m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
Definition: cinfo3d_visu.h:500
SFVEC3D m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
Definition: cinfo3d_visu.h:501
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
Definition: 3d_math.h:136
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
void init_lights(void)
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: cinfo3d_visu.h:63
const SFVEC3F & GetPos() const
Definition: ccamera.h:109
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:497
SFVEC3D m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
Definition: cinfo3d_visu.h:504
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
CircleFilled.
Definition: cimage.cpp:172
CINFO3D_VISU & m_settings
settings refrence in use for this render
SFVEC3D m_BgColorTop
background top color
Definition: cinfo3d_visu.h:498
void ApplyScalePosition(float aZposition, float aZscale)
SFVEC3F GetLayerColor(PCB_LAYER_ID aLayerId) const
GetLayerColor - get the technical color of a layer.
void setLight_Top(bool enabled)
float GetLayerBottomZpos3DU(PCB_LAYER_ID aLayerId) const
GetLayerBottomZpos3DU - Get the bottom z position.
Definition: cinfo3d_visu.h:287
GRID3D_TYPE m_last_grid_type
Stores the last grid computed.
GLuint OGL_LoadTexture(const CIMAGE &aImage)
OGL_LoadTexture - generate a new OpenGL texture.
Definition: ogl_utils.cpp:80
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
Definition: cinfo3d_visu.h:499
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
void Draw_transparent() const
Draw_transparent - render the model into the current context.
int GetWaitForEditingTimeOut() override
GetWaitForEditingTimeOut - Give the interface the time (in ms) that it should wait for editing or mov...
const glm::mat4 GetRotationMatrix() const
Function GetRotationMatrix Get the rotation matrix to be applied in a transformation camera.
Definition: ccamera.cpp:158
#define UNITS3D_TO_UNITSPCB
Scale convertion from 3d model units to pcb units.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_inner
void OGL_DrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
OGL_DrawBackground.
Definition: ogl_utils.cpp:179
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
const BOARD * GetBoard() const
GetBoard - Get current board to be rendered.
Definition: cinfo3d_visu.h:128
void OGL_SetMaterial(const SMATERIAL &aMaterial)
OGL_SetMaterial - Set OpenGL materials.
Definition: ogl_utils.cpp:144
PCB_LAYER_ID
A quick note on layer IDs:
SFVEC3D m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
Definition: cinfo3d_visu.h:503
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
void setLight_Front(bool enabled)
#define NULL
MODULES & Modules()
Definition: class_board.h:226
void render_3D_module(const MODULE *module, bool aRenderTransparentOnly)
void setLight_Bottom(bool enabled)
bool m_is_opengl_initialized
flag if the opengl specific for this render was already initialized
wxPoint GetBoardPosBIU() const
GetBoardPosBIU - Get the board size.
Definition: cinfo3d_visu.h:183
C3D_RENDER_OGL_LEGACY(CINFO3D_VISU &aSettings)
float GetNonCopperLayerThickness3DU() const
GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.
Definition: cinfo3d_visu.h:159
Class CINFO3D_VISU Helper class to handle information needed to display 3D board.
Definition: cinfo3d_visu.h:70
void SetCurWindowSize(const wxSize &aSize) override
SetCurWindowSize - Before each render, the canvas will tell the render what is the size of its window...
void render_solder_mask_layer(PCB_LAYER_ID aLayerID, float aZPosition, bool aIsRenderingOnPreviewMode)
bool Have_opaque() const
Have_opaque - return true if have opaque meshs to render.
void reload(REPORTER *aStatusTextReporter)
bool Redraw(bool aIsMoving, REPORTER *aStatusTextReporter) override
Redraw - Ask to redraw the view.
wxSize m_windowSize
The window size that this camera is working.
MODULE_ATTR_T
Enum MODULE_ATTR_T is the set of attributes allowed within a MODULE, using MODULE::SetAttributes() an...
Definition: class_module.h:71
float GetLayerTopZpos3DU(PCB_LAYER_ID aLayerId) const
GetLayerTopZpos3DU - Get the top z position.
Definition: cinfo3d_visu.h:280
float GetEpoxyThickness3DU() const
GetEpoxyThickness3DU - Get the current epoxy thickness.
Definition: cinfo3d_visu.h:153
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
void DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
DrawAllCameraCulled - Draw all layers if they are visible by the camera.
struct C3D_RENDER_OGL_LEGACY::@0 m_materials
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:502
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
SFVEC3F GetColor(COLOR4D aColor) const
GetColor.
GRID3D_TYPE
Grid types.
Definition: 3d_enums.h:71
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
void DrawAll(bool aDrawMiddle=true) const
DrawAll - This function calls all the display lists.
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.
#define SIZE_OF_CIRCLE_TEXTURE
bool Have_transparent() const
Have_transparent - return true if have transparent meshs to render.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:205
const int scale
const glm::mat4 & GetViewMatrix() const
Definition: ccamera.cpp:419
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
#define _(s)
Definition: 3d_actions.cpp:31
void Draw_opaque() const
Draw_opaque - render the model into the current context.
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void Draw_bboxes() const
Draw_bboxes - draw individual bounding boxes of each mesh.
void SetItIsTransparent(bool aSetTransparent)
SFVEC3F SphericalToCartesian(float aInclination, float aAzimuth)
SphericalToCartesian.
Definition: 3d_math.h:43
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
implements generic openGL functions that are common to any openGL target
const glm::mat4 & GetProjectionMatrix() const
Definition: ccamera.cpp:389
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
Defines math related functions.
CIMAGE manages a 8-bit channel image.
Definition: cimage.h:89
Module description (excepted pads)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
void Draw_bbox() const
Draw_bbox - draw main bounding box of the model.
void set_layer_material(PCB_LAYER_ID aLayerID)
bool ShouldModuleBeDisplayed(MODULE_ATTR_T aModuleAttributs) const
ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs and the flags.
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.
SFVEC3F get_layer_color(PCB_LAYER_ID aLayerID)
const wxPoint GetPosition() const override
Definition: class_module.h:210
float GetModulesZcoord3DIU(bool aIsFlipped) const
GetModulesZcoord3DIU - Get the position of the module in 3d integer units considering if it is flippe...
void EfxFilter(CIMAGE *aInImg, IMAGE_FILTER aFilterType)
Function EfxFilter apply a filter to the input image and stores it in the image class this <- FilterT...
Definition: cimage.cpp:471
void OGL_draw_arrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
OGL_draw_arrow - draw a round arrow.
This is a base class to hold data and functions for render targets.