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