KiCad PCB EDA Suite
Loading...
Searching...
No Matches
3d_toolbar.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 <[email protected]>
5 * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
6 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2022 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 <wx/wupdlock.h>
28#include <wx/choice.h>
29
30#include <bitmaps.h>
32#include <eda_3d_viewer_frame.h>
33#include <menus_helpers.h>
34#include <tool/action_toolbar.h>
36#include <3d_viewer_id.h>
37
39{
40 wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::ReCreateMainToolbar" ) );
41
42 wxWindowUpdateLocker dummy( this );
43
44 if( m_mainToolBar )
45 {
47 }
48 else
49 {
50 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
51 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
53 }
54
55 // Show the hotkey to open the windows list selector:
56 wxString keyName = KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY );
57
58 m_viewportsLabel = new wxStaticText( m_mainToolBar, wxID_ANY,
59 wxString::Format( _( "Viewports (%s+Tab):" ), keyName ) );
60 m_viewportsLabel->Wrap( -1 );
61
62 m_cbViewports = new wxChoice( m_mainToolBar, wxID_ANY );
63
64 for( std::pair<const wxString, VIEWPORT3D>& pair : m_viewports )
65 m_cbViewports->Append( pair.first, static_cast<void*>( &pair.second ) );
66
67 m_cbViewports->Append( wxT( "---" ) );
68 m_cbViewports->Append( _( "Save viewport..." ) );
69 m_cbViewports->Append( _( "Delete viewport..." ) );
70
71 m_cbViewports->SetToolTip( wxString::Format( _( "Save and restore view orientation and zoom.\n"
72 "Use %s+Tab to activate selector.\n"
73 "Successive Tabs while holding %s down will "
74 "cycle through viewports in the popup." ),
75 keyName, keyName ) );
76
77 m_cbViewports->SetSelection( m_cbViewports->GetCount() - 3 );
78
79 m_lastSelectedViewport = nullptr;
80
81 // Set up toolbar
82 m_mainToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
83 KiScaledBitmap( BITMAPS::import3d, this ), _( "Reload board" ) );
84
86 m_mainToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString,
87 KiScaledBitmap( BITMAPS::copy, this ),
88 _( "Copy 3D image to clipboard" ) );
89
91 m_mainToolBar->AddTool( ID_RENDER_CURRENT_VIEW, wxEmptyString,
92 KiScaledBitmap( BITMAPS::render_mode, this ),
93 _( "Render current view using Raytracing" ), wxITEM_CHECK );
94
100
104
108
112
115
121
124
131
133 m_mainToolBar->AddControl( m_viewportsLabel );
134 m_mainToolBar->AddControl( m_cbViewports );
135
137}
138
139
@ ID_RELOAD3D_BOARD
Definition: 3d_viewer_id.h:20
@ ID_TOOL_SCREENCOPY_TOCLIBBOARD
Definition: 3d_viewer_id.h:29
@ ID_RENDER_CURRENT_VIEW
Definition: 3d_viewer_id.h:40
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:157
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
Define the structure of a toolbar with buttons that invoke ACTIONs.
static constexpr bool TOGGLE
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION rotateXCCW
static TOOL_ACTION showNotInPosFile
static TOOL_ACTION showTHT
static TOOL_ACTION rotateZCCW
static TOOL_ACTION rotateZCW
static TOOL_ACTION rotateYCCW
static TOOL_ACTION rotateXCW
static TOOL_ACTION showDNP
static TOOL_ACTION toggleOrtho
static TOOL_ACTION moveLeft
static TOOL_ACTION showSMD
static TOOL_ACTION moveUp
static TOOL_ACTION flipView
static TOOL_ACTION moveDown
static TOOL_ACTION moveRight
static TOOL_ACTION showVirtual
static TOOL_ACTION rotateYCW
ACTION_TOOLBAR * m_mainToolBar
wxStaticText * m_viewportsLabel
void ReCreateMainToolbar()
Definition: 3d_toolbar.cpp:38
VIEWPORT3D * m_lastSelectedViewport
std::map< wxString, VIEWPORT3D > m_viewports
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
#define _(s)
Declaration of the eda_3d_viewer class.
#define VIEWPORT_SWITCH_KEY
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
@ ID_H_TOOLBAR
Definition: id.h:100
Macros and inline functions to create menus items in menubars or popup menus.
std::vector< FAB_LAYER_COLOR > dummy