KiCad PCB EDA Suite
eda_3d_viewer.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-2021 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 
25 #include <wx/colordlg.h>
26 #include <wx/colour.h>
27 #include <wx/filename.h>
28 #include <wx/string.h>
29 #include <wx/wupdlock.h>
30 #include <wx/clipbrd.h>
31 #include "eda_3d_viewer.h"
32 #include <3d_viewer_settings.h>
33 #include <3d_viewer_id.h>
37 #include <bitmaps.h>
40 #include <board.h>
41 #include <core/arraydim.h>
43 #include <gal/dpi_scaling.h>
44 #include <pgm_base.h>
45 #include <project.h>
48 #include <tool/action_manager.h>
49 #include <tool/common_control.h>
50 #include <tool/tool_manager.h>
51 #include <tool/tool_dispatcher.h>
52 #include <tool/action_toolbar.h>
53 #include <widgets/infobar.h>
55 #include <wx/filedlg.h>
56 
64 const wxChar* EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
65 
66 
67 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
68 
69  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
70  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
71 
73  EDA_3D_VIEWER::Process_Special_Functions )
74 
75  EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_VIEWER::Install3DViewOptionDialog )
76 
77  EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER::Exit3DFrame )
78  EVT_MENU( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER::OnRenderEngineSelection )
79  EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER::OnDisableRayTracing )
80 
81  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
82 END_EVENT_TABLE()
83 
84 
85 EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle,
86  long style ) :
87  KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
88  wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ),
89  m_mainToolBar( nullptr ),
90  m_canvas( nullptr ),
91  m_currentCamera( m_trackBallCamera ),
92  m_trackBallCamera( RANGE_SCALE_3D )
93 {
94  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle );
95 
96  m_disable_ray_tracing = false;
97  m_aboutTitle = _( "KiCad 3D Viewer" );
98 
99  // Give it an icon
100  wxIcon icon;
101  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_3d ) );
102  SetIcon( icon );
103 
104  // Create the status line
105  static const int status_dims[4] = { -1, 170, 130, 130 };
106 
107  wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
108  SetStatusWidths( arrayDim( status_dims ), status_dims );
109 
110  m_canvas = new EDA_3D_CANVAS( this,
111  OGL_ATT_LIST::GetAttributesList( m_boardAdapter.GetAntiAliasingMode() ),
112  aParent->GetBoard(), m_boardAdapter, m_currentCamera,
113  Prj().Get3DCacheManager() );
114 
115  auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
116  LoadSettings( config );
117 
118  // Some settings need the canvas
119  loadCommonSettings();
120 
121  // Create the manager
122  m_toolManager = new TOOL_MANAGER;
123  m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
124 
125  m_actions = new EDA_3D_ACTIONS();
126  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
127  m_canvas->SetEventDispatcher( m_toolDispatcher );
128 
129  // Register tools
130  m_toolManager->RegisterTool( new COMMON_CONTROL );
131  m_toolManager->RegisterTool( new EDA_3D_CONTROLLER );
132  m_toolManager->InitTools();
133 
134  setupUIConditions();
135 
136  if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
137  ctrlTool->SetRotationIncrement( config->m_Camera.rotation_increment );
138 
139  // Run the viewer control tool, it is supposed to be always active
140  m_toolManager->InvokeTool( "3DViewer.Control" );
141 
142  CreateMenuBar();
143  ReCreateMainToolbar();
144 
145  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
146 
147  m_auimgr.SetManagedWindow( this );
148 
149  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
150  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
151  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
152 
153  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
154  // hidding it.
155  m_auimgr.Update();
156 
157  // We don't want the infobar displayed right away
158  m_auimgr.GetPane( "InfoBar" ).Hide();
159  m_auimgr.Update();
160 
161  m_canvas->SetInfoBar( m_infoBar );
162  m_canvas->SetStatusBar( status_bar );
163 
164  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
165  // in order to receive mouse events. Otherwise, the user has to click somewhere on
166  // the canvas before it will respond to mouse wheel events.
167  m_canvas->SetFocus();
168 }
169 
170 
172 {
173  m_canvas->SetEventDispatcher( nullptr );
174 
175  m_auimgr.UnInit();
176 
177  // m_canvas delete will be called by wxWidget manager
178  //delete m_canvas;
179  //m_canvas = nullptr;
180 }
181 
182 
184 {
186 
189 
190 // Helper to define check conditions
191 #define MaterialCheck( x ) ACTION_CONDITIONS().Check( cond.MaterialMode( x ) )
192 #define FlagCheck( x ) ACTION_CONDITIONS().Check( cond.Flag( x ) )
193 #define GridSizeCheck( x ) ACTION_CONDITIONS().Check( cond.GridSize( x ) )
194 
195  auto raytracingCondition = [this]( const SELECTION& aSel )
196  {
198  };
199 
201  ACTION_CONDITIONS().Check( raytracingCondition ) );
202 
209 
227  FlagCheck( FL_AXIS ) );
228 
234 
235 
236  auto orthoCondition =
237  [this] ( const SELECTION& )
238  {
240  };
241 
242  mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( orthoCondition ) );
243 
244 #undef MaterialCheck
245 #undef FlagCheck
246 #undef GridSizeCheck
247 }
248 
249 
251 {
252  // This will schedule a request to load later
253  if( m_canvas )
254  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
255 }
256 
257 
258 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
259 {
260  ReloadRequest();
261 
262  // After the ReloadRequest call, the refresh often takes a bit of time,
263  // and it is made here only on request.
264  if( aForceImmediateRedraw )
265  m_canvas->Refresh();
266 }
267 
268 
270 {
271  // Only update in OpenGL for an interactive interaction
273  m_canvas->Request_refresh( true );
274 }
275 
276 
278 {
281  else
282  NewDisplay( true );
283 }
284 
285 
286 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
287 {
288  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
289 
290  Close( true );
291 }
292 
293 
294 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
295 {
296  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnCloseWindow" );
297 
298  if( m_canvas )
299  m_canvas->Close();
300 
301  // m_canvas delete will be called by wxWidget manager
302  //delete m_canvas;
303  //m_canvas = nullptr;
304 
305  Destroy();
306  event.Skip( true );
307 }
308 
309 
310 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
311 {
312  int id = event.GetId();
313  bool isChecked = event.IsChecked();
314 
315  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
316  id, isChecked );
317 
318  if( m_canvas == nullptr )
319  return;
320 
321  switch( id )
322  {
323  case ID_RELOAD3D_BOARD:
324  NewDisplay( true );
325  break;
326 
330  takeScreenshot( event );
331  return;
332 
334  if( Set3DColorFromUser( m_boardAdapter.m_BgColorBot, _( "Background Color, Bottom" ),
335  nullptr ) )
336  refreshRender();
337  return;
338 
340  if( Set3DColorFromUser( m_boardAdapter.m_BgColorTop, _( "Background Color, Top" ),
341  nullptr ) )
342  refreshRender();
343  return;
344 
347  return;
348 
351  return;
352 
355  return;
356 
359  break;
360 
363  break;
364 
367  refreshRender();
368  break;
369 
371  {
372  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
373  cfg->ResetToDefaults();
374  LoadSettings( cfg );
375 
376  // Tell canvas that we (may have) changed the render engine
378 
379  NewDisplay( true );
380  }
381  return;
382 
383  default:
384  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
385  return;
386  }
387 }
388 
389 
390 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
391 {
392  const RENDER_ENGINE old_engine = m_boardAdapter.GetRenderEngine();
393 
394  if( old_engine == RENDER_ENGINE::OPENGL_LEGACY )
396  else
398 
399  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
401  "OpenGL Legacy" );
402 
403  if( old_engine != m_boardAdapter.GetRenderEngine() )
405 }
406 
407 
408 void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
409 {
410  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
411 
412  m_disable_ray_tracing = true;
414 }
415 
416 
417 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &aEvent )
418 {
419  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
420 
421  if( aEvent.GetActive() && m_canvas )
422  {
423  // Reload data if 3D frame shows a board,
424  // because it can be changed since last frame activation
427 
428  // Activates again the focus of the canvas so it will catch mouse and key events
429  m_canvas->SetFocus();
430  }
431 
432  aEvent.Skip(); // required under wxMAC
433 }
434 
435 
436 void EDA_3D_VIEWER::OnSetFocus( wxFocusEvent& aEvent )
437 {
438  // Activates again the focus of the canvas so it will catch mouse and key events
439  if( m_canvas )
440  m_canvas->SetFocus();
441 
442  aEvent.Skip();
443 }
444 
445 
447 {
449 
450  EDA_3D_VIEWER_SETTINGS* cfg = dynamic_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
451  wxASSERT( cfg );
452 
453  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
454 
455  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
456 
457  auto set_color =
458  [] ( const COLOR4D& aColor, SFVEC4F& aTarget )
459  {
460  aTarget.r = aColor.r;
461  aTarget.g = aColor.g;
462  aTarget.b = aColor.b;
463  aTarget.a = aColor.a;
464  };
465 
468  set_color( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor );
469  set_color( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor );
470  set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ),
476 
477  if( cfg )
478  {
485 
488 
489  for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
490  {
493 
494  SFVEC2F sphericalCoord =
495  SFVEC2F( ( cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
496  cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
497 
498  sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
499  sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
500 
501  m_boardAdapter.m_RtLightSphericalCoords[i] = sphericalCoord;
502  }
503 
504 #define TRANSFER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
505 
507  TRANSFER_SETTING( FL_SUBTRACT_MASK_FROM_SILK, subtract_mask_from_silk );
508 
509  // OpenGL options
510  TRANSFER_SETTING( FL_RENDER_OPENGL_COPPER_THICKNESS, opengl_copper_thickness );
511  TRANSFER_SETTING( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, opengl_show_model_bbox );
512  TRANSFER_SETTING( FL_HIGHLIGHT_ROLLOVER_ITEM, opengl_highlight_on_rollover );
513  TRANSFER_SETTING( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, opengl_AA_disableOnMove );
515  opengl_thickness_disableOnMove );
516  TRANSFER_SETTING( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, opengl_vias_disableOnMove );
517  TRANSFER_SETTING( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, opengl_holes_disableOnMove );
518 
519  // Raytracing options
520  TRANSFER_SETTING( FL_RENDER_RAYTRACING_SHADOWS, raytrace_shadows );
521  TRANSFER_SETTING( FL_RENDER_RAYTRACING_BACKFLOOR, raytrace_backfloor );
522  TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFRACTIONS, raytrace_refractions );
523  TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFLECTIONS, raytrace_reflections );
524  TRANSFER_SETTING( FL_RENDER_RAYTRACING_POST_PROCESSING, raytrace_post_processing );
525  TRANSFER_SETTING( FL_RENDER_RAYTRACING_ANTI_ALIASING, raytrace_anti_aliasing );
526  TRANSFER_SETTING( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, raytrace_procedural_textures );
527 
528  TRANSFER_SETTING( FL_AXIS, show_axis );
529  TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL, show_footprints_normal );
530  TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL_INSERT, show_footprints_insert );
531  TRANSFER_SETTING( FL_FP_ATTRIBUTES_VIRTUAL, show_footprints_virtual );
532  TRANSFER_SETTING( FL_ZONE, show_zones );
533  TRANSFER_SETTING( FL_ADHESIVE, show_adhesive );
534  TRANSFER_SETTING( FL_SILKSCREEN, show_silkscreen );
535  TRANSFER_SETTING( FL_SOLDERMASK, show_soldermask );
536  TRANSFER_SETTING( FL_SOLDERPASTE, show_solderpaste );
537  TRANSFER_SETTING( FL_COMMENTS, show_comments );
538  TRANSFER_SETTING( FL_ECO, show_eco );
539  TRANSFER_SETTING( FL_SHOW_BOARD_BODY, show_board_body );
540  TRANSFER_SETTING( FL_CLIP_SILK_ON_VIA_ANNULUS, clip_silk_on_via_annulus );
541  TRANSFER_SETTING( FL_RENDER_PLATED_PADS_AS_PLATED, renderPlatedPadsAsPlated );
542 
543  m_boardAdapter.SetGridType( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
545  static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
546 
549 
553 
557 
562 
563  // When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
564  // because the ray tracing is very time consumming, and can be seen as not working
565  // (freeze window) with large boards.
566 #if 0
567  RENDER_ENGINE engine = static_cast<RENDER_ENGINE>( cfg->m_Render.engine );
568  wxLogTrace( m_logTrace, engine == RENDER_ENGINE::RAYTRACING ?
569  "EDA_3D_VIEWER::LoadSettings render setting Ray Trace" :
570  "EDA_3D_VIEWER::LoadSettings render setting OpenGL" );
571 #else
573 #endif
574 
575  m_boardAdapter.SetMaterialMode( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
576 
579 
580 #undef TRANSFER_SETTING
581  }
582 }
583 
584 
586 {
587  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
588 
590 
591  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
592 
593  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
594 
595  auto save_color =
596  [colors] ( SFVEC4F& aSource, LAYER_3D_ID aTarget )
597  {
598  // You could think just copy the new color in config is enough.
599  // unfortunately, SFVEC4F uses floats, and COLOR4D uses doubles,
600  // and the conversion SFVEC4F from/to COLOR4D creates small diffs.
601  //
602  // This has no matter to draw colors, but creates slight differences
603  // in config file, that appears always modified.
604  // So we must compare the SFVEC4F old and new values and update only
605  // actual changes.
606  SFVEC4F newSFVEC4Fcolor( float( colors->GetColor( aTarget ).r ),
607  float( colors->GetColor( aTarget ).g ),
608  float( colors->GetColor( aTarget ).b ),
609  float( colors->GetColor( aTarget ).a ) );
610 
611  if( aSource != newSFVEC4Fcolor )
612  colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b,
613  aSource.a ) );
614  };
615 
624 
625  Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
626 
628  "EDA_3D_VIEWER::SaveSettings render setting Ray Trace" :
629  "EDA_3D_VIEWER::SaveSettings render setting OpenGL" );
630 
631  if( cfg )
632  {
633 
634  auto save_color =
635  [] ( const SFVEC3F& aSource, COLOR4D& aTarget )
636  {
637  aTarget = COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 );
638  };
639 
640  save_color( m_boardAdapter.m_RtCameraLightColor, cfg->m_Render.raytrace_lightColorCamera );
641  save_color( m_boardAdapter.m_RtLightColorTop, cfg->m_Render.raytrace_lightColorTop );
642  save_color( m_boardAdapter.m_RtLightColorBottom, cfg->m_Render.raytrace_lightColorBottom );
643 
644  for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
645  {
646  save_color( m_boardAdapter.m_RtLightColor[i], cfg->m_Render.raytrace_lightColor[i] );
647 
648  cfg->m_Render.raytrace_lightElevation[i] =
649  (int)( m_boardAdapter.m_RtLightSphericalCoords[i].x * 180.0f - 90.0f );
650  cfg->m_Render.raytrace_lightAzimuth[i] =
651  (int)( m_boardAdapter.m_RtLightSphericalCoords[i].y * 180.0f );
652  }
653 
654  cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_RtShadowSampleCount;
655  cfg->m_Render.raytrace_nrsamples_reflections = m_boardAdapter.m_RtReflectionSampleCount;
656  cfg->m_Render.raytrace_nrsamples_refractions = m_boardAdapter.m_RtRefractionSampleCount;
657 
658  cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_RtSpreadShadows;
659  cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_RtSpreadReflections;
660  cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_RtSpreadRefractions;
661 
662  cfg->m_Render.raytrace_recursivelevel_refractions =
664  cfg->m_Render.raytrace_recursivelevel_reflections =
666 
667 #define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
668 
669  cfg->m_Render.engine = static_cast<int>( m_boardAdapter.GetRenderEngine() );
670  cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GetGridType() );
671  cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.GetMaterialMode() );
672  cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.GetAntiAliasingMode() );
673 
674  save_color( m_boardAdapter.m_OpenGlSelectionColor, cfg->m_Render.opengl_selection_color );
675 
676  cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
677  cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();
678 
679  if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
680  cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();
681 
682  TRANSFER_SETTING( opengl_AA_disableOnMove, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE );
683  TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS );
684  TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
685  TRANSFER_SETTING( opengl_highlight_on_rollover, FL_HIGHLIGHT_ROLLOVER_ITEM );
686  TRANSFER_SETTING( opengl_thickness_disableOnMove, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE );
687  TRANSFER_SETTING( opengl_vias_disableOnMove, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
688  TRANSFER_SETTING( opengl_holes_disableOnMove, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );
689 
690  TRANSFER_SETTING( raytrace_anti_aliasing, FL_RENDER_RAYTRACING_ANTI_ALIASING );
691  TRANSFER_SETTING( raytrace_backfloor, FL_RENDER_RAYTRACING_BACKFLOOR );
692  TRANSFER_SETTING( raytrace_post_processing, FL_RENDER_RAYTRACING_POST_PROCESSING );
693  TRANSFER_SETTING( raytrace_procedural_textures, FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
694  TRANSFER_SETTING( raytrace_reflections, FL_RENDER_RAYTRACING_REFLECTIONS );
695  TRANSFER_SETTING( raytrace_refractions, FL_RENDER_RAYTRACING_REFRACTIONS );
696  TRANSFER_SETTING( raytrace_shadows, FL_RENDER_RAYTRACING_SHADOWS );
697 
699  TRANSFER_SETTING( show_adhesive, FL_ADHESIVE );
700  TRANSFER_SETTING( show_axis, FL_AXIS );
701  TRANSFER_SETTING( show_board_body, FL_SHOW_BOARD_BODY );
702  TRANSFER_SETTING( clip_silk_on_via_annulus, FL_CLIP_SILK_ON_VIA_ANNULUS );
703  TRANSFER_SETTING( renderPlatedPadsAsPlated, FL_RENDER_PLATED_PADS_AS_PLATED );
704  TRANSFER_SETTING( show_comments, FL_COMMENTS );
705  TRANSFER_SETTING( show_eco, FL_ECO );
706  TRANSFER_SETTING( show_footprints_insert, FL_FP_ATTRIBUTES_NORMAL_INSERT );
707  TRANSFER_SETTING( show_footprints_normal, FL_FP_ATTRIBUTES_NORMAL );
708  TRANSFER_SETTING( show_footprints_virtual, FL_FP_ATTRIBUTES_VIRTUAL );
709  TRANSFER_SETTING( show_silkscreen, FL_SILKSCREEN );
710  TRANSFER_SETTING( show_soldermask, FL_SOLDERMASK );
711  TRANSFER_SETTING( show_solderpaste, FL_SOLDERPASTE );
712  TRANSFER_SETTING( show_zones, FL_ZONE );
713  TRANSFER_SETTING( subtract_mask_from_silk, FL_SUBTRACT_MASK_FROM_SILK );
714 
715 #undef TRANSFER_SETTING
716  }
717 }
718 
719 
721 {
722  BOARD* brd = GetBoard();
723  const FAB_LAYER_COLOR* stdColors = GetColorStandardList();
724  wxColour color;
725 
726  if( brd )
727  {
728  const BOARD_STACKUP& stckp = brd->GetDesignSettings().GetStackupDescriptor();
729 
730  for( const BOARD_STACKUP_ITEM* stckpItem : stckp.GetList() )
731  {
732  wxString colorName = stckpItem->GetColor();
733 
734  if( colorName.StartsWith( "#" ) ) // This is a user defined color.
735  {
736  color.Set( colorName );
737  }
738  else
739  {
740  for( int i = 0; i < GetColorStandardListCount(); i++ )
741  {
742  if( stdColors[i].m_ColorName == colorName )
743  {
744  color = stdColors[i].m_Color;
745  break;
746  }
747  }
748  }
749 
750  if( color.IsOk() )
751  {
752  switch( stckpItem->GetBrdLayerId() )
753  {
754  case F_SilkS:
755  m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0;
756  m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0;
757  m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0;
758  break;
759  case B_SilkS:
760  m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0;
761  m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0;
762  m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0;
763  break;
764  case F_Mask:
765  m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0;
766  m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0;
767  m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0;
768  // Keep the previous alpha value
769  //m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0;
770  break;
771  case B_Mask:
772  m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0;
773  m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0;
774  m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0;
775  // Keep the previous alpha value
776  //m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0;
777  break;
778  default:
779  break;
780  }
781  }
782  }
783  }
784 }
785 
786 
787 void EDA_3D_VIEWER::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
788 {
789  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
790 
791  // Regen menu bars, etc
792  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
793 
794  // There is no base class that handles toolbars for this frame
796 
798 
799  NewDisplay( true );
800 }
801 
802 
803 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
804 {
805  wxString fullFileName;
806  bool fmt_is_jpeg = false;
807 
808  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
809  fmt_is_jpeg = true;
810 
811  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
812  {
813  // Remember path between saves during this session only.
814  const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
815  const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
816 
817  // First time path is set to the project path.
818  if( !m_defaultSaveScreenshotFileName.IsOk() )
820 
821  m_defaultSaveScreenshotFileName.SetExt( ext );
822 
823  wxFileDialog dlg( this, _( "3D Image File Name" ),
825  m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
826  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
827 
828  if( dlg.ShowModal() == wxID_CANCEL )
829  return;
830 
831  m_defaultSaveScreenshotFileName = dlg.GetPath();
832 
833  if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
834  m_defaultSaveScreenshotFileName.SetExt( ext );
835 
836  fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
837 
838  wxFileName fn = fullFileName;
839 
840  if( !fn.IsDirWritable() )
841  {
842  wxString msg;
843 
844  msg.Printf( _( "Insufficient permissions required to save file\n%s" ), fullFileName );
845  wxMessageBox( msg, _( "Error" ), wxOK | wxICON_ERROR, this );
846  return;
847  }
848 
849  // Be sure the screen area destroyed by the file dialog is redrawn
850  // before making a screen copy.
851  // Without this call, under Linux the screen refresh is made to late.
852  wxYield();
853  }
854 
855  // Be sure we have the latest 3D view (remember 3D view is buffered)
856  m_canvas->Request_refresh( true );
857  wxYield();
858 
859  // Build image from the 3D buffer
860  wxWindowUpdateLocker noUpdates( this );
861 
862  wxImage screenshotImage;
863 
864  if( m_canvas )
865  m_canvas->GetScreenshot( screenshotImage );
866 
867  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
868  {
869  wxBitmap bitmap( screenshotImage );
870 
871  wxLogNull doNotLog; // disable logging of failed clipboard actions
872 
873  if( wxTheClipboard->Open() )
874  {
875  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
876 
877  if( !wxTheClipboard->SetData( dobjBmp ) )
878  wxMessageBox( _( "Failed to copy image to clipboard" ) );
879 
880  wxTheClipboard->Flush(); /* the data in clipboard will stay
881  * available after the application exits */
882  wxTheClipboard->Close();
883  }
884  }
885  else
886  {
887  if( !screenshotImage.SaveFile( fullFileName,
888  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
889  wxMessageBox( _( "Can't save file" ) );
890 
891  screenshotImage.Destroy();
892  }
893 
894 }
895 
896 
898 {
899  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
900 
901  if( m_canvas )
903 }
904 
905 
906 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC4F &aColor, const wxString& aTitle,
907  CUSTOM_COLORS_LIST* aPredefinedColors,
908  bool aAllowOpacityControl,
909  KIGFX::COLOR4D aDefaultColor )
910 {
911  KIGFX::COLOR4D newcolor;
912  KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, aColor.a );
913 
914  DIALOG_COLOR_PICKER picker( this, oldcolor, aAllowOpacityControl, aPredefinedColors,
915  aDefaultColor );
916 
917  if( picker.ShowModal() != wxID_OK )
918  return false;
919 
920  newcolor = picker.GetColor();
921 
922  if( newcolor == oldcolor )
923  return false;
924 
925  aColor.r = newcolor.r;
926  aColor.g = newcolor.g;
927  aColor.b = newcolor.b;
928  aColor.a = newcolor.a;
929 
930  return true;
931 }
932 
933 
935 {
936  CUSTOM_COLORS_LIST colors;
937 
938  colors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
939  colors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
940 
941  if( Set3DColorFromUser( m_boardAdapter.m_SilkScreenColorTop, _( "Silkscreen Color" ),
942  &colors, false, colors[0].m_Color ) )
943  {
945 
946  refreshRender();
947 
948  return true;
949  }
950 
951  return false;
952 }
953 
954 
956 {
957  CUSTOM_COLORS_LIST colors;
958 
959  colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, 0.83, "Green" ) );
960  colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, 0.83, "Light Green" ) );
961  colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, 0.83,
962  "Saturated Green" ) );
963  colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, 0.83, "Red" ) );
964  colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, 0.83,
965  "Red Light Orange" ) );
966  colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, 0.83, "Red 2" ) );
967  colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, 0.83, "Blue" ) );
968  colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, 0.83, "Light blue 1" ) );
969  colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, 0.83, "Light blue 2" ) );
970  colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, 0.83,
971  "Green blue (dark)" ) );
972  colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, 0.83, "Black" ) );
973  colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, 0.83, "White" ) );
974  colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, 0.83, "Purple" ) );
975  colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, 0.83, "Purple Dark" ) );
976 
977  if( Set3DColorFromUser( m_boardAdapter.m_SolderMaskColorTop, _( "Solder Mask Color" ),
978  &colors, true, colors[0].m_Color ) )
979  {
981 
982  refreshRender();
983 
984  return true;
985  }
986 
987  return false;
988 }
989 
990 
992 {
993  CUSTOM_COLORS_LIST colors;
994 
995  colors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
996  colors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
997  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
998  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
999 
1000  if( Set3DColorFromUser( m_boardAdapter.m_CopperColor, _( "Copper Color" ), &colors, false,
1001  colors[0].m_Color ) )
1002  {
1003  refreshRender();
1004 
1005  return true;
1006  }
1007 
1008  return false;
1009 }
1010 
1011 
1013 {
1014  CUSTOM_COLORS_LIST colors;
1015 
1016  colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, 0.9,
1017  "FR4 natural, dark" ) );
1018  colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, 0.9, "FR4 natural" ) );
1019  colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, 0.9, "brown/red" ) );
1020  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 1" ) );
1021  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, 0.9, "brown 2" ) );
1022  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 3" ) );
1023  colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, 0.9, "green 1" ) );
1024  colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, 0.9, "green 2" ) );
1025 
1026  if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors,
1027  true, colors[0].m_Color ) )
1028  {
1029  refreshRender();
1030 
1031  return true;
1032  }
1033 
1034  return false;
1035 }
1036 
1037 
1039 {
1040  CUSTOM_COLORS_LIST colors;
1041 
1042  colors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
1043  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1044  colors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
1045 
1046  if( Set3DColorFromUser( m_boardAdapter.m_SolderPasteColor, _( "Solder Paste Color" ), &colors,
1047  false, colors[0].m_Color ) )
1048  {
1049  refreshRender();
1050 
1051  return true;
1052  }
1053 
1054  return false;
1055 }
1056 
1057 
1059 {
1060  wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
1061 
1062  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
1063 
1064  const DPI_SCALING dpi{ settings, this };
1065  m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
1066  // TODO(JE) use all control options
1068 }
Use a gray shading based on diffuse material.
void AnimationEnabledSet(bool aAnimationEnabled)
Enable or disable camera animation when switching to a pre-defined view.
void ResetToDefaults()
Resets all parameters to default values.
GRID3D_TYPE GetGridType() const noexcept
Get the current grid.
SFVEC4F GetColor(COLOR4D aColor) const
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
int m_RtShadowSampleCount
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
PROJECTION_TYPE GetProjection()
Definition: camera.h:160
const std::string JpegFileExtension
static TOOL_ACTION show10mmGrid
Definition: 3d_actions.h:70
static TOOL_ACTION materialCAD
Definition: 3d_actions.h:77
Manage layers needed to make a physical board.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
static TOOL_ACTION showBoundingBoxes
Definition: 3d_actions.h:83
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
void SetAntiAliasingMode(ANTIALIASING_MODE aAAmode)
Set the current antialiasing mode value.
PROJECT & Prj()
Definition: kicad.cpp:403
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
Set the status of a flag.
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
int color
Definition: DXF_plotter.cpp:60
EDA_3D_ACTIONS.
Definition: 3d_actions.h:41
LAYER_3D_ID
3D Viewer virtual layers for color settings
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
std::vector< SFVEC2F > m_RtLightSphericalCoords
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
bool IsReloadRequestPending() const
Query if there is a pending reload request.
Definition: eda_3d_canvas.h:91
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
static TOOL_ACTION showRefractions
Definition: 3d_actions.h:87
int GetColorStandardListCount()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
double g
Green component.
Definition: color4d.h:359
void SynchroniseColoursWithBoard()
A class to handle a custom color (predefined color) for the color picker dialog.
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
wxString JpegFileWildcard()
void SetGridType(GRID3D_TYPE aGridType) noexcept
Set the current grid.
wxAuiManager m_auimgr
Manage TOOL_ACTION objects.
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
void Request_refresh(bool aRedrawImmediately=true)
Schedule a refresh update of the canvas.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
static const int * GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode)
Get a list of attributes to pass to wxGLCanvas.
float m_RtSpreadRefractions
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
SFVEC3F m_RtCameraLightColor
void loadCommonSettings()
Load configuration from common settings.
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
Definition: dpi_scaling.h:36
double b
Blue component.
Definition: color4d.h:360
EDA_3D_CANVAS * m_canvas
void MovingSpeedMultiplierSet(int aMovingSpeedMultiplier)
Set the camera animation moving speed multiplier option.
Use only diffuse material properties.
RENDER_ENGINE GetRenderEngine() const noexcept
Master controller class:
Definition: tool_manager.h:52
void OnActivate(wxActivateEvent &event)
static TOOL_ACTION antiAliasing
Definition: 3d_actions.h:89
BOARD_ADAPTER m_boardAdapter
BOARD_STACKUP & GetStackupDescriptor()
double a
Alpha component.
Definition: color4d.h:361
void OnDisableRayTracing(wxCommandEvent &aEvent)
int m_RtRecursiveReflectionCount
float m_RtSpreadReflections
SFVEC4F m_BgColorTop
background top color
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
static TOOL_ACTION show5mmGrid
Definition: 3d_actions.h:71
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
#define TRANSFER_SETTING(flag, field)
Use all material properties from model file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void RenderEngineChanged()
Notify that the render engine was changed.
bool Set3DSilkScreenColorFromUser()
Set the silkscreen color from a set of colors.
EDA_3D_CONTROLLER.
Definition: 3d_controller.h:39
MATERIAL_MODE GetMaterialMode() const noexcept
SFVEC3F m_RtLightColorTop
CAMERA & m_currentCamera
void SetMaterialMode(MATERIAL_MODE aMaterialMode) noexcept
bool AnimationEnabledGet() const
Return whether camera animation is enabled when switching to a pre-defined view.
Definition of file extensions used in Kicad.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
void OnCloseWindow(wxCloseEvent &event)
SFVEC4F m_BgColorBot
background bottom color
bool Set3DColorFromUser(SFVEC4F &aColor, const wxString &aTitle, CUSTOM_COLORS_LIST *aPredefinedColors, bool aAllowOpacityControl=false, KIGFX::COLOR4D aDefaultColor=KIGFX::COLOR4D(1.0, 1.0, 1.0, 1.0))
Get a SFVEC3D from a color dialog.
static TOOL_ACTION materialNormal
Definition: 3d_actions.h:75
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:36
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:117
int m_RtRecursiveRefractionCount
static TOOL_ACTION addFloor
Definition: 3d_actions.h:86
std::vector< SFVEC3F > m_RtLightColor
static TOOL_ACTION showAxis
Definition: 3d_actions.h:93
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
Handle actions that are shared between different applications.
bool Set3DSolderPasteColorFromUser()
Set the solder mask color from a set of colors.
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
int m_RtRefractionSampleCount
Specialization of the wxAuiPaneInfo class for KiCad panels.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
void SetRenderEngine(RENDER_ENGINE aRenderEngine) noexcept
wxString PngFileWildcard()
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
BOARD * GetBoard()
static TOOL_ACTION materialDiffuse
Definition: 3d_actions.h:76
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
COLOR4D GetColor(int aLayer) const
void GetScreenshot(wxImage &aDstImage)
Request a screenshot and output it to the aDstImage.
int MovingSpeedMultiplierGet() const
Return the current camera animation moving speed multiplier option.
static TOOL_ACTION proceduralTextures
Definition: 3d_actions.h:85
static TOOL_ACTION show2_5mmGrid
Definition: 3d_actions.h:72
static TOOL_ACTION show1mmGrid
Definition: 3d_actions.h:73
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
see class PGM_BASE
Declaration of the eda_3d_viewer class.
Board layer functions and definitions.
wxFileName m_defaultSaveScreenshotFileName
ANTIALIASING_MODE GetAntiAliasingMode() const
Get the current antialiasing mode value.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
#define _(s)
Definition: 3d_actions.cpp:33
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
SFVEC4F m_CopperColor
in realistic mode: copper color
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
The base frame for deriving all KiCad main window classes.
void OnRenderEngineSelection(wxCommandEvent &event)
#define MaterialCheck(x)
#define GridSizeCheck(x)
static TOOL_ACTION postProcessing
Definition: 3d_actions.h:90
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:74
KIGFX::COLOR4D GetColor()
const FAB_LAYER_COLOR * GetColorStandardList()
const std::string PngFileExtension
void SetScaleFactor(double aFactor)
Set the canvas scale factor, probably for a hi-DPI display.
std::vector< KIGFX::COLOR4D > raytrace_lightColor
RENDER_ENGINE
Render engine mode.
Definition: 3d_enums.h:110
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:197
static TOOL_ACTION noGrid
Definition: 3d_actions.h:69
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
SFVEC3F m_OpenGlSelectionColor
void OnSetFocus(wxFocusEvent &event)
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
Color settings are a bit different than most of the settings objects in that there can be more than o...
static TOOL_ACTION showReflections
Definition: 3d_actions.h:88
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:66
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
double r
Red component.
Definition: color4d.h:358
static TOOL_ACTION toggleOrtho
Definition: 3d_actions.h:60
#define FlagCheck(x)
SFVEC3F m_RtLightColorBottom
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
float m_RtSpreadShadows
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
static TOOL_ACTION renderShadows
Definition: 3d_actions.h:84
EVT_TOOL_RANGE(ID_START_COMMAND_3D, ID_MENU_COMMAND_END, EDA_3D_VIEWER::Process_Special_Functions) EDA_3D_VIEWER
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:61
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
Definition: eda_3d_viewer.h:51
int m_RtReflectionSampleCount
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard()
Definition: eda_3d_viewer.h:76
bool m_disable_ray_tracing
bool Set3DBoardBodyColorFromUser()
Set the copper color from a set of colors.
void ReloadRequest()
Request reloading the 3D view.
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
void SetColor(int aLayer, COLOR4D aColor)
void Process_Special_Functions(wxCommandEvent &event)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.