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>
32 #include <3d_actions.h>
33 #include <tool/tool_manager.h>
34 #include <tool/common_control.h>
35 #include "help_common_strings.h"
36 
37 
39 {
40  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
41 
43  wxMenuBar* menuBar = new wxMenuBar;
44 
45 
46  //-- File menu -----------------------------------------------------------
47  //
48  CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool );
49 
50  fileMenu->AddItem( ID_MENU_SCREENCOPY_PNG, _( "Export Current View as PNG..." ), "",
52 
53  fileMenu->AddItem( ID_MENU_SCREENCOPY_JPEG, _( "Export Current View as JPEG..." ), "",
55 
56  fileMenu->AddSeparator();
57  fileMenu->AddClose( _( "3D Viewer" ) );
58 
59  fileMenu->Resolve();
60 
61  //-- Edit menu -------------------------------------------------------
62  // Avoid to translate hotkey modifiers like Ctrl and Shift.
63  // The translated modifiers do not always work
64  CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, tool );
65 
66  editMenu->AddItem( ID_TOOL_SCREENCOPY_TOCLIBBOARD, _( "Copy 3D Image" ), "",
68 
69  editMenu->Resolve();
70 
71  //-- View menu -------------------------------------------------------
72  //
73  CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, tool );
74 
75  viewMenu->AddItem( ID_ZOOM_IN, _( "Zoom In\tF1" ), HELP_ZOOM_IN,
77 
78  viewMenu->AddItem( ID_ZOOM_OUT, _( "Zoom Out\tF2" ), HELP_ZOOM_OUT,
80 
81  viewMenu->AddItem( ID_ZOOM_PAGE, _( "Zoom to Fit" ), HELP_ZOOM_FIT,
83 
84  viewMenu->AddItem( ID_ZOOM_REDRAW, _( "Redraw\tR" ), HELP_ZOOM_REDRAW,
86 
87  viewMenu->AddSeparator();
88  viewMenu->AddItem( ID_ROTATE3D_X_NEG, _( "Rotate X Clockwise" ) + "\tCtrl+Shift+X", "",
90 
91  viewMenu->AddItem( ID_ROTATE3D_X_POS, _( "Rotate X Counterclockwise" ) + "\tCtrl+X", "",
93 
94  viewMenu->AddSeparator();
95  viewMenu->AddItem( ID_ROTATE3D_Y_NEG, _( "Rotate Y Clockwise" ) + "\tCtrl+Shift+Y", "",
97 
98  viewMenu->AddItem( ID_ROTATE3D_Y_POS, _( "Rotate Y Counterclockwise" ) + "\tCtrl+Y", "",
100 
101  viewMenu->AddSeparator();
102  viewMenu->AddItem( ID_ROTATE3D_Z_NEG, _( "Rotate Z Clockwise" ) + "\tCtrl+Shift+Z", "",
104 
105  viewMenu->AddItem( ID_ROTATE3D_Z_POS, _( "Rotate Z Counterclockwise" ) + "\tCtrl+Z", "",
107 
108  viewMenu->AddSeparator();
109  viewMenu->AddItem( ID_MOVE3D_LEFT, _( "Move Left\tLeft" ), "",
111 
112  viewMenu->AddItem( ID_MOVE3D_RIGHT, _( "Move Right\tRight" ), "",
114 
115  viewMenu->AddItem( ID_MOVE3D_UP, _( "Move Up\tUp" ), "",
117 
118  viewMenu->AddItem( ID_MOVE3D_DOWN, _( "Move Down\tDown" ), "",
120 
121  viewMenu->Resolve();
122 
123  //-- Preferences menu -----------------------------------------------
124  //
125  CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
126 
127  //clang-format off
128  auto raytracingCondition = [this]( const SELECTION& aSel )
129  {
131  };
132 
133  auto NormalModeCondition = [this]( const SELECTION& aSel )
134  {
136  };
137 
138  auto DiffuseModeCondition = [this]( const SELECTION& aSel )
139  {
141  };
142 
143  auto CADModeCondition = [this]( const SELECTION& aSel )
144  {
146  };
147 
148  auto copperThicknessCondition = [this]( const SELECTION& aSel )
149  {
151  };
152 
153  auto boundingBoxesCondition = [this]( const SELECTION& aSel )
154  {
156  };
157 
158  auto renderShadowsCondition = [this]( const SELECTION& aSel )
159  {
161  };
162 
163  auto proceduralTexturesCondition = [this]( const SELECTION& aSel )
164  {
166  };
167 
168  auto showFloorCondition = [this]( const SELECTION& aSel )
169  {
171  };
172 
173  auto useRefractionsCondition = [this]( const SELECTION& aSel )
174  {
176  };
177 
178  auto useReflectionsCondition = [this]( const SELECTION& aSel )
179  {
181  };
182 
183  auto antiAliasingCondition = [this]( const SELECTION& aSel )
184  {
186  };
187 
188  auto postProcessCondition = [this]( const SELECTION& aSel )
189  {
191  };
192 
193  auto showAxesCondition = [this]( const SELECTION& aSel )
194  {
195  return m_settings.GetFlag( FL_AXIS );
196  };
197  //clang-format on
198 
199  prefsMenu->AddItem( ID_TOOL_SET_VISIBLE_ITEMS, _( "Display Options" ), "",
201 
202  prefsMenu->AddCheckItem( ID_RENDER_CURRENT_VIEW, _( "Raytracing" ), "",
203  tools_xpm, raytracingCondition );
204 
205  // Render options submenu
206  CONDITIONAL_MENU* optsSubmenu = new CONDITIONAL_MENU( false, tool );
207  optsSubmenu->SetTitle( _( "Render Options" ) );
208  optsSubmenu->SetIcon( options_3drender_xpm );
209 
210  // Material properties submenu
211  CONDITIONAL_MENU* propsSubmenu = new CONDITIONAL_MENU( false, tool );
212  propsSubmenu->SetTitle( _( "Material Properties" ) );
213  propsSubmenu->SetIcon( color_materials_xpm );
214 
216  _( "Use All Properties" ),
217  _( "Use all material properties from each 3D model file" ),
218  nullptr, NormalModeCondition );
219 
221  _( "Use Diffuse Only" ),
222  _( "Use only the diffuse color property from model 3D model file" ),
223  nullptr, DiffuseModeCondition );
224 
226  _( "CAD Color Style" ),
227  _( "Use a CAD color style based on the diffuse color of the material" ),
228  nullptr, CADModeCondition );
229 
230  optsSubmenu->AddMenu( propsSubmenu, SELECTION_CONDITIONS::ShowAlways );
231 
233  _( "Show Copper Thickness" ),
234  _( "Shows the copper thickness on copper layers (slower loading)" ),
235  use_3D_copper_thickness_xpm, copperThicknessCondition );
236 
238  _( "Show Model Bounding Boxes" ), "",
239  ortho_xpm, boundingBoxesCondition );
240 
241  // Raytracing submenu
242  CONDITIONAL_MENU* raySubmenu = new CONDITIONAL_MENU( false, tool );
243  raySubmenu->SetTitle( _( "Raytracing Options" ) );
244  raySubmenu->SetIcon( tools_xpm );
245 
247  _( "Render Shadows" ), "",
248  green_xpm, renderShadowsCondition );
249 
251  _( "Procedural Textures" ),
252  _( "Apply procedural textures to materials (slow)"),
253  green_xpm, proceduralTexturesCondition );
254 
256  _( "Add Floor" ),
257  _( "Adds a floor plane below the board (slow)"),
258  green_xpm, showFloorCondition );
259 
261  _( "Refractions" ),
262  _( "Render materials with refractions properties on final render (slow)"),
263  green_xpm, useRefractionsCondition );
264 
266  _( "Reflections" ),
267  _( "Render materials with reflections properties on final render (slow)"),
268  green_xpm, useReflectionsCondition );
269 
271  _( "Anti-aliasing" ),
272  _( "Render with improved quality on final render (slow)"),
273  green_xpm, antiAliasingCondition );
274 
276  _( "Post-processing" ),
277  _( "Apply Screen Space Ambient Occlusion and Global Illumination reflections on final render (slow)"),
278  green_xpm, postProcessCondition );
279 
280  optsSubmenu->AddMenu( raySubmenu, SELECTION_CONDITIONS::ShowAlways );
281  prefsMenu->AddMenu( optsSubmenu, SELECTION_CONDITIONS::ShowAlways );
282 
283  prefsMenu->AddSeparator();
284 
285  // Color submenu
286  CONDITIONAL_MENU* colorSubmenu = new CONDITIONAL_MENU( false, tool );
287  colorSubmenu->SetTitle( _( "Choose Colors" ) );
288  colorSubmenu->SetIcon( palette_xpm );
289 
290  colorSubmenu->AddItem( ID_MENU3D_BGCOLOR_TOP, _( "Background Top Color..." ), "",
292 
293  colorSubmenu->AddItem( ID_MENU3D_BGCOLOR_BOTTOM, _( "Background Bottom Color..." ), "",
295 
296  colorSubmenu->AddItem( ID_MENU3D_SILKSCREEN_COLOR, _( "Silkscreen Color..." ), "",
298 
299  colorSubmenu->AddItem( ID_MENU3D_SOLDERMASK_COLOR, _( "Solder Mask Color..." ), "",
301 
302  colorSubmenu->AddItem( ID_MENU3D_SOLDERPASTE_COLOR, _( "Solder Paste Color..." ), "",
304 
305  colorSubmenu->AddItem( ID_MENU3D_COPPER_COLOR, _( "Copper/Surface Finish Color..." ), "",
307 
308  colorSubmenu->AddItem( ID_MENU3D_PCB_BODY_COLOR, _( "Board Body Color..." ), "",
310 
311  // Only allow the stackup to be used in the PCB editor, since it isn't editable in the other frames
312  if( Parent()->IsType( FRAME_PCB_EDITOR ) )
313  {
314  colorSubmenu->AddItem( ID_MENU3D_STACKUP_COLORS, _( "Get colors from physical stackup" ), "",
316  }
317 
318  prefsMenu->AddMenu( colorSubmenu );
319 
320  prefsMenu->AddCheckItem( ID_MENU3D_AXIS_ONOFF, _( "Show 3D &Axis" ), "",
321  axis3d_front_xpm, showAxesCondition );
322 
323  // Grid submenu
324  CONDITIONAL_MENU* gridSubmenu = new CONDITIONAL_MENU( false, tool );
325  gridSubmenu->SetTitle( _( "3D Grid" ) );
326  gridSubmenu->SetIcon( grid_xpm );
327 
328  //clang-format off
329  auto noGridCondition = [this]( const SELECTION& aSel )
330  {
332  };
333 
334  auto grid10mmCondition = [this]( const SELECTION& aSel )
335  {
337  };
338 
339  auto grid5mmCondition = [this]( const SELECTION& aSel )
340  {
342  };
343 
344  auto grid2p5mmCondition = [this]( const SELECTION& aSel )
345  {
347  };
348 
349  auto grid_1mmCondition = [this]( const SELECTION& aSel )
350  {
352  };
353  //clang-format on
354 
355  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), "",
356  nullptr, noGridCondition );
357  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_10_MM, _( "3D Grid 10mm" ), "",
358  nullptr, grid10mmCondition );
359  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_5_MM, _( "3D Grid 5mm" ), "",
360  nullptr, grid5mmCondition );
361  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5mm" ), "",
362  nullptr, grid2p5mmCondition );
363  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1mm" ), "",
364  nullptr, grid_1mmCondition );
365 
366  prefsMenu->AddMenu( gridSubmenu, SELECTION_CONDITIONS::ShowAlways );
367 
368  prefsMenu->AddSeparator();
369  prefsMenu->AddItem( ID_MENU3D_RESET_DEFAULTS, _( "Reset to Default Settings" ), "",
371 
372 #ifdef __APPLE__ // Note: will get moved to Apple menu by wxWidgets
373  prefsMenu->AddItem( wxID_PREFERENCES,
374  _( "Preferences...\tCTRL+," ),
375  _( "Show preferences for all open tools" ),
377 #endif
378 
379  prefsMenu->Resolve();
380 
381  //-- Menubar -------------------------------------------------------------
382  //
383  menuBar->Append( fileMenu, _( "&File" ) );
384  menuBar->Append( editMenu, _( "&Edit" ) );
385  menuBar->Append( viewMenu, _( "&View" ) );
386  menuBar->Append( prefsMenu, _( "&Preferences" ) );
387  AddStandardHelpMenu( menuBar );
388 
389  SetMenuBar( menuBar );
390 }
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 right_xpm[1]
Definition: right.cpp:49
const BITMAP_OPAQUE down_xpm[1]
Definition: down.cpp:47
const BITMAP_OPAQUE axis3d_front_xpm[1]
const BITMAP_OPAQUE setcolor_solderpaste_xpm[1]
CINFO3D_VISU m_settings
#define HELP_ZOOM_OUT
const BITMAP_OPAQUE palette_xpm[1]
Definition: palette.cpp:89
const BITMAP_OPAQUE rotate_neg_z_xpm[1]
Definition: id.h:200
const BITMAP_OPAQUE ortho_xpm[1]
Definition: ortho.cpp:55
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
const BITMAP_OPAQUE zoom_fit_in_page_xpm[1]
void AddCheckItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddCheckItem()
#define HELP_ZOOM_IN
const BITMAP_OPAQUE left_xpm[1]
Definition: left.cpp:48
const BITMAP_OPAQUE rotate_pos_z_xpm[1]
const BITMAP_OPAQUE setcolor_board_body_xpm[1]
const BITMAP_OPAQUE rotate_pos_y_xpm[1]
const BITMAP_OPAQUE zoom_redraw_xpm[1]
Definition: zoom_redraw.cpp:58
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
const BITMAP_OPAQUE rotate_pos_x_xpm[1]
Use only diffuse material properties.
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:246
const BITMAP_OPAQUE zoom_out_xpm[1]
Definition: zoom_out.cpp:58
const BITMAP_OPAQUE setcolor_copper_xpm[1]
const BITMAP_OPAQUE read_setup_xpm[1]
Definition: read_setup.cpp:99
Use all material properties from model file.
strings common to toolbars and menubar
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
const BITMAP_OPAQUE up_xpm[1]
Definition: up.cpp:47
#define HELP_ZOOM_REDRAW
const BITMAP_OPAQUE setcolor_silkscreen_xpm[1]
const BITMAP_OPAQUE copy_xpm[1]
Definition: copy.cpp:67
COMMON_CONTROL.
void Resolve()
Function Resolve()
const BITMAP_OPAQUE tools_xpm[1]
Definition: tools.cpp:113
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:234
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void AddClose(wxString aAppname="")
Function AddClose()
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
const BITMAP_OPAQUE rotate_neg_x_xpm[1]
#define HELP_ZOOM_FIT
const BITMAP_OPAQUE setcolor_3d_bg_xpm[1]
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:86
const BITMAP_OPAQUE rotate_neg_y_xpm[1]
Declaration of the eda_3d_viewer class.
bool IsType(FRAME_T aType) const
#define _(s)
Definition: 3d_actions.cpp:31
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:67
void CreateMenuBar()
Definition: 3d_menubar.cpp:38
const BITMAP_OPAQUE use_3D_copper_thickness_xpm[1]
TOOL_MANAGER * m_toolManager
const BITMAP_OPAQUE preference_xpm[1]
Definition: preference.cpp:66
const BITMAP_OPAQUE green_xpm[1]
Definition: green.cpp:95
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
const BITMAP_OPAQUE color_materials_xpm[1]
const BITMAP_OPAQUE zoom_in_xpm[1]
Definition: zoom_in.cpp:59