2011-12-16 08:32:23 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-04-02 13:18:19 +02:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-06-08 11:56:42 +02:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-07-19 19:56:05 -04:00
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-16 08:32:23 -05:00
|
|
|
*
|
2018-01-07 21:05:03 -07: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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2011-12-16 08:32:23 -05:00
|
|
|
*
|
2018-01-07 21:05:03 -07:00
|
|
|
* 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.
|
2011-12-16 08:32:23 -05:00
|
|
|
*
|
2018-01-07 21:05:03 -07:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-12-16 08:32:23 -05:00
|
|
|
*/
|
|
|
|
|
2019-05-14 20:21:10 +01:00
|
|
|
#include <tool/actions.h>
|
2018-01-29 21:58:58 +01:00
|
|
|
#include <footprint_edit_frame.h>
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <pcbnew_id.h>
|
2017-02-20 20:20:39 +08:00
|
|
|
#include <bitmaps.h>
|
2024-07-08 20:58:47 -07:00
|
|
|
#include <lset.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>
|
2019-05-15 23:49:48 +01:00
|
|
|
#include <tools/pcb_actions.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2019-11-03 17:14:21 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
2023-04-09 22:59:01 +01:00
|
|
|
#include <wx/choice.h>
|
|
|
|
#include <wx/wupdlock.h>
|
2022-01-17 11:55:55 +00:00
|
|
|
#include <advanced_config.h>
|
2021-07-19 19:56:05 -04:00
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
#include <toolbars_footprint_editor.h>
|
2021-03-27 21:49:38 +00:00
|
|
|
|
2025-02-26 03:22:49 +00:00
|
|
|
std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_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;
|
2021-12-04 23:52:00 +00:00
|
|
|
|
2024-09-25 21:41:32 +01:00
|
|
|
// clang-format off
|
2025-02-26 03:22:49 +00:00
|
|
|
switch( aToolbar )
|
2022-12-05 21:27:00 +03:00
|
|
|
{
|
2025-02-26 03:22:49 +00:00
|
|
|
// No Aux toolbar
|
|
|
|
case TOOLBAR_LOC::TOP_AUX:
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::LEFT:
|
|
|
|
config.AppendAction( ACTIONS::toggleGrid )
|
|
|
|
.AppendAction( ACTIONS::toggleGridOverrides )
|
|
|
|
.AppendAction( PCB_ACTIONS::togglePolarCoords )
|
|
|
|
.AppendAction( ACTIONS::inchesUnits )
|
|
|
|
.AppendAction( ACTIONS::milsUnits )
|
|
|
|
.AppendAction( ACTIONS::millimetersUnits )
|
|
|
|
.AppendAction( ACTIONS::toggleCursorStyle );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::toggleHV45Mode );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::padDisplayMode )
|
|
|
|
.AppendAction( PCB_ACTIONS::graphicsOutlines )
|
|
|
|
.AppendAction( PCB_ACTIONS::textOutlines )
|
|
|
|
.AppendAction( ACTIONS::highContrastMode );
|
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
|
|
|
|
config.AppendAction( ACTIONS::toggleBoundingBoxes );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::showLibraryTree )
|
|
|
|
.AppendAction( PCB_ACTIONS::showLayersManager )
|
|
|
|
.AppendAction( ACTIONS::showProperties );
|
|
|
|
|
|
|
|
/* TODO (ISM): Implement context menus
|
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
|
|
|
|
gridMenu->Add( ACTIONS::gridProperties );
|
|
|
|
gridMenu->Add( ACTIONS::gridOrigin );
|
|
|
|
m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::RIGHT:
|
2025-07-14 02:24:34 +02:00
|
|
|
config.AppendAction( ACTIONS::selectionTool )
|
|
|
|
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Lasso selection tools" ) )
|
|
|
|
.AddAction( ACTIONS::selectAutoLasso )
|
|
|
|
.AddAction( ACTIONS::selectInsideLasso )
|
|
|
|
.AddAction( ACTIONS::selectTouchingLasso )
|
|
|
|
.AddAction( ACTIONS::selectTouchingPath ) );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::placePad )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawRuleArea );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::drawLine )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawArc )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawRectangle )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawCircle )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawPolygon )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawBezier )
|
|
|
|
.AppendAction( PCB_ACTIONS::placeReferenceImage )
|
|
|
|
.AppendAction( PCB_ACTIONS::placeText )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawTextBox )
|
|
|
|
.AppendAction( PCB_ACTIONS::drawTable )
|
2025-02-27 02:51:29 +00:00
|
|
|
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
|
2025-02-26 03:22:49 +00:00
|
|
|
.AddAction( PCB_ACTIONS::drawOrthogonalDimension )
|
|
|
|
.AddAction( PCB_ACTIONS::drawAlignedDimension )
|
|
|
|
.AddAction( PCB_ACTIONS::drawCenterDimension )
|
|
|
|
.AddAction( PCB_ACTIONS::drawRadialDimension )
|
|
|
|
.AddAction( PCB_ACTIONS::drawLeader ) )
|
|
|
|
.AppendAction( ACTIONS::deleteTool );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::setAnchor )
|
|
|
|
.AppendAction( ACTIONS::gridSetOrigin )
|
|
|
|
.AppendAction( ACTIONS::measureTool );
|
|
|
|
|
|
|
|
/* TODO (ISM): Implement context menus
|
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
|
|
|
|
auto makeArcMenu = [&]()
|
|
|
|
{
|
|
|
|
std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
|
|
|
|
|
2025-05-02 23:17:30 +08:00
|
|
|
arcMenu->Add( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
|
|
|
|
arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
|
|
|
|
arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
return arcMenu;
|
|
|
|
};
|
|
|
|
|
|
|
|
m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOOLBAR_LOC::TOP_MAIN:
|
|
|
|
config.AppendAction( PCB_ACTIONS::newFootprint )
|
|
|
|
.AppendAction( PCB_ACTIONS::createFootprint )
|
|
|
|
.AppendAction( ACTIONS::save );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::print );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::undo )
|
|
|
|
.AppendAction( ACTIONS::redo );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::zoomRedraw )
|
|
|
|
.AppendAction( ACTIONS::zoomInCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomOutCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomFitScreen )
|
|
|
|
.AppendAction( ACTIONS::zoomTool );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::rotateCcw )
|
|
|
|
.AppendAction( PCB_ACTIONS::rotateCw )
|
|
|
|
.AppendAction( PCB_ACTIONS::mirrorH )
|
|
|
|
.AppendAction( PCB_ACTIONS::mirrorV )
|
2025-03-31 09:34:19 -04:00
|
|
|
.AppendAction( ACTIONS::group )
|
|
|
|
.AppendAction( ACTIONS::ungroup );
|
2025-02-26 03:22:49 +00:00
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::footprintProperties )
|
|
|
|
.AppendAction( PCB_ACTIONS::defaultPadProperties )
|
|
|
|
.AppendAction( ACTIONS::showDatasheet )
|
|
|
|
.AppendAction( PCB_ACTIONS::checkFootprint );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PCB_ACTIONS::loadFpFromBoard )
|
|
|
|
.AppendAction( PCB_ACTIONS::saveFpToBoard );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
|
|
|
|
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendControl( ACTION_TOOLBAR_CONTROLS::layerSelector );
|
|
|
|
break;
|
|
|
|
}
|
2025-02-20 02:53:15 +00:00
|
|
|
|
|
|
|
// clang-format on
|
|
|
|
return config;
|
2021-03-27 21:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-03 17:14:21 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
|
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
if( !m_SelLayerBox )
|
2019-11-03 17:14:21 +00:00
|
|
|
return;
|
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
|
|
|
|
m_SelLayerBox->Resync();
|
2019-11-03 17:14:21 +00:00
|
|
|
|
|
|
|
if( aForceResizeToolbar )
|
2021-04-02 21:33:31 +01:00
|
|
|
UpdateToolbarControlSizes();
|
2019-11-03 17:14:21 +00:00
|
|
|
}
|