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-2019 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 
30 #include "eda_3d_viewer.h"
31 
32 #include "../3d_viewer_id.h"
33 #include "../common_ogl/cogl_att_list.h"
34 
35 #include <bitmaps.h>
36 #include <dpi_scaling.h>
37 #include <gestfich.h>
38 #include <pgm_base.h>
39 #include <project.h>
41 
42 #include <hotkeys_basic.h>
43 #include <wx/colordlg.h>
44 #include <wx/colourdata.h>
45 #include <wx/toolbar.h>
46 
47 
55 const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
56 
57 
58 // Key to store 3D Viewer config
59 
60 static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
61 static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
62 static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
63 
64 static const wxChar keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
65 static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
66 static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
67 
68 static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" );
69 static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" );
70 static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" );
71 
72 static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" );
73 static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" );
74 static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" );
75 
76 static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" );
77 static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" );
78 static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" );
79 
80 static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
81 static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
82 static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
83 
84 static const wxChar keyBoardBodyColor_Red[] = wxT( "BoardBodyColor_Red" );
85 static const wxChar keyBoardBodyColor_Green[] = wxT( "BoardBodyColor_Green" );
86 static const wxChar keyBoardBodyColor_Blue[] = wxT( "BoardBodyColor_Blue" );
87 
88 static const wxChar keyMousewheelPanning[] = wxT( "MousewheelPAN3D" );
89 
90 static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
91 static const wxChar keyRenderEngine[] = wxT( "RenderEngine" );
92 //static const wxChar keyRenderTextures[] = wxT( "Render_Textures" );
93 static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
94 
95 static const wxChar keyRenderOGL_ShowCopperTck[]= wxT( "Render_OGL_ShowCopperThickness" );
96 static const wxChar keyRenderOGL_ShowModelBBox[]= wxT( "Render_OGL_ShowModelBoudingBoxes" );
97 
98 static const wxChar keyRenderRAY_Shadows[] = wxT( "Render_RAY_Shadows" );
99 static const wxChar keyRenderRAY_Backfloor[] = wxT( "Render_RAY_Backfloor" );
100 static const wxChar keyRenderRAY_Refractions[] = wxT( "Render_RAY_Refractions" );
101 static const wxChar keyRenderRAY_Reflections[] = wxT( "Render_RAY_Reflections" );
102 static const wxChar keyRenderRAY_PostProcess[] = wxT( "Render_RAY_PostProcess" );
103 static const wxChar keyRenderRAY_AAliasing[] = wxT( "Render_RAY_AntiAliasing" );
104 static const wxChar keyRenderRAY_ProceduralT[] = wxT( "Render_RAY_ProceduralTextures" );
105 
106 static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
107 static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
108 static const wxChar keyShowZones[] = wxT( "ShowZones" );
109 static const wxChar keyShowFootprints_Normal[] = wxT( "ShowFootprints_Normal" );
110 static const wxChar keyShowFootprints_Insert[] = wxT( "ShowFootprints_Insert" );
111 static const wxChar keyShowFootprints_Virtual[] = wxT( "ShowFootprints_Virtual" );
112 static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
113 static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
114 static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
115 static const wxChar keyShowSolderPasteLayers[] = wxT( "ShowSolderPasteLayers" );
116 static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
117 static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
118 static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
119 
120 
121 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
122 
123  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
124  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
125 
127 
130 
132 
136 
139 
140  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
141 
151 
154 END_EVENT_TABLE()
155 
156 
158  const wxString &aTitle, long style ) :
159  KIWAY_PLAYER( aKiway, aParent,
160  FRAME_PCB_DISPLAY3D, aTitle,
161  wxDefaultPosition, wxDefaultSize,
162  style, VIEWER3D_FRAMENAME )
163 {
164  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle );
165 
166  m_canvas = NULL;
167  m_disable_ray_tracing = false;
168 
169  // Give it an icon
170  wxIcon icon;
171  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
172  SetIcon( icon );
173 
174  LoadSettings( config() );
175  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
176 
177  // Create the status line
178  static const int status_dims[4] = { -1, 130, 130, 170 };
179 
180  wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
181  SetStatusWidths( arrayDim( status_dims ), status_dims );
182 
183  m_canvas = new EDA_3D_CANVAS( this,
185  aParent->GetBoard(),
186  m_settings,
187  Prj().Get3DCacheManager() );
188 
189  if( m_canvas )
190  m_canvas->SetStatusBar( status_bar );
191 
192  // Some settings need the canvas
193  loadCommonSettings();
194 
195  CreateMenuBar();
196  ReCreateMainToolbar();
197 
198  m_auimgr.SetManagedWindow( this );
199 
200  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
201  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
202 
203  m_auimgr.Update();
204 
205  m_mainToolBar->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ),
206  NULL, this );
207 
208  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
209  // in order to receive mouse events. Otherwise, the user has to click somewhere on
210  // the canvas before it will respond to mouse wheel events.
211  if( m_canvas )
212  m_canvas->SetFocus();
213 }
214 
215 
217 {
218  m_mainToolBar->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ),
219  NULL, this );
220 
221  m_auimgr.UnInit();
222 
223  // m_canvas delete will be called by wxWidget manager
224  //delete m_canvas;
225  //m_canvas = 0;
226 }
227 
228 
230 {
231  // This will schedule a request to load later
232  if( m_canvas )
233  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
234 }
235 
236 
237 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
238 {
239  ReloadRequest();
240 
241  // After the ReloadRequest call, the refresh often takes a bit of time,
242  // and it is made here only on request.
243  if( aForceImmediateRedraw )
244  m_canvas->Refresh();
245 }
246 
247 
248 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
249 {
250  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
251 
252  Close( true );
253 }
254 
255 
256 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
257 {
258  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnCloseWindow" );
259 
260  if( m_canvas )
261  m_canvas->Close();
262 
263  // m_canvas delete will be called by wxWidget manager
264  //delete m_canvas;
265  //m_canvas = 0;
266 
267  Destroy();
268  event.Skip( true );
269 }
270 
271 #define ROT_ANGLE 10.0
272 
273 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
274 {
275  int id = event.GetId();
276  bool isChecked = event.IsChecked();
277 
278  wxLogTrace( m_logTrace,
279  "EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
280  id, isChecked );
281 
282  if( m_canvas == NULL )
283  return;
284 
285  switch( id )
286  {
287  case ID_RELOAD3D_BOARD:
288  NewDisplay( true );
289  break;
290 
291  case ID_ROTATE3D_X_POS:
292  m_settings.CameraGet().RotateX( glm::radians(ROT_ANGLE) );
293 
296  else
298 
299  break;
300 
301  case ID_ROTATE3D_X_NEG:
302  m_settings.CameraGet().RotateX( -glm::radians(ROT_ANGLE) );
303 
306  else
308 
309  break;
310 
311  case ID_ROTATE3D_Y_POS:
312  m_settings.CameraGet().RotateY( glm::radians(ROT_ANGLE) );
313 
316  else
318 
319  break;
320 
321  case ID_ROTATE3D_Y_NEG:
322  m_settings.CameraGet().RotateY( -glm::radians(ROT_ANGLE) );
323 
326  else
328 
329  break;
330 
331  case ID_ROTATE3D_Z_POS:
332  m_settings.CameraGet().RotateZ( glm::radians(ROT_ANGLE) );
333 
336  else
338 
339  break;
340 
341  case ID_ROTATE3D_Z_NEG:
342  m_settings.CameraGet().RotateZ( -glm::radians(ROT_ANGLE) );
343 
346  else
348 
349  break;
350 
351  case ID_MOVE3D_LEFT:
352  m_canvas->SetView3D( WXK_LEFT );
353  return;
354 
355  case ID_MOVE3D_RIGHT:
356  m_canvas->SetView3D( WXK_RIGHT );
357  return;
358 
359  case ID_MOVE3D_UP:
360  m_canvas->SetView3D( WXK_UP );
361  return;
362 
363  case ID_MOVE3D_DOWN:
364  m_canvas->SetView3D( WXK_DOWN );
365  return;
366 
367  case ID_ORTHO:
370  return;
371 
375  takeScreenshot( event );
376  return;
377 
379  if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ),
380  nullptr ) )
381  {
384  else
385  NewDisplay( true );
386  }
387  return;
388 
390  if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ), nullptr ) )
391  {
394  else
395  NewDisplay( true );
396  }
397  return;
398 
401  return;
402 
405  return;
406 
409  return;
410 
413  break;
414 
417  break;
418 
421  NewDisplay( true );
422  return;
423 
426  NewDisplay( true );
427  return;
428 
431  NewDisplay( true );
432  return;
433 
436  NewDisplay( true );
437  return;
438 
441  NewDisplay( true );
442  return;
443 
447  return;
448 
452  return;
453 
456  NewDisplay( true );
457  return;
458 
461  NewDisplay( true );
462  return;
463 
467  return;
468 
472  return;
473 
476  NewDisplay( true );
477  return;
478 
482  return;
483 
485  m_settings.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
486  NewDisplay( true );
487  return;
488 
490  m_settings.SetFlag( FL_AXIS, isChecked );
492  return;
493 
496  NewDisplay( true );
497  return;
498 
501  NewDisplay( true );
502  return;
503 
506  NewDisplay( true );
507  return;
508 
510  m_settings.SetFlag( FL_ZONE, isChecked );
511  NewDisplay( true );
512  return;
513 
515  m_settings.SetFlag( FL_ADHESIVE, isChecked );
516  NewDisplay( true );
517  return;
518 
520  m_settings.SetFlag( FL_SILKSCREEN, isChecked );
521  NewDisplay( true );
522  return;
523 
525  m_settings.SetFlag( FL_SOLDERMASK, isChecked );
526  NewDisplay( true );
527  return;
528 
530  m_settings.SetFlag( FL_SOLDERPASTE, isChecked );
531  NewDisplay( true );
532  return;
533 
535  m_settings.SetFlag( FL_COMMENTS, isChecked );
536  NewDisplay( true );
537  return;
538 
539  case ID_MENU3D_ECO_ONOFF:
540  m_settings.SetFlag( FL_ECO, isChecked );
541  NewDisplay( true );
542  return;
543 
545  {
546  // Reload settings with a dummy config, so it will load the defaults
547  wxConfig *fooconfig = new wxConfig( "FooBarApp" );
548  LoadSettings( fooconfig );
549  delete fooconfig;
550 
551  // Tell canvas that we (may have) changed the render engine
553 
554  NewDisplay( true );
555  }
556  return;
557 
559  {
560  DisplayHotKeys();
561  }
562  return;
563 
564  default:
565  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
566  return;
567  }
568 }
569 
570 
571 void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
572 {
573  int id = event.GetId();
574 
575  wxASSERT( id < ID_MENU3D_GRID_END );
576  wxASSERT( id > ID_MENU3D_GRID );
577 
578  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::On3DGridSelection id %d", id );
579 
580  switch( id )
581  {
584  break;
585 
588  break;
589 
590  case ID_MENU3D_GRID_5_MM:
592  break;
593 
596  break;
597 
598  case ID_MENU3D_GRID_1_MM:
600  break;
601 
602  default:
603  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" );
604  return;
605  }
606 
607  if( m_canvas )
609 }
610 
611 
612 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
613 {
614  const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
615 
616  if( old_engine == RENDER_ENGINE_OPENGL_LEGACY )
618  else
620 
621  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
623  "Ray Trace" : "OpenGL Legacy" );
624 
625  if( old_engine != m_settings.RenderEngineGet() )
626  {
628  }
629 }
630 
631 
632 void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
633 {
634  int id = event.GetId();
635 
636  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::ProcessZoom id:%d", id );
637 
638  if( m_canvas == NULL )
639  return;
640 
641  switch( id )
642  {
643  case ID_ZOOM_PAGE:
644  m_canvas->SetView3D( WXK_HOME );
645  break;
646 
647  case ID_ZOOM_IN:
648  m_canvas->SetView3D( WXK_F1 );
649  break;
650 
651  case ID_ZOOM_OUT:
652  m_canvas->SetView3D( WXK_F2 );
653  break;
654 
655  case ID_ZOOM_REDRAW:
657  break;
658 
659  default:
660  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::ProcessZoom()" );
661  return;
662  }
663 
665 }
666 
667 
668 void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
669 {
670  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
671 
672  m_disable_ray_tracing = true;
674 }
675 
676 
677 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
678 {
679  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
680 
681  if( m_canvas )
682  {
683  // Reload data if 3D frame shows a board,
684  // because it can be changed since last frame activation
687 
688  // Activates again the focus of the canvas so it will catch mouse and key events
689  m_canvas->SetFocus();
690  }
691 
692  event.Skip(); // required under wxMAC
693 }
694 
695 
696 void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
697 {
698  // Activates again the focus of the canvas so it will catch mouse and key events
699  if( m_canvas )
700  m_canvas->SetFocus();
701 
702  event.Skip();
703 }
704 
705 
706 void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg )
707 {
709 
710  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
711 
712  aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
713  aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
714  aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
715 
716  aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
717  aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
718  aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
719 
720  // m_SolderMaskColor default value = dark grey-green
721  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColor.r, 100.0 * 0.2 / 255.0 );
722  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColor.g, 255.0 * 0.2 / 255.0 );
723  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColor.b, 180.0 * 0.2 / 255.0 );
724 
725  // m_SolderPasteColor default value = light grey
726  aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 /255.0 );
727  aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 /255.0 );
728  aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 /255.0 );
729 
730  // m_SilkScreenColor default value = white
731  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColor.r, 0.9 );
732  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColor.g, 0.9 );
733  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColor.b, 0.9 );
734 
735  // m_CopperColor default value = gold
736  aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
737  aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
738  aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 );
739 
740  // m_BoardBodyColor default value = FR4, in realistic mode
741  aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
742  aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
743  aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 /255.0 );
744 
745 
746  bool tmp;
747  aCfg->Read( keyShowRealisticMode, &tmp, true );
749 
750  // OpenGL options
751  aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
753 
754  aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
756 
757  // Raytracing options
758  aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
760 
761  aCfg->Read( keyRenderRAY_Backfloor, &tmp, true );
763 
764  aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
766 
767  aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
769 
770  aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
772 
773  aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
775 
776  aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
778 
779  aCfg->Read( keyShowAxis, &tmp, true );
780  m_settings.SetFlag( FL_AXIS, tmp );
781 
782  aCfg->Read( keyShowFootprints_Normal, &tmp, true );
784 
785  aCfg->Read( keyShowFootprints_Insert, &tmp, true );
787 
788  aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
790 
791  aCfg->Read( keyShowZones, &tmp, true );
792  m_settings.SetFlag( FL_ZONE, tmp );
793 
794  aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
796 
797  aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
799 
800  aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
802 
803  aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
805 
806  aCfg->Read( keyShowCommentsLayer, &tmp, true );
808 
809  aCfg->Read( keyShowEcoLayers, &tmp, true );
810  m_settings.SetFlag( FL_ECO, tmp );
811 
812  aCfg->Read( keyShowBoardBody, &tmp, true );
814 
815  int tmpi;
816  aCfg->Read( keyShowGrid, &tmpi, (int)GRID3D_NONE );
817  m_settings.GridSet( (GRID3D_TYPE)tmpi );
818 
819  aCfg->Read( keyRenderEngine, &tmpi, (int)RENDER_ENGINE_OPENGL_LEGACY );
820  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings render setting %s",
821  ( (RENDER_ENGINE)tmpi == RENDER_ENGINE_RAYTRACING ) ? "Ray Trace" : "OpenGL" );
823 
824  aCfg->Read( keyRenderMaterial, &tmpi, (int)MATERIAL_MODE_NORMAL );
826 }
827 
828 
829 void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
830 {
832 
833  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
834 
835  aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
836  aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
837  aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
838 
839  aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
840  aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
841  aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
842 
846 
850 
854 
855  aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
857  aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
858 
862 
864 
865  aCfg->Write( keyRenderEngine, (int)m_settings.RenderEngineGet() );
866  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings render setting %s",
867  ( m_settings.RenderEngineGet() == RENDER_ENGINE_RAYTRACING ) ? "Ray Trace" : "OpenGL" );
868 
869  aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() );
870 
871  // OpenGL options
872  aCfg->Write( keyRenderOGL_ShowCopperTck,
874  aCfg->Write( keyRenderOGL_ShowModelBBox,
876 
877  // Raytracing options
885 
886  aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
887  aCfg->Write( keyShowGrid, (int)m_settings.GridGet() );
888 
892 
893  aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
899  aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
901 }
902 
903 
905 {
906  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
907 
908  // Regen menu bars, etc
910 
911  // There is no base class that handles toolbars for this frame
913 
915 
916  NewDisplay( true );
917 }
918 
919 
920 void EDA_3D_VIEWER::OnLeftClick( wxDC *DC, const wxPoint &MousePos )
921 {
922  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnLeftClick" );
923  // Do nothing
924 }
925 
926 
927 void EDA_3D_VIEWER::OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu )
928 {
929  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRightClick" );
930  // Do nothing
931 }
932 
933 
934 void EDA_3D_VIEWER::OnKeyEvent( wxKeyEvent& event )
935 {
936  if( m_canvas )
937  return m_canvas->OnKeyEvent( event );
938 
939  event.Skip();
940 }
941 
942 
943 void EDA_3D_VIEWER::RedrawActiveWindow( wxDC *DC, bool EraseBg )
944 {
945  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RedrawActiveWindow" );
946  // Do nothing
947 }
948 
949 
950 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
951 {
952  wxString fullFileName;
953  bool fmt_is_jpeg = false;
954 
955  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
956  fmt_is_jpeg = true;
957 
958  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
959  {
960  // Remember path between saves during this session only.
961  const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
962  const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
963 
964  // First time path is set to the project path.
965  if( !m_defaultSaveScreenshotFileName.IsOk() )
967 
968  m_defaultSaveScreenshotFileName.SetExt( ext );
969 
970  wxFileDialog dlg( this, _( "3D Image File Name" ),
972  m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
973  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
974 
975  if( dlg.ShowModal() == wxID_CANCEL )
976  return;
977 
978  m_defaultSaveScreenshotFileName = dlg.GetPath();
979 
980  if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
981  m_defaultSaveScreenshotFileName.SetExt( ext );
982 
983  fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
984 
985  // Be sure the screen area destroyed by the file dialog is redrawn
986  // before making a screen copy.
987  // Without this call, under Linux the screen refresh is made to late.
988  wxYield();
989  }
990 
991  // Be sure we have the latest 3D view (remember 3D view is buffered)
992  m_canvas->Request_refresh( true );
993  wxYield();
994 
995  // Build image from the 3D buffer
996  wxWindowUpdateLocker noUpdates( this );
997 
998  wxImage screenshotImage;
999 
1000  if( m_canvas )
1001  m_canvas->GetScreenshot( screenshotImage );
1002 
1003  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
1004  {
1005  wxBitmap bitmap( screenshotImage );
1006 
1007  if( wxTheClipboard->Open() )
1008  {
1009  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
1010 
1011  if( !wxTheClipboard->SetData( dobjBmp ) )
1012  wxMessageBox( _( "Failed to copy image to clipboard" ) );
1013 
1014  wxTheClipboard->Flush(); /* the data in clipboard will stay
1015  * available after the application exits */
1016  wxTheClipboard->Close();
1017  }
1018  }
1019  else
1020  {
1021  if( !screenshotImage.SaveFile( fullFileName,
1022  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
1023  wxMessageBox( _( "Can't save file" ) );
1024 
1025  screenshotImage.Destroy();
1026  }
1027 
1028 }
1029 
1030 
1032 {
1033  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
1034 
1035  if( m_canvas )
1037 }
1038 
1039 
1040 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
1041  CUSTOM_COLORS_LIST* aPredefinedColors )
1042 {
1043  KIGFX::COLOR4D newcolor;
1044  KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, 1.0 );
1045 
1046  DIALOG_COLOR_PICKER picker( this, oldcolor, false, aPredefinedColors );
1047 
1048  if( picker.ShowModal() != wxID_OK )
1049  return false;
1050 
1051  newcolor = picker.GetColor();
1052 
1053  if( newcolor == oldcolor )
1054  return false;
1055 
1056  aColor.r = newcolor.r;
1057  aColor.g = newcolor.g;
1058  aColor.b = newcolor.b;
1059 
1060  return true;
1061 }
1062 
1063 
1065 {
1066  CUSTOM_COLORS_LIST definedColors;
1067  definedColors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
1068  definedColors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
1069 
1071  _( "Solder Mask Color" ), &definedColors );
1072 
1073  if( change )
1074  NewDisplay( true );
1075 
1076  return change;
1077 }
1078 
1079 
1081 {
1082  CUSTOM_COLORS_LIST definedColors;
1083 
1084  definedColors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, "Green" ) );
1085  definedColors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, "Light Green" ) );
1086  definedColors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0,
1087  "Saturated Green" ) );
1088  definedColors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, "Red" ) );
1089  definedColors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0,
1090  "Red Light Orange" ) );
1091  definedColors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, "Red 2" ) );
1092  definedColors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, "Blue" ) );
1093  definedColors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, "Light blue 1" ) );
1094  definedColors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, "Light blue 2" ) );
1095  definedColors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0,
1096  "Green blue (dark)" ) );
1097  definedColors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, "Black" ) );
1098  definedColors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, "White" ) );
1099  definedColors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, "Purple" ) );
1100  definedColors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, "Purple Dark" ) );
1101 
1103  _( "Solder Mask Color" ),
1104  &definedColors );
1105 
1106  if( change )
1107  NewDisplay( true );
1108 
1109  return change;
1110 }
1111 
1112 
1114 {
1115  CUSTOM_COLORS_LIST definedColors;
1116 
1117  definedColors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
1118  definedColors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
1119  definedColors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1120  definedColors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
1121 
1122  bool change = Set3DColorFromUser( m_settings.m_CopperColor, _( "Copper Color" ),
1123  &definedColors );
1124 
1125  if( change )
1126  NewDisplay( true );
1127 
1128  return change;
1129 }
1130 
1131 
1133 {
1134  CUSTOM_COLORS_LIST definedColors;
1135 
1136  definedColors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0,
1137  "FR4 natural, dark" ) );
1138  definedColors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, "FR4 natural" ) );
1139  definedColors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, "brown/red" ) );
1140  definedColors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 1" ) );
1141  definedColors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, "brown 2" ) );
1142  definedColors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 3" ) );
1143  definedColors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, "green 1" ) );
1144  definedColors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, "green 2" ) );
1145 
1146  bool change = Set3DColorFromUser( m_settings.m_BoardBodyColor, _( "Board Body Color" ),
1147  &definedColors );
1148  if( change )
1149  NewDisplay( true );
1150 
1151  return change;
1152 }
1153 
1154 
1156 {
1157  CUSTOM_COLORS_LIST definedColors;
1158 
1159  definedColors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
1160  definedColors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1161  definedColors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
1162 
1164  _( "Solder Paste Color" ), &definedColors );
1165 
1166  if( change )
1167  NewDisplay( true );
1168 
1169  return change;
1170 }
1171 
1172 
1173 void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent )
1174 {
1175  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIEngine %s %s",
1176  ( !m_disable_ray_tracing ) ? "enable" : "disable",
1178  "Ray Trace" : "OpenGL Legacy" );
1179 
1180  aEvent.Enable( !m_disable_ray_tracing );
1182 }
1183 
1184 
1185 void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent )
1186 {
1187  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIMaterial() id %d", aEvent.GetId() );
1188 
1189  // Set the state of toggle menus according to the current display options
1190  switch( aEvent.GetId() )
1191  {
1193  aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL );
1194  break;
1195 
1198  break;
1199 
1201  aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE );
1202  break;
1203 
1204  default:
1205  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
1206  }
1207 }
1208 
1209 
1210 void EDA_3D_VIEWER::OnUpdateUIOpenGL( wxUpdateUIEvent& aEvent )
1211 {
1212  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIOpenGL() id %d", aEvent.GetId() );
1213 
1214  // OpenGL
1215  switch( aEvent.GetId() )
1216  {
1219  break;
1220 
1223  break;
1224 
1225  default:
1226  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIOpenGL()" );
1227  }
1228 }
1229 
1230 
1231 void EDA_3D_VIEWER::OnUpdateUIRayTracing( wxUpdateUIEvent& aEvent )
1232 {
1233  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIRayTracing() id %d", aEvent.GetId() );
1234 
1235  // Raytracing
1236  switch( aEvent.GetId() )
1237  {
1239  aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
1240  break;
1241 
1244  break;
1245 
1248  break;
1249 
1252  break;
1253 
1256  break;
1257 
1260  break;
1261 
1264  break;
1265 
1266  default:
1267  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
1268  }
1269 }
1270 
1271 
1272 void EDA_3D_VIEWER::OnUpdateUIAxis( wxUpdateUIEvent& aEvent )
1273 {
1274  aEvent.Check( m_settings.GetFlag( FL_AXIS ) );
1275 }
1276 
1277 
1279 {
1280  wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
1281 
1282  wxConfigBase& cmnCfg = *Pgm().CommonSettings();
1283 
1284  {
1285  const DPI_SCALING dpi{ &cmnCfg, this };
1286  m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
1287  }
1288 
1289  {
1290  bool option;
1291  cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
1293  }
1294 }
static const wxChar keyShowSolderMaskLayers[]
static const wxChar keyShowFootprints_Normal[]
static const wxChar keyRenderRAY_ProceduralT[]
static const wxChar keyShowGrid[]
bool Set3DCopperColorFromUser()
Set the copper color from a set of colors.
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:127
static const wxChar keyShowBoardBody[]
Use only diffuse material properties.
Definition: 3d_enums.h:93
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
static const wxChar keyRenderRAY_Reflections[]
const std::string JpegFileExtension
CINFO3D_VISU m_settings
static const wxChar keyBgColor_Red_Top[]
void On3DGridSelection(wxCommandEvent &event)
This file is part of the common library TODO brief description.
void Install3DViewOptionDialog(wxCommandEvent &event)
static const wxChar keySilkColor_Blue[]
static const wxChar keyMousewheelPanning[]
static const wxChar keyBgColor_Blue_Top[]
bool Set3DSolderMaskColorFromUser()
Set the solder mask color from a set of colors.
void GridSet(GRID3D_TYPE aGridType)
GridSet - set the current grid.
Definition: cinfo3d_visu.h:222
static const wxChar keyRenderEngine[]
static const wxChar keyBgColor_Red[]
SFVEC3D m_CopperColor
in realistic mode: copper color
Definition: cinfo3d_visu.h:509
void OnUpdateUIAxis(wxUpdateUIEvent &aEvent)
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
PROJECT & Prj()
Definition: kicad.cpp:303
void OnKeyEvent(wxKeyEvent &event)
void RotateY(float aAngleInRadians)
Definition: ccamera.cpp:503
static const wxChar keyShowFootprints_Insert[]
EVT_TOOL(ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, PCB_EDIT_FRAME::OnSelectOptionToolbar) EVT_TOOL_RANGE(ID_TB_OPTIONS_SHOW_ZONES
virtual void SaveSettings(wxConfigBase *aCfg)
Saves common frame parameters to a configuration data file.
void RedrawActiveWindow(wxDC *DC, bool EraseBg)
Definition: id.h:235
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::language_change) EVT_UPDATE_UI_RANGE(ID_TO_SCH
static const wxChar keyCopperColor_Green[]
static const wxChar keyShowFootprints_Virtual[]
void SetStatusBar(wxStatusBar *aStatusBar)
Definition: eda_3d_canvas.h:73
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:52
bool IsReloadRequestPending() const
IsReloadRequestPending - Query if there is a pending reload request.
Definition: eda_3d_canvas.h:81
double g
Green component.
Definition: color4d.h:310
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
static const wxChar keyShowAdhesiveLayers[]
a class to handle a custom color (predefined color) for the color picker dialog
wxString JpegFileWildcard()
static const wxChar keySilkColor_Green[]
wxAuiManager m_auimgr
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:503
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
void ReloadRequest(BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
SFVEC3D m_BgColorTop
background top color
Definition: cinfo3d_visu.h:504
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
void MaterialModeSet(MATERIAL_MODE aMaterialMode)
MaterialModeSet.
Definition: cinfo3d_visu.h:240
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
void loadCommonSettings()
Load configuration from common settings.
static const wxChar keyShowRealisticMode[]
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
Definition: dpi_scaling.h:35
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
Definition: cinfo3d_visu.h:505
double b
Blue component.
Definition: color4d.h:311
EDA_3D_CANVAS * m_canvas
static const wxChar keyCopperColor_Blue[]
static const wxChar keySMaskColor_Green[]
bool Set3DColorFromUser(SFVEC3D &aColor, const wxString &aTitle, CUSTOM_COLORS_LIST *aPredefinedColors)
Get a SFVEC3D from a wx colour dialog.
static const wxChar keyBgColor_Green_Top[]
static const wxChar keyShowSolderPasteLayers[]
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:246
void DisplayHotKeys()
void RenderEngineSet(RENDER_ENGINE aRenderEngine)
RenderEngineSet.
Definition: cinfo3d_visu.h:228
static const wxChar keySPasteColor_Red[]
static const wxChar keyShowSilkScreenLayers[]
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void OnActivate(wxActivateEvent &event)
static const wxChar keyCopperColor_Red[]
void RotateZ(float aAngleInRadians)
Definition: ccamera.cpp:510
void OnUpdateUIMaterial(wxUpdateUIEvent &aEvent)
void RotateX(float aAngleInRadians)
Definition: ccamera.cpp:496
void OnDisableRayTracing(wxCommandEvent &aEvent)
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
void RenderRaytracingRequest()
RenderRaytracingRequest - Request to render the current view in Raytracing mode.
wxAuiToolBar * m_mainToolBar
void OnKeyEvent(wxKeyEvent &event)
static const wxChar keyShowZones[]
static const wxChar keyRenderMaterial[]
static const wxChar keyRenderRAY_AAliasing[]
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.
virtual void LoadSettings(wxConfigBase *aCfg)
Load common frame parameters from a configuration file.
void OnUpdateUIEngine(wxUpdateUIEvent &aEvent)
void ToggleProjection()
Definition: ccamera.cpp:417
void GetKicadAbout(wxCommandEvent &event)
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:50
Definition of file extensions used in Kicad.
Use a gray shading based on diffuse material.
Definition: 3d_enums.h:94
EDA_3D_VIEWER::OnUpdateUIMaterial ID_MENU3D_FL_RAYTRACING_PROCEDURAL_TEXTURES
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
void OnLeftClick(wxDC *DC, const wxPoint &MousePos)
void OnCloseWindow(wxCloseEvent &event)
static const wxChar keyBgColor_Green[]
static const wxChar keyBoardBodyColor_Blue[]
void ReCreateMainToolbar()
Equivalent of EDA_DRAW_FRAME::ReCreateHToolbar.
Definition: 3d_toolbar.cpp:39
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
void OnUpdateUIOpenGL(wxUpdateUIEvent &aEvent)
MATERIAL_MODE
Render 3d model shape materials mode.
Definition: 3d_enums.h:90
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:507
bool Set3DSolderPasteColorFromUser()
Set the solder mask color from a set of colors.
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:190
Specialization of the wxAuiPaneInfo class for KiCad panels.
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:506
GRID3D_TYPE
Grid types.
Definition: 3d_enums.h:71
static const wxChar keyRenderOGL_ShowModelBBox[]
wxString PngFileWildcard()
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PCB_LIB_TABLE_EDIT
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:107
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:234
static const wxChar keySPasteColor_Green[]
Use all material properties from model file.
Definition: 3d_enums.h:92
static const wxChar keyBoardBodyColor_Red[]
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.
SFVEC3D m_SilkScreenColor
in realistic mode: SilkScreen color
Definition: cinfo3d_visu.h:508
static const wxChar keySilkColor_Red[]
static const wxChar keyBgColor_Blue[]
static const wxChar keySMaskColor_Red[]
static const wxChar keyRenderRAY_Refractions[]
see class PGM_BASE
Declaration of the eda_3d_viewer class.
static const wxChar keyRenderOGL_ShowCopperTck[]
static const wxChar keyRenderRAY_Backfloor[]
void OnUpdateUIRayTracing(wxUpdateUIEvent &aEvent)
wxFileName m_defaultSaveScreenshotFileName
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void ProcessZoom(wxCommandEvent &event)
#define ROT_ANGLE
static const wxChar keySMaskColor_Blue[]
The base frame for deriving all KiCad main window classes.
void OnRenderEngineSelection(wxCommandEvent &event)
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:60
KIGFX::COLOR4D GetColor()
const std::string PngFileExtension
void SetScaleFactor(double aFactor)
Set the canvas scale factor, probably for a hi-DPI display.
RENDER_ENGINE
Render engine mode.
Definition: 3d_enums.h:82
static const wxChar keyBoardBodyColor_Green[]
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void OnSetFocus(wxFocusEvent &event)
static const wxChar keyShowAxis[]
static const wxChar keySPasteColor_Blue[]
virtual void CommonSettingsChanged()
Notification event that some of the common (suite-wide) settings have changed.
void OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu)
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:49
EDA_3D_VIEWER::OnUpdateUIMaterial EVT_UPDATE_UI_RANGE(ID_MENU3D_FL_OPENGL_RENDER_COPPER_THICKNESS, ID_MENU3D_FL_OPENGL_RENDER_SHOW_MODEL_BBOX, EDA_3D_VIEWER::OnUpdateUIOpenGL) EVT_UPDATE_UI_RANGE(ID_MENU3D_FL_RAYTRACING_RENDER_SHADOWS
Some functions to handle hotkeys in KiCad.
double r
Red component.
Definition: color4d.h:309
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
void CommonSettingsChanged() override
Notification that common settings are updated.
static const wxChar keyShowEcoLayers[]
static const wxChar keyShowCommentsLayer[]
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
static const wxChar keyRenderRAY_Shadows[]
#define VIEWER3D_FRAMENAME
Definition: eda_3d_viewer.h:44
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard()
Definition: eda_3d_viewer.h:62
bool m_disable_ray_tracing
bool Set3DBoardBodyColorFromUser()
Set the copper color from a set of colors.
static const wxChar keyRenderRAY_PostProcess[]
void ReloadRequest()
Request reloading the 3D view.
void Process_Special_Functions(wxCommandEvent &event)
EVT_TOOL_RANGE(ID_START_COMMAND_3D, ID_MENU_COMMAND_END, EDA_3D_VIEWER::Process_Special_Functions) EVT_UPDATE_UI_RANGE(ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.