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-2020 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 
63 const wxChar* EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
64 
65 
66 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
67 
68  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
69  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
70 
72  EDA_3D_VIEWER::Process_Special_Functions )
73 
74  EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_VIEWER::Install3DViewOptionDialog )
75 
76  EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER::Exit3DFrame )
77  EVT_MENU( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER::OnRenderEngineSelection )
78  EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER::OnDisableRayTracing )
79 
80  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
81 END_EVENT_TABLE()
82 
83 
84 EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle,
85  long style ) :
86  KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
87  wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ),
88  m_mainToolBar( nullptr ),
89  m_canvas( nullptr ),
90  m_currentCamera( m_trackBallCamera ),
91  m_trackBallCamera( RANGE_SCALE_3D )
92 {
93  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle );
94 
95  m_disable_ray_tracing = false;
96  m_aboutTitle = _( "KiCad 3D Viewer" );
97 
98  // Give it an icon
99  wxIcon icon;
100  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
101  SetIcon( icon );
102 
103  // Create the status line
104  static const int status_dims[4] = { -1, 170, 130, 130 };
105 
106  wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
107  SetStatusWidths( arrayDim( status_dims ), status_dims );
108 
109  m_canvas = new EDA_3D_CANVAS( this,
110  OGL_ATT_LIST::GetAttributesList( m_boardAdapter.GetAntiAliasingMode() ),
111  aParent->GetBoard(), m_boardAdapter, m_currentCamera,
112  Prj().Get3DCacheManager() );
113 
114  auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
115  LoadSettings( config );
116 
117  // Some settings need the canvas
118  loadCommonSettings();
119 
120  // Create the manager
121  m_toolManager = new TOOL_MANAGER;
122  m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
123 
124  m_actions = new EDA_3D_ACTIONS();
125  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
126  m_canvas->SetEventDispatcher( m_toolDispatcher );
127 
128  // Register tools
129  m_toolManager->RegisterTool( new COMMON_CONTROL );
130  m_toolManager->RegisterTool( new EDA_3D_CONTROLLER );
131  m_toolManager->InitTools();
132 
133  setupUIConditions();
134 
135  if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
136  ctrlTool->SetRotationIncrement( config->m_Camera.rotation_increment );
137 
138  // Run the viewer control tool, it is supposed to be always active
139  m_toolManager->InvokeTool( "3DViewer.Control" );
140 
141  CreateMenuBar();
142  ReCreateMainToolbar();
143 
144  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
145 
146  m_auimgr.SetManagedWindow( this );
147 
148  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
149  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
150  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
151 
152  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
153  // hidding it.
154  m_auimgr.Update();
155 
156  // We don't want the infobar displayed right away
157  m_auimgr.GetPane( "InfoBar" ).Hide();
158  m_auimgr.Update();
159 
160  m_canvas->SetInfoBar( m_infoBar );
161  m_canvas->SetStatusBar( status_bar );
162 
163  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
164  // in order to receive mouse events. Otherwise, the user has to click somewhere on
165  // the canvas before it will respond to mouse wheel events.
166  m_canvas->SetFocus();
167 }
168 
169 
171 {
172  m_canvas->SetEventDispatcher( nullptr );
173 
174  m_auimgr.UnInit();
175 
176  // m_canvas delete will be called by wxWidget manager
177  //delete m_canvas;
178  //m_canvas = nullptr;
179 }
180 
181 
183 {
185 
188 
189 // Helper to define check conditions
190 #define MaterialCheck( x ) ACTION_CONDITIONS().Check( cond.MaterialMode( x ) )
191 #define FlagCheck( x ) ACTION_CONDITIONS().Check( cond.Flag( x ) )
192 #define GridSizeCheck( x ) ACTION_CONDITIONS().Check( cond.GridSize( x ) )
193 
194  auto raytracingCondition = [this]( const SELECTION& aSel )
195  {
197  };
198 
200  ACTION_CONDITIONS().Check( raytracingCondition ) );
201 
208 
226  FlagCheck( FL_AXIS ) );
227 
233 
234 
235  auto orthoCondition =
236  [this] ( const SELECTION& )
237  {
239  };
240 
241  mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( orthoCondition ) );
242 
243 #undef MaterialCheck
244 #undef FlagCheck
245 #undef GridSizeCheck
246 }
247 
248 
250 {
251  // This will schedule a request to load later
252  if( m_canvas )
253  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
254 }
255 
256 
257 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
258 {
259  ReloadRequest();
260 
261  // After the ReloadRequest call, the refresh often takes a bit of time,
262  // and it is made here only on request.
263  if( aForceImmediateRedraw )
264  m_canvas->Refresh();
265 }
266 
267 
269 {
270  // Only update in OpenGL for an interactive interaction
272  m_canvas->Request_refresh( true );
273 }
274 
275 
277 {
280  else
281  NewDisplay( true );
282 }
283 
284 
285 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
286 {
287  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
288 
289  Close( true );
290 }
291 
292 
293 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
294 {
295  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnCloseWindow" );
296 
297  if( m_canvas )
298  m_canvas->Close();
299 
300  // m_canvas delete will be called by wxWidget manager
301  //delete m_canvas;
302  //m_canvas = nullptr;
303 
304  Destroy();
305  event.Skip( true );
306 }
307 
308 
309 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
310 {
311  int id = event.GetId();
312  bool isChecked = event.IsChecked();
313 
314  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
315  id, isChecked );
316 
317  if( m_canvas == nullptr )
318  return;
319 
320  switch( id )
321  {
322  case ID_RELOAD3D_BOARD:
323  NewDisplay( true );
324  break;
325 
329  takeScreenshot( event );
330  return;
331 
333  if( Set3DColorFromUser( m_boardAdapter.m_BgColorBot, _( "Background Color, Bottom" ),
334  nullptr ) )
335  refreshRender();
336  return;
337 
339  if( Set3DColorFromUser( m_boardAdapter.m_BgColorTop, _( "Background Color, Top" ),
340  nullptr ) )
341  refreshRender();
342  return;
343 
346  return;
347 
350  return;
351 
354  return;
355 
358  break;
359 
362  break;
363 
366  refreshRender();
367  break;
368 
370  {
371  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
372  cfg->ResetToDefaults();
373  LoadSettings( cfg );
374 
375  // Tell canvas that we (may have) changed the render engine
377 
378  NewDisplay( true );
379  }
380  return;
381 
382  default:
383  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
384  return;
385  }
386 }
387 
388 
389 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
390 {
391  const RENDER_ENGINE old_engine = m_boardAdapter.GetRenderEngine();
392 
393  if( old_engine == RENDER_ENGINE::OPENGL_LEGACY )
395  else
397 
398  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
400  "OpenGL Legacy" );
401 
402  if( old_engine != m_boardAdapter.GetRenderEngine() )
404 }
405 
406 
407 void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
408 {
409  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
410 
411  m_disable_ray_tracing = true;
413 }
414 
415 
416 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &aEvent )
417 {
418  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
419 
420  if( aEvent.GetActive() && m_canvas )
421  {
422  // Reload data if 3D frame shows a board,
423  // because it can be changed since last frame activation
426 
427  // Activates again the focus of the canvas so it will catch mouse and key events
428  m_canvas->SetFocus();
429  }
430 
431  aEvent.Skip(); // required under wxMAC
432 }
433 
434 
435 void EDA_3D_VIEWER::OnSetFocus( wxFocusEvent& aEvent )
436 {
437  // Activates again the focus of the canvas so it will catch mouse and key events
438  if( m_canvas )
439  m_canvas->SetFocus();
440 
441  aEvent.Skip();
442 }
443 
444 
446 {
448 
449  EDA_3D_VIEWER_SETTINGS* cfg = dynamic_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
450  wxASSERT( cfg );
451 
452  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
453 
454  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
455 
456  auto set_color =
457  [] ( const COLOR4D& aColor, SFVEC4F& aTarget )
458  {
459  aTarget.r = aColor.r;
460  aTarget.g = aColor.g;
461  aTarget.b = aColor.b;
462  aTarget.a = aColor.a;
463  };
464 
466  set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_boardAdapter.m_BgColorTop );
467  set_color( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor );
468  set_color( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor );
469  set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ),
475 
476  if( cfg )
477  {
484 
487 
488  for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
489  {
492 
493  SFVEC2F sphericalCoord =
494  SFVEC2F( ( cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
495  cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
496 
497  sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
498  sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
499 
500  m_boardAdapter.m_RtLightSphericalCoords[i] = sphericalCoord;
501  }
502 
503 #define TRANSFER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
504 
506  TRANSFER_SETTING( FL_SUBTRACT_MASK_FROM_SILK, subtract_mask_from_silk );
507 
508  // OpenGL options
509  TRANSFER_SETTING( FL_RENDER_OPENGL_COPPER_THICKNESS, opengl_copper_thickness );
510  TRANSFER_SETTING( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, opengl_show_model_bbox );
511  TRANSFER_SETTING( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, opengl_AA_disableOnMove );
513  opengl_thickness_disableOnMove );
514  TRANSFER_SETTING( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, opengl_vias_disableOnMove );
515  TRANSFER_SETTING( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, opengl_holes_disableOnMove );
516 
517  // Raytracing options
518  TRANSFER_SETTING( FL_RENDER_RAYTRACING_SHADOWS, raytrace_shadows );
519  TRANSFER_SETTING( FL_RENDER_RAYTRACING_BACKFLOOR, raytrace_backfloor );
520  TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFRACTIONS, raytrace_refractions );
521  TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFLECTIONS, raytrace_reflections );
522  TRANSFER_SETTING( FL_RENDER_RAYTRACING_POST_PROCESSING, raytrace_post_processing );
523  TRANSFER_SETTING( FL_RENDER_RAYTRACING_ANTI_ALIASING, raytrace_anti_aliasing );
524  TRANSFER_SETTING( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, raytrace_procedural_textures );
525 
526  TRANSFER_SETTING( FL_AXIS, show_axis );
527  TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL, show_footprints_normal );
528  TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL_INSERT, show_footprints_insert );
529  TRANSFER_SETTING( FL_FP_ATTRIBUTES_VIRTUAL, show_footprints_virtual );
530  TRANSFER_SETTING( FL_ZONE, show_zones );
531  TRANSFER_SETTING( FL_ADHESIVE, show_adhesive );
532  TRANSFER_SETTING( FL_SILKSCREEN, show_silkscreen );
533  TRANSFER_SETTING( FL_SOLDERMASK, show_soldermask );
534  TRANSFER_SETTING( FL_SOLDERPASTE, show_solderpaste );
535  TRANSFER_SETTING( FL_COMMENTS, show_comments );
536  TRANSFER_SETTING( FL_ECO, show_eco );
537  TRANSFER_SETTING( FL_SHOW_BOARD_BODY, show_board_body );
538  TRANSFER_SETTING( FL_CLIP_SILK_ON_VIA_ANNULUS, clip_silk_on_via_annulus );
539  TRANSFER_SETTING( FL_RENDER_PLATED_PADS_AS_PLATED, renderPlatedPadsAsPlated );
540 
541  m_boardAdapter.SetGridType( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
543  static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
544 
547 
551 
555 
560 
561  // When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
562  // because the ray tracing is very time consumming, and can be seen as not working
563  // (freeze window) with large boards.
564 #if 0
565  RENDER_ENGINE engine = static_cast<RENDER_ENGINE>( cfg->m_Render.engine );
566  wxLogTrace( m_logTrace, engine == RENDER_ENGINE::RAYTRACING ?
567  "EDA_3D_VIEWER::LoadSettings render setting Ray Trace" :
568  "EDA_3D_VIEWER::LoadSettings render setting OpenGL" );
569 #else
571 #endif
572 
573  m_boardAdapter.SetMaterialMode( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
574 
577 
578 #undef TRANSFER_SETTING
579  }
580 }
581 
582 
584 {
585  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
586 
588 
589  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
590 
591  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
592 
593  auto save_color =
594  [colors] ( SFVEC4F& aSource, LAYER_3D_ID aTarget )
595  {
596  // You could think just copy the new color in config is enough.
597  // unfortunately, SFVEC4F uses floats, and COLOR4D uses doubles,
598  // and the conversion SFVEC4F from/to COLOR4D creates small diffs.
599  //
600  // This has no matter to draw colors, but creates slight differences
601  // in config file, that appears always modified.
602  // So we must compare the SFVEC4F old and new values and update only
603  // actual changes.
604  SFVEC4F newSFVEC4Fcolor( float( colors->GetColor( aTarget ).r ),
605  float( colors->GetColor( aTarget ).g ),
606  float( colors->GetColor( aTarget ).b ),
607  float( colors->GetColor( aTarget ).a ) );
608 
609  if( aSource != newSFVEC4Fcolor )
610  colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b,
611  aSource.a ) );
612  };
613 
622 
623  Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
624 
626  "EDA_3D_VIEWER::SaveSettings render setting Ray Trace" :
627  "EDA_3D_VIEWER::SaveSettings render setting OpenGL" );
628 
629  if( cfg )
630  {
631 
632  auto save_color =
633  [] ( const SFVEC3F& aSource, COLOR4D& aTarget )
634  {
635  aTarget = COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 );
636  };
637 
638  save_color( m_boardAdapter.m_RtCameraLightColor, cfg->m_Render.raytrace_lightColorCamera );
639  save_color( m_boardAdapter.m_RtLightColorTop, cfg->m_Render.raytrace_lightColorTop );
640  save_color( m_boardAdapter.m_RtLightColorBottom, cfg->m_Render.raytrace_lightColorBottom );
641 
642  for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
643  {
644  save_color( m_boardAdapter.m_RtLightColor[i], cfg->m_Render.raytrace_lightColor[i] );
645 
646  cfg->m_Render.raytrace_lightElevation[i] =
647  (int)( m_boardAdapter.m_RtLightSphericalCoords[i].x * 180.0f - 90.0f );
648  cfg->m_Render.raytrace_lightAzimuth[i] =
649  (int)( m_boardAdapter.m_RtLightSphericalCoords[i].y * 180.0f );
650  }
651 
652  cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_RtShadowSampleCount;
653  cfg->m_Render.raytrace_nrsamples_reflections = m_boardAdapter.m_RtReflectionSampleCount;
654  cfg->m_Render.raytrace_nrsamples_refractions = m_boardAdapter.m_RtRefractionSampleCount;
655 
656  cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_RtSpreadShadows;
657  cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_RtSpreadReflections;
658  cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_RtSpreadRefractions;
659 
660  cfg->m_Render.raytrace_recursivelevel_refractions =
662  cfg->m_Render.raytrace_recursivelevel_reflections =
664 
665 #define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
666 
667  cfg->m_Render.engine = static_cast<int>( m_boardAdapter.GetRenderEngine() );
668  cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GetGridType() );
669  cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.GetMaterialMode() );
670  cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.GetAntiAliasingMode() );
671 
672  save_color( m_boardAdapter.m_OpenGlSelectionColor, cfg->m_Render.opengl_selection_color );
673 
674  cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
675  cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();
676 
677  if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
678  cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();
679 
680  TRANSFER_SETTING( opengl_AA_disableOnMove, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE );
681  TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS );
682  TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
683  TRANSFER_SETTING( opengl_thickness_disableOnMove,
685  TRANSFER_SETTING( opengl_vias_disableOnMove, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
686  TRANSFER_SETTING( opengl_holes_disableOnMove, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );
687 
688  TRANSFER_SETTING( raytrace_anti_aliasing, FL_RENDER_RAYTRACING_ANTI_ALIASING );
689  TRANSFER_SETTING( raytrace_backfloor, FL_RENDER_RAYTRACING_BACKFLOOR );
690  TRANSFER_SETTING( raytrace_post_processing, FL_RENDER_RAYTRACING_POST_PROCESSING );
691  TRANSFER_SETTING( raytrace_procedural_textures, FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
692  TRANSFER_SETTING( raytrace_reflections, FL_RENDER_RAYTRACING_REFLECTIONS );
693  TRANSFER_SETTING( raytrace_refractions, FL_RENDER_RAYTRACING_REFRACTIONS );
694  TRANSFER_SETTING( raytrace_shadows, FL_RENDER_RAYTRACING_SHADOWS );
695 
697  TRANSFER_SETTING( show_adhesive, FL_ADHESIVE );
698  TRANSFER_SETTING( show_axis, FL_AXIS );
699  TRANSFER_SETTING( show_board_body, FL_SHOW_BOARD_BODY );
700  TRANSFER_SETTING( clip_silk_on_via_annulus, FL_CLIP_SILK_ON_VIA_ANNULUS );
701  TRANSFER_SETTING( renderPlatedPadsAsPlated, FL_RENDER_PLATED_PADS_AS_PLATED );
702  TRANSFER_SETTING( show_comments, FL_COMMENTS );
703  TRANSFER_SETTING( show_eco, FL_ECO );
704  TRANSFER_SETTING( show_footprints_insert, FL_FP_ATTRIBUTES_NORMAL_INSERT );
705  TRANSFER_SETTING( show_footprints_normal, FL_FP_ATTRIBUTES_NORMAL );
706  TRANSFER_SETTING( show_footprints_virtual, FL_FP_ATTRIBUTES_VIRTUAL );
707  TRANSFER_SETTING( show_silkscreen, FL_SILKSCREEN );
708  TRANSFER_SETTING( show_soldermask, FL_SOLDERMASK );
709  TRANSFER_SETTING( show_solderpaste, FL_SOLDERPASTE );
710  TRANSFER_SETTING( show_zones, FL_ZONE );
711  TRANSFER_SETTING( subtract_mask_from_silk, FL_SUBTRACT_MASK_FROM_SILK );
712 
713 #undef TRANSFER_SETTING
714  }
715 }
716 
717 
719 {
720  BOARD* brd = GetBoard();
721  const FAB_LAYER_COLOR* stdColors = GetColorStandardList();
722  wxColour color;
723 
724  if( brd )
725  {
726  const BOARD_STACKUP& stckp = brd->GetDesignSettings().GetStackupDescriptor();
727 
728  for( const BOARD_STACKUP_ITEM* stckpItem : stckp.GetList() )
729  {
730  wxString colorName = stckpItem->GetColor();
731 
732  if( colorName.StartsWith( "#" ) ) // This is a user defined color.
733  {
734  color.Set( colorName );
735  }
736  else
737  {
738  for( int i = 0; i < GetColorStandardListCount(); i++ )
739  {
740  if( stdColors[i].m_ColorName == colorName )
741  {
742  color = stdColors[i].m_Color;
743  break;
744  }
745  }
746  }
747 
748  if( color.IsOk() )
749  {
750  switch( stckpItem->GetBrdLayerId() )
751  {
752  case F_SilkS:
753  m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0;
754  m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0;
755  m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0;
756  break;
757  case B_SilkS:
758  m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0;
759  m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0;
760  m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0;
761  break;
762  case F_Mask:
763  m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0;
764  m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0;
765  m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0;
766  // Keep the previous alpha value
767  //m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0;
768  break;
769  case B_Mask:
770  m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0;
771  m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0;
772  m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0;
773  // Keep the previous alpha value
774  //m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0;
775  break;
776  default:
777  break;
778  }
779  }
780  }
781  }
782 }
783 
784 
785 void EDA_3D_VIEWER::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
786 {
787  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
788 
789  // Regen menu bars, etc
790  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
791 
792  // There is no base class that handles toolbars for this frame
794 
796 
797  NewDisplay( true );
798 }
799 
800 
801 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
802 {
803  wxString fullFileName;
804  bool fmt_is_jpeg = false;
805 
806  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
807  fmt_is_jpeg = true;
808 
809  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
810  {
811  // Remember path between saves during this session only.
812  const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
813  const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
814 
815  // First time path is set to the project path.
816  if( !m_defaultSaveScreenshotFileName.IsOk() )
818 
819  m_defaultSaveScreenshotFileName.SetExt( ext );
820 
821  wxFileDialog dlg( this, _( "3D Image File Name" ),
823  m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
824  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
825 
826  if( dlg.ShowModal() == wxID_CANCEL )
827  return;
828 
829  m_defaultSaveScreenshotFileName = dlg.GetPath();
830 
831  if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
832  m_defaultSaveScreenshotFileName.SetExt( ext );
833 
834  fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
835 
836  wxFileName fn = fullFileName;
837 
838  if( !fn.IsDirWritable() )
839  {
840  wxString msg;
841 
842  msg.Printf( _( "Insufficient permissions required to save file\n%s" ), fullFileName );
843  wxMessageBox( msg, _( "Error" ), wxOK | wxICON_ERROR, this );
844  return;
845  }
846 
847  // Be sure the screen area destroyed by the file dialog is redrawn
848  // before making a screen copy.
849  // Without this call, under Linux the screen refresh is made to late.
850  wxYield();
851  }
852 
853  // Be sure we have the latest 3D view (remember 3D view is buffered)
854  m_canvas->Request_refresh( true );
855  wxYield();
856 
857  // Build image from the 3D buffer
858  wxWindowUpdateLocker noUpdates( this );
859 
860  wxImage screenshotImage;
861 
862  if( m_canvas )
863  m_canvas->GetScreenshot( screenshotImage );
864 
865  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
866  {
867  wxBitmap bitmap( screenshotImage );
868 
869  wxLogNull doNotLog; // disable logging of failed clipboard actions
870 
871  if( wxTheClipboard->Open() )
872  {
873  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
874 
875  if( !wxTheClipboard->SetData( dobjBmp ) )
876  wxMessageBox( _( "Failed to copy image to clipboard" ) );
877 
878  wxTheClipboard->Flush(); /* the data in clipboard will stay
879  * available after the application exits */
880  wxTheClipboard->Close();
881  }
882  }
883  else
884  {
885  if( !screenshotImage.SaveFile( fullFileName,
886  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
887  wxMessageBox( _( "Can't save file" ) );
888 
889  screenshotImage.Destroy();
890  }
891 
892 }
893 
894 
896 {
897  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
898 
899  if( m_canvas )
901 }
902 
903 
904 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC4F &aColor, const wxString& aTitle,
905  CUSTOM_COLORS_LIST* aPredefinedColors,
906  bool aAllowOpacityControl,
907  KIGFX::COLOR4D aDefaultColor )
908 {
909  KIGFX::COLOR4D newcolor;
910  KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, aColor.a );
911 
912  DIALOG_COLOR_PICKER picker( this, oldcolor, aAllowOpacityControl, aPredefinedColors,
913  aDefaultColor );
914 
915  if( picker.ShowModal() != wxID_OK )
916  return false;
917 
918  newcolor = picker.GetColor();
919 
920  if( newcolor == oldcolor )
921  return false;
922 
923  aColor.r = newcolor.r;
924  aColor.g = newcolor.g;
925  aColor.b = newcolor.b;
926  aColor.a = newcolor.a;
927 
928  return true;
929 }
930 
931 
933 {
935 
936  colors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
937  colors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
938 
939  if( Set3DColorFromUser( m_boardAdapter.m_SilkScreenColorTop, _( "Silkscreen Color" ),
940  &colors, false, colors[0].m_Color ) )
941  {
943 
944  refreshRender();
945 
946  return true;
947  }
948 
949  return false;
950 }
951 
952 
954 {
956 
957  colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, 0.83, "Green" ) );
958  colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, 0.83, "Light Green" ) );
959  colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, 0.83,
960  "Saturated Green" ) );
961  colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, 0.83, "Red" ) );
962  colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, 0.83,
963  "Red Light Orange" ) );
964  colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, 0.83, "Red 2" ) );
965  colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, 0.83, "Blue" ) );
966  colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, 0.83, "Light blue 1" ) );
967  colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, 0.83, "Light blue 2" ) );
968  colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, 0.83,
969  "Green blue (dark)" ) );
970  colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, 0.83, "Black" ) );
971  colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, 0.83, "White" ) );
972  colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, 0.83, "Purple" ) );
973  colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, 0.83, "Purple Dark" ) );
974 
975  if( Set3DColorFromUser( m_boardAdapter.m_SolderMaskColorTop, _( "Solder Mask Color" ),
976  &colors, true, colors[0].m_Color ) )
977  {
979 
980  refreshRender();
981 
982  return true;
983  }
984 
985  return false;
986 }
987 
988 
990 {
992 
993  colors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
994  colors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
995  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
996  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
997 
998  if( Set3DColorFromUser( m_boardAdapter.m_CopperColor, _( "Copper Color" ), &colors, false,
999  colors[0].m_Color ) )
1000  {
1001  refreshRender();
1002 
1003  return true;
1004  }
1005 
1006  return false;
1007 }
1008 
1009 
1011 {
1013 
1014  colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, 0.9,
1015  "FR4 natural, dark" ) );
1016  colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, 0.9, "FR4 natural" ) );
1017  colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, 0.9, "brown/red" ) );
1018  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 1" ) );
1019  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, 0.9, "brown 2" ) );
1020  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 3" ) );
1021  colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, 0.9, "green 1" ) );
1022  colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, 0.9, "green 2" ) );
1023 
1024  if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors,
1025  true, colors[0].m_Color ) )
1026  {
1027  refreshRender();
1028 
1029  return true;
1030  }
1031 
1032  return false;
1033 }
1034 
1035 
1037 {
1039 
1040  colors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
1041  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1042  colors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
1043 
1044  if( Set3DColorFromUser( m_boardAdapter.m_SolderPasteColor, _( "Solder Paste Color" ), &colors,
1045  false, colors[0].m_Color ) )
1046  {
1047  refreshRender();
1048 
1049  return true;
1050  }
1051 
1052  return false;
1053 }
1054 
1055 
1057 {
1058  wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
1059 
1060  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
1061 
1062  const DPI_SCALING dpi{ settings, this };
1063  m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
1064  // TODO(JE) use all control options
1066 }
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
this class manage the layers needed to make a physical board they are solder mask,...
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:386
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:591
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
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
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)
const BITMAP_OPAQUE icon_3d_xpm[1]
Definition: icon_3d.cpp:36
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:38
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
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
Handle actions that are shared between different applications.
bool Set3DSolderPasteColorFromUser()
Set the solder mask color from a set of colors.
this class manage one layer needed to make a physical board it can be a solder mask,...
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:71
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
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
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:197
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:109
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
static VRML_COLOR colors[VRML_COLOR_LAST]
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 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.