KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_sch_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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 * Copyright (C) 2019 CERN
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 <advanced_config.h>
29#include <sch_draw_panel.h>
30#include <sch_edit_frame.h>
31#include <kiface_base.h>
32#include <bitmaps.h>
33#include <eeschema_id.h>
34#include <pgm_base.h>
35#include <python_scripting.h>
36#include <tool/tool_manager.h>
37#include <tool/action_toolbar.h>
38#include <tools/ee_actions.h>
45#include <toolbars_sch_editor.h>
46
47
48std::optional<TOOLBAR_CONFIGURATION> SCH_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
49{
51
52 // clang-format off
53 switch( aToolbar )
54 {
55 case TOOLBAR_LOC::TOP_AUX:
56 return std::nullopt;
57
58 case TOOLBAR_LOC::LEFT:
59 config.AppendAction( ACTIONS::toggleGrid )
60 .AppendAction( ACTIONS::toggleGridOverrides )
61 .AppendAction( ACTIONS::inchesUnits )
62 .AppendAction( ACTIONS::milsUnits )
63 .AppendAction( ACTIONS::millimetersUnits )
64 .AppendAction( ACTIONS::toggleCursorStyle );
65
66 config.AppendSeparator()
67 .AppendAction( EE_ACTIONS::toggleHiddenPins );
68
69 config.AppendSeparator()
70 .AppendAction( EE_ACTIONS::lineModeFree )
71 .AppendAction( EE_ACTIONS::lineMode90 )
72 .AppendAction( EE_ACTIONS::lineMode45 );
73
74 config.AppendSeparator()
75 .AppendAction( EE_ACTIONS::toggleAnnotateAuto );
76
77 config.AppendSeparator()
78 .AppendAction( EE_ACTIONS::showHierarchy )
79 .AppendAction( ACTIONS::showProperties );
80
81 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
83
84 /* TODO (ISM): Handle context menus
85 EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
86 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
87 gridMenu->Add( ACTIONS::gridProperties );
88 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
89 */
90 break;
91
92 case TOOLBAR_LOC::RIGHT:
93 config.AppendAction( ACTIONS::selectionTool )
94 .AppendAction( EE_ACTIONS::highlightNetTool );
95
96 config.AppendSeparator()
97 .AppendAction( EE_ACTIONS::placeSymbol )
98 .AppendAction( EE_ACTIONS::placePower )
99 .AppendAction( EE_ACTIONS::drawWire )
100 .AppendAction( EE_ACTIONS::drawBus )
101 .AppendAction( EE_ACTIONS::placeBusWireEntry )
102 .AppendAction( EE_ACTIONS::placeNoConnect )
103 .AppendAction( EE_ACTIONS::placeJunction )
104 .AppendAction( EE_ACTIONS::placeLabel )
105 .AppendAction( EE_ACTIONS::placeClassLabel )
106 .AppendAction( EE_ACTIONS::drawRuleArea )
107 .AppendAction( EE_ACTIONS::placeGlobalLabel )
108 .AppendAction( EE_ACTIONS::placeHierLabel )
109 .AppendAction( EE_ACTIONS::drawSheet )
110 .AppendAction( EE_ACTIONS::placeSheetPin )
111 .AppendAction( EE_ACTIONS::syncAllSheetsPins );
112
113 config.AppendSeparator()
114 .AppendAction( EE_ACTIONS::placeSchematicText )
115 .AppendAction( EE_ACTIONS::drawTextBox )
116 .AppendAction( EE_ACTIONS::drawTable )
117 .AppendAction( EE_ACTIONS::drawRectangle )
118 .AppendAction( EE_ACTIONS::drawCircle )
119 .AppendAction( EE_ACTIONS::drawArc )
120 .AppendAction( EE_ACTIONS::drawBezier )
121 .AppendAction( EE_ACTIONS::drawLines )
122 .AppendAction( EE_ACTIONS::placeImage )
123 .AppendAction( ACTIONS::deleteTool );
124
125 break;
126
127 case TOOLBAR_LOC::TOP_MAIN:
128 if( Kiface().IsSingle() ) // not when under a project mgr
129 {
130 config.AppendAction( ACTIONS::doNew );
131 config.AppendAction( ACTIONS::open );
132 }
133
134 config.AppendAction( ACTIONS::save );
135
136 config.AppendSeparator()
137 .AppendAction( EE_ACTIONS::schematicSetup );
138
139 config.AppendSeparator()
140 .AppendAction( ACTIONS::pageSettings )
141 .AppendAction( ACTIONS::print )
142 .AppendAction( ACTIONS::plot );
143
144 config.AppendSeparator()
145 .AppendAction( ACTIONS::paste );
146
147 config.AppendSeparator()
148 .AppendAction( ACTIONS::undo )
149 .AppendAction( ACTIONS::redo );
150
151 config.AppendSeparator()
152 .AppendAction( ACTIONS::find )
153 .AppendAction( ACTIONS::findAndReplace );
154
155 config.AppendSeparator()
156 .AppendAction( ACTIONS::zoomRedraw )
157 .AppendAction( ACTIONS::zoomInCenter )
158 .AppendAction( ACTIONS::zoomOutCenter )
159 .AppendAction( ACTIONS::zoomFitScreen )
160 .AppendAction( ACTIONS::zoomFitObjects )
161 .AppendAction( ACTIONS::zoomTool );
162
163 config.AppendSeparator()
164 .AppendAction( EE_ACTIONS::navigateBack )
165 .AppendAction( EE_ACTIONS::navigateUp )
166 .AppendAction( EE_ACTIONS::navigateForward );
167
168 config.AppendSeparator()
169 .AppendAction( EE_ACTIONS::rotateCCW )
170 .AppendAction( EE_ACTIONS::rotateCW )
171 .AppendAction( EE_ACTIONS::mirrorV )
172 .AppendAction( EE_ACTIONS::mirrorH );
173
174 config.AppendSeparator()
175 .AppendAction( ACTIONS::showSymbolEditor )
176 .AppendAction( ACTIONS::showSymbolBrowser )
177 .AppendAction( ACTIONS::showFootprintEditor );
178
179 config.AppendSeparator()
180 .AppendAction( EE_ACTIONS::annotate )
181 .AppendAction( EE_ACTIONS::runERC )
182 .AppendAction( EE_ACTIONS::showSimulator )
183 .AppendAction( EE_ACTIONS::assignFootprints )
184 .AppendAction( EE_ACTIONS::editSymbolFields )
185 .AppendAction( EE_ACTIONS::generateBOM );
186
187 config.AppendSeparator()
188 .AppendAction( EE_ACTIONS::showPcbNew );
189
190 // Insert all the IPC plugins here on the toolbar
191 // TODO (ISM): Move this to individual actions for each script
193
194 break;
195 }
196
197 // clang-format on
198 return config;
199}
200
201
203{
205
206 // IPC/Scripting plugin control
207 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
208 // control
209 auto pluginControlFactory =
210 [this]( ACTION_TOOLBAR* aToolbar )
211 {
212 // Add scripting console and API plugins
213 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
214
215 #ifdef KICAD_IPC_API
216 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
217 !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
218 #else
219 bool haveApiPlugins = false;
220 #endif
221
222 if( scriptingAvailable || haveApiPlugins )
223 {
224 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
225
226 if( haveApiPlugins )
227 AddApiPluginTools( aToolbar );
228 }
229 };
230
232
233}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION toggleGrid
Definition: actions.h:191
static TOOL_ACTION paste
Definition: actions.h:73
static TOOL_ACTION zoomRedraw
Definition: actions.h:124
static TOOL_ACTION millimetersUnits
Definition: actions.h:199
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION showSymbolEditor
Definition: actions.h:215
static TOOL_ACTION showSymbolBrowser
Definition: actions.h:214
static TOOL_ACTION findAndReplace
Definition: actions.h:110
static TOOL_ACTION milsUnits
Definition: actions.h:198
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:147
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION inchesUnits
Definition: actions.h:197
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:144
static TOOL_ACTION selectionTool
Definition: actions.h:206
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:79
static TOOL_ACTION zoomTool
Definition: actions.h:138
static TOOL_ACTION showFootprintEditor
Definition: actions.h:217
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:220
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomFitObjects
Definition: actions.h:135
static TOOL_ACTION zoomInCenter
Definition: actions.h:127
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:192
static TOOL_ACTION find
Definition: actions.h:109
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.
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 configureToolbars()
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
static TOOL_ACTION mirrorV
Definition: ee_actions.h:133
static TOOL_ACTION runERC
Inspection and Editing.
Definition: ee_actions.h:157
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:280
static TOOL_ACTION lineMode90
Definition: ee_actions.h:275
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:243
static TOOL_ACTION drawTable
Definition: ee_actions.h:105
static TOOL_ACTION syncAllSheetsPins
Definition: ee_actions.h:102
static TOOL_ACTION navigateForward
Definition: ee_actions.h:231
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:79
static TOOL_ACTION navigateBack
Definition: ee_actions.h:232
static TOOL_ACTION drawRuleArea
Definition: ee_actions.h:114
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:90
static TOOL_ACTION drawWire
Definition: ee_actions.h:83
static TOOL_ACTION drawCircle
Definition: ee_actions.h:107
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:132
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:274
static TOOL_ACTION drawBus
Definition: ee_actions.h:84
static TOOL_ACTION placePower
Definition: ee_actions.h:81
static TOOL_ACTION placeSheetPin
Definition: ee_actions.h:96
static TOOL_ACTION drawLines
Definition: ee_actions.h:110
static TOOL_ACTION mirrorH
Definition: ee_actions.h:134
static TOOL_ACTION showSimulator
Definition: ee_actions.h:291
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:307
static TOOL_ACTION rotateCW
Definition: ee_actions.h:131
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:168
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:91
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:92
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:160
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:104
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:106
static TOOL_ACTION annotate
Definition: ee_actions.h:158
static TOOL_ACTION placeImage
Definition: ee_actions.h:111
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:235
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:103
static TOOL_ACTION drawArc
Definition: ee_actions.h:108
static TOOL_ACTION lineMode45
Definition: ee_actions.h:276
static TOOL_ACTION drawSheet
Definition: ee_actions.h:93
static TOOL_ACTION drawBezier
Definition: ee_actions.h:109
static TOOL_ACTION navigateUp
Definition: ee_actions.h:230
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:185
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:88
static TOOL_ACTION placeJunction
Definition: ee_actions.h:87
static TOOL_ACTION generateBOM
Definition: ee_actions.h:188
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:86
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:170
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:689
void configureToolbars() override
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.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1073
see class PGM_BASE