KiCad PCB EDA Suite
3d_menubar.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) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
6  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <fctsys.h>
28 #include <tool/conditional_menu.h>
29 #include <eda_3d_viewer.h>
30 #include <menus_helpers.h>
31 #include <3d_viewer_id.h>
33 #include <tool/tool_manager.h>
34 #include <tool/common_control.h>
35 
36 
38 {
39  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
40 
42  wxMenuBar* menuBar = new wxMenuBar;
43 
44 
45  //-- File menu -----------------------------------------------------------
46  //
47  CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool );
48 
49  fileMenu->AddItem( ID_MENU_SCREENCOPY_PNG, _( "Export Current View as PNG..." ), "",
51 
52  fileMenu->AddItem( ID_MENU_SCREENCOPY_JPEG, _( "Export Current View as JPEG..." ), "",
54 
55  fileMenu->AddSeparator();
56  fileMenu->AddClose( _( "3D Viewer" ) );
57 
58  fileMenu->Resolve();
59 
60  //-- Edit menu -------------------------------------------------------
61  // Avoid to translate hotkey modifiers like Ctrl and Shift.
62  // The translated modifiers do not always work
63  CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, tool );
64 
65  editMenu->AddItem( ID_TOOL_SCREENCOPY_TOCLIBBOARD, _( "Copy 3D Image" ), "",
67 
68  editMenu->Resolve();
69 
70  //-- View menu -------------------------------------------------------
71  //
72  CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, tool );
73 
78 
79  viewMenu->AddSeparator();
82 
83  viewMenu->AddSeparator();
86 
87  viewMenu->AddSeparator();
90 
91  viewMenu->AddSeparator();
96 
97  viewMenu->Resolve();
98 
99  //-- Preferences menu -----------------------------------------------
100  //
101  CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
102 
103  //clang-format off
104  auto raytracingCondition = [this]( const SELECTION& aSel )
105  {
107  };
108 
109  auto NormalModeCondition = [this]( const SELECTION& aSel )
110  {
112  };
113 
114  auto DiffuseModeCondition = [this]( const SELECTION& aSel )
115  {
117  };
118 
119  auto CADModeCondition = [this]( const SELECTION& aSel )
120  {
122  };
123 
124  auto copperThicknessCondition = [this]( const SELECTION& aSel )
125  {
127  };
128 
129  auto boundingBoxesCondition = [this]( const SELECTION& aSel )
130  {
132  };
133 
134  auto renderShadowsCondition = [this]( const SELECTION& aSel )
135  {
137  };
138 
139  auto proceduralTexturesCondition = [this]( const SELECTION& aSel )
140  {
142  };
143 
144  auto showFloorCondition = [this]( const SELECTION& aSel )
145  {
147  };
148 
149  auto useRefractionsCondition = [this]( const SELECTION& aSel )
150  {
152  };
153 
154  auto useReflectionsCondition = [this]( const SELECTION& aSel )
155  {
157  };
158 
159  auto antiAliasingCondition = [this]( const SELECTION& aSel )
160  {
162  };
163 
164  auto postProcessCondition = [this]( const SELECTION& aSel )
165  {
167  };
168 
169  auto showAxesCondition = [this]( const SELECTION& aSel )
170  {
171  return m_settings.GetFlag( FL_AXIS );
172  };
173  //clang-format on
174 
175  prefsMenu->AddItem( ID_TOOL_SET_VISIBLE_ITEMS, _( "Display Options" ), "",
177 
178  prefsMenu->AddCheckItem( ID_RENDER_CURRENT_VIEW, _( "Raytracing" ), "",
179  tools_xpm, raytracingCondition );
180 
181  // Render options submenu
182  CONDITIONAL_MENU* optsSubmenu = new CONDITIONAL_MENU( false, tool );
183  optsSubmenu->SetTitle( _( "Render Options" ) );
184  optsSubmenu->SetIcon( options_3drender_xpm );
185 
186  // Material properties submenu
187  CONDITIONAL_MENU* propsSubmenu = new CONDITIONAL_MENU( false, tool );
188  propsSubmenu->SetTitle( _( "Material Properties" ) );
189  propsSubmenu->SetIcon( color_materials_xpm );
190 
192  _( "Use All Properties" ),
193  _( "Use all material properties from each 3D model file" ),
194  nullptr, NormalModeCondition );
195 
197  _( "Use Diffuse Only" ),
198  _( "Use only the diffuse color property from model 3D model file" ),
199  nullptr, DiffuseModeCondition );
200 
202  _( "CAD Color Style" ),
203  _( "Use a CAD color style based on the diffuse color of the material" ),
204  nullptr, CADModeCondition );
205 
206  optsSubmenu->AddMenu( propsSubmenu, SELECTION_CONDITIONS::ShowAlways );
207 
208  optsSubmenu->AddCheckItem( EDA_3D_ACTIONS::showCopperThickness, copperThicknessCondition );
209  optsSubmenu->AddCheckItem( EDA_3D_ACTIONS::showBoundingBoxes, boundingBoxesCondition );
210 
211  // Raytracing submenu
212  CONDITIONAL_MENU* raySubmenu = new CONDITIONAL_MENU( false, tool );
213  raySubmenu->SetTitle( _( "Raytracing Options" ) );
214  raySubmenu->SetIcon( tools_xpm );
215 
216  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::renderShadows, renderShadowsCondition );
217  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::proceduralTextures, proceduralTexturesCondition );
218  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::addFloor, showFloorCondition );
219  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::showRefractions, useRefractionsCondition );
220  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::showReflections, useReflectionsCondition );
221  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::antiAliasing, antiAliasingCondition );
222 
223  raySubmenu->AddCheckItem( EDA_3D_ACTIONS::postProcessing, postProcessCondition );
224 
225  optsSubmenu->AddMenu( raySubmenu, SELECTION_CONDITIONS::ShowAlways );
226  prefsMenu->AddMenu( optsSubmenu, SELECTION_CONDITIONS::ShowAlways );
227 
228  prefsMenu->AddSeparator();
229 
230  // Color submenu
231  CONDITIONAL_MENU* colorSubmenu = new CONDITIONAL_MENU( false, tool );
232  colorSubmenu->SetTitle( _( "Choose Colors" ) );
233  colorSubmenu->SetIcon( palette_xpm );
234 
235  colorSubmenu->AddItem( ID_MENU3D_BGCOLOR_TOP, _( "Background Top Color..." ), "",
237 
238  colorSubmenu->AddItem( ID_MENU3D_BGCOLOR_BOTTOM, _( "Background Bottom Color..." ), "",
240 
241  colorSubmenu->AddItem( ID_MENU3D_SILKSCREEN_COLOR, _( "Silkscreen Color..." ), "",
243 
244  colorSubmenu->AddItem( ID_MENU3D_SOLDERMASK_COLOR, _( "Solder Mask Color..." ), "",
246 
247  colorSubmenu->AddItem( ID_MENU3D_SOLDERPASTE_COLOR, _( "Solder Paste Color..." ), "",
249 
250  colorSubmenu->AddItem( ID_MENU3D_COPPER_COLOR, _( "Copper/Surface Finish Color..." ), "",
252 
253  colorSubmenu->AddItem( ID_MENU3D_PCB_BODY_COLOR, _( "Board Body Color..." ), "",
255 
256  // Only allow the stackup to be used in the PCB editor, since it isn't editable in the other frames
257  if( Parent()->IsType( FRAME_PCB_EDITOR ) )
258  {
259  colorSubmenu->AddItem( ID_MENU3D_STACKUP_COLORS, _( "Get colors from physical stackup" ), "",
261  }
262 
263  prefsMenu->AddMenu( colorSubmenu );
264 
265  prefsMenu->AddCheckItem( EDA_3D_ACTIONS::showAxis, showAxesCondition );
266 
267  // Grid submenu
268  CONDITIONAL_MENU* gridSubmenu = new CONDITIONAL_MENU( false, tool );
269  gridSubmenu->SetTitle( _( "3D Grid" ) );
270  gridSubmenu->SetIcon( grid_xpm );
271 
272  //clang-format off
273  auto noGridCondition = [this]( const SELECTION& aSel )
274  {
276  };
277 
278  auto grid10mmCondition = [this]( const SELECTION& aSel )
279  {
281  };
282 
283  auto grid5mmCondition = [this]( const SELECTION& aSel )
284  {
286  };
287 
288  auto grid2p5mmCondition = [this]( const SELECTION& aSel )
289  {
291  };
292 
293  auto grid_1mmCondition = [this]( const SELECTION& aSel )
294  {
296  };
297  //clang-format on
298 
299  gridSubmenu->AddCheckItem( EDA_3D_ACTIONS::noGrid, noGridCondition );
300  gridSubmenu->AddCheckItem( EDA_3D_ACTIONS::show10mmGrid, grid10mmCondition );
301  gridSubmenu->AddCheckItem( EDA_3D_ACTIONS::show5mmGrid, grid5mmCondition );
302  gridSubmenu->AddCheckItem( EDA_3D_ACTIONS::show2_5mmGrid, grid2p5mmCondition );
303  gridSubmenu->AddCheckItem( EDA_3D_ACTIONS::show1mmGrid, grid_1mmCondition );
304 
305  prefsMenu->AddMenu( gridSubmenu, SELECTION_CONDITIONS::ShowAlways );
306 
307  prefsMenu->AddSeparator();
308  prefsMenu->AddItem( ID_MENU3D_RESET_DEFAULTS, _( "Reset to Default Settings" ), "",
310 
311 #ifdef __APPLE__ // Note: will get moved to Apple menu by wxWidgets
312  prefsMenu->AddItem( wxID_PREFERENCES,
313  _( "Preferences...\tCTRL+," ),
314  _( "Show preferences for all open tools" ),
316 #endif
317 
318  prefsMenu->Resolve();
319 
320  //-- Menubar -------------------------------------------------------------
321  //
322  menuBar->Append( fileMenu, _( "&File" ) );
323  menuBar->Append( editMenu, _( "&Edit" ) );
324  menuBar->Append( viewMenu, _( "&View" ) );
325  menuBar->Append( prefsMenu, _( "&Preferences" ) );
326  AddStandardHelpMenu( menuBar );
327 
328  SetMenuBar( menuBar );
329 }
static TOOL_ACTION rotateXCW
Definition: 3d_actions.h:47
Use a gray shading based on diffuse material.
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
const BITMAP_OPAQUE options_3drender_xpm[1]
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
const BITMAP_OPAQUE setcolor_soldermask_xpm[1]
const BITMAP_OPAQUE setcolor_solderpaste_xpm[1]
CINFO3D_VISU m_settings
static TOOL_ACTION show10mmGrid
Definition: 3d_actions.h:69
static TOOL_ACTION showBoundingBoxes
Definition: 3d_actions.h:79
const BITMAP_OPAQUE palette_xpm[1]
Definition: palette.cpp:89
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:222
void AddCheckItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddCheckItem()
static TOOL_ACTION showRefractions
Definition: 3d_actions.h:83
const BITMAP_OPAQUE setcolor_board_body_xpm[1]
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
Use only diffuse material properties.
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:252
static TOOL_ACTION antiAliasing
Definition: 3d_actions.h:85
const BITMAP_OPAQUE setcolor_copper_xpm[1]
const BITMAP_OPAQUE read_setup_xpm[1]
Definition: read_setup.cpp:99
static TOOL_ACTION moveLeft
Definition: 3d_actions.h:53
static TOOL_ACTION show5mmGrid
Definition: 3d_actions.h:70
Use all material properties from model file.
static TOOL_ACTION rotateYCW
Definition: 3d_actions.h:49
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: action_menu.cpp:68
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
const BITMAP_OPAQUE grid_xpm[1]
Definition: grid.cpp:21
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:75
static TOOL_ACTION rotateXCCW
Definition: 3d_actions.h:48
const BITMAP_OPAQUE setcolor_silkscreen_xpm[1]
const BITMAP_OPAQUE copy_xpm[1]
Definition: copy.cpp:67
static TOOL_ACTION rotateZCCW
Definition: 3d_actions.h:52
static TOOL_ACTION addFloor
Definition: 3d_actions.h:82
static TOOL_ACTION showAxis
Definition: 3d_actions.h:89
COMMON_CONTROL.
static TOOL_ACTION rotateZCW
Definition: 3d_actions.h:51
void Resolve()
Function Resolve()
const BITMAP_OPAQUE tools_xpm[1]
Definition: tools.cpp:113
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:240
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION moveDown
Definition: 3d_actions.h:56
void AddClose(wxString aAppname="")
Function AddClose()
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
static TOOL_ACTION proceduralTextures
Definition: 3d_actions.h:81
const BITMAP_OPAQUE setcolor_3d_bg_xpm[1]
static TOOL_ACTION show2_5mmGrid
Definition: 3d_actions.h:71
static TOOL_ACTION show1mmGrid
Definition: 3d_actions.h:72
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:86
Declaration of the eda_3d_viewer class.
bool IsType(FRAME_T aType) const
static TOOL_ACTION rotateYCCW
Definition: 3d_actions.h:50
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:87
static TOOL_ACTION postProcessing
Definition: 3d_actions.h:86
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:76
void CreateMenuBar()
Definition: 3d_menubar.cpp:37
static TOOL_ACTION moveUp
Definition: 3d_actions.h:55
static TOOL_ACTION noGrid
Definition: 3d_actions.h:68
static TOOL_ACTION zoomIn
Definition: actions.h:88
static TOOL_ACTION zoomOut
Definition: actions.h:89
static TOOL_ACTION showReflections
Definition: 3d_actions.h:84
TOOL_MANAGER * m_toolManager
const BITMAP_OPAQUE preference_xpm[1]
Definition: preference.cpp:66
static TOOL_ACTION renderShadows
Definition: 3d_actions.h:80
static TOOL_ACTION moveRight
Definition: 3d_actions.h:54
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION showCopperThickness
Definition: 3d_actions.h:78
const BITMAP_OPAQUE color_materials_xpm[1]