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 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
63 .AddAction( ACTIONS::millimetersUnits )
64 .AddAction( ACTIONS::inchesUnits )
65 .AddAction( ACTIONS::milsUnits ) )
66 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
69 .AddAction( ACTIONS::cursor45Crosshairs ) );
70
71 config.AppendSeparator()
73 .AppendAction( SCH_ACTIONS::showHiddenPins )
74 .AppendAction( SCH_ACTIONS::showHiddenFields );
75 // .AppendAction( SCH_ACTIONS::togglePinAltIcons );
76
77 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
79
80 config.AppendSeparator()
81 .AppendAction( ACTIONS::showLibraryTree )
82 .AppendAction( ACTIONS::showProperties );
83
84 /* TODO: Implement 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
93 config.AppendAction( ACTIONS::selectionTool );
94
95 config.AppendSeparator()
96 .AppendAction( SCH_ACTIONS::placeSymbolPin )
97 .AppendAction( SCH_ACTIONS::placeSymbolText )
98 .AppendAction( SCH_ACTIONS::drawSymbolTextBox )
99 .AppendAction( SCH_ACTIONS::drawRectangle )
100 .AppendAction( SCH_ACTIONS::drawCircle )
101 .AppendAction( SCH_ACTIONS::drawArc )
102 .AppendAction( SCH_ACTIONS::drawBezier )
103 .AppendAction( SCH_ACTIONS::drawSymbolLines )
104 .AppendAction( SCH_ACTIONS::drawSymbolPolygon )
105 .AppendAction( SCH_ACTIONS::placeSymbolAnchor )
106 .AppendAction( ACTIONS::deleteTool);
107 break;
108
110 config.AppendAction( SCH_ACTIONS::newSymbol );
111
112/* TODO (ISM): Handle visibility changes
113 if( !IsSymbolFromSchematic() )
114 config.AppendAction( ACTIONS::saveAll );
115 else
116 config.AppendAction( ACTIONS::save );
117*/
118
119 config.AppendSeparator()
120 .AppendAction( ACTIONS::undo )
121 .AppendAction( ACTIONS::redo );
122
123 config.AppendSeparator()
124 .AppendAction( ACTIONS::find )
125 .AppendAction( ACTIONS::findAndReplace );
126
127 config.AppendSeparator()
128 .AppendAction( ACTIONS::zoomRedraw )
129 .AppendAction( ACTIONS::zoomInCenter )
130 .AppendAction( ACTIONS::zoomOutCenter )
131 .AppendAction( ACTIONS::zoomFitScreen )
132 .AppendAction( ACTIONS::zoomTool );
133
134 config.AppendSeparator()
135 .AppendAction( SCH_ACTIONS::rotateCCW )
136 .AppendAction( SCH_ACTIONS::rotateCW )
137 .AppendAction( SCH_ACTIONS::mirrorV )
138 .AppendAction( SCH_ACTIONS::mirrorH );
139
140 config.AppendSeparator()
141 .AppendAction( SCH_ACTIONS::symbolProperties )
142 .AppendAction( SCH_ACTIONS::pinTable );
143
144 config.AppendSeparator()
145 .AppendAction( ACTIONS::showDatasheet )
146 .AppendAction( SCH_ACTIONS::checkSymbol );
147
148 config.AppendSeparator()
150
151 config.AppendSeparator()
153
154 config.AppendSeparator()
155 .AppendAction( SCH_ACTIONS::toggleSyncedPinsMode );
156
157 config.AppendSeparator()
158 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
159 break;
160 }
161
162 // clang-format on
163 return config;
164}
165
166
168{
170
171 auto unitDisplayFactory =
172 [this]( ACTION_TOOLBAR* aToolbar )
173 {
174 if( !m_unitSelectBox )
175 {
176 m_unitSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_UNIT_NUMBER,
177 wxEmptyString, wxDefaultPosition,
178 wxSize( LISTBOX_WIDTH, -1 ), 0,
179 nullptr, wxCB_READONLY );
180 }
181
182 aToolbar->Add( m_unitSelectBox );
183 };
184
185 auto bodyDisplayFactory =
186 [this]( ACTION_TOOLBAR* aToolbar )
187 {
189 {
190 m_bodyStyleSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_BODY_STYLE,
191 wxEmptyString, wxDefaultPosition,
192 wxSize( LISTBOX_WIDTH, -1 ), 0,
193 nullptr, wxCB_READONLY );
194 }
195
196 aToolbar->Add( m_bodyStyleSelectBox );
197 };
198
201}
202
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