KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_symbol_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) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <advanced_config.h>
24#include <eeschema_id.h>
25#include <pgm_base.h>
27#include <symbol_edit_frame.h>
28#include <sch_painter.h>
32#include <tool/action_menu.h>
33#include <tool/action_toolbar.h>
34#include <tool/tool_manager.h>
36#include <tools/sch_actions.h>
40#include <wx/combobox.h>
41
42#ifdef __UNIX__
43#define LISTBOX_WIDTH 140
44#else
45#define LISTBOX_WIDTH 120
46#endif
47
48
49std::optional<TOOLBAR_CONFIGURATION> SYMBOL_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
50{
52
53 // clang-format off
54 switch( aToolbar )
55 {
57 return std::nullopt;
58
60 config.AppendAction( ACTIONS::toggleGrid )
61 .WithContextMenu(
62 []( TOOL_MANAGER* aToolMgr )
63 {
64 SCH_SELECTION_TOOL* selTool = aToolMgr->GetTool<SCH_SELECTION_TOOL>();
65 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
66 menu->Add( ACTIONS::gridProperties );
67 return menu;
68 } )
69 .AppendAction( ACTIONS::toggleGridOverrides )
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()
81 .AppendAction( SCH_ACTIONS::showHiddenPins )
82 .AppendAction( SCH_ACTIONS::showHiddenFields );
83 // .AppendAction( SCH_ACTIONS::togglePinAltIcons );
84
85 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
87
88 config.AppendSeparator()
89 .AppendAction( ACTIONS::showLibraryTree )
90 .AppendAction( ACTIONS::showProperties );
91 break;
92
94 config.AppendAction( ACTIONS::selectionTool );
95
96 config.AppendSeparator()
97 .AppendAction( SCH_ACTIONS::placeSymbolPin )
98 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Text objects" ) )
100 .AddAction( SCH_ACTIONS::drawSymbolTextBox ) )
101 .AppendAction( SCH_ACTIONS::drawRectangle )
102 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Circle" ) )
103 .AddAction( SCH_ACTIONS::drawCircle )
104 .AddAction( SCH_ACTIONS::drawEllipse ) )
105 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Arc" ) )
106 .AddAction( SCH_ACTIONS::drawArcCenter )
109 .AddAction( SCH_ACTIONS::drawArcTangent )
111 .AddAction( SCH_ACTIONS::drawEllipseArc ) )
112 .AppendAction( SCH_ACTIONS::drawBezier )
113 .AppendAction( SCH_ACTIONS::drawSymbolLines )
114 .AppendAction( SCH_ACTIONS::drawSymbolPolygon )
115 .AppendAction( SCH_ACTIONS::placeSymbolAnchor )
116 .AppendAction( ACTIONS::deleteTool);
117 break;
118
120 config.AppendAction( SCH_ACTIONS::newSymbol )
121 .AppendAction( ACTIONS::saveAll )
122 .AppendAction( ACTIONS::save );
123
124 config.AppendSeparator()
125 .AppendAction( ACTIONS::undo )
126 .AppendAction( ACTIONS::redo );
127
128 config.AppendSeparator()
129 .AppendAction( ACTIONS::find )
130 .AppendAction( ACTIONS::findAndReplace );
131
132 config.AppendSeparator()
133 .AppendAction( ACTIONS::zoomRedraw )
134 .AppendAction( ACTIONS::zoomInCenter )
135 .AppendAction( ACTIONS::zoomOutCenter )
136 .AppendAction( ACTIONS::zoomFitScreen )
137 .AppendAction( ACTIONS::zoomTool );
138
139 config.AppendSeparator()
140 .AppendAction( SCH_ACTIONS::rotateCCW )
141 .AppendAction( SCH_ACTIONS::rotateCW )
142 .AppendAction( SCH_ACTIONS::mirrorV )
143 .AppendAction( SCH_ACTIONS::mirrorH );
144
145 config.AppendSeparator()
146 .AppendAction( SCH_ACTIONS::symbolProperties )
147 .AppendAction( SCH_ACTIONS::pinTable );
148
149 config.AppendSeparator()
150 .AppendAction( ACTIONS::showDatasheet )
151 .AppendAction( SCH_ACTIONS::checkSymbol );
152
153 config.AppendSeparator()
155
156 config.AppendSeparator()
158
159 config.AppendSeparator()
160 .AppendAction( SCH_ACTIONS::toggleSyncedPinsMode );
161
162 config.AppendSeparator()
163 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
164
165 config.AppendSeparator()
167 break;
168 }
169
170 // clang-format on
171 return config;
172}
173
174
176{
178
179 auto unitDisplayFactory =
180 [this]( ACTION_TOOLBAR* aToolbar )
181 {
182 if( !m_unitSelectBox )
183 {
184 m_unitSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_UNIT_NUMBER,
185 wxEmptyString, wxDefaultPosition,
186 wxSize( LISTBOX_WIDTH, -1 ), 0,
187 nullptr, wxCB_READONLY );
188 }
189
190 aToolbar->Add( m_unitSelectBox );
191 };
192
193 auto bodyDisplayFactory =
194 [this]( ACTION_TOOLBAR* aToolbar )
195 {
197 {
198 m_bodyStyleSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_BODY_STYLE,
199 wxEmptyString, wxDefaultPosition,
200 wxSize( LISTBOX_WIDTH, -1 ), 0,
201 nullptr, wxCB_READONLY );
202 }
203
204 aToolbar->Add( m_bodyStyleSelectBox );
205 };
206
209
210 // IPC/Scripting plugin control
211 auto pluginControlFactory =
212 [this]( ACTION_TOOLBAR* aToolbar )
213 {
214 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server
216
217 if( haveApiPlugins )
218 {
219 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
220 AddApiPluginTools( aToolbar );
221 }
222 };
223
225}
226
227
229{
231
232 switch( aId )
233 {
234 case ID_LIBEDIT_SELECT_UNIT_NUMBER: m_unitSelectBox = nullptr; break;
236 }
237}
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 showDatasheet
Definition actions.h:263
static TOOL_ACTION findAndReplace
Definition actions.h:114
static TOOL_ACTION milsUnits
Definition actions.h:201
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:153
static TOOL_ACTION saveAll
Definition actions.h:57
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION inchesUnits
Definition actions.h:200
static TOOL_ACTION selectionTool
Definition actions.h:247
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 showProperties
Definition actions.h:262
static TOOL_ACTION zoomInCenter
Definition actions.h:131
static TOOL_ACTION toggleGridOverrides
Definition actions.h:195
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:149
static TOOL_ACTION find
Definition actions.h:113
static ACTION_TOOLBAR_CONTROL unitSelector
static ACTION_TOOLBAR_CONTROL ipcScripting
static ACTION_TOOLBAR_CONTROL bodyStyleSelector
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 ClearToolbarControl(int aId)
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.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:546
virtual API_PLUGIN_MANAGER & GetPluginManager() const
Definition pgm_base.h:139
static TOOL_ACTION rotateCCW
static TOOL_ACTION newSymbol
static TOOL_ACTION drawArcCenter
static TOOL_ACTION drawArcStartEndCenter
static TOOL_ACTION mirrorV
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION checkSymbol
static TOOL_ACTION pinTable
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION drawRectangle
static TOOL_ACTION drawEllipse
static TOOL_ACTION drawCircle
static TOOL_ACTION drawArcTangent
static TOOL_ACTION drawBezier
static TOOL_ACTION rotateCW
static TOOL_ACTION showElectricalTypes
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION showHiddenFields
static TOOL_ACTION placeSymbolAnchor
static TOOL_ACTION showHiddenPins
static TOOL_ACTION drawArcStartDirEnd
static TOOL_ACTION mirrorH
static TOOL_ACTION symbolProperties
static TOOL_ACTION placeSymbolText
static TOOL_ACTION drawArcStartEndMid
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION addSymbolToSchematic
wxComboBox * m_unitSelectBox
void ClearToolbarControl(int aId) override
PLUGIN_ACTION_SCOPE PluginActionScope() const override
void configureToolbars() override
wxComboBox * m_bodyStyleSelectBox
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
Master controller class:
T * GetTool()
Return the tool of given type or nullptr if there is no such tool registered.
#define _(s)
@ ID_LIBEDIT_SELECT_UNIT_NUMBER
Definition eeschema_id.h:59
@ ID_LIBEDIT_SELECT_BODY_STYLE
Definition eeschema_id.h:60
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.
#define LISTBOX_WIDTH