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  //
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 
74  viewMenu->AddItem( ID_ZOOM_IN, _( "Zoom In\tF1" ), HELP_ZOOM_IN,
75  zoom_in_xpm, SELECTION_CONDITIONS::ShowAlways );
76 
77  viewMenu->AddItem( ID_ZOOM_OUT, _( "Zoom Out\tF2" ), HELP_ZOOM_OUT,
78  zoom_out_xpm, SELECTION_CONDITIONS::ShowAlways );
79 
80  viewMenu->AddItem( ID_ZOOM_PAGE, _( "Zoom to Fit" ), HELP_ZOOM_FIT,
81  zoom_fit_in_page_xpm, SELECTION_CONDITIONS::ShowAlways );
82 
83  viewMenu->AddItem( ID_ZOOM_REDRAW, _( "Redraw\tR" ), HELP_ZOOM_REDRAW,
84  zoom_redraw_xpm, SELECTION_CONDITIONS::ShowAlways );
85 
86  viewMenu->AddSeparator();
87  viewMenu->AddItem( ID_ROTATE3D_X_NEG, _( "Rotate X Clockwise\tShift+X" ), "",
88  rotate_neg_x_xpm, SELECTION_CONDITIONS::ShowAlways );
89 
90  viewMenu->AddItem( ID_ROTATE3D_X_POS, _( "Rotate X Counterclockwise\tX" ), "",
91  rotate_pos_x_xpm, SELECTION_CONDITIONS::ShowAlways );
92 
93  viewMenu->AddSeparator();
94  viewMenu->AddItem( ID_ROTATE3D_Y_NEG, _( "Rotate Y Clockwise\tShift+Y" ), "",
95  rotate_neg_y_xpm, SELECTION_CONDITIONS::ShowAlways );
96 
97  viewMenu->AddItem( ID_ROTATE3D_Y_POS, _( "Rotate Y Counterclockwise\tY" ), "",
98  rotate_pos_y_xpm, SELECTION_CONDITIONS::ShowAlways );
99 
100  viewMenu->AddSeparator();
101  viewMenu->AddItem( ID_ROTATE3D_Z_NEG, _( "Rotate Z Clockwise\tShift+Z" ), "",
102  rotate_neg_z_xpm, SELECTION_CONDITIONS::ShowAlways );;
103 
104  viewMenu->AddItem( ID_ROTATE3D_Z_POS, _( "Rotate Z Counterclockwise\tZ" ), "",
105  rotate_pos_z_xpm, SELECTION_CONDITIONS::ShowAlways );
106 
107  viewMenu->AddSeparator();
108  viewMenu->AddItem( ID_MOVE3D_LEFT, _( "Move Left\tLeft" ), "",
110 
111  viewMenu->AddItem( ID_MOVE3D_RIGHT, _( "Move Right\tRight" ), "",
113 
114  viewMenu->AddItem( ID_MOVE3D_UP, _( "Move Up\tUp" ), "",
116 
117  viewMenu->AddItem( ID_MOVE3D_DOWN, _( "Move Down\tDown" ), "",
119 
120  viewMenu->Resolve();
121 
122  //-- Preferences menu -----------------------------------------------
123  //
124  CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
125 
126  auto raytracingCondition = [ this ] ( const SELECTION& aSel ) {
128  };
129  auto NormalModeCondition = [ this ] ( const SELECTION& aSel ) {
131  };
132  auto DiffuseModeCondition = [ this ] ( const SELECTION& aSel ) {
134  };
135  auto CADModeCondition = [ this ] ( const SELECTION& aSel ) {
137  };
138  auto copperThicknessCondition = [ this ] ( const SELECTION& aSel ) {
140  };
141  auto boundingBoxesCondition = [ this ] ( const SELECTION& aSel ) {
143  };
144  auto renderShadowsCondition = [ this ] ( const SELECTION& aSel ) {
146  };
147  auto proceduralTexturesCondition = [ this ] ( const SELECTION& aSel ) {
149  };
150  auto showFloorCondition = [ this ] ( const SELECTION& aSel ) {
152  };
153  auto useRefractionsCondition = [ this ] ( const SELECTION& aSel ) {
155  };
156  auto useReflectionsCondition = [ this ] ( const SELECTION& aSel ) {
158  };
159  auto antiAliasingCondition = [ this ] ( const SELECTION& aSel ) {
161  };
162  auto postProcessCondition = [ this ] ( const SELECTION& aSel ) {
164  };
165  auto showAxesCondition = [ this ] ( const SELECTION& aSel ) {
166  return m_settings.GetFlag( FL_AXIS );
167  };
168 
169  prefsMenu->AddItem( ID_TOOL_SET_VISIBLE_ITEMS, _( "Display Options" ), "",
170  read_setup_xpm, SELECTION_CONDITIONS::ShowAlways );
171 
172  prefsMenu->AddCheckItem( ID_RENDER_CURRENT_VIEW, _( "Raytracing" ), "",
173  tools_xpm, raytracingCondition );
174 
175  // Render options submenu
176  CONDITIONAL_MENU* optsSubmenu = new CONDITIONAL_MENU( false, tool );
177  optsSubmenu->SetTitle( _( "Render Options" ) );
178  optsSubmenu->SetIcon( options_3drender_xpm );
179 
180  // Material properties submenu
181  CONDITIONAL_MENU* propsSubmenu = new CONDITIONAL_MENU( false, tool );
182  propsSubmenu->SetTitle( _( "Material Properties" ) );
183  propsSubmenu->SetIcon( color_materials_xpm );
184 
186  _( "Use All Properties" ),
187  _( "Use all material properties from each 3D model file" ),
188  nullptr, NormalModeCondition );
189 
191  _( "Use Diffuse Only" ),
192  _( "Use only the diffuse color property from model 3D model file" ),
193  nullptr, DiffuseModeCondition );
194 
196  _( "CAD Color Style" ),
197  _( "Use a CAD color style based on the diffuse color of the material" ),
198  nullptr, CADModeCondition );
199 
200  optsSubmenu->AddMenu( propsSubmenu, SELECTION_CONDITIONS::ShowAlways );
201 
203  _( "Show Copper Thickness" ),
204  _( "Shows the copper thickness on copper layers (slower loading)" ),
205  use_3D_copper_thickness_xpm, copperThicknessCondition );
206 
208  _( "Show Model Bounding Boxes" ), "",
209  ortho_xpm, 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 
217  _( "Render Shadows" ), "",
218  green_xpm, renderShadowsCondition );
219 
221  _( "Procedural Textures" ),
222  _( "Apply procedural textures to materials (slow)"),
223  green_xpm, proceduralTexturesCondition );
224 
226  _( "Add Floor" ),
227  _( "Adds a floor plane below the board (slow)"),
228  green_xpm, showFloorCondition );
229 
231  _( "Refractions" ),
232  _( "Render materials with refractions properties on final render (slow)"),
233  green_xpm, useRefractionsCondition );
234 
236  _( "Reflections" ),
237  _( "Render materials with reflections properties on final render (slow)"),
238  green_xpm, useReflectionsCondition );
239 
241  _( "Anti-aliasing" ),
242  _( "Render with improved quality on final render (slow)"),
243  green_xpm, antiAliasingCondition );
244 
246  _( "Post-processing" ),
247  _( "Apply Screen Space Ambient Occlusion and Global Illumination reflections on final render (slow)"),
248  green_xpm, postProcessCondition );
249 
250  optsSubmenu->AddMenu( raySubmenu, SELECTION_CONDITIONS::ShowAlways );
251  prefsMenu->AddMenu( optsSubmenu, SELECTION_CONDITIONS::ShowAlways );
252 
253  prefsMenu->AddSeparator();
254 
255  // Color submenu
256  CONDITIONAL_MENU* colorSubmenu = new CONDITIONAL_MENU( false, tool );
257  colorSubmenu->SetTitle( _( "Choose Colors" ) );
258  colorSubmenu->SetIcon( palette_xpm );
259 
260  colorSubmenu->AddItem( ID_MENU3D_BGCOLOR_TOP, _( "Background Top Color..." ), "",
261  setcolor_3d_bg_xpm, SELECTION_CONDITIONS::ShowAlways );
262 
263  colorSubmenu->AddItem( ID_MENU3D_BGCOLOR_BOTTOM, _( "Background Bottom Color..." ), "",
264  setcolor_3d_bg_xpm, SELECTION_CONDITIONS::ShowAlways );
265 
266  colorSubmenu->AddItem( ID_MENU3D_SILKSCREEN_COLOR, _( "Silkscreen Color..." ), "",
267  setcolor_silkscreen_xpm, SELECTION_CONDITIONS::ShowAlways );
268 
269  colorSubmenu->AddItem( ID_MENU3D_SOLDERMASK_COLOR, _( "Solder Mask Color..." ), "",
270  setcolor_soldermask_xpm, SELECTION_CONDITIONS::ShowAlways );
271 
272  colorSubmenu->AddItem( ID_MENU3D_SOLDERPASTE_COLOR, _( "Solder Paste Color..." ), "",
273  setcolor_solderpaste_xpm, SELECTION_CONDITIONS::ShowAlways );
274 
275  colorSubmenu->AddItem( ID_MENU3D_COPPER_COLOR, _( "Copper/Surface Finish Color..." ), "",
276  setcolor_copper_xpm, SELECTION_CONDITIONS::ShowAlways );
277 
278  colorSubmenu->AddItem( ID_MENU3D_PCB_BODY_COLOR, _( "Board Body Color..." ), "",
279  setcolor_board_body_xpm, SELECTION_CONDITIONS::ShowAlways );
280 
281  prefsMenu->AddMenu( colorSubmenu );
282 
283  prefsMenu->AddCheckItem( ID_MENU3D_AXIS_ONOFF, _( "Show 3D &Axis" ), "",
284  axis3d_front_xpm, showAxesCondition );
285 
286  // Grid submenu
287  CONDITIONAL_MENU* gridSubmenu = new CONDITIONAL_MENU( false, tool );
288  gridSubmenu->SetTitle( _( "3D Grid" ) );
289  gridSubmenu->SetIcon( grid_xpm );
290 
291  auto noGridCondition = [ this ] ( const SELECTION& aSel ) {
292  return m_settings.GridGet() == GRID3D_NONE;
293  };
294  auto grid10mmCondition = [ this ] ( const SELECTION& aSel ) {
295  return m_settings.GridGet() == GRID3D_10MM;
296  };
297  auto grid5mmCondition = [ this ] ( const SELECTION& aSel ) {
298  return m_settings.GridGet() == GRID3D_5MM;
299  };
300  auto grid2p5mmCondition = [ this ] ( const SELECTION& aSel ) {
301  return m_settings.GridGet() == GRID3D_2P5MM;
302  };
303  auto grid_1mmCondition = [ this ] ( const SELECTION& aSel ) {
304  return m_settings.GridGet() == GRID3D_1MM;
305  };
306 
307  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), "",
308  nullptr, noGridCondition );
309  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_10_MM, _( "3D Grid 10mm" ), "",
310  nullptr, grid10mmCondition );
311  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_5_MM, _( "3D Grid 5mm" ), "",
312  nullptr, grid5mmCondition );
313  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5mm" ), "",
314  nullptr, grid2p5mmCondition );
315  gridSubmenu->AddCheckItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1mm" ), "",
316  nullptr, grid_1mmCondition );
317 
318  prefsMenu->AddMenu( gridSubmenu, SELECTION_CONDITIONS::ShowAlways );
319 
320  prefsMenu->AddSeparator();
321  prefsMenu->AddItem( ID_MENU3D_RESET_DEFAULTS, _( "Reset to Default Settings" ), "",
323 
324 #ifdef __APPLE__ // Note: will get moved to Apple menu by wxWidgets
325  prefsMenu->AddItem( wxID_PREFERENCES,
326  _( "Preferences...\tCTRL+," ),
327  _( "Show preferences for all open tools" ),
328  preference_xpm, SELECTION_CONDITIONS::ShowAlways );
329 #endif
330 
331  prefsMenu->Resolve();
332 
333  //-- Menubar -------------------------------------------------------------
334  //
335  menuBar->Append( fileMenu, _( "&File" ) );
336  menuBar->Append( editMenu, _( "&Edit" ) );
337  menuBar->Append( viewMenu, _( "&View" ) );
338  menuBar->Append( prefsMenu, _( "&Preferences" ) );
339  AddStandardHelpMenu( menuBar );
340 
341  SetMenuBar( menuBar );
342 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
Use only diffuse material properties.
Definition: 3d_enums.h:93
CINFO3D_VISU m_settings
#define HELP_ZOOM_OUT
Definition: id.h:215
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
void AddCheckItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddCheckItem()
#define HELP_ZOOM_IN
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE
MATERIAL_MODE MaterialModeGet() const
MaterialModeGet.
Definition: cinfo3d_visu.h:246
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.
#define HELP_ZOOM_REDRAW
Use a gray shading based on diffuse material.
Definition: 3d_enums.h:94
Class COMMON_CONTROL.
#define _(s)
void Resolve()
Function Resolve()
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:234
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
Use all material properties from model file.
Definition: 3d_enums.h:92
void AddClose(wxString aAppname="")
Function AddClose()
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
#define HELP_ZOOM_FIT
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.
void CreateMenuBar()
Definition: 3d_menubar.cpp:38
TOOL_MANAGER * m_toolManager
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()