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-2020 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 <tool/conditional_menu.h>
28 #include <eda_3d_viewer.h>
29 #include <menus_helpers.h>
30 #include <3d_viewer_id.h>
32 #include <tool/tool_manager.h>
33 #include <tool/common_control.h>
34 #include <widgets/wx_menubar.h>
35 
36 
38 {
39  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
40 
42  WX_MENUBAR* menuBar = new WX_MENUBAR();
43 
44 
45  //-- File menu -----------------------------------------------------------
46  //
47  ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
48 
49  fileMenu->Add( _( "Export Current View as PNG..." ),
50  "",
52  export_xpm );
53 
54  fileMenu->Add( _( "Export Current View as JPEG..." ),
55  "",
57  export_xpm );
58 
59  fileMenu->AppendSeparator();
60  fileMenu->AddClose( _( "3D Viewer" ) );
61 
62 
63  //-- Edit menu -------------------------------------------------------
64  // Avoid to translate hotkey modifiers like Ctrl and Shift.
65  // The translated modifiers do not always work
66  ACTION_MENU* editMenu = new ACTION_MENU( false, tool );
67 
68  editMenu->Add( _( "Copy 3D Image" ),
69  "",
71  copy_xpm );
72 
73 
74  //-- View menu -------------------------------------------------------
75  //
76  ACTION_MENU* viewMenu = new ACTION_MENU( false, tool );
77 
78  viewMenu->Add( ACTIONS::zoomIn );
79  viewMenu->Add( ACTIONS::zoomOut );
80  viewMenu->Add( ACTIONS::zoomFitScreen );
81  viewMenu->Add( ACTIONS::zoomRedraw );
82 
83  viewMenu->AppendSeparator();
84  viewMenu->Add( EDA_3D_ACTIONS::rotateXCW );
85  viewMenu->Add( EDA_3D_ACTIONS::rotateXCCW );
86 
87  viewMenu->AppendSeparator();
88  viewMenu->Add( EDA_3D_ACTIONS::rotateYCW );
89  viewMenu->Add( EDA_3D_ACTIONS::rotateYCCW );
90 
91  viewMenu->AppendSeparator();
92  viewMenu->Add( EDA_3D_ACTIONS::rotateZCW );
93  viewMenu->Add( EDA_3D_ACTIONS::rotateZCCW );
94 
95  viewMenu->AppendSeparator();
96  viewMenu->Add( EDA_3D_ACTIONS::moveLeft );
97  viewMenu->Add( EDA_3D_ACTIONS::moveRight );
98  viewMenu->Add( EDA_3D_ACTIONS::moveUp );
99  viewMenu->Add( EDA_3D_ACTIONS::moveDown );
100 
101 
102  //-- Preferences menu -----------------------------------------------
103  //
104  ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
105 
106  prefsMenu->Add( _( "Display Options" ), "",
108  read_setup_xpm );
109 
110  prefsMenu->Add( _( "Raytracing" ), "",
112  tools_xpm,
114 
115  // Render options submenu
116  ACTION_MENU* optsSubmenu = new ACTION_MENU( false, tool );
117  optsSubmenu->SetTitle( _( "Render Options" ) );
118  optsSubmenu->SetIcon( options_3drender_xpm );
119 
120  // Material properties submenu
121  ACTION_MENU* propsSubmenu = new ACTION_MENU( false, tool );
122  propsSubmenu->SetTitle( _( "Material Properties" ) );
123  propsSubmenu->SetIcon( color_materials_xpm );
124 
128 
129  optsSubmenu->Add( propsSubmenu );
130 
132 
133  // Raytracing submenu
134  ACTION_MENU* raySubmenu = new ACTION_MENU( false, tool );
135  raySubmenu->SetTitle( _( "Raytracing Options" ) );
136  raySubmenu->SetIcon( tools_xpm );
137 
145 
146  optsSubmenu->Add( raySubmenu );
147  prefsMenu->Add( optsSubmenu );
148 
149  prefsMenu->AppendSeparator();
150 
151  // Color submenu
152  ACTION_MENU* colorSubmenu = new ACTION_MENU( false, tool );
153  colorSubmenu->SetTitle( _( "Choose Colors" ) );
154  colorSubmenu->SetIcon( palette_xpm );
155 
156  colorSubmenu->Add( _( "Background Top Color..." ),
159 
160  colorSubmenu->Add( _( "Background Bottom Color..." ),
163 
164  colorSubmenu->Add( _( "Silkscreen Color..." ),
167 
168  colorSubmenu->Add( _( "Solder Mask Color..." ),
171 
172  colorSubmenu->Add( _( "Solder Paste Color..." ),
175 
176  colorSubmenu->Add( _( "Copper/Surface Finish Color..." ),
179 
180  colorSubmenu->Add( _( "Board Body Color..." ),
183 
184  // Only allow the stackup to be used in the PCB editor, since it isn't editable in the other frames
185  if( Parent()->IsType( FRAME_PCB_EDITOR ) )
186  {
187  colorSubmenu->Add( _( "Get colors from physical stackup" ),
189  nullptr );
190  }
191 
192  prefsMenu->Add( colorSubmenu );
193 
195 
196  // Grid submenu
197  ACTION_MENU* gridSubmenu = new ACTION_MENU( false, tool );
198  gridSubmenu->SetTitle( _( "3D Grid" ) );
199  gridSubmenu->SetIcon( grid_xpm );
200 
206 
207  prefsMenu->Add( gridSubmenu );
208 
209  prefsMenu->AppendSeparator();
210  prefsMenu->Add( _( "Reset to Default Settings" ), ID_MENU3D_RESET_DEFAULTS, tools_xpm );
211 
212 #ifdef __APPLE__ // Note: will get moved to Apple menu by wxWidgets
213  prefsMenu->Add( _( "Preferences...\tCTRL+," ),
214  _( "Show preferences for all open tools" ),
215  wxID_PREFERENCES,
216  preference_xpm );
217 #endif
218 
219  //-- Menubar -------------------------------------------------------------
220  //
221  menuBar->Append( fileMenu, _( "&File" ) );
222  menuBar->Append( editMenu, _( "&Edit" ) );
223  menuBar->Append( viewMenu, _( "&View" ) );
224  menuBar->Append( prefsMenu, _( "&Preferences" ) );
225  AddStandardHelpMenu( menuBar );
226 
227  SetMenuBar( menuBar );
228 }
static TOOL_ACTION rotateXCW
Definition: 3d_actions.h:47
const BITMAP_OPAQUE options_3drender_xpm[1]
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Adds a wxWidgets-style entry to the menu.
const BITMAP_OPAQUE setcolor_soldermask_xpm[1]
const BITMAP_OPAQUE setcolor_solderpaste_xpm[1]
static TOOL_ACTION show10mmGrid
Definition: 3d_actions.h:70
static TOOL_ACTION materialCAD
Definition: 3d_actions.h:77
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
static TOOL_ACTION showBoundingBoxes
Definition: 3d_actions.h:83
const BITMAP_OPAQUE palette_xpm[1]
Definition: palette.cpp:89
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION showRefractions
Definition: 3d_actions.h:87
const BITMAP_OPAQUE setcolor_board_body_xpm[1]
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:45
static TOOL_ACTION antiAliasing
Definition: 3d_actions.h:89
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:71
static TOOL_ACTION rotateYCW
Definition: 3d_actions.h:49
void SetIcon(const BITMAP_OPAQUE *aIcon)
Assigns an icon for the entry.
Definition: action_menu.cpp:71
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
const BITMAP_OPAQUE grid_xpm[1]
Definition: grid.cpp:19
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:71
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:62
static TOOL_ACTION materialNormal
Definition: 3d_actions.h:75
static TOOL_ACTION rotateZCCW
Definition: 3d_actions.h:52
static TOOL_ACTION addFloor
Definition: 3d_actions.h:86
static TOOL_ACTION showAxis
Definition: 3d_actions.h:93
COMMON_CONTROL.
static TOOL_ACTION rotateZCW
Definition: 3d_actions.h:51
const BITMAP_OPAQUE tools_xpm[1]
Definition: tools.cpp:113
static TOOL_ACTION materialDiffuse
Definition: 3d_actions.h:76
static TOOL_ACTION moveDown
Definition: 3d_actions.h:56
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:85
const BITMAP_OPAQUE setcolor_3d_bg_xpm[1]
static constexpr bool CHECK
Definition: action_menu.h:162
static TOOL_ACTION show2_5mmGrid
Definition: 3d_actions.h:72
static TOOL_ACTION show1mmGrid
Definition: 3d_actions.h:73
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
void SetTitle(const wxString &aTitle) override
Sets title for the menu.
Definition: action_menu.cpp:89
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:88
static TOOL_ACTION postProcessing
Definition: 3d_actions.h:90
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:69
static TOOL_ACTION zoomIn
Definition: actions.h:89
static TOOL_ACTION zoomOut
Definition: actions.h:90
static TOOL_ACTION showReflections
Definition: 3d_actions.h:88
const BITMAP_OPAQUE preference_xpm[1]
Definition: preference.cpp:53
static TOOL_ACTION renderShadows
Definition: 3d_actions.h:84
static TOOL_ACTION moveRight
Definition: 3d_actions.h:54
const BITMAP_OPAQUE color_materials_xpm[1]
void AddClose(wxString aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.