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 keyRenderTextures[] = wxT( "Render_Textures" );
86 static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
87 
88 static const wxChar keyRenderOGL_ShowCopperTck[]= wxT( "Render_OGL_ShowCopperThickness" );
89 static const wxChar keyRenderOGL_ShowModelBBox[]= wxT( "Render_OGL_ShowModelBoudingBoxes" );
90 
91 static const wxChar keyRenderRAY_Shadows[] = wxT( "Render_RAY_Shadows" );
92 static const wxChar keyRenderRAY_Backfloor[] = wxT( "Render_RAY_Backfloor" );
93 static const wxChar keyRenderRAY_Refractions[] = wxT( "Render_RAY_Refractions" );
94 static const wxChar keyRenderRAY_Reflections[] = wxT( "Render_RAY_Reflections" );
95 static const wxChar keyRenderRAY_PostProcess[] = wxT( "Render_RAY_PostProcess" );
96 static const wxChar keyRenderRAY_AAliasing[] = wxT( "Render_RAY_AntiAliasing" );
97 static const wxChar keyRenderRAY_ProceduralT[] = wxT( "Render_RAY_ProceduralTextures" );
98 
99 static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
100 static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
101 static const wxChar keyShowZones[] = wxT( "ShowZones" );
102 static const wxChar keyShowFootprints_Normal[] = wxT( "ShowFootprints_Normal" );
103 static const wxChar keyShowFootprints_Insert[] = wxT( "ShowFootprints_Insert" );
104 static const wxChar keyShowFootprints_Virtual[] = wxT( "ShowFootprints_Virtual" );
105 static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
106 static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
107 static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
108 static const wxChar keyShowSolderPasteLayers[] = wxT( "ShowSolderPasteLayers" );
109 static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
110 static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
111 static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
112 
113 
114 BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
115 
116  EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
117  EVT_SET_FOCUS( EDA_3D_VIEWER::OnSetFocus )
118 
120  EDA_3D_VIEWER::ProcessZoom )
121 
123  EDA_3D_VIEWER::Process_Special_Functions )
124 
125  EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_VIEWER::Install3DViewOptionDialog )
126 
127  EVT_MENU( wxID_EXIT,
128  EDA_3D_VIEWER::Exit3DFrame )
129 
131  EDA_3D_VIEWER::On3DGridSelection )
132 
134  EDA_3D_VIEWER::OnRenderEngineSelection )
135 
136  EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow )
137 
138  EVT_UPDATE_UI_RANGE( ID_START_COMMAND_3D, ID_MENU_COMMAND_END,
139  EDA_3D_VIEWER::OnUpdateMenus )
140 
141 END_EVENT_TABLE()
142 
143 
145  PCB_BASE_FRAME *aParent,
146  const wxString &aTitle,
147  long style ) :
148 
149  KIWAY_PLAYER( aKiway,
150  aParent,
152  aTitle,
153  wxDefaultPosition,
154  wxDefaultSize,
155  style,
157 {
158  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::EDA_3D_VIEWER %s" ), aTitle );
159 
160  m_canvas = NULL;
161  m_defaultFileName = "";
162 
163  // Give it an icon
164  wxIcon icon;
165  icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
166  SetIcon( icon );
167 
168  LoadSettings( config() );
169  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
170 
171  // Create the status line
172  static const int status_dims[4] = { -1, 130, 130, 170 };
173 
174  wxStatusBar *status_bar = CreateStatusBar( DIM( status_dims ) );
175  SetStatusWidths( DIM( status_dims ), status_dims );
176 
177  CreateMenuBar();
178  ReCreateMainToolbar();
179 
180  m_canvas = new EDA_3D_CANVAS( this,
182  aParent->GetBoard(),
183  m_settings,
184  Prj().Get3DCacheManager() );
185 
186  if( m_canvas )
187  m_canvas->SetStatusBar( status_bar );
188 
189  m_auimgr.SetManagedWindow( this );
190 
191  EDA_PANEINFO horiztb;
192  horiztb.HorizontalToolbarPane();
193 
194  m_auimgr.AddPane( m_mainToolBar,
195  wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() );
196 
197  if( m_canvas )
198  m_auimgr.AddPane( m_canvas,
199  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
200 
201  m_auimgr.Update();
202 
203  m_mainToolBar->EnableTool( ID_RENDER_CURRENT_VIEW,
204  (m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY) );
205 
206  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
207  // in order to receive mouse events. Otherwise, the user has to click somewhere on
208  // the canvas before it will respond to mouse wheel events.
209  if( m_canvas )
210  m_canvas->SetFocus();
211 }
212 
213 
215 {
216  m_auimgr.UnInit();
217 
218  // m_canvas delete will be called by wxWidget manager
219  //delete m_canvas;
220  //m_canvas = 0;
221 }
222 
223 
225 {
226  // This will schedule a request to load later
227  if( m_canvas )
228  m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() );
229 }
230 
231 
232 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
233 {
234  ReloadRequest();
235 
236  // After the ReloadRequest call, the refresh often takes a bit of time,
237  // and it is made here only on request.
238  if( aForceImmediateRedraw )
239  m_canvas->Refresh();
240 }
241 
242 
243 void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
244 {
245  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::Exit3DFrame" ) );
246 
247  Close( true );
248 }
249 
250 
251 void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
252 {
253  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnCloseWindow" ) );
254 
255  if( m_canvas )
256  m_canvas->Close();
257 
258  // m_canvas delete will be called by wxWidget manager
259  //delete m_canvas;
260  //m_canvas = 0;
261 
262  Destroy();
263  event.Skip( true );
264 }
265 
266 #define ROT_ANGLE 10.0
267 
268 void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
269 {
270  int id = event.GetId();
271  bool isChecked = event.IsChecked();
272 
273  wxLogTrace( m_logTrace,
274  wxT( "EDA_3D_VIEWER::Process_Special_Functions id:%d isChecked:%d" ),
275  id, isChecked );
276 
277  if( m_canvas == NULL )
278  return;
279 
280  switch( id )
281  {
284  break;
285 
286  case ID_RELOAD3D_BOARD:
287  ReloadRequest();
289  break;
290 
291  case ID_ROTATE3D_X_POS:
292  m_settings.CameraGet().RotateX( glm::radians(ROT_ANGLE) );
294  break;
295 
296  case ID_ROTATE3D_X_NEG:
297  m_settings.CameraGet().RotateX( -glm::radians(ROT_ANGLE) );
299  break;
300 
301  case ID_ROTATE3D_Y_POS:
302  m_settings.CameraGet().RotateY( glm::radians(ROT_ANGLE) );
304  break;
305 
306  case ID_ROTATE3D_Y_NEG:
307  m_settings.CameraGet().RotateY( -glm::radians(ROT_ANGLE) );
309  break;
310 
311  case ID_ROTATE3D_Z_POS:
312  m_settings.CameraGet().RotateZ( glm::radians(ROT_ANGLE) );
314  break;
315 
316  case ID_ROTATE3D_Z_NEG:
317  m_settings.CameraGet().RotateZ( -glm::radians(ROT_ANGLE) );
319  break;
320 
321  case ID_MOVE3D_LEFT:
322  m_canvas->SetView3D( WXK_LEFT );
323  return;
324 
325  case ID_MOVE3D_RIGHT:
326  m_canvas->SetView3D( WXK_RIGHT );
327  return;
328 
329  case ID_MOVE3D_UP:
330  m_canvas->SetView3D( WXK_UP );
331  return;
332 
333  case ID_MOVE3D_DOWN:
334  m_canvas->SetView3D( WXK_DOWN );
335  return;
336 
337  case ID_ORTHO:
340  return;
341 
345  takeScreenshot( event );
346  return;
347 
349  if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ) ) )
350  {
353  else
354  ReloadRequest();
355  }
356  return;
357 
359  if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ) ) )
360  {
363  else
364  ReloadRequest();
365  }
366  return;
367 
370  return;
371 
374  return;
375 
378  return;
379 
382  break;
383 
386  break;
387 
390  break;
391 
395  ReloadRequest( );
396  return;
397 
400  ReloadRequest( );
401  return;
402 
405  ReloadRequest( );
406  return;
407 
410  ReloadRequest( );
411  return;
412 
415  ReloadRequest();
416  return;
417 
421  return;
422 
426  return;
427 
430  ReloadRequest( );
431  return;
432 
435  ReloadRequest( );
436  return;
437 
441  return;
442 
446  return;
447 
450  ReloadRequest( );
451  return;
452 
456  return;
457 
459  m_settings.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
460  ReloadRequest( );
461  return;
462 
464  m_settings.SetFlag( FL_AXIS, isChecked );
466  return;
467 
470  ReloadRequest( );
471  return;
472 
475  ReloadRequest( );
476  return;
477 
480  ReloadRequest( );
481  return;
482 
484  m_settings.SetFlag( FL_ZONE, isChecked );
485  ReloadRequest( );
486  return;
487 
489  m_settings.SetFlag( FL_ADHESIVE, isChecked );
490  ReloadRequest( );
491  return;
492 
494  m_settings.SetFlag( FL_SILKSCREEN, isChecked );
495  ReloadRequest( );
496  return;
497 
499  m_settings.SetFlag( FL_SOLDERMASK, isChecked );
500  ReloadRequest( );
501  return;
502 
504  m_settings.SetFlag( FL_SOLDERPASTE, isChecked );
505  ReloadRequest( );
506  return;
507 
509  m_settings.SetFlag( FL_COMMENTS, isChecked );
510  ReloadRequest( );
511  return;
512 
513  case ID_MENU3D_ECO_ONOFF:
514  m_settings.SetFlag( FL_ECO, isChecked );
515  ReloadRequest( );
516  return;
517 
519  {
520  // Reload settings with a dummy config, so it will load the defaults
521  wxConfig *fooconfig = new wxConfig("FooBarApp");
522  LoadSettings( fooconfig );
523  delete fooconfig;
524 
525  // Refresh menu option state
527 
528  // Tell canvas that we (may) changed the render engine
530 
531  ReloadRequest();
532  }
533  return;
534 
536  {
537  DisplayHotKeys();
538  }
539  return;
540 
541  default:
542  wxLogMessage( wxT( "EDA_3D_VIEWER::Process_Special_Functions() error: unknown command %d" ), id );
543  return;
544  }
545 }
546 
547 
548 void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event )
549 {
550  int id = event.GetId();
551 
552  wxASSERT( id < ID_MENU3D_GRID_END );
553  wxASSERT( id > ID_MENU3D_GRID );
554 
555  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::On3DGridSelection id:%d" ), id );
556 
557  switch( id )
558  {
561  break;
562 
565  break;
566 
567  case ID_MENU3D_GRID_5_MM:
569  break;
570 
573  break;
574 
575  case ID_MENU3D_GRID_1_MM:
577  break;
578 
579  default:
580  wxLogMessage( wxT( "EDA_3D_VIEWER::On3DGridSelection() error: unknown command %d" ), id );
581  return;
582  }
583 
584  if( m_canvas )
586 }
587 
588 
589 void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
590 {
591  int id = event.GetId();
592 
593  wxASSERT( id < ID_MENU3D_ENGINE_END );
594  wxASSERT( id > ID_MENU3D_ENGINE );
595 
596  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnRenderEngineSelection id:%d" ), id );
597 
598  const RENDER_ENGINE old_engine = m_settings.RenderEngineGet();
599 
600  switch( id )
601  {
603  if( old_engine != RENDER_ENGINE_OPENGL_LEGACY )
605  break;
606 
608  if( old_engine != RENDER_ENGINE_RAYTRACING )
610  break;
611 
612  default:
613  wxLogMessage( wxT( "EDA_3D_VIEWER::OnRenderEngineSelection() error: unknown command %d" ), id );
614  return;
615  }
616 
617  if( old_engine != m_settings.RenderEngineGet() )
618  {
620  }
621 }
622 
623 
624 void EDA_3D_VIEWER::OnUpdateMenus(wxUpdateUIEvent &event)
625 {
627  // to have it working this way
629 }
630 
631 
632 void EDA_3D_VIEWER::ProcessZoom( wxCommandEvent &event )
633 {
634  int id = event.GetId();
635 
636  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::ProcessZoom id:%d" ), id );
637 
638  if( m_canvas == NULL )
639  return;
640 
641  switch( id )
642  {
643  case ID_ZOOM_PAGE:
644  m_canvas->SetView3D( WXK_HOME );
645  break;
646 
647  case ID_ZOOM_IN:
648  m_canvas->SetView3D( WXK_F1 );
649  break;
650 
651  case ID_ZOOM_OUT:
652  m_canvas->SetView3D( WXK_F2 );
653  break;
654 
655  case ID_ZOOM_REDRAW:
657  break;
658 
659  default:
660  wxLogMessage( wxT( "EDA_3D_VIEWER::ProcessZoom() error: unknown command %d" ), id );
661  return;
662  }
663 
665 }
666 
667 
668 void EDA_3D_VIEWER::OnActivate( wxActivateEvent &event )
669 {
670  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnActivate" ) );
671 
672  if( m_canvas )
673  {
674  // Reload data if 3D frame shows a board,
675  // because it can be changed since last frame activation
678 
679  // Activates again the focus of the canvas so it will catch mouse and key events
680  m_canvas->SetFocus();
681  }
682 
683  event.Skip(); // required under wxMAC
684 }
685 
686 
687 void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
688 {
689  // Activates again the focus of the canvas so it will catch mouse and key events
690  if( m_canvas )
691  m_canvas->SetFocus();
692 
693  event.Skip();
694 }
695 
696 
697 void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg )
698 {
700 
701  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::LoadSettings" ) );
702 
703  aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
704  aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
705  aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
706 
707  aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
708  aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
709  aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
710 
711  // m_SolderMaskColor default value = dark grey-green
712  aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColor.r, 100.0 * 0.2 / 255.0 );
713  aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColor.g, 255.0 * 0.2 / 255.0 );
714  aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColor.b, 180.0 * 0.2 / 255.0 );
715 
716  // m_SolderPasteColor default value = light grey
717  aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 /255.0 );
718  aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 /255.0 );
719  aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 /255.0 );
720 
721  // m_SilkScreenColor default value = white
722  aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColor.r, 0.9 );
723  aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColor.g, 0.9 );
724  aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColor.b, 0.9 );
725 
726  // m_CopperColor default value = gold
727  aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
728  aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
729  aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 /255.0 );
730 
731  // m_BoardBodyColor default value = FR4, in realistic mode
732  aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
733  aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
734  aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 /255.0 );
735 
736 
737  bool tmp;
738  aCfg->Read( keyMousewheelPanning, &tmp, false );
740 
741  aCfg->Read( keyShowRealisticMode, &tmp, true );
743 
744  // OpenGL options
745  aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
747 
748  aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
750 
751  // Raytracing options
752  aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
754 
755  aCfg->Read( keyRenderRAY_Backfloor, &tmp, true );
757 
758  aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
760 
761  aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
763 
764  aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
766 
767  aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
769 
770  aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
772 
773  aCfg->Read( keyShowAxis, &tmp, true );
774  m_settings.SetFlag( FL_AXIS, tmp );
775 
776  aCfg->Read( keyShowFootprints_Normal, &tmp, true );
778 
779  aCfg->Read( keyShowFootprints_Insert, &tmp, true );
781 
782  aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
784 
785  aCfg->Read( keyShowZones, &tmp, true );
786  m_settings.SetFlag( FL_ZONE, tmp );
787 
788  aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
790 
791  aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
793 
794  aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
796 
797  aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
799 
800  aCfg->Read( keyShowCommentsLayer, &tmp, true );
802 
803  aCfg->Read( keyShowEcoLayers, &tmp, true );
804  m_settings.SetFlag( FL_ECO, tmp );
805 
806  aCfg->Read( keyShowBoardBody, &tmp, true );
808 
809  int tmpi;
810  aCfg->Read( keyShowGrid, &tmpi, (int)GRID3D_NONE );
811  m_settings.GridSet( (GRID3D_TYPE)tmpi );
812 
813  aCfg->Read( keyRenderEngine, &tmpi, (int)RENDER_ENGINE_OPENGL_LEGACY );
815 
816  aCfg->Read( keyRenderMaterial, &tmpi, (int)MATERIAL_MODE_NORMAL );
818 }
819 
820 
821 void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
822 {
824 
825  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::SaveSettings" ) );
826 
827  aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
828  aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
829  aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
830 
831  aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
832  aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
833  aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
834 
838 
842 
846 
847  aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
849  aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
850 
854 
856 
858 
859  aCfg->Write( keyRenderEngine, (int)m_settings.RenderEngineGet() );
860 
861  aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() );
862 
863  // OpenGL options
866 
867  // Raytracing options
875 
876  aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
877  aCfg->Write( keyShowGrid, (int)m_settings.GridGet() );
878 
882 
883  aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
889  aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
891 }
892 
893 
894 void EDA_3D_VIEWER::OnLeftClick( wxDC *DC, const wxPoint &MousePos )
895 {
896  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnLeftClick" ) );
897  // Do nothing
898 }
899 
900 
901 void EDA_3D_VIEWER::OnRightClick( const wxPoint &MousePos, wxMenu *PopMenu )
902 {
903  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::OnRightClick" ) );
904  // Do nothing
905 }
906 
907 
908 void EDA_3D_VIEWER::RedrawActiveWindow( wxDC *DC, bool EraseBg )
909 {
910  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::RedrawActiveWindow" ) );
911  // Do nothing
912 }
913 
914 
915 void EDA_3D_VIEWER::takeScreenshot( wxCommandEvent& event )
916 {
917  wxString fullFileName;
918  bool fmt_is_jpeg = false;
919 
920  if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
921  fmt_is_jpeg = true;
922 
923  if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
924  {
925  // Remember path between saves during this session only.
926  static wxFileName fn;
927  const wxString file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
928  const wxString mask = wxT( "*." ) + file_ext;
929 
930  // First time path is set to the project path.
931  if( !fn.IsOk() )
932  fn = Parent()->Prj().GetProjectFullName();
933 
934  fn.SetExt( file_ext );
935 
936  fullFileName = EDA_FILE_SELECTOR( _( "3D Image File Name:" ), fn.GetPath(),
937  m_defaultFileName, file_ext, mask, this,
938  wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );
939 
940  if( fullFileName.IsEmpty() )
941  return;
942 
943  fn = fullFileName;
944 
945  // Be sure the screen area destroyed by the file dialog is redrawn
946  // before making a screen copy.
947  // Without this call, under Linux the screen refresh is made to late.
948  wxYield();
949  }
950 
951  // Be sure we have the latest 3D view (remember 3D view is buffered)
952  Refresh();
953  wxYield();
954 
955  // Build image from the 3D buffer
956  wxWindowUpdateLocker noUpdates( this );
957 
958  wxImage screenshotImage;
959 
960  if( m_canvas )
961  m_canvas->GetScreenshot( screenshotImage );
962 
963  if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
964  {
965  wxBitmap bitmap( screenshotImage );
966 
967  if( wxTheClipboard->Open() )
968  {
969  wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
970 
971  if( !wxTheClipboard->SetData( dobjBmp ) )
972  wxMessageBox( _( "Failed to copy image to clipboard" ) );
973 
974  wxTheClipboard->Flush(); /* the data in clipboard will stay
975  * available after the application exits */
976  wxTheClipboard->Close();
977  }
978  }
979  else
980  {
981  if( !screenshotImage.SaveFile( fullFileName,
982  fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
983  wxMessageBox( _( "Can't save file" ) );
984 
985  screenshotImage.Destroy();
986  }
987 
988 }
989 
990 
992 {
993  if( m_canvas )
995 
998 
999  m_mainToolBar->Refresh();
1000 }
1001 
1002 
1003 bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC3D &aColor, const wxString& aTitle,
1004  wxColourData* aPredefinedColors )
1005 {
1006  wxColour newcolor, oldcolor;
1007 
1008  oldcolor.Set( KiROUND( aColor.r * 255 ),
1009  KiROUND( aColor.g * 255 ),
1010  KiROUND( aColor.b * 255 ) );
1011 
1012  wxColourData emptyColorSet; // Provides a empty predefined set of colors
1013  // if no color set available to avoid use of an
1014  // old color set
1015 
1016  if( aPredefinedColors == NULL )
1017  aPredefinedColors = &emptyColorSet;
1018 
1019  newcolor = wxGetColourFromUser( this, oldcolor, aTitle, aPredefinedColors );
1020 
1021  if( !newcolor.IsOk() ) // Cancel command
1022  return false;
1023 
1024  if( newcolor != oldcolor )
1025  {
1026  aColor.r = (double) newcolor.Red() / 255.0;
1027  aColor.g = (double) newcolor.Green() / 255.0;
1028  aColor.b = (double) newcolor.Blue() / 255.0;
1029  }
1030 
1031  return true;
1032 }
1033 
1034 
1036 {
1037  wxColourData definedColors;
1038  unsigned int i = 0;
1039 
1040  definedColors.SetCustomColour( i++, wxColour( 241, 241, 241 ) ); // White
1041  definedColors.SetCustomColour( i++, wxColour( 4, 18, 21 ) ); // Dark
1042 
1043  for(; i < wxColourData::NUM_CUSTOM;)
1044  {
1045  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1046  }
1047 
1049  _( "Silk Screen Color" ),
1050  &definedColors );
1051 
1052  if( change )
1053  NewDisplay();
1054 
1055  return change;
1056 }
1057 
1058 
1060 {
1061  wxColourData definedColors;
1062  unsigned int i = 0;
1063 
1064  definedColors.SetCustomColour( i++, wxColour( 20, 51, 36 ) ); // Green
1065  definedColors.SetCustomColour( i++, wxColour( 91, 168, 12 ) ); // Light Green
1066  definedColors.SetCustomColour( i++, wxColour( 13, 104, 11 ) ); // Saturated Green
1067  definedColors.SetCustomColour( i++, wxColour(181, 19, 21 ) ); // Red
1068  definedColors.SetCustomColour( i++, wxColour(239, 53, 41 ) ); // Red Light Orange
1069  definedColors.SetCustomColour( i++, wxColour(210, 40, 14 ) ); // Red 2
1070  definedColors.SetCustomColour( i++, wxColour( 2, 59, 162 ) ); // Blue
1071  definedColors.SetCustomColour( i++, wxColour( 54, 79, 116 ) ); // Light blue 1
1072  definedColors.SetCustomColour( i++, wxColour( 61, 85, 130 ) ); // Light blue 2
1073  definedColors.SetCustomColour( i++, wxColour( 21, 70, 80 ) ); // Green blue (dark)
1074  definedColors.SetCustomColour( i++, wxColour( 11, 11, 11 ) ); // Black
1075  definedColors.SetCustomColour( i++, wxColour( 245, 245,245 ) ); // White
1076  definedColors.SetCustomColour( i++, wxColour(119, 31, 91 ) ); // Purple
1077  definedColors.SetCustomColour( i++, wxColour( 32, 2, 53 ) ); // Purple Dark
1078 
1079  for(; i < wxColourData::NUM_CUSTOM;)
1080  {
1081  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1082  }
1083 
1085  _( "Solder Mask Color" ),
1086  &definedColors );
1087 
1088  if( change )
1089  NewDisplay();
1090 
1091  return change;
1092 }
1093 
1094 
1096 {
1097  wxColourData definedColors;
1098  unsigned int i = 0;
1099 
1100  definedColors.SetCustomColour( i++, wxColour( 184, 115, 50) ); // Copper
1101  definedColors.SetCustomColour( i++, wxColour( 191, 155, 58) ); // Gold
1102  definedColors.SetCustomColour( i++, wxColour( 213, 213, 213) ); // Silver
1103  definedColors.SetCustomColour( i++, wxColour( 160, 160, 160) ); // tin
1104 
1105  for(; i < wxColourData::NUM_CUSTOM;)
1106  {
1107  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1108  }
1109 
1111  _( "Copper Color" ),
1112  &definedColors );
1113 
1114  if( change )
1115  NewDisplay();
1116 
1117  return change;
1118 }
1119 
1120 
1122 {
1123  wxColourData definedColors;
1124  unsigned int i = 0;
1125 
1126  definedColors.SetCustomColour( i++, wxColour( 51, 43, 22 ) ); // FR4 natural, dark
1127  definedColors.SetCustomColour( i++, wxColour( 109, 116, 75 ) ); // FR4 natural
1128  definedColors.SetCustomColour( i++, wxColour( 78, 14, 5 ) ); // brown/red
1129  definedColors.SetCustomColour( i++, wxColour( 146, 99, 47 ) ); // brown 1
1130  definedColors.SetCustomColour( i++, wxColour( 160, 123, 54 ) ); // brown 2
1131  definedColors.SetCustomColour( i++, wxColour( 146, 99, 47 ) ); // brown 3
1132  definedColors.SetCustomColour( i++, wxColour( 63, 126, 71 ) ); // green 1
1133  definedColors.SetCustomColour( i++, wxColour( 117, 122, 90 ) ); // green 2
1134 
1135  for(; i < wxColourData::NUM_CUSTOM;)
1136  {
1137  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1138  }
1139 
1141  _( "Board Body Color" ),
1142  &definedColors );
1143 
1144  if( change )
1145  NewDisplay();
1146 
1147  return change;
1148 }
1149 
1150 
1152 {
1153  wxColourData definedColors;
1154  unsigned int i = 0;
1155 
1156  definedColors.SetCustomColour( i++, wxColour( 128, 128, 128 ) ); // grey
1157  definedColors.SetCustomColour( i++, wxColour( 213, 213, 213 ) ); // Silver
1158  definedColors.SetCustomColour( i++, wxColour( 90, 90, 90 ) ); // grey 2
1159 
1160  for(; i < wxColourData::NUM_CUSTOM;)
1161  {
1162  definedColors.SetCustomColour( i++, wxColour( 0, 0, 0 ) );
1163  }
1164 
1166  _( "Solder Paste Color" ),
1167  &definedColors );
1168 
1169  if( change )
1170  NewDisplay();
1171 
1172  return change;
1173 }
1174 
1175 
1176 // Define 3D Viewer Hotkeys
1177 static EDA_HOTKEY Hk3D_PivotCenter( _HKI( "Center pivot rotation (Middle mouse click)" ), 0, WXK_SPACE );
1178 static EDA_HOTKEY Hk3D_MoveLeft( _HKI( "Move board Left" ), ID_POPUP_MOVE3D_LEFT, WXK_LEFT );
1179 static EDA_HOTKEY Hk3D_MoveRight( _HKI( "Move board Right" ), ID_POPUP_MOVE3D_RIGHT, WXK_RIGHT );
1180 static EDA_HOTKEY Hk3D_MoveUp( _HKI( "Move board Up" ), ID_POPUP_MOVE3D_UP, WXK_UP );
1181 static EDA_HOTKEY Hk3D_MoveDown( _HKI( "Move board Down" ), ID_POPUP_MOVE3D_DOWN, WXK_DOWN );
1182 static EDA_HOTKEY Hk3D_HomeView( _HKI( "Home view" ), 0, WXK_HOME );
1183 static EDA_HOTKEY Hk3D_ResetView( _HKI( "Reset view" ), 0, 'R' );
1184 
1185 static EDA_HOTKEY Hk3D_ViewFront( _HKI( "View Front" ), ID_POPUP_VIEW_YPOS, 'Y' );
1186 static EDA_HOTKEY Hk3D_ViewBack( _HKI( "View Back" ), ID_POPUP_VIEW_YNEG, GR_KB_SHIFT + 'Y' );
1187 static EDA_HOTKEY Hk3D_ViewLeft( _HKI( "View Left" ), ID_POPUP_VIEW_XNEG, GR_KB_SHIFT + 'X' );
1188 static EDA_HOTKEY Hk3D_ViewRight( _HKI( "View Right" ), ID_POPUP_VIEW_XPOS, 'X' );
1189 static EDA_HOTKEY Hk3D_ViewTop( _HKI( "View Top" ), ID_POPUP_VIEW_ZPOS, 'Z' );
1190 static EDA_HOTKEY Hk3D_ViewBot( _HKI( "View Bot" ), ID_POPUP_VIEW_ZNEG, GR_KB_SHIFT + 'Z' );
1191 
1192 static EDA_HOTKEY Hk3D_Rotate45axisZ( _HKI( "Rotate 45 degrees over Z axis" ), 0, WXK_TAB );
1193 static EDA_HOTKEY Hk3D_ZoomIn( _HKI( "Zoom in " ), ID_POPUP_ZOOMIN, WXK_F1 );
1194 static EDA_HOTKEY Hk3D_ZoomOut( _HKI( "Zoom out" ), ID_POPUP_ZOOMOUT, WXK_F2 );
1195 static EDA_HOTKEY Hk3D_AttributesTHT( _HKI( "Toggle 3D models with type Through Hole" ), 0, 'T' );
1196 static EDA_HOTKEY Hk3D_AttributesSMD( _HKI( "Toggle 3D models with type Surface Mount" ), 0, 'S' );
1197 static EDA_HOTKEY Hk3D_AttributesVirtual( _HKI( "Toggle 3D models with type Virtual" ), 0, 'V' );
1198 
1199 static wxString viewer3DSectionTitle( _HKI( "Viewer 3D" ) );
1200 
1201 // List of hotkey descriptors for the 3D Viewer only
1202 // !TODO: this is used just for help menu, the structured are not used yet in the viewer
1204 {
1206  &Hk3D_MoveLeft,
1207  &Hk3D_MoveRight,
1208  &Hk3D_MoveUp,
1209  &Hk3D_MoveDown,
1210  &Hk3D_HomeView,
1211  &Hk3D_ResetView,
1212  &Hk3D_ViewFront,
1213  &Hk3D_ViewBack,
1214  &Hk3D_ViewLeft,
1215  &Hk3D_ViewRight,
1216  &Hk3D_ViewTop,
1217  &Hk3D_ViewBot,
1219  &Hk3D_ZoomIn,
1220  &Hk3D_ZoomOut,
1224  NULL
1225 };
1226 
1227 
1228 // list of sections and corresponding hotkey list for the 3D Viewer
1229 // (used to list current hotkeys)
1231 {
1233  { NULL, NULL, NULL }
1234 };
1235 
1236 
1238 {
1239  DisplayHotkeyList( this, g_3DViewer_Hokeys_Descr );
1240 }
static const wxChar keyShowSolderMaskLayers[]
static const wxChar keyShowFootprints_Normal[]
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:62
static EDA_HOTKEY Hk3D_ViewRight(_HKI("View Right"), ID_POPUP_VIEW_XPOS, 'X')
#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:93
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:87
static EDA_HOTKEY Hk3D_ViewLeft(_HKI("View Left"), ID_POPUP_VIEW_XNEG, GR_KB_SHIFT+ 'X')
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
static const wxChar keyRenderRAY_Reflections[]
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.
static EDA_HOTKEY Hk3D_ViewFront(_HKI("View Front"), ID_POPUP_VIEW_YPOS, 'Y')
PROJECT & Prj()
Definition: kicad.cpp:270
void SetMenuBarOptionsState()
Set the state of toggle menus according to the current display options.
Definition: 3d_toolbar.cpp:415
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. ...
void RedrawActiveWindow(wxDC *DC, bool EraseBg)
Definition: id.h:241
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:94
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
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:503
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)
static EDA_HOTKEY Hk3D_ViewBot(_HKI("View Bot"), ID_POPUP_VIEW_ZNEG, GR_KB_SHIFT+ 'Z')
SFVEC3D m_BgColorTop
background top color
Definition: cinfo3d_visu.h:504
void Exit3DFrame(wxCommandEvent &event)
Called when user press the File->Exit.
void MaterialModeSet(MATERIAL_MODE aMaterialMode)
MaterialModeSet.
Definition: cinfo3d_visu.h:240
Specialization of the wxAuiPaneInfo class for KiCad panels.
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[]
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[]
EVT_TOOL(ID_MODVIEW_SELECT_LIB, FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary) EVT_TOOL(ID_MODVIEW_SELECT_PART
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:78
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[]
#define GR_KB_SHIFT
Definition: common.h:66
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.
static EDA_HOTKEY Hk3D_ViewBack(_HKI("View Back"), ID_POPUP_VIEW_YNEG, GR_KB_SHIFT+ 'Y')
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
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:94
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
void OnLeftClick(wxDC *DC, const wxPoint &MousePos)
void OnCloseWindow(wxCloseEvent &event)
Template define a least-recently-used cache algo based on wxHashMap and wxString http://docs.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:90
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.
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:71
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:92
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
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 const wxChar keySMaskColor_Blue[]
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
void OnRenderEngineSelection(wxCommandEvent &event)
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_HIGH_CONTRAST_MODE
RENDER_ENGINE
Render engine mode.
Definition: 3d_enums.h:82
static const wxChar keyBoardBodyColor_Green[]
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void OnSetFocus(wxFocusEvent &event)
static const wxChar keyShowAxis[]
static const wxChar keySPasteColor_Blue[]
void OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu)
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[]
static EDA_HOTKEY Hk3D_ViewTop(_HKI("View Top"), ID_POPUP_VIEW_ZPOS, 'Z')
#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
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.