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-2021 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 <bitmaps.h>
28 #include <tool/conditional_menu.h>
29 #include <eda_3d_viewer.h>
30 #include <menus_helpers.h>
31 #include <3d_viewer_id.h>
33 #include <tool/tool_manager.h>
34 #include <tool/common_control.h>
35 #include <widgets/wx_menubar.h>
36 
37 
39 {
40  wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
41 
43  WX_MENUBAR* menuBar = new WX_MENUBAR();
44 
45 
46  //-- File menu -----------------------------------------------------------
47  //
48  ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
49 
50  fileMenu->Add( _( "Export Current View as PNG..." ),
51  "",
54 
55  fileMenu->Add( _( "Export Current View as JPEG..." ),
56  "",
59 
60  fileMenu->AppendSeparator();
61  fileMenu->AddClose( _( "3D Viewer" ) );
62 
63 
64  //-- Edit menu -------------------------------------------------------
65  // Avoid to translate hotkey modifiers like Ctrl and Shift.
66  // The translated modifiers do not always work
67  ACTION_MENU* editMenu = new ACTION_MENU( false, tool );
68 
69  editMenu->Add( _( "Copy 3D Image" ),
70  "",
72  BITMAPS::copy );
73 
74 
75  //-- View menu -------------------------------------------------------
76  //
77  ACTION_MENU* viewMenu = new ACTION_MENU( false, tool );
78 
79  viewMenu->Add( ACTIONS::zoomIn );
80  viewMenu->Add( ACTIONS::zoomOut );
81  viewMenu->Add( ACTIONS::zoomFitScreen );
82  viewMenu->Add( ACTIONS::zoomRedraw );
83 
84  viewMenu->AppendSeparator();
85  viewMenu->Add( EDA_3D_ACTIONS::rotateXCW );
86  viewMenu->Add( EDA_3D_ACTIONS::rotateXCCW );
87 
88  viewMenu->AppendSeparator();
89  viewMenu->Add( EDA_3D_ACTIONS::rotateYCW );
90  viewMenu->Add( EDA_3D_ACTIONS::rotateYCCW );
91 
92  viewMenu->AppendSeparator();
93  viewMenu->Add( EDA_3D_ACTIONS::rotateZCW );
94  viewMenu->Add( EDA_3D_ACTIONS::rotateZCCW );
95 
96  viewMenu->AppendSeparator();
97  viewMenu->Add( EDA_3D_ACTIONS::moveLeft );
98  viewMenu->Add( EDA_3D_ACTIONS::moveRight );
99  viewMenu->Add( EDA_3D_ACTIONS::moveUp );
100  viewMenu->Add( EDA_3D_ACTIONS::moveDown );
101 
102 
103  //-- Preferences menu -----------------------------------------------
104  //
105  ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
106 
107  prefsMenu->Add( _( "Display Options" ), "",
109  BITMAPS::config );
110 
111  prefsMenu->Add( _( "Raytracing" ), "",
115 
116  // Render options submenu
117  ACTION_MENU* optsSubmenu = new ACTION_MENU( false, tool );
118  optsSubmenu->SetTitle( _( "Render Options" ) );
119  optsSubmenu->SetIcon( BITMAPS::options_3drender );
120 
121  // Material properties submenu
122  ACTION_MENU* propsSubmenu = new ACTION_MENU( false, tool );
123  propsSubmenu->SetTitle( _( "Material Properties" ) );
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 
144 
145  optsSubmenu->Add( raySubmenu );
146  prefsMenu->Add( optsSubmenu );
147 
148  prefsMenu->AppendSeparator();
149 
150  // Color submenu
151  ACTION_MENU* colorSubmenu = new ACTION_MENU( false, tool );
152  colorSubmenu->SetTitle( _( "Choose Colors" ) );
153  colorSubmenu->SetIcon( BITMAPS::color_materials );
154 
155  colorSubmenu->Add( _( "Background Top Color..." ),
158 
159  colorSubmenu->Add( _( "Background Bottom Color..." ),
162 
163  colorSubmenu->Add( _( "Silkscreen Color..." ),
166 
167  colorSubmenu->Add( _( "Solder Mask Color..." ),
170 
171  colorSubmenu->Add( _( "Solder Paste Color..." ),
174 
175  colorSubmenu->Add( _( "Copper/Surface Finish Color..." ),
178 
179  colorSubmenu->Add( _( "Board Body Color..." ),
182 
183  // Only allow the stackup to be used in the PCB editor, since it isn't editable in the other frames
184  if( Parent()->IsType( FRAME_PCB_EDITOR ) )
185  {
186  colorSubmenu->Add( _( "Get colors from physical stackup" ),
189  }
190 
191  prefsMenu->Add( colorSubmenu );
192 
194 
195  // Grid submenu
196  ACTION_MENU* gridSubmenu = new ACTION_MENU( false, tool );
197  gridSubmenu->SetTitle( _( "3D Grid" ) );
198  gridSubmenu->SetIcon( BITMAPS::grid );
199 
205 
206  prefsMenu->Add( gridSubmenu );
207 
208  prefsMenu->AppendSeparator();
209  prefsMenu->Add( _( "Reset to Default Settings" ), ID_MENU3D_RESET_DEFAULTS, BITMAPS::tools );
210 
211 #ifdef __APPLE__ // Note: will get moved to Apple menu by wxWidgets
212  prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
213  _( "Show preferences for all open tools" ),
214  wxID_PREFERENCES,
216 #endif
217 
218  //-- Menubar -------------------------------------------------------------
219  //
220  menuBar->Append( fileMenu, _( "&File" ) );
221  menuBar->Append( editMenu, _( "&Edit" ) );
222  menuBar->Append( viewMenu, _( "&View" ) );
223  menuBar->Append( prefsMenu, _( "&Preferences" ) );
224  AddStandardHelpMenu( menuBar );
225 
226  SetMenuBar( menuBar );
227 }
static TOOL_ACTION rotateXCW
Definition: 3d_actions.h:47
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:47
static TOOL_ACTION showBoundingBoxes
Definition: 3d_actions.h:83
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:72
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION showRefractions
Definition: 3d_actions.h:87
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
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 AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION rotateXCCW
Definition: 3d_actions.h:48
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
Handle actions that are shared between different applications.
static TOOL_ACTION rotateZCW
Definition: 3d_actions.h:51
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
static constexpr bool CHECK
Definition: action_menu.h:182
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:157
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:90
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:93
static TOOL_ACTION postProcessing
Definition: 3d_actions.h:90
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:74
void CreateMenuBar()
Definition: 3d_menubar.cpp:38
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:94
static TOOL_ACTION zoomOut
Definition: actions.h:95
static TOOL_ACTION showReflections
Definition: 3d_actions.h:88
static TOOL_ACTION renderShadows
Definition: 3d_actions.h:84
static TOOL_ACTION moveRight
Definition: 3d_actions.h:54
void AddClose(wxString aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.