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-2017 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 
227 
229 {
230  // This will schedule a request to load later
231  if( m_canvas )
232  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
233 }
234 
235 
236 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
237 {
238  ReloadRequest();
239 
240  // After the ReloadRequest call, the refresh often takes a bit of time,
241  // and it is made here only on request.
242  if( aForceImmediateRedraw )
243  m_canvas->Refresh();
244 }
245 
246 
247 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
248 {
249  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::Exit3DFrame" ) );
250 
251  Close( true );
252 }
253 
254 
255 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
256 {
257  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnCloseWindow" ) );
258 
259  if( m_canvas )
260  m_canvas->Close();
261 
262  // m_canvas delete will be called by wxWidget manager
263  //delete m_canvas;
264  //m_canvas = 0;
265 
266  Destroy();
267  event.Skip( true );
268 }
269 
270 #define ROT_ANGLE 10.0
271 
272 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
273 {
274  int id = event.GetId();
275  bool isChecked = event.IsChecked();
276 
277  wxLogTrace( m_logTrace,
278  wxT( "EDA_3D_VIEWER::Process_Special_Functions id:%d isChecked:%d" ),
279  id, isChecked );
280 
281  if( m_canvas == NULL )
282  return;
283 
284  switch( id )
285  {
288  break;
289 
290  case ID_RELOAD3D_BOARD:
291  ReloadRequest();
293  break;
294 
295  case ID_ROTATE3D_X_POS:
296  m_settings.CameraGet().RotateX( glm::radians(ROT_ANGLE) );
298  break;
299 
300  case ID_ROTATE3D_X_NEG:
301  m_settings.CameraGet().RotateX( -glm::radians(ROT_ANGLE) );
303  break;
304 
305  case ID_ROTATE3D_Y_POS:
306  m_settings.CameraGet().RotateY( glm::radians(ROT_ANGLE) );
308  break;
309 
310  case ID_ROTATE3D_Y_NEG:
311  m_settings.CameraGet().RotateY( -glm::radians(ROT_ANGLE) );
313  break;
314 
315  case ID_ROTATE3D_Z_POS:
316  m_settings.CameraGet().RotateZ( glm::radians(ROT_ANGLE) );
318  break;
319 
320  case ID_ROTATE3D_Z_NEG:
321  m_settings.CameraGet().RotateZ( -glm::radians(ROT_ANGLE) );
323  break;
324 
325  case ID_MOVE3D_LEFT:
326  m_canvas->SetView3D( WXK_LEFT );
327  return;
328 
329  case ID_MOVE3D_RIGHT:
330  m_canvas->SetView3D( WXK_RIGHT );
331  return;
332 
333  case ID_MOVE3D_UP:
334  m_canvas->SetView3D( WXK_UP );
335  return;
336 
337  case ID_MOVE3D_DOWN:
338  m_canvas->SetView3D( WXK_DOWN );
339  return;
340 
341  case ID_ORTHO:
344  return;
345 
349  takeScreenshot( event );
350  return;
351 
353  if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ) ) )
354  {
357  else
358  ReloadRequest();
359  }
360  return;
361 
363  if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ) ) )
364  {
367  else
368  ReloadRequest();
369  }
370  return;
371 
374  return;
375 
378  return;
379 
382  return;
383 
386  break;
387 
390  break;
391 
394  break;
395 
399  ReloadRequest( );
400  return;
401 
404  ReloadRequest();
405  return;
406 
409  ReloadRequest( );
410  return;
411 
414  ReloadRequest( );
415  return;
416 
419  ReloadRequest( );
420  return;
421 
424  ReloadRequest();
425  return;
426 
430  return;
431 
435  return;
436 
439  ReloadRequest( );
440  return;
441 
444  ReloadRequest( );
445  return;
446 
450  return;
451 
455  return;
456 
459  ReloadRequest( );
460  return;
461 
465  return;
466 
468  m_settings.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
469  ReloadRequest( );
470  return;
471 
473  m_settings.SetFlag( FL_AXIS, isChecked );
475  return;
476 
479  ReloadRequest( );
480  return;
481 
484  ReloadRequest( );
485  return;
486 
489  ReloadRequest( );
490  return;
491 
493  m_settings.SetFlag( FL_ZONE, isChecked );
494  ReloadRequest( );
495  return;
496 
498  m_settings.SetFlag( FL_ADHESIVE, isChecked );
499  ReloadRequest( );
500  return;
501 
503  m_settings.SetFlag( FL_SILKSCREEN, isChecked );
504  ReloadRequest( );
505  return;
506 
508  m_settings.SetFlag( FL_SOLDERMASK, isChecked );
509  ReloadRequest( );
510  return;
511 
513  m_settings.SetFlag( FL_SOLDERPASTE, isChecked );
514  ReloadRequest( );
515  return;
516 
518  m_settings.SetFlag( FL_COMMENTS, isChecked );
519  ReloadRequest( );
520  return;
521 
522  case ID_MENU3D_ECO_ONOFF:
523  m_settings.SetFlag( FL_ECO, isChecked );
524  ReloadRequest( );
525  return;
526 
528  {
529  // Reload settings with a dummy config, so it will load the defaults
530  wxConfig *fooconfig = new wxConfig("FooBarApp");
531  LoadSettings( fooconfig );
532  delete fooconfig;
533 
534  // Refresh menu option state
536 
537  // Tell canvas that we (may) changed the render engine
539 
540  ReloadRequest();
541  }
542  return;
543 
545  {
546  DisplayHotKeys();
547  }
548  return;
549 
550  default:
551  wxLogMessage( wxT( "EDA_3D_VIEWER::Process_Special_Functions() error: unknown command %d" ), id );
552  return;
553  }
554 }
555 
556 
557 void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
558 {
559  int id = event.GetId();
560 
561  wxASSERT( id < ID_MENU3D_GRID_END );
562  wxASSERT( id > ID_MENU3D_GRID );
563 
564  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::On3DGridSelection id:%d" ), id );
565 
566  switch( id )
567  {
570  break;
571 
574  break;
575 
576  case ID_MENU3D_GRID_5_MM:
578  break;
579 
582  break;
583 
584  case ID_MENU3D_GRID_1_MM:
586  break;
587 
588  default:
589  wxLogMessage( wxT( "EDA_3D_VIEWER::On3DGridSelection() error: unknown command %d" ), id );
590  return;
591  }
592 
593  if( m_canvas )
595 }
596 
597 
598 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
599 {
600  int id = event.GetId();
601 
602  wxASSERT( id < ID_MENU3D_ENGINE_END );
603  wxASSERT( id > ID_MENU3D_ENGINE );
604 
605  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnRenderEngineSelection id:%d" ), id );
606 
607  const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
608 
609  switch( id )
610  {
612  if( old_engine != RENDER_ENGINE_OPENGL_LEGACY )
614  break;
615 
617  if( old_engine != RENDER_ENGINE_RAYTRACING )
619  break;
620 
621  default:
622  wxLogMessage( wxT( "EDA_3D_VIEWER::OnRenderEngineSelection() error: unknown command %d" ), id );
623  return;
624  }
625 
626  if( old_engine != m_settings.RenderEngineGet() )
627  {
629  }
630 }
631 
632 
633 void EDA_3D_VIEWER::OnUpdateMenus(wxUpdateUIEvent &event)
634 {
636  // to have it working this way
638 }
639 
640 
641 void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
642 {
643  int id = event.GetId();
644 
645  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::ProcessZoom id:%d" ), id );
646 
647  if( m_canvas == NULL )
648  return;
649 
650  switch( id )
651  {
652  case ID_ZOOM_PAGE:
653  m_canvas->SetView3D( WXK_HOME );
654  break;
655 
656  case ID_ZOOM_IN:
657  m_canvas->SetView3D( WXK_F1 );
658  break;
659 
660  case ID_ZOOM_OUT:
661  m_canvas->SetView3D( WXK_F2 );
662  break;
663 
664  case ID_ZOOM_REDRAW:
666  break;
667 
668  default:
669  wxLogMessage( wxT( "EDA_3D_VIEWER::ProcessZoom() error: unknown command %d" ), id );
670  return;
671  }
672 
674 }
675 
676 
677 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
678 {
679  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnActivate" ) );
680 
681  if( m_canvas )
682  {
683  // Reload data if 3D frame shows a board,
684  // because it can be changed since last frame activation
687 
688  // Activates again the focus of the canvas so it will catch mouse and key events
689  m_canvas->SetFocus();
690  }
691 
692  event.Skip(); // required under wxMAC
693 }
694 
695 
696 void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
697 {
698  // Activates again the focus of the canvas so it will catch mouse and key events
699  if( m_canvas )
700  m_canvas->SetFocus();
701 
702  event.Skip();
703 }
704 
705 
706 void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg )
707 {
709 
710  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::LoadSettings" ) );
711 
712  aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
713  aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
714  aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
715 
716  aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
717  aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
718  aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
719 
720  // m_SolderMaskColor default value = dark grey-green
721  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColor.r, 100.0 * 0.2 / 255.0 );
722  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColor.g, 255.0 * 0.2 / 255.0 );
723  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColor.b, 180.0 * 0.2 / 255.0 );
724 
725  // m_SolderPasteColor default value = light grey
726  aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 /255.0 );
727  aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 /255.0 );
728  aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 /255.0 );
729 
730  // m_SilkScreenColor default value = white
731  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColor.r, 0.9 );
732  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColor.g, 0.9 );
733  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColor.b, 0.9 );
734 
735  // m_CopperColor default value = gold
736  aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
737  aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
738  aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 /255.0 );
739 
740  // m_BoardBodyColor default value = FR4, in realistic mode
741  aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
742  aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
743  aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 /255.0 );
744 
745 
746  bool tmp;
747  aCfg->Read( keyMousewheelPanning, &tmp, false );
749 
750  aCfg->Read( keyShowRealisticMode, &tmp, true );
752 
753  aCfg->Read( keyRenderRemoveHoles, &tmp, true );
755 
756  // OpenGL options
757  aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
759 
760  aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
762 
763  // Raytracing options
764  aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
766 
767  aCfg->Read( keyRenderRAY_Backfloor, &tmp, true );
769 
770  aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
772 
773  aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
775 
776  aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
778 
779  aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
781 
782  aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
784 
785  aCfg->Read( keyShowAxis, &tmp, true );
786  m_settings.SetFlag( FL_AXIS, tmp );
787 
788  aCfg->Read( keyShowFootprints_Normal, &tmp, true );
790 
791  aCfg->Read( keyShowFootprints_Insert, &tmp, true );
793 
794  aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
796 
797  aCfg->Read( keyShowZones, &tmp, true );
798  m_settings.SetFlag( FL_ZONE, tmp );
799 
800  aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
802 
803  aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
805 
806  aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
808 
809  aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
811 
812  aCfg->Read( keyShowCommentsLayer, &tmp, true );
814 
815  aCfg->Read( keyShowEcoLayers, &tmp, true );
816  m_settings.SetFlag( FL_ECO, tmp );
817 
818  aCfg->Read( keyShowBoardBody, &tmp, true );
820 
821  int tmpi;
822  aCfg->Read( keyShowGrid, &tmpi, (int)GRID3D_NONE );
823  m_settings.GridSet( (GRID3D_TYPE)tmpi );
824 
825  aCfg->Read( keyRenderEngine, &tmpi, (int)RENDER_ENGINE_OPENGL_LEGACY );
827 
828  aCfg->Read( keyRenderMaterial, &tmpi, (int)MATERIAL_MODE_NORMAL );
830 }
831 
832 
833 void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
834 {
836 
837  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::SaveSettings" ) );
838 
839  aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
840  aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
841  aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
842 
843  aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
844  aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
845  aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
846 
850 
854 
858 
859  aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
861  aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
862 
866 
868 
870 
871  aCfg->Write( keyRenderEngine, (int)m_settings.RenderEngineGet() );
872 
874 
875  aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() );
876 
877  // OpenGL options
880 
881  // Raytracing options
889 
890  aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
891  aCfg->Write( keyShowGrid, (int)m_settings.GridGet() );
892 
896 
897  aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
903  aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
905 }
906 
907 
908 void EDA_3D_VIEWER::OnLeftClick( wxDC *DC, const wxPoint &MousePos )
909 {
910  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnLeftClick" ) );
911  // Do nothing
912 }
913 
914 
915 void EDA_3D_VIEWER::OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu )
916 {
917  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnRightClick" ) );
918  // Do nothing
919 }
920 
921 
922 void EDA_3D_VIEWER::RedrawActiveWindow( wxDC *DC, bool EraseBg )
923 {
924  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::RedrawActiveWindow" ) );
925  // Do nothing
926 }
927 
928 
929 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
930 {
931  wxString fullFileName;
932  bool fmt_is_jpeg = false;
933 
934  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
935  fmt_is_jpeg = true;
936 
937  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
938  {
939  // Remember path between saves during this session only.
940  static wxFileName fn;
941  const wxString file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
942  const wxString mask = wxT( "*." ) + file_ext;
943 
944  // First time path is set to the project path.
945  if( !fn.IsOk() )
946  fn = Parent()->Prj().GetProjectFullName();
947 
948  fn.SetExt( file_ext );
949 
950  fullFileName = EDA_FILE_SELECTOR( _( "3D Image File Name:" ), fn.GetPath(),
951  m_defaultFileName, file_ext, mask, this,
952  wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );
953 
954  if( fullFileName.IsEmpty() )
955  return;
956 
957  fn = fullFileName;
958 
959  // Be sure the screen area destroyed by the file dialog is redrawn
960  // before making a screen copy.
961  // Without this call, under Linux the screen refresh is made to late.
962  wxYield();
963  }
964 
965  // Be sure we have the latest 3D view (remember 3D view is buffered)
966  Refresh();
967  wxYield();
968 
969  // Build image from the 3D buffer
970  wxWindowUpdateLocker noUpdates( this );
971 
972  wxImage screenshotImage;
973 
974  if( m_canvas )
975  m_canvas->GetScreenshot( screenshotImage );
976 
977  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
978  {
979  wxBitmap bitmap( screenshotImage );
980 
981  if( wxTheClipboard->Open() )
982  {
983  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
984 
985  if( !wxTheClipboard->SetData( dobjBmp ) )
986  wxMessageBox( _( "Failed to copy image to clipboard" ) );
987 
988  wxTheClipboard->Flush(); /* the data in clipboard will stay
989  * available after the application exits */
990  wxTheClipboard->Close();
991  }
992  }
993  else
994  {
995  if( !screenshotImage.SaveFile( fullFileName,
996  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
997  wxMessageBox( _( "Can't save file" ) );
998 
999  screenshotImage.Destroy();
1000  }
1001 
1002 }
1003 
1004 
1006 {
1007  if( m_canvas )
1009 
1012 
1013  m_mainToolBar->Refresh();
1014 }
1015 
1016 
1017 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
1018  wxColourData* aPredefinedColors )
1019 {
1020  wxColour newcolor, oldcolor;
1021 
1022  oldcolor.Set( KiROUND( aColor.r * 255 ),
1023  KiROUND( aColor.g * 255 ),
1024  KiROUND( aColor.b * 255 ) );
1025 
1026  wxColourData emptyColorSet; // Provides a empty predefined set of colors
1027  // if no color set available to avoid use of an
1028  // old color set
1029 
1030  if( aPredefinedColors == NULL )
1031  aPredefinedColors = &emptyColorSet;
1032 
1033  newcolor = wxGetColourFromUser( this, oldcolor, aTitle, aPredefinedColors );
1034 
1035  if( !newcolor.IsOk() ) // Cancel command
1036  return false;
1037 
1038  if( newcolor != oldcolor )
1039  {
1040  aColor.r = (double) newcolor.Red() / 255.0;
1041  aColor.g = (double) newcolor.Green() / 255.0;
1042  aColor.b = (double) newcolor.Blue() / 255.0;
1043  }
1044 
1045  return true;
1046 }
1047 
1048 
1050 {
1051  wxColourData definedColors;
1052  unsigned int i = 0;
1053 
1054  definedColors.SetCustomColour( i++, wxColour( 241, 241, 241 ) ); // White
1055  definedColors.SetCustomColour( i++, wxColour( 4, 18, 21 ) ); // Dark
1056 
1057  for(; i < wxColourData::NUM_CUSTOM;)
1058  {
1059  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1060  }
1061 
1063  _( "Silk Screen Color" ),
1064  &definedColors );
1065 
1066  if( change )
1067  NewDisplay();
1068 
1069  return change;
1070 }
1071 
1072 
1074 {
1075  wxColourData definedColors;
1076  unsigned int i = 0;
1077 
1078  definedColors.SetCustomColour( i++, wxColour( 20, 51, 36 ) ); // Green
1079  definedColors.SetCustomColour( i++, wxColour( 91, 168, 12 ) ); // Light Green
1080  definedColors.SetCustomColour( i++, wxColour( 13, 104, 11 ) ); // Saturated Green
1081  definedColors.SetCustomColour( i++, wxColour(181, 19, 21 ) ); // Red
1082  definedColors.SetCustomColour( i++, wxColour(239, 53, 41 ) ); // Red Light Orange
1083  definedColors.SetCustomColour( i++, wxColour(210, 40, 14 ) ); // Red 2
1084  definedColors.SetCustomColour( i++, wxColour( 2, 59, 162 ) ); // Blue
1085  definedColors.SetCustomColour( i++, wxColour( 54, 79, 116 ) ); // Light blue 1
1086  definedColors.SetCustomColour( i++, wxColour( 61, 85, 130 ) ); // Light blue 2
1087  definedColors.SetCustomColour( i++, wxColour( 21, 70, 80 ) ); // Green blue (dark)
1088  definedColors.SetCustomColour( i++, wxColour( 11, 11, 11 ) ); // Black
1089  definedColors.SetCustomColour( i++, wxColour( 245, 245,245 ) ); // White
1090  definedColors.SetCustomColour( i++, wxColour(119, 31, 91 ) ); // Purple
1091  definedColors.SetCustomColour( i++, wxColour( 32, 2, 53 ) ); // Purple Dark
1092 
1093  for(; i < wxColourData::NUM_CUSTOM;)
1094  {
1095  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1096  }
1097 
1099  _( "Solder Mask Color" ),
1100  &definedColors );
1101 
1102  if( change )
1103  NewDisplay();
1104 
1105  return change;
1106 }
1107 
1108 
1110 {
1111  wxColourData definedColors;
1112  unsigned int i = 0;
1113 
1114  definedColors.SetCustomColour( i++, wxColour( 184, 115, 50) ); // Copper
1115  definedColors.SetCustomColour( i++, wxColour( 191, 155, 58) ); // Gold
1116  definedColors.SetCustomColour( i++, wxColour( 213, 213, 213) ); // Silver
1117  definedColors.SetCustomColour( i++, wxColour( 160, 160, 160) ); // tin
1118 
1119  for(; i < wxColourData::NUM_CUSTOM;)
1120  {
1121  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1122  }
1123 
1125  _( "Copper Color" ),
1126  &definedColors );
1127 
1128  if( change )
1129  NewDisplay();
1130 
1131  return change;
1132 }
1133 
1134 
1136 {
1137  wxColourData definedColors;
1138  unsigned int i = 0;
1139 
1140  definedColors.SetCustomColour( i++, wxColour( 51, 43, 22 ) ); // FR4 natural, dark
1141  definedColors.SetCustomColour( i++, wxColour( 109, 116, 75 ) ); // FR4 natural
1142  definedColors.SetCustomColour( i++, wxColour( 78, 14, 5 ) ); // brown/red
1143  definedColors.SetCustomColour( i++, wxColour( 146, 99, 47 ) ); // brown 1
1144  definedColors.SetCustomColour( i++, wxColour( 160, 123, 54 ) ); // brown 2
1145  definedColors.SetCustomColour( i++, wxColour( 146, 99, 47 ) ); // brown 3
1146  definedColors.SetCustomColour( i++, wxColour( 63, 126, 71 ) ); // green 1
1147  definedColors.SetCustomColour( i++, wxColour( 117, 122, 90 ) ); // green 2
1148 
1149  for(; i < wxColourData::NUM_CUSTOM;)
1150  {
1151  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1152  }
1153 
1155  _( "Board Body Color" ),
1156  &definedColors );
1157 
1158  if( change )
1159  NewDisplay();
1160 
1161  return change;
1162 }
1163 
1164 
1166 {
1167  wxColourData definedColors;
1168  unsigned int i = 0;
1169 
1170  definedColors.SetCustomColour( i++, wxColour( 128, 128, 128 ) ); // grey
1171  definedColors.SetCustomColour( i++, wxColour( 213, 213, 213 ) ); // Silver
1172  definedColors.SetCustomColour( i++, wxColour( 90, 90, 90 ) ); // grey 2
1173 
1174  for(; i < wxColourData::NUM_CUSTOM;)
1175  {
1176  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1177  }
1178 
1180  _( "Solder Paste Color" ),
1181  &definedColors );
1182 
1183  if( change )
1184  NewDisplay();
1185 
1186  return change;
1187 }
1188 
1189 
1190 // Define 3D Viewer Hotkeys
1191 static EDA_HOTKEY Hk3D_PivotCenter( _HKI( "Center pivot rotation (Middle mouse click)" ), 0, WXK_SPACE );
1192 static EDA_HOTKEY Hk3D_MoveLeft( _HKI( "Move board Left" ), ID_POPUP_MOVE3D_LEFT, WXK_LEFT );
1193 static EDA_HOTKEY Hk3D_MoveRight( _HKI( "Move board Right" ), ID_POPUP_MOVE3D_RIGHT, WXK_RIGHT );
1194 static EDA_HOTKEY Hk3D_MoveUp( _HKI( "Move board Up" ), ID_POPUP_MOVE3D_UP, WXK_UP );
1195 static EDA_HOTKEY Hk3D_MoveDown( _HKI( "Move board Down" ), ID_POPUP_MOVE3D_DOWN, WXK_DOWN );
1196 static EDA_HOTKEY Hk3D_HomeView( _HKI( "Home view" ), 0, WXK_HOME );
1197 static EDA_HOTKEY Hk3D_ResetView( _HKI( "Reset view" ), 0, 'R' );
1198 
1199 static EDA_HOTKEY Hk3D_ViewFront( _HKI( "View Front" ), ID_POPUP_VIEW_YPOS, 'y' );
1200 static EDA_HOTKEY Hk3D_ViewBack( _HKI( "View Back" ), ID_POPUP_VIEW_YNEG, 'Y' );
1201 static EDA_HOTKEY Hk3D_ViewLeft( _HKI( "View Left" ), ID_POPUP_VIEW_XNEG, 'X' );
1202 static EDA_HOTKEY Hk3D_ViewRight( _HKI( "View Right" ), ID_POPUP_VIEW_XPOS, 'x' );
1203 static EDA_HOTKEY Hk3D_ViewTop( _HKI( "View Top" ), ID_POPUP_VIEW_ZPOS, 'z' );
1204 static EDA_HOTKEY Hk3D_ViewBot( _HKI( "View Bot" ), ID_POPUP_VIEW_ZNEG, 'Z' );
1205 
1206 static EDA_HOTKEY Hk3D_Rotate45axisZ( _HKI( "Rotate 45 degrees over Z axis" ), 0, WXK_TAB );
1207 static EDA_HOTKEY Hk3D_ZoomIn( _HKI( "Zoom in " ), ID_POPUP_ZOOMIN, WXK_F1 );
1208 static EDA_HOTKEY Hk3D_ZoomOut( _HKI( "Zoom out" ), ID_POPUP_ZOOMOUT, WXK_F2 );
1209 static EDA_HOTKEY Hk3D_AttributesTHT( _HKI( "Toggle 3D models with type Through Hole" ), 0, 'T' );
1210 static EDA_HOTKEY Hk3D_AttributesSMD( _HKI( "Toggle 3D models with type Surface Mount" ), 0, 'S' );
1211 static EDA_HOTKEY Hk3D_AttributesVirtual( _HKI( "Toggle 3D models with type Virtual" ), 0, 'V' );
1212 
1213 static wxString viewer3DSectionTitle( _HKI( "Viewer 3D" ) );
1214 
1215 // List of hotkey descriptors for the 3D Viewer only
1216 // !TODO: this is used just for help menu, the structured are not used yet in the viewer
1218 {
1220  &Hk3D_MoveLeft,
1221  &Hk3D_MoveRight,
1222  &Hk3D_MoveUp,
1223  &Hk3D_MoveDown,
1224  &Hk3D_HomeView,
1225  &Hk3D_ResetView,
1226  &Hk3D_ViewFront,
1227  &Hk3D_ViewBack,
1228  &Hk3D_ViewLeft,
1229  &Hk3D_ViewRight,
1230  &Hk3D_ViewTop,
1231  &Hk3D_ViewBot,
1233  &Hk3D_ZoomIn,
1234  &Hk3D_ZoomOut,
1238  NULL
1239 };
1240 
1241 
1242 // list of sections and corresponding hotkey list for the 3D Viewer
1243 // (used to list current hotkeys)
1245 {
1247  { NULL, NULL, NULL }
1248 };
1249 
1250 
1252 {
1253  DisplayHotkeyList( this, g_3DViewer_Hokeys_Descr );
1254 }
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:487
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:62
#define DIM(x)
of elements in an array
Definition: macros.h:98
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
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:106
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:270
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:335
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:149
static EDA_HOTKEY Hk3D_ViewBot(_HKI("View Bot"), ID_POPUP_VIEW_ZNEG, 'Z')
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:503
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
static EDA_HOTKEY Hk3D_MoveDown(_HKI("Move board Down"), ID_POPUP_MOVE3D_DOWN, WXK_DOWN)
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.
void MaterialModeSet(MATERIAL_MODE aMaterialMode)
MaterialModeSet.
Definition: cinfo3d_visu.h:240
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
static const wxChar keyShowRealisticMode[]
static EDA_HOTKEY Hk3D_ZoomOut(_HKI("Zoom out"), ID_POPUP_ZOOMOUT, WXK_F2)
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
Definition: cinfo3d_visu.h:505
EDA_3D_CANVAS * m_canvas
The canvas where the openGL context will be rendered.
static const wxChar keyCopperColor_Blue[]
static const wxChar keySMaskColor_Green[]
static EDA_HOTKEY Hk3D_ViewRight(_HKI("View Right"), ID_POPUP_VIEW_XPOS, 'x')
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')
void Refresh()
Update the board display after modifying it bu a python script (note: it is automatically called by a...
static const wxChar keyShowZones[]
static const wxChar keyRenderMaterial[]
static const wxChar keyRenderRAY_AAliasing[]
static EDA_HOTKEY Hk3D_ResetView(_HKI("Reset view"), 0, 'R')
static EDA_HOTKEY Hk3D_ViewTop(_HKI("View Top"), ID_POPUP_VIEW_ZPOS, 'z')
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:275
static EDA_HOTKEY Hk3D_MoveRight(_HKI("Move board Right"), ID_POPUP_MOVE3D_RIGHT, WXK_RIGHT)
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 const wxChar keyBgColor_Green[]
static const wxChar keyBoardBodyColor_Blue[]
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:145
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:234
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:506
static EDA_HOTKEY Hk3D_MoveLeft(_HKI("Move board Left"), ID_POPUP_MOVE3D_LEFT, WXK_LEFT)
GRID3D_TYPE
Grid types.
Definition: 3d_enums.h:72
static const wxChar keyRenderOGL_ShowModelBBox[]
static EDA_HOTKEY Hk3D_ZoomIn(_HKI("Zoom in "), ID_POPUP_ZOOMIN, WXK_F1)
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 EDA_HOTKEY Hk3D_ViewLeft(_HKI("View Left"), ID_POPUP_VIEW_XNEG, 'X')
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
static EDA_HOTKEY Hk3D_MoveUp(_HKI("Move board Up"), ID_POPUP_MOVE3D_UP, WXK_UP)
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 EDA_HOTKEY Hk3D_ViewBack(_HKI("View Back"), ID_POPUP_VIEW_YNEG, 'Y')
static const wxChar keySMaskColor_Blue[]
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
void OnRenderEngineSelection(wxCommandEvent &event)
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"))
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.
#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_ViewFront(_HKI("View Front"), ID_POPUP_VIEW_YPOS, 'y')
bool Set3DBoardBodyColorFromUser()
Function Set3DBoardBodyBodyColorFromUser 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)
void takeScreenshot(wxCommandEvent &event)
Function TakeScreenshot Create a Screenshot of the current 3D view.