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 #include "../3d_viewer_id.h"
32 #include <project.h>
33 #include <gestfich.h>
35 #include <wx/colordlg.h>
36 #include <wx/colourdata.h>
37 #include <lru_cache.h>
38 #include "../common_ogl/cogl_att_list.h"
39 #include <hotkeys_basic.h>
40 #include <wx/toolbar.h>
41 #include <bitmaps.h>
42 #include <pgm_base.h>
43 
44 
52 const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
53 
54 
55 // Key to store 3D Viewer config
56 
57 static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
58 static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
59 static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
60 
61 static const wxChar keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
62 static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
63 static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
64 
65 static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" );
66 static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" );
67 static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" );
68 
69 static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" );
70 static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" );
71 static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" );
72 
73 static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" );
74 static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" );
75 static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" );
76 
77 static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
78 static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
79 static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
80 
81 static const wxChar keyBoardBodyColor_Red[] = wxT( "BoardBodyColor_Red" );
82 static const wxChar keyBoardBodyColor_Green[] = wxT( "BoardBodyColor_Green" );
83 static const wxChar keyBoardBodyColor_Blue[] = wxT( "BoardBodyColor_Blue" );
84 
85 static const wxChar keyMousewheelPanning[] = wxT( "MousewheelPAN3D" );
86 
87 static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
88 static const wxChar keyRenderEngine[] = wxT( "RenderEngine" );
89 //static const wxChar keyRenderTextures[] = wxT( "Render_Textures" );
90 static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
91 
92 static const wxChar keyRenderOGL_ShowCopperTck[]= wxT( "Render_OGL_ShowCopperThickness" );
93 static const wxChar keyRenderOGL_ShowModelBBox[]= wxT( "Render_OGL_ShowModelBoudingBoxes" );
94 
95 static const wxChar keyRenderRAY_Shadows[] = wxT( "Render_RAY_Shadows" );
96 static const wxChar keyRenderRAY_Backfloor[] = wxT( "Render_RAY_Backfloor" );
97 static const wxChar keyRenderRAY_Refractions[] = wxT( "Render_RAY_Refractions" );
98 static const wxChar keyRenderRAY_Reflections[] = wxT( "Render_RAY_Reflections" );
99 static const wxChar keyRenderRAY_PostProcess[] = wxT( "Render_RAY_PostProcess" );
100 static const wxChar keyRenderRAY_AAliasing[] = wxT( "Render_RAY_AntiAliasing" );
101 static const wxChar keyRenderRAY_ProceduralT[] = wxT( "Render_RAY_ProceduralTextures" );
102 
103 static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
104 static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
105 static const wxChar keyShowZones[] = wxT( "ShowZones" );
106 static const wxChar keyShowFootprints_Normal[] = wxT( "ShowFootprints_Normal" );
107 static const wxChar keyShowFootprints_Insert[] = wxT( "ShowFootprints_Insert" );
108 static const wxChar keyShowFootprints_Virtual[] = wxT( "ShowFootprints_Virtual" );
109 static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
110 static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
111 static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
112 static const wxChar keyShowSolderPasteLayers[] = wxT( "ShowSolderPasteLayers" );
113 static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
114 static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
115 static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
116 
117 
118 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
119 
120  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
121  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
122 
124 
127 
129 
133 
136 
137  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
138 
148 
151 END_EVENT_TABLE()
152 
153 
155  const wxString &aTitle, long style ) :
156  KIWAY_PLAYER( aKiway, aParent,
157  FRAME_PCB_DISPLAY3D, aTitle,
158  wxDefaultPosition, wxDefaultSize,
159  style, VIEWER3D_FRAMENAME )
160 {
161  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle );
162 
163  m_canvas = NULL;
164  m_disable_ray_tracing = false;
165 
166  // Give it an icon
167  wxIcon icon;
168  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
169  SetIcon( icon );
170 
171  bool option;
172  Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
173  m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, option );
174 
175  LoadSettings( config() );
176  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
177 
178  // Create the status line
179  static const int status_dims[4] = { -1, 130, 130, 170 };
180 
181  wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
182  SetStatusWidths( arrayDim( status_dims ), status_dims );
183 
184  m_canvas = new EDA_3D_CANVAS( this,
186  aParent->GetBoard(),
187  m_settings,
188  Prj().Get3DCacheManager() );
189 
190  if( m_canvas )
191  m_canvas->SetStatusBar( status_bar );
192 
193  CreateMenuBar();
194  ReCreateMainToolbar();
195 
196  m_auimgr.SetManagedWindow( this );
197 
198  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
199  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
200 
201  m_auimgr.Update();
202 
203  m_mainToolBar->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ),
204  NULL, this );
205 
206  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
207  // in order to receive mouse events. Otherwise, the user has to click somewhere on
208  // the canvas before it will respond to mouse wheel events.
209  if( m_canvas )
210  m_canvas->SetFocus();
211 }
212 
213 
215 {
216  m_mainToolBar->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( EDA_3D_VIEWER::OnKeyEvent ),
217  NULL, this );
218 
219  m_auimgr.UnInit();
220 
221  // m_canvas delete will be called by wxWidget manager
222  //delete m_canvas;
223  //m_canvas = 0;
224 }
225 
226 
228 {
229  // This will schedule a request to load later
230  if( m_canvas )
231  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
232 }
233 
234 
235 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
236 {
237  ReloadRequest();
238 
239  // After the ReloadRequest call, the refresh often takes a bit of time,
240  // and it is made here only on request.
241  if( aForceImmediateRedraw )
242  m_canvas->Refresh();
243 }
244 
245 
246 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
247 {
248  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
249 
250  Close( true );
251 }
252 
253 
254 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
255 {
256  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnCloseWindow" );
257 
258  if( m_canvas )
259  m_canvas->Close();
260 
261  // m_canvas delete will be called by wxWidget manager
262  //delete m_canvas;
263  //m_canvas = 0;
264 
265  Destroy();
266  event.Skip( true );
267 }
268 
269 #define ROT_ANGLE 10.0
270 
271 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
272 {
273  int id = event.GetId();
274  bool isChecked = event.IsChecked();
275 
276  wxLogTrace( m_logTrace,
277  "EDA_3D_VIEWER::Process_Special_Functions id %d isChecked %d",
278  id, isChecked );
279 
280  if( m_canvas == NULL )
281  return;
282 
283  switch( id )
284  {
285  case ID_RELOAD3D_BOARD:
286  NewDisplay( true );
287  break;
288 
289  case ID_ROTATE3D_X_POS:
290  m_settings.CameraGet().RotateX( glm::radians(ROT_ANGLE) );
292  break;
293 
294  case ID_ROTATE3D_X_NEG:
295  m_settings.CameraGet().RotateX( -glm::radians(ROT_ANGLE) );
297  break;
298 
299  case ID_ROTATE3D_Y_POS:
300  m_settings.CameraGet().RotateY( glm::radians(ROT_ANGLE) );
302  break;
303 
304  case ID_ROTATE3D_Y_NEG:
305  m_settings.CameraGet().RotateY( -glm::radians(ROT_ANGLE) );
307  break;
308 
309  case ID_ROTATE3D_Z_POS:
310  m_settings.CameraGet().RotateZ( glm::radians(ROT_ANGLE) );
312  break;
313 
314  case ID_ROTATE3D_Z_NEG:
315  m_settings.CameraGet().RotateZ( -glm::radians(ROT_ANGLE) );
317  break;
318 
319  case ID_MOVE3D_LEFT:
320  m_canvas->SetView3D( WXK_LEFT );
321  return;
322 
323  case ID_MOVE3D_RIGHT:
324  m_canvas->SetView3D( WXK_RIGHT );
325  return;
326 
327  case ID_MOVE3D_UP:
328  m_canvas->SetView3D( WXK_UP );
329  return;
330 
331  case ID_MOVE3D_DOWN:
332  m_canvas->SetView3D( WXK_DOWN );
333  return;
334 
335  case ID_ORTHO:
338  return;
339 
343  takeScreenshot( event );
344  return;
345 
347  if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ),
348  nullptr ) )
349  {
352  else
353  NewDisplay( true );
354  }
355  return;
356 
358  if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ), nullptr ) )
359  {
362  else
363  NewDisplay( true );
364  }
365  return;
366 
369  return;
370 
373  return;
374 
377  return;
378 
381  break;
382 
385  break;
386 
389  NewDisplay( true );
390  return;
391 
394  NewDisplay( true );
395  return;
396 
399  NewDisplay( true );
400  return;
401 
404  NewDisplay( true );
405  return;
406 
409  NewDisplay( true );
410  return;
411 
415  return;
416 
420  return;
421 
424  NewDisplay( true );
425  return;
426 
429  NewDisplay( true );
430  return;
431 
435  return;
436 
440  return;
441 
444  NewDisplay( true );
445  return;
446 
450  return;
451 
453  m_settings.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
454  NewDisplay( true );
455  return;
456 
458  m_settings.SetFlag( FL_AXIS, isChecked );
460  return;
461 
464  NewDisplay( true );
465  return;
466 
469  NewDisplay( true );
470  return;
471 
474  NewDisplay( true );
475  return;
476 
478  m_settings.SetFlag( FL_ZONE, isChecked );
479  NewDisplay( true );
480  return;
481 
483  m_settings.SetFlag( FL_ADHESIVE, isChecked );
484  NewDisplay( true );
485  return;
486 
488  m_settings.SetFlag( FL_SILKSCREEN, isChecked );
489  NewDisplay( true );
490  return;
491 
493  m_settings.SetFlag( FL_SOLDERMASK, isChecked );
494  NewDisplay( true );
495  return;
496 
498  m_settings.SetFlag( FL_SOLDERPASTE, isChecked );
499  NewDisplay( true );
500  return;
501 
503  m_settings.SetFlag( FL_COMMENTS, isChecked );
504  NewDisplay( true );
505  return;
506 
507  case ID_MENU3D_ECO_ONOFF:
508  m_settings.SetFlag( FL_ECO, isChecked );
509  NewDisplay( true );
510  return;
511 
513  {
514  // Reload settings with a dummy config, so it will load the defaults
515  wxConfig *fooconfig = new wxConfig( "FooBarApp" );
516  LoadSettings( fooconfig );
517  delete fooconfig;
518 
519  // Tell canvas that we (may have) changed the render engine
521 
522  NewDisplay( true );
523  }
524  return;
525 
527  {
528  DisplayHotKeys();
529  }
530  return;
531 
532  default:
533  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
534  return;
535  }
536 }
537 
538 
539 void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
540 {
541  int id = event.GetId();
542 
543  wxASSERT( id < ID_MENU3D_GRID_END );
544  wxASSERT( id > ID_MENU3D_GRID );
545 
546  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::On3DGridSelection id %d", id );
547 
548  switch( id )
549  {
552  break;
553 
556  break;
557 
558  case ID_MENU3D_GRID_5_MM:
560  break;
561 
564  break;
565 
566  case ID_MENU3D_GRID_1_MM:
568  break;
569 
570  default:
571  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" );
572  return;
573  }
574 
575  if( m_canvas )
577 }
578 
579 
580 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
581 {
582  const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
583 
584  if( old_engine == RENDER_ENGINE_OPENGL_LEGACY )
586  else
588 
589  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
591  "Ray Trace" : "OpenGL Legacy" );
592 
593  if( old_engine != m_settings.RenderEngineGet() )
594  {
596  }
597 }
598 
599 
600 void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
601 {
602  int id = event.GetId();
603 
604  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::ProcessZoom id:%d", id );
605 
606  if( m_canvas == NULL )
607  return;
608 
609  switch( id )
610  {
611  case ID_ZOOM_PAGE:
612  m_canvas->SetView3D( WXK_HOME );
613  break;
614 
615  case ID_ZOOM_IN:
616  m_canvas->SetView3D( WXK_F1 );
617  break;
618 
619  case ID_ZOOM_OUT:
620  m_canvas->SetView3D( WXK_F2 );
621  break;
622 
623  case ID_ZOOM_REDRAW:
625  break;
626 
627  default:
628  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::ProcessZoom()" );
629  return;
630  }
631 
633 }
634 
635 
636 void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
637 {
638  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
639 
640  m_disable_ray_tracing = true;
642 }
643 
644 
645 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
646 {
647  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
648 
649  if( m_canvas )
650  {
651  // Reload data if 3D frame shows a board,
652  // because it can be changed since last frame activation
655 
656  // Activates again the focus of the canvas so it will catch mouse and key events
657  m_canvas->SetFocus();
658  }
659 
660  event.Skip(); // required under wxMAC
661 }
662 
663 
664 void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
665 {
666  // Activates again the focus of the canvas so it will catch mouse and key events
667  if( m_canvas )
668  m_canvas->SetFocus();
669 
670  event.Skip();
671 }
672 
673 
674 void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg )
675 {
677 
678  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
679 
680  aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
681  aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
682  aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
683 
684  aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
685  aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
686  aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
687 
688  // m_SolderMaskColor default value = dark grey-green
689  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColor.r, 100.0 * 0.2 / 255.0 );
690  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColor.g, 255.0 * 0.2 / 255.0 );
691  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColor.b, 180.0 * 0.2 / 255.0 );
692 
693  // m_SolderPasteColor default value = light grey
694  aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 /255.0 );
695  aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 /255.0 );
696  aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 /255.0 );
697 
698  // m_SilkScreenColor default value = white
699  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColor.r, 0.9 );
700  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColor.g, 0.9 );
701  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColor.b, 0.9 );
702 
703  // m_CopperColor default value = gold
704  aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
705  aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
706  aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 );
707 
708  // m_BoardBodyColor default value = FR4, in realistic mode
709  aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
710  aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
711  aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 /255.0 );
712 
713 
714  bool tmp;
715  aCfg->Read( keyShowRealisticMode, &tmp, true );
717 
718  // OpenGL options
719  aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
721 
722  aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
724 
725  // Raytracing options
726  aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
728 
729  aCfg->Read( keyRenderRAY_Backfloor, &tmp, true );
731 
732  aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
734 
735  aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
737 
738  aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
740 
741  aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
743 
744  aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
746 
747  aCfg->Read( keyShowAxis, &tmp, true );
748  m_settings.SetFlag( FL_AXIS, tmp );
749 
750  aCfg->Read( keyShowFootprints_Normal, &tmp, true );
752 
753  aCfg->Read( keyShowFootprints_Insert, &tmp, true );
755 
756  aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
758 
759  aCfg->Read( keyShowZones, &tmp, true );
760  m_settings.SetFlag( FL_ZONE, tmp );
761 
762  aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
764 
765  aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
767 
768  aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
770 
771  aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
773 
774  aCfg->Read( keyShowCommentsLayer, &tmp, true );
776 
777  aCfg->Read( keyShowEcoLayers, &tmp, true );
778  m_settings.SetFlag( FL_ECO, tmp );
779 
780  aCfg->Read( keyShowBoardBody, &tmp, true );
782 
783  int tmpi;
784  aCfg->Read( keyShowGrid, &tmpi, (int)GRID3D_NONE );
785  m_settings.GridSet( (GRID3D_TYPE)tmpi );
786 
787  aCfg->Read( keyRenderEngine, &tmpi, (int)RENDER_ENGINE_OPENGL_LEGACY );
788  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings render setting %s",
789  ( (RENDER_ENGINE)tmpi == RENDER_ENGINE_RAYTRACING ) ? "Ray Trace" : "OpenGL" );
791 
792  aCfg->Read( keyRenderMaterial, &tmpi, (int)MATERIAL_MODE_NORMAL );
794 }
795 
796 
797 void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
798 {
800 
801  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
802 
803  aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
804  aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
805  aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
806 
807  aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
808  aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
809  aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
810 
814 
818 
822 
823  aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
825  aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
826 
830 
832 
833  aCfg->Write( keyRenderEngine, (int)m_settings.RenderEngineGet() );
834  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings render setting %s",
835  ( m_settings.RenderEngineGet() == RENDER_ENGINE_RAYTRACING ) ? "Ray Trace" : "OpenGL" );
836 
837  aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() );
838 
839  // OpenGL options
840  aCfg->Write( keyRenderOGL_ShowCopperTck,
842  aCfg->Write( keyRenderOGL_ShowModelBBox,
844 
845  // Raytracing options
853 
854  aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
855  aCfg->Write( keyShowGrid, (int)m_settings.GridGet() );
856 
860 
861  aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
867  aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
869 }
870 
871 
872 void EDA_3D_VIEWER::OnLeftClick( wxDC *DC, const wxPoint &MousePos )
873 {
874  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnLeftClick" );
875  // Do nothing
876 }
877 
878 
879 void EDA_3D_VIEWER::OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu )
880 {
881  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRightClick" );
882  // Do nothing
883 }
884 
885 
886 void EDA_3D_VIEWER::OnKeyEvent( wxKeyEvent& event )
887 {
888  if( m_canvas )
889  return m_canvas->OnKeyEvent( event );
890 
891  event.Skip();
892 }
893 
894 
895 void EDA_3D_VIEWER::RedrawActiveWindow( wxDC *DC, bool EraseBg )
896 {
897  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RedrawActiveWindow" );
898  // Do nothing
899 }
900 
901 
902 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
903 {
904  wxString fullFileName;
905  bool fmt_is_jpeg = false;
906 
907  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
908  fmt_is_jpeg = true;
909 
910  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
911  {
912  // Remember path between saves during this session only.
913  const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
914  const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
915 
916  // First time path is set to the project path.
917  if( !m_defaultSaveScreenshotFileName.IsOk() )
919 
920  m_defaultSaveScreenshotFileName.SetExt( ext );
921 
922  wxFileDialog dlg( this, _( "3D Image File Name" ),
924  m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
925  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
926 
927  if( dlg.ShowModal() == wxID_CANCEL )
928  return;
929 
930  m_defaultSaveScreenshotFileName = dlg.GetPath();
931 
932  if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
933  m_defaultSaveScreenshotFileName.SetExt( ext );
934 
935  fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
936 
937  // Be sure the screen area destroyed by the file dialog is redrawn
938  // before making a screen copy.
939  // Without this call, under Linux the screen refresh is made to late.
940  wxYield();
941  }
942 
943  // Be sure we have the latest 3D view (remember 3D view is buffered)
944  Refresh();
945  wxYield();
946 
947  // Build image from the 3D buffer
948  wxWindowUpdateLocker noUpdates( this );
949 
950  wxImage screenshotImage;
951 
952  if( m_canvas )
953  m_canvas->GetScreenshot( screenshotImage );
954 
955  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
956  {
957  wxBitmap bitmap( screenshotImage );
958 
959  if( wxTheClipboard->Open() )
960  {
961  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
962 
963  if( !wxTheClipboard->SetData( dobjBmp ) )
964  wxMessageBox( _( "Failed to copy image to clipboard" ) );
965 
966  wxTheClipboard->Flush(); /* the data in clipboard will stay
967  * available after the application exits */
968  wxTheClipboard->Close();
969  }
970  }
971  else
972  {
973  if( !screenshotImage.SaveFile( fullFileName,
974  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
975  wxMessageBox( _( "Can't save file" ) );
976 
977  screenshotImage.Destroy();
978  }
979 
980 }
981 
982 
984 {
985  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
986 
987  if( m_canvas )
989 }
990 
991 
992 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
993  CUSTOM_COLORS_LIST* aPredefinedColors )
994 {
995  KIGFX::COLOR4D newcolor;
996  KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, 1.0 );
997 
998  DIALOG_COLOR_PICKER picker( this, oldcolor, false, aPredefinedColors );
999 
1000  if( picker.ShowModal() != wxID_OK )
1001  return false;
1002 
1003  newcolor = picker.GetColor();
1004 
1005  if( newcolor == oldcolor )
1006  return false;
1007 
1008  aColor.r = newcolor.r;
1009  aColor.g = newcolor.g;
1010  aColor.b = newcolor.b;
1011 
1012  return true;
1013 }
1014 
1015 
1017 {
1018  CUSTOM_COLORS_LIST definedColors;
1019  definedColors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
1020  definedColors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
1021 
1023  _( "Solder Mask Color" ), &definedColors );
1024 
1025  if( change )
1026  NewDisplay( true );
1027 
1028  return change;
1029 }
1030 
1031 
1033 {
1034  CUSTOM_COLORS_LIST definedColors;
1035 
1036  definedColors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, "Green" ) );
1037  definedColors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, "Light Green" ) );
1038  definedColors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0,
1039  "Saturated Green" ) );
1040  definedColors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, "Red" ) );
1041  definedColors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0,
1042  "Red Light Orange" ) );
1043  definedColors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, "Red 2" ) );
1044  definedColors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, "Blue" ) );
1045  definedColors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, "Light blue 1" ) );
1046  definedColors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, "Light blue 2" ) );
1047  definedColors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0,
1048  "Green blue (dark)" ) );
1049  definedColors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, "Black" ) );
1050  definedColors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, "White" ) );
1051  definedColors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, "Purple" ) );
1052  definedColors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, "Purple Dark" ) );
1053 
1055  _( "Solder Mask Color" ),
1056  &definedColors );
1057 
1058  if( change )
1059  NewDisplay( true );
1060 
1061  return change;
1062 }
1063 
1064 
1066 {
1067  CUSTOM_COLORS_LIST definedColors;
1068 
1069  definedColors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
1070  definedColors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
1071  definedColors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1072  definedColors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
1073 
1074  bool change = Set3DColorFromUser( m_settings.m_CopperColor, _( "Copper Color" ),
1075  &definedColors );
1076 
1077  if( change )
1078  NewDisplay( true );
1079 
1080  return change;
1081 }
1082 
1083 
1085 {
1086  CUSTOM_COLORS_LIST definedColors;
1087 
1088  definedColors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0,
1089  "FR4 natural, dark" ) );
1090  definedColors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, "FR4 natural" ) );
1091  definedColors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, "brown/red" ) );
1092  definedColors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 1" ) );
1093  definedColors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, "brown 2" ) );
1094  definedColors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 3" ) );
1095  definedColors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, "green 1" ) );
1096  definedColors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, "green 2" ) );
1097 
1098  bool change = Set3DColorFromUser( m_settings.m_BoardBodyColor, _( "Board Body Color" ),
1099  &definedColors );
1100  if( change )
1101  NewDisplay( true );
1102 
1103  return change;
1104 }
1105 
1106 
1108 {
1109  CUSTOM_COLORS_LIST definedColors;
1110 
1111  definedColors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
1112  definedColors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1113  definedColors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
1114 
1116  _( "Solder Paste Color" ), &definedColors );
1117 
1118  if( change )
1119  NewDisplay( true );
1120 
1121  return change;
1122 }
1123 
1124 
1125 void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent )
1126 {
1127  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIEngine %s %s",
1128  ( !m_disable_ray_tracing ) ? "enable" : "disable",
1130  "Ray Trace" : "OpenGL Legacy" );
1131 
1132  aEvent.Enable( !m_disable_ray_tracing );
1134 }
1135 
1136 
1137 void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent )
1138 {
1139  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIMaterial() id %d", aEvent.GetId() );
1140 
1141  // Set the state of toggle menus according to the current display options
1142  switch( aEvent.GetId() )
1143  {
1145  aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL );
1146  break;
1147 
1150  break;
1151 
1153  aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE );
1154  break;
1155 
1156  default:
1157  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
1158  }
1159 }
1160 
1161 
1162 void EDA_3D_VIEWER::OnUpdateUIOpenGL( wxUpdateUIEvent& aEvent )
1163 {
1164  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIOpenGL() id %d", aEvent.GetId() );
1165 
1166  // OpenGL
1167  switch( aEvent.GetId() )
1168  {
1171  break;
1172 
1175  break;
1176 
1177  default:
1178  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIOpenGL()" );
1179  }
1180 }
1181 
1182 
1183 void EDA_3D_VIEWER::OnUpdateUIRayTracing( wxUpdateUIEvent& aEvent )
1184 {
1185  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnUpdateUIRayTracing() id %d", aEvent.GetId() );
1186 
1187  // Raytracing
1188  switch( aEvent.GetId() )
1189  {
1191  aEvent.Check( m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
1192  break;
1193 
1196  break;
1197 
1200  break;
1201 
1204  break;
1205 
1208  break;
1209 
1212  break;
1213 
1216  break;
1217 
1218  default:
1219  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
1220  }
1221 }
1222 
1223 
1224 void EDA_3D_VIEWER::OnUpdateUIAxis( wxUpdateUIEvent& aEvent )
1225 {
1226  aEvent.Check( m_settings.GetFlag( FL_AXIS ) );
1227 }
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:120
static const wxChar keyShowBoardBody[]
Use only diffuse material properties.
Definition: 3d_enums.h:93
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_MODEDIT_INSERT_MODULE_IN_BOARD
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
Store all the settings and options to be used by the renders.
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
Function LoadSettings loads 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[]
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file.
void RedrawActiveWindow(wxDC *DC, bool EraseBg)
Definition: id.h:241
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
Function SaveSettings 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.
static const wxChar keyShowRealisticMode[]
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
The canvas where the openGL context will be rendered.
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 OnKeyEvent(wxKeyEvent &event)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
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)
Function LoadSettings loads 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:49
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)
Template define a least-recently-used cache algo based on wxHashMap and wxString http://docs....
static const wxChar keyBgColor_Green[]
static const wxChar keyBoardBodyColor_Blue[]
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
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:189
Specialization of the wxAuiPaneInfo class for KiCad panels.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
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:99
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
Filename to propose for save a screenshot.
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void ProcessZoom(wxCommandEvent &event)
#define ROT_ANGLE
static const wxChar keySMaskColor_Blue[]
Class EDA_BASE_FRAME is 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
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[]
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.
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
void takeScreenshot(wxCommandEvent &event)
Create a Screenshot of the current 3D view.