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-2016 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>
34 #include <wx/colordlg.h>
35 #include <wx/colourdata.h>
36 #include <lru_cache.h>
37 #include "../common_ogl/cogl_att_list.h"
38 #include <hotkeys_basic.h>
39 #include <wx/toolbar.h>
40 #include <bitmaps.h>
41 
48 const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
49 
50 
51 // Key to store 3D Viewer config
52 
53 static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
54 static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
55 static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
56 
57 static const wxChar keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
58 static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
59 static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
60 
61 static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" );
62 static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" );
63 static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" );
64 
65 static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" );
66 static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" );
67 static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" );
68 
69 static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" );
70 static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" );
71 static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" );
72 
73 static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
74 static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
75 static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
76 
77 static const wxChar keyBoardBodyColor_Red[] = wxT( "BoardBodyColor_Red" );
78 static const wxChar keyBoardBodyColor_Green[] = wxT( "BoardBodyColor_Green" );
79 static const wxChar keyBoardBodyColor_Blue[] = wxT( "BoardBodyColor_Blue" );
80 
81 static const wxChar keyMousewheelPanning[] = wxT( "MousewheelPAN3D" );
82 
83 static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
84 static const wxChar keyRenderEngine[] = wxT( "RenderEngine" );
85 static const wxChar keyRenderRemoveHoles[] = wxT( "Render_RemoveHoles" );
86 //static const wxChar keyRenderTextures[] = wxT( "Render_Textures" );
87 static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
88 
89 static const wxChar keyRenderOGL_ShowCopperTck[]= wxT( "Render_OGL_ShowCopperThickness" );
90 static const wxChar keyRenderOGL_ShowModelBBox[]= wxT( "Render_OGL_ShowModelBoudingBoxes" );
91 
92 static const wxChar keyRenderRAY_Shadows[] = wxT( "Render_RAY_Shadows" );
93 static const wxChar keyRenderRAY_Backfloor[] = wxT( "Render_RAY_Backfloor" );
94 static const wxChar keyRenderRAY_Refractions[] = wxT( "Render_RAY_Refractions" );
95 static const wxChar keyRenderRAY_Reflections[] = wxT( "Render_RAY_Reflections" );
96 static const wxChar keyRenderRAY_PostProcess[] = wxT( "Render_RAY_PostProcess" );
97 static const wxChar keyRenderRAY_AAliasing[] = wxT( "Render_RAY_AntiAliasing" );
98 static const wxChar keyRenderRAY_ProceduralT[] = wxT( "Render_RAY_ProceduralTextures" );
99 
100 static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
101 static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
102 static const wxChar keyShowZones[] = wxT( "ShowZones" );
103 static const wxChar keyShowFootprints_Normal[] = wxT( "ShowFootprints_Normal" );
104 static const wxChar keyShowFootprints_Insert[] = wxT( "ShowFootprints_Insert" );
105 static const wxChar keyShowFootprints_Virtual[] = wxT( "ShowFootprints_Virtual" );
106 static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
107 static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
108 static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
109 static const wxChar keyShowSolderPasteLayers[] = wxT( "ShowSolderPasteLayers" );
110 static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
111 static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
112 static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
113 
114 
115 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
116 
117  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
118  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
119 
122  EDA_3D_VIEWER::ProcessZoom )
123 
126  EDA_3D_VIEWER::Process_Special_Functions )
127 
128  EVT_MENU( wxID_EXIT,
129  EDA_3D_VIEWER::Exit3DFrame )
130 
133  EDA_3D_VIEWER::On3DGridSelection )
134 
137  EDA_3D_VIEWER::OnRenderEngineSelection )
138 
139  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
140 
141  EVT_UPDATE_UI_RANGE( ID_START_COMMAND_3D,
143  EDA_3D_VIEWER::OnUpdateMenus )
144 
145 END_EVENT_TABLE()
146 
147 
149  PCB_BASE_FRAME *aParent,
150  const wxString &aTitle,
151  long style ) :
152 
153  KIWAY_PLAYER( aKiway,
154  aParent,
156  aTitle,
157  wxDefaultPosition,
158  wxDefaultSize,
159  style,
161 {
162  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::EDA_3D_VIEWER %s" ), aTitle );
163 
164  m_canvas = NULL;
165  m_defaultFileName = "";
166 
167  // Give it an icon
168  wxIcon icon;
169  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
170  SetIcon( icon );
171 
172  LoadSettings( config() );
173  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
174 
175  // Create the status line
176  static const int status_dims[4] = { -1, 130, 130, 170 };
177 
178  wxStatusBar *status_bar = CreateStatusBar( DIM( status_dims ) );
179  SetStatusWidths( DIM( status_dims ), status_dims );
180 
181  CreateMenuBar();
182  ReCreateMainToolbar();
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  m_auimgr.SetManagedWindow( this );
194 
195  EDA_PANEINFO horiztb;
196  horiztb.HorizontalToolbarPane();
197 
198  m_auimgr.AddPane( m_mainToolBar,
199  wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() );
200 
201  if( m_canvas )
202  m_auimgr.AddPane( m_canvas,
203  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
204 
205  m_auimgr.Update();
206 
207  m_mainToolBar->EnableTool( ID_RENDER_CURRENT_VIEW,
208  (m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY) );
209 
210  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
211  // in order to receive mouse events. Otherwise, the user has to click somewhere on
212  // the canvas before it will respond to mouse wheel events.
213  if( m_canvas )
214  m_canvas->SetFocus();
215 }
216 
217 
219 {
220  m_auimgr.UnInit();
221 
222  // m_canvas delete will be called by wxWidget manager
223  //delete m_canvas;
224  //m_canvas = 0;
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  // This function is used by moduleframe.cpp
234  // while editing the pcb board, so it will not redraw to not slow the pcbnew
235  //m_canvas->Refresh();
236 }
237 
238 
239 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
240 {
241  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::Exit3DFrame" ) );
242 
243  Close( true );
244 }
245 
246 
247 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
248 {
249  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnCloseWindow" ) );
250 
251  if( m_canvas )
252  m_canvas->Close();
253 
254  // m_canvas delete will be called by wxWidget manager
255  //delete m_canvas;
256  //m_canvas = 0;
257 
258  Destroy();
259  event.Skip( true );
260 }
261 
262 #define ROT_ANGLE 10.0
263 
264 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
265 {
266  int id = event.GetId();
267  bool isChecked = event.IsChecked();
268 
269  wxLogTrace( m_logTrace,
270  wxT( "EDA_3D_VIEWER::Process_Special_Functions id:%d isChecked:%d" ),
271  id, isChecked );
272 
273  if( m_canvas == NULL )
274  return;
275 
276  switch( id )
277  {
280  break;
281 
282  case ID_RELOAD3D_BOARD:
283  ReloadRequest();
285  break;
286 
287  case ID_ROTATE3D_X_POS:
288  m_settings.CameraGet().RotateX( glm::radians(ROT_ANGLE) );
290  break;
291 
292  case ID_ROTATE3D_X_NEG:
293  m_settings.CameraGet().RotateX( -glm::radians(ROT_ANGLE) );
295  break;
296 
297  case ID_ROTATE3D_Y_POS:
298  m_settings.CameraGet().RotateY( glm::radians(ROT_ANGLE) );
300  break;
301 
302  case ID_ROTATE3D_Y_NEG:
303  m_settings.CameraGet().RotateY( -glm::radians(ROT_ANGLE) );
305  break;
306 
307  case ID_ROTATE3D_Z_POS:
308  m_settings.CameraGet().RotateZ( glm::radians(ROT_ANGLE) );
310  break;
311 
312  case ID_ROTATE3D_Z_NEG:
313  m_settings.CameraGet().RotateZ( -glm::radians(ROT_ANGLE) );
315  break;
316 
317  case ID_MOVE3D_LEFT:
318  m_canvas->SetView3D( WXK_LEFT );
319  return;
320 
321  case ID_MOVE3D_RIGHT:
322  m_canvas->SetView3D( WXK_RIGHT );
323  return;
324 
325  case ID_MOVE3D_UP:
326  m_canvas->SetView3D( WXK_UP );
327  return;
328 
329  case ID_MOVE3D_DOWN:
330  m_canvas->SetView3D( WXK_DOWN );
331  return;
332 
333  case ID_ORTHO:
336  return;
337 
341  takeScreenshot( event );
342  return;
343 
345  if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ) ) )
346  {
349  else
350  ReloadRequest();
351  }
352  return;
353 
355  if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ) ) )
356  {
359  else
360  ReloadRequest();
361  }
362  return;
363 
366  return;
367 
370  return;
371 
374  return;
375 
378  break;
379 
382  break;
383 
386  break;
387 
391  ReloadRequest( );
392  return;
393 
396  ReloadRequest();
397  return;
398 
401  ReloadRequest( );
402  return;
403 
406  ReloadRequest( );
407  return;
408 
411  ReloadRequest( );
412  return;
413 
416  ReloadRequest();
417  return;
418 
422  return;
423 
427  return;
428 
431  ReloadRequest( );
432  return;
433 
436  ReloadRequest( );
437  return;
438 
442  return;
443 
447  return;
448 
451  ReloadRequest( );
452  return;
453 
457  return;
458 
460  m_settings.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
461  ReloadRequest( );
462  return;
463 
465  m_settings.SetFlag( FL_AXIS, isChecked );
467  return;
468 
471  ReloadRequest( );
472  return;
473 
476  ReloadRequest( );
477  return;
478 
481  ReloadRequest( );
482  return;
483 
485  m_settings.SetFlag( FL_ZONE, isChecked );
486  ReloadRequest( );
487  return;
488 
490  m_settings.SetFlag( FL_ADHESIVE, isChecked );
491  ReloadRequest( );
492  return;
493 
495  m_settings.SetFlag( FL_SILKSCREEN, isChecked );
496  ReloadRequest( );
497  return;
498 
500  m_settings.SetFlag( FL_SOLDERMASK, isChecked );
501  ReloadRequest( );
502  return;
503 
505  m_settings.SetFlag( FL_SOLDERPASTE, isChecked );
506  ReloadRequest( );
507  return;
508 
510  m_settings.SetFlag( FL_COMMENTS, isChecked );
511  ReloadRequest( );
512  return;
513 
514  case ID_MENU3D_ECO_ONOFF:
515  m_settings.SetFlag( FL_ECO, isChecked );
516  ReloadRequest( );
517  return;
518 
520  {
521  // Reload settings with a dummy config, so it will load the defaults
522  wxConfig *fooconfig = new wxConfig("FooBarApp");
523  LoadSettings( fooconfig );
524  delete fooconfig;
525 
526  // Refresh menu option state
528 
529  // Tell canvas that we (may) changed the render engine
531 
532  ReloadRequest();
533  }
534  return;
535 
537  {
538  DisplayHotKeys();
539  }
540  return;
541 
542  default:
543  wxLogMessage( wxT( "EDA_3D_VIEWER::Process_Special_Functions() error: unknown command %d" ), id );
544  return;
545  }
546 }
547 
548 
549 void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
550 {
551  int id = event.GetId();
552 
553  wxASSERT( id < ID_MENU3D_GRID_END );
554  wxASSERT( id > ID_MENU3D_GRID );
555 
556  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::On3DGridSelection id:%d" ), id );
557 
558  switch( id )
559  {
562  break;
563 
566  break;
567 
568  case ID_MENU3D_GRID_5_MM:
570  break;
571 
574  break;
575 
576  case ID_MENU3D_GRID_1_MM:
578  break;
579 
580  default:
581  wxLogMessage( wxT( "EDA_3D_VIEWER::On3DGridSelection() error: unknown command %d" ), id );
582  return;
583  }
584 
585  if( m_canvas )
587 }
588 
589 
590 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
591 {
592  int id = event.GetId();
593 
594  wxASSERT( id < ID_MENU3D_ENGINE_END );
595  wxASSERT( id > ID_MENU3D_ENGINE );
596 
597  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnRenderEngineSelection id:%d" ), id );
598 
599  const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
600 
601  switch( id )
602  {
604  if( old_engine != RENDER_ENGINE_OPENGL_LEGACY )
606  break;
607 
609  if( old_engine != RENDER_ENGINE_RAYTRACING )
611  break;
612 
613  default:
614  wxLogMessage( wxT( "EDA_3D_VIEWER::OnRenderEngineSelection() error: unknown command %d" ), id );
615  return;
616  }
617 
618  if( old_engine != m_settings.RenderEngineGet() )
619  {
621  }
622 }
623 
624 
625 void EDA_3D_VIEWER::OnUpdateMenus(wxUpdateUIEvent &event)
626 {
628  // to have it working this way
630 }
631 
632 
633 void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
634 {
635  int id = event.GetId();
636 
637  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::ProcessZoom id:%d" ), id );
638 
639  if( m_canvas == NULL )
640  return;
641 
642  switch( id )
643  {
644  case ID_ZOOM_PAGE:
645  m_canvas->SetView3D( WXK_HOME );
646  break;
647 
648  case ID_ZOOM_IN:
649  m_canvas->SetView3D( WXK_F1 );
650  break;
651 
652  case ID_ZOOM_OUT:
653  m_canvas->SetView3D( WXK_F2 );
654  break;
655 
656  case ID_ZOOM_REDRAW:
658  break;
659 
660  default:
661  wxLogMessage( wxT( "EDA_3D_VIEWER::ProcessZoom() error: unknown command %d" ), id );
662  return;
663  }
664 
666 }
667 
668 
669 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
670 {
671  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnActivate" ) );
672 
673  if( m_canvas )
674  {
675  // Reload data if 3D frame shows a board,
676  // because it can be changed since last frame activation
679 
680  // Activates again the focus of the canvas so it will catch mouse and key events
681  m_canvas->SetFocus();
682  }
683 
684  event.Skip(); // required under wxMAC
685 }
686 
687 
688 void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
689 {
690  // Activates again the focus of the canvas so it will catch mouse and key events
691  if( m_canvas )
692  m_canvas->SetFocus();
693 
694  event.Skip();
695 }
696 
697 
698 void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg )
699 {
701 
702  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::LoadSettings" ) );
703 
704  aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
705  aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
706  aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
707 
708  aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
709  aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
710  aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
711 
712  // m_SolderMaskColor default value = dark grey-green
713  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColor.r, 100.0 * 0.2 / 255.0 );
714  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColor.g, 255.0 * 0.2 / 255.0 );
715  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColor.b, 180.0 * 0.2 / 255.0 );
716 
717  // m_SolderPasteColor default value = light grey
718  aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 /255.0 );
719  aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 /255.0 );
720  aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 /255.0 );
721 
722  // m_SilkScreenColor default value = white
723  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColor.r, 0.9 );
724  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColor.g, 0.9 );
725  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColor.b, 0.9 );
726 
727  // m_CopperColor default value = gold
728  aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
729  aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
730  aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 /255.0 );
731 
732  // m_BoardBodyColor default value = FR4, in realistic mode
733  aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
734  aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
735  aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 /255.0 );
736 
737 
738  bool tmp;
739  aCfg->Read( keyMousewheelPanning, &tmp, false );
741 
742  aCfg->Read( keyShowRealisticMode, &tmp, true );
744 
745  aCfg->Read( keyRenderRemoveHoles, &tmp, true );
747 
748  // OpenGL options
749  aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
751 
752  aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
754 
755  // Raytracing options
756  aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
758 
759  aCfg->Read( keyRenderRAY_Backfloor, &tmp, true );
761 
762  aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
764 
765  aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
767 
768  aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
770 
771  aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
773 
774  aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
776 
777  aCfg->Read( keyShowAxis, &tmp, true );
778  m_settings.SetFlag( FL_AXIS, tmp );
779 
780  aCfg->Read( keyShowFootprints_Normal, &tmp, true );
782 
783  aCfg->Read( keyShowFootprints_Insert, &tmp, true );
785 
786  aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
788 
789  aCfg->Read( keyShowZones, &tmp, true );
790  m_settings.SetFlag( FL_ZONE, tmp );
791 
792  aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
794 
795  aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
797 
798  aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
800 
801  aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
803 
804  aCfg->Read( keyShowCommentsLayer, &tmp, true );
806 
807  aCfg->Read( keyShowEcoLayers, &tmp, true );
808  m_settings.SetFlag( FL_ECO, tmp );
809 
810  aCfg->Read( keyShowBoardBody, &tmp, true );
812 
813  int tmpi;
814  aCfg->Read( keyShowGrid, &tmpi, (int)GRID3D_NONE );
815  m_settings.GridSet( (GRID3D_TYPE)tmpi );
816 
817  aCfg->Read( keyRenderEngine, &tmpi, (int)RENDER_ENGINE_OPENGL_LEGACY );
819 
820  aCfg->Read( keyRenderMaterial, &tmpi, (int)MATERIAL_MODE_NORMAL );
822 }
823 
824 
825 void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
826 {
828 
829  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::SaveSettings" ) );
830 
831  aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
832  aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
833  aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
834 
835  aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
836  aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
837  aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
838 
842 
846 
850 
851  aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
853  aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
854 
858 
860 
862 
863  aCfg->Write( keyRenderEngine, (int)m_settings.RenderEngineGet() );
864 
866 
867  aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() );
868 
869  // OpenGL options
872 
873  // Raytracing options
881 
882  aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
883  aCfg->Write( keyShowGrid, (int)m_settings.GridGet() );
884 
888 
889  aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
895  aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
897 }
898 
899 
900 void EDA_3D_VIEWER::OnLeftClick( wxDC *DC, const wxPoint &MousePos )
901 {
902  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnLeftClick" ) );
903  // Do nothing
904 }
905 
906 
907 void EDA_3D_VIEWER::OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu )
908 {
909  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnRightClick" ) );
910  // Do nothing
911 }
912 
913 
914 void EDA_3D_VIEWER::RedrawActiveWindow( wxDC *DC, bool EraseBg )
915 {
916  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::RedrawActiveWindow" ) );
917  // Do nothing
918 }
919 
920 
921 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
922 {
923  wxString fullFileName;
924  bool fmt_is_jpeg = false;
925 
926  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
927  fmt_is_jpeg = true;
928 
929  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
930  {
931  // Remember path between saves during this session only.
932  static wxFileName fn;
933  const wxString file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
934  const wxString mask = wxT( "*." ) + file_ext;
935 
936  // First time path is set to the project path.
937  if( !fn.IsOk() )
938  fn = Parent()->Prj().GetProjectFullName();
939 
940  fn.SetExt( file_ext );
941 
942  fullFileName = EDA_FILE_SELECTOR( _( "3D Image File Name:" ), fn.GetPath(),
943  m_defaultFileName, file_ext, mask, this,
944  wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );
945 
946  if( fullFileName.IsEmpty() )
947  return;
948 
949  fn = fullFileName;
950 
951  // Be sure the screen area destroyed by the file dialog is redrawn
952  // before making a screen copy.
953  // Without this call, under Linux the screen refresh is made to late.
954  wxYield();
955  }
956 
957  // Be sure we have the latest 3D view (remember 3D view is buffered)
958  Refresh();
959  wxYield();
960 
961  // Build image from the 3D buffer
962  wxWindowUpdateLocker noUpdates( this );
963 
964  wxImage screenshotImage;
965 
966  if( m_canvas )
967  m_canvas->GetScreenshot( screenshotImage );
968 
969  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
970  {
971  wxBitmap bitmap( screenshotImage );
972 
973  if( wxTheClipboard->Open() )
974  {
975  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
976 
977  if( !wxTheClipboard->SetData( dobjBmp ) )
978  wxMessageBox( _( "Failed to copy image to clipboard" ) );
979 
980  wxTheClipboard->Flush(); /* the data in clipboard will stay
981  * available after the application exits */
982  wxTheClipboard->Close();
983  }
984  }
985  else
986  {
987  if( !screenshotImage.SaveFile( fullFileName,
988  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
989  wxMessageBox( _( "Can't save file" ) );
990 
991  screenshotImage.Destroy();
992  }
993 
994 }
995 
996 
998 {
999  if( m_canvas )
1001 
1004 
1005  m_mainToolBar->Refresh();
1006 }
1007 
1008 
1009 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
1010  wxColourData* aPredefinedColors )
1011 {
1012  wxColour newcolor, oldcolor;
1013 
1014  oldcolor.Set( KiROUND( aColor.r * 255 ),
1015  KiROUND( aColor.g * 255 ),
1016  KiROUND( aColor.b * 255 ) );
1017 
1018  wxColourData emptyColorSet; // Provides a empty predefined set of colors
1019  // if no color set available to avoid use of an
1020  // old color set
1021 
1022  if( aPredefinedColors == NULL )
1023  aPredefinedColors = &emptyColorSet;
1024 
1025  newcolor = wxGetColourFromUser( this, oldcolor, aTitle, aPredefinedColors );
1026 
1027  if( !newcolor.IsOk() ) // Cancel command
1028  return false;
1029 
1030  if( newcolor != oldcolor )
1031  {
1032  aColor.r = (double) newcolor.Red() / 255.0;
1033  aColor.g = (double) newcolor.Green() / 255.0;
1034  aColor.b = (double) newcolor.Blue() / 255.0;
1035  }
1036 
1037  return true;
1038 }
1039 
1040 
1042 {
1043  wxColourData definedColors;
1044  unsigned int i = 0;
1045 
1046  definedColors.SetCustomColour( i++, wxColour( 241, 241, 241 ) ); // White
1047  definedColors.SetCustomColour( i++, wxColour( 4, 18, 21 ) ); // Dark
1048 
1049  for(; i < wxColourData::NUM_CUSTOM;)
1050  {
1051  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1052  }
1053 
1055  _( "Silk Screen Color" ),
1056  &definedColors );
1057 
1058  if( change )
1059  NewDisplay();
1060 
1061  return change;
1062 }
1063 
1064 
1066 {
1067  wxColourData definedColors;
1068  unsigned int i = 0;
1069 
1070  definedColors.SetCustomColour( i++, wxColour( 20, 51, 36 ) ); // Green
1071  definedColors.SetCustomColour( i++, wxColour( 91, 168, 12 ) ); // Light Green
1072  definedColors.SetCustomColour( i++, wxColour( 13, 104, 11 ) ); // Saturated Green
1073  definedColors.SetCustomColour( i++, wxColour(181, 19, 21 ) ); // Red
1074  definedColors.SetCustomColour( i++, wxColour(239, 53, 41 ) ); // Red Light Orange
1075  definedColors.SetCustomColour( i++, wxColour(210, 40, 14 ) ); // Red 2
1076  definedColors.SetCustomColour( i++, wxColour( 2, 59, 162 ) ); // Blue
1077  definedColors.SetCustomColour( i++, wxColour( 54, 79, 116 ) ); // Light blue 1
1078  definedColors.SetCustomColour( i++, wxColour( 61, 85, 130 ) ); // Light blue 2
1079  definedColors.SetCustomColour( i++, wxColour( 21, 70, 80 ) ); // Green blue (dark)
1080  definedColors.SetCustomColour( i++, wxColour( 11, 11, 11 ) ); // Black
1081  definedColors.SetCustomColour( i++, wxColour( 245, 245,245 ) ); // White
1082  definedColors.SetCustomColour( i++, wxColour(119, 31, 91 ) ); // Purple
1083  definedColors.SetCustomColour( i++, wxColour( 32, 2, 53 ) ); // Purple Dark
1084 
1085  for(; i < wxColourData::NUM_CUSTOM;)
1086  {
1087  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1088  }
1089 
1091  _( "Solder Mask Color" ),
1092  &definedColors );
1093 
1094  if( change )
1095  NewDisplay();
1096 
1097  return change;
1098 }
1099 
1100 
1102 {
1103  wxColourData definedColors;
1104  unsigned int i = 0;
1105 
1106  definedColors.SetCustomColour( i++, wxColour( 184, 115, 50) ); // Copper
1107  definedColors.SetCustomColour( i++, wxColour( 191, 155, 58) ); // Gold
1108  definedColors.SetCustomColour( i++, wxColour( 213, 213, 213) ); // Silver
1109  definedColors.SetCustomColour( i++, wxColour( 160, 160, 160) ); // tin
1110 
1111  for(; i < wxColourData::NUM_CUSTOM;)
1112  {
1113  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1114  }
1115 
1117  _( "Copper Color" ),
1118  &definedColors );
1119 
1120  if( change )
1121  NewDisplay();
1122 
1123  return change;
1124 }
1125 
1126 
1128 {
1129  wxColourData definedColors;
1130  unsigned int i = 0;
1131 
1132  definedColors.SetCustomColour( i++, wxColour( 51, 43, 22 ) ); // FR4 natural, dark
1133  definedColors.SetCustomColour( i++, wxColour( 109, 116, 75 ) ); // FR4 natural
1134  definedColors.SetCustomColour( i++, wxColour( 78, 14, 5 ) ); // brown/red
1135  definedColors.SetCustomColour( i++, wxColour( 146, 99, 47 ) ); // brown 1
1136  definedColors.SetCustomColour( i++, wxColour( 160, 123, 54 ) ); // brown 2
1137  definedColors.SetCustomColour( i++, wxColour( 146, 99, 47 ) ); // brown 3
1138  definedColors.SetCustomColour( i++, wxColour( 63, 126, 71 ) ); // green 1
1139  definedColors.SetCustomColour( i++, wxColour( 117, 122, 90 ) ); // green 2
1140 
1141  for(; i < wxColourData::NUM_CUSTOM;)
1142  {
1143  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1144  }
1145 
1147  _( "Board Body Color" ),
1148  &definedColors );
1149 
1150  if( change )
1151  NewDisplay();
1152 
1153  return change;
1154 }
1155 
1156 
1158 {
1159  wxColourData definedColors;
1160  unsigned int i = 0;
1161 
1162  definedColors.SetCustomColour( i++, wxColour( 128, 128, 128 ) ); // grey
1163  definedColors.SetCustomColour( i++, wxColour( 213, 213, 213 ) ); // Silver
1164  definedColors.SetCustomColour( i++, wxColour( 90, 90, 90 ) ); // grey 2
1165 
1166  for(; i < wxColourData::NUM_CUSTOM;)
1167  {
1168  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1169  }
1170 
1172  _( "Solder Paste Color" ),
1173  &definedColors );
1174 
1175  if( change )
1176  NewDisplay();
1177 
1178  return change;
1179 }
1180 
1181 
1182 // Define 3D Viewer Hotkeys
1183 // !TODO: this is used just for help menu, the structured are not used yet in the viewer
1184 static EDA_HOTKEY Hk3D_PivotCenter( _HKI( "Center pivot rotation (Middle mouse click)" ), 0, WXK_SPACE );
1185 static EDA_HOTKEY Hk3D_MoveLeft( _HKI( "Move board Left" ), 0, WXK_LEFT );
1186 static EDA_HOTKEY Hk3D_MoveRight( _HKI( "Move board Right" ), 0, WXK_RIGHT );
1187 static EDA_HOTKEY Hk3D_MoveUp( _HKI( "Move board Up" ), 0, WXK_UP );
1188 static EDA_HOTKEY Hk3D_MoveDown( _HKI( "Move board Down" ), 0, WXK_DOWN );
1189 static EDA_HOTKEY Hk3D_HomeView( _HKI( "Home view" ), 0, WXK_HOME );
1190 static EDA_HOTKEY Hk3D_ResetView( _HKI( "Reset view" ), 0, 'R' );
1191 
1192 static EDA_HOTKEY Hk3D_ViewFront( _HKI( "View Top" ), 0, 'y' );
1193 static EDA_HOTKEY Hk3D_ViewBack( _HKI( "View Bot" ), 0, 'Y' );
1194 static EDA_HOTKEY Hk3D_ViewLeft( _HKI( "View Left" ), 0, 'X' );
1195 static EDA_HOTKEY Hk3D_ViewRight( _HKI( "View Right" ), 0, 'x' );
1196 static EDA_HOTKEY Hk3D_ViewTop( _HKI( "View Top" ), 0, 'z' );
1197 static EDA_HOTKEY Hk3D_ViewBot( _HKI( "View Bot" ), 0, 'Z' );
1198 
1199 static EDA_HOTKEY Hk3D_Rotate45axisZ( _HKI( "Rotate 45 degrees over Z axis" ), 0, WXK_TAB );
1200 static EDA_HOTKEY Hk3D_ZoomIn( _HKI( "Zoom in " ), 0, WXK_F1 );
1201 static EDA_HOTKEY Hk3D_ZoomOut( _HKI( "Zoom out" ), 0, WXK_F2 );
1202 static EDA_HOTKEY Hk3D_AttributesTHT( _HKI( "Toggle 3D models with type Through Hole" ), 0, 'T' );
1203 static EDA_HOTKEY Hk3D_AttributesSMD( _HKI( "Toggle 3D models with type Surface Mount" ), 0, 'S' );
1204 static EDA_HOTKEY Hk3D_AttributesVirtual( _HKI( "Toggle 3D models with type Virtual" ), 0, 'V' );
1205 
1206 static wxString viewer3DSectionTitle( _HKI( "Viewer 3D" ) );
1207 
1208 // List of hotkey descriptors for the 3D Viewer only
1209 // !TODO: this is used just for help menu, the structured are not used yet in the viewer
1211 {
1213  &Hk3D_MoveLeft,
1214  &Hk3D_MoveRight,
1215  &Hk3D_MoveUp,
1216  &Hk3D_MoveDown,
1217  &Hk3D_HomeView,
1218  &Hk3D_ResetView,
1219  &Hk3D_ViewFront,
1220  &Hk3D_ViewBack,
1221  &Hk3D_ViewLeft,
1222  &Hk3D_ViewRight,
1223  &Hk3D_ViewTop,
1224  &Hk3D_ViewBot,
1226  &Hk3D_ZoomIn,
1227  &Hk3D_ZoomOut,
1231  NULL
1232 };
1233 
1234 
1235 // list of sections and corresponding hotkey list for the 3D Viewer
1236 // (used to list current hotkeys)
1238 {
1240  { NULL, NULL, NULL }
1241 };
1242 
1243 
1245 {
1246  DisplayHotkeyList( this, g_3DViewer_Hokeys_Descr );
1247 }
static const wxChar keyShowSolderMaskLayers[]
static const wxChar keyShowFootprints_Normal[]
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:474
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:62
#define DIM(x)
of elements in an array
Definition: macros.h:98
static EDA_HOTKEY Hk3D_ViewFront(_HKI("View Top"), 0, 'y')
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
static const wxChar keyRenderRAY_ProceduralT[]
static const wxChar keyShowGrid[]
bool Set3DCopperColorFromUser()
Function 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:111
static const wxChar keyShowBoardBody[]
Use only diffuse material properties.
Definition: 3d_enums.h:94
KICAD_MANAGER_FRAME::Process_Config KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser EVT_UPDATE_UI_RANGE(ID_TO_SCH, ID_TO_PCB_FP_EDITOR, KICAD_MANAGER_FRAME::OnUpdateRequiresProject) enum hotkey_id_commnand
static EDA_HOTKEY Hk3D_ViewRight(_HKI("View Right"), 0, 'x')
static EDA_HOTKEY Hk3D_ViewBack(_HKI("View Bot"), 0, 'Y')
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:87
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
static const wxChar keyRenderRAY_Reflections[]
static const wxChar keyRenderRemoveHoles[]
static EDA_HOTKEY * viewer3d_Hotkey_List[]
static EDA_HOTKEY Hk3D_Rotate45axisZ(_HKI("Rotate 45 degrees over Z axis"), 0, WXK_TAB)
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.
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
bool IsReloadRequestPending() const
IsReloadRequestPending - Query if there is a pending reload request.
Definition: eda_3d_canvas.h:82
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:246
static const wxChar keySilkColor_Blue[]
static const wxChar keyMousewheelPanning[]
static const wxChar keyBgColor_Blue_Top[]
bool Set3DSolderMaskColorFromUser()
Function 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 LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
PROJECT & Prj()
Definition: kicad.cpp:293
void SetMenuBarOptionsState()
Set the state of toggle menus according to the current display options.
Definition: 3d_toolbar.cpp:414
static EDA_HOTKEY Hk3D_AttributesVirtual(_HKI("Toggle 3D models with type Virtual"), 0, 'V')
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. ...
Definition: basicframe.cpp:316
void RedrawActiveWindow(wxDC *DC, bool EraseBg)
Definition: id.h:232
static EDA_HOTKEY Hk3D_AttributesTHT(_HKI("Toggle 3D models with type Through Hole"), 0, 'T')
static const wxChar keyCopperColor_Green[]
static const wxChar keyShowFootprints_Virtual[]
void SetStatusBar(wxStatusBar *aStatusBar)
Definition: eda_3d_canvas.h:74
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
Class EDA_3D_CANVAS Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:53
static EDA_HOTKEY Hk3D_PivotCenter(_HKI("Center pivot rotation (Middle mouse click)"), 0, WXK_SPACE)
static const wxChar keyShowAdhesiveLayers[]
static const wxChar keySilkColor_Green[]
wxAuiManager m_auimgr
Definition: wxstruct.h:139
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:503
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)
Exit3DFrame - Called when user press the File->Exit.
static EDA_HOTKEY Hk3D_MoveLeft(_HKI("Move board Left"), 0, WXK_LEFT)
void MaterialModeSet(MATERIAL_MODE aMaterialMode)
MaterialModeSet.
Definition: cinfo3d_visu.h:240
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:465
static const wxChar keyShowRealisticMode[]
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
Definition: cinfo3d_visu.h:505
static EDA_HOTKEY Hk3D_ZoomIn(_HKI("Zoom in "), 0, WXK_F1)
EDA_3D_CANVAS * m_canvas
The canvas where the openGL context will be rendered.
static const wxChar keyCopperColor_Blue[]
static const wxChar keySMaskColor_Green[]
EDA_3D_VIEWER::Process_Special_Functions EVT_MENU(wxID_EXIT, EDA_3D_VIEWER::Exit3DFrame) EVT_MENU_RANGE(ID_MENU3D_GRID
static const wxChar keyBgColor_Green_Top[]
static const wxChar keyShowSolderPasteLayers[]
void RenderEngineSet(RENDER_ENGINE aRenderEngine)
RenderEngineSet.
Definition: cinfo3d_visu.h:228
static const wxChar keySPasteColor_Red[]
static const wxChar keyShowSilkScreenLayers[]
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
void OnActivate(wxActivateEvent &event)
void OnUpdateMenus(wxUpdateUIEvent &event)
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
EDA_3D_VIEWER::Process_Special_Functions ID_MENU3D_GRID_END
static const wxChar keyCopperColor_Red[]
void RotateZ(float aAngleInRadians)
Definition: ccamera.cpp:510
void RotateX(float aAngleInRadians)
Definition: ccamera.cpp:496
void RenderRaytracingRequest()
RenderRaytracingRequest - Request to render the current view in Raytracing mode.
static EDA_HOTKEY Hk3D_AttributesSMD(_HKI("Toggle 3D models with type Surface Mount"), 0, 'S')
static EDA_HOTKEY Hk3D_ViewBot(_HKI("View Bot"), 0, 'Z')
void Refresh()
static const wxChar keyShowZones[]
static const wxChar keyRenderMaterial[]
static const wxChar keyRenderRAY_AAliasing[]
static EDA_HOTKEY Hk3D_ResetView(_HKI("Reset view"), 0, 'R')
void RenderEngineChanged()
RenderEngineChanged - Notify that the render engine was changed.
bool Set3DSilkScreenColorFromUser()
Function 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.
Definition: basicframe.cpp:256
void ToggleProjection()
Definition: ccamera.cpp:417
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[]
Use a gray shading based on diffuse material.
Definition: 3d_enums.h:95
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
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.wxwidgets.org/3.0/classwx_hash_map.html.
EVT_TOOL_RANGE(ID_ZOOM_IN, ID_ZOOM_REDRAW, EDA_3D_VIEWER::ProcessZoom) EVT_TOOL_RANGE(ID_START_COMMAND_3D
static EDA_HOTKEY Hk3D_MoveRight(_HKI("Move board Right"), 0, WXK_RIGHT)
static const wxChar keyBgColor_Green[]
static const wxChar keyBoardBodyColor_Blue[]
static EDA_HOTKEY Hk3D_ViewLeft(_HKI("View Left"), 0, 'X')
MATERIAL_MODE
Render 3d model shape materials mode.
Definition: 3d_enums.h:91
static EDA_HOTKEY Hk3D_HomeView(_HKI("Home view"), 0, WXK_HOME)
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:507
bool Set3DSolderPasteColorFromUser()
Function Set3DSolderPasteColorFromUser Set the solder mask color from a set of colors.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:135
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:234
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:506
GRID3D_TYPE
Grid types.
Definition: 3d_enums.h:72
static const wxChar keyRenderOGL_ShowModelBBox[]
void NewDisplay(int dummy=0)
Definition: eda_3d_viewer.h:71
void RenderEngineChanged()
RenderEngineChanged - Update toolbar icon and call canvas RenderEngineChanged.
static const wxChar keySPasteColor_Green[]
Use all material properties from model file.
Definition: 3d_enums.h:93
static const wxChar keyBoardBodyColor_Red[]
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
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[]
ID_MENU_COMMAND_END
static const wxChar keyRenderRAY_Refractions[]
void SetView3D(int keycode)
SetView3D - Helper function to call view commands.
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:57
Declaration of the eda_3d_viewer class.
wxString m_defaultFileName
Filename to propose for save a screenshot.
EDA_3D_VIEWER::Process_Special_Functions EDA_3D_VIEWER::On3DGridSelection EVT_MENU_RANGE(ID_MENU3D_ENGINE, ID_MENU3D_ENGINE_END, EDA_3D_VIEWER::OnRenderEngineSelection) EVT_UPDATE_UI_RANGE(ID_START_COMMAND_3D
static const wxChar keyRenderOGL_ShowCopperTck[]
static const wxChar keyRenderRAY_Backfloor[]
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
bool Set3DColorFromUser(SFVEC3D &aColor, const wxString &aTitle, wxColourData *aPredefinedColors=NULL)
Function Set3DColorFromUser Get a SFVEC3D from a wx colour dialog.
void ProcessZoom(wxCommandEvent &event)
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
#define ROT_ANGLE
static const wxChar keySMaskColor_Blue[]
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:112
void OnRenderEngineSelection(wxCommandEvent &event)
static EDA_HOTKEY Hk3D_MoveUp(_HKI("Move board Up"), 0, WXK_UP)
RENDER_ENGINE
Render engine mode.
Definition: 3d_enums.h:83
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)
Class EDA_3D_VIEWER Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard...
Definition: eda_3d_viewer.h:50
Some functions to handle hotkeys in KiCad.
wxString g_CommonSectionTag
static wxString viewer3DSectionTitle(_HKI("Viewer 3D"))
static EDA_HOTKEY Hk3D_ViewTop(_HKI("View Top"), 0, 'z')
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
static const wxChar keyShowEcoLayers[]
static const wxChar keyShowCommentsLayer[]
#define _HKI(x)
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:64
static EDA_HOTKEY Hk3D_ZoomOut(_HKI("Zoom out"), 0, WXK_F2)
bool Set3DBoardBodyColorFromUser()
Function Set3DBoardBodyBodyColorFromUser Set the copper color from a set of colors.
static const wxChar keyRenderRAY_PostProcess[]
void Process_Special_Functions(wxCommandEvent &event)
static EDA_HOTKEY Hk3D_MoveDown(_HKI("Move board Down"), 0, WXK_DOWN)
void takeScreenshot(wxCommandEvent &event)
Function TakeScreenshot Create a Screenshot of the current 3D view.