KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_footprint_editor.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * 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, see <https://www.gnu.org/licenses/>.
21 */
22
23#include <tool/actions.h>
24#include <tool/action_menu.h>
26#include <pcbnew_id.h>
27#include <bitmaps.h>
28#include <lset.h>
29#include <tool/action_toolbar.h>
30#include <tool/tool_manager.h>
32#include <tools/pcb_actions.h>
35#include <wx/choice.h>
36#include <wx/wupdlock.h>
37#include <advanced_config.h>
39#include <api/api_utils.h>
40#include <pgm_base.h>
42#include <wx/log.h>
43
45
46std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
47{
49
50 // clang-format off
51 switch( aToolbar )
52 {
53 // No Aux toolbar
55 return std::nullopt;
56
58 config.AppendAction( ACTIONS::toggleGrid )
59 .WithContextMenu(
60 []( TOOL_MANAGER* aToolMgr )
61 {
62 PCB_SELECTION_TOOL* selTool = aToolMgr->GetTool<PCB_SELECTION_TOOL>();
63 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
64 menu->Add( ACTIONS::gridProperties );
65 menu->Add( ACTIONS::gridOrigin );
66 return menu;
67 } )
68 .AppendAction( ACTIONS::toggleGridOverrides )
69 .AppendAction( PCB_ACTIONS::togglePolarCoords )
70 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
71 .AddAction( ACTIONS::millimetersUnits )
72 .AddAction( ACTIONS::inchesUnits )
73 .AddAction( ACTIONS::milsUnits ) )
74 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
77 .AddAction( ACTIONS::cursor45Crosshairs ) );
78
79 config.AppendSeparator()
80 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
81 .AddAction( PCB_ACTIONS::lineModeFree )
82 .AddAction( PCB_ACTIONS::lineMode90 )
83 .AddAction( PCB_ACTIONS::lineMode45 ) )
85
86 config.AppendSeparator()
87 .AppendAction( PCB_ACTIONS::padDisplayMode )
88 .AppendAction( PCB_ACTIONS::graphicsOutlines )
89 .AppendAction( PCB_ACTIONS::textOutlines )
90 .AppendAction( ACTIONS::highContrastMode );
91
92 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
94
95 config.AppendSeparator()
96 .AppendAction( ACTIONS::showLibraryTree )
97 .AppendAction( PCB_ACTIONS::showLayersManager )
98 .AppendAction( ACTIONS::showProperties );
99 break;
100
102 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
103 .AddAction( ACTIONS::selectSetRect )
104 .AddAction( ACTIONS::selectSetLasso ) );
105
106 config.AppendSeparator()
107 .AppendAction( PCB_ACTIONS::placePad )
108 .AppendAction( PCB_ACTIONS::drawRuleArea );
109
110 config.AppendSeparator()
111 .AppendAction( PCB_ACTIONS::drawLine )
112 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Arc" ) )
113 .AddAction( PCB_ACTIONS::drawArcCenter )
116 .AddAction( PCB_ACTIONS::drawArcTangent )
118 .AddAction( PCB_ACTIONS::drawEllipseArc )
119 .AddContextMenu(
120 []( TOOL_MANAGER* aToolMgr )
121 {
122 PCB_SELECTION_TOOL* selTool = aToolMgr->GetTool<PCB_SELECTION_TOOL>();
123 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
127 return menu;
128 } ) )
129 .AppendAction( PCB_ACTIONS::drawRectangle )
130 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Circle" ) )
131 .AddAction( PCB_ACTIONS::drawCircle )
132 .AddAction( PCB_ACTIONS::drawEllipse ) )
133 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Constraints" ) )
152 .AppendAction( PCB_ACTIONS::drawPolygon )
153 .AppendAction( PCB_ACTIONS::drawBezier )
154 .AppendAction( PCB_ACTIONS::placeReferenceImage )
155 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Text objects" ) )
156 .AddAction( PCB_ACTIONS::placeText )
157 .AddAction( PCB_ACTIONS::drawTextBox ) )
158 .AppendAction( PCB_ACTIONS::drawTable )
159 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
164 .AddAction( PCB_ACTIONS::drawLeader ) )
165 .AppendAction( PCB_ACTIONS::placeBarcode )
166 .AppendAction( ACTIONS::deleteTool );
167
168 config.AppendSeparator()
169 .AppendAction( PCB_ACTIONS::placePoint )
170 .AppendAction( PCB_ACTIONS::setAnchor )
171 .AppendAction( ACTIONS::gridSetOrigin )
172 .AppendAction( ACTIONS::measureTool );
173 break;
174
176 config.AppendAction( PCB_ACTIONS::newFootprint )
177 .AppendAction( PCB_ACTIONS::createFootprint )
178 .AppendAction( ACTIONS::save );
179
180 config.AppendSeparator()
181 .AppendAction( ACTIONS::print );
182
183 config.AppendSeparator()
184 .AppendAction( ACTIONS::undo )
185 .AppendAction( ACTIONS::redo );
186
187 config.AppendSeparator()
188 .AppendAction( ACTIONS::zoomRedraw )
189 .AppendAction( ACTIONS::zoomInCenter )
190 .AppendAction( ACTIONS::zoomOutCenter )
191 .AppendAction( ACTIONS::zoomFitScreen )
192 .AppendAction( ACTIONS::zoomTool );
193
194 config.AppendSeparator()
195 .AppendAction( PCB_ACTIONS::rotateCcw )
196 .AppendAction( PCB_ACTIONS::rotateCw )
197 .AppendAction( PCB_ACTIONS::mirrorV )
198 .AppendAction( PCB_ACTIONS::mirrorH )
199 .AppendAction( ACTIONS::group )
200 .AppendAction( ACTIONS::ungroup );
201
202 config.AppendSeparator()
203 .AppendAction( PCB_ACTIONS::footprintProperties )
204 .AppendAction( PCB_ACTIONS::padTable )
205 .AppendAction( PCB_ACTIONS::defaultPadProperties )
206 .AppendAction( ACTIONS::showDatasheet )
207 .AppendAction( PCB_ACTIONS::checkFootprint );
208
209 config.AppendSeparator()
210 .AppendAction( PCB_ACTIONS::loadFpFromBoard )
211 .AppendAction( PCB_ACTIONS::saveFpToBoard );
212
213 config.AppendSeparator()
214 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
215
216 config.AppendSeparator()
217 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
218
219 config.AppendSeparator()
221
222 config.AppendSeparator()
224 break;
225 }
226
227 // clang-format on
228 return config;
229}
230
231
232void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
233{
234 if( !m_SelLayerBox )
235 return;
236
237 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
238 m_SelLayerBox->Resync();
239
240 if( aForceResizeToolbar )
242}
243
245{
247
248 // IPC/Scripting plugin control
249 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this
250 // entire control
251 auto pluginControlFactory =
252 [this]( ACTION_TOOLBAR* aToolbar )
253 {
254 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server
256
257 if( haveApiPlugins )
258 {
259 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
260 AddApiPluginTools( aToolbar );
261 }
262 };
263
265}
266
267
269{
270 wxLogTrace( traceApi, "Footprint editor frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
273 aEvt.Skip();
274}
static TOOL_ACTION gridProperties
Definition actions.h:196
static TOOL_ACTION toggleGrid
Definition actions.h:194
static TOOL_ACTION zoomRedraw
Definition actions.h:128
static TOOL_ACTION millimetersUnits
Definition actions.h:202
static TOOL_ACTION showLibraryTree
Definition actions.h:160
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:148
static TOOL_ACTION zoomOutCenter
Definition actions.h:132
static TOOL_ACTION togglePolarCoords
Definition actions.h:205
static TOOL_ACTION selectSetLasso
Definition actions.h:217
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:216
static TOOL_ACTION group
Definition actions.h:235
static TOOL_ACTION showDatasheet
Definition actions.h:263
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:272
static TOOL_ACTION milsUnits
Definition actions.h:201
static TOOL_ACTION ungroup
Definition actions.h:236
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:153
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:274
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION inchesUnits
Definition actions.h:200
static TOOL_ACTION highContrastMode
Definition actions.h:151
static TOOL_ACTION gridOrigin
Definition actions.h:197
static TOOL_ACTION measureTool
Definition actions.h:248
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION redo
Definition actions.h:72
static TOOL_ACTION deleteTool
Definition actions.h:82
static TOOL_ACTION zoomTool
Definition actions.h:142
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:150
static TOOL_ACTION print
Definition actions.h:60
static TOOL_ACTION showProperties
Definition actions.h:262
static TOOL_ACTION zoomInCenter
Definition actions.h:131
static TOOL_ACTION gridSetOrigin
Definition actions.h:191
static TOOL_ACTION toggleGridOverrides
Definition actions.h:195
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:273
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:149
static constexpr bool CHECK
static ACTION_TOOLBAR_CONTROL gridSelect
static ACTION_TOOLBAR_CONTROL layerSelector
static ACTION_TOOLBAR_CONTROL zoomSelect
static ACTION_TOOLBAR_CONTROL ipcScripting
Define the structure of a toolbar with buttons that invoke ACTIONs.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
std::vector< const PLUGIN_ACTION * > GetActionsForScope(PLUGIN_ACTION_SCOPE aScope)
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
virtual void RecreateToolbars()
void ReCreateMenuBar()
Recreate the menu bar.
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
void onPluginAvailabilityChanged(wxCommandEvent &aEvt)
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building a new one from the new layers names an...
PLUGIN_ACTION_SCOPE PluginActionScope() const override
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION drawRuleArea
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION setAnchor
static TOOL_ACTION padDisplayMode
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION showLayersManager
static TOOL_ACTION drawArcStartEndCenter
static TOOL_ACTION addConstraintVertical
static TOOL_ACTION drawCircle
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION createFootprint
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION addConstraintPerpendicular
static TOOL_ACTION drawPolygon
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
static TOOL_ACTION drawArcStartDirEnd
static TOOL_ACTION drawRadialDimension
static TOOL_ACTION padTable
static TOOL_ACTION drawLeader
static TOOL_ACTION addConstraintAngular
static TOOL_ACTION lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION addConstraintArcAngle
static TOOL_ACTION newFootprint
static TOOL_ACTION defaultPadProperties
static TOOL_ACTION addConstraintHorizontal
static TOOL_ACTION drawEllipse
static TOOL_ACTION addConstraintCollinear
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION addConstraintEqualRadius
static TOOL_ACTION addConstraintTangent
static TOOL_ACTION loadFpFromBoard
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION drawArcCenter
static TOOL_ACTION drawArcTangent
static TOOL_ACTION addConstraintFixedLength
static TOOL_ACTION footprintProperties
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION toggleAutoConstraints
Toggle authoring constraints automatically while drawing.
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION checkFootprint
static TOOL_ACTION placeBarcode
static TOOL_ACTION placePoint
static TOOL_ACTION addConstraintSymmetric
static TOOL_ACTION addConstraintFixedPosition
Ground a point, and the cluster holding it.
static TOOL_ACTION mirrorV
static TOOL_ACTION addConstraintPointOnLine
static TOOL_ACTION saveFpToBoard
static TOOL_ACTION addConstraintCoincident
static TOOL_ACTION drawLine
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION addConstraintParallel
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION addConstraintFixedRadius
static TOOL_ACTION addConstraintEqualLength
static TOOL_ACTION drawArcStartEndMid
static TOOL_ACTION addConstraintMidpoint
static TOOL_ACTION addConstraintConcentric
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void configureToolbars() override
The selection tool: currently supports:
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:546
virtual API_PLUGIN_MANAGER & GetPluginManager() const
Definition pgm_base.h:139
Master controller class:
T * GetTool()
Return the tool of given type or nullptr if there is no such tool registered.
#define _(s)
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:33
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.