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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <advanced_config.h>
27#include <eeschema_id.h>
28#include <symbol_edit_frame.h>
29#include <sch_painter.h>
33#include <tool/action_toolbar.h>
34#include <tool/tool_manager.h>
35#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 .AppendAction( ACTIONS::toggleGridOverrides )
62 .AppendAction( ACTIONS::inchesUnits )
63 .AppendAction( ACTIONS::milsUnits )
64 .AppendAction( ACTIONS::millimetersUnits )
65 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
68 .AddAction( ACTIONS::cursor45Crosshairs ) );
69
70 config.AppendSeparator()
72 .AppendAction( SCH_ACTIONS::showHiddenPins )
73 .AppendAction( SCH_ACTIONS::showHiddenFields );
74 // .AppendAction( SCH_ACTIONS::togglePinAltIcons );
75
76 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
78
79 config.AppendSeparator()
80 .AppendAction( ACTIONS::showLibraryTree )
81 .AppendAction( ACTIONS::showProperties );
82
83 /* TODO: Implement context menus
84 EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
85 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
86 gridMenu->Add( ACTIONS::gridProperties );
87 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
88 */
89 break;
90
92 config.AppendAction( ACTIONS::selectionTool );
93
94 config.AppendSeparator()
95 .AppendAction( SCH_ACTIONS::placeSymbolPin )
96 .AppendAction( SCH_ACTIONS::placeSymbolText )
97 .AppendAction( SCH_ACTIONS::drawSymbolTextBox )
98 .AppendAction( SCH_ACTIONS::drawRectangle )
99 .AppendAction( SCH_ACTIONS::drawCircle )
100 .AppendAction( SCH_ACTIONS::drawArc )
101 .AppendAction( SCH_ACTIONS::drawBezier )
102 .AppendAction( SCH_ACTIONS::drawSymbolLines )
103 .AppendAction( SCH_ACTIONS::drawSymbolPolygon )
104 .AppendAction( SCH_ACTIONS::placeSymbolAnchor )
105 .AppendAction( ACTIONS::deleteTool);
106 break;
107
109 config.AppendAction( SCH_ACTIONS::newSymbol );
110
111/* TODO (ISM): Handle visibility changes
112 if( !IsSymbolFromSchematic() )
113 config.AppendAction( ACTIONS::saveAll );
114 else
115 config.AppendAction( ACTIONS::save );
116*/
117
118 config.AppendSeparator()
119 .AppendAction( ACTIONS::undo )
120 .AppendAction( ACTIONS::redo );
121
122 config.AppendSeparator()
123 .AppendAction( ACTIONS::find )
124 .AppendAction( ACTIONS::findAndReplace );
125
126 config.AppendSeparator()
127 .AppendAction( ACTIONS::zoomRedraw )
128 .AppendAction( ACTIONS::zoomInCenter )
129 .AppendAction( ACTIONS::zoomOutCenter )
130 .AppendAction( ACTIONS::zoomFitScreen )
131 .AppendAction( ACTIONS::zoomTool );
132
133 config.AppendSeparator()
134 .AppendAction( SCH_ACTIONS::rotateCCW )
135 .AppendAction( SCH_ACTIONS::rotateCW )
136 .AppendAction( SCH_ACTIONS::mirrorV )
137 .AppendAction( SCH_ACTIONS::mirrorH );
138
139 config.AppendSeparator()
140 .AppendAction( SCH_ACTIONS::symbolProperties )
141 .AppendAction( SCH_ACTIONS::pinTable );
142
143 config.AppendSeparator()
144 .AppendAction( ACTIONS::showDatasheet )
145 .AppendAction( SCH_ACTIONS::checkSymbol );
146
147 config.AppendSeparator()
149
150 config.AppendSeparator()
152
153 config.AppendSeparator()
154 .AppendAction( SCH_ACTIONS::toggleSyncedPinsMode );
155
156 config.AppendSeparator()
157 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
158 break;
159 }
160
161 // clang-format on
162 return config;
163}
164
165
167{
169
170 auto unitDisplayFactory =
171 [this]( ACTION_TOOLBAR* aToolbar )
172 {
173 if( !m_unitSelectBox )
174 {
175 m_unitSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_UNIT_NUMBER,
176 wxEmptyString, wxDefaultPosition,
177 wxSize( LISTBOX_WIDTH, -1 ), 0,
178 nullptr, wxCB_READONLY );
179 }
180
181 aToolbar->Add( m_unitSelectBox );
182 };
183
184 auto bodyDisplayFactory =
185 [this]( ACTION_TOOLBAR* aToolbar )
186 {
188 {
189 m_bodyStyleSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_BODY_STYLE,
190 wxEmptyString, wxDefaultPosition,
191 wxSize( LISTBOX_WIDTH, -1 ), 0,
192 nullptr, wxCB_READONLY );
193 }
194
195 aToolbar->Add( m_bodyStyleSelectBox );
196 };
197
200}
201
static TOOL_ACTION toggleGrid
Definition actions.h:197
static TOOL_ACTION zoomRedraw
Definition actions.h:131
static TOOL_ACTION millimetersUnits
Definition actions.h:205
static TOOL_ACTION showLibraryTree
Definition actions.h:163
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:151
static TOOL_ACTION zoomOutCenter
Definition actions.h:135
static TOOL_ACTION showDatasheet
Definition actions.h:266
static TOOL_ACTION findAndReplace
Definition actions.h:117
static TOOL_ACTION milsUnits
Definition actions.h:204
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:156
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION inchesUnits
Definition actions.h:203
static TOOL_ACTION selectionTool
Definition actions.h:250
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:153
static TOOL_ACTION showProperties
Definition actions.h:265
static TOOL_ACTION zoomInCenter
Definition actions.h:134
static TOOL_ACTION toggleGridOverrides
Definition actions.h:198
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:152
static TOOL_ACTION find
Definition actions.h:116
static ACTION_TOOLBAR_CONTROL unitSelector
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.
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()
static TOOL_ACTION rotateCCW
static TOOL_ACTION newSymbol
static TOOL_ACTION mirrorV
static TOOL_ACTION checkSymbol
static TOOL_ACTION drawArc
Definition sch_actions.h:97
static TOOL_ACTION pinTable
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION drawRectangle
Definition sch_actions.h:95
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION drawBezier
Definition sch_actions.h:98
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 mirrorH
static TOOL_ACTION symbolProperties
static TOOL_ACTION placeSymbolText
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION addSymbolToSchematic
wxComboBox * m_unitSelectBox
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.
#define _(s)
@ ID_LIBEDIT_SELECT_UNIT_NUMBER
Definition eeschema_id.h:65
@ ID_LIBEDIT_SELECT_BODY_STYLE
Definition eeschema_id.h:66
@ 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