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 
39 #include <base_units.h>
40 
44 #define UNITS3D_TO_UNITSPCB (IU_PER_MM)
45 
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 }
72 
73 
75 {
76  wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::~C3D_RENDER_OGL_LEGACY" ) );
77 
79 
80  glDeleteTextures( 1, &m_ogl_circle_texture );
81 }
82 
83 
85 {
86  return 50; // ms
87 }
88 
89 
90 void C3D_RENDER_OGL_LEGACY::SetCurWindowSize( const wxSize &aSize )
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 }
100 
101 
103 {
104  if( enabled )
105  glEnable( GL_LIGHT0 );
106  else
107  glDisable( GL_LIGHT0 );
108 }
109 
110 
112 {
113  if( enabled )
114  glEnable( GL_LIGHT1 );
115  else
116  glDisable( GL_LIGHT1 );
117 }
118 
119 
121 {
122  if( enabled )
123  glEnable( GL_LIGHT2 );
124  else
125  glDisable( GL_LIGHT2 );
126 }
127 
128 
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 }
174 
175 
177 {
178  m_materials = {};
179 
181  {
182  // http://devernay.free.fr/cours/opengl/materials.html
183 
184  // Copper material mixed with the copper color
185  m_materials.m_Copper.m_Ambient = SFVEC3F( m_settings.m_CopperColor.r * 0.1f,
186  m_settings.m_CopperColor.g * 0.1f,
187  m_settings.m_CopperColor.b * 0.1f);
188 
189  m_materials.m_Copper.m_Specular = SFVEC3F( m_settings.m_CopperColor.r * 0.75f + 0.25f,
190  m_settings.m_CopperColor.g * 0.75f + 0.25f,
191  m_settings.m_CopperColor.b * 0.75f + 0.25f );
192 
193  // This guess the material type(ex: copper vs gold) to determine the
194  // shininess factor between 0.1 and 0.4
195  float shininessfactor = 0.40f - mapf( fabs( m_settings.m_CopperColor.r -
197  0.15f, 1.00f,
198  0.00f, 0.30f );
199 
200  m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
201  m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.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  m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
218 
219 
220  // Silk screen material mixed with silk screen color
221  m_materials.m_SilkS.m_Ambient = SFVEC3F( m_settings.m_SilkScreenColor.r,
224 
225  m_materials.m_SilkS.m_Specular = SFVEC3F( m_settings.m_SilkScreenColor.r *
226  m_settings.m_SilkScreenColor.r + 0.10f,
228  m_settings.m_SilkScreenColor.g + 0.10f,
230  m_settings.m_SilkScreenColor.b + 0.10f );
231 
232  m_materials.m_SilkS.m_Shininess = 0.078125f * 128.0f;
233  m_materials.m_SilkS.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
234 
235 
236  // Solder mask material mixed with solder mask color
237  m_materials.m_SolderMask.m_Ambient = SFVEC3F( m_settings.m_SolderMaskColor.r * 0.3f,
238  m_settings.m_SolderMaskColor.g * 0.3f,
239  m_settings.m_SolderMaskColor.b * 0.3f );
240 
241  m_materials.m_SolderMask.m_Specular = SFVEC3F( m_settings.m_SolderMaskColor.r *
247 
248  m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
249  m_materials.m_SolderMask.m_Transparency = 0.17f;
250  m_materials.m_SolderMask.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
251 
252 
253  // Epoxy material
254  m_materials.m_EpoxyBoard.m_Ambient = SFVEC3F( 117.0f / 255.0f,
255  97.0f / 255.0f,
256  47.0f / 255.0f );
257 
258  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
259 
260  m_materials.m_EpoxyBoard.m_Specular = SFVEC3F( 18.0f / 255.0f,
261  3.0f / 255.0f,
262  20.0f / 255.0f );
263 
264  m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
265  m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
266  }
267  else // Technical Mode
268  {
269  const SFVEC3F matAmbientColor = SFVEC3F( 0.10f );
270  const SFVEC3F matSpecularColor = SFVEC3F( 0.10f );
271  const float matShininess = 0.1f * 128.0f;
272 
273  // Copper material
274  m_materials.m_Copper.m_Ambient = matAmbientColor;
275  m_materials.m_Copper.m_Specular = matSpecularColor;
276  m_materials.m_Copper.m_Shininess = matShininess;
277  m_materials.m_Copper.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
278 
279  // Paste material
280  m_materials.m_Paste.m_Ambient = matAmbientColor;
281  m_materials.m_Paste.m_Specular = matSpecularColor;
282  m_materials.m_Paste.m_Shininess = matShininess;
283  m_materials.m_Paste.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
284 
285  // Silk screen material
286  m_materials.m_SilkS.m_Ambient = matAmbientColor;
287  m_materials.m_SilkS.m_Specular = matSpecularColor;
288  m_materials.m_SilkS.m_Shininess = matShininess;
289  m_materials.m_SilkS.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
290 
291  // Solder mask material
292  m_materials.m_SolderMask.m_Ambient = matAmbientColor;
293  m_materials.m_SolderMask.m_Specular = matSpecularColor;
294  m_materials.m_SolderMask.m_Shininess = matShininess;
295  m_materials.m_SolderMask.m_Transparency = 0.17f;
296  m_materials.m_SolderMask.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
297 
298  // Epoxy material
299  m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
300  m_materials.m_EpoxyBoard.m_Diffuse = m_settings.m_BoardBodyColor;
301  m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
302  m_materials.m_EpoxyBoard.m_Shininess = matShininess;
303  m_materials.m_EpoxyBoard.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
304 
305  // Gray material (used for example in technical vias and pad holes)
306  m_materials.m_GrayMaterial.m_Ambient = SFVEC3F( 0.8f, 0.8f, 0.8f );
307  m_materials.m_GrayMaterial.m_Diffuse = SFVEC3F( 0.3f, 0.3f, 0.3f );
308  m_materials.m_GrayMaterial.m_Specular = SFVEC3F( 0.4f, 0.4f, 0.4f );
309  m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
310  m_materials.m_GrayMaterial.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
311  }
312 }
313 
314 
316 {
317  switch( aLayerID )
318  {
319  case B_Mask:
320  case F_Mask:
321  m_materials.m_SolderMask.m_Diffuse = get_layer_color( aLayerID );
322  OGL_SetMaterial( m_materials.m_SolderMask );
323  break;
324 
325  case B_Paste:
326  case F_Paste:
327  m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
328  OGL_SetMaterial( m_materials.m_Paste );
329  break;
330 
331  case B_SilkS:
332  case F_SilkS:
333  m_materials.m_SilkS.m_Diffuse = get_layer_color( aLayerID );
334  OGL_SetMaterial( m_materials.m_SilkS );
335  break;
336 
337  case B_Adhes:
338  case F_Adhes:
339  case Dwgs_User:
340  case Cmts_User:
341  case Eco1_User:
342  case Eco2_User:
343  case Edge_Cuts:
344  case Margin:
345  case B_CrtYd:
346  case F_CrtYd:
347  case B_Fab:
348  case F_Fab:
349  m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID );
350  m_materials.m_Plastic.m_Ambient = SFVEC3F(
351  m_materials.m_Plastic.m_Diffuse.r * 0.05f,
352  m_materials.m_Plastic.m_Diffuse.g * 0.05f,
353  m_materials.m_Plastic.m_Diffuse.b * 0.05f );
354 
355  m_materials.m_Plastic.m_Specular = SFVEC3F(
356  m_materials.m_Plastic.m_Diffuse.r * 0.7f,
357  m_materials.m_Plastic.m_Diffuse.g * 0.7f,
358  m_materials.m_Plastic.m_Diffuse.b * 0.7f );
359 
360  m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
361  m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f );
362  OGL_SetMaterial( m_materials.m_Plastic );
363  break;
364 
365  default:
366  m_materials.m_Copper.m_Diffuse = get_layer_color( aLayerID );
367  OGL_SetMaterial( m_materials.m_Copper );
368 
369  break;
370  }
371 }
372 
373 
375 {
376  SFVEC3F layerColor = m_settings.GetLayerColor( aLayerID );
377 
379  {
380  switch( aLayerID )
381  {
382  case B_Adhes:
383  case F_Adhes:
384  break;
385 
386  case B_Mask:
387  case F_Mask:
388  layerColor = m_settings.m_SolderMaskColor;
389  break;
390 
391  case B_Paste:
392  case F_Paste:
393  layerColor = m_settings.m_SolderPasteColor;
394  break;
395 
396  case B_SilkS:
397  case F_SilkS:
398  layerColor = m_settings.m_SilkScreenColor;
399  break;
400 
401  case Dwgs_User:
402  case Cmts_User:
403  case Eco1_User:
404  case Eco2_User:
405  case Edge_Cuts:
406  case Margin:
407  break;
408 
409  case B_CrtYd:
410  case F_CrtYd:
411  break;
412 
413  case B_Fab:
414  case F_Fab:
415  break;
416 
417  default:
418  layerColor = m_settings.m_CopperColor;
419  break;
420  }
421  }
422 
423  return layerColor;
424 }
425 
426 void init_lights(void)
427 {
428  // Setup light
429  // https://www.opengl.org/sdk/docs/man2/xhtml/glLight.xml
430  // /////////////////////////////////////////////////////////////////////////
431  const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
432  const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
433  const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
434 
435  glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
436  glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
437  glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
438 
439  const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
440  const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
441 
442  // defines a directional light that points along the negative z-axis
443  GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
444 
445  // This makes a vector slight not perpendicular with XZ plane
446  const SFVEC3F vectorLight = SphericalToCartesian( glm::pi<float>() * 0.03f,
447  glm::pi<float>() * 0.25f );
448 
449  position[0] = vectorLight.x;
450  position[1] = vectorLight.y;
451  position[2] = vectorLight.z;
452 
453  glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
454  glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
455  glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
456  glLightfv( GL_LIGHT1, GL_POSITION, position );
457 
458 
459  // defines a directional light that points along the positive z-axis
460  position[2] = -position[2];
461 
462  glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
463  glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
464  glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
465  glLightfv( GL_LIGHT2, GL_POSITION, position );
466 
467  const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
468 
469  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
470 
471  glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
472 }
473 
474 
475 bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving,
476  REPORTER *aStatusTextReporter )
477 {
478  // Initialize openGL
480  {
481  if( !initializeOpenGL() )
482  return false;
483  }
484 
485  if( m_reloadRequested )
486  {
487  std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
488 
489  if( aStatusTextReporter )
490  aStatusTextReporter->Report( _( "Loading..." ) );
491 
492  reload( aStatusTextReporter );
493  setupMaterials();
494 
495  // generate a new 3D grid as the size of the board may had changed
498  }
499  else
500  {
501  // Check if grid was changed
503  {
504  // and generate a new one
507  }
508  }
509 
510  // Initial setup
511  // /////////////////////////////////////////////////////////////////////////
512  glDepthFunc( GL_LESS );
513  glEnable( GL_CULL_FACE );
514  glFrontFace( GL_CCW ); // This is the openGL default
515  glEnable( GL_NORMALIZE ); // This allow openGL to normalize the normals after transformations
516 
517  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
518 
519 
520  // clear color and depth buffers
521  // /////////////////////////////////////////////////////////////////////////
522  glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
523  glClearDepth( 1.0f );
524  glClearStencil( 0x00 );
525  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
526 
527 
528  // Draw the background ( rectangle with color gradient)
529  // /////////////////////////////////////////////////////////////////////////
532 
533  glEnable( GL_DEPTH_TEST );
534 
535 
536  // Set projection and modelview matrixes
537  // /////////////////////////////////////////////////////////////////////////
538  glMatrixMode( GL_PROJECTION );
539  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetProjectionMatrix() ) );
540 
541  glMatrixMode( GL_MODELVIEW );
542  glLoadIdentity();
543  glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().GetViewMatrix() ) );
544 
545 
546  // Position the headlight
547  // /////////////////////////////////////////////////////////////////////////
548 
549  setLight_Front( true );
550  setLight_Top( true );
551  setLight_Bottom( true );
552 
553  glEnable( GL_LIGHTING );
554 
555  {
556  const SFVEC3F &cameraPos = m_settings.CameraGet().GetPos();
557 
558  // Place the light at a minimun Z so the diffuse factor will not drop
559  // and the board will still look with good light.
560  float zpos;
561 
562  if( cameraPos.z > 0.0f )
563  {
564  zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
565  }
566  else
567  {
568  zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
569  }
570 
571  const GLfloat headlight_pos[] = { cameraPos.x,
572  cameraPos.y,
573  zpos,
574  1.0f }; // This is a point light
575 
576  glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
577  }
578 
579 
580  // Display board body
581  // /////////////////////////////////////////////////////////////////////////
583  {
585  {
588 
589  OGL_SetMaterial( m_materials.m_EpoxyBoard );
590 
592 
594  {
598 
601  NULL );
602  }
603  else
604  {
606  }
607  }
608  }
609 
610 
612  {
613  // Draw vias and pad holes with copper material
615  }
616  else
617  {
618  OGL_SetMaterial( m_materials.m_GrayMaterial );
619  }
620 
621  if( m_ogl_disp_list_via )
622  {
624  }
625 
627  {
629  }
630 
631 
632  // Display copper and tech layers
633  // /////////////////////////////////////////////////////////////////////////
634  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
635  ii != m_ogl_disp_lists_layers.end();
636  ++ii )
637  {
638 
639  const PCB_LAYER_ID layer_id = (PCB_LAYER_ID)(ii->first);
640 
641  // Mask kayers are not processed here because they are a special case
642  if( (layer_id == B_Mask) || (layer_id == F_Mask) )
643  continue;
644 
645  // Do not show inner layers when it is displaying the board
647  {
648  if( (layer_id > F_Cu) && (layer_id < B_Cu) )
649  continue;
650  }
651 
652  glPushMatrix();
653 
654  // !TODO: if we want to increase the separation between layers
655  //glScalef( 1.0f, 1.0f, 3.0f );
656 
657 
658  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
659  set_layer_material( layer_id );
660 
663  pLayerDispList->GetZBot(),
664  pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
665 
666  if( (layer_id >= F_Cu) && (layer_id <= B_Cu) )
667  {
668  if( m_ogl_disp_lists_layers_holes_outer.find( layer_id ) !=
670  {
671  const CLAYERS_OGL_DISP_LISTS* viasHolesLayer =
673 
674  wxASSERT( viasHolesLayer != NULL );
675 
676  if( viasHolesLayer != NULL )
677  {
678  pLayerDispList->DrawAllCameraCulledSubtractLayer(
680  viasHolesLayer,
681  (aIsMoving == false) );
682  }
683  }
684  else
685  {
686  pLayerDispList->DrawAllCameraCulledSubtractLayer(
688  NULL,
689  (aIsMoving == false) );
690  }
691  }
692  else
693  {
694  pLayerDispList->DrawAllCameraCulled( m_settings.CameraGet().GetPos().z,
695  (aIsMoving == false) );
696  }
697 
698  glPopMatrix();
699  }
700 
701 
702  // Render 3D Models (Non-transparent)
703  // /////////////////////////////////////////////////////////////////////////
704 
705  //setLight_Top( false );
706  //setLight_Bottom( true );
707  render_3D_models( false, false );
708 
709  //setLight_Top( true );
710  //setLight_Bottom( false );
711  render_3D_models( true, false );
712 
713 
714  // Display transparent mask layers
715  // /////////////////////////////////////////////////////////////////////////
717  {
718  //setLight_Top( true );
719  //setLight_Bottom( true );
720 
721  if( m_settings.CameraGet().GetPos().z > 0 )
722  {
724  aIsMoving );
725 
727  aIsMoving );
728  }
729  else
730  {
732  aIsMoving );
733 
735  aIsMoving );
736  }
737  }
738 
739 
740  // Render 3D Models (Transparent)
741  // /////////////////////////////////////////////////////////////////////////
742 
743  //setLight_Top( false );
744  //setLight_Bottom( true );
745  render_3D_models( false, true );
746 
747  //setLight_Top( true );
748  //setLight_Bottom( false );
749  render_3D_models( true, true );
750 
751 
752  // Render Grid
753  // /////////////////////////////////////////////////////////////////////////
754 
755  if( m_settings.GridGet() != GRID3D_NONE )
756  {
757  glDisable( GL_LIGHTING );
758 
759  if( glIsList( m_ogl_disp_list_grid ) )
760  glCallList( m_ogl_disp_list_grid );
761 
762  glEnable( GL_LIGHTING );
763  }
764 
765 
766  // Render 3D arrows
767  // /////////////////////////////////////////////////////////////////////////
768  if( m_settings.GetFlag( FL_AXIS ) )
770 
771  // Return back to the original viewport (this is important if we want
772  // to take a screenshot after the render)
773  // /////////////////////////////////////////////////////////////////////////
774  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
775 
776  return false;
777 }
778 
779 
781 {
782  glEnable( GL_LINE_SMOOTH );
783  glShadeModel( GL_SMOOTH );
784 
785  // 4-byte pixel alignment
786  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
787 
788  // Initialize the open GL texture to draw the filled semi-circle of the segments
790 
791  if( !circleImage )
792  return false;
793 
794  circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
795  (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
796  (SIZE_OF_CIRCLE_TEXTURE / 2) - 4,
797  0xFF );
798 
799  //circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
800  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
801  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 2, 0xFF );
802 
803  CIMAGE *circleImage_Copy = new CIMAGE( *circleImage );
804 
805  circleImage->EfxFilter( circleImage_Copy, FILTER_BLUR_3X3 );
806 
807  m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
808 
809  //circleImage_Copy->SaveAsPNG("circleImage.png");
810  delete circleImage_Copy;
811  circleImage_Copy = 0;
812 
813  //circleImage->SaveAsPNG("circleImage_blured.png");
814  delete circleImage;
815  circleImage = 0;
816 
817  init_lights();
818 
819  // Use this mode if you want see the triangle lines (debug proposes)
820  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
821 
823 
824  return true;
825 }
826 
827 
829 {
830  glEnable( GL_COLOR_MATERIAL );
831  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
832 
833  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
834  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
835  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
836  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
837 
838  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
839  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
840 
841  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
842  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
843  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
844 }
845 
846 
848 {
849  if( glIsList( m_ogl_disp_list_grid ) )
850  glDeleteLists( m_ogl_disp_list_grid, 1 );
851 
853 
854  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
855  ii != m_ogl_disp_lists_layers.end();
856  ++ii )
857  {
858  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
859  delete pLayerDispList;
860  }
861 
862  m_ogl_disp_lists_layers.clear();
863 
864 
865  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin();
867  ++ii )
868  {
869  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
870  delete pLayerDispList;
871  }
872 
874 
875 
876  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin();
878  ++ii )
879  {
880  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
881  delete pLayerDispList;
882  }
883 
885 
886  for( MAP_TRIANGLES::const_iterator ii = m_triangles.begin();
887  ii != m_triangles.end();
888  ++ii )
889  {
890  CLAYER_TRIANGLES *pointer = static_cast<CLAYER_TRIANGLES*>(ii->second);
891  delete pointer;
892  }
893 
894  m_triangles.clear();
895 
896 
897  for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin();
898  ii != m_3dmodel_map.end();
899  ++ii )
900  {
901  C_OGL_3DMODEL *pointer = static_cast<C_OGL_3DMODEL*>(ii->second);
902  delete pointer;
903  }
904 
905  m_3dmodel_map.clear();
906 
907 
908  delete m_ogl_disp_list_board;
910 
913 
916 
919 
922 
923  delete m_ogl_disp_list_via;
925 
928 
931 }
932 
933 
935  float aZPosition,
936  bool aIsRenderingOnPreviewMode )
937 {
938  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
939 
941  {
942  if( m_ogl_disp_lists_layers.find( aLayerID ) !=
944  {
945  CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID );
946 
949  aZPosition,
951 
953  aZPosition,
955 
956  set_layer_material( aLayerID );
957 
959 
961  pLayerDispListMask,
963  !aIsRenderingOnPreviewMode );
964  }
965  else
966  {
967  // This case there is no layer with mask, so we will render the full board as mask
968 
971  aZPosition,
973 
975  aZPosition,
977 
978  set_layer_material( aLayerID );
979 
981 
983  NULL,
985  !aIsRenderingOnPreviewMode );
986  }
987  }
988 }
989 
990 
991 void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot,
992  bool aRenderTransparentOnly )
993 {
994  // Go for all modules
995  for( auto module : m_settings.GetBoard()->Modules() )
996  {
997  if( !module->Models().empty() )
998  if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T) module->GetAttributes() ) )
999  if( ( aRenderTopOrBot && !module->IsFlipped() )
1000  || ( !aRenderTopOrBot && module->IsFlipped() ) )
1001  render_3D_module( module, aRenderTransparentOnly );
1002  }
1003 }
1004 
1005 
1007  bool aRenderTransparentOnly )
1008 {
1009  if( !module->Models().empty() )
1010  {
1011  const double zpos = m_settings.GetModulesZcoord3DIU( module->IsFlipped() );
1012 
1013  glPushMatrix();
1014 
1015  wxPoint pos = module->GetPosition();
1016 
1017  glTranslatef( pos.x * m_settings.BiuTo3Dunits(),
1018  -pos.y * m_settings.BiuTo3Dunits(),
1019  zpos );
1020 
1021  if( module->GetOrientation() )
1022  glRotated( (double) module->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
1023 
1024  if( module->IsFlipped() )
1025  {
1026  glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1027  glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1028  }
1029 
1030  double modelunit_to_3d_units_factor = m_settings.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
1031 
1032  glScaled( modelunit_to_3d_units_factor,
1033  modelunit_to_3d_units_factor,
1034  modelunit_to_3d_units_factor );
1035 
1036  // Get the list of model files for this model
1037  auto sM = module->Models().begin();
1038  auto eM = module->Models().end();
1039 
1040  while( sM != eM )
1041  {
1042  if( !sM->m_Filename.empty() )
1043  {
1044  // Check if the model is present in our cache map
1045  if( m_3dmodel_map.find( sM->m_Filename ) != m_3dmodel_map.end() )
1046  {
1047  // It is not present, try get it from cache
1048  const C_OGL_3DMODEL *modelPtr = m_3dmodel_map[ sM->m_Filename ];
1049 
1050  if( modelPtr )
1051  {
1052  if( ( (!aRenderTransparentOnly) && modelPtr->Have_opaque() ) ||
1053  ( aRenderTransparentOnly && modelPtr->Have_transparent() ) )
1054  {
1055  glPushMatrix();
1056 
1057  glTranslatef( sM->m_Offset.x, sM->m_Offset.y, sM->m_Offset.z );
1058 
1059  glRotatef( -sM->m_Rotation.z, 0.0f, 0.0f, 1.0f );
1060  glRotatef( -sM->m_Rotation.y, 0.0f, 1.0f, 0.0f );
1061  glRotatef( -sM->m_Rotation.x, 1.0f, 0.0f, 0.0f );
1062 
1063  glScalef( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z );
1064 
1065  if( aRenderTransparentOnly )
1066  modelPtr->Draw_transparent();
1067  else
1068  modelPtr->Draw_opaque();
1069 
1071  {
1072  glEnable( GL_BLEND );
1073  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1074 
1075  glLineWidth( 1 );
1076  modelPtr->Draw_bboxes();
1077 
1078  glDisable( GL_LIGHTING );
1079 
1080  glColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
1081 
1082  glLineWidth( 4 );
1083  modelPtr->Draw_bbox();
1084 
1085  glEnable( GL_LIGHTING );
1086  }
1087 
1088  glPopMatrix();
1089  }
1090  }
1091  }
1092  }
1093 
1094  ++sM;
1095  }
1096 
1097  glPopMatrix();
1098  }
1099 }
1100 
1101 
1102 // create a 3D grid to an openGL display list: an horizontal grid (XY plane and Z = 0,
1103 // and a vertical grid (XZ plane and Y = 0)
1105 {
1106  if( glIsList( m_ogl_disp_list_grid ) )
1107  glDeleteLists( m_ogl_disp_list_grid, 1 );
1108 
1110 
1111  if( aGridType == GRID3D_NONE )
1112  return;
1113 
1114  m_ogl_disp_list_grid = glGenLists( 1 );
1115 
1116  if( !glIsList( m_ogl_disp_list_grid ) )
1117  return;
1118 
1119  glNewList( m_ogl_disp_list_grid, GL_COMPILE );
1120 
1121  glEnable( GL_BLEND );
1122  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1123 
1124  const double zpos = 0.0;
1125 
1126  // Color of grid lines
1127  const SFVEC3F gridColor = m_settings.GetColor( DARKGRAY );
1128 
1129  // Color of grid lines every 5 lines
1130  const SFVEC3F gridColor_marker = m_settings.GetColor( LIGHTGRAY );
1131  const double scale = m_settings.BiuTo3Dunits();
1132  const double transparency = 0.35;
1133 
1134  double griSizeMM = 0.0;
1135 
1136  switch( aGridType )
1137  {
1138  default:
1139  case GRID3D_NONE:
1140  return;
1141  case GRID3D_1MM:
1142  griSizeMM = 1.0;
1143  break;
1144  case GRID3D_2P5MM:
1145  griSizeMM = 2.5;
1146  break;
1147  case GRID3D_5MM:
1148  griSizeMM = 5.0;
1149  break;
1150  case GRID3D_10MM:
1151  griSizeMM = 10.0;
1152  break;
1153  }
1154 
1155  glNormal3f( 0.0, 0.0, 1.0 );
1156 
1157  const wxSize brd_size = m_settings.GetBoardSizeBIU();
1158  wxPoint brd_center_pos = m_settings.GetBoardPosBIU();
1159 
1160  brd_center_pos.y = -brd_center_pos.y;
1161 
1162  const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
1163  const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
1164 
1165  // Grid limits, in 3D units
1166  double xmin = (brd_center_pos.x - xsize / 2) * scale;
1167  double xmax = (brd_center_pos.x + xsize / 2) * scale;
1168  double ymin = (brd_center_pos.y - ysize / 2) * scale;
1169  double ymax = (brd_center_pos.y + ysize / 2) * scale;
1170  double zmin = Millimeter2iu( -50 ) * scale;
1171  double zmax = Millimeter2iu( 100 ) * scale;
1172 
1173  // Draw horizontal grid centered on 3D origin (center of the board)
1174  for( int ii = 0; ; ii++ )
1175  {
1176  if( (ii % 5) )
1177  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1178  else
1179  glColor4f( gridColor_marker.r,
1180  gridColor_marker.g,
1181  gridColor_marker.b,
1182  transparency );
1183 
1184  const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
1185 
1186  if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1187  {
1188  glBegin( GL_LINES );
1189  glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1190  glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1191  glEnd();
1192 
1193  if( ii != 0 )
1194  {
1195  glBegin( GL_LINES );
1196  glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1197  glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1198  glEnd();
1199  }
1200  }
1201 
1202  if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1203  {
1204  glBegin( GL_LINES );
1205  glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
1206  glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
1207  glEnd();
1208 
1209  if( ii != 0 )
1210  {
1211  glBegin( GL_LINES );
1212  glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
1213  glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
1214  glEnd();
1215  }
1216  }
1217 
1218  if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1219  break;
1220  }
1221 
1222  // Draw vertical grid on Z axis
1223  glNormal3f( 0.0, -1.0, 0.0 );
1224 
1225  // Draw vertical grid lines (parallel to Z axis)
1226  double posy = -brd_center_pos.y * scale;
1227 
1228  for( int ii = 0; ; ii++ )
1229  {
1230  if( (ii % 5) )
1231  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1232  else
1233  glColor4f( gridColor_marker.r,
1234  gridColor_marker.g,
1235  gridColor_marker.b,
1236  transparency );
1237 
1238  const double delta = ii * griSizeMM * IU_PER_MM;
1239 
1240  glBegin( GL_LINES );
1241  xmax = (brd_center_pos.x + delta) * scale;
1242 
1243  glVertex3f( xmax, posy, zmin );
1244  glVertex3f( xmax, posy, zmax );
1245  glEnd();
1246 
1247  if( ii != 0 )
1248  {
1249  glBegin( GL_LINES );
1250  xmin = (brd_center_pos.x - delta) * scale;
1251  glVertex3f( xmin, posy, zmin );
1252  glVertex3f( xmin, posy, zmax );
1253  glEnd();
1254  }
1255 
1256  if( delta > xsize / 2.0f )
1257  break;
1258  }
1259 
1260  // Draw horizontal grid lines on Z axis (parallel to X axis)
1261  for( int ii = 0; ; ii++ )
1262  {
1263  if( (ii % 5) )
1264  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1265  else
1266  glColor4f( gridColor_marker.r,
1267  gridColor_marker.g,
1268  gridColor_marker.b,
1269  transparency );
1270 
1271  const double delta = ii * griSizeMM * IU_PER_MM * scale;
1272 
1273  if( delta <= zmax )
1274  {
1275  // Draw grid lines on Z axis (positive Z axis coordinates)
1276  glBegin( GL_LINES );
1277  glVertex3f( xmin, posy, delta );
1278  glVertex3f( xmax, posy, delta );
1279  glEnd();
1280  }
1281 
1282  if( delta <= -zmin && ( ii != 0 ) )
1283  {
1284  // Draw grid lines on Z axis (negative Z axis coordinates)
1285  glBegin( GL_LINES );
1286  glVertex3f( xmin, posy, -delta );
1287  glVertex3f( xmax, posy, -delta );
1288  glEnd();
1289  }
1290 
1291  if( ( delta > zmax ) && ( delta > -zmin ) )
1292  break;
1293  }
1294 
1295  glDisable( GL_BLEND );
1296 
1297  glEndList();
1298 }
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
double GetOrientation() const
Definition: class_module.h:202
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:272
Implementation of conversion functions that require both schematic and board internal units.
SFVEC3D m_CopperColor
in realistic mode: copper color
Definition: cinfo3d_visu.h:503
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
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:110
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:497
Class 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
struct C3D_RENDER_OGL_LEGACY::@33 m_materials
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:130
#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:
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
void setLight_Front(bool enabled)
MODULES & Modules()
Definition: class_board.h:236
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:73
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.
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:501
#define _(s)
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.
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:500
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.
SFVEC3D m_SilkScreenColor
in realistic mode: SilkScreen color
Definition: cinfo3d_visu.h:502
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:192
const int scale
const glm::mat4 & GetViewMatrix() const
Definition: ccamera.cpp:389
bool m_reloadRequested
!TODO: this must be reviewed in order to flag change types
#define max(a, b)
Definition: auxiliary.h:86
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
implements generic openGL functions that are common to any openGL target
const glm::mat4 & GetProjectionMatrix() const
Definition: ccamera.cpp:359
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.
Class CIMAGE manages a 8-bit channel image.
Definition: cimage.h:86
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:197
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, E_FILTER aFilterType)
Function EfxFilter apply a filter to the input image and stores it in the image class this <- FilterT...
Definition: cimage.cpp:469
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
#define min(a, b)
Definition: auxiliary.h:85
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.