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 
25 #include "eda_3d_viewer.h"
26 
27 
28 #include "../3d_viewer_id.h"
29 #include "../common_ogl/cogl_att_list.h"
30 #include <3d_actions.h>
31 #include <bitmaps.h>
34 #include <class_board.h>
35 #include <dpi_scaling.h>
36 #include <gestfich.h>
37 #include <hotkeys_basic.h>
38 #include <pgm_base.h>
39 #include <project.h>
40 #include <tool/common_control.h>
41 #include <tool/tool_manager.h>
43 #include <wx/colordlg.h>
44 #include <wx/colour.h>
45 #include <wx/string.h>
46 #include <wx/toolbar.h>
47 
48 
56 const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
57 
58 
59 // Key to store 3D Viewer config
60 
61 static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
62 static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
63 static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
64 
65 static const wxChar keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
66 static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
67 static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
68 
69 static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" );
70 static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" );
71 static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" );
72 
73 static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" );
74 static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" );
75 static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" );
76 
77 static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" );
78 static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" );
79 static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" );
80 
81 static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
82 static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
83 static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
84 
85 static const wxChar keyBoardBodyColor_Red[] = wxT( "BoardBodyColor_Red" );
86 static const wxChar keyBoardBodyColor_Green[] = wxT( "BoardBodyColor_Green" );
87 static const wxChar keyBoardBodyColor_Blue[] = wxT( "BoardBodyColor_Blue" );
88 
89 static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
90 static const wxChar keyRenderEngine[] = wxT( "RenderEngine" );
91 static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
92 
93 static const wxChar keyRenderOGL_ShowCopperTck[]= wxT( "Render_OGL_ShowCopperThickness" );
94 static const wxChar keyRenderOGL_ShowModelBBox[]= wxT( "Render_OGL_ShowModelBoudingBoxes" );
95 
96 static const wxChar keyRenderRAY_Shadows[] = wxT( "Render_RAY_Shadows" );
97 static const wxChar keyRenderRAY_Backfloor[] = wxT( "Render_RAY_Backfloor" );
98 static const wxChar keyRenderRAY_Refractions[] = wxT( "Render_RAY_Refractions" );
99 static const wxChar keyRenderRAY_Reflections[] = wxT( "Render_RAY_Reflections" );
100 static const wxChar keyRenderRAY_PostProcess[] = wxT( "Render_RAY_PostProcess" );
101 static const wxChar keyRenderRAY_AAliasing[] = wxT( "Render_RAY_AntiAliasing" );
102 static const wxChar keyRenderRAY_ProceduralT[] = wxT( "Render_RAY_ProceduralTextures" );
103 
104 static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
105 static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
106 static const wxChar keyShowZones[] = wxT( "ShowZones" );
107 static const wxChar keyShowFootprints_Normal[] = wxT( "ShowFootprints_Normal" );
108 static const wxChar keyShowFootprints_Insert[] = wxT( "ShowFootprints_Insert" );
109 static const wxChar keyShowFootprints_Virtual[] = wxT( "ShowFootprints_Virtual" );
110 static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
111 static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
112 static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
113 static const wxChar keyShowSolderPasteLayers[] = wxT( "ShowSolderPasteLayers" );
114 static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
115 static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
116 static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
117 
118 
119 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
120 
121  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
122  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
123 
125 
128 
130 
131  EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER::Exit3DFrame )
134 
136 
141 
142  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
143 END_EVENT_TABLE()
144 
145 
147  const wxString &aTitle, long style ) :
148  KIWAY_PLAYER( aKiway, aParent,
149  FRAME_PCB_DISPLAY3D, aTitle,
150  wxDefaultPosition, wxDefaultSize,
151  style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) )
152 {
153  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::EDA_3D_VIEWER %s", aTitle );
154 
155  m_canvas = NULL;
156  m_disable_ray_tracing = false;
157  m_mainToolBar = nullptr;
158  m_AboutTitle = "3D Viewer";
159 
160  // Give it an icon
161  wxIcon icon;
162  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
163  SetIcon( icon );
164 
165  LoadSettings( config() );
166  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
167 
168  // Create the status line
169  static const int status_dims[4] = { -1, 130, 130, 170 };
170 
171  wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
172  SetStatusWidths( arrayDim( status_dims ), status_dims );
173 
174  m_canvas = new EDA_3D_CANVAS( this,
176  aParent->GetBoard(),
177  m_settings,
178  Prj().Get3DCacheManager() );
179 
180  if( m_canvas )
181  m_canvas->SetStatusBar( status_bar );
182 
183  // Some settings need the canvas
184  loadCommonSettings();
185 
186  // Create the manager
187  m_toolManager = new TOOL_MANAGER;
188  m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, this );
189 
190  // Register tools
191  m_toolManager->RegisterTool( new COMMON_CONTROL );
192  m_actions = new EDA_3D_ACTIONS();
193  m_toolManager->InitTools();
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 = nullptr;
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 = nullptr;
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:
369 
372  else
374  return;
375 
379  takeScreenshot( event );
380  return;
381 
383  if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ),
384  nullptr ) )
385  {
388  else
389  NewDisplay( true );
390  }
391  return;
392 
394  if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ), nullptr ) )
395  {
398  else
399  NewDisplay( true );
400  }
401  return;
402 
405  return;
406 
409  return;
410 
413  return;
414 
417  break;
418 
421  break;
422 
425  NewDisplay( true );
426  break;
427 
430  NewDisplay( true );
431  return;
432 
435  NewDisplay( true );
436  return;
437 
440  NewDisplay( true );
441  return;
442 
445  NewDisplay( true );
446  return;
447 
450  NewDisplay( true );
451  return;
452 
456  return;
457 
461  return;
462 
465  NewDisplay( true );
466  return;
467 
470  NewDisplay( true );
471  return;
472 
476  return;
477 
481  return;
482 
485  NewDisplay( true );
486  return;
487 
491  return;
492 
494  m_settings.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
495  NewDisplay( true );
496  return;
497 
499  m_settings.SetFlag( FL_AXIS, isChecked );
501  return;
502 
505  NewDisplay( true );
506  return;
507 
510  NewDisplay( true );
511  return;
512 
515  NewDisplay( true );
516  return;
517 
519  m_settings.SetFlag( FL_ZONE, isChecked );
520  NewDisplay( true );
521  return;
522 
524  m_settings.SetFlag( FL_ADHESIVE, isChecked );
525  NewDisplay( true );
526  return;
527 
529  m_settings.SetFlag( FL_SILKSCREEN, isChecked );
530  NewDisplay( true );
531  return;
532 
534  m_settings.SetFlag( FL_SOLDERMASK, isChecked );
535  NewDisplay( true );
536  return;
537 
539  m_settings.SetFlag( FL_SOLDERPASTE, isChecked );
540  NewDisplay( true );
541  return;
542 
544  m_settings.SetFlag( FL_COMMENTS, isChecked );
545  NewDisplay( true );
546  return;
547 
548  case ID_MENU3D_ECO_ONOFF:
549  m_settings.SetFlag( FL_ECO, isChecked );
550  NewDisplay( true );
551  return;
552 
554  {
555  // Reload settings with a dummy config, so it will load the defaults
556  wxConfig *fooconfig = new wxConfig( "FooBarApp" );
557  LoadSettings( fooconfig );
558  delete fooconfig;
559 
560  // Tell canvas that we (may have) changed the render engine
562 
563  NewDisplay( true );
564  }
565  return;
566 
567  default:
568  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::Process_Special_Functions()" );
569  return;
570  }
571 }
572 
573 
574 void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
575 {
576  int id = event.GetId();
577 
578  wxASSERT( id < ID_MENU3D_GRID_END );
579  wxASSERT( id > ID_MENU3D_GRID );
580 
581  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::On3DGridSelection id %d", id );
582 
583  switch( id )
584  {
587  break;
590  break;
591  case ID_MENU3D_GRID_5_MM:
593  break;
596  break;
597  case ID_MENU3D_GRID_1_MM:
599  break;
600 
601  default:
602  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" );
603  }
604 
605  int menu_ids[]
606  {
609  };
610 
611  // Refresh checkmarks
612  wxMenuBar* menuBar = GetMenuBar();
613 
614  for( int ii = 0; ii < 5; ii++ )
615  {
616  wxMenuItem* item = menuBar->FindItem( menu_ids[ii] );
617  item->Check( menu_ids[ii] == id );
618  }
619 
620  if( m_canvas )
622 }
623 
624 
625 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
626 {
627  const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
628 
629  if( old_engine == RENDER_ENGINE::OPENGL_LEGACY )
631  else
633 
634  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
635  ( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
636  "OpenGL Legacy" );
637 
638  if( old_engine != m_settings.RenderEngineGet() )
639  {
641  }
642 }
643 
644 
645 void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
646 {
647  int id = event.GetId();
648 
649  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::ProcessZoom id:%d", id );
650 
651  if( m_canvas == NULL )
652  return;
653 
654  switch( id )
655  {
656  case ID_ZOOM_PAGE: m_canvas->SetView3D( WXK_HOME ); break;
657  case ID_ZOOM_IN: m_canvas->SetView3D( WXK_F1 ); break;
658  case ID_ZOOM_OUT: m_canvas->SetView3D( WXK_F2 ); break;
659  case ID_ZOOM_REDRAW: m_canvas->Request_refresh(); break;
660  default: wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::ProcessZoom()" );
661  }
662 
664 }
665 
666 
667 void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent )
668 {
669  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ );
670 
671  m_disable_ray_tracing = true;
673 }
674 
675 
676 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
677 {
678  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnActivate" );
679 
680  if( m_canvas )
681  {
682  // Reload data if 3D frame shows a board,
683  // because it can be changed since last frame activation
686 
687  // Activates again the focus of the canvas so it will catch mouse and key events
688  m_canvas->SetFocus();
689  }
690 
691  event.Skip(); // required under wxMAC
692 }
693 
694 
695 void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
696 {
697  // Activates again the focus of the canvas so it will catch mouse and key events
698  if( m_canvas )
699  m_canvas->SetFocus();
700 
701  event.Skip();
702 }
703 
704 
705 void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg )
706 {
708 
709  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
710 
711  aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
712  aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
713  aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
714 
715  aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
716  aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
717  aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
718 
719  // m_SolderMaskColorTop default value = dark grey-green
720  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColorTop.r, 100.0 * 0.2 / 255.0 );
721  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColorTop.g, 255.0 * 0.2 / 255.0 );
722  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColorTop.b, 180.0 * 0.2 / 255.0 );
723 
724  // m_SolderMaskColorBot default value = dark grey-green
725  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColorBot.r, 100.0 * 0.2 / 255.0 );
726  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColorBot.g, 255.0 * 0.2 / 255.0 );
727  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColorBot.b, 180.0 * 0.2 / 255.0 );
728 
729  // m_SolderPasteColor default value = light grey
730  aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 / 255.0 );
731  aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 / 255.0 );
732  aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 / 255.0 );
733 
734  // m_SilkScreenColorTop default value = white
735  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColorTop.r, 0.9 );
736  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColorTop.g, 0.9 );
737  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColorTop.b, 0.9 );
738 
739  // m_SilkScreenColorBot default value = white
740  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColorBot.r, 0.9 );
741  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColorBot.g, 0.9 );
742  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColorBot.b, 0.9 );
743 
744  // m_CopperColor default value = gold
745  aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
746  aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
747  aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 );
748 
749  // m_BoardBodyColor default value = FR4, in realistic mode
750  aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
751  aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
752  aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 / 255.0 );
753 
754 
755  bool tmp;
756  aCfg->Read( keyShowRealisticMode, &tmp, true );
758 
759  // OpenGL options
760  aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
762 
763  aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
765 
766  // Raytracing options
767  aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
769 
770  aCfg->Read( keyRenderRAY_Backfloor, &tmp, false );
772 
773  aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
775 
776  aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
778 
779  aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
781 
782  aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
784 
785  aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
787 
788  aCfg->Read( keyShowAxis, &tmp, true );
789  m_settings.SetFlag( FL_AXIS, tmp );
790 
791  aCfg->Read( keyShowFootprints_Normal, &tmp, true );
793 
794  aCfg->Read( keyShowFootprints_Insert, &tmp, true );
796 
797  aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
799 
800  aCfg->Read( keyShowZones, &tmp, true );
801  m_settings.SetFlag( FL_ZONE, tmp );
802 
803  aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
805 
806  aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
808 
809  aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
811 
812  aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
814 
815  aCfg->Read( keyShowCommentsLayer, &tmp, true );
817 
818  aCfg->Read( keyShowEcoLayers, &tmp, true );
819  m_settings.SetFlag( FL_ECO, tmp );
820 
821  aCfg->Read( keyShowBoardBody, &tmp, true );
823 
824  int tmpi;
825  aCfg->Read( keyShowGrid, &tmpi, static_cast<int>( GRID3D_TYPE::NONE ) );
826  m_settings.GridSet( static_cast<GRID3D_TYPE>( tmpi ) );
827 
828  aCfg->Read( keyRenderEngine, &tmpi, static_cast<int>( RENDER_ENGINE::OPENGL_LEGACY ) );
829  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings render setting %s",
830  ( static_cast<RENDER_ENGINE>( tmpi ) == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
831  "OpenGL" );
832  m_settings.RenderEngineSet( static_cast<RENDER_ENGINE>( tmpi ) );
833 
834  aCfg->Read( keyRenderMaterial, &tmpi, static_cast<int>( MATERIAL_MODE::NORMAL ) );
835  m_settings.MaterialModeSet( static_cast<MATERIAL_MODE>( tmpi ) );
836 }
837 
838 
839 void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
840 {
842 
843  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
844 
845  aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
846  aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
847  aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
848 
849  aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
850  aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
851  aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
852 
856 
860 
864 
868 
872 
873  aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
875  aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
876 
880 
882 
883  aCfg->Write( keyRenderEngine, static_cast<int>( m_settings.RenderEngineGet() ) );
884  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings render setting %s",
885  ( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
886  "OpenGL" );
887 
888  aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() );
889 
890  // OpenGL options
891  aCfg->Write( keyRenderOGL_ShowCopperTck,
893  aCfg->Write( keyRenderOGL_ShowModelBBox,
895 
896  // Raytracing options
901  aCfg->Write(
904  aCfg->Write( keyRenderRAY_ProceduralT,
906 
907  aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
908  aCfg->Write( keyShowGrid, (int) m_settings.GridGet() );
909 
911  aCfg->Write(
914 
915  aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
921  aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
923 }
924 
925 
927 {
928  BOARD* brd = GetBoard();
929  const FAB_LAYER_COLOR* stdColors = GetColorStandardList();
930  wxColour color;
931  if( brd )
932  {
934 
935  for( BOARD_STACKUP_ITEM* stckpItem : stckp.GetList() )
936  {
937  wxString colorName = stckpItem->GetColor();
938 
939  if( colorName.StartsWith( "#" ) ) // This is a user defined color.
940  {
941  color.Set( colorName );
942  }
943  else
944  {
945  for( int i = 0; i < GetColorStandardListCount(); i++ )
946  {
947  if( stdColors[i].m_ColorName == colorName )
948  {
949  color = stdColors[i].m_Color;
950  break;
951  }
952  }
953  }
954 
955  if( color.IsOk() )
956  {
957  switch( stckpItem->GetBrdLayerId() )
958  {
959  case F_SilkS:
960  m_settings.m_SilkScreenColorTop.r = color.Red() / 255.0;
961  m_settings.m_SilkScreenColorTop.g = color.Green() / 255.0;
962  m_settings.m_SilkScreenColorTop.b = color.Blue() / 255.0;
963  break;
964  case B_SilkS:
965  m_settings.m_SilkScreenColorBot.r = color.Red() / 255.0;
966  m_settings.m_SilkScreenColorBot.g = color.Green() / 255.0;
967  m_settings.m_SilkScreenColorBot.b = color.Blue() / 255.0;
968  break;
969  case F_Mask:
970  m_settings.m_SolderMaskColorTop.r = color.Red() / 255.0;
971  m_settings.m_SolderMaskColorTop.g = color.Green() / 255.0;
972  m_settings.m_SolderMaskColorTop.b = color.Blue() / 255.0;
973  break;
974  case B_Mask:
975  m_settings.m_SolderMaskColorBot.r = color.Red() / 255.0;
976  m_settings.m_SolderMaskColorBot.g = color.Green() / 255.0;
977  m_settings.m_SolderMaskColorBot.b = color.Blue() / 255.0;
978  break;
979  default:
980  break;
981  }
982  }
983  }
984  }
985 }
986 
987 void EDA_3D_VIEWER::CommonSettingsChanged( bool aEnvVarsChanged )
988 {
989  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
990 
991  // Regen menu bars, etc
992  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
993 
994  // There is no base class that handles toolbars for this frame
996 
998 
999  NewDisplay( true );
1000 }
1001 
1002 
1003 void EDA_3D_VIEWER::OnKeyEvent( wxKeyEvent& event )
1004 {
1005  if( m_canvas )
1006  return m_canvas->OnKeyEvent( event );
1007 
1008  event.Skip();
1009 }
1010 
1011 
1012 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
1013 {
1014  wxString fullFileName;
1015  bool fmt_is_jpeg = false;
1016 
1017  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
1018  fmt_is_jpeg = true;
1019 
1020  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
1021  {
1022  // Remember path between saves during this session only.
1023  const wxString wildcard = fmt_is_jpeg ? JpegFileWildcard() : PngFileWildcard();
1024  const wxString ext = fmt_is_jpeg ? JpegFileExtension : PngFileExtension;
1025 
1026  // First time path is set to the project path.
1027  if( !m_defaultSaveScreenshotFileName.IsOk() )
1029 
1030  m_defaultSaveScreenshotFileName.SetExt( ext );
1031 
1032  wxFileDialog dlg( this, _( "3D Image File Name" ),
1034  m_defaultSaveScreenshotFileName.GetFullName(), wildcard,
1035  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1036 
1037  if( dlg.ShowModal() == wxID_CANCEL )
1038  return;
1039 
1040  m_defaultSaveScreenshotFileName = dlg.GetPath();
1041 
1042  if( m_defaultSaveScreenshotFileName.GetExt().IsEmpty() )
1043  m_defaultSaveScreenshotFileName.SetExt( ext );
1044 
1045  fullFileName = m_defaultSaveScreenshotFileName.GetFullPath();
1046 
1047  // Be sure the screen area destroyed by the file dialog is redrawn
1048  // before making a screen copy.
1049  // Without this call, under Linux the screen refresh is made to late.
1050  wxYield();
1051  }
1052 
1053  // Be sure we have the latest 3D view (remember 3D view is buffered)
1054  m_canvas->Request_refresh( true );
1055  wxYield();
1056 
1057  // Build image from the 3D buffer
1058  wxWindowUpdateLocker noUpdates( this );
1059 
1060  wxImage screenshotImage;
1061 
1062  if( m_canvas )
1063  m_canvas->GetScreenshot( screenshotImage );
1064 
1065  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
1066  {
1067  wxBitmap bitmap( screenshotImage );
1068 
1069  if( wxTheClipboard->Open() )
1070  {
1071  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
1072 
1073  if( !wxTheClipboard->SetData( dobjBmp ) )
1074  wxMessageBox( _( "Failed to copy image to clipboard" ) );
1075 
1076  wxTheClipboard->Flush(); /* the data in clipboard will stay
1077  * available after the application exits */
1078  wxTheClipboard->Close();
1079  }
1080  }
1081  else
1082  {
1083  if( !screenshotImage.SaveFile( fullFileName,
1084  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
1085  wxMessageBox( _( "Can't save file" ) );
1086 
1087  screenshotImage.Destroy();
1088  }
1089 
1090 }
1091 
1092 
1094 {
1095  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::RenderEngineChanged()" );
1096 
1097  if( m_canvas )
1099 }
1100 
1101 
1102 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
1103  CUSTOM_COLORS_LIST* aPredefinedColors )
1104 {
1105  KIGFX::COLOR4D newcolor;
1106  KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, 1.0 );
1107 
1108  DIALOG_COLOR_PICKER picker( this, oldcolor, false, aPredefinedColors );
1109 
1110  if( picker.ShowModal() != wxID_OK )
1111  return false;
1112 
1113  newcolor = picker.GetColor();
1114 
1115  if( newcolor == oldcolor )
1116  return false;
1117 
1118  aColor.r = newcolor.r;
1119  aColor.g = newcolor.g;
1120  aColor.b = newcolor.b;
1121 
1122  return true;
1123 }
1124 
1125 
1127 {
1129 
1130  colors.push_back( CUSTOM_COLOR_ITEM( 241.0/255.0, 241.0/255.0, 241.0/255.0, "White" ) );
1131  colors.push_back( CUSTOM_COLOR_ITEM( 4.0/255.0, 18.0/255.0, 21.0/255.0, "Dark" ) );
1132 
1133  if( Set3DColorFromUser( m_settings.m_SilkScreenColorTop, _( "Silkscreen Color" ), &colors ) )
1134  {
1136  NewDisplay( true );
1137  return true;
1138  }
1139 
1140  return false;
1141 }
1142 
1143 
1145 {
1147 
1148  colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, "Green" ) );
1149  colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, "Light Green" ) );
1150  colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, "Saturated Green" ) );
1151  colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, "Red" ) );
1152  colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, "Red Light Orange" ) );
1153  colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, "Red 2" ) );
1154  colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, "Blue" ) );
1155  colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, "Light blue 1" ) );
1156  colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, "Light blue 2" ) );
1157  colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, "Green blue (dark)" ) );
1158  colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, "Black" ) );
1159  colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, "White" ) );
1160  colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, "Purple" ) );
1161  colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, "Purple Dark" ) );
1162 
1163  if( Set3DColorFromUser( m_settings.m_SolderMaskColorTop, _( "Solder Mask Color" ), &colors ) )
1164  {
1166  NewDisplay( true );
1167  return true;
1168  }
1169 
1170  return false;
1171 }
1172 
1173 
1175 {
1177 
1178  colors.push_back( CUSTOM_COLOR_ITEM( 184/255.0, 115/255.0, 50/255.0, "Copper" ) );
1179  colors.push_back( CUSTOM_COLOR_ITEM( 178/255.0, 156/255.0, 0.0, "Gold" ) );
1180  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1181  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 160/255.0, 160/255.0, "Tin" ) );
1182 
1183  if( Set3DColorFromUser( m_settings.m_CopperColor, _( "Copper Color" ), &colors ) )
1184  {
1185  NewDisplay( true );
1186  return true;
1187  }
1188 
1189  return false;
1190 }
1191 
1192 
1194 {
1196 
1197  colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, "FR4 natural, dark" ) );
1198  colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, "FR4 natural" ) );
1199  colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, "brown/red" ) );
1200  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 1" ) );
1201  colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, "brown 2" ) );
1202  colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, "brown 3" ) );
1203  colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, "green 1" ) );
1204  colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, "green 2" ) );
1205 
1206  if( Set3DColorFromUser( m_settings.m_BoardBodyColor, _( "Board Body Color" ), &colors ) )
1207  {
1208  NewDisplay( true );
1209  return true;
1210  }
1211 
1212  return false;
1213 }
1214 
1215 
1217 {
1219 
1220  colors.push_back( CUSTOM_COLOR_ITEM( 128/255.0, 128/255.0, 128/255.0, "grey" ) );
1221  colors.push_back( CUSTOM_COLOR_ITEM( 213/255.0, 213/255.0, 213/255.0, "Silver" ) );
1222  colors.push_back( CUSTOM_COLOR_ITEM( 90/255.0, 90/255.0, 90/255.0, "grey 2" ) );
1223 
1224  if( Set3DColorFromUser( m_settings.m_SolderPasteColor, _( "Solder Paste Color" ), &colors ) )
1225  {
1226  NewDisplay( true );
1227  return true;
1228  }
1229 
1230  return false;
1231 }
1232 
1233 
1234 void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent )
1235 {
1237 }
1238 
1239 
1240 void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent )
1241 {
1242  // Set the state of toggle menus according to the current display options
1243  switch( aEvent.GetId() )
1244  {
1246  aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL );
1247  break;
1248 
1251  break;
1252 
1254  aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE );
1255  break;
1256 
1257  default:
1258  wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" );
1259  }
1260 }
1261 
1262 
1264 {
1265  wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
1266 
1267  wxConfigBase& cmnCfg = *Pgm().CommonSettings();
1268 
1269  {
1270  const DPI_SCALING dpi{ &cmnCfg, this };
1271  m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
1272  }
1273 
1274  {
1275  bool option;
1276  cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
1278  }
1279 }
static const wxChar keyShowSolderMaskLayers[]
static const wxChar keyShowFootprints_Normal[]
Use a gray shading based on diffuse material.
static const wxChar keyRenderRAY_ProceduralT[]
static const wxChar keyShowGrid[]
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:59
static const wxChar keyShowBoardBody[]
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:98
static const wxChar keyRenderRAY_Reflections[]
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification that common settings are updated.
std::vector< BOARD_STACKUP_ITEM * > & GetList()
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[]
this class manage the layers needed to make a physical board they are solder mask,...
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:505
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
PROJECT & Prj()
Definition: kicad.cpp:305
void OnKeyEvent(wxKeyEvent &event)
void RotateY(float aAngleInRadians)
Definition: ccamera.cpp:533
static const wxChar keyShowFootprints_Insert[]
virtual void SaveSettings(wxConfigBase *aCfg)
Saves common frame parameters to a configuration data file.
SFVEC3D m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
Definition: cinfo3d_visu.h:500
int color
Definition: DXF_plotter.cpp:61
SFVEC3D m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
Definition: cinfo3d_visu.h:501
EDA_3D_ACTIONS.
Definition: 3d_actions.h:41
Definition: id.h:200
static const wxChar keyCopperColor_Green[]
static const wxChar keyShowFootprints_Virtual[]
void SetStatusBar(wxStatusBar *aStatusBar)
Definition: eda_3d_canvas.h:81
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:60
bool IsReloadRequestPending() const
IsReloadRequestPending - Query if there is a pending reload request.
Definition: eda_3d_canvas.h:89
int GetColorStandardListCount()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
double g
Green component.
Definition: color4d.h:302
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:497
SFVEC3D m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
Definition: cinfo3d_visu.h:504
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:498
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:499
double b
Blue component.
Definition: color4d.h:303
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[]
Use only diffuse material properties.
static const wxChar keyShowSolderPasteLayers[]
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:246
void RenderEngineSet(RENDER_ENGINE aRenderEngine)
RenderEngineSet.
Definition: cinfo3d_visu.h:228
static const wxChar keySPasteColor_Red[]
static const wxChar keyShowSilkScreenLayers[]
TOOL_MANAGER.
Definition: tool_manager.h:50
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)
BOARD_STACKUP & GetStackupDescriptor()
static const wxChar keyCopperColor_Red[]
void RotateZ(float aAngleInRadians)
Definition: ccamera.cpp:540
void OnUpdateUIMaterial(wxUpdateUIEvent &aEvent)
void RotateX(float aAngleInRadians)
Definition: ccamera.cpp:526
void OnDisableRayTracing(wxCommandEvent &aEvent)
SFVEC3D m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
Definition: cinfo3d_visu.h:503
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)
#define NULL
static const wxChar keyShowZones[]
static const wxChar keyRenderMaterial[]
static const wxChar keyRenderRAY_AAliasing[]
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.
virtual void LoadSettings(wxConfigBase *aCfg)
Load common frame parameters from a configuration file.
void OnUpdateUIEngine(wxUpdateUIEvent &aEvent)
void ToggleProjection()
Definition: ccamera.cpp:447
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:50
Definition of file extensions used in Kicad.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:274
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
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
COMMON_CONTROL.
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:502
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.
static const wxChar keyRenderOGL_ShowModelBBox[]
wxString PngFileWildcard()
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
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[]
virtual void CommonSettingsChanged(bool aEnvVarsChanged)
Notification event that some of the common (suite-wide) settings have changed.
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.
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[]
PCB_EDIT_FRAME::OnUpdateSelectTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize) PCB_EDIT_FRAME
wxFileName m_defaultSaveScreenshotFileName
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
#define _(s)
Definition: 3d_actions.cpp:31
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)
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnToggleShowLayerManager GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) EVT_UPDATE_UI_RANGE(ID_TB_OPTIONS_SHOW_GBR_MODE_0
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:67
KIGFX::COLOR4D GetColor()
const FAB_LAYER_COLOR * GetColorStandardList()
const std::string PngFileExtension
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
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[]
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:56
void SynchroniseColoursWithBoard(void)
double r
Red component.
Definition: color4d.h:301
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
static const wxChar keyShowEcoLayers[]
static const wxChar keyShowCommentsLayer[]
EVT_MENU_RANGE(ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, EDA_3D_CANVAS::OnPopUpMenu) EDA_3D_CANVAS
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
static const wxChar keyRenderRAY_Shadows[]
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
Definition: eda_3d_viewer.h:50
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:69
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
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.