KiCad PCB EDA Suite
dialog_3D_view_option.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2014-2020 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 
29 #include <bitmaps.h>
30 #include <tool/tool_manager.h>
31 
33 {
34 public:
35  explicit DIALOG_3D_VIEW_OPTIONS( EDA_3D_VIEWER* aParent );
36 
38  {
39  return static_cast<EDA_3D_VIEWER*>( DIALOG_SHIM::GetParent() );
40  }
41 
42 private:
45 
46  void initDialog();
47 
48  void OnCheckEnableAnimation( wxCommandEvent& WXUNUSED( event ) ) override;
49 
51  bool TransferDataFromWindow() override;
52 
54  bool TransferDataToWindow() override;
55 };
56 
57 
58 void EDA_3D_VIEWER::Install3DViewOptionDialog( wxCommandEvent& event )
59 {
60  DIALOG_3D_VIEW_OPTIONS dlg( this );
61 
62  if( dlg.ShowModal() == wxID_OK )
63  {
64  NewDisplay( true );
65  }
66 }
67 
68 
70  DIALOG_3D_VIEW_OPTIONS_BASE( aParent ),
71  m_settings( aParent->GetAdapter() ),
72  m_canvas( aParent->GetCanvas() )
73 {
74  initDialog();
75 
76  m_sdbSizerOK->SetDefault();
77 
78  // Now all widgets have the size fixed, call FinishDialogSettings
80 }
81 
82 
84 {
86  m_bitmapBoardBody->SetBitmap( KiBitmap( ortho_xpm ) );
88  m_bitmap3DshapesTH->SetBitmap( KiBitmap( shape_3d_xpm ) );
89  m_bitmap3DshapesSMD->SetBitmap( KiBitmap( shape_3d_xpm ) );
91  m_bitmapBoundingBoxes->SetBitmap( KiBitmap( axis3d_xpm ) );
92  m_bitmapAreas->SetBitmap( KiBitmap( add_zone_xpm ) );
93  m_bitmapSilkscreen->SetBitmap( KiBitmap( text_xpm ) );
96  m_bitmapAdhesive->SetBitmap( KiBitmap( tools_xpm ) );
97  m_bitmapComments->SetBitmap( KiBitmap( editor_xpm ) );
98  m_bitmapECO->SetBitmap( KiBitmap( editor_xpm ) );
100 }
101 
103 {
104  m_staticAnimationSpeed->Enable( m_checkBoxEnableAnimation->GetValue() );
105  m_sliderAnimationSpeed->Enable( m_checkBoxEnableAnimation->GetValue() );
106 }
107 
109 {
110  // Check/uncheck checkboxes
113  m_checkBoxAreas->SetValue( m_settings.GetFlag( FL_ZONE ) );
114 
118 
124  m_checkBoxECO->SetValue( m_settings.GetFlag( FL_ECO ) );
126 
127  // OpenGL options
134  m_choiceAntiAliasing->SetSelection( static_cast<int>( m_settings.AntiAliasingGet() ) );
135 
136  // Raytracing options
144 
145  // Camera Options
150 
152  m_spinCtrlRotationAngle->SetValue( ctrlTool->GetRotationIncrement() );
153 
154  return true;
155 }
156 
157 
159 {
160  // Set render mode
162 
163  // Set visibility of items
165  m_settings.SetFlag( FL_ZONE, m_checkBoxAreas->GetValue() );
167 
168  // Set 3D shapes visibility
172 
173  // Set Layer visibility
179  m_settings.SetFlag( FL_ECO, m_checkBoxECO->GetValue( ) );
180 
181  // OpenGL options
188  m_settings.AntiAliasingSet( static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() ) );
189 
190  // Raytracing options
198 
199  // Camera Options
202 
204  ctrlTool->SetRotationIncrement( m_spinCtrlRotationAngle->GetValue() );
205 
206  return true;
207 }
void AnimationEnabledSet(bool aAnimationEnabled)
AnimationEnabledSet - Enable or disable camera animation when switching to a pre-defined view.
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
void Install3DViewOptionDialog(wxCommandEvent &event)
const BITMAP_OPAQUE editor_xpm[1]
Definition: editor.cpp:83
DIALOG_3D_VIEW_OPTIONS(EDA_3D_VIEWER *aParent)
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
void SetRotationIncrement(double aRotIncrement)
Set the increment used by the RotateView actions.
Definition: 3d_controller.h:67
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_3D_VIEW_OPTIONS_BASE.
const BITMAP_OPAQUE ortho_xpm[1]
Definition: ortho.cpp:55
const BITMAP_OPAQUE text_xpm[1]
Definition: text.cpp:27
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:47
void MovingSpeedMultiplierSet(int aMovingSpeedMultiplier)
MovingSpeedMultiplierSet - Set the camera animation moving speed multiplier option.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
bool TransferDataToWindow() override
Automatically called after creating the dialog.
void AntiAliasingSet(ANTIALIASING_MODE aAAmode)
AntiAliasingSet - set the current antialiasing mode value.
EDA_3D_CONTROLLER.
Definition: 3d_controller.h:39
bool AnimationEnabledGet() const
AnimationEnabledGet - Returns whether camera animation is enabled when switching to a pre-defined vie...
double GetRotationIncrement()
Get the increment used by the RotateView actions.
Definition: 3d_controller.h:77
const BITMAP_OPAQUE shape_3d_xpm[1]
Definition: shape_3d.cpp:35
const BITMAP_OPAQUE axis3d_xpm[1]
Definition: axis3d.cpp:91
const BITMAP_OPAQUE tools_xpm[1]
Definition: tools.cpp:113
const BITMAP_OPAQUE pads_mask_layers_xpm[1]
int MovingSpeedMultiplierGet() const
MovingSpeedMultiplierGet - Return the current camera animation moving speed multiplier option.
Declaration of the eda_3d_viewer class.
const BITMAP_OPAQUE use_3D_copper_thickness_xpm[1]
ANTIALIASING_MODE AntiAliasingGet() const
GridGet - get the current antialiasing mode value.
const BITMAP_OPAQUE add_zone_xpm[1]
Definition: add_zone.cpp:74
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:65
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:74
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
Class BOARD_ADAPTER Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:68
bool TransferDataFromWindow() override
Automatically called when clicking on the OK button.
void OnCheckEnableAnimation(wxCommandEvent &WXUNUSED(event)) override