KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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, jaen-pierre.charras@gipsa-lab.inpg.com
5 * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
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
41#ifdef __UNIX__
42#define LISTBOX_WIDTH 140
43#else
44#define LISTBOX_WIDTH 120
45#endif
46
47
48std::optional<TOOLBAR_CONFIGURATION> SYMBOL_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()
68 .AppendAction( SCH_ACTIONS::showHiddenPins )
69 .AppendAction( SCH_ACTIONS::showHiddenFields );
70 // .AppendAction( SCH_ACTIONS::togglePinAltIcons );
71
72 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
74
75 config.AppendSeparator()
76 .AppendAction( ACTIONS::showLibraryTree )
77 .AppendAction( ACTIONS::showProperties );
78
79 /* TODO: Implement context menus
80 EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
81 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
82 gridMenu->Add( ACTIONS::gridProperties );
83 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
84 */
85 break;
86
87 case TOOLBAR_LOC::RIGHT:
88 config.AppendAction( ACTIONS::selectionTool );
89
90 config.AppendSeparator()
91 .AppendAction( SCH_ACTIONS::placeSymbolPin )
92 .AppendAction( SCH_ACTIONS::placeSymbolText )
93 .AppendAction( SCH_ACTIONS::drawSymbolTextBox )
94 .AppendAction( SCH_ACTIONS::drawRectangle )
95 .AppendAction( SCH_ACTIONS::drawCircle )
96 .AppendAction( SCH_ACTIONS::drawArc )
97 .AppendAction( SCH_ACTIONS::drawBezier )
98 .AppendAction( SCH_ACTIONS::drawSymbolLines )
99 .AppendAction( SCH_ACTIONS::drawSymbolPolygon )
100 .AppendAction( SCH_ACTIONS::placeSymbolAnchor )
101 .AppendAction( ACTIONS::deleteTool);
102 break;
103
104 case TOOLBAR_LOC::TOP_MAIN:
105 config.AppendAction( SCH_ACTIONS::newSymbol );
106
107/* TODO (ISM): Handle visibility changes
108 if( !IsSymbolFromSchematic() )
109 config.AppendAction( ACTIONS::saveAll );
110 else
111 config.AppendAction( ACTIONS::save );
112*/
113
114 config.AppendSeparator()
115 .AppendAction( ACTIONS::undo )
116 .AppendAction( ACTIONS::redo );
117
118 config.AppendSeparator()
119 .AppendAction( ACTIONS::zoomRedraw )
120 .AppendAction( ACTIONS::zoomInCenter )
121 .AppendAction( ACTIONS::zoomOutCenter )
122 .AppendAction( ACTIONS::zoomFitScreen )
123 .AppendAction( ACTIONS::zoomTool );
124
125 config.AppendSeparator()
126 .AppendAction( SCH_ACTIONS::rotateCCW )
127 .AppendAction( SCH_ACTIONS::rotateCW )
128 .AppendAction( SCH_ACTIONS::mirrorV )
129 .AppendAction( SCH_ACTIONS::mirrorH );
130
131 config.AppendSeparator()
132 .AppendAction( SCH_ACTIONS::symbolProperties )
133 .AppendAction( SCH_ACTIONS::pinTable );
134
135 config.AppendSeparator()
136 .AppendAction( ACTIONS::showDatasheet )
137 .AppendAction( SCH_ACTIONS::checkSymbol );
138
139 config.AppendSeparator()
140 .AppendAction( SCH_ACTIONS::showDeMorganStandard )
141 .AppendAction( SCH_ACTIONS::showDeMorganAlternate );
142
143 config.AppendSeparator()
145
146 config.AppendSeparator()
147 .AppendAction( SCH_ACTIONS::toggleSyncedPinsMode );
148
149 config.AppendSeparator()
150 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
151 break;
152 }
153
154 // clang-format on
155 return config;
156}
157
158
160{
162
163 auto unitDisplayFactory =
164 [this]( ACTION_TOOLBAR* aToolbar )
165 {
166 if( !m_unitSelectBox )
167 {
168 m_unitSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_UNIT_NUMBER,
169 wxEmptyString, wxDefaultPosition,
170 wxSize( LISTBOX_WIDTH, -1 ), 0,
171 nullptr, wxCB_READONLY );
172 }
173
174 aToolbar->Add( m_unitSelectBox );
175 };
176
178}
179
static TOOL_ACTION toggleGrid
Definition: actions.h:191
static TOOL_ACTION zoomRedraw
Definition: actions.h:124
static TOOL_ACTION millimetersUnits
Definition: actions.h:199
static TOOL_ACTION showLibraryTree
Definition: actions.h:154
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION showDatasheet
Definition: actions.h:221
static TOOL_ACTION milsUnits
Definition: actions.h:198
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:147
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 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 showProperties
Definition: actions.h:220
static TOOL_ACTION zoomInCenter
Definition: actions.h:127
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:192
static ACTION_TOOLBAR_CONTROL unitSelector
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
Definition: sch_actions.h:133
static TOOL_ACTION newSymbol
Definition: sch_actions.h:215
static TOOL_ACTION mirrorV
Definition: sch_actions.h:134
static TOOL_ACTION checkSymbol
Definition: sch_actions.h:173
static TOOL_ACTION showDeMorganAlternate
Definition: sch_actions.h:144
static TOOL_ACTION drawArc
Definition: sch_actions.h:109
static TOOL_ACTION pinTable
Definition: sch_actions.h:164
static TOOL_ACTION drawSymbolLines
Definition: sch_actions.h:123
static TOOL_ACTION placeSymbolPin
Definition: sch_actions.h:120
static TOOL_ACTION drawSymbolTextBox
Definition: sch_actions.h:122
static TOOL_ACTION drawRectangle
Definition: sch_actions.h:107
static TOOL_ACTION drawCircle
Definition: sch_actions.h:108
static TOOL_ACTION drawBezier
Definition: sch_actions.h:110
static TOOL_ACTION rotateCW
Definition: sch_actions.h:132
static TOOL_ACTION showElectricalTypes
Definition: sch_actions.h:264
static TOOL_ACTION drawSymbolPolygon
Definition: sch_actions.h:124
static TOOL_ACTION showHiddenFields
Definition: sch_actions.h:249
static TOOL_ACTION placeSymbolAnchor
Definition: sch_actions.h:125
static TOOL_ACTION showHiddenPins
Definition: sch_actions.h:248
static TOOL_ACTION mirrorH
Definition: sch_actions.h:135
static TOOL_ACTION symbolProperties
Definition: sch_actions.h:163
static TOOL_ACTION placeSymbolText
Definition: sch_actions.h:121
static TOOL_ACTION toggleSyncedPinsMode
Definition: sch_actions.h:258
static TOOL_ACTION showDeMorganStandard
Definition: sch_actions.h:143
static TOOL_ACTION addSymbolToSchematic
Definition: sch_actions.h:192
wxComboBox * m_unitSelectBox
void configureToolbars() override
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
@ ID_LIBEDIT_SELECT_UNIT_NUMBER
Definition: eeschema_id.h:60
#define LISTBOX_WIDTH