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 
520  bool aIsMoving, REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
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, aWarningTextReporter );
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  {
739  ( ( ( layer_id == B_SilkS ) &&
740  ( m_ogl_disp_lists_layers.find( B_Mask ) != m_ogl_disp_lists_layers.end() ) ) ||
741  ( ( layer_id == F_SilkS ) &&
742  ( m_ogl_disp_lists_layers.find( F_Mask ) != m_ogl_disp_lists_layers.end() ) ) ) )
743  {
744  const PCB_LAYER_ID layerMask_id = (layer_id == B_SilkS)?B_Mask:F_Mask;
745 
746  const CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( layerMask_id );
747 
748  pLayerDispList->DrawAllCameraCulledSubtractLayer(
749  pLayerDispListMask,
751  (aIsMoving == false) );
752  }
753  else
754  {
756  ( ( layer_id == B_SilkS ) || ( layer_id == F_SilkS )
757  // Remove vias on SolderPaste can be added as an option in future
758  // ( layer_id == B_Paste ) || ( layer_id == F_Paste ) )
759  ) )
760  {
761  pLayerDispList->DrawAllCameraCulledSubtractLayer(
762  NULL,
764  (aIsMoving == false) );
765  }
766  else
767  {
768  pLayerDispList->DrawAllCameraCulled( m_settings.CameraGet().GetPos().z,
769  (aIsMoving == false) );
770  }
771  }
772  }
773 
774  glPopMatrix();
775  }
776 
777 
778  // Render 3D Models (Non-transparent)
779  // /////////////////////////////////////////////////////////////////////////
780 
781  //setLight_Top( false );
782  //setLight_Bottom( true );
783  render_3D_models( false, false );
784 
785  //setLight_Top( true );
786  //setLight_Bottom( false );
787  render_3D_models( true, false );
788 
789 
790  // Display transparent mask layers
791  // /////////////////////////////////////////////////////////////////////////
793  {
794  //setLight_Top( true );
795  //setLight_Bottom( true );
796 
797  // add a depth buffer offset, it will help to hide some artifacts
798  // on silkscreen where the SolderMask is removed
799  glEnable( GL_POLYGON_OFFSET_FILL );
800  glPolygonOffset( 0.0f, -1.0f );
801 
802  if( m_settings.CameraGet().GetPos().z > 0 )
803  {
805  aIsMoving );
806 
808  aIsMoving );
809  }
810  else
811  {
813  aIsMoving );
814 
816  aIsMoving );
817  }
818 
819  glDisable( GL_POLYGON_OFFSET_FILL );
820  glPolygonOffset( 0.0f, 0.0f );
821  }
822 
823 
824  // Render 3D Models (Transparent)
825  // /////////////////////////////////////////////////////////////////////////
826 
827  //setLight_Top( false );
828  //setLight_Bottom( true );
829  render_3D_models( false, true );
830 
831  //setLight_Top( true );
832  //setLight_Bottom( false );
833  render_3D_models( true, true );
834 
835 
836  // Render Grid
837  // /////////////////////////////////////////////////////////////////////////
838 
840  {
841  glDisable( GL_LIGHTING );
842 
843  if( glIsList( m_ogl_disp_list_grid ) )
844  glCallList( m_ogl_disp_list_grid );
845 
846  glEnable( GL_LIGHTING );
847  }
848 
849 
850  // Render 3D arrows
851  // /////////////////////////////////////////////////////////////////////////
852  if( m_settings.GetFlag( FL_AXIS ) )
854 
855  // Return back to the original viewport (this is important if we want
856  // to take a screenshot after the render)
857  // /////////////////////////////////////////////////////////////////////////
858  glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
859 
860  return false;
861 }
862 
863 
865 {
866  glEnable( GL_LINE_SMOOTH );
867  glShadeModel( GL_SMOOTH );
868 
869  // 4-byte pixel alignment
870  glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
871 
872  // Initialize the open GL texture to draw the filled semi-circle of the segments
874 
875  if( !circleImage )
876  return false;
877 
878  circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
879  (SIZE_OF_CIRCLE_TEXTURE / 2) - 0,
880  (SIZE_OF_CIRCLE_TEXTURE / 2) - 4,
881  0xFF );
882 
883  //circleImage->CircleFilled( (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
884  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 1,
885  // (SIZE_OF_CIRCLE_TEXTURE / 4)*1.5f - 2, 0xFF );
886 
887  CIMAGE *circleImage_Copy = new CIMAGE( *circleImage );
888 
889  circleImage->EfxFilter( circleImage_Copy, IMAGE_FILTER::BLUR_3X3 );
890 
891  m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
892 
893  //circleImage_Copy->SaveAsPNG("circleImage.png");
894  delete circleImage_Copy;
895  circleImage_Copy = 0;
896 
897  //circleImage->SaveAsPNG("circleImage_blured.png");
898  delete circleImage;
899  circleImage = 0;
900 
901  init_lights();
902 
903  // Use this mode if you want see the triangle lines (debug proposes)
904  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
905 
907 
908  return true;
909 }
910 
911 
913 {
914  glEnable( GL_COLOR_MATERIAL );
915  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
916 
917  const SFVEC4F ambient = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
918  const SFVEC4F diffuse = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
919  const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
920  const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
921 
922  glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
923  glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
924 
925  glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
926  glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
927  glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
928 }
929 
930 
932 {
933  if( glIsList( m_ogl_disp_list_grid ) )
934  glDeleteLists( m_ogl_disp_list_grid, 1 );
935 
937 
938  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin();
939  ii != m_ogl_disp_lists_layers.end();
940  ++ii )
941  {
942  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
943  delete pLayerDispList;
944  }
945 
946  m_ogl_disp_lists_layers.clear();
947 
948 
949  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin();
951  ++ii )
952  {
953  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
954  delete pLayerDispList;
955  }
956 
958 
959 
960  for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin();
962  ++ii )
963  {
964  CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast<CLAYERS_OGL_DISP_LISTS*>(ii->second);
965  delete pLayerDispList;
966  }
967 
969 
970  for( MAP_TRIANGLES::const_iterator ii = m_triangles.begin();
971  ii != m_triangles.end();
972  ++ii )
973  {
974  CLAYER_TRIANGLES *pointer = static_cast<CLAYER_TRIANGLES*>(ii->second);
975  delete pointer;
976  }
977 
978  m_triangles.clear();
979 
980 
981  for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin();
982  ii != m_3dmodel_map.end();
983  ++ii )
984  {
985  C_OGL_3DMODEL *pointer = static_cast<C_OGL_3DMODEL*>(ii->second);
986  delete pointer;
987  }
988 
989  m_3dmodel_map.clear();
990 
991 
992  delete m_ogl_disp_list_board;
994 
997 
1000 
1003 
1006 
1007  delete m_ogl_disp_list_via;
1008  m_ogl_disp_list_via = 0;
1009 
1012 
1015 }
1016 
1017 
1019  float aZPosition,
1020  bool aIsRenderingOnPreviewMode )
1021 {
1022  wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
1023 
1024  if( m_ogl_disp_list_board )
1025  {
1026  if( m_ogl_disp_lists_layers.find( aLayerID ) !=
1027  m_ogl_disp_lists_layers.end() )
1028  {
1029  CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID );
1030 
1033  aZPosition,
1035 
1037  aZPosition,
1039 
1040  set_layer_material( aLayerID );
1041 
1043 
1045  pLayerDispListMask,
1047  !aIsRenderingOnPreviewMode );
1048  }
1049  else
1050  {
1051  // This case there is no layer with mask, so we will render the full board as mask
1052 
1055  aZPosition,
1057 
1059  aZPosition,
1061 
1062  set_layer_material( aLayerID );
1063 
1065 
1067  NULL,
1069  !aIsRenderingOnPreviewMode );
1070  }
1071  }
1072 }
1073 
1074 
1075 void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot,
1076  bool aRenderTransparentOnly )
1077 {
1078  // Go for all modules
1079  for( auto module : m_settings.GetBoard()->Modules() )
1080  {
1081  if( !module->Models().empty() )
1082  if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T) module->GetAttributes() ) )
1083  if( ( aRenderTopOrBot && !module->IsFlipped() )
1084  || ( !aRenderTopOrBot && module->IsFlipped() ) )
1085  render_3D_module( module, aRenderTransparentOnly );
1086  }
1087 }
1088 
1089 
1091  bool aRenderTransparentOnly )
1092 {
1093  if( !module->Models().empty() )
1094  {
1095  const double zpos = m_settings.GetModulesZcoord3DIU( module->IsFlipped() );
1096 
1097  glPushMatrix();
1098 
1099  wxPoint pos = module->GetPosition();
1100 
1101  glTranslatef( pos.x * m_settings.BiuTo3Dunits(),
1102  -pos.y * m_settings.BiuTo3Dunits(),
1103  zpos );
1104 
1105  if( module->GetOrientation() )
1106  glRotated( (double) module->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
1107 
1108  if( module->IsFlipped() )
1109  {
1110  glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
1111  glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
1112  }
1113 
1114  double modelunit_to_3d_units_factor = m_settings.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
1115 
1116  glScaled( modelunit_to_3d_units_factor,
1117  modelunit_to_3d_units_factor,
1118  modelunit_to_3d_units_factor );
1119 
1120  // Get the list of model files for this model
1121  auto sM = module->Models().begin();
1122  auto eM = module->Models().end();
1123 
1124  while( sM != eM )
1125  {
1126  if( !sM->m_Filename.empty() )
1127  {
1128  // Check if the model is present in our cache map
1129  if( m_3dmodel_map.find( sM->m_Filename ) != m_3dmodel_map.end() )
1130  {
1131  // It is not present, try get it from cache
1132  const C_OGL_3DMODEL *modelPtr = m_3dmodel_map[ sM->m_Filename ];
1133 
1134  if( modelPtr )
1135  {
1136  if( ( (!aRenderTransparentOnly) && modelPtr->Have_opaque() ) ||
1137  ( aRenderTransparentOnly && modelPtr->Have_transparent() ) )
1138  {
1139  glPushMatrix();
1140 
1141  glTranslatef( sM->m_Offset.x, sM->m_Offset.y, sM->m_Offset.z );
1142 
1143  glRotatef( -sM->m_Rotation.z, 0.0f, 0.0f, 1.0f );
1144  glRotatef( -sM->m_Rotation.y, 0.0f, 1.0f, 0.0f );
1145  glRotatef( -sM->m_Rotation.x, 1.0f, 0.0f, 0.0f );
1146 
1147  glScalef( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z );
1148 
1149  if( aRenderTransparentOnly )
1150  modelPtr->Draw_transparent();
1151  else
1152  modelPtr->Draw_opaque();
1153 
1155  {
1156  glEnable( GL_BLEND );
1157  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1158 
1159  glLineWidth( 1 );
1160  modelPtr->Draw_bboxes();
1161 
1162  glDisable( GL_LIGHTING );
1163 
1164  glColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
1165 
1166  glLineWidth( 4 );
1167  modelPtr->Draw_bbox();
1168 
1169  glEnable( GL_LIGHTING );
1170  }
1171 
1172  glPopMatrix();
1173  }
1174  }
1175  }
1176  }
1177 
1178  ++sM;
1179  }
1180 
1181  glPopMatrix();
1182  }
1183 }
1184 
1185 
1186 // create a 3D grid to an openGL display list: an horizontal grid (XY plane and Z = 0,
1187 // and a vertical grid (XZ plane and Y = 0)
1189 {
1190  if( glIsList( m_ogl_disp_list_grid ) )
1191  glDeleteLists( m_ogl_disp_list_grid, 1 );
1192 
1194 
1195  if( aGridType == GRID3D_TYPE::NONE )
1196  return;
1197 
1198  m_ogl_disp_list_grid = glGenLists( 1 );
1199 
1200  if( !glIsList( m_ogl_disp_list_grid ) )
1201  return;
1202 
1203  glNewList( m_ogl_disp_list_grid, GL_COMPILE );
1204 
1205  glEnable( GL_BLEND );
1206  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1207 
1208  const double zpos = 0.0;
1209 
1210  // Color of grid lines
1211  const SFVEC3F gridColor = m_settings.GetColor( DARKGRAY );
1212 
1213  // Color of grid lines every 5 lines
1214  const SFVEC3F gridColor_marker = m_settings.GetColor( LIGHTGRAY );
1215  const double scale = m_settings.BiuTo3Dunits();
1216  const double transparency = 0.35;
1217 
1218  double griSizeMM = 0.0;
1219 
1220  switch( aGridType )
1221  {
1222  default:
1223  case GRID3D_TYPE::NONE:
1224  return;
1225  case GRID3D_TYPE::GRID_1MM:
1226  griSizeMM = 1.0;
1227  break;
1229  griSizeMM = 2.5;
1230  break;
1231  case GRID3D_TYPE::GRID_5MM:
1232  griSizeMM = 5.0;
1233  break;
1235  griSizeMM = 10.0;
1236  break;
1237  }
1238 
1239  glNormal3f( 0.0, 0.0, 1.0 );
1240 
1241  const wxSize brd_size = m_settings.GetBoardSizeBIU();
1242  wxPoint brd_center_pos = m_settings.GetBoardPosBIU();
1243 
1244  brd_center_pos.y = -brd_center_pos.y;
1245 
1246  const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
1247  const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
1248 
1249  // Grid limits, in 3D units
1250  double xmin = (brd_center_pos.x - xsize / 2) * scale;
1251  double xmax = (brd_center_pos.x + xsize / 2) * scale;
1252  double ymin = (brd_center_pos.y - ysize / 2) * scale;
1253  double ymax = (brd_center_pos.y + ysize / 2) * scale;
1254  double zmin = Millimeter2iu( -50 ) * scale;
1255  double zmax = Millimeter2iu( 100 ) * scale;
1256 
1257  // Draw horizontal grid centered on 3D origin (center of the board)
1258  for( int ii = 0; ; ii++ )
1259  {
1260  if( (ii % 5) )
1261  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1262  else
1263  glColor4f( gridColor_marker.r,
1264  gridColor_marker.g,
1265  gridColor_marker.b,
1266  transparency );
1267 
1268  const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
1269 
1270  if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
1271  {
1272  glBegin( GL_LINES );
1273  glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
1274  glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
1275  glEnd();
1276 
1277  if( ii != 0 )
1278  {
1279  glBegin( GL_LINES );
1280  glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
1281  glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
1282  glEnd();
1283  }
1284  }
1285 
1286  if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
1287  {
1288  glBegin( GL_LINES );
1289  glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
1290  glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
1291  glEnd();
1292 
1293  if( ii != 0 )
1294  {
1295  glBegin( GL_LINES );
1296  glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
1297  glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
1298  glEnd();
1299  }
1300  }
1301 
1302  if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
1303  break;
1304  }
1305 
1306  // Draw vertical grid on Z axis
1307  glNormal3f( 0.0, -1.0, 0.0 );
1308 
1309  // Draw vertical grid lines (parallel to Z axis)
1310  double posy = -brd_center_pos.y * scale;
1311 
1312  for( int ii = 0; ; ii++ )
1313  {
1314  if( (ii % 5) )
1315  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1316  else
1317  glColor4f( gridColor_marker.r,
1318  gridColor_marker.g,
1319  gridColor_marker.b,
1320  transparency );
1321 
1322  const double delta = ii * griSizeMM * IU_PER_MM;
1323 
1324  glBegin( GL_LINES );
1325  xmax = (brd_center_pos.x + delta) * scale;
1326 
1327  glVertex3f( xmax, posy, zmin );
1328  glVertex3f( xmax, posy, zmax );
1329  glEnd();
1330 
1331  if( ii != 0 )
1332  {
1333  glBegin( GL_LINES );
1334  xmin = (brd_center_pos.x - delta) * scale;
1335  glVertex3f( xmin, posy, zmin );
1336  glVertex3f( xmin, posy, zmax );
1337  glEnd();
1338  }
1339 
1340  if( delta > xsize / 2.0f )
1341  break;
1342  }
1343 
1344  // Draw horizontal grid lines on Z axis (parallel to X axis)
1345  for( int ii = 0; ; ii++ )
1346  {
1347  if( (ii % 5) )
1348  glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1349  else
1350  glColor4f( gridColor_marker.r,
1351  gridColor_marker.g,
1352  gridColor_marker.b,
1353  transparency );
1354 
1355  const double delta = ii * griSizeMM * IU_PER_MM * scale;
1356 
1357  if( delta <= zmax )
1358  {
1359  // Draw grid lines on Z axis (positive Z axis coordinates)
1360  glBegin( GL_LINES );
1361  glVertex3f( xmin, posy, delta );
1362  glVertex3f( xmax, posy, delta );
1363  glEnd();
1364  }
1365 
1366  if( delta <= -zmin && ( ii != 0 ) )
1367  {
1368  // Draw grid lines on Z axis (negative Z axis coordinates)
1369  glBegin( GL_LINES );
1370  glVertex3f( xmin, posy, -delta );
1371  glVertex3f( xmax, posy, -delta );
1372  glEnd();
1373  }
1374 
1375  if( ( delta > zmax ) && ( delta > -zmin ) )
1376  break;
1377  }
1378 
1379  glDisable( GL_BLEND );
1380 
1381  glEndList();
1382 }
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:183
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:516
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:511
SFVEC3D m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
Definition: cinfo3d_visu.h:512
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:222
void init_lights(void)
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: cinfo3d_visu.h:66
const SFVEC3F & GetPos() const
Definition: ccamera.h:113
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:508
SFVEC3D m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
Definition: cinfo3d_visu.h:515
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:62
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:509
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
void ApplyScalePosition(float aZposition, float aZscale)
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:293
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:510
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:147
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:131
void reload(REPORTER *aStatusTextReporter, REPORTER *aWarningTextReporter)
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:514
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:216
void setLight_Front(bool enabled)
#define NULL
MODULES & Modules()
Definition: class_board.h:229
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:189
C3D_RENDER_OGL_LEGACY(CINFO3D_VISU &aSettings)
float GetNonCopperLayerThickness3DU() const
GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.
Definition: cinfo3d_visu.h:165
Class CINFO3D_VISU Helper class to handle information needed to display 3D board.
Definition: cinfo3d_visu.h:73
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.
bool Redraw(bool aIsMoving, REPORTER *aStatusTextReporter, REPORTER *aWarningTextReporter) 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:286
float GetEpoxyThickness3DU() const
GetEpoxyThickness3DU - Get the current epoxy thickness.
Definition: cinfo3d_visu.h:159
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:513
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:77
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:33
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
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.