2011-10-28 09:43:37 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2017-12-26 09:38:45 -05:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-28 09:43:37 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2022-01-17 11:55:55 +00:00
|
|
|
#include <advanced_config.h>
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <eeschema_id.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2020-05-23 00:11:04 +01:00
|
|
|
#include <sch_painter.h>
|
2023-07-26 18:32:06 -04:00
|
|
|
#include <symbol_editor_settings.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_library_manager.h>
|
2025-02-26 03:22:49 +00:00
|
|
|
#include <toolbars_symbol_editor.h>
|
2019-06-09 22:57:23 +01:00
|
|
|
#include <tool/action_toolbar.h>
|
2020-09-27 18:27:25 +01:00
|
|
|
#include <tool/tool_manager.h>
|
2025-03-12 14:41:25 +00:00
|
|
|
#include <tools/sch_actions.h>
|
|
|
|
#include <tools/sch_selection_tool.h>
|
2023-07-26 18:32:06 -04:00
|
|
|
#include <widgets/sch_properties_panel.h>
|
|
|
|
#include <widgets/sch_properties_panel.h>
|
|
|
|
#include <widgets/wx_aui_utils.h>
|
2025-07-31 08:27:51 +02:00
|
|
|
#include <wx/combobox.h>
|
2010-06-30 13:15:34 +02:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#ifdef __UNIX__
|
|
|
|
#define LISTBOX_WIDTH 140
|
|
|
|
#else
|
|
|
|
#define LISTBOX_WIDTH 120
|
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
std::optional<TOOLBAR_CONFIGURATION> SYMBOL_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
TOOLBAR_CONFIGURATION config;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2024-09-25 22:09:32 +01:00
|
|
|
// clang-format off
|
2025-02-26 03:22:49 +00:00
|
|
|
switch( aToolbar )
|
|
|
|
{
|
|
|
|
case TOOLBAR_LOC::TOP_AUX:
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::LEFT:
|
|
|
|
config.AppendAction( ACTIONS::toggleGrid )
|
|
|
|
.AppendAction( ACTIONS::toggleGridOverrides )
|
|
|
|
.AppendAction( ACTIONS::inchesUnits )
|
|
|
|
.AppendAction( ACTIONS::milsUnits )
|
|
|
|
.AppendAction( ACTIONS::millimetersUnits )
|
2025-08-22 18:19:28 -07:00
|
|
|
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
|
|
|
|
.AddAction( ACTIONS::cursorSmallCrosshairs )
|
|
|
|
.AddAction( ACTIONS::cursorFullCrosshairs )
|
|
|
|
.AddAction( ACTIONS::cursor45Crosshairs ) );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::showElectricalTypes )
|
|
|
|
.AppendAction( SCH_ACTIONS::showHiddenPins )
|
|
|
|
.AppendAction( SCH_ACTIONS::showHiddenFields );
|
|
|
|
// .AppendAction( SCH_ACTIONS::togglePinAltIcons );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
|
|
|
|
config.AppendAction( ACTIONS::toggleBoundingBoxes );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::showLibraryTree )
|
|
|
|
.AppendAction( ACTIONS::showProperties );
|
|
|
|
|
|
|
|
/* TODO: Implement context menus
|
|
|
|
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
|
|
|
|
gridMenu->Add( ACTIONS::gridProperties );
|
|
|
|
m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::RIGHT:
|
|
|
|
config.AppendAction( ACTIONS::selectionTool );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::placeSymbolPin )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeSymbolText )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawSymbolTextBox )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawRectangle )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawCircle )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawArc )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawBezier )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawSymbolLines )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawSymbolPolygon )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeSymbolAnchor )
|
2025-02-26 03:22:49 +00:00
|
|
|
.AppendAction( ACTIONS::deleteTool);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::TOP_MAIN:
|
2025-03-12 14:41:25 +00:00
|
|
|
config.AppendAction( SCH_ACTIONS::newSymbol );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
/* TODO (ISM): Handle visibility changes
|
|
|
|
if( !IsSymbolFromSchematic() )
|
|
|
|
config.AppendAction( ACTIONS::saveAll );
|
|
|
|
else
|
|
|
|
config.AppendAction( ACTIONS::save );
|
|
|
|
*/
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::undo )
|
|
|
|
.AppendAction( ACTIONS::redo );
|
|
|
|
|
2025-07-30 16:28:04 +01:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::find )
|
|
|
|
.AppendAction( ACTIONS::findAndReplace );
|
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::zoomRedraw )
|
|
|
|
.AppendAction( ACTIONS::zoomInCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomOutCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomFitScreen )
|
|
|
|
.AppendAction( ACTIONS::zoomTool );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::rotateCCW )
|
|
|
|
.AppendAction( SCH_ACTIONS::rotateCW )
|
|
|
|
.AppendAction( SCH_ACTIONS::mirrorV )
|
|
|
|
.AppendAction( SCH_ACTIONS::mirrorH );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::symbolProperties )
|
|
|
|
.AppendAction( SCH_ACTIONS::pinTable );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::showDatasheet )
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::checkSymbol );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::showDeMorganStandard )
|
|
|
|
.AppendAction( SCH_ACTIONS::showDeMorganAlternate );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendControl( ACTION_TOOLBAR_CONTROLS::unitSelector );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::toggleSyncedPinsMode );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::addSymbolToSchematic );
|
2025-02-26 03:22:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-27 18:27:25 +01:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format on
|
|
|
|
return config;
|
2011-02-23 09:20:01 -05:00
|
|
|
}
|
2023-07-26 18:32:06 -04:00
|
|
|
|
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::configureToolbars()
|
2023-07-26 18:32:06 -04:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
SCH_BASE_FRAME::configureToolbars();
|
|
|
|
|
2025-02-20 12:42:39 +00:00
|
|
|
auto unitDisplayFactory =
|
|
|
|
[this]( ACTION_TOOLBAR* aToolbar )
|
2025-02-20 02:53:15 +00:00
|
|
|
{
|
|
|
|
if( !m_unitSelectBox )
|
|
|
|
{
|
|
|
|
m_unitSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_UNIT_NUMBER,
|
|
|
|
wxEmptyString, wxDefaultPosition,
|
|
|
|
wxSize( LISTBOX_WIDTH, -1 ), 0,
|
|
|
|
nullptr, wxCB_READONLY );
|
|
|
|
}
|
|
|
|
|
|
|
|
aToolbar->Add( m_unitSelectBox );
|
|
|
|
};
|
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::unitSelector, unitDisplayFactory );
|
2023-07-26 18:32:06 -04:00
|
|
|
}
|
2025-02-26 03:22:49 +00:00
|
|
|
|