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>
34 #include "../common_ogl/cogl_att_list.h"
38 #include <bitmaps.h>
41 #include <board.h>
42 #include <core/arraydim.h>
44 #include <gal/dpi_scaling.h>
45 #include <pgm_base.h>
46 #include <project.h>
49 #include <tool/action_manager.h>
50 #include <tool/common_control.h>
51 #include <tool/tool_manager.h>
52 #include <tool/tool_dispatcher.h>
53 #include <tool/action_toolbar.h>
54 #include <widgets/infobar.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 = "3D Viewer";
98 
99  // Give it an icon
100  wxIcon icon;
101  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
102  SetIcon( icon );
103 
104  // Create the status line
105  static const int status_dims[4] = { -1, 130, 130, 170 };
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, COGL_ATT_LIST::GetAttributesList( m_boardAdapter.AntiAliasingGet() ),
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  // Create the infobar
145  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
146 
147  m_auimgr.SetManagedWindow( this );
148 
149  m_auimgr.AddPane( m_mainToolBar,
150  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
151  m_auimgr.AddPane( m_infoBar,
152  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
153  m_auimgr.AddPane( m_canvas,
154  EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
155 
156  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
157  // hidding it.
158  m_auimgr.Update();
159 
160  // We don't want the infobar displayed right away
161  m_auimgr.GetPane( "InfoBar" ).Hide();
162  m_auimgr.Update();
163 
164  if( m_canvas )
165  {
166  m_canvas->SetInfoBar( m_infoBar );
167  m_canvas->SetStatusBar( status_bar );
168  }
169 
170  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
171  // in order to receive mouse events. Otherwise, the user has to click somewhere on
172  // the canvas before it will respond to mouse wheel events.
173  if( m_canvas )
174  m_canvas->SetFocus();
175 }
176 
177 
179 {
180  m_canvas->SetEventDispatcher( nullptr );
181 
182  m_auimgr.UnInit();
183 
184  // m_canvas delete will be called by wxWidget manager
185  //delete m_canvas;
186  //m_canvas = nullptr;
187 }
188 
189 
191 {
193 
196 
197 // Helper to define check conditions
198 #define MaterialCheck( x ) ACTION_CONDITIONS().Check( cond.MaterialMode( x ) )
199 #define FlagCheck( x ) ACTION_CONDITIONS().Check( cond.Flag( x ) )
200 #define GridSizeCheck( x ) ACTION_CONDITIONS().Check( cond.GridSize( x ) )
201 
202  auto raytracingCondition = [this]( const SELECTION& aSel )
203  {
205  };
206 
208  ACTION_CONDITIONS().Check( raytracingCondition ) );
209 
216 
234  FlagCheck( FL_AXIS ) );
235 
241 
242 
243  auto orthoCondition =
244  [this] ( const SELECTION& )
245  {
247  };
248 
249  mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( orthoCondition ) );
250 
251 #undef MaterialCheck
252 #undef FlagCheck
253 #undef GridSizeCheck
254 }
255 
256 
258 {
259  // This will schedule a request to load later
260  if( m_canvas )
261  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
262 }
263 
264 
265 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
266 {
267  ReloadRequest();
268 
269  // After the ReloadRequest call, the refresh often takes a bit of time,
270  // and it is made here only on request.
271  if( aForceImmediateRedraw )
272  m_canvas->Refresh();
273 }
274 
276 {
277  // Only update in OpenGL for an interactive interaction
279  m_canvas->Request_refresh( true );
280 }
281 
283 {
286  else
287  NewDisplay( true );
288 }
289 
290 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
291 {
292  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
293 
294  Close( true );
295 }
296 
297 
298 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
299 {
300  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnCloseWindow" );
301 
302  if( m_canvas )
303  m_canvas->Close();
304 
305  // m_canvas delete will be called by wxWidget manager
306  //delete m_canvas;
307  //m_canvas = nullptr;
308 
309  Destroy();
310  event.Skip( true );
311 }
312 
313 
314 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
315 {
316  int id = event.GetId();
317  bool isChecked = event.IsChecked();
318 
319  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
320  id, isChecked );
321 
322  if( m_canvas == NULL )
323  return;
324 
325  switch( id )
326  {
327  case ID_RELOAD3D_BOARD:
328  NewDisplay( true );
329  break;
330 
334  takeScreenshot( event );
335  return;
336 
338  if( Set3DColorFromUser( m_boardAdapter.m_BgColorBot, _( "Background Color, Bottom" ),
339  nullptr ) )
340  refreshRender();
341  return;
342 
344  if( Set3DColorFromUser( m_boardAdapter.m_BgColorTop, _( "Background Color, Top" ), nullptr ) )
345  refreshRender();
346  return;
347 
350  return;
351 
354  return;
355 
358  return;
359 
362  break;
363 
366  break;
367 
370  refreshRender();
371  break;
372 
374  {
375  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
376  cfg->ResetToDefaults();
377  LoadSettings( cfg );
378 
379  // Tell canvas that we (may have) changed the render engine
381 
382  NewDisplay( true );
383  }
384  return;
385 
386  default:
387  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
388  return;
389  }
390 }
391 
392 
393 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
394 {
395  const RENDER_ENGINE old_engine = m_boardAdapter.RenderEngineGet();
396 
397  if( old_engine == RENDER_ENGINE::OPENGL_LEGACY )
399  else
401 
402  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
404  "OpenGL Legacy" );
405 
406  if( old_engine != m_boardAdapter.RenderEngineGet() )
408 }
409 
410 
411 void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
412 {
413  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
414 
415  m_disable_ray_tracing = true;
417 }
418 
419 
420 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &aEvent )
421 {
422  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
423 
424  if( aEvent.GetActive() && m_canvas )
425  {
426  // Reload data if 3D frame shows a board,
427  // because it can be changed since last frame activation
430 
431  // Activates again the focus of the canvas so it will catch mouse and key events
432  m_canvas->SetFocus();
433  }
434 
435  aEvent.Skip(); // required under wxMAC
436 }
437 
438 
439 void EDA_3D_VIEWER::OnSetFocus( wxFocusEvent& aEvent )
440 {
441  // Activates again the focus of the canvas so it will catch mouse and key events
442  if( m_canvas )
443  m_canvas->SetFocus();
444 
445  aEvent.Skip();
446 }
447 
448 
450 {
452 
453  EDA_3D_VIEWER_SETTINGS* cfg = dynamic_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
454  wxASSERT( cfg );
455 
456  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
457 
458  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
459 
460  auto set_color =
461  [] ( const COLOR4D& aColor, SFVEC4F& aTarget )
462  {
463  aTarget.r = aColor.r;
464  aTarget.g = aColor.g;
465  aTarget.b = aColor.b;
466  aTarget.a = aColor.a;
467  };
468 
470  set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_boardAdapter.m_BgColorTop );
471  set_color( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor );
472  set_color( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor );
478 
479  if( cfg )
480  {
484 
487 
488  for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
489  {
491 
492  SFVEC2F sphericalCoord = SFVEC2F( ( cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
493  cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
494 
495  sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
496  sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
497 
499  }
500 
501 #define TRANSFER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
502 
504  TRANSFER_SETTING( FL_SUBTRACT_MASK_FROM_SILK, subtract_mask_from_silk );
505 
506  // OpenGL options
507  TRANSFER_SETTING( FL_RENDER_OPENGL_COPPER_THICKNESS, opengl_copper_thickness );
508  TRANSFER_SETTING( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, opengl_show_model_bbox );
509  TRANSFER_SETTING( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, opengl_AA_disableOnMove );
510  TRANSFER_SETTING( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, opengl_thickness_disableOnMove );
511  TRANSFER_SETTING( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, opengl_vias_disableOnMove );
512  TRANSFER_SETTING( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, opengl_holes_disableOnMove );
513 
514  // Raytracing options
515  TRANSFER_SETTING( FL_RENDER_RAYTRACING_SHADOWS, raytrace_shadows );
516  TRANSFER_SETTING( FL_RENDER_RAYTRACING_BACKFLOOR, raytrace_backfloor );
517  TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFRACTIONS, raytrace_refractions );
518  TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFLECTIONS, raytrace_reflections );
519  TRANSFER_SETTING( FL_RENDER_RAYTRACING_POST_PROCESSING, raytrace_post_processing );
520  TRANSFER_SETTING( FL_RENDER_RAYTRACING_ANTI_ALIASING, raytrace_anti_aliasing );
521  TRANSFER_SETTING( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, raytrace_procedural_textures );
522 
523  TRANSFER_SETTING( FL_AXIS, show_axis );
524  TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL, show_footprints_normal );
525  TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL_INSERT, show_footprints_insert );
526  TRANSFER_SETTING( FL_FP_ATTRIBUTES_VIRTUAL, show_footprints_virtual );
527  TRANSFER_SETTING( FL_ZONE, show_zones );
528  TRANSFER_SETTING( FL_ADHESIVE, show_adhesive );
529  TRANSFER_SETTING( FL_SILKSCREEN, show_silkscreen );
530  TRANSFER_SETTING( FL_SOLDERMASK, show_soldermask );
531  TRANSFER_SETTING( FL_SOLDERPASTE, show_solderpaste );
532  TRANSFER_SETTING( FL_COMMENTS, show_comments );
533  TRANSFER_SETTING( FL_ECO, show_eco );
534  TRANSFER_SETTING( FL_SHOW_BOARD_BODY, show_board_body );
535  TRANSFER_SETTING( FL_CLIP_SILK_ON_VIA_ANNULUS, clip_silk_on_via_annulus );
536  TRANSFER_SETTING( FL_RENDER_PLATED_PADS_AS_PLATED, renderPlatedPadsAsPlated );
537 
538  m_boardAdapter.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
539  m_boardAdapter.AntiAliasingSet( static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
540 
542 
546 
550 
553 
554  // When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
555  // because the ray tracing is very time consumming, and can be seen as not working
556  // (freeze window) with large boards.
557 #if 0
558  RENDER_ENGINE engine = static_cast<RENDER_ENGINE>( cfg->m_Render.engine );
559  wxLogTrace( m_logTrace, engine == RENDER_ENGINE::RAYTRACING ?
560  "EDA_3D_VIEWER::LoadSettings render setting Ray Trace" :
561  "EDA_3D_VIEWER::LoadSettings render setting OpenGL" );
562 #else
564 #endif
565 
566  m_boardAdapter.MaterialModeSet( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
567 
570 
571 #undef TRANSFER_SETTING
572  }
573 }
574 
575 
577 {
578  auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
579 
581 
582  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
583 
584  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
585 
586  auto save_color =
587  [colors] ( SFVEC4F& aSource, LAYER_3D_ID aTarget )
588  {
589  // You could think just copy the new color in config is enough.
590  // unfortunately, SFVEC4F uses floats, and COLOR4D uses doubles,
591  // and the conversion SFVEC4F from/to COLOR4D creates small diffs.
592  //
593  // This has no matter to draw colors, but creates slight differences
594  // in config file, that appears always modified.
595  // So we must compare the SFVEC4F old and new values and update only
596  // actual changes.
597  SFVEC4F newSFVEC4Fcolor( float(colors->GetColor( aTarget ).r),
598  float(colors->GetColor( aTarget ).g),
599  float(colors->GetColor( aTarget ).b),
600  float(colors->GetColor( aTarget ).a) );
601 
602  if( aSource != newSFVEC4Fcolor )
603  colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b, aSource.a ) );
604  };
605 
614 
615  Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
616 
618  "EDA_3D_VIEWER::SaveSettings render setting Ray Trace" :
619  "EDA_3D_VIEWER::SaveSettings render setting OpenGL" );
620 
621  if( cfg )
622  {
623 
624  auto save_color =
625  [] ( const SFVEC3F& aSource, COLOR4D& aTarget )
626  {
627  aTarget = COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 );
628  };
629 
630  save_color( m_boardAdapter.m_raytrace_lightColorCamera, cfg->m_Render.raytrace_lightColorCamera );
631 
632  save_color( m_boardAdapter.m_raytrace_lightColorTop, cfg->m_Render.raytrace_lightColorTop );
633  save_color( m_boardAdapter.m_raytrace_lightColorBottom, cfg->m_Render.raytrace_lightColorBottom );
634 
635  for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
636  {
637  save_color( m_boardAdapter.m_raytrace_lightColor[i], cfg->m_Render.raytrace_lightColor[i] );
638 
639  cfg->m_Render.raytrace_lightElevation[i] = (int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].x * 180.0f - 90.0f );
640  cfg->m_Render.raytrace_lightAzimuth[i] = (int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].y * 180.0f );
641  }
642 
643  cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_raytrace_nrsamples_shadows;
644  cfg->m_Render.raytrace_nrsamples_reflections = m_boardAdapter.m_raytrace_nrsamples_reflections;
645  cfg->m_Render.raytrace_nrsamples_refractions = m_boardAdapter.m_raytrace_nrsamples_refractions;
646 
647  cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_raytrace_spread_shadows;
648  cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_raytrace_spread_reflections;
649  cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_raytrace_spread_refractions;
650 
651  cfg->m_Render.raytrace_recursivelevel_refractions = m_boardAdapter.m_raytrace_recursivelevel_refractions;
652  cfg->m_Render.raytrace_recursivelevel_reflections = m_boardAdapter.m_raytrace_recursivelevel_reflections;
653 
654 #define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
655 
656  cfg->m_Render.engine = static_cast<int>( m_boardAdapter.RenderEngineGet() );
657  cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GridGet() );
658  cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.MaterialModeGet() );
659  cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.AntiAliasingGet() );
660 
661  save_color( m_boardAdapter.m_opengl_selectionColor, cfg->m_Render.opengl_selection_color );
662 
663  cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
664  cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();
665 
666  if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
667  cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();
668 
669  TRANSFER_SETTING( opengl_AA_disableOnMove, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE );
670  TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS );
671  TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
672  TRANSFER_SETTING( opengl_thickness_disableOnMove, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE );
673  TRANSFER_SETTING( opengl_vias_disableOnMove, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
674  TRANSFER_SETTING( opengl_holes_disableOnMove, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );
675 
676  TRANSFER_SETTING( raytrace_anti_aliasing, FL_RENDER_RAYTRACING_ANTI_ALIASING );
677  TRANSFER_SETTING( raytrace_backfloor, FL_RENDER_RAYTRACING_BACKFLOOR );
678  TRANSFER_SETTING( raytrace_post_processing, FL_RENDER_RAYTRACING_POST_PROCESSING );
679  TRANSFER_SETTING( raytrace_procedural_textures, FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
680  TRANSFER_SETTING( raytrace_reflections, FL_RENDER_RAYTRACING_REFLECTIONS );
681  TRANSFER_SETTING( raytrace_refractions, FL_RENDER_RAYTRACING_REFRACTIONS );
682  TRANSFER_SETTING( raytrace_shadows, FL_RENDER_RAYTRACING_SHADOWS );
683 
685  TRANSFER_SETTING( show_adhesive, FL_ADHESIVE );
686  TRANSFER_SETTING( show_axis, FL_AXIS );
687  TRANSFER_SETTING( show_board_body, FL_SHOW_BOARD_BODY );
688  TRANSFER_SETTING( clip_silk_on_via_annulus, FL_CLIP_SILK_ON_VIA_ANNULUS );
689  TRANSFER_SETTING( renderPlatedPadsAsPlated, FL_RENDER_PLATED_PADS_AS_PLATED );
690  TRANSFER_SETTING( show_comments, FL_COMMENTS );
691  TRANSFER_SETTING( show_eco, FL_ECO );
692  TRANSFER_SETTING( show_footprints_insert, FL_FP_ATTRIBUTES_NORMAL_INSERT );
693  TRANSFER_SETTING( show_footprints_normal, FL_FP_ATTRIBUTES_NORMAL );
694  TRANSFER_SETTING( show_footprints_virtual, FL_FP_ATTRIBUTES_VIRTUAL );
695  TRANSFER_SETTING( show_silkscreen, FL_SILKSCREEN );
696  TRANSFER_SETTING( show_soldermask, FL_SOLDERMASK );
697  TRANSFER_SETTING( show_solderpaste, FL_SOLDERPASTE );
698  TRANSFER_SETTING( show_zones, FL_ZONE );
699  TRANSFER_SETTING( subtract_mask_from_silk, FL_SUBTRACT_MASK_FROM_SILK );
700 
701 #undef TRANSFER_SETTING
702  }
703 }
704 
705 
707 {
708  BOARD* brd = GetBoard();
709  const FAB_LAYER_COLOR* stdColors = GetColorStandardList();
710  wxColour color;
711  if( brd )
712  {
713  const BOARD_STACKUP& stckp = brd->GetDesignSettings().GetStackupDescriptor();
714 
715  for( const BOARD_STACKUP_ITEM* stckpItem : stckp.GetList() )
716  {
717  wxString colorName = stckpItem->GetColor();
718 
719  if( colorName.StartsWith( "#" ) ) // This is a user defined color.
720  {
721  color.Set( colorName );
722  }
723  else
724  {
725  for( int i = 0; i < GetColorStandardListCount(); i++ )
726  {
727  if( stdColors[i].m_ColorName == colorName )
728  {
729  color = stdColors[i].m_Color;
730  break;
731  }
732  }
733  }
734 
735  if( color.IsOk() )
736  {
737  switch( stckpItem->GetBrdLayerId() )
738  {
739  case F_SilkS:
740  m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0;
741  m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0;
742  m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0;
743  break;
744  case B_SilkS:
745  m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0;
746  m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0;
747  m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0;
748  break;
749  case F_Mask:
750  m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0;
751  m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0;
752  m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0;
753  // Keep the previous alpha value
754  //m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0;
755  break;
756  case B_Mask:
757  m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0;
758  m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0;
759  m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0;
760  // Keep the previous alpha value
761  //m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0;
762  break;
763  default:
764  break;
765  }
766  }
767  }
768  }
769 }
770 
771 
772 void EDA_3D_VIEWER::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
773 {
774  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
775 
776  // Regen menu bars, etc
777  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
778 
779  // There is no base class that handles toolbars for this frame
781 
783 
784  NewDisplay( true );
785 }
786 
787 
788 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
789 {
790  wxString fullFileName;
791  bool fmt_is_jpeg = false;
792 
793  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
794  fmt_is_jpeg = true;
795 
796  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
797  {
798  // Remember path between saves during this session only.
799  const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
800  const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
801 
802  // First time path is set to the project path.
803  if( !m_defaultSaveScreenshotFileName.IsOk() )
805 
806  m_defaultSaveScreenshotFileName.SetExt( ext );
807 
808  wxFileDialog dlg( this, _( "3D Image File Name" ),
810  m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
811  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
812 
813  if( dlg.ShowModal() == wxID_CANCEL )
814  return;
815 
816  m_defaultSaveScreenshotFileName = dlg.GetPath();
817 
818  if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
819  m_defaultSaveScreenshotFileName.SetExt( ext );
820 
821  fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
822 
823  wxFileName fn = fullFileName;
824 
825  if( !fn.IsDirWritable() )
826  {
827  wxString msg;
828 
829  msg.Printf( _( "Insufficient permissions required to save file\n%s" ), fullFileName );
830  wxMessageBox( msg, _( "Error" ), wxOK | wxICON_ERROR, this );
831  return;
832  }
833 
834  // Be sure the screen area destroyed by the file dialog is redrawn
835  // before making a screen copy.
836  // Without this call, under Linux the screen refresh is made to late.
837  wxYield();
838  }
839 
840  // Be sure we have the latest 3D view (remember 3D view is buffered)
841  m_canvas->Request_refresh( true );
842  wxYield();
843 
844  // Build image from the 3D buffer
845  wxWindowUpdateLocker noUpdates( this );
846 
847  wxImage screenshotImage;
848 
849  if( m_canvas )
850  m_canvas->GetScreenshot( screenshotImage );
851 
852  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
853  {
854  wxBitmap bitmap( screenshotImage );
855 
856  if( wxTheClipboard->Open() )
857  {
858  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
859 
860  if( !wxTheClipboard->SetData( dobjBmp ) )
861  wxMessageBox( _( "Failed to copy image to clipboard" ) );
862 
863  wxTheClipboard->Flush(); /* the data in clipboard will stay
864  * available after the application exits */
865  wxTheClipboard->Close();
866  }
867  }
868  else
869  {
870  if( !screenshotImage.SaveFile( fullFileName,
871  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
872  wxMessageBox( _( "Can't save file" ) );
873 
874  screenshotImage.Destroy();
875  }
876 
877 }
878 
879 
881 {
882  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
883 
884  if( m_canvas )
886 }
887 
888 
889 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC4F &aColor, const wxString& aTitle,
890  CUSTOM_COLORS_LIST* aPredefinedColors,
891  bool aAllowOpacityControl,
892  KIGFX::COLOR4D aDefaultColor )
893 {
894  KIGFX::COLOR4D newcolor;
895  KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, aColor.a );
896 
897  DIALOG_COLOR_PICKER picker( this, oldcolor, aAllowOpacityControl, aPredefinedColors, aDefaultColor );
898 
899  if( picker.ShowModal() != wxID_OK )
900  return false;
901 
902  newcolor = picker.GetColor();
903 
904  if( newcolor == oldcolor )
905  return false;
906 
907  aColor.r = newcolor.r;
908  aColor.g = newcolor.g;
909  aColor.b = newcolor.b;
910  aColor.a = newcolor.a;
911 
912  return true;
913 }
914 
915 
917 {
919 
920  colors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
921  colors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
922 
923  if( Set3DColorFromUser( m_boardAdapter.m_SilkScreenColorTop, _( "Silkscreen Color" ), &colors, false, colors[0].m_Color ) )
924  {
926 
927  refreshRender();
928 
929  return true;
930  }
931 
932  return false;
933 }
934 
935 
937 {
939 
940  colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, 0.83, "Green" ) );
941  colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, 0.83, "Light Green" ) );
942  colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, 0.83, "Saturated Green" ) );
943  colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, 0.83, "Red" ) );
944  colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, 0.83, "Red Light Orange" ) );
945  colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, 0.83, "Red 2" ) );
946  colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, 0.83, "Blue" ) );
947  colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, 0.83, "Light blue 1" ) );
948  colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, 0.83, "Light blue 2" ) );
949  colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, 0.83, "Green blue (dark)" ) );
950  colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, 0.83, "Black" ) );
951  colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, 0.83, "White" ) );
952  colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, 0.83, "Purple" ) );
953  colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, 0.83, "Purple Dark" ) );
954 
955  if( Set3DColorFromUser( m_boardAdapter.m_SolderMaskColorTop, _( "Solder Mask Color" ), &colors, true, colors[0].m_Color ) )
956  {
958 
959  refreshRender();
960 
961  return true;
962  }
963 
964  return false;
965 }
966 
967 
969 {
971 
972  colors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
973  colors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
974  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
975  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
976 
977  if( Set3DColorFromUser( m_boardAdapter.m_CopperColor, _( "Copper Color" ), &colors, false, colors[0].m_Color ) )
978  {
979  refreshRender();
980 
981  return true;
982  }
983 
984  return false;
985 }
986 
987 
989 {
991 
992  colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, 0.9, "FR4 natural, dark" ) );
993  colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, 0.9, "FR4 natural" ) );
994  colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, 0.9, "brown/red" ) );
995  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 1" ) );
996  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, 0.9, "brown 2" ) );
997  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 3" ) );
998  colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, 0.9, "green 1" ) );
999  colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, 0.9, "green 2" ) );
1000 
1001  if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors, true, colors[0].m_Color ) )
1002  {
1003  refreshRender();
1004 
1005  return true;
1006  }
1007 
1008  return false;
1009 }
1010 
1011 
1013 {
1015 
1016  colors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
1017  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1018  colors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
1019 
1020  if( Set3DColorFromUser( m_boardAdapter.m_SolderPasteColor, _( "Solder Paste Color" ), &colors, false, colors[0].m_Color ) )
1021  {
1022  refreshRender();
1023 
1024  return true;
1025  }
1026 
1027  return false;
1028 }
1029 
1030 
1032 {
1033  wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
1034 
1035  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
1036 
1037  const DPI_SCALING dpi{ settings, this };
1038  m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
1039  // TODO(JE) use all control options
1041 }
Use a gray shading based on diffuse material.
void AnimationEnabledSet(bool aAnimationEnabled)
AnimationEnabledSet - Enable or disable camera animation when switching to a pre-defined view.
void ResetToDefaults()
Resets all parameters to default values.
std::vector< SFVEC3F > m_raytrace_lightColor
void GridSet(GRID3D_TYPE aGridType) noexcept
GridSet - set the current grid.
SFVEC3F m_raytrace_lightColorBottom
SFVEC4F GetColor(COLOR4D aColor) const
GetColor.
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:61
SFVEC3F m_raytrace_lightColorCamera
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
const std::string JpegFileExtension
int m_raytrace_nrsamples_refractions
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)
Saves common frame parameters to a configuration data file.
std::vector< SFVEC2F > m_raytrace_lightSphericalCoords
static TOOL_ACTION showBoundingBoxes
Definition: 3d_actions.h:83
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
float m_raytrace_spread_reflections
PROJECT & Prj()
Definition: kicad.cpp:342
glm::vec4 SFVEC4F
Definition: xv3d_types.h:49
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - 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
SFVEC3F m_raytrace_lightColorTop
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves 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.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
bool IsReloadRequestPending() const
IsReloadRequestPending - Query if there is a pending reload request.
Definition: eda_3d_canvas.h:88
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:559
double g
Green component.
Definition: color4d.h:375
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()
wxAuiManager m_auimgr
ACTION_MANAGER.
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
CCAMERA & m_currentCamera
void ReloadRequest(BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
void RenderEngineSet(RENDER_ENGINE aRenderEngine) noexcept
RenderEngineSet.
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
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:376
EDA_3D_CANVAS * m_canvas
void MovingSpeedMultiplierSet(int aMovingSpeedMultiplier)
MovingSpeedMultiplierSet - Set the camera animation moving speed multiplier option.
Use only diffuse material properties.
TOOL_MANAGER.
Definition: tool_manager.h:51
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:377
float m_raytrace_spread_shadows
void OnDisableRayTracing(wxCommandEvent &aEvent)
SFVEC4F m_BgColorTop
background top color
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets 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
PROJECTION_TYPE GetProjection()
Definition: ccamera.h:164
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
#define NULL
int m_raytrace_nrsamples_shadows
#define TRANSFER_SETTING(flag, field)
const BITMAP_OPAQUE icon_3d_xpm[1]
Definition: icon_3d.cpp:143
Use all material properties from model file.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void RenderEngineChanged()
RenderEngineChanged - Notify that the render engine was changed.
bool Set3DSilkScreenColorFromUser()
Set the silkscreen color from a set of colors.
void AntiAliasingSet(ANTIALIASING_MODE aAAmode)
AntiAliasingSet - set the current antialiasing mode value.
EDA_3D_CONTROLLER.
Definition: 3d_controller.h:39
bool AnimationEnabledGet() const
AnimationEnabledGet - Returns whether camera animation is enabled when switching to a pre-defined vie...
Definition of file extensions used in Kicad.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
float m_raytrace_spread_refractions
RENDER_ENGINE RenderEngineGet() const noexcept
RenderEngineGet.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
SFVEC3F m_opengl_selectionColor
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 wx colour dialog.
static TOOL_ACTION materialNormal
Definition: 3d_actions.h:75
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:38
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:116
static TOOL_ACTION addFloor
Definition: 3d_actions.h:86
static TOOL_ACTION showAxis
Definition: 3d_actions.h:93
COMMON_CONTROL.
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,...
Specialization of the wxAuiPaneInfo class for KiCad panels.
int m_raytrace_recursivelevel_reflections
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
wxString PngFileWildcard()
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
BOARD * GetBoard()
static TOOL_ACTION materialDiffuse
Definition: 3d_actions.h:76
static const int * GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode)
Get a list of attributes to pass to wxGLCanvas.
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:70
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
MovingSpeedMultiplierGet - 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:48
see class PGM_BASE
Declaration of the eda_3d_viewer class.
Board layer functions and definitions.
wxFileName m_defaultSaveScreenshotFileName
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:200
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets 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:47
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:76
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.
void OnSetFocus(wxFocusEvent &event)
Color settings are a bit different than most of the settings objects in that there can be more than o...
ANTIALIASING_MODE AntiAliasingGet() const
GridGet - get the current antialiasing mode value.
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:65
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
double r
Red component.
Definition: color4d.h:374
int m_raytrace_recursivelevel_refractions
static TOOL_ACTION toggleOrtho
Definition: 3d_actions.h:60
#define FlagCheck(x)
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
GRID3D_TYPE GridGet() const noexcept
GridGet - get the current grid.
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
MATERIAL_MODE MaterialModeGet() const noexcept
MaterialModeGet.
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
static VRML_COLOR colors[VRML_COLOR_LAST]
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard()
Definition: eda_3d_viewer.h:78
bool m_disable_ray_tracing
bool Set3DBoardBodyColorFromUser()
Set the copper color from a set of colors.
void ReloadRequest()
Request reloading the 3D view.
void MaterialModeSet(MATERIAL_MODE aMaterialMode) noexcept
MaterialModeSet.
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
void Process_Special_Functions(wxCommandEvent &event)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
int m_raytrace_nrsamples_reflections
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.