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 
31 #include <fctsys.h>
32 
33 #include <eda_3d_viewer.h>
34 #include <3d_canvas/cinfo3d_visu.h>
35 #include <menus_helpers.h>
36 #include <3d_viewer_id.h>
37 #include "help_common_strings.h"
38 
40 
42 {
43  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
44 
45  wxMenuBar* menuBar = new wxMenuBar;
46  wxMenu* fileMenu = new wxMenu;
47  wxMenu* editMenu = new wxMenu;
48  wxMenu* viewMenu = new wxMenu;
49  wxMenu* prefsMenu = new wxMenu;
50  wxMenu* helpMenu = new wxMenu;
51 
52  menuBar->Append( fileMenu, _( "&File" ) );
53 
55  _( "Export Current View as PNG..." ),
56  KiBitmap( export_xpm ) );
57 
59  _( "Export Current View as JPEG..." ),
60  KiBitmap( export_xpm ) );
61 
62  fileMenu->AppendSeparator();
63  AddMenuItem( fileMenu, wxID_EXIT,
64  _( "&Exit" ),
65  KiBitmap( exit_xpm ) );
66 
67  menuBar->Append( editMenu, _( "&Edit" ) );
68 
70  _( "Copy 3D Image" ),
71  KiBitmap( copy_xpm ) );
72 
73  menuBar->Append( viewMenu, _( "&View" ) );
74 
75  AddMenuItem( viewMenu, ID_ZOOM_IN,
76  _( "Zoom &In" ), HELP_ZOOM_IN,
77  KiBitmap( zoom_in_xpm ) );
78 
79  AddMenuItem( viewMenu, ID_ZOOM_OUT,
80  _( "Zoom &Out" ), HELP_ZOOM_OUT,
81  KiBitmap( zoom_out_xpm ) );
82 
83  AddMenuItem( viewMenu, ID_ZOOM_PAGE,
84  _( "Zoom to &Fit" ), HELP_ZOOM_FIT,
85  KiBitmap( zoom_fit_in_page_xpm ) );
86 
87  AddMenuItem( viewMenu, ID_ZOOM_REDRAW,
88  _( "&Redraw" ), HELP_ZOOM_REDRAW,
89  KiBitmap( zoom_redraw_xpm ) );
90 
91  viewMenu->AppendSeparator();
92 
93  AddMenuItem( viewMenu, ID_ROTATE3D_X_NEG,
94  _( "Rotate X Clockwise" ),
95  KiBitmap( rotate_neg_x_xpm ) );
96 
97  AddMenuItem( viewMenu, ID_ROTATE3D_X_POS,
98  _( "Rotate X Counterclockwise" ),
99  KiBitmap( rotate_pos_x_xpm ) );
100 
101  viewMenu->AppendSeparator();
102 
103  AddMenuItem( viewMenu, ID_ROTATE3D_Y_NEG,
104  _( "Rotate Y Clockwise" ),
105  KiBitmap( rotate_neg_y_xpm ) );
106 
107  AddMenuItem( viewMenu, ID_ROTATE3D_Y_POS,
108  _( "Rotate Y Counterclockwise" ),
109  KiBitmap( rotate_pos_y_xpm ) );
110 
111  viewMenu->AppendSeparator();
112 
113  AddMenuItem( viewMenu, ID_ROTATE3D_Z_NEG,
114  _( "Rotate Z Clockwise" ),
115  KiBitmap( rotate_neg_z_xpm ) );
116 
117  AddMenuItem( viewMenu, ID_ROTATE3D_Z_POS,
118  _( "Rotate Z Counterclockwise" ),
119  KiBitmap( rotate_pos_z_xpm ) );
120 
121  viewMenu->AppendSeparator();
122 
123  AddMenuItem( viewMenu, ID_MOVE3D_LEFT,
124  _( "Move left" ),
125  KiBitmap( left_xpm ) );
126 
127  AddMenuItem( viewMenu, ID_MOVE3D_RIGHT,
128  _( "Move right" ),
129  KiBitmap( right_xpm ) );
130 
131  AddMenuItem( viewMenu, ID_MOVE3D_UP,
132  _( "Move up" ),
133  KiBitmap( up_xpm ) );
134 
135  AddMenuItem( viewMenu, ID_MOVE3D_DOWN,
136  _( "Move down" ),
137  KiBitmap( down_xpm ) );
138 
139  menuBar->Append( prefsMenu, _( "&Preferences" ) );
140 
142  _( "Display Options" ),
143  KiBitmap( read_setup_xpm ) );
144 
145  prefsMenu->AppendCheckItem( ID_RENDER_CURRENT_VIEW, _( "Raytracing" ) );
146  prefsMenu->Check( ID_RENDER_CURRENT_VIEW,
148 
149  wxMenu * renderOptionsMenu = new wxMenu;
150  AddMenuItem( prefsMenu, renderOptionsMenu, ID_MENU3D_FL,
151  _( "Render Options" ), KiBitmap( options_3drender_xpm ) );
152 
153  wxMenu * materialsList = new wxMenu;
154  AddMenuItem( renderOptionsMenu, materialsList, ID_MENU3D_FL_RENDER_MATERIAL,
155  _( "Material Properties" ), KiBitmap( color_materials_xpm ) );
156 
157  materialsList->AppendRadioItem( ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL,
158  _( "Use All Properties" ),
159  _( "Use all material properties from each 3D model file" ) );
160 
161  materialsList->AppendRadioItem( ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY,
162  _( "Use Diffuse Only" ),
163  _( "Use only the diffuse color property from model 3D model file" ) );
164 
165  materialsList->AppendRadioItem( ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE,
166  _( "CAD Color Style" ),
167  _( "Use a CAD color style based on the diffuse color of the material" ) );
168 
169  // Add specific preferences for OpenGL
170  // /////////////////////////////////////////////////////////////////////////
171  wxMenu * renderOptionsMenu_OPENGL = new wxMenu;
172 
173  AddMenuItem( renderOptionsMenu, renderOptionsMenu_OPENGL, ID_MENU3D_FL_OPENGL,
174  _( "OpenGL Options" ), KiBitmap( tools_xpm ) );
175 
176  AddMenuItem( renderOptionsMenu_OPENGL, ID_MENU3D_FL_OPENGL_RENDER_COPPER_THICKNESS,
177  _( "Show Copper Thickness" ),
178  _( "Shows the copper thickness on copper layers (slower loading)"),
179  KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
180 
181  AddMenuItem( renderOptionsMenu_OPENGL, ID_MENU3D_FL_OPENGL_RENDER_SHOW_MODEL_BBOX,
182  _( "Show Model Bounding Boxes" ),
183  KiBitmap( ortho_xpm ), wxITEM_CHECK );
184 
185 
186  // Add specific preferences for Raytracing
187  // /////////////////////////////////////////////////////////////////////////
188  wxMenu * renderOptionsMenu_RAYTRACING = new wxMenu;
189  AddMenuItem( renderOptionsMenu, renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING,
190  _( "Raytracing Options" ), KiBitmap( tools_xpm ) );
191 
192  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_RENDER_SHADOWS,
193  _( "Render Shadows" ),
194  KiBitmap( green_xpm ), wxITEM_CHECK );
195 
196  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_PROCEDURAL_TEXTURES,
197  _( "Procedural Textures" ),
198  _( "Apply procedural textures to materials (slow)"),
199  KiBitmap( green_xpm ), wxITEM_CHECK );
200 
201  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_BACKFLOOR,
202  _( "Add Floor" ),
203  _( "Adds a floor plane below the board (slow)"),
204  KiBitmap( green_xpm ), wxITEM_CHECK );
205 
206  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_REFRACTIONS,
207  _( "Refractions" ),
208  _( "Render materials with refractions properties on final render (slow)"),
209  KiBitmap( green_xpm ), wxITEM_CHECK );
210 
211  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_REFLECTIONS,
212  _( "Reflections" ),
213  _( "Render materials with reflections properties on final render (slow)"),
214  KiBitmap( green_xpm ), wxITEM_CHECK );
215 
216  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_ANTI_ALIASING,
217  _( "Anti-aliasing" ),
218  _( "Render with improved quality on final render (slow)"),
219  KiBitmap( green_xpm ), wxITEM_CHECK );
220 
221  AddMenuItem( renderOptionsMenu_RAYTRACING, ID_MENU3D_FL_RAYTRACING_POST_PROCESSING,
222  _( "Post-processing" ),
223  _( "Apply Screen Space Ambient Occlusion and Global Illumination reflections on final render (slow)"),
224  KiBitmap( green_xpm ), wxITEM_CHECK );
225 
226  prefsMenu->AppendSeparator();
227 
228 
229  // Colors, axis and grid elements
230  // /////////////////////////////////////////////////////////////////////////
231 
232  // Add submenu set Colors
233  wxMenu * setColorMenu = new wxMenu;
234  AddMenuItem( prefsMenu, setColorMenu, ID_MENU3D_COLOR,
235  _( "Choose Colors" ), KiBitmap( palette_xpm ) );
236 
237  wxMenu * setBgColorMenu = new wxMenu;
238  AddMenuItem( setColorMenu, setBgColorMenu, ID_MENU3D_BGCOLOR,
239  _( "Background Color" ), KiBitmap( palette_xpm ) );
240 
242  _( "Background Top Color..." ), KiBitmap( setcolor_3d_bg_xpm ) );
243 
245  _( "Background Bottom Color..." ), KiBitmap( setcolor_3d_bg_xpm ) );
246 
248  _( "Silkscreen Color..." ), KiBitmap( setcolor_silkscreen_xpm ) );
249 
251  _( "Solder Mask Color..." ), KiBitmap( setcolor_soldermask_xpm ) );
252 
254  _( "Solder Paste Color..." ), KiBitmap( setcolor_solderpaste_xpm ) );
255 
257  _( "Copper/Surface Finish Color..." ), KiBitmap( setcolor_copper_xpm ) );
258 
260  _( "Board Body Color..." ), KiBitmap( setcolor_board_body_xpm ) );
261 
262  AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
263  _( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
264 
265 
266  // Creates grid menu
267  // /////////////////////////////////////////////////////////////////////////
268 
269  wxMenu * gridlistMenu = new wxMenu;
270  AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
271  _( "3D Grid" ), KiBitmap( grid_xpm ) );
272  gridlistMenu->AppendRadioItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString );
273  gridlistMenu->AppendRadioItem( ID_MENU3D_GRID_10_MM, _( "3D Grid 10 mm" ), wxEmptyString );
274  gridlistMenu->AppendRadioItem( ID_MENU3D_GRID_5_MM, _( "3D Grid 5 mm" ), wxEmptyString );
275  gridlistMenu->AppendRadioItem( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 mm" ), wxEmptyString );
276  gridlistMenu->AppendRadioItem( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString );
277 
278  // If the grid is on, check the corresponding menuitem showing the grid size
279  if( m_settings.GridGet() != GRID3D_NONE )
280  {
281  gridlistMenu->Check( ID_MENU3D_GRID_10_MM, m_settings.GridGet() == GRID3D_10MM );
282  gridlistMenu->Check( ID_MENU3D_GRID_5_MM, m_settings.GridGet() == GRID3D_5MM );
283  gridlistMenu->Check( ID_MENU3D_GRID_2P5_MM, m_settings.GridGet() == GRID3D_2P5MM );
284  gridlistMenu->Check( ID_MENU3D_GRID_1_MM, m_settings.GridGet() == GRID3D_1MM );
285  }
286  else
287  gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
288 
289  // Reset options
290  // /////////////////////////////////////////////////////////////////////////
291  prefsMenu->AppendSeparator();
292 
294  _( "Reset to Default Settings" ),
295  KiBitmap( tools_xpm ) );
296 
297  // Help menu
298  // /////////////////////////////////////////////////////////////////////////
299  menuBar->Append( helpMenu, _( "&Help" ) );
300 
301  AddMenuItem( helpMenu, wxID_HELP,
302  _( "Pcbnew &Manual" ),
303  _( "Open Pcbnew Manual" ),
304  KiBitmap( online_help_xpm ) );
305 
306  AddMenuItem( helpMenu, wxID_INDEX,
307  _( "&Getting Started in KiCad" ),
308  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
309  KiBitmap( help_xpm ) );
310 
311  wxString text = AddHotkeyName( _( "&List Hotkeys..." ), g_3DViewer_Hokeys_Descr, HK_HELP );
313  text,
314  _( "Displays the current hotkeys list and corresponding commands" ),
315  KiBitmap( hotkeys_xpm ) );
316 
317  helpMenu->AppendSeparator();
318 
320  _( "Get &Involved" ),
321  _( "Contribute to KiCad (opens a web browser)" ),
322  KiBitmap( info_xpm ) );
323 
324  helpMenu->AppendSeparator();
325 
326  AddMenuItem( helpMenu, wxID_ABOUT,
327  _( "&About KiCad" ),
328  _( "Display KiCad About dialog" ),
329  KiBitmap( about_xpm ) );
330 
331  SetMenuBar( menuBar );
332 }
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:94
CINFO3D_VISU m_settings
Store all the settings and options to be used by the renders.
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
#define HELP_ZOOM_FIT
Definition: id.h:241
Handles data related with the board to be visualized.
GRID3D_TYPE GridGet() const
GridGet - get the current grid.
Definition: cinfo3d_visu.h:216
#define HELP_ZOOM_OUT
ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE
#define HELP_ZOOM_REDRAW
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
EDA_3D_VIEWER::OnUpdateUIMaterial ID_MENU3D_FL_RAYTRACING_PROCEDURAL_TEXTURES
RENDER_ENGINE RenderEngineGet() const
RenderEngineGet.
Definition: cinfo3d_visu.h:234
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
Declaration of the eda_3d_viewer class.
struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[]
#define HELP_ZOOM_IN
void CreateMenuBar()
Definition: 3d_menubar.cpp:41
strings common to toolbars and menubar