2011-12-16 08:32:23 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-02-11 19:50:55 +01:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-03-16 08:38:36 -04: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.
|
2019-08-14 09:28:07 +01:00
|
|
|
* Copyright (C) 2019 CERN
|
2011-12-16 08:32:23 -05: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>
|
2024-01-20 18:35:29 -05:00
|
|
|
#include <api/api_plugin_manager.h>
|
2018-08-03 14:18:26 +02:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 11:49:51 +01:00
|
|
|
#include <sch_edit_frame.h>
|
2021-09-14 23:45:14 +01:00
|
|
|
#include <kiface_base.h>
|
2017-02-20 20:20:39 +08:00
|
|
|
#include <bitmaps.h>
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <eeschema_id.h>
|
2024-01-20 18:35:29 -05:00
|
|
|
#include <pgm_base.h>
|
2021-03-18 06:28:04 -07:00
|
|
|
#include <python_scripting.h>
|
2019-05-13 21:42:40 +01:00
|
|
|
#include <tool/tool_manager.h>
|
2019-05-14 20:21:10 +01:00
|
|
|
#include <tool/action_toolbar.h>
|
2025-03-12 14:41:25 +00:00
|
|
|
#include <tools/sch_actions.h>
|
|
|
|
#include <tools/sch_selection_tool.h>
|
2022-12-12 11:46:20 +00:00
|
|
|
#include <widgets/hierarchy_pane.h>
|
2022-06-02 21:56:17 +00:00
|
|
|
#include <widgets/wx_aui_utils.h>
|
2025-03-20 11:57:59 -04:00
|
|
|
#include <widgets/sch_design_block_pane.h>
|
2023-06-20 21:57:20 -04:00
|
|
|
#include <widgets/sch_properties_panel.h>
|
2023-05-14 21:35:39 -04:00
|
|
|
#include <widgets/sch_search_pane.h>
|
2025-02-26 03:22:49 +00:00
|
|
|
#include <toolbars_sch_editor.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
std::optional<TOOLBAR_CONFIGURATION> SCH_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
TOOLBAR_CONFIGURATION config;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2024-09-25 22:09:32 +01:00
|
|
|
// clang-format off
|
2025-02-26 03:22:49 +00:00
|
|
|
switch( aToolbar )
|
2023-05-14 21:35:39 -04:00
|
|
|
{
|
2025-02-26 03:22:49 +00:00
|
|
|
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 )
|
|
|
|
.AppendAction( ACTIONS::toggleCursorStyle );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::toggleHiddenPins );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::lineModeFree )
|
|
|
|
.AppendAction( SCH_ACTIONS::lineMode90 )
|
|
|
|
.AppendAction( SCH_ACTIONS::lineMode45 );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::toggleAnnotateAuto );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::showHierarchy )
|
2025-02-26 03:22:49 +00:00
|
|
|
.AppendAction( ACTIONS::showProperties );
|
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
|
|
|
|
config.AppendAction( ACTIONS::toggleBoundingBoxes );
|
|
|
|
|
|
|
|
/* TODO (ISM): Handle 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 )
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::highlightNetTool );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( SCH_ACTIONS::placeSymbol )
|
|
|
|
.AppendAction( SCH_ACTIONS::placePower )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawWire )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawBus )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeBusWireEntry )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeNoConnect )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeJunction )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeLabel )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeClassLabel )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawRuleArea )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeGlobalLabel )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeHierLabel )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawSheet )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeSheetPin )
|
|
|
|
.AppendAction( SCH_ACTIONS::syncAllSheetsPins );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( SCH_ACTIONS::placeSchematicText )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawTextBox )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawTable )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawRectangle )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawCircle )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawArc )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawBezier )
|
|
|
|
.AppendAction( SCH_ACTIONS::drawLines )
|
|
|
|
.AppendAction( SCH_ACTIONS::placeImage )
|
2025-02-26 03:22:49 +00:00
|
|
|
.AppendAction( ACTIONS::deleteTool );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::TOP_MAIN:
|
|
|
|
if( Kiface().IsSingle() ) // not when under a project mgr
|
|
|
|
{
|
|
|
|
config.AppendAction( ACTIONS::doNew );
|
|
|
|
config.AppendAction( ACTIONS::open );
|
|
|
|
}
|
|
|
|
|
|
|
|
config.AppendAction( ACTIONS::save );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::schematicSetup );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::pageSettings )
|
|
|
|
.AppendAction( ACTIONS::print )
|
|
|
|
.AppendAction( ACTIONS::plot );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::paste );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::undo )
|
|
|
|
.AppendAction( ACTIONS::redo );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::find )
|
|
|
|
.AppendAction( ACTIONS::findAndReplace );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::zoomRedraw )
|
|
|
|
.AppendAction( ACTIONS::zoomInCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomOutCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomFitScreen )
|
|
|
|
.AppendAction( ACTIONS::zoomFitObjects )
|
|
|
|
.AppendAction( ACTIONS::zoomTool );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::navigateBack )
|
|
|
|
.AppendAction( SCH_ACTIONS::navigateUp )
|
|
|
|
.AppendAction( SCH_ACTIONS::navigateForward );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::rotateCCW )
|
|
|
|
.AppendAction( SCH_ACTIONS::rotateCW )
|
|
|
|
.AppendAction( SCH_ACTIONS::mirrorV )
|
2025-04-16 11:31:56 +01:00
|
|
|
.AppendAction( SCH_ACTIONS::mirrorH )
|
|
|
|
.AppendAction( ACTIONS::group )
|
|
|
|
.AppendAction( ACTIONS::ungroup );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::showSymbolEditor )
|
|
|
|
.AppendAction( ACTIONS::showSymbolBrowser )
|
|
|
|
.AppendAction( ACTIONS::showFootprintEditor );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::annotate )
|
|
|
|
.AppendAction( SCH_ACTIONS::runERC )
|
|
|
|
.AppendAction( SCH_ACTIONS::showSimulator )
|
|
|
|
.AppendAction( SCH_ACTIONS::assignFootprints )
|
|
|
|
.AppendAction( SCH_ACTIONS::editSymbolFields )
|
|
|
|
.AppendAction( SCH_ACTIONS::generateBOM );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
2025-03-12 14:41:25 +00:00
|
|
|
.AppendAction( SCH_ACTIONS::showPcbNew );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
// Insert all the IPC plugins here on the toolbar
|
|
|
|
// TODO (ISM): Move this to individual actions for each script
|
|
|
|
config.AppendControl( ACTION_TOOLBAR_CONTROLS::ipcScripting );
|
|
|
|
|
|
|
|
break;
|
2023-05-14 21:35:39 -04:00
|
|
|
}
|
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format on
|
|
|
|
return config;
|
2022-06-02 21:56:17 +00:00
|
|
|
}
|
2024-02-21 11:35:09 -05:00
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
void SCH_EDIT_FRAME::configureToolbars()
|
2024-02-21 11:35:09 -05:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
SCH_BASE_FRAME::configureToolbars();
|
2024-02-21 11:35:09 -05:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// IPC/Scripting plugin control
|
|
|
|
// TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
|
|
|
|
// control
|
2025-02-20 12:42:39 +00:00
|
|
|
auto pluginControlFactory =
|
|
|
|
[this]( ACTION_TOOLBAR* aToolbar )
|
2024-02-21 11:35:09 -05:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
// Add scripting console and API plugins
|
|
|
|
bool scriptingAvailable = SCRIPTING::IsWxAvailable();
|
|
|
|
|
|
|
|
#ifdef KICAD_IPC_API
|
|
|
|
bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
|
|
|
|
!Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
|
|
|
|
#else
|
|
|
|
bool haveApiPlugins = false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( scriptingAvailable || haveApiPlugins )
|
|
|
|
{
|
|
|
|
aToolbar->AddScaledSeparator( aToolbar->GetParent() );
|
|
|
|
|
|
|
|
if( haveApiPlugins )
|
|
|
|
AddApiPluginTools( aToolbar );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::ipcScripting, pluginControlFactory );
|
2025-03-20 11:57:59 -04:00
|
|
|
}
|