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 (C) 2004-2019 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
46/* Create the main Horizontal Toolbar for the schematic editor
47 */
49{
50 if( m_mainToolBar )
51 {
53 }
54 else
55 {
57 wxDefaultPosition, wxDefaultSize,
58 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
60 }
61
62 // Set up toolbar
63 if( Kiface().IsSingle() ) // not when under a project mgr
64 {
67 }
68
70
73
78
81
85
89
97
102
108
113
121
124
125 // Add scripting console and API plugins
126 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
127#ifdef KICAD_IPC_API
128 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
129 !Pgm().GetPluginManager().GetActionsForScope( PLUGIN_ACTION_SCOPE::SCHEMATIC ).empty();
130#else
131 bool haveApiPlugins = false;
132#endif
133
134 if( scriptingAvailable || haveApiPlugins )
135 {
137
138 if( scriptingAvailable )
140
141 if( haveApiPlugins )
143 }
144
145 // after adding the tools to the toolbar, must call Realize() to reflect the changes
147}
148
149
150/* Create Vertical Right Toolbar
151 */
153{
154 if( m_drawToolBar )
155 {
157 }
158 else
159 {
160 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
161 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
163 }
164
165 // Set up toolbar
166 // clang-format off
169
186
198 // clang-format on
199
201}
202
203
204/* Create Vertical Left Toolbar (Option Toolbar)
205 */
207{
208 if( m_optionsToolBar )
209 {
211 }
212 else
213 {
215 wxDefaultPosition, wxDefaultSize,
216 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
218 }
219
226
229
234
237
241
242 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
244
246 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
247 gridMenu->Add( ACTIONS::gridProperties );
249
251}
252
253
255{
257
258 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
259 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
260
262
263 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
264 searchPaneInfo.Show( m_show_search );
265
266 if( m_show_search )
267 {
268 searchPaneInfo.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
269
270 if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
271 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
272 {
273 SetAuiPaneSize( m_auimgr, searchPaneInfo, -1, cfg->m_AuiPanels.search_panel_height );
274 }
275 else if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
276 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
277 {
278 SetAuiPaneSize( m_auimgr, searchPaneInfo, cfg->m_AuiPanels.search_panel_width, -1 );
279 }
280
282 }
283 else
284 {
285 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
286 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
287 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
288 m_auimgr.Update();
289 }
290}
291
292
294{
295 if( !m_propertiesPanel )
296 return;
297
298 bool show = !m_propertiesPanel->IsShownOnScreen();
299
300 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
301 propertiesPaneInfo.Show( show );
302
304
305 EESCHEMA_SETTINGS* settings = eeconfig();
306
307 if( show )
308 {
309 SetAuiPaneSize( m_auimgr, propertiesPaneInfo,
310 settings->m_AuiPanels.properties_panel_width, -1 );
311 }
312 else
313 {
315 m_auimgr.Update();
316 }
317}
318
319
321{
323
324 wxCHECK( cfg, /* void */ );
325
326 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
327
328 hierarchy_pane.Show( !hierarchy_pane.IsShown() );
329
331
332 if( hierarchy_pane.IsShown() )
333 {
334 if( hierarchy_pane.IsFloating() )
335 {
336 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
338 m_auimgr.Update();
339 }
340 else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
341 {
342 // SetAuiPaneSize also updates m_auimgr
343 SetAuiPaneSize( m_auimgr, hierarchy_pane,
345 }
346 }
347 else
348 {
349 if( hierarchy_pane.IsFloating() )
350 {
351 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
352 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
353 }
354 else
355 {
357 }
358
359 m_auimgr.Update();
360 }
361}
362
363
365{
367
368 wxCHECK( cfg, /* void */ );
369
370 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
371
372 db_library_pane.Show( !db_library_pane.IsShown() );
373
374 if( db_library_pane.IsShown() )
375 {
376 if( db_library_pane.IsFloating() )
377 {
378 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
380 m_auimgr.Update();
381 }
383 {
384 // SetAuiPaneSize also updates m_auimgr
385 SetAuiPaneSize( m_auimgr, db_library_pane,
387 }
388 }
389 else
390 {
391 if( db_library_pane.IsFloating() )
392 {
393 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
394 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
395 }
396 else
397 {
399 }
400
401 m_auimgr.Update();
402 }
403}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION gridProperties
Definition: actions.h:189
static TOOL_ACTION toggleGrid
Definition: actions.h:187
static TOOL_ACTION paste
Definition: actions.h:73
static TOOL_ACTION zoomRedraw
Definition: actions.h:124
static TOOL_ACTION millimetersUnits
Definition: actions.h:195
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION showSymbolEditor
Definition: actions.h:211
static TOOL_ACTION showSymbolBrowser
Definition: actions.h:210
static TOOL_ACTION findAndReplace
Definition: actions.h:110
static TOOL_ACTION milsUnits
Definition: actions.h:194
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:193
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:144
static TOOL_ACTION selectionTool
Definition: actions.h:202
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:213
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:216
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:188
static TOOL_ACTION find
Definition: actions.h:109
Define the structure of a toolbar with buttons that invoke ACTIONs.
static constexpr bool TOGGLE
static constexpr bool CANCEL
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
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 const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_optionsToolBar
static const wxString PropertiesPaneName()
ACTION_TOOLBAR * m_mainToolBar
ACTION_TOOLBAR * m_drawToolBar
SEARCH_PANE * m_searchPane
static const wxString DesignBlocksPaneName()
PROPERTIES_PANEL * m_propertiesPanel
virtual void addApiPluginTools()
Append actions from API plugins to the main toolbar.
static TOOL_ACTION mirrorV
Definition: ee_actions.h:132
static TOOL_ACTION runERC
Inspection and Editing.
Definition: ee_actions.h:156
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:284
static TOOL_ACTION lineMode90
Definition: ee_actions.h:279
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:247
static TOOL_ACTION drawTable
Definition: ee_actions.h:104
static TOOL_ACTION syncAllSheetsPins
Definition: ee_actions.h:101
static TOOL_ACTION navigateForward
Definition: ee_actions.h:235
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:79
static TOOL_ACTION navigateBack
Definition: ee_actions.h:236
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:272
static TOOL_ACTION drawRuleArea
Definition: ee_actions.h:113
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:106
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:131
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:278
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:109
static TOOL_ACTION mirrorH
Definition: ee_actions.h:133
static TOOL_ACTION showSimulator
Definition: ee_actions.h:295
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:311
static TOOL_ACTION rotateCW
Definition: ee_actions.h:130
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:167
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:159
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:103
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:105
static TOOL_ACTION annotate
Definition: ee_actions.h:157
static TOOL_ACTION placeImage
Definition: ee_actions.h:110
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:239
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:102
static TOOL_ACTION drawArc
Definition: ee_actions.h:107
static TOOL_ACTION lineMode45
Definition: ee_actions.h:280
static TOOL_ACTION drawSheet
Definition: ee_actions.h:93
static TOOL_ACTION drawBezier
Definition: ee_actions.h:108
static TOOL_ACTION navigateUp
Definition: ee_actions.h:234
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:181
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:184
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:86
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:169
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
EESCHEMA_SETTINGS * eeconfig() const
void ToggleProperties() override
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void ToggleLibraryTree() override
void ReCreateVToolbar() override
void ToggleSearch()
Toggle the show/hide state of Search pane.
static const wxString SearchPaneName()
void ToggleSchematicHierarchy()
Toggle the show/hide state of the left side schematic navigation panel.
static const wxString SchematicHierarchyPaneName()
void ReCreateOptToolbar() override
DESIGN_BLOCK_PANE * m_designBlocksPane
HIERARCHY_PANE * m_hierarchy
void ReCreateHToolbar() override
void FocusSearch()
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
@ ID_OPT_TOOLBAR
Definition: id.h:101
@ ID_V_TOOLBAR
Definition: id.h:100
@ ID_H_TOOLBAR
Definition: id.h:99
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.