2013-12-09 10:01:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-11-11 15:29:34 +00:00
|
|
|
* Copyright (C) 2013-2023 CERN
|
2024-01-16 15:23:12 +00:00
|
|
|
* Copyright (C) 2017-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-12-09 10:01:05 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
2015-03-03 10:55:23 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-12-09 10:01:05 +00: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
|
|
|
|
*/
|
|
|
|
|
2024-05-10 20:44:00 +00:00
|
|
|
#include <macros.h>
|
2021-03-31 20:13:08 +00:00
|
|
|
#include <advanced_config.h>
|
2015-02-18 00:10:20 +00:00
|
|
|
#include <limits>
|
2023-09-18 03:13:09 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2023-11-10 22:29:49 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2023-03-30 11:49:23 +00:00
|
|
|
#include <pcb_shape.h>
|
2022-09-22 14:05:06 +00:00
|
|
|
#include <pcb_group.h>
|
|
|
|
#include <pcb_target.h>
|
|
|
|
#include <pcb_textbox.h>
|
2024-02-03 13:43:41 +00:00
|
|
|
#include <pcb_table.h>
|
2023-10-06 17:04:00 +00:00
|
|
|
#include <pcb_generator.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
2015-02-18 00:10:20 +00:00
|
|
|
#include <kiway.h>
|
2016-04-02 12:52:29 +00:00
|
|
|
#include <array_creator.h>
|
2018-08-22 18:05:40 +00:00
|
|
|
#include <status_popup.h>
|
2018-11-13 13:30:56 +00:00
|
|
|
#include <tool/selection_conditions.h>
|
2013-12-09 10:01:05 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-08-13 12:29:18 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2019-08-13 12:29:18 +00:00
|
|
|
#include <tools/edit_tool.h>
|
2023-06-30 23:31:58 +00:00
|
|
|
#include <tools/item_modification_routine.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_picker_tool.h>
|
2023-08-05 15:43:10 +00:00
|
|
|
#include <tools/pcb_point_editor.h>
|
2019-08-13 12:29:18 +00:00
|
|
|
#include <tools/tool_event_utils.h>
|
2021-01-16 23:17:32 +00:00
|
|
|
#include <tools/pcb_grid_helper.h>
|
2020-06-27 11:57:40 +00:00
|
|
|
#include <tools/pad_tool.h>
|
2013-12-09 10:01:05 +00:00
|
|
|
#include <view/view_controls.h>
|
2020-11-06 18:00:10 +00:00
|
|
|
#include <connectivity/connectivity_algo.h>
|
2022-11-18 14:32:43 +00:00
|
|
|
#include <core/kicad_algo.h>
|
2023-10-17 07:27:59 +00:00
|
|
|
#include <fix_board_shape.h>
|
2017-02-20 18:10:20 +00:00
|
|
|
#include <bitmaps.h>
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
|
|
|
using namespace std::placeholders;
|
2017-09-17 17:49:06 +00:00
|
|
|
#include "kicad_clipboard.h"
|
2020-12-09 20:48:04 +00:00
|
|
|
#include <wx/hyperlink.h>
|
2015-07-02 14:10:07 +00:00
|
|
|
#include <router/router_tool.h>
|
2015-02-12 03:22:24 +00:00
|
|
|
#include <dialogs/dialog_move_exact.h>
|
2015-07-09 11:35:51 +00:00
|
|
|
#include <dialogs/dialog_track_via_properties.h>
|
2024-02-03 13:43:41 +00:00
|
|
|
#include <dialogs/dialog_tablecell_properties.h>
|
|
|
|
#include <dialogs/dialog_table_properties.h>
|
2020-10-20 21:23:05 +00:00
|
|
|
#include <dialogs/dialog_unit_entry.h>
|
2023-10-23 17:23:24 +00:00
|
|
|
#include <pcb_reference_image.h>
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2022-09-16 11:33:56 +00:00
|
|
|
const unsigned int EDIT_TOOL::COORDS_PADDING = pcbIUScale.mmToIU( 20 );
|
2018-04-25 22:32:05 +00:00
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
EDIT_TOOL::EDIT_TOOL() :
|
2020-12-09 20:48:04 +00:00
|
|
|
PCB_TOOL_BASE( "pcbnew.InteractiveEdit" ),
|
2021-07-19 23:56:05 +00:00
|
|
|
m_selectionTool( nullptr ),
|
2020-12-10 17:34:26 +00:00
|
|
|
m_dragging( false )
|
2013-12-09 10:01:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-08 12:09:20 +00:00
|
|
|
void EDIT_TOOL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
m_dragging = false;
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
|
2014-09-08 12:09:20 +00:00
|
|
|
}
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
|
2023-07-02 17:13:35 +00:00
|
|
|
static std::shared_ptr<CONDITIONAL_MENU> makePositioningToolsMenu( TOOL_INTERACTIVE* aTool )
|
2020-05-16 14:09:00 +00:00
|
|
|
{
|
2023-07-02 17:13:35 +00:00
|
|
|
auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
|
2020-05-16 14:09:00 +00:00
|
|
|
|
2023-07-02 17:13:35 +00:00
|
|
|
menu->SetIcon( BITMAPS::special_tools );
|
|
|
|
menu->SetTitle( _( "Positioning Tools" ) );
|
2023-06-30 19:21:29 +00:00
|
|
|
|
2023-07-02 17:13:35 +00:00
|
|
|
auto notMovingCondition = []( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
return aSelection.Empty() || !aSelection.Front()->IsMoving();
|
|
|
|
};
|
2020-05-16 14:09:00 +00:00
|
|
|
|
2023-07-02 17:13:35 +00:00
|
|
|
// clang-format off
|
|
|
|
menu->AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
|
|
|
menu->AddItem( PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
|
|
|
menu->AddItem( PCB_ACTIONS::copyWithReference, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
|
|
|
menu->AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
|
|
|
// clang-format on
|
|
|
|
return menu;
|
|
|
|
};
|
2020-05-16 14:09:00 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
|
2023-07-02 17:39:03 +00:00
|
|
|
static std::shared_ptr<CONDITIONAL_MENU> makeShapeModificationMenu( TOOL_INTERACTIVE* aTool )
|
|
|
|
{
|
|
|
|
auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
|
|
|
|
|
|
|
|
menu->SetTitle( _( "Shape Modification" ) );
|
|
|
|
|
2023-07-22 00:23:59 +00:00
|
|
|
static const std::vector<KICAD_T> filletChamferTypes = { PCB_SHAPE_LOCATE_POLY_T,
|
|
|
|
PCB_SHAPE_LOCATE_RECT_T,
|
|
|
|
PCB_SHAPE_LOCATE_SEGMENT_T };
|
2023-07-02 17:39:03 +00:00
|
|
|
|
2023-10-17 07:27:59 +00:00
|
|
|
static const std::vector<KICAD_T> healShapesTypes = { PCB_SHAPE_LOCATE_SEGMENT_T,
|
|
|
|
PCB_SHAPE_LOCATE_ARC_T,
|
|
|
|
PCB_SHAPE_LOCATE_BEZIER_T };
|
|
|
|
|
2023-07-22 00:23:59 +00:00
|
|
|
static const std::vector<KICAD_T> lineExtendTypes = { PCB_SHAPE_LOCATE_SEGMENT_T };
|
|
|
|
|
|
|
|
static const std::vector<KICAD_T> polygonBooleanTypes = { PCB_SHAPE_LOCATE_RECT_T,
|
|
|
|
PCB_SHAPE_LOCATE_POLY_T };
|
2023-07-02 17:39:03 +00:00
|
|
|
|
2024-04-30 00:47:34 +00:00
|
|
|
static const std::vector<KICAD_T> polygonSimplifyTypes = { PCB_SHAPE_LOCATE_POLY_T,
|
|
|
|
PCB_ZONE_T };
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
auto hasCornerCondition =
|
|
|
|
[aTool]( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
PCB_POINT_EDITOR *pt_tool = aTool->GetManager()->GetTool<PCB_POINT_EDITOR>();
|
|
|
|
|
|
|
|
return pt_tool && pt_tool->HasCorner();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto hasMidpointCondition =
|
|
|
|
[aTool]( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
PCB_POINT_EDITOR *pt_tool = aTool->GetManager()->GetTool<PCB_POINT_EDITOR>();
|
|
|
|
|
|
|
|
return pt_tool && pt_tool->HasMidpoint();
|
|
|
|
};
|
|
|
|
|
2023-07-02 17:39:03 +00:00
|
|
|
// clang-format off
|
2023-10-17 07:27:59 +00:00
|
|
|
menu->AddItem( PCB_ACTIONS::healShapes, SELECTION_CONDITIONS::HasTypes( healShapesTypes ) );
|
2024-04-30 00:47:34 +00:00
|
|
|
menu->AddItem( PCB_ACTIONS::simplifyPolygons, SELECTION_CONDITIONS::HasTypes( polygonSimplifyTypes ) );
|
2023-08-05 15:43:10 +00:00
|
|
|
menu->AddItem( PCB_ACTIONS::filletLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) );
|
|
|
|
menu->AddItem( PCB_ACTIONS::chamferLines, SELECTION_CONDITIONS::OnlyTypes( filletChamferTypes ) );
|
|
|
|
menu->AddItem( PCB_ACTIONS::extendLines, SELECTION_CONDITIONS::OnlyTypes( lineExtendTypes )
|
|
|
|
&& SELECTION_CONDITIONS::Count( 2 ) );
|
|
|
|
menu->AddItem( PCB_ACTIONS::pointEditorMoveCorner, hasCornerCondition );
|
|
|
|
menu->AddItem( PCB_ACTIONS::pointEditorMoveMidpoint, hasMidpointCondition );
|
2023-07-22 00:23:59 +00:00
|
|
|
|
2023-10-17 07:27:59 +00:00
|
|
|
menu->AddSeparator( SELECTION_CONDITIONS::OnlyTypes( polygonBooleanTypes )
|
|
|
|
&& SELECTION_CONDITIONS::MoreThan( 1 ) );
|
2023-07-22 00:23:59 +00:00
|
|
|
|
|
|
|
menu->AddItem( PCB_ACTIONS::mergePolygons, SELECTION_CONDITIONS::OnlyTypes( polygonBooleanTypes )
|
|
|
|
&& SELECTION_CONDITIONS::MoreThan( 1 ) );
|
|
|
|
menu->AddItem( PCB_ACTIONS::subtractPolygons, SELECTION_CONDITIONS::OnlyTypes( polygonBooleanTypes )
|
|
|
|
&& SELECTION_CONDITIONS::MoreThan( 1 ) );
|
|
|
|
menu->AddItem( PCB_ACTIONS::intersectPolygons, SELECTION_CONDITIONS::OnlyTypes( polygonBooleanTypes )
|
|
|
|
&& SELECTION_CONDITIONS::MoreThan( 1 ) );
|
2023-07-02 17:39:03 +00:00
|
|
|
// clang-format on
|
2023-08-05 15:43:10 +00:00
|
|
|
|
2023-07-02 17:39:03 +00:00
|
|
|
return menu;
|
|
|
|
};
|
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
bool EDIT_TOOL::Init()
|
|
|
|
{
|
|
|
|
// Find the selection tool, so they can cooperate
|
2020-12-16 13:31:32 +00:00
|
|
|
m_selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2023-07-02 17:13:35 +00:00
|
|
|
std::shared_ptr<CONDITIONAL_MENU> positioningToolsSubMenu = makePositioningToolsMenu( this );
|
2022-09-03 18:29:02 +00:00
|
|
|
m_selectionTool->GetToolMenu().RegisterSubMenu( positioningToolsSubMenu );
|
|
|
|
|
2023-07-02 17:39:03 +00:00
|
|
|
std::shared_ptr<CONDITIONAL_MENU> shapeModificationSubMenu = makeShapeModificationMenu( this );
|
|
|
|
m_selectionTool->GetToolMenu().RegisterSubMenu( shapeModificationSubMenu );
|
|
|
|
|
2024-01-18 00:21:06 +00:00
|
|
|
auto positioningToolsCondition =
|
|
|
|
[&]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
std::shared_ptr<CONDITIONAL_MENU> subMenu = makePositioningToolsMenu( this );
|
|
|
|
subMenu->Evaluate( aSel );
|
|
|
|
return subMenu->GetMenuItemCount() > 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto shapeModificationCondition =
|
|
|
|
[&]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
std::shared_ptr<CONDITIONAL_MENU> subMenu = makeShapeModificationMenu( this );
|
|
|
|
subMenu->Evaluate( aSel );
|
|
|
|
return subMenu->GetMenuItemCount() > 0;
|
|
|
|
};
|
|
|
|
|
2021-04-11 13:18:08 +00:00
|
|
|
auto propertiesCondition =
|
|
|
|
[&]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
if( aSel.GetSize() == 0 )
|
|
|
|
{
|
|
|
|
if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) )
|
|
|
|
{
|
2022-09-04 20:04:17 +00:00
|
|
|
DS_PROXY_VIEW_ITEM* ds = canvas()->GetDrawingSheet();
|
2021-04-11 13:18:08 +00:00
|
|
|
VECTOR2D cursor = getViewControls()->GetCursorPosition( false );
|
|
|
|
|
2022-01-02 02:06:40 +00:00
|
|
|
if( ds && ds->HitTestDrawingSheetItems( getView(), cursor ) )
|
2021-04-11 13:18:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aSel.GetSize() == 1 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : aSel )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
if( !dynamic_cast<PCB_TRACK*>( item ) )
|
2021-04-11 13:18:08 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
auto inFootprintEditor =
|
2020-12-02 00:10:56 +00:00
|
|
|
[ this ]( const SELECTION& aSelection )
|
2020-04-20 23:24:29 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
return m_isFootprintEditor;
|
2020-04-20 23:24:29 +00:00
|
|
|
};
|
2017-01-23 06:47:39 +00:00
|
|
|
|
2022-12-27 19:18:13 +00:00
|
|
|
auto canMirror =
|
|
|
|
[ this ]( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
if( !m_isFootprintEditor
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_PAD_T } )( aSelection ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-05-10 20:44:00 +00:00
|
|
|
if( SELECTION_CONDITIONS::HasTypes( { PCB_GROUP_T } )( aSelection ) )
|
|
|
|
return true;
|
|
|
|
|
2022-12-27 19:18:13 +00:00
|
|
|
return SELECTION_CONDITIONS::HasTypes( EDIT_TOOL::MirrorableItems )( aSelection );
|
|
|
|
};
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } )
|
2020-11-13 12:21:02 +00:00
|
|
|
&& SELECTION_CONDITIONS::Count( 1 );
|
2017-01-31 08:03:07 +00:00
|
|
|
|
2023-09-11 20:16:47 +00:00
|
|
|
auto multipleFootprintsCondition =
|
|
|
|
[]( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
bool foundFirst = false;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : aSelection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
if( foundFirst )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
foundFirst = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
2023-09-07 16:50:58 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
auto noActiveToolCondition =
|
2020-12-02 00:10:56 +00:00
|
|
|
[ this ]( const SELECTION& aSelection )
|
2020-04-20 23:24:29 +00:00
|
|
|
{
|
|
|
|
return frame()->ToolStackIsEmpty();
|
|
|
|
};
|
2018-02-11 01:15:16 +00:00
|
|
|
|
2020-07-16 01:22:29 +00:00
|
|
|
auto notMovingCondition =
|
2023-07-01 10:51:37 +00:00
|
|
|
[]( const SELECTION& aSelection )
|
2020-07-16 01:22:29 +00:00
|
|
|
{
|
2023-06-30 19:21:29 +00:00
|
|
|
return aSelection.Empty() || !aSelection.Front()->IsMoving();
|
2020-07-16 01:22:29 +00:00
|
|
|
};
|
|
|
|
|
2020-08-19 22:15:44 +00:00
|
|
|
auto noItemsCondition =
|
2020-12-02 00:10:56 +00:00
|
|
|
[ this ]( const SELECTION& aSelections ) -> bool
|
2020-08-19 22:15:44 +00:00
|
|
|
{
|
|
|
|
return frame()->GetBoard() && !frame()->GetBoard()->IsEmpty();
|
|
|
|
};
|
|
|
|
|
2022-11-28 19:14:22 +00:00
|
|
|
auto isSkippable =
|
|
|
|
[ this ]( const SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
return frame()->IsCurrentTool( PCB_ACTIONS::moveIndividually );
|
|
|
|
};
|
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
static std::vector<KICAD_T> connectedTypes = { PCB_TRACE_T,
|
|
|
|
PCB_ARC_T,
|
|
|
|
PCB_VIA_T,
|
|
|
|
PCB_PAD_T,
|
|
|
|
PCB_ZONE_T };
|
|
|
|
|
2022-09-13 18:04:57 +00:00
|
|
|
static std::vector<KICAD_T> unroutableTypes = { PCB_TRACE_T,
|
|
|
|
PCB_ARC_T,
|
|
|
|
PCB_VIA_T,
|
|
|
|
PCB_PAD_T,
|
|
|
|
PCB_FOOTPRINT_T };
|
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
static std::vector<KICAD_T> trackTypes = { PCB_TRACE_T,
|
|
|
|
PCB_ARC_T,
|
|
|
|
PCB_VIA_T };
|
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
// Add context menu entries that are displayed when selection tool is active
|
2017-01-12 10:07:52 +00:00
|
|
|
CONDITIONAL_MENU& menu = m_selectionTool->GetToolMenu().GetMenu();
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2023-07-02 17:39:03 +00:00
|
|
|
// clang-format off
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty
|
|
|
|
&& notMovingCondition );
|
2022-09-13 18:04:57 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::unrouteSelected, SELECTION_CONDITIONS::NotEmpty
|
2022-11-28 14:39:40 +00:00
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( unroutableTypes )
|
2022-12-21 12:11:51 +00:00
|
|
|
&& notMovingCondition
|
|
|
|
&& !inFootprintEditor );
|
2022-11-28 14:39:40 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::moveIndividually, SELECTION_CONDITIONS::MoreThan( 1 )
|
2022-09-15 14:19:47 +00:00
|
|
|
&& notMovingCondition );
|
2022-11-28 19:14:22 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::skip, isSkippable );
|
2021-11-27 14:34:23 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::breakTrack, SELECTION_CONDITIONS::Count( 1 )
|
2022-09-03 18:29:02 +00:00
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( trackTypes ) );
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::Count( 1 )
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems ) );
|
|
|
|
menu.AddItem( PCB_ACTIONS::dragFreeAngle, SELECTION_CONDITIONS::Count( 1 )
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::DraggableItems )
|
2022-08-20 09:27:35 +00:00
|
|
|
&& !SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } ) );
|
2022-09-03 18:29:02 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::filletTracks, SELECTION_CONDITIONS::OnlyTypes( trackTypes ) );
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty );
|
|
|
|
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
|
|
|
|
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
2022-12-27 19:18:13 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::mirrorH, canMirror );
|
|
|
|
menu.AddItem( PCB_ACTIONS::mirrorV, canMirror );
|
2022-08-29 19:07:16 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::swap, SELECTION_CONDITIONS::MoreThan( 1 ) );
|
2022-11-28 14:39:40 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::packAndMoveFootprints, SELECTION_CONDITIONS::MoreThan( 1 )
|
2022-09-27 13:30:17 +00:00
|
|
|
&& SELECTION_CONDITIONS::HasType( PCB_FOOTPRINT_T ) );
|
2021-04-11 13:18:08 +00:00
|
|
|
|
|
|
|
menu.AddItem( PCB_ACTIONS::properties, propertiesCondition );
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2022-12-26 19:32:56 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::assignNetClass, SELECTION_CONDITIONS::OnlyTypes( connectedTypes )
|
|
|
|
&& !inFootprintEditor );
|
2022-09-03 18:29:02 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::inspectClearance, SELECTION_CONDITIONS::Count( 2 ) );
|
|
|
|
|
2021-01-17 18:19:02 +00:00
|
|
|
// Footprint actions
|
|
|
|
menu.AddSeparator();
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::editFpInFpEditor, singleFootprintCondition );
|
|
|
|
menu.AddItem( PCB_ACTIONS::updateFootprint, singleFootprintCondition );
|
2023-09-07 16:50:58 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::updateFootprints, multipleFootprintsCondition );
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::changeFootprint, singleFootprintCondition );
|
2023-09-07 16:50:58 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::changeFootprints, multipleFootprintsCondition );
|
2020-05-16 14:09:00 +00:00
|
|
|
|
2023-07-02 17:39:03 +00:00
|
|
|
// Add the submenu for the special tools: modfiers and positioning tools
|
2022-09-03 18:29:02 +00:00
|
|
|
menu.AddSeparator( 100 );
|
2024-01-18 00:21:06 +00:00
|
|
|
menu.AddMenu( shapeModificationSubMenu.get(), shapeModificationCondition, 100 );
|
|
|
|
menu.AddMenu( positioningToolsSubMenu.get(), positioningToolsCondition, 100 );
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2020-09-10 19:58:05 +00:00
|
|
|
menu.AddSeparator( 150 );
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty, 150 );
|
|
|
|
menu.AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty, 150 );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2018-02-11 01:15:16 +00:00
|
|
|
// Selection tool handles the context menu for some other tools, such as the Picker.
|
|
|
|
// Don't add things like Paste when another tool is active.
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( ACTIONS::paste, noActiveToolCondition, 150 );
|
2021-08-18 15:43:10 +00:00
|
|
|
menu.AddItem( ACTIONS::pasteSpecial, noActiveToolCondition && !inFootprintEditor, 150 );
|
2021-04-11 13:18:08 +00:00
|
|
|
menu.AddItem( ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty, 150 );
|
|
|
|
menu.AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty, 150 );
|
2020-08-19 22:15:44 +00:00
|
|
|
|
2020-09-10 19:58:05 +00:00
|
|
|
menu.AddSeparator( 150 );
|
2023-07-02 17:39:03 +00:00
|
|
|
menu.AddItem( ACTIONS::selectAll, noItemsCondition, 150 );
|
2023-09-06 23:44:39 +00:00
|
|
|
menu.AddItem( ACTIONS::unselectAll, noItemsCondition, 150 );
|
2023-07-02 17:39:03 +00:00
|
|
|
// clang-format on
|
2015-02-18 00:10:20 +00:00
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-13 12:29:18 +00:00
|
|
|
int EDIT_TOOL::GetAndPlace( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-05-08 19:08:18 +00:00
|
|
|
// GetAndPlace makes sense only in board editor, although it is also called
|
|
|
|
// in fpeditor, that shares the same EDIT_TOOL list
|
|
|
|
if( !getEditFrame<PCB_BASE_FRAME>()->IsType( FRAME_PCB_EDITOR ) )
|
|
|
|
return 0;
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
FOOTPRINT* fp = getEditFrame<PCB_BASE_FRAME>()->GetFootprintFromBoardByReference();
|
2019-08-13 12:29:18 +00:00
|
|
|
|
2020-11-07 17:35:24 +00:00
|
|
|
if( fp )
|
2019-08-13 12:29:18 +00:00
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
|
|
|
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, fp );
|
2019-08-13 12:29:18 +00:00
|
|
|
|
2020-11-07 17:35:24 +00:00
|
|
|
selectionTool->GetSelection().SetReferencePoint( fp->GetPosition() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::move );
|
2019-08-13 12:29:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
bool EDIT_TOOL::invokeInlineRouter( int aDragMode )
|
2015-02-18 00:10:20 +00:00
|
|
|
{
|
2019-08-13 12:29:18 +00:00
|
|
|
ROUTER_TOOL* theRouter = m_toolMgr->GetTool<ROUTER_TOOL>();
|
2017-08-29 23:15:23 +00:00
|
|
|
|
|
|
|
if( !theRouter )
|
|
|
|
return false;
|
|
|
|
|
2020-08-04 13:31:31 +00:00
|
|
|
// don't allow switch from moving to dragging
|
|
|
|
if( m_dragging )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// make sure we don't accidentally invoke inline routing mode while the router is already
|
|
|
|
// active!
|
2018-01-05 23:44:37 +00:00
|
|
|
if( theRouter->IsToolActive() )
|
2017-08-29 23:15:23 +00:00
|
|
|
return false;
|
|
|
|
|
2021-01-27 19:55:42 +00:00
|
|
|
if( theRouter->CanInlineDrag( aDragMode ) )
|
2015-02-18 00:10:20 +00:00
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::routerInlineDrag, aDragMode );
|
2015-02-18 00:10:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2017-08-24 14:31:23 +00:00
|
|
|
|
2020-08-05 15:01:10 +00:00
|
|
|
bool EDIT_TOOL::isRouterActive() const
|
|
|
|
{
|
|
|
|
ROUTER_TOOL* router = m_toolMgr->GetTool<ROUTER_TOOL>();
|
|
|
|
|
2022-08-30 17:28:56 +00:00
|
|
|
return router && router->RoutingInProgress();
|
2017-08-22 14:44:47 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 14:31:23 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-10-28 09:51:04 +00:00
|
|
|
if( !m_toolMgr->GetTool<ROUTER_TOOL>() )
|
2023-09-03 12:59:22 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
2021-10-28 09:51:04 +00:00
|
|
|
return false; // don't drag when no router tool (i.e. fp editor)
|
2023-09-03 12:59:22 +00:00
|
|
|
}
|
2021-10-28 09:51:04 +00:00
|
|
|
|
2021-10-23 17:53:10 +00:00
|
|
|
if( m_toolMgr->GetTool<ROUTER_TOOL>()->IsToolActive() )
|
2023-09-03 12:59:22 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
2021-10-23 17:53:10 +00:00
|
|
|
return false; // don't drag when router is already active
|
2023-09-03 12:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_dragging )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return false; // don't do a router drag when already in an EDIT_TOOL drag
|
|
|
|
}
|
2021-10-23 17:53:10 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
int mode = PNS::DM_ANY;
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::dragFreeAngle ) )
|
|
|
|
mode |= PNS::DM_FREE_ANGLE;
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-12-10 01:33:24 +00:00
|
|
|
{
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
2021-04-28 22:53:31 +00:00
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2022-02-26 22:53:00 +00:00
|
|
|
|
2022-09-09 09:55:35 +00:00
|
|
|
std::vector<PCB_TRACK*> tracks;
|
|
|
|
std::vector<PCB_TRACK*> vias;
|
2024-05-16 09:27:19 +00:00
|
|
|
std::vector<FOOTPRINT*> footprints;
|
2022-09-08 12:09:05 +00:00
|
|
|
|
|
|
|
for( EDA_ITEM* item : aCollector )
|
2022-02-26 22:53:00 +00:00
|
|
|
{
|
2022-09-16 21:48:33 +00:00
|
|
|
if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
|
2022-09-09 09:55:35 +00:00
|
|
|
{
|
2022-09-16 21:48:33 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
vias.push_back( track );
|
|
|
|
else
|
|
|
|
tracks.push_back( track );
|
2022-09-09 09:55:35 +00:00
|
|
|
}
|
2024-05-16 09:27:19 +00:00
|
|
|
else if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item ) )
|
|
|
|
{
|
|
|
|
footprints.push_back( footprint );
|
|
|
|
}
|
2022-09-08 12:09:05 +00:00
|
|
|
}
|
|
|
|
|
2024-05-16 09:27:19 +00:00
|
|
|
if( footprints.size() == (unsigned) aCollector.GetCount() )
|
2022-09-16 21:48:33 +00:00
|
|
|
{
|
2024-05-16 09:27:19 +00:00
|
|
|
// We can drag multiple footprints; no need to whittle down selection.
|
2022-09-16 21:48:33 +00:00
|
|
|
}
|
2024-05-16 09:27:19 +00:00
|
|
|
else if( tracks.size() || vias.size() )
|
2022-09-16 21:48:33 +00:00
|
|
|
{
|
2024-05-16 09:27:19 +00:00
|
|
|
/*
|
|
|
|
* First trim down selection to active layer, tracks vs zones, etc.
|
|
|
|
*/
|
|
|
|
if( aCollector.GetCount() > 1 )
|
|
|
|
sTool->GuessSelectionCandidates( aCollector, aPt );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have a knee between two tracks, or a via attached to two tracks,
|
|
|
|
* then drop the selection to a single item. We don't want a selection
|
|
|
|
* disambiguation menu when it doesn't matter which items is picked.
|
|
|
|
*/
|
|
|
|
auto connected = []( PCB_TRACK* track, const VECTOR2I& pt )
|
|
|
|
{
|
|
|
|
return track->GetStart() == pt || track->GetEnd() == pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
if( tracks.size() == 2 && vias.size() == 0 )
|
|
|
|
{
|
|
|
|
if( connected( tracks[0], tracks[1]->GetStart() )
|
|
|
|
|| connected( tracks[0], tracks[1]->GetEnd() ) )
|
|
|
|
{
|
|
|
|
aCollector.Remove( tracks[1] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( tracks.size() == 2 && vias.size() == 1 )
|
2022-09-08 12:09:05 +00:00
|
|
|
{
|
2024-05-16 09:27:19 +00:00
|
|
|
if( connected( tracks[0], vias[0]->GetPosition() )
|
|
|
|
&& connected( tracks[1], vias[0]->GetPosition() ) )
|
|
|
|
{
|
|
|
|
aCollector.Remove( tracks[0] );
|
|
|
|
aCollector.Remove( tracks[1] );
|
|
|
|
}
|
2022-09-08 12:09:05 +00:00
|
|
|
}
|
2022-02-26 22:53:00 +00:00
|
|
|
}
|
2020-12-10 01:33:24 +00:00
|
|
|
},
|
2021-04-28 22:53:31 +00:00
|
|
|
true /* prompt user regarding locked items */ );
|
2020-10-30 17:40:07 +00:00
|
|
|
|
2020-12-10 01:33:24 +00:00
|
|
|
if( selection.Empty() )
|
2020-10-30 17:40:07 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-01-03 01:21:20 +00:00
|
|
|
if( selection.Size() == 1 && selection.Front()->Type() == PCB_ARC_T )
|
|
|
|
{
|
|
|
|
// TODO: This really should be done in PNS to ensure DRC is maintained, but for now
|
|
|
|
// it allows interactive editing of an arc track
|
|
|
|
return DragArcTrack( aEvent );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
invokeInlineRouter( mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->GetSelection();
|
|
|
|
|
|
|
|
if( selection.Size() != 1 || selection.Front()->Type() != PCB_ARC_T )
|
|
|
|
return 0;
|
|
|
|
|
2022-02-27 11:54:03 +00:00
|
|
|
PCB_ARC* theArc = static_cast<PCB_ARC*>( selection.Front() );
|
|
|
|
EDA_ANGLE maxTangentDeviation( ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation, DEGREES_T );
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2022-02-27 11:54:03 +00:00
|
|
|
if( theArc->GetAngle() + maxTangentDeviation >= ANGLE_180 )
|
2021-03-31 20:13:08 +00:00
|
|
|
{
|
2023-11-25 20:13:52 +00:00
|
|
|
wxString msg = wxString::Format( _( "Unable to resize arc tracks of %s or greater." ),
|
|
|
|
EDA_UNIT_UTILS::UI::MessageTextFromValue( ANGLE_180 - maxTangentDeviation ) );
|
2022-02-27 11:54:03 +00:00
|
|
|
frame()->ShowInfoBarError( msg );
|
|
|
|
|
2021-03-31 20:13:08 +00:00
|
|
|
return 0; // don't bother with > 180 degree arcs
|
|
|
|
}
|
2021-01-03 01:21:20 +00:00
|
|
|
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
|
|
|
2021-09-13 12:23:10 +00:00
|
|
|
Activate();
|
|
|
|
// Must be done after Activate() so that it gets set into the correct context
|
2021-01-03 01:21:20 +00:00
|
|
|
controls->ShowCursor( true );
|
|
|
|
controls->SetAutoPan( true );
|
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
bool restore_state = false;
|
2023-06-27 15:52:50 +00:00
|
|
|
|
|
|
|
commit.Modify( theArc );
|
|
|
|
|
2021-01-03 01:21:20 +00:00
|
|
|
VECTOR2I arcCenter = theArc->GetCenter();
|
2021-01-10 13:04:21 +00:00
|
|
|
SEG tanStart = SEG( arcCenter, theArc->GetStart() ).PerpendicularSeg( theArc->GetStart() );
|
|
|
|
SEG tanEnd = SEG( arcCenter, theArc->GetEnd() ).PerpendicularSeg( theArc->GetEnd() );
|
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
//Ensure the tangent segments are in the correct orientation
|
2022-08-30 20:58:43 +00:00
|
|
|
OPT_VECTOR2I tanIntersect = tanStart.IntersectLines( tanEnd );
|
|
|
|
|
|
|
|
if( !tanIntersect )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
tanStart.A = *tanIntersect;
|
2021-01-22 16:41:47 +00:00
|
|
|
tanStart.B = theArc->GetStart();
|
2022-08-30 20:58:43 +00:00
|
|
|
tanEnd.A = *tanIntersect;
|
2021-01-22 16:41:47 +00:00
|
|
|
tanEnd.B = theArc->GetEnd();
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2023-11-25 19:49:12 +00:00
|
|
|
std::set<PCB_TRACK*> addedTracks;
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
auto getUniqueTrackAtAnchorCollinear =
|
|
|
|
[&]( const VECTOR2I& aAnchor, const SEG& aCollinearSeg ) -> PCB_TRACK*
|
|
|
|
{
|
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
// Allow items at a distance within the width of the arc track
|
|
|
|
int allowedDeviation = theArc->GetWidth();
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
for( int i = 0; i < 3; i++ )
|
|
|
|
{
|
|
|
|
itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor,
|
|
|
|
{ PCB_PAD_T, PCB_VIA_T,
|
|
|
|
PCB_TRACE_T, PCB_ARC_T },
|
|
|
|
allowedDeviation );
|
|
|
|
allowedDeviation /= 2;
|
|
|
|
|
|
|
|
if( itemsOnAnchor.size() == 1 )
|
|
|
|
break;
|
|
|
|
}
|
2023-06-27 15:52:50 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
PCB_TRACK* track = nullptr;
|
2022-02-27 11:54:03 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() == PCB_TRACE_T )
|
|
|
|
{
|
|
|
|
track = static_cast<PCB_TRACK*>( itemsOnAnchor.front() );
|
|
|
|
commit.Modify( track );
|
2021-01-22 16:41:47 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
SEG trackSeg( track->GetStart(), track->GetEnd() );
|
2021-01-10 13:04:21 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
// Allow deviations in colinearity as defined in ADVANCED_CFG
|
|
|
|
if( trackSeg.Angle( aCollinearSeg ) > maxTangentDeviation )
|
|
|
|
track = nullptr;
|
|
|
|
}
|
2023-11-25 19:49:12 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
if( !track )
|
|
|
|
{
|
|
|
|
track = new PCB_TRACK( theArc->GetParent() );
|
|
|
|
track->SetStart( aAnchor );
|
|
|
|
track->SetEnd( aAnchor );
|
|
|
|
track->SetNet( theArc->GetNet() );
|
|
|
|
track->SetLayer( theArc->GetLayer() );
|
|
|
|
track->SetWidth( theArc->GetWidth() );
|
|
|
|
track->SetLocked( theArc->IsLocked() );
|
|
|
|
track->SetFlags( IS_NEW );
|
|
|
|
getView()->Add( track );
|
|
|
|
addedTracks.insert( track );
|
|
|
|
}
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
return track;
|
|
|
|
};
|
2023-11-25 19:49:12 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->GetStart(), tanStart);
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->GetEnd(), tanEnd );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-03-31 20:13:08 +00:00
|
|
|
if( trackOnStart->GetLength() != 0 )
|
2021-01-03 01:21:20 +00:00
|
|
|
{
|
|
|
|
tanStart.A = trackOnStart->GetStart();
|
|
|
|
tanStart.B = trackOnStart->GetEnd();
|
|
|
|
}
|
|
|
|
|
2021-03-31 20:13:08 +00:00
|
|
|
if( trackOnEnd->GetLength() != 0 )
|
2021-01-03 01:21:20 +00:00
|
|
|
{
|
|
|
|
tanEnd.A = trackOnEnd->GetStart();
|
|
|
|
tanEnd.B = trackOnEnd->GetEnd();
|
|
|
|
}
|
|
|
|
|
2021-03-31 20:13:08 +00:00
|
|
|
// Recalculate intersection point
|
2022-08-30 20:58:43 +00:00
|
|
|
if( tanIntersect = tanStart.IntersectLines( tanEnd ); !tanIntersect )
|
|
|
|
return 0;
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
auto isTrackStartClosestToArcStart =
|
|
|
|
[&]( PCB_TRACK* aTrack ) -> bool
|
|
|
|
{
|
|
|
|
double trackStartToArcStart = GetLineLength( aTrack->GetStart(), theArc->GetStart() );
|
|
|
|
double trackEndToArcStart = GetLineLength( aTrack->GetEnd(), theArc->GetStart() );
|
2021-06-12 10:39:28 +00:00
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
return trackStartToArcStart < trackEndToArcStart;
|
|
|
|
};
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart );
|
|
|
|
bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
|
|
|
// Calculate constraints
|
2021-01-22 16:41:47 +00:00
|
|
|
//======================
|
|
|
|
// maxTanCircle is the circle with maximum radius that is tangent to the two adjacent straight
|
|
|
|
// tracks and whose tangent points are constrained within the original tracks and their
|
|
|
|
// projected intersection points.
|
|
|
|
//
|
|
|
|
// The cursor will be constrained first within the isosceles triangle formed by the segments
|
2021-07-19 23:56:05 +00:00
|
|
|
// cSegTanStart, cSegTanEnd and cSegChord. After that it will be constrained to be outside
|
2021-01-22 16:41:47 +00:00
|
|
|
// maxTanCircle.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// ____________ <-cSegTanStart
|
|
|
|
// / * . ' *
|
|
|
|
// cSegTanEnd-> / * . ' *
|
|
|
|
// /* . ' <-cSegChord *
|
|
|
|
// /. '
|
|
|
|
// /* *
|
|
|
|
//
|
|
|
|
// * c * <-maxTanCircle
|
|
|
|
//
|
|
|
|
// * *
|
|
|
|
//
|
|
|
|
// * *
|
|
|
|
// * *
|
|
|
|
// * *
|
|
|
|
//
|
|
|
|
|
2023-11-25 20:13:52 +00:00
|
|
|
auto getFurthestPointToTanInterstect =
|
|
|
|
[&]( VECTOR2I& aPointA, VECTOR2I& aPointB ) -> VECTOR2I
|
|
|
|
{
|
|
|
|
if( ( aPointA - *tanIntersect ).EuclideanNorm()
|
|
|
|
> ( aPointB - *tanIntersect ).EuclideanNorm() )
|
|
|
|
{
|
|
|
|
return aPointA;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return aPointB;
|
|
|
|
}
|
|
|
|
};
|
2021-01-10 13:04:21 +00:00
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
CIRCLE maxTanCircle;
|
|
|
|
VECTOR2I tanStartPoint = getFurthestPointToTanInterstect( tanStart.A, tanStart.B );
|
|
|
|
VECTOR2I tanEndPoint = getFurthestPointToTanInterstect( tanEnd.A, tanEnd.B );
|
|
|
|
VECTOR2I tempTangentPoint = tanEndPoint;
|
|
|
|
|
|
|
|
if( getFurthestPointToTanInterstect( tanStartPoint, tanEndPoint ) == tanEndPoint )
|
|
|
|
tempTangentPoint = tanStartPoint;
|
|
|
|
|
|
|
|
maxTanCircle.ConstructFromTanTanPt( tanStart, tanEnd, tempTangentPoint );
|
|
|
|
VECTOR2I maxTanPtStart = tanStart.LineProject( maxTanCircle.Center );
|
|
|
|
VECTOR2I maxTanPtEnd = tanEnd.LineProject( maxTanCircle.Center );
|
|
|
|
|
2022-08-30 20:58:43 +00:00
|
|
|
SEG cSegTanStart( maxTanPtStart, *tanIntersect );
|
|
|
|
SEG cSegTanEnd( maxTanPtEnd, *tanIntersect );
|
2021-01-22 16:41:47 +00:00
|
|
|
SEG cSegChord( maxTanPtStart, maxTanPtEnd );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
int cSegTanStartSide = cSegTanStart.Side( theArc->GetMid() );
|
|
|
|
int cSegTanEndSide = cSegTanEnd.Side( theArc->GetMid() );
|
|
|
|
int cSegChordSide = cSegChord.Side( theArc->GetMid() );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-08-04 16:22:49 +00:00
|
|
|
bool eatFirstMouseUp = true;
|
2021-07-05 19:25:04 +00:00
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
// Start the tool loop
|
2021-01-03 01:21:20 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
|
|
|
{
|
|
|
|
m_cursor = controls->GetMousePosition();
|
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
// Constrain cursor within the isosceles triangle
|
|
|
|
if( cSegTanStartSide != cSegTanStart.Side( m_cursor )
|
|
|
|
|| cSegTanEndSide != cSegTanEnd.Side( m_cursor )
|
|
|
|
|| cSegChordSide != cSegChord.Side( m_cursor ) )
|
2021-01-03 01:21:20 +00:00
|
|
|
{
|
2021-01-22 16:41:47 +00:00
|
|
|
std::vector<VECTOR2I> possiblePoints;
|
|
|
|
|
|
|
|
possiblePoints.push_back( cSegTanEnd.NearestPoint( m_cursor ) );
|
|
|
|
possiblePoints.push_back( cSegChord.NearestPoint( m_cursor ) );
|
|
|
|
|
|
|
|
VECTOR2I closest = cSegTanStart.NearestPoint( m_cursor );
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
for( const VECTOR2I& candidate : possiblePoints )
|
2021-01-22 16:41:47 +00:00
|
|
|
{
|
2021-06-12 10:39:28 +00:00
|
|
|
if( ( candidate - m_cursor ).SquaredEuclideanNorm()
|
|
|
|
< ( closest - m_cursor ).SquaredEuclideanNorm() )
|
2021-01-22 16:41:47 +00:00
|
|
|
{
|
|
|
|
closest = candidate;
|
|
|
|
}
|
|
|
|
}
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
m_cursor = closest;
|
2021-01-03 01:21:20 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
// Constrain cursor to be outside maxTanCircle
|
|
|
|
if( ( m_cursor - maxTanCircle.Center ).EuclideanNorm() < maxTanCircle.Radius )
|
|
|
|
m_cursor = maxTanCircle.NearestPoint( m_cursor );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
|
|
|
controls->ForceCursorPosition( true, m_cursor );
|
|
|
|
|
|
|
|
// Calculate resulting object coordinates
|
|
|
|
CIRCLE circlehelper;
|
2021-01-22 16:41:47 +00:00
|
|
|
circlehelper.ConstructFromTanTanPt( cSegTanStart, cSegTanEnd, m_cursor );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-01-10 13:04:21 +00:00
|
|
|
VECTOR2I newCenter = circlehelper.Center;
|
2021-01-22 16:41:47 +00:00
|
|
|
VECTOR2I newStart = cSegTanStart.LineProject( newCenter );
|
|
|
|
VECTOR2I newEnd = cSegTanEnd.LineProject( newCenter );
|
2021-07-17 19:56:18 +00:00
|
|
|
VECTOR2I newMid = CalcArcMid( newStart, newEnd, newCenter );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Update objects
|
2022-01-02 02:06:40 +00:00
|
|
|
theArc->SetStart( newStart );
|
|
|
|
theArc->SetEnd( newEnd );
|
|
|
|
theArc->SetMid( newMid );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
|
|
|
if( isStartTrackOnStartPt )
|
2022-01-02 02:06:40 +00:00
|
|
|
trackOnStart->SetStart( newStart );
|
2021-01-03 01:21:20 +00:00
|
|
|
else
|
2022-01-02 02:06:40 +00:00
|
|
|
trackOnStart->SetEnd( newStart );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
|
|
|
if( isEndTrackOnStartPt )
|
2022-01-02 02:06:40 +00:00
|
|
|
trackOnEnd->SetStart( newEnd );
|
2021-01-03 01:21:20 +00:00
|
|
|
else
|
2022-01-02 02:06:40 +00:00
|
|
|
trackOnEnd->SetEnd( newEnd );
|
2021-01-10 13:04:21 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Update view
|
2021-01-03 01:21:20 +00:00
|
|
|
getView()->Update( trackOnStart );
|
|
|
|
getView()->Update( trackOnEnd );
|
|
|
|
getView()->Update( theArc );
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Handle events
|
2021-07-05 19:25:04 +00:00
|
|
|
if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
|
|
|
|
{
|
2021-08-04 16:22:49 +00:00
|
|
|
eatFirstMouseUp = false;
|
2021-07-05 19:25:04 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
2021-01-03 01:21:20 +00:00
|
|
|
{
|
|
|
|
restore_state = true; // Canceling the tool means that items have to be restored
|
|
|
|
break; // Finish
|
|
|
|
}
|
|
|
|
else if( evt->IsAction( &ACTIONS::undo ) )
|
|
|
|
{
|
|
|
|
restore_state = true; // Perform undo locally
|
|
|
|
break; // Finish
|
|
|
|
}
|
2021-08-04 16:22:49 +00:00
|
|
|
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT )
|
2023-11-25 20:13:52 +00:00
|
|
|
|| evt->IsDblClick( BUT_LEFT ) )
|
2021-01-03 01:21:20 +00:00
|
|
|
{
|
2021-08-04 16:22:49 +00:00
|
|
|
// Eat mouse-up/-click events that leaked through from the lock dialog
|
2023-10-13 19:30:43 +00:00
|
|
|
if( eatFirstMouseUp && !evt->IsAction( &ACTIONS::cursorClick ) )
|
2021-08-04 16:22:49 +00:00
|
|
|
{
|
|
|
|
eatFirstMouseUp = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-01-22 16:41:47 +00:00
|
|
|
break; // Finish
|
2021-01-03 01:21:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Amend the end points of the arc if we delete the joining tracks
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I newStart = trackOnStart->GetStart();
|
|
|
|
VECTOR2I newEnd = trackOnEnd->GetStart();
|
2021-03-31 20:13:08 +00:00
|
|
|
|
|
|
|
if( isStartTrackOnStartPt )
|
|
|
|
newStart = trackOnStart->GetEnd();
|
|
|
|
|
|
|
|
if( isEndTrackOnStartPt )
|
|
|
|
newEnd = trackOnEnd->GetEnd();
|
|
|
|
|
2022-09-17 00:45:14 +00:00
|
|
|
int maxLengthIU =
|
|
|
|
KiROUND( ADVANCED_CFG::GetCfg().m_MaxTrackLengthToKeep * pcbIUScale.IU_PER_MM );
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( trackOnStart->GetLength() <= maxLengthIU )
|
|
|
|
{
|
2023-11-25 19:49:12 +00:00
|
|
|
if( addedTracks.count( trackOnStart ) )
|
|
|
|
{
|
|
|
|
getView()->Remove( trackOnStart );
|
|
|
|
addedTracks.erase( trackOnStart );
|
|
|
|
delete trackOnStart;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
commit.Remove( trackOnStart );
|
|
|
|
}
|
|
|
|
|
2021-03-31 20:13:08 +00:00
|
|
|
theArc->SetStart( newStart );
|
2023-06-27 15:52:50 +00:00
|
|
|
}
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( trackOnEnd->GetLength() <= maxLengthIU )
|
|
|
|
{
|
2023-11-25 19:49:12 +00:00
|
|
|
if( addedTracks.count( trackOnEnd ) )
|
|
|
|
{
|
|
|
|
getView()->Remove( trackOnEnd );
|
|
|
|
addedTracks.erase( trackOnEnd );
|
|
|
|
delete trackOnEnd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
commit.Remove( trackOnEnd );
|
|
|
|
}
|
|
|
|
|
2021-03-31 20:13:08 +00:00
|
|
|
theArc->SetEnd( newEnd );
|
2023-06-27 15:52:50 +00:00
|
|
|
}
|
2021-03-31 20:13:08 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( theArc->GetLength() <= 0 )
|
|
|
|
commit.Remove( theArc );
|
2021-01-03 01:21:20 +00:00
|
|
|
|
2023-11-25 19:49:12 +00:00
|
|
|
for( PCB_TRACK* added : addedTracks )
|
|
|
|
{
|
|
|
|
getView()->Remove( added );
|
|
|
|
commit.Add( added );
|
|
|
|
}
|
|
|
|
|
2021-01-03 01:21:20 +00:00
|
|
|
// Should we commit?
|
|
|
|
if( restore_state )
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Revert();
|
2021-01-03 01:21:20 +00:00
|
|
|
else
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Drag Arc Track" ) );
|
2017-08-03 15:53:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-03-03 10:50:50 +00:00
|
|
|
|
2020-07-05 21:36:12 +00:00
|
|
|
|
2019-10-31 00:00:07 +00:00
|
|
|
int EDIT_TOOL::ChangeTrackWidth( const TOOL_EVENT& aEvent )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
const PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-08-12 16:39:57 +00:00
|
|
|
{
|
2020-12-15 22:32:02 +00:00
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = aCollector[ i ];
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
if( !dynamic_cast<PCB_TRACK*>( item ) )
|
2020-12-15 22:32:02 +00:00
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
2020-12-10 01:33:24 +00:00
|
|
|
},
|
2020-12-10 17:34:26 +00:00
|
|
|
true /* prompt user regarding locked items */ );
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
2019-10-31 00:00:07 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2020-12-02 00:10:56 +00:00
|
|
|
if( item->Type() == PCB_VIA_T )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( item );
|
2020-12-02 00:10:56 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( via );
|
2019-10-31 00:00:07 +00:00
|
|
|
|
2019-07-17 20:45:43 +00:00
|
|
|
int new_width;
|
|
|
|
int new_drill;
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( via->GetViaType() == VIATYPE::MICROVIA )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
2022-08-14 11:03:18 +00:00
|
|
|
NETCLASS* netClass = via->GetEffectiveNetClass();
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2020-12-08 12:30:07 +00:00
|
|
|
new_width = netClass->GetuViaDiameter();
|
|
|
|
new_drill = netClass->GetuViaDrill();
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_width = board()->GetDesignSettings().GetCurrentViaSize();
|
|
|
|
new_drill = board()->GetDesignSettings().GetCurrentViaDrill();
|
|
|
|
}
|
|
|
|
|
|
|
|
via->SetDrill( new_drill );
|
|
|
|
via->SetWidth( new_width );
|
|
|
|
}
|
2020-12-02 00:10:56 +00:00
|
|
|
else if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
|
2020-12-02 00:10:56 +00:00
|
|
|
|
2020-12-11 18:29:52 +00:00
|
|
|
wxCHECK( track, 0 );
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( track );
|
2019-10-31 00:00:07 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
int new_width = board()->GetDesignSettings().GetCurrentTrackWidth();
|
|
|
|
track->SetWidth( new_width );
|
|
|
|
}
|
2019-10-31 00:00:07 +00:00
|
|
|
}
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2024-02-03 13:43:41 +00:00
|
|
|
commit.Push( _( "Edit Track Width/Via Size" ) );
|
2019-10-31 00:00:07 +00:00
|
|
|
|
|
|
|
if( selection.IsHover() )
|
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2019-10-31 00:00:07 +00:00
|
|
|
|
|
|
|
// Notify other tools of the changes -- This updates the visual ratsnest
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2019-10-31 00:00:07 +00:00
|
|
|
return 0;
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2019-10-31 00:00:07 +00:00
|
|
|
|
2020-10-20 21:23:05 +00:00
|
|
|
int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
// Store last used fillet radius to allow pressing "enter" if repeat fillet is required
|
2023-08-05 15:43:10 +00:00
|
|
|
static int filletRadius = 0;
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-12-02 00:10:56 +00:00
|
|
|
{
|
2020-12-15 22:32:02 +00:00
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = aCollector[i];
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
if( !dynamic_cast<PCB_TRACK*>( item ) )
|
2020-12-15 22:32:02 +00:00
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
2020-12-02 00:10:56 +00:00
|
|
|
},
|
2021-07-05 19:25:04 +00:00
|
|
|
true /* prompt user regarding locked items */ );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
|
|
|
if( selection.Size() < 2 )
|
|
|
|
{
|
2020-12-15 22:32:02 +00:00
|
|
|
frame()->ShowInfoBarMsg( _( "At least two straight track segments must be selected." ) );
|
2020-10-20 21:23:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
WX_UNIT_ENTRY_DIALOG dlg( frame(), _( "Fillet Tracks" ), _( "Enter fillet radius:" ),
|
|
|
|
filletRadius );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2020-10-20 21:23:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
filletRadius = dlg.GetValue();
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
if( filletRadius == 0 )
|
2020-10-20 21:23:05 +00:00
|
|
|
{
|
2020-10-21 19:41:54 +00:00
|
|
|
frame()->ShowInfoBarMsg( _( "A radius of zero was entered.\n"
|
|
|
|
"The fillet operation was not performed." ) );
|
2020-10-20 21:23:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
struct FILLET_OP
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* t1;
|
|
|
|
PCB_TRACK* t2;
|
|
|
|
// Start point of track is modified after PCB_ARC is added, otherwise the end point:
|
|
|
|
bool t1Start = true;
|
|
|
|
bool t2Start = true;
|
2020-11-06 18:00:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<FILLET_OP> filletOperations;
|
|
|
|
bool operationPerformedOnAtLeastOne = false;
|
|
|
|
bool didOneAttemptFail = false;
|
2021-06-11 21:07:02 +00:00
|
|
|
std::set<PCB_TRACK*> processedTracks;
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
auto processFilletOp =
|
|
|
|
[&]( PCB_TRACK* aTrack, bool aStartPoint )
|
|
|
|
{
|
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> c = board()->GetConnectivity();
|
|
|
|
VECTOR2I anchor = aStartPoint ? aTrack->GetStart() : aTrack->GetEnd();
|
|
|
|
std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
itemsOnAnchor = c->GetConnectedItemsAtAnchor( aTrack, anchor,
|
|
|
|
{ PCB_PAD_T, PCB_VIA_T,
|
|
|
|
PCB_TRACE_T, PCB_ARC_T } );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
if( itemsOnAnchor.size() > 0
|
|
|
|
&& selection.Contains( itemsOnAnchor.at( 0 ) )
|
|
|
|
&& itemsOnAnchor.at( 0 )->Type() == PCB_TRACE_T )
|
2020-11-06 18:00:10 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
PCB_TRACK* trackOther = static_cast<PCB_TRACK*>( itemsOnAnchor.at( 0 ) );
|
2020-12-02 00:10:56 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
// Make sure we don't fillet the same pair of tracks twice
|
|
|
|
if( processedTracks.find( trackOther ) == processedTracks.end() )
|
|
|
|
{
|
|
|
|
if( itemsOnAnchor.size() == 1 )
|
|
|
|
{
|
|
|
|
FILLET_OP filletOp;
|
|
|
|
filletOp.t1 = aTrack;
|
|
|
|
filletOp.t2 = trackOther;
|
|
|
|
filletOp.t1Start = aStartPoint;
|
|
|
|
filletOp.t2Start = aTrack->IsPointOnEnds( filletOp.t2->GetStart() );
|
|
|
|
filletOperations.push_back( filletOp );
|
|
|
|
}
|
|
|
|
else
|
2020-11-06 18:00:10 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
// User requested to fillet these two tracks but not possible as
|
|
|
|
// there are other elements connected at that point
|
|
|
|
didOneAttemptFail = true;
|
2020-11-06 18:00:10 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-24 18:54:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_TRACE_T )
|
|
|
|
{
|
|
|
|
PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
|
2021-01-06 21:02:30 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
if( track->GetLength() > 0 )
|
|
|
|
{
|
|
|
|
processFilletOp( track, true ); // on the start point of track
|
|
|
|
processFilletOp( track, false ); // on the end point of track
|
2021-01-06 21:02:30 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
processedTracks.insert( track );
|
|
|
|
}
|
|
|
|
}
|
2020-11-06 18:00:10 +00:00
|
|
|
}
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
2020-11-06 18:00:10 +00:00
|
|
|
std::vector<BOARD_ITEM*> itemsToAddToSelection;
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
for( FILLET_OP filletOp : filletOperations )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* track1 = filletOp.t1;
|
|
|
|
PCB_TRACK* track2 = filletOp.t2;
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
bool trackOnStart = track1->IsPointOnEnds( track2->GetStart() );
|
|
|
|
bool trackOnEnd = track1->IsPointOnEnds( track2->GetEnd() );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
if( trackOnStart && trackOnEnd )
|
|
|
|
continue; // Ignore duplicate tracks
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
if( ( trackOnStart || trackOnEnd ) && track1->GetLayer() == track2->GetLayer() )
|
|
|
|
{
|
|
|
|
SEG t1Seg( track1->GetStart(), track1->GetEnd() );
|
|
|
|
SEG t2Seg( track2->GetStart(), track2->GetEnd() );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
if( t1Seg.ApproxCollinear( t2Seg ) )
|
|
|
|
continue;
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
SHAPE_ARC sArc( t1Seg, t2Seg, filletRadius );
|
2022-09-20 23:16:00 +00:00
|
|
|
VECTOR2I t1newPoint, t2newPoint;
|
2020-11-06 18:00:10 +00:00
|
|
|
|
2020-12-02 00:10:56 +00:00
|
|
|
auto setIfPointOnSeg =
|
2023-08-05 15:43:10 +00:00
|
|
|
[]( VECTOR2I& aPointToSet, const SEG& aSegment, const VECTOR2I& aVecToTest )
|
2020-12-02 00:10:56 +00:00
|
|
|
{
|
|
|
|
VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
|
2020-11-06 18:00:10 +00:00
|
|
|
|
2020-12-02 00:10:56 +00:00
|
|
|
// Find out if we are on the segment (minimum precision)
|
|
|
|
if( segToVec.EuclideanNorm() < SHAPE_ARC::MIN_PRECISION_IU )
|
|
|
|
{
|
|
|
|
aPointToSet.x = aVecToTest.x;
|
|
|
|
aPointToSet.y = aVecToTest.y;
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-06 18:00:10 +00:00
|
|
|
|
2020-12-02 00:10:56 +00:00
|
|
|
return false;
|
|
|
|
};
|
2020-10-20 21:23:05 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
//Do not draw a fillet if the end points of the arc are not within the track segments
|
|
|
|
if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.GetP0() )
|
|
|
|
&& !setIfPointOnSeg( t2newPoint, t2Seg, sArc.GetP0() ) )
|
|
|
|
{
|
|
|
|
didOneAttemptFail = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.GetP1() )
|
|
|
|
&& !setIfPointOnSeg( t2newPoint, t2Seg, sArc.GetP1() ) )
|
|
|
|
{
|
|
|
|
didOneAttemptFail = true;
|
|
|
|
continue;
|
2020-10-20 21:23:05 +00:00
|
|
|
}
|
2020-11-06 18:00:10 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_ARC* tArc = new PCB_ARC( frame()->GetBoard(), &sArc );
|
2020-11-06 18:00:10 +00:00
|
|
|
tArc->SetLayer( track1->GetLayer() );
|
|
|
|
tArc->SetWidth( track1->GetWidth() );
|
|
|
|
tArc->SetNet( track1->GetNet() );
|
2021-07-05 19:10:05 +00:00
|
|
|
tArc->SetLocked( track1->IsLocked() );
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Add( tArc );
|
2020-11-06 18:00:10 +00:00
|
|
|
itemsToAddToSelection.push_back( tArc );
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( track1 );
|
|
|
|
commit.Modify( track2 );
|
2020-11-06 18:00:10 +00:00
|
|
|
|
|
|
|
if( filletOp.t1Start )
|
|
|
|
track1->SetStart( t1newPoint );
|
|
|
|
else
|
|
|
|
track1->SetEnd( t1newPoint );
|
2021-01-06 21:02:30 +00:00
|
|
|
|
2020-11-06 18:00:10 +00:00
|
|
|
if( filletOp.t2Start )
|
|
|
|
track2->SetStart( t2newPoint );
|
|
|
|
else
|
|
|
|
track2->SetEnd( t2newPoint );
|
|
|
|
|
|
|
|
operationPerformedOnAtLeastOne = true;
|
2020-10-20 21:23:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Fillet Tracks" ) );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
|
|
|
//select the newly created arcs
|
|
|
|
for( BOARD_ITEM* item : itemsToAddToSelection )
|
|
|
|
m_selectionTool->AddItemToSel( item );
|
|
|
|
|
|
|
|
if( !operationPerformedOnAtLeastOne )
|
2020-10-21 19:41:54 +00:00
|
|
|
frame()->ShowInfoBarMsg( _( "Unable to fillet the selected track segments." ) );
|
2020-10-20 21:23:05 +00:00
|
|
|
else if( didOneAttemptFail )
|
2020-10-21 19:41:54 +00:00
|
|
|
frame()->ShowInfoBarMsg( _( "Some of the track segments could not be filleted." ) );
|
2020-10-20 21:23:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
/**
|
|
|
|
* Prompt the user for the fillet radius and return it.
|
|
|
|
*
|
|
|
|
* @param aFrame
|
|
|
|
* @param aErrorMsg filled with an error message if the parameter is invalid somehow
|
|
|
|
* @return std::optional<int> the fillet radius or std::nullopt if no
|
|
|
|
* valid fillet specified
|
|
|
|
*/
|
|
|
|
static std::optional<int> GetFilletParams( PCB_BASE_EDIT_FRAME& aFrame, wxString& aErrorMsg )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
|
|
|
// Store last used fillet radius to allow pressing "enter" if repeat fillet is required
|
2023-08-05 15:43:10 +00:00
|
|
|
static int filletRadius = 0;
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
WX_UNIT_ENTRY_DIALOG dlg( &aFrame, _( "Fillet Lines" ), _( "Enter fillet radius:" ),
|
|
|
|
filletRadius );
|
2023-06-30 23:31:58 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2023-06-30 23:31:58 +00:00
|
|
|
return std::nullopt;
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
filletRadius = dlg.GetValue();
|
2023-06-30 23:31:58 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
if( filletRadius == 0 )
|
2023-06-30 23:31:58 +00:00
|
|
|
{
|
|
|
|
aErrorMsg = _( "A radius of zero was entered.\n"
|
|
|
|
"The fillet operation was not performed." );
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
return filletRadius;
|
2023-06-30 23:31:58 +00:00
|
|
|
}
|
|
|
|
|
2023-07-02 17:59:04 +00:00
|
|
|
/**
|
|
|
|
* Prompt the user for chamfer parameters
|
|
|
|
*
|
|
|
|
* @param aFrame
|
|
|
|
* @param aErrorMsg filled with an error message if the parameter is invalid somehow
|
|
|
|
* @return std::optional<int> the chamfer parameters or std::nullopt if no
|
|
|
|
* valid fillet specified
|
|
|
|
*/
|
|
|
|
static std::optional<CHAMFER_PARAMS> GetChamferParams( PCB_BASE_EDIT_FRAME& aFrame,
|
|
|
|
wxString& aErrorMsg )
|
|
|
|
{
|
|
|
|
// Non-zero and the KLC default for Fab layer chamfers
|
|
|
|
const int default_setback = pcbIUScale.mmToIU( 1 );
|
|
|
|
// Store last used setback to allow pressing "enter" if repeat chamfer is required
|
|
|
|
static CHAMFER_PARAMS params{ default_setback, default_setback };
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
WX_UNIT_ENTRY_DIALOG dlg( &aFrame, _( "Chamfer Lines" ), _( "Enter chamfer setback:" ),
|
|
|
|
params.m_chamfer_setback_a );
|
2023-07-02 17:59:04 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2023-07-02 17:59:04 +00:00
|
|
|
return std::nullopt;
|
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
params.m_chamfer_setback_a = dlg.GetValue();
|
2023-07-02 17:59:04 +00:00
|
|
|
// It's hard to easily specify an asymmetric chamfer (which line gets the longer
|
|
|
|
// setbeck?), so we just use the same setback for each
|
2023-08-05 15:43:10 +00:00
|
|
|
params.m_chamfer_setback_b = params.m_chamfer_setback_a;
|
2023-07-02 17:59:04 +00:00
|
|
|
|
|
|
|
// Some technically-valid chamfers are not useful to actually do
|
2023-08-05 15:43:10 +00:00
|
|
|
if( params.m_chamfer_setback_a == 0 )
|
2023-07-02 17:59:04 +00:00
|
|
|
{
|
|
|
|
aErrorMsg = _( "A setback of zero was entered.\n"
|
|
|
|
"The chamfer operation was not performed." );
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
2023-06-30 23:31:58 +00:00
|
|
|
|
2023-07-02 17:59:04 +00:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
|
|
|
int EDIT_TOOL::ModifyLines( const TOOL_EVENT& aEvent )
|
2023-06-30 23:31:58 +00:00
|
|
|
{
|
2022-11-18 14:32:43 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
2023-08-05 15:43:10 +00:00
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
2023-08-05 15:43:10 +00:00
|
|
|
std::vector<VECTOR2I> pts;
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-08-05 15:43:10 +00:00
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
2023-08-05 15:43:10 +00:00
|
|
|
BOARD_ITEM* item = aCollector[i];
|
|
|
|
|
|
|
|
// We've converted the polygon and rectangle to segments, so drop everything
|
|
|
|
// that isn't a segment at this point
|
|
|
|
if( !item->IsType( { PCB_SHAPE_LOCATE_SEGMENT_T,
|
|
|
|
PCB_SHAPE_LOCATE_POLY_T,
|
|
|
|
PCB_SHAPE_LOCATE_RECT_T } ) )
|
|
|
|
{
|
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
2022-11-18 14:32:43 +00:00
|
|
|
}
|
2023-08-05 15:43:10 +00:00
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
std::set<PCB_SHAPE*> lines_to_add;
|
2022-11-18 14:32:43 +00:00
|
|
|
std::vector<PCB_SHAPE*> items_to_remove;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
std::vector<VECTOR2I> pts;
|
|
|
|
PCB_SHAPE *graphic = static_cast<PCB_SHAPE*>( item );
|
2023-01-02 15:52:08 +00:00
|
|
|
PCB_LAYER_ID layer = graphic->GetLayer();
|
|
|
|
int width = graphic->GetWidth();
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-07-24 16:07:56 +00:00
|
|
|
if( graphic->GetShape() == SHAPE_T::RECTANGLE )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
|
|
|
items_to_remove.push_back( graphic );
|
|
|
|
VECTOR2I start( graphic->GetStart() );
|
|
|
|
VECTOR2I end( graphic->GetEnd() );
|
|
|
|
pts.emplace_back( start );
|
|
|
|
pts.emplace_back( VECTOR2I( end.x, start.y ) );
|
|
|
|
pts.emplace_back( end );
|
|
|
|
pts.emplace_back( VECTOR2I( start.x, end.y ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( graphic->GetShape() == SHAPE_T::POLY )
|
|
|
|
{
|
|
|
|
items_to_remove.push_back( graphic );
|
|
|
|
|
|
|
|
for( int jj = 0; jj < graphic->GetPolyShape().VertexCount(); ++jj )
|
|
|
|
pts.emplace_back( graphic->GetPolyShape().CVertex( jj ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( size_t jj = 1; jj < pts.size(); ++jj )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_SHAPE *line = new PCB_SHAPE( frame()->GetModel(), SHAPE_T::SEGMENT );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
|
|
|
line->SetStart( pts[jj - 1] );
|
|
|
|
line->SetEnd( pts[jj] );
|
2023-01-02 15:52:08 +00:00
|
|
|
line->SetWidth( width );
|
|
|
|
line->SetLayer( layer );
|
2022-11-18 14:32:43 +00:00
|
|
|
lines_to_add.insert( line );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pts.size() > 1 )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_SHAPE *line = new PCB_SHAPE( frame()->GetModel(), SHAPE_T::SEGMENT );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
|
|
|
line->SetStart( pts.back() );
|
|
|
|
line->SetEnd( pts.front() );
|
2023-01-02 15:52:08 +00:00
|
|
|
line->SetWidth( width );
|
|
|
|
line->SetLayer( layer );
|
2022-11-18 14:32:43 +00:00
|
|
|
lines_to_add.insert( line );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( PCB_SHAPE* item : lines_to_add )
|
|
|
|
selection.Add( item );
|
|
|
|
|
|
|
|
for( PCB_SHAPE* item : items_to_remove )
|
|
|
|
selection.Remove( item );
|
|
|
|
|
|
|
|
if( selection.CountType( PCB_SHAPE_LOCATE_SEGMENT_T ) < 2 )
|
|
|
|
{
|
|
|
|
frame()->ShowInfoBarMsg( _( "A shape with least two lines must be selected." ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
BOARD_COMMIT commit{ this };
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// List of thing to select at the end of the operation
|
|
|
|
// (doing it as we go will invalidate the iterator)
|
|
|
|
std::vector<PCB_SHAPE*> items_to_select_on_success;
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-07-29 13:15:03 +00:00
|
|
|
// And same for items to deselect
|
|
|
|
std::vector<PCB_SHAPE*> items_to_deselect_on_success;
|
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// Handle modifications to existing items by the routine
|
|
|
|
// How to deal with this depends on whether we're in the footprint editor or not
|
|
|
|
// and whether the item was conjured up by decomposing a polygon or rectangle
|
|
|
|
const auto item_modification_handler = [&]( PCB_SHAPE& aItem )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
2023-07-30 12:41:17 +00:00
|
|
|
// If the item was "conjured up" it will be added later separately
|
|
|
|
if( !alg::contains( lines_to_add, &aItem ) )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
2023-07-30 12:41:17 +00:00
|
|
|
commit.Modify( &aItem );
|
|
|
|
items_to_select_on_success.push_back( &aItem );
|
2023-06-30 23:31:58 +00:00
|
|
|
}
|
|
|
|
};
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-07-29 13:15:03 +00:00
|
|
|
bool any_items_created = !lines_to_add.empty();
|
2023-06-30 23:31:58 +00:00
|
|
|
const auto item_creation_handler = [&]( std::unique_ptr<PCB_SHAPE> aItem )
|
|
|
|
{
|
|
|
|
any_items_created = true;
|
|
|
|
items_to_select_on_success.push_back( aItem.get() );
|
|
|
|
commit.Add( aItem.release() );
|
|
|
|
};
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-07-29 13:15:03 +00:00
|
|
|
bool any_items_removed = !items_to_remove.empty();
|
|
|
|
const auto item_removal_handler = [&]( PCB_SHAPE& aItem )
|
|
|
|
{
|
|
|
|
any_items_removed = true;
|
|
|
|
items_to_deselect_on_success.push_back( &aItem );
|
|
|
|
commit.Remove( &aItem );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Combine these callbacks into a CHANGE_HANDLER to inject in the ROUTINE
|
|
|
|
ITEM_MODIFICATION_ROUTINE::CALLABLE_BASED_HANDLER change_handler(
|
|
|
|
item_creation_handler, item_modification_handler, item_removal_handler );
|
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// Construct an appropriate tool
|
|
|
|
std::unique_ptr<PAIRWISE_LINE_ROUTINE> pairwise_line_routine;
|
|
|
|
wxString error_message;
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::filletLines ) )
|
|
|
|
{
|
|
|
|
const std::optional<int> filletRadiusIU = GetFilletParams( *frame(), error_message );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
if( filletRadiusIU.has_value() )
|
|
|
|
{
|
|
|
|
pairwise_line_routine = std::make_unique<LINE_FILLET_ROUTINE>(
|
2023-07-29 13:15:03 +00:00
|
|
|
frame()->GetModel(), change_handler, *filletRadiusIU );
|
2023-06-30 23:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-02 17:59:04 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::chamferLines ) )
|
|
|
|
{
|
|
|
|
const std::optional<CHAMFER_PARAMS> chamfer_params =
|
|
|
|
GetChamferParams( *frame(), error_message );
|
|
|
|
|
|
|
|
if( chamfer_params.has_value() )
|
|
|
|
{
|
|
|
|
pairwise_line_routine = std::make_unique<LINE_CHAMFER_ROUTINE>(
|
2023-07-29 13:15:03 +00:00
|
|
|
frame()->GetModel(), change_handler, *chamfer_params );
|
2023-07-02 17:59:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::extendLines ) )
|
|
|
|
{
|
|
|
|
if( selection.CountType( PCB_SHAPE_LOCATE_SEGMENT_T ) != 2 )
|
|
|
|
{
|
|
|
|
error_message = _( "Exactly two lines must be selected to extend them." );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-29 13:15:03 +00:00
|
|
|
pairwise_line_routine =
|
|
|
|
std::make_unique<LINE_EXTENSION_ROUTINE>( frame()->GetModel(), change_handler );
|
2023-07-02 17:59:04 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
if( !pairwise_line_routine )
|
|
|
|
{
|
|
|
|
// Didn't construct any mofication routine - could be an error or cancellation
|
|
|
|
if( !error_message.empty() )
|
|
|
|
frame()->ShowInfoBarMsg( error_message );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// Apply the tool to every line pair
|
|
|
|
alg::for_all_pairs( selection.begin(), selection.end(),
|
|
|
|
[&]( EDA_ITEM* a, EDA_ITEM* b )
|
|
|
|
{
|
|
|
|
PCB_SHAPE* line_a = static_cast<PCB_SHAPE*>( a );
|
|
|
|
PCB_SHAPE* line_b = static_cast<PCB_SHAPE*>( b );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
pairwise_line_routine->ProcessLinePair( *line_a, *line_b );
|
|
|
|
} );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// Items created like lines from a rectangle
|
|
|
|
// Some of these might have been changed by the tool, but we need to
|
|
|
|
// add *all* of them to the selection and commit them
|
|
|
|
for( PCB_SHAPE* item : lines_to_add )
|
|
|
|
{
|
|
|
|
m_selectionTool->AddItemToSel( item, true );
|
|
|
|
commit.Add( item );
|
|
|
|
}
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// Remove items like rectangles that we decomposed into lines
|
2023-06-27 15:52:50 +00:00
|
|
|
for( PCB_SHAPE* item : items_to_remove )
|
2022-11-18 14:32:43 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Remove( item );
|
2022-11-18 14:32:43 +00:00
|
|
|
m_selectionTool->RemoveItemFromSel( item, true );
|
|
|
|
}
|
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
// Select added and modified items
|
|
|
|
for( PCB_SHAPE* item : items_to_select_on_success )
|
2022-11-18 14:32:43 +00:00
|
|
|
m_selectionTool->AddItemToSel( item, true );
|
|
|
|
|
2023-07-29 13:15:03 +00:00
|
|
|
// Deselect removed items
|
|
|
|
for( PCB_SHAPE* item : items_to_deselect_on_success )
|
|
|
|
m_selectionTool->RemoveItemFromSel( item, true );
|
|
|
|
|
|
|
|
if( any_items_removed )
|
2022-11-18 14:32:43 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent );
|
|
|
|
|
2023-07-29 13:15:03 +00:00
|
|
|
if( any_items_created )
|
2022-11-18 14:32:43 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
|
|
|
|
|
|
|
// Notify other tools of the changes
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
2023-06-30 23:31:58 +00:00
|
|
|
commit.Push( pairwise_line_routine->GetCommitDescription() );
|
2022-11-18 14:32:43 +00:00
|
|
|
|
2023-09-30 20:38:40 +00:00
|
|
|
if (const std::optional<wxString> msg = pairwise_line_routine->GetStatusMessage()) {
|
|
|
|
frame()->ShowInfoBarMsg( *msg );
|
|
|
|
}
|
2022-11-18 14:32:43 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-30 00:47:34 +00:00
|
|
|
int EDIT_TOOL::SimplifyPolygons( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
std::vector<VECTOR2I> pts;
|
|
|
|
|
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = aCollector[i];
|
|
|
|
|
|
|
|
if( !item->IsType( { PCB_SHAPE_LOCATE_POLY_T, PCB_ZONE_T } ) )
|
|
|
|
aCollector.Remove( item );
|
|
|
|
|
|
|
|
if( ZONE* zone = dyn_cast<ZONE*>( item ) )
|
|
|
|
{
|
|
|
|
if( zone->IsTeardropArea() )
|
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
|
|
|
|
// Store last used value
|
|
|
|
static int s_toleranceValue = pcbIUScale.mmToIU( 3 );
|
|
|
|
|
|
|
|
WX_UNIT_ENTRY_DIALOG dlg( frame(), _( "Simplify Shapes" ), _( "Tolerance value:" ),
|
|
|
|
s_toleranceValue );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
s_toleranceValue = dlg.GetValue();
|
|
|
|
|
|
|
|
if( s_toleranceValue <= 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
BOARD_COMMIT commit{ this };
|
|
|
|
|
|
|
|
std::vector<PCB_SHAPE*> shapeList;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
commit.Modify( item );
|
|
|
|
|
|
|
|
if( PCB_SHAPE* shape = dyn_cast<PCB_SHAPE*>( item ) )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET& poly = shape->GetPolyShape();
|
|
|
|
|
|
|
|
poly.SimplifyOutlines( s_toleranceValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ZONE* zone = dyn_cast<ZONE*>( item ) )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET* poly = zone->Outline();
|
|
|
|
|
|
|
|
poly->SimplifyOutlines( s_toleranceValue );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit.Push( _( "Simplify Polygons" ) );
|
|
|
|
|
|
|
|
// Notify other tools of the changes
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-17 07:27:59 +00:00
|
|
|
int EDIT_TOOL::HealShapes( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
std::vector<VECTOR2I> pts;
|
|
|
|
|
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = aCollector[i];
|
|
|
|
|
|
|
|
// We've converted the polygon and rectangle to segments, so drop everything
|
|
|
|
// that isn't a segment at this point
|
|
|
|
if( !item->IsType( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_ARC_T,
|
|
|
|
PCB_SHAPE_LOCATE_BEZIER_T } ) )
|
|
|
|
{
|
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
|
|
|
|
// Store last used value
|
|
|
|
static int s_toleranceValue = pcbIUScale.mmToIU( 3 );
|
|
|
|
|
|
|
|
WX_UNIT_ENTRY_DIALOG dlg( frame(), _( "Heal Shapes" ), _( "Tolerance value:" ),
|
|
|
|
s_toleranceValue );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
s_toleranceValue = dlg.GetValue();
|
|
|
|
|
|
|
|
if( s_toleranceValue <= 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
BOARD_COMMIT commit{ this };
|
|
|
|
|
|
|
|
std::vector<PCB_SHAPE*> shapeList;
|
|
|
|
std::vector<std::unique_ptr<PCB_SHAPE>> newShapes;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item ) )
|
|
|
|
{
|
|
|
|
shapeList.push_back( shape );
|
|
|
|
commit.Modify( shape );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectBoardShapes( shapeList, newShapes, s_toleranceValue );
|
|
|
|
|
|
|
|
std::vector<PCB_SHAPE*> items_to_select;
|
|
|
|
|
|
|
|
for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
|
|
|
|
{
|
|
|
|
PCB_SHAPE* shape = ptr.release();
|
|
|
|
|
|
|
|
commit.Add( shape );
|
|
|
|
items_to_select.push_back( shape );
|
|
|
|
}
|
|
|
|
|
2024-02-03 13:43:41 +00:00
|
|
|
commit.Push( _( "Heal Shapes" ) );
|
2023-10-17 07:27:59 +00:00
|
|
|
|
|
|
|
// Select added items
|
|
|
|
for( PCB_SHAPE* item : items_to_select )
|
|
|
|
m_selectionTool->AddItemToSel( item, true );
|
|
|
|
|
|
|
|
if( items_to_select.size() > 0 )
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
|
|
|
|
|
|
|
// Notify other tools of the changes
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-22 00:23:59 +00:00
|
|
|
int EDIT_TOOL::BooleanPolygons( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = aCollector[i];
|
|
|
|
|
|
|
|
if( !item->IsType( {
|
|
|
|
PCB_SHAPE_LOCATE_POLY_T,
|
|
|
|
PCB_SHAPE_LOCATE_RECT_T,
|
|
|
|
} ) )
|
|
|
|
{
|
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
|
|
|
|
const EDA_ITEM* const last_item = selection.GetLastAddedItem();
|
|
|
|
|
|
|
|
// Gather or construct polygon source shapes to merge
|
|
|
|
std::vector<PCB_SHAPE*> items_to_process;
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
items_to_process.push_back( static_cast<PCB_SHAPE*>( item ) );
|
|
|
|
|
|
|
|
// put the last one in the selection at the front of the vector
|
|
|
|
// so it can be used as the property donor and as the basis for the
|
|
|
|
// boolean operation
|
|
|
|
if( item == last_item )
|
|
|
|
{
|
|
|
|
std::swap( items_to_process.back(), items_to_process.front() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOARD_COMMIT commit{ this };
|
|
|
|
|
|
|
|
// Handle modifications to existing items by the routine
|
|
|
|
const auto item_modification_handler = [&]( PCB_SHAPE& aItem )
|
|
|
|
{
|
|
|
|
commit.Modify( &aItem );
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<PCB_SHAPE*> items_to_select_on_success;
|
|
|
|
const auto item_creation_handler = [&]( std::unique_ptr<PCB_SHAPE> aItem )
|
|
|
|
{
|
|
|
|
items_to_select_on_success.push_back( aItem.get() );
|
|
|
|
commit.Add( aItem.release() );
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto item_removal_handler = [&]( PCB_SHAPE& aItem )
|
|
|
|
{
|
|
|
|
commit.Remove( &aItem );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Combine these callbacks into a CHANGE_HANDLER to inject in the ROUTINE
|
|
|
|
ITEM_MODIFICATION_ROUTINE::CALLABLE_BASED_HANDLER change_handler(
|
|
|
|
item_creation_handler, item_modification_handler, item_removal_handler );
|
|
|
|
|
|
|
|
// Construct an appropriate routine
|
|
|
|
std::unique_ptr<POLYGON_BOOLEAN_ROUTINE> boolean_routine;
|
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::mergePolygons ) )
|
|
|
|
{
|
|
|
|
boolean_routine =
|
|
|
|
std::make_unique<POLYGON_MERGE_ROUTINE>( frame()->GetModel(), change_handler );
|
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::subtractPolygons ) )
|
|
|
|
{
|
|
|
|
boolean_routine =
|
|
|
|
std::make_unique<POLYGON_SUBTRACT_ROUTINE>( frame()->GetModel(), change_handler );
|
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::intersectPolygons ) )
|
|
|
|
{
|
|
|
|
boolean_routine =
|
|
|
|
std::make_unique<POLYGON_INTERSECT_ROUTINE>( frame()->GetModel(), change_handler );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( false, "Could not find a polygon routine for this action" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform the operation on each polygon
|
|
|
|
for( PCB_SHAPE* shape : items_to_process )
|
|
|
|
{
|
|
|
|
boolean_routine->ProcessShape( *shape );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Select new items
|
|
|
|
for( PCB_SHAPE* item : items_to_select_on_success )
|
|
|
|
{
|
|
|
|
m_selectionTool->AddItemToSel( item, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify other tools of the changes
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
|
|
|
commit.Push( boolean_routine->GetCommitDescription() );
|
|
|
|
|
|
|
|
if( const std::optional<wxString> msg = boolean_routine->GetStatusMessage() )
|
|
|
|
{
|
|
|
|
frame()->ShowInfoBarMsg( *msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
2013-12-09 10:01:05 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
|
|
|
const PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
|
|
|
} );
|
2014-02-04 16:27:00 +00:00
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
// Tracks & vias are treated in a special way:
|
2022-08-20 09:27:35 +00:00
|
|
|
if( ( SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )( selection ) )
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection );
|
2021-09-09 20:49:16 +00:00
|
|
|
dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
2024-02-03 13:43:41 +00:00
|
|
|
else if( ( SELECTION_CONDITIONS::OnlyTypes( { PCB_TABLECELL_T } ) )( selection ) )
|
|
|
|
{
|
|
|
|
std::vector<PCB_TABLECELL*> cells;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection.Items() )
|
|
|
|
cells.push_back( static_cast<PCB_TABLECELL*>( item ) );
|
|
|
|
|
|
|
|
DIALOG_TABLECELL_PROPERTIES dlg( editFrame, cells );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
|
|
|
if( dlg.GetReturnValue() == DIALOG_TABLECELL_PROPERTIES::TABLECELL_PROPS_EDIT_TABLE )
|
|
|
|
{
|
|
|
|
PCB_TABLE* table = static_cast<PCB_TABLE*>( cells[0]->GetParent() );
|
|
|
|
DIALOG_TABLE_PROPERTIES tableDlg( frame(), table );
|
|
|
|
|
|
|
|
tableDlg.ShowQuasiModal(); // Scintilla's auto-complete requires quasiModal
|
|
|
|
}
|
|
|
|
}
|
2020-04-20 23:24:29 +00:00
|
|
|
else if( selection.Size() == 1 )
|
2013-12-09 10:01:05 +00:00
|
|
|
{
|
|
|
|
// Display properties dialog
|
2023-07-13 10:24:33 +00:00
|
|
|
if( BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selection.Front() ) )
|
|
|
|
{
|
|
|
|
// Do not handle undo buffer, it is done by the properties dialogs
|
|
|
|
editFrame->OnEditItemRequest( item );
|
2014-05-22 10:06:45 +00:00
|
|
|
|
2023-07-13 10:24:33 +00:00
|
|
|
// Notify other tools of the changes
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
}
|
2013-12-09 10:01:05 +00:00
|
|
|
}
|
2021-02-22 16:37:43 +00:00
|
|
|
else if( selection.Size() == 0 && getView()->IsLayerVisible( LAYER_DRAWINGSHEET ) )
|
2020-05-02 23:06:43 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_PROXY_VIEW_ITEM* ds = editFrame->GetCanvas()->GetDrawingSheet();
|
|
|
|
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
|
2020-05-02 23:06:43 +00:00
|
|
|
|
2022-01-02 02:06:40 +00:00
|
|
|
if( ds && ds->HitTestDrawingSheetItems( getView(), cursorPos ) )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( ACTIONS::pageSettings );
|
2021-07-24 08:53:09 +00:00
|
|
|
else
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::footprintProperties );
|
2020-05-02 23:06:43 +00:00
|
|
|
}
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
if( selection.IsHover() )
|
2018-09-17 13:14:23 +00:00
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2021-09-21 15:43:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Check for items becoming invisible and drop them from the selection.
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2022-09-27 22:53:47 +00:00
|
|
|
PCB_SELECTION selCopy = selection;
|
|
|
|
LSET visible = editFrame->GetBoard()->GetVisibleLayers();
|
2021-09-21 15:43:53 +00:00
|
|
|
|
2022-09-27 22:53:47 +00:00
|
|
|
for( EDA_ITEM* eda_item : selCopy )
|
2021-09-21 15:43:53 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
if( BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( eda_item ) )
|
|
|
|
{
|
|
|
|
if( !( item->GetLayerSet() & visible ).any() )
|
|
|
|
m_selectionTool->RemoveItemFromSel( item );
|
|
|
|
}
|
2021-09-21 15:43:53 +00:00
|
|
|
}
|
2018-09-17 13:14:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
2013-12-09 10:01:05 +00:00
|
|
|
{
|
2020-08-05 15:01:10 +00:00
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT localCommit( this );
|
|
|
|
BOARD_COMMIT* commit = dynamic_cast<BOARD_COMMIT*>( aEvent.Commit() );
|
|
|
|
|
|
|
|
if( !commit )
|
|
|
|
commit = &localCommit;
|
2019-06-12 12:24:00 +00:00
|
|
|
|
2021-12-06 22:51:22 +00:00
|
|
|
// Be sure that there is at least one item that we can modify. If nothing was selected before,
|
|
|
|
// try looking for the stuff under mouse cursor (i.e. KiCad old-style hover selection)
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2021-12-21 23:02:33 +00:00
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
2024-01-15 17:29:55 +00:00
|
|
|
sTool->FilterCollectorForTableCells( aCollector );
|
2020-02-05 12:49:12 +00:00
|
|
|
},
|
2021-12-06 22:51:22 +00:00
|
|
|
// Prompt user regarding locked items if in board editor and in free-pad-mode (if
|
|
|
|
// we're not in free-pad mode we delay this until the second RequestSelection()).
|
2022-07-24 15:49:46 +00:00
|
|
|
frame()->GetPcbNewSettings()->m_AllowFreePads && !m_isFootprintEditor );
|
2017-03-03 12:42:28 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
2014-02-04 16:27:00 +00:00
|
|
|
|
2022-08-25 22:50:47 +00:00
|
|
|
std::optional<VECTOR2I> oldRefPt;
|
2021-12-21 16:03:36 +00:00
|
|
|
bool is_hover = selection.IsHover(); // N.B. This must be saved before the second
|
|
|
|
// call to RequestSelection() below
|
2021-01-23 22:52:45 +00:00
|
|
|
|
|
|
|
if( selection.HasReferencePoint() )
|
|
|
|
oldRefPt = selection.GetReferencePoint();
|
|
|
|
|
2021-12-06 22:51:22 +00:00
|
|
|
// Now filter out pads if not in free pads mode. We cannot do this in the first
|
|
|
|
// RequestSelection() as we need the reference point when a pad is the selection front.
|
2022-07-24 15:49:46 +00:00
|
|
|
if( !m_isFootprintEditor && !frame()->GetPcbNewSettings()->m_AllowFreePads )
|
2021-12-06 22:51:22 +00:00
|
|
|
{
|
|
|
|
selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
2024-01-15 17:29:55 +00:00
|
|
|
sTool->FilterCollectorForTableCells( aCollector );
|
2021-12-06 22:51:22 +00:00
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
}
|
|
|
|
|
2022-01-01 23:28:25 +00:00
|
|
|
// Did we filter everything out? If so, don't try to operate further
|
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
|
|
|
|
2024-03-06 13:48:48 +00:00
|
|
|
// A single textbox "walks" if we rotate it around its position, as we keep resetting which
|
|
|
|
// corner is the origin.
|
|
|
|
if( selection.Size() == 1 && dynamic_cast<PCB_TEXTBOX*>( selection.Front() ) )
|
2023-11-06 13:29:12 +00:00
|
|
|
{
|
2024-03-06 13:48:48 +00:00
|
|
|
selection.SetReferencePoint( static_cast<PCB_TEXTBOX*>( selection.Front() )->GetCenter() );
|
2023-11-06 13:29:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
updateModificationPoint( selection );
|
|
|
|
}
|
2021-01-23 22:52:45 +00:00
|
|
|
|
2022-01-13 20:04:14 +00:00
|
|
|
VECTOR2I refPt = selection.GetReferencePoint();
|
|
|
|
EDA_ANGLE rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
|
2014-02-04 16:27:00 +00:00
|
|
|
|
2023-11-10 22:29:49 +00:00
|
|
|
if( frame()->GetCanvas()->GetView()->GetGAL()->IsFlippedX() )
|
|
|
|
rotateAngle = -rotateAngle;
|
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
// Calculate view bounding box
|
|
|
|
BOX2I viewBBox = selection.Front()->ViewBBox();
|
2018-07-31 04:52:21 +00:00
|
|
|
|
2020-12-15 22:32:02 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2021-12-11 23:57:51 +00:00
|
|
|
viewBBox.Merge( item->ViewBBox() );
|
|
|
|
|
|
|
|
// Check if the view bounding box will go out of bounds
|
|
|
|
VECTOR2D rotPos = viewBBox.GetPosition();
|
|
|
|
VECTOR2D rotEnd = viewBBox.GetEnd();
|
|
|
|
|
|
|
|
RotatePoint( &rotPos.x, &rotPos.y, refPt.x, refPt.y, rotateAngle );
|
|
|
|
RotatePoint( &rotEnd.x, &rotEnd.y, refPt.x, refPt.y, rotateAngle );
|
|
|
|
|
|
|
|
typedef std::numeric_limits<int> coord_limits;
|
|
|
|
|
2022-07-16 19:33:33 +00:00
|
|
|
int max = coord_limits::max() - COORDS_PADDING;
|
|
|
|
int min = -max;
|
2021-12-11 23:57:51 +00:00
|
|
|
|
|
|
|
bool outOfBounds = rotPos.x < min || rotPos.x > max || rotPos.y < min || rotPos.y > max
|
|
|
|
|| rotEnd.x < min || rotEnd.x > max || rotEnd.y < min || rotEnd.y > max;
|
|
|
|
|
|
|
|
if( !outOfBounds )
|
2013-12-18 13:33:34 +00:00
|
|
|
{
|
2021-12-11 23:57:51 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2023-07-15 16:37:17 +00:00
|
|
|
if( !item->IsNew() && !item->IsMoving() )
|
2023-06-27 15:52:50 +00:00
|
|
|
commit->Modify( item );
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2023-07-13 10:24:33 +00:00
|
|
|
if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item ) )
|
2023-10-29 11:23:52 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
board_item->Rotate( refPt, rotateAngle );
|
2023-10-29 11:23:52 +00:00
|
|
|
board_item->Normalize();
|
|
|
|
}
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( !localCommit.Empty() )
|
|
|
|
localCommit.Push( _( "Rotate" ) );
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
if( is_hover && !m_dragging )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2014-01-29 09:17:14 +00:00
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
2014-02-28 15:53:28 +00:00
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
if( m_dragging )
|
2023-06-27 15:52:50 +00:00
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::updateLocalRatsnest, VECTOR2I() );
|
2021-12-11 23:57:51 +00:00
|
|
|
}
|
2019-01-01 21:54:10 +00:00
|
|
|
|
2021-01-23 22:52:45 +00:00
|
|
|
// Restore the old reference so any mouse dragging that occurs doesn't make the selection jump
|
2020-12-23 23:06:17 +00:00
|
|
|
// to this now invalid reference
|
2021-01-24 19:37:48 +00:00
|
|
|
if( oldRefPt )
|
2021-01-23 22:52:45 +00:00
|
|
|
selection.SetReferencePoint( *oldRefPt );
|
|
|
|
else
|
|
|
|
selection.ClearReferencePoint();
|
2020-12-23 23:06:17 +00:00
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* Mirror a point about the vertical axis passing through another point.
|
2017-01-23 06:47:39 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
static VECTOR2I mirrorPointX( const VECTOR2I& aPoint, const VECTOR2I& aMirrorPoint )
|
2017-01-23 06:47:39 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I mirrored = aPoint;
|
2017-01-23 06:47:39 +00:00
|
|
|
|
|
|
|
mirrored.x -= aMirrorPoint.x;
|
|
|
|
mirrored.x = -mirrored.x;
|
|
|
|
mirrored.x += aMirrorPoint.x;
|
|
|
|
|
|
|
|
return mirrored;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-20 23:16:00 +00:00
|
|
|
/**
|
|
|
|
* Mirror a point about the vertical axis passing through another point.
|
|
|
|
*/
|
|
|
|
static VECTOR2I mirrorPointY( const VECTOR2I& aPoint, const VECTOR2I& aMirrorPoint )
|
|
|
|
{
|
|
|
|
VECTOR2I mirrored = aPoint;
|
|
|
|
|
|
|
|
mirrored.y -= aMirrorPoint.y;
|
|
|
|
mirrored.y = -mirrored.y;
|
|
|
|
mirrored.y += aMirrorPoint.y;
|
|
|
|
|
|
|
|
return mirrored;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-23 06:47:39 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Mirror a pad in the vertical axis passing through a point (mirror left to right).
|
2017-01-23 06:47:39 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
static void mirrorPadX( PAD& aPad, const VECTOR2I& aMirrorPoint )
|
2017-01-23 06:47:39 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad.GetShape() == PAD_SHAPE::CUSTOM )
|
2020-07-25 15:41:36 +00:00
|
|
|
aPad.FlipPrimitives( true ); // mirror primitives left to right
|
2019-01-17 04:55:40 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint );
|
2017-01-23 06:47:39 +00:00
|
|
|
aPad.SetPosition( tmpPt );
|
|
|
|
|
|
|
|
tmpPt = aPad.GetOffset();
|
|
|
|
tmpPt.x = -tmpPt.x;
|
|
|
|
aPad.SetOffset( tmpPt );
|
|
|
|
|
|
|
|
auto tmpz = aPad.GetDelta();
|
|
|
|
tmpz.x = -tmpz.x;
|
|
|
|
aPad.SetDelta( tmpz );
|
|
|
|
|
|
|
|
aPad.SetOrientation( -aPad.GetOrientation() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-20 23:16:00 +00:00
|
|
|
/**
|
|
|
|
* Mirror a pad in the vertical axis passing through a point (mirror left to right).
|
|
|
|
*/
|
|
|
|
static void mirrorPadY( PAD& aPad, const VECTOR2I& aMirrorPoint )
|
|
|
|
{
|
|
|
|
if( aPad.GetShape() == PAD_SHAPE::CUSTOM )
|
|
|
|
aPad.FlipPrimitives( false ); // mirror primitives top to bottom
|
|
|
|
|
|
|
|
VECTOR2I tmpPt = mirrorPointY( aPad.GetPosition(), aMirrorPoint );
|
|
|
|
aPad.SetPosition( tmpPt );
|
|
|
|
|
|
|
|
tmpPt = aPad.GetOffset();
|
|
|
|
tmpPt.y = -tmpPt.y;
|
|
|
|
aPad.SetOffset( tmpPt );
|
|
|
|
|
|
|
|
auto tmpz = aPad.GetDelta();
|
|
|
|
tmpz.y = -tmpz.y;
|
|
|
|
aPad.SetDelta( tmpz );
|
|
|
|
|
|
|
|
aPad.SetOrientation( -aPad.GetOrientation() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-27 19:18:13 +00:00
|
|
|
const std::vector<KICAD_T> EDIT_TOOL::MirrorableItems = {
|
|
|
|
PCB_SHAPE_T,
|
2023-06-06 15:09:34 +00:00
|
|
|
PCB_FIELD_T,
|
2022-12-27 19:18:13 +00:00
|
|
|
PCB_TEXT_T,
|
|
|
|
PCB_TEXTBOX_T,
|
|
|
|
PCB_ZONE_T,
|
|
|
|
PCB_PAD_T,
|
|
|
|
PCB_TRACE_T,
|
|
|
|
PCB_ARC_T,
|
|
|
|
PCB_VIA_T,
|
|
|
|
};
|
|
|
|
|
2017-01-23 06:47:39 +00:00
|
|
|
int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-08-05 15:01:10 +00:00
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT localCommit( this );
|
|
|
|
BOARD_COMMIT* commit = dynamic_cast<BOARD_COMMIT*>( aEvent.Commit() );
|
|
|
|
|
|
|
|
if( !commit )
|
|
|
|
commit = &localCommit;
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
2021-04-28 22:53:31 +00:00
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
2020-02-05 12:49:12 +00:00
|
|
|
},
|
2021-04-28 22:53:31 +00:00
|
|
|
!m_dragging /* prompt user regarding locked items */ );
|
2017-01-23 06:47:39 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
if( selection.Empty() )
|
2017-01-23 06:47:39 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-09-28 16:38:54 +00:00
|
|
|
updateModificationPoint( selection );
|
2022-09-20 23:16:00 +00:00
|
|
|
VECTOR2I mirrorPoint = selection.GetReferencePoint();
|
2017-01-23 06:47:39 +00:00
|
|
|
|
2022-09-20 23:16:00 +00:00
|
|
|
// Set the mirroring options.
|
2022-07-04 09:14:47 +00:00
|
|
|
// Unfortunately, the mirror function do not have the same parameter for all items
|
|
|
|
// So we need these 2 parameters to avoid mistakes
|
2022-09-20 23:16:00 +00:00
|
|
|
bool mirrorLeftRight = true;
|
|
|
|
bool mirrorAroundXaxis = false;
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::mirrorV ) )
|
|
|
|
{
|
|
|
|
mirrorLeftRight = false;
|
|
|
|
mirrorAroundXaxis = true;
|
|
|
|
}
|
2022-07-04 09:14:47 +00:00
|
|
|
|
2024-05-10 20:44:00 +00:00
|
|
|
std::vector<EDA_ITEM*> items;
|
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2024-05-10 20:44:00 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == PCB_GROUP_T )
|
|
|
|
{
|
|
|
|
static_cast<PCB_GROUP*>( item )->RunOnDescendants(
|
|
|
|
[&]( BOARD_ITEM* descendant )
|
|
|
|
{
|
|
|
|
items.push_back( descendant );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
items.push_back( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : items )
|
2017-01-23 06:47:39 +00:00
|
|
|
{
|
2022-12-27 19:18:13 +00:00
|
|
|
if( !item->IsType( MirrorableItems ) )
|
2017-01-23 06:47:39 +00:00
|
|
|
continue;
|
2022-12-27 19:18:13 +00:00
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
if( !item->IsNew() && !item->IsMoving() )
|
2023-06-27 15:52:50 +00:00
|
|
|
commit->Modify( item );
|
2017-01-23 06:47:39 +00:00
|
|
|
|
|
|
|
// modify each object as necessary
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2022-09-22 14:05:06 +00:00
|
|
|
case PCB_SHAPE_T:
|
|
|
|
static_cast<PCB_SHAPE*>( item )->Mirror( mirrorPoint, mirrorAroundXaxis );
|
2017-01-23 06:47:39 +00:00
|
|
|
break;
|
|
|
|
|
2022-09-22 14:05:06 +00:00
|
|
|
case PCB_ZONE_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
static_cast<ZONE*>( item )->Mirror( mirrorPoint, mirrorLeftRight );
|
2022-09-22 14:05:06 +00:00
|
|
|
break;
|
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2022-09-22 14:05:06 +00:00
|
|
|
case PCB_TEXT_T:
|
|
|
|
static_cast<PCB_TEXT*>( item )->Mirror( mirrorPoint, mirrorAroundXaxis );
|
2017-01-23 06:47:39 +00:00
|
|
|
break;
|
|
|
|
|
2022-09-22 14:05:06 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
|
|
|
static_cast<PCB_TEXTBOX*>( item )->Mirror( mirrorPoint, mirrorAroundXaxis );
|
|
|
|
break;
|
2022-09-20 23:16:00 +00:00
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
case PCB_TABLE_T:
|
|
|
|
// JEY TODO: tables
|
|
|
|
break;
|
|
|
|
|
2022-09-22 14:05:06 +00:00
|
|
|
case PCB_PAD_T:
|
2022-09-20 23:16:00 +00:00
|
|
|
if( mirrorLeftRight )
|
2022-09-22 14:05:06 +00:00
|
|
|
mirrorPadX( *static_cast<PAD*>( item ), mirrorPoint );
|
2022-09-20 23:16:00 +00:00
|
|
|
else
|
2022-09-22 14:05:06 +00:00
|
|
|
mirrorPadY( *static_cast<PAD*>( item ), mirrorPoint );
|
|
|
|
|
2017-01-23 06:47:39 +00:00
|
|
|
break;
|
|
|
|
|
2022-09-24 18:54:56 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_ARC_T:
|
|
|
|
case PCB_VIA_T:
|
|
|
|
static_cast<PCB_TRACK*>( item )->Mirror( mirrorPoint, mirrorAroundXaxis );
|
|
|
|
break;
|
|
|
|
|
2017-01-23 06:47:39 +00:00
|
|
|
default:
|
|
|
|
// it's likely the commit object is wrong if you get here
|
2024-05-10 20:44:00 +00:00
|
|
|
UNIMPLEMENTED_FOR( item->GetClass() );
|
2017-01-23 06:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( !localCommit.Empty() )
|
|
|
|
localCommit.Push( _( "Mirror" ) );
|
2017-01-23 06:47:39 +00:00
|
|
|
|
2017-08-07 08:02:07 +00:00
|
|
|
if( selection.IsHover() && !m_dragging )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2017-01-23 06:47:39 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
2017-01-23 06:47:39 +00:00
|
|
|
|
2019-01-01 21:54:10 +00:00
|
|
|
if( m_dragging )
|
2023-06-27 15:52:50 +00:00
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::updateLocalRatsnest, VECTOR2I() );
|
2019-01-01 21:54:10 +00:00
|
|
|
|
2017-01-23 06:47:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2023-11-21 23:43:48 +00:00
|
|
|
int EDIT_TOOL::JustifyText( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOARD_COMMIT localCommit( this );
|
|
|
|
BOARD_COMMIT* commit = dynamic_cast<BOARD_COMMIT*>( aEvent.Commit() );
|
|
|
|
|
|
|
|
if( !commit )
|
|
|
|
commit = &localCommit;
|
|
|
|
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
|
|
|
},
|
|
|
|
!m_dragging /* prompt user regarding locked items */ );
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
auto setJustify =
|
|
|
|
[&]( EDA_TEXT* aTextItem )
|
|
|
|
{
|
|
|
|
if( aEvent.Matches( ACTIONS::leftJustify.MakeEvent() ) )
|
|
|
|
aTextItem->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
|
|
|
else if( aEvent.Matches( ACTIONS::centerJustify.MakeEvent() ) )
|
|
|
|
aTextItem->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
else
|
|
|
|
aTextItem->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
|
|
|
};
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T )
|
|
|
|
{
|
|
|
|
if( !item->IsNew() && !item->IsMoving() )
|
|
|
|
commit->Modify( item );
|
|
|
|
|
|
|
|
setJustify( static_cast<PCB_TEXT*>( item ) );
|
|
|
|
}
|
|
|
|
else if( item->Type() == PCB_TEXTBOX_T )
|
|
|
|
{
|
|
|
|
if( !item->IsNew() && !item->IsMoving() )
|
|
|
|
commit->Modify( item );
|
|
|
|
|
|
|
|
setJustify( static_cast<PCB_TEXTBOX*>( item ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !localCommit.Empty() )
|
|
|
|
{
|
|
|
|
if( aEvent.Matches( ACTIONS::leftJustify.MakeEvent() ) )
|
|
|
|
localCommit.Push( _( "Left Justify" ) );
|
|
|
|
else if( aEvent.Matches( ACTIONS::centerJustify.MakeEvent() ) )
|
|
|
|
localCommit.Push( _( "Center Justify" ) );
|
|
|
|
else
|
|
|
|
localCommit.Push( _( "Right Justify" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( selection.IsHover() && !m_dragging )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
|
|
|
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
|
|
|
if( m_dragging )
|
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::updateLocalRatsnest, VECTOR2I() );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
|
2013-12-09 10:01:05 +00:00
|
|
|
{
|
2020-08-05 15:01:10 +00:00
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT localCommit( this );
|
|
|
|
BOARD_COMMIT* commit = dynamic_cast<BOARD_COMMIT*>( aEvent.Commit() );
|
|
|
|
|
|
|
|
if( !commit )
|
|
|
|
commit = &localCommit;
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
2021-04-28 22:53:31 +00:00
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
2024-01-15 17:29:55 +00:00
|
|
|
sTool->FilterCollectorForTableCells( aCollector );
|
2020-02-05 12:49:12 +00:00
|
|
|
},
|
2021-04-28 22:53:31 +00:00
|
|
|
!m_dragging /* prompt user regarding locked items */ );
|
2014-02-04 16:27:00 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
if( selection.Empty() )
|
2014-02-04 16:27:00 +00:00
|
|
|
return 0;
|
|
|
|
|
2022-08-25 22:50:47 +00:00
|
|
|
std::optional<VECTOR2I> oldRefPt;
|
2021-01-23 22:52:45 +00:00
|
|
|
|
|
|
|
if( selection.HasReferencePoint() )
|
|
|
|
oldRefPt = selection.GetReferencePoint();
|
|
|
|
|
2017-09-28 16:38:54 +00:00
|
|
|
updateModificationPoint( selection );
|
2019-09-17 08:06:39 +00:00
|
|
|
|
2019-10-01 10:01:40 +00:00
|
|
|
// Flip around the anchor for footprints, and the bounding box center for board items
|
2021-01-23 22:52:45 +00:00
|
|
|
VECTOR2I refPt = IsFootprintEditor() ? VECTOR2I( 0, 0 ) : selection.GetCenter();
|
2019-09-17 08:06:39 +00:00
|
|
|
|
2020-11-01 15:25:42 +00:00
|
|
|
// If only one item selected, flip around the selection or item anchor point (instead
|
|
|
|
// of the bounding box center) to avoid moving the item anchor
|
2019-09-17 08:06:39 +00:00
|
|
|
if( selection.GetSize() == 1 )
|
2023-11-06 13:29:12 +00:00
|
|
|
refPt = selection.GetReferencePoint();
|
2019-09-17 08:06:39 +00:00
|
|
|
|
2022-07-24 15:49:46 +00:00
|
|
|
bool leftRight = frame()->GetPcbNewSettings()->m_FlipLeftRight;
|
2014-02-04 16:27:00 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2013-12-18 13:33:34 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
2020-08-11 19:37:07 +00:00
|
|
|
{
|
2023-07-15 16:37:17 +00:00
|
|
|
if( !boardItem->IsNew() && !boardItem->IsMoving() )
|
2023-07-13 10:24:33 +00:00
|
|
|
commit->Modify( boardItem );
|
|
|
|
|
|
|
|
boardItem->Flip( refPt, leftRight );
|
2023-10-29 11:23:52 +00:00
|
|
|
boardItem->Normalize();
|
2023-07-13 10:24:33 +00:00
|
|
|
}
|
2013-12-09 10:01:05 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( !localCommit.Empty() )
|
|
|
|
localCommit.Push( _( "Change Side / Flip" ) );
|
2014-01-29 09:17:14 +00:00
|
|
|
|
2017-08-07 08:02:07 +00:00
|
|
|
if( selection.IsHover() && !m_dragging )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2014-02-04 16:27:00 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
2014-02-28 15:53:28 +00:00
|
|
|
|
2019-01-01 21:54:10 +00:00
|
|
|
if( m_dragging )
|
2023-06-27 15:52:50 +00:00
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::updateLocalRatsnest, VECTOR2I() );
|
2019-01-01 21:54:10 +00:00
|
|
|
|
2021-01-23 22:52:45 +00:00
|
|
|
// Restore the old reference so any mouse dragging that occurs doesn't make the selection jump
|
2020-12-23 23:06:17 +00:00
|
|
|
// to this now invalid reference
|
2021-01-24 19:37:48 +00:00
|
|
|
if( oldRefPt )
|
2021-01-23 22:52:45 +00:00
|
|
|
selection.SetReferencePoint( *oldRefPt );
|
|
|
|
else
|
|
|
|
selection.ClearReferencePoint();
|
2020-12-23 23:06:17 +00:00
|
|
|
|
2013-12-09 10:01:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-27 12:47:05 +00:00
|
|
|
void EDIT_TOOL::getChildItemsOfGroupsAndGenerators( EDA_ITEM* item,
|
|
|
|
std::unordered_set<BOARD_ITEM*>& children )
|
|
|
|
{
|
|
|
|
wxASSERT( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T );
|
|
|
|
|
|
|
|
std::unordered_set<BOARD_ITEM*>& childItems = static_cast<PCB_GROUP*>( item )->GetItems();
|
|
|
|
|
|
|
|
for( BOARD_ITEM* childItem : childItems )
|
|
|
|
{
|
|
|
|
children.insert( childItem );
|
|
|
|
|
|
|
|
if( childItem->Type() == PCB_GROUP_T || childItem->Type() == PCB_GENERATOR_T )
|
|
|
|
getChildItemsOfGroupsAndGenerators( childItem, children );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDIT_TOOL::removeNonRootItems( std::unordered_set<EDA_ITEM*>& items )
|
|
|
|
{
|
|
|
|
auto itr = items.begin();
|
|
|
|
|
|
|
|
while( itr != items.end() )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* curItem = dynamic_cast<BOARD_ITEM*>( *itr );
|
|
|
|
|
|
|
|
if( curItem )
|
|
|
|
{
|
|
|
|
if( curItem->Type() == PCB_GROUP_T || curItem->Type() == PCB_GENERATOR_T )
|
|
|
|
{
|
|
|
|
std::unordered_set<BOARD_ITEM*> childItems;
|
|
|
|
getChildItemsOfGroupsAndGenerators( curItem, childItems );
|
|
|
|
|
|
|
|
std::for_each( childItems.begin(), childItems.end(),
|
|
|
|
[&]( auto eraseItem )
|
|
|
|
{
|
|
|
|
items.erase( eraseItem );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++itr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-17 12:02:39 +00:00
|
|
|
void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
|
2013-12-09 10:01:05 +00:00
|
|
|
{
|
2024-04-17 17:29:45 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
|
|
|
BOARD_COMMIT commit( this );
|
2023-06-27 15:52:50 +00:00
|
|
|
|
2013-12-09 10:07:30 +00:00
|
|
|
// As we are about to remove items, they have to be removed from the selection first
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2024-03-27 12:47:05 +00:00
|
|
|
// Only delete items that are the root of a selected set (e.g. only delete grouped / generated
|
|
|
|
// items from the parent item, not individually) - issue #17527
|
|
|
|
std::unordered_set<EDA_ITEM*> rootItems( aItems.begin(), aItems.end() );
|
|
|
|
removeNonRootItems( rootItems );
|
|
|
|
|
2024-04-17 17:29:45 +00:00
|
|
|
int itemsDeleted = 0;
|
|
|
|
int fieldsHidden = 0;
|
|
|
|
int fieldsAlreadyHidden = 0;
|
|
|
|
|
2024-03-27 12:47:05 +00:00
|
|
|
for( EDA_ITEM* item : rootItems )
|
2018-09-15 23:30:10 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
|
|
|
|
wxCHECK2( board_item, continue );
|
|
|
|
|
|
|
|
FOOTPRINT* parentFP = board_item->GetParentFootprint();
|
2020-09-25 17:37:03 +00:00
|
|
|
|
2023-12-20 03:38:34 +00:00
|
|
|
if( board_item->GetParentGroup() )
|
2023-12-17 21:01:31 +00:00
|
|
|
commit.Stage( board_item, CHT_UNGROUP );
|
2018-09-15 23:30:10 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2024-04-17 17:29:45 +00:00
|
|
|
{
|
|
|
|
PCB_FIELD* field = static_cast<PCB_FIELD*>( board_item );
|
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
wxASSERT( parentFP );
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( parentFP );
|
2024-04-17 17:29:45 +00:00
|
|
|
|
|
|
|
if( field->IsVisible() )
|
|
|
|
{
|
|
|
|
field->SetVisible( false );
|
|
|
|
fieldsHidden++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fieldsAlreadyHidden++;
|
|
|
|
}
|
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
getView()->Update( board_item );
|
2018-09-15 23:30:10 +00:00
|
|
|
break;
|
2024-04-17 17:29:45 +00:00
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-06-06 17:30:03 +00:00
|
|
|
case PCB_TEXT_T:
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_SHAPE_T:
|
|
|
|
case PCB_TEXTBOX_T:
|
2024-01-15 17:29:55 +00:00
|
|
|
case PCB_TABLE_T:
|
2023-10-23 17:23:24 +00:00
|
|
|
case PCB_REFERENCE_IMAGE_T:
|
2023-07-09 18:02:56 +00:00
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2023-12-17 21:01:31 +00:00
|
|
|
commit.Remove( board_item );
|
2024-04-17 17:29:45 +00:00
|
|
|
itemsDeleted++;
|
2023-12-17 21:01:31 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
case PCB_TABLECELL_T:
|
|
|
|
// Clear contents of table cell
|
|
|
|
commit.Modify( board_item );
|
|
|
|
static_cast<PCB_TABLECELL*>( board_item )->SetText( wxEmptyString );
|
2024-04-17 17:29:45 +00:00
|
|
|
itemsDeleted++;
|
2024-01-15 17:29:55 +00:00
|
|
|
break;
|
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
case PCB_GROUP_T:
|
2024-01-07 12:57:22 +00:00
|
|
|
board_item->RunOnDescendants(
|
|
|
|
[&commit]( BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
commit.Stage( aItem, CHT_UNGROUP );
|
|
|
|
} );
|
|
|
|
|
|
|
|
board_item->RunOnDescendants(
|
|
|
|
[&commit]( BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
commit.Remove( aItem );
|
|
|
|
} );
|
2023-12-17 21:01:31 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
commit.Remove( board_item );
|
2024-04-17 17:29:45 +00:00
|
|
|
itemsDeleted++;
|
2023-01-31 10:16:38 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-17 12:56:17 +00:00
|
|
|
case PCB_PAD_T:
|
2022-07-24 15:49:46 +00:00
|
|
|
if( IsFootprintEditor() || frame()->GetPcbNewSettings()->m_AllowFreePads )
|
2021-07-29 12:59:30 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( parentFP );
|
2023-03-30 11:49:23 +00:00
|
|
|
getView()->Remove( board_item );
|
|
|
|
parentFP->Remove( board_item );
|
2024-04-17 17:29:45 +00:00
|
|
|
itemsDeleted++;
|
2021-07-29 12:59:30 +00:00
|
|
|
}
|
2019-12-17 12:56:17 +00:00
|
|
|
|
2020-06-14 14:04:15 +00:00
|
|
|
break;
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
case PCB_ZONE_T:
|
2023-12-02 20:06:42 +00:00
|
|
|
// We process the zones special so that cutouts can be deleted when the delete
|
|
|
|
// tool is called from inside a cutout when the zone is selected.
|
|
|
|
// Only interact with cutouts when deleting and a single item is selected
|
|
|
|
if( !aIsCut && aItems.GetSize() == 1 )
|
2020-04-14 16:57:18 +00:00
|
|
|
{
|
2023-12-02 20:06:42 +00:00
|
|
|
VECTOR2I curPos = getViewControls()->GetCursorPosition();
|
|
|
|
ZONE* zone = static_cast<ZONE*>( board_item );
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
int outlineIdx, holeIdx;
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
if( zone->HitTestCutout( curPos, &outlineIdx, &holeIdx ) )
|
|
|
|
{
|
|
|
|
// Remove the cutout
|
|
|
|
commit.Modify( zone );
|
|
|
|
zone->RemoveCutout( outlineIdx, holeIdx );
|
|
|
|
zone->UnFill();
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
// TODO Refill zone when KiCad supports auto re-fill
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
// Update the display
|
|
|
|
zone->HatchBorder();
|
|
|
|
canvas()->Refresh();
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
// Restore the selection on the original zone
|
|
|
|
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, zone );
|
2020-04-14 16:57:18 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-12-02 20:06:42 +00:00
|
|
|
// Remove the entire zone otherwise
|
|
|
|
commit.Remove( board_item );
|
2024-04-17 17:29:45 +00:00
|
|
|
itemsDeleted++;
|
2020-08-11 19:37:07 +00:00
|
|
|
break;
|
|
|
|
|
2023-10-06 17:04:00 +00:00
|
|
|
case PCB_GENERATOR_T:
|
2024-03-27 12:47:05 +00:00
|
|
|
if( rootItems.size() == 1 )
|
2023-11-09 13:55:00 +00:00
|
|
|
{
|
|
|
|
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( board_item );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genRemove, &commit,
|
|
|
|
generator );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-02 18:00:25 +00:00
|
|
|
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( board_item );
|
|
|
|
|
|
|
|
for( BOARD_ITEM* member : generator->GetItems() )
|
2023-12-17 21:01:31 +00:00
|
|
|
commit.Stage( member, CHT_UNGROUP );
|
|
|
|
|
2024-01-02 18:00:25 +00:00
|
|
|
for( BOARD_ITEM* member : generator->GetItems() )
|
|
|
|
commit.Remove( member );
|
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
commit.Remove( board_item );
|
|
|
|
}
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2024-04-17 17:29:45 +00:00
|
|
|
itemsDeleted++;
|
2023-10-06 17:04:00 +00:00
|
|
|
break;
|
|
|
|
|
2018-09-15 23:30:10 +00:00
|
|
|
default:
|
2024-02-28 21:23:20 +00:00
|
|
|
wxASSERT_MSG( parentFP == nullptr, wxT( "Try to delete an item living in a footprint" ) );
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Remove( board_item );
|
2024-04-18 22:37:37 +00:00
|
|
|
itemsDeleted++;
|
2018-09-15 23:30:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-02-18 00:10:20 +00:00
|
|
|
|
2020-09-25 17:37:03 +00:00
|
|
|
// If the entered group has been emptied then leave it.
|
2020-08-12 11:23:30 +00:00
|
|
|
PCB_GROUP* enteredGroup = m_selectionTool->GetEnteredGroup();
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2020-09-25 17:37:03 +00:00
|
|
|
if( enteredGroup && enteredGroup->GetItems().empty() )
|
|
|
|
m_selectionTool->ExitGroup();
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2022-10-17 12:02:39 +00:00
|
|
|
if( aIsCut )
|
2024-04-17 17:29:45 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Cut" ) );
|
2024-04-17 17:29:45 +00:00
|
|
|
}
|
|
|
|
else if( itemsDeleted == 0 )
|
|
|
|
{
|
|
|
|
if( fieldsHidden == 1 )
|
|
|
|
commit.Push( _( "Hide Field" ) );
|
|
|
|
else if( fieldsHidden > 1 )
|
|
|
|
commit.Push( _( "Hide Fields" ) );
|
|
|
|
else if( fieldsAlreadyHidden > 0 )
|
|
|
|
editFrame->ShowInfoBarError( _( "Use the Footprint Properties dialog to remove fields." ) );
|
|
|
|
}
|
2019-01-12 01:27:29 +00:00
|
|
|
else
|
2024-04-17 17:29:45 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Delete" ) );
|
2024-04-17 17:29:45 +00:00
|
|
|
}
|
2022-10-17 12:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
|
|
|
|
|
|
|
editFrame->PushTool( aEvent );
|
|
|
|
|
|
|
|
std::vector<BOARD_ITEM*> lockedItems;
|
|
|
|
Activate();
|
|
|
|
|
|
|
|
// get a copy instead of reference (as we're going to clear the selection before removing items)
|
|
|
|
PCB_SELECTION selectionCopy;
|
|
|
|
bool isCut = aEvent.Parameter<PCB_ACTIONS::REMOVE_FLAGS>() == PCB_ACTIONS::REMOVE_FLAGS::CUT;
|
|
|
|
bool isAlt = aEvent.Parameter<PCB_ACTIONS::REMOVE_FLAGS>() == PCB_ACTIONS::REMOVE_FLAGS::ALT;
|
|
|
|
|
|
|
|
// If we are in a "Cut" operation, then the copied selection exists already and we want to
|
|
|
|
// delete exactly that; no more, no fewer. Any filtering for locked items must be done in
|
|
|
|
// the copyToClipboard() routine.
|
|
|
|
if( isCut )
|
|
|
|
{
|
|
|
|
selectionCopy = m_selectionTool->GetSelection();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// When not in free-pad mode we normally auto-promote selected pads to their parent
|
|
|
|
// footprints. But this is probably a little too dangerous for a destructive operation,
|
|
|
|
// so we just do the promotion but not the deletion (allowing for a second delete to do
|
|
|
|
// it if that's what the user wanted).
|
|
|
|
selectionCopy = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
} );
|
|
|
|
|
|
|
|
size_t beforeFPCount = selectionCopy.CountType( PCB_FOOTPRINT_T );
|
|
|
|
|
|
|
|
m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
|
|
|
} );
|
|
|
|
|
|
|
|
if( !selectionCopy.IsHover()
|
|
|
|
&& m_selectionTool->GetSelection().CountType( PCB_FOOTPRINT_T ) > beforeFPCount )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
canvas()->Refresh();
|
|
|
|
editFrame->PopTool( aEvent );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In "alternative" mode, we expand selected track items to their full connection.
|
|
|
|
if( isAlt && ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
|
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectConnection );
|
2022-10-17 12:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Finally run RequestSelection() one more time to find out what user wants to do about
|
|
|
|
// locked objects.
|
|
|
|
selectionCopy = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteItems( selectionCopy, isCut );
|
2023-06-10 20:11:05 +00:00
|
|
|
canvas()->Refresh();
|
2013-12-09 10:01:05 +00:00
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
editFrame->PopTool( aEvent );
|
2016-06-21 15:06:28 +00:00
|
|
|
return 0;
|
2013-12-09 10:01:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-18 19:27:00 +00:00
|
|
|
int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2020-08-05 15:01:10 +00:00
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
const PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
2021-04-28 22:53:31 +00:00
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2024-01-15 17:29:55 +00:00
|
|
|
sTool->FilterCollectorForTableCells( aCollector );
|
2020-12-10 01:33:24 +00:00
|
|
|
},
|
2021-04-28 22:53:31 +00:00
|
|
|
true /* prompt user regarding locked items */ );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
if( selection.Empty() )
|
2015-02-12 03:22:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2022-01-16 01:06:25 +00:00
|
|
|
VECTOR2I translation;
|
|
|
|
EDA_ANGLE rotation;
|
2018-06-12 07:36:35 +00:00
|
|
|
ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
|
|
|
|
: ROTATE_AROUND_ITEM_ANCHOR;
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2019-06-20 13:28:51 +00:00
|
|
|
// TODO: Implement a visible bounding border at the edge
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I sel_box = selection.GetBoundingBox();
|
2019-06-20 13:28:51 +00:00
|
|
|
|
2020-07-01 12:28:10 +00:00
|
|
|
DIALOG_MOVE_EXACT dialog( frame(), translation, rotation, rotationAnchor, sel_box );
|
2015-02-12 03:22:24 +00:00
|
|
|
int ret = dialog.ShowModal();
|
|
|
|
|
2015-02-22 14:43:44 +00:00
|
|
|
if( ret == wxID_OK )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
EDA_ANGLE angle = rotation;
|
|
|
|
VECTOR2I rp = selection.GetCenter();
|
|
|
|
VECTOR2I selCenter( rp.x, rp.y );
|
2017-04-22 20:07:29 +00:00
|
|
|
|
|
|
|
// Make sure the rotation is from the right reference point
|
2018-06-12 07:36:35 +00:00
|
|
|
selCenter += translation;
|
2017-04-22 20:07:29 +00:00
|
|
|
|
2022-07-24 15:49:46 +00:00
|
|
|
if( !frame()->GetPcbNewSettings()->m_Display.m_DisplayInvertYAxis )
|
2022-01-16 01:06:25 +00:00
|
|
|
rotation = -rotation;
|
2021-10-02 23:02:53 +00:00
|
|
|
|
2023-07-13 10:24:33 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
|
|
|
|
|
|
|
|
wxCHECK2( boardItem, continue );
|
2018-06-12 07:36:35 +00:00
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
if( !boardItem->IsNew() )
|
2023-07-13 10:24:33 +00:00
|
|
|
commit.Modify( boardItem );
|
2018-06-11 23:41:24 +00:00
|
|
|
|
2023-07-13 10:24:33 +00:00
|
|
|
if( !boardItem->GetParent() || !boardItem->GetParent()->IsSelected() )
|
|
|
|
boardItem->Move( translation );
|
2018-06-12 07:36:35 +00:00
|
|
|
|
|
|
|
switch( rotationAnchor )
|
|
|
|
{
|
|
|
|
case ROTATE_AROUND_ITEM_ANCHOR:
|
2023-07-13 10:24:33 +00:00
|
|
|
boardItem->Rotate( boardItem->GetPosition(), angle );
|
2018-06-12 07:36:35 +00:00
|
|
|
break;
|
2023-12-22 21:20:36 +00:00
|
|
|
case ROTATE_AROUND_SEL_CENTER:
|
|
|
|
boardItem->Rotate( selCenter, angle );
|
2018-06-12 07:36:35 +00:00
|
|
|
break;
|
|
|
|
case ROTATE_AROUND_USER_ORIGIN:
|
2023-07-13 10:24:33 +00:00
|
|
|
boardItem->Rotate( frame()->GetScreen()->m_LocalOrigin, angle );
|
2018-06-12 07:36:35 +00:00
|
|
|
break;
|
|
|
|
case ROTATE_AROUND_AUX_ORIGIN:
|
2023-07-13 10:24:33 +00:00
|
|
|
boardItem->Rotate( board()->GetDesignSettings().GetAuxOrigin(), angle );
|
2018-06-12 07:36:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-04-22 20:07:29 +00:00
|
|
|
|
|
|
|
if( !m_dragging )
|
2023-07-13 10:24:33 +00:00
|
|
|
getView()->Update( boardItem );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
2024-02-03 13:43:41 +00:00
|
|
|
commit.Push( _( "Move Exactly" ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
if( selection.IsHover() )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
2019-01-01 21:54:10 +00:00
|
|
|
|
|
|
|
if( m_dragging )
|
2023-06-27 15:52:50 +00:00
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::updateLocalRatsnest, VECTOR2I() );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-18 19:27:00 +00:00
|
|
|
int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2020-08-05 15:01:10 +00:00
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
// Be sure that there is at least one item that we can modify
|
2021-04-03 18:08:04 +00:00
|
|
|
const PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
2021-01-09 03:43:13 +00:00
|
|
|
[]( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
2023-09-03 21:04:00 +00:00
|
|
|
sTool->FilterCollectorForFreePads( aCollector, true );
|
2021-12-08 13:07:18 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
2021-04-28 22:53:31 +00:00
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2024-01-15 17:29:55 +00:00
|
|
|
sTool->FilterCollectorForTableCells( aCollector );
|
2021-01-09 03:43:13 +00:00
|
|
|
} );
|
2017-03-03 12:42:28 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
2015-02-12 03:22:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2024-02-20 02:35:29 +00:00
|
|
|
// Duplicating tuhing patterns alone is not supported
|
|
|
|
if( selection.Size() == 1 && selection.CountType( PCB_GENERATOR_T ) )
|
|
|
|
return 0;
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
// we have a selection to work on now, so start the tool process
|
2016-05-25 09:52:43 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2019-11-01 02:57:13 +00:00
|
|
|
// If the selection was given a hover, we do not keep the selection after completion
|
|
|
|
bool is_hover = selection.IsHover();
|
|
|
|
|
2017-06-12 09:16:30 +00:00
|
|
|
std::vector<BOARD_ITEM*> new_items;
|
|
|
|
new_items.reserve( selection.Size() );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2017-06-12 09:16:30 +00:00
|
|
|
// Each selected item is duplicated and pushed to new_items list
|
|
|
|
// Old selection is cleared, and new items are then selected.
|
2019-05-05 10:33:34 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2020-08-11 19:37:07 +00:00
|
|
|
BOARD_ITEM* dupe_item = nullptr;
|
2023-07-13 10:24:33 +00:00
|
|
|
BOARD_ITEM* orig_item = dynamic_cast<BOARD_ITEM*>( item );
|
|
|
|
|
|
|
|
wxCHECK2( orig_item, continue );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* parentFootprint = editFrame->GetBoard()->GetFirstFootprint();
|
2024-01-16 15:23:12 +00:00
|
|
|
|
|
|
|
// PCB_FIELD items are specific items (not only graphic, but are properies )
|
|
|
|
// and cannot be duplicated like other footprint items. So skip it:
|
|
|
|
if( orig_item->Type() == PCB_FIELD_T )
|
|
|
|
{
|
|
|
|
orig_item->ClearSelected();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
dupe_item = parentFootprint->DuplicateItem( orig_item );
|
2020-05-03 07:59:05 +00:00
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
if( increment && dupe_item->Type() == PCB_PAD_T
|
|
|
|
&& static_cast<PAD*>( dupe_item )->CanHaveNumber() )
|
2020-05-03 07:59:05 +00:00
|
|
|
{
|
2020-06-27 11:57:40 +00:00
|
|
|
PAD_TOOL* padTool = m_toolMgr->GetTool<PAD_TOOL>();
|
2021-08-23 23:10:21 +00:00
|
|
|
wxString padNumber = padTool->GetLastPadNumber();
|
|
|
|
padNumber = parentFootprint->GetNextPadNumber( padNumber );
|
|
|
|
padTool->SetLastPadNumber( padNumber );
|
|
|
|
static_cast<PAD*>( dupe_item )->SetNumber( padNumber );
|
2020-05-03 07:59:05 +00:00
|
|
|
}
|
2024-01-16 15:23:12 +00:00
|
|
|
|
|
|
|
dupe_item->ClearSelected();
|
|
|
|
new_items.push_back( dupe_item );
|
|
|
|
commit.Add( dupe_item );
|
2020-02-05 12:49:12 +00:00
|
|
|
}
|
2023-09-07 14:29:36 +00:00
|
|
|
else if( /*FOOTPRINT* parentFootprint =*/ orig_item->GetParentFootprint() )
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2023-09-03 21:04:00 +00:00
|
|
|
// No sub-footprint modifications allowed outside of footprint editor
|
2023-09-07 14:29:36 +00:00
|
|
|
// and parentFootprint is not (yet?) used
|
2020-02-05 12:49:12 +00:00
|
|
|
}
|
2015-02-18 19:29:52 +00:00
|
|
|
else
|
2020-02-05 12:49:12 +00:00
|
|
|
{
|
2020-02-20 12:11:04 +00:00
|
|
|
switch( orig_item->Type() )
|
|
|
|
{
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2020-02-20 12:11:04 +00:00
|
|
|
case PCB_TEXT_T:
|
2022-01-30 10:52:52 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
2023-10-23 17:23:24 +00:00
|
|
|
case PCB_REFERENCE_IMAGE_T:
|
2020-10-04 14:19:33 +00:00
|
|
|
case PCB_SHAPE_T:
|
2020-02-20 12:11:04 +00:00
|
|
|
case PCB_TRACE_T:
|
2021-03-18 10:38:33 +00:00
|
|
|
case PCB_ARC_T:
|
2020-02-20 12:11:04 +00:00
|
|
|
case PCB_VIA_T:
|
2020-11-11 23:05:59 +00:00
|
|
|
case PCB_ZONE_T:
|
2020-02-20 12:11:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_CENTER_T:
|
2021-07-13 18:46:33 +00:00
|
|
|
case PCB_DIM_RADIAL_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_LEADER_T:
|
2020-02-20 12:11:04 +00:00
|
|
|
dupe_item = orig_item->Duplicate();
|
2024-01-07 12:57:22 +00:00
|
|
|
|
|
|
|
// Clear the selection flag here, otherwise the PCB_SELECTION_TOOL
|
|
|
|
// will not properly select it later on
|
|
|
|
dupe_item->ClearSelected();
|
|
|
|
|
|
|
|
new_items.push_back( dupe_item );
|
|
|
|
commit.Add( dupe_item );
|
2020-02-20 12:11:04 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
case PCB_TABLE_T:
|
|
|
|
// JEY TODO: tables
|
|
|
|
break;
|
|
|
|
|
2024-01-07 12:57:22 +00:00
|
|
|
case PCB_GENERATOR_T:
|
2020-08-11 19:37:07 +00:00
|
|
|
case PCB_GROUP_T:
|
2020-08-12 11:23:30 +00:00
|
|
|
dupe_item = static_cast<PCB_GROUP*>( orig_item )->DeepDuplicate();
|
2024-01-07 12:57:22 +00:00
|
|
|
|
|
|
|
dupe_item->RunOnDescendants(
|
|
|
|
[&]( BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
aItem->ClearSelected();
|
|
|
|
new_items.push_back( aItem );
|
|
|
|
commit.Add( aItem );
|
|
|
|
} );
|
|
|
|
|
|
|
|
dupe_item->ClearSelected();
|
|
|
|
new_items.push_back( dupe_item );
|
|
|
|
commit.Add( dupe_item );
|
2020-08-11 19:37:07 +00:00
|
|
|
break;
|
2020-08-15 00:33:27 +00:00
|
|
|
|
2020-02-20 12:11:04 +00:00
|
|
|
default:
|
2022-02-05 13:25:43 +00:00
|
|
|
wxASSERT_MSG( false, wxString::Format( wxT( "Unhandled item type %d" ),
|
2021-04-28 22:53:31 +00:00
|
|
|
orig_item->Type() ) );
|
2020-02-20 12:11:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-02-05 12:49:12 +00:00
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
2017-06-12 09:16:30 +00:00
|
|
|
// Clear the old selection first
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2017-06-12 09:16:30 +00:00
|
|
|
|
|
|
|
// Select the new items
|
2023-06-16 21:28:15 +00:00
|
|
|
EDA_ITEMS nItems( new_items.begin(), new_items.end() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction<EDA_ITEMS*>( PCB_ACTIONS::selectItems, &nItems );
|
2017-06-12 09:16:30 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
// record the new items as added
|
2016-06-08 09:24:46 +00:00
|
|
|
if( !selection.Empty() )
|
2016-03-18 11:15:50 +00:00
|
|
|
{
|
|
|
|
editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
|
2019-05-05 10:33:34 +00:00
|
|
|
(int) new_items.size() ) );
|
2018-03-05 13:52:09 +00:00
|
|
|
|
2016-03-18 11:15:50 +00:00
|
|
|
// If items were duplicated, pick them up
|
2024-02-15 13:06:55 +00:00
|
|
|
if( doMoveSelection( aEvent, &commit, true ) )
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Duplicate" ) );
|
|
|
|
else
|
|
|
|
commit.Revert();
|
2019-11-01 02:57:13 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
// Deselect the duplicated item if we originally started as a hover selection
|
2021-04-03 18:08:04 +00:00
|
|
|
if( is_hover )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2016-03-18 11:15:50 +00:00
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
return 0;
|
2017-04-19 12:15:11 +00:00
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
|
2016-04-02 12:52:29 +00:00
|
|
|
int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-08-05 15:01:10 +00:00
|
|
|
if( isRouterActive() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-01-09 03:43:13 +00:00
|
|
|
// Be sure that there is at least one item that we can modify
|
2021-09-09 20:49:16 +00:00
|
|
|
const PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
|
|
|
} );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2017-03-03 12:42:28 +00:00
|
|
|
if( selection.Empty() )
|
2016-05-11 09:18:27 +00:00
|
|
|
return 0;
|
2016-03-07 07:13:06 +00:00
|
|
|
|
2016-04-02 12:52:29 +00:00
|
|
|
// we have a selection to work on now, so start the tool process
|
|
|
|
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
|
2021-10-24 19:59:19 +00:00
|
|
|
ARRAY_CREATOR array_creator( *editFrame, m_isFootprintEditor, selection, m_toolMgr );
|
2016-04-02 12:52:29 +00:00
|
|
|
array_creator.Invoke();
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void EDIT_TOOL::PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
|
|
|
|
PCB_SELECTION_TOOL* sTool )
|
2019-01-09 01:17:49 +00:00
|
|
|
{
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
|
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
if( aCollector[i]->Type() != PCB_PAD_T )
|
2019-01-09 01:17:49 +00:00
|
|
|
aCollector.Remove( i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-02 00:10:56 +00:00
|
|
|
void EDIT_TOOL::FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* sTool )
|
2018-01-05 23:44:37 +00:00
|
|
|
{
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
|
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
if( aCollector[i]->Type() != PCB_FOOTPRINT_T )
|
2018-01-05 23:44:37 +00:00
|
|
|
aCollector.Remove( i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
bool EDIT_TOOL::updateModificationPoint( PCB_SELECTION& aSelection )
|
2014-02-04 16:27:00 +00:00
|
|
|
{
|
2022-01-01 23:28:25 +00:00
|
|
|
// Can't modify an empty group
|
|
|
|
if( aSelection.Empty() )
|
|
|
|
return false;
|
|
|
|
|
2024-02-15 13:06:55 +00:00
|
|
|
if( ( m_dragging || aSelection[0]->IsMoving() ) && aSelection.HasReferencePoint() )
|
|
|
|
return false;
|
|
|
|
|
2018-04-19 14:55:40 +00:00
|
|
|
// When there is only one item selected, the reference point is its position...
|
2024-03-09 19:19:47 +00:00
|
|
|
if( aSelection.Size() == 1 && aSelection.Front()->Type() != PCB_TABLE_T )
|
2014-02-04 16:27:00 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
if( BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aSelection.Front() ) )
|
|
|
|
aSelection.SetReferencePoint( item->GetPosition() );
|
2014-02-04 16:27:00 +00:00
|
|
|
}
|
2021-05-04 00:04:24 +00:00
|
|
|
// ...otherwise modify items with regard to the grid-snapped center position
|
2014-02-04 16:27:00 +00:00
|
|
|
else
|
|
|
|
{
|
2021-05-04 00:04:24 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
|
2024-05-17 17:30:45 +00:00
|
|
|
VECTOR2I refPt = aSelection.GetCenter();
|
|
|
|
|
|
|
|
// Exclude text in the footprint editor if there's anything else selected
|
|
|
|
if( m_isFootprintEditor )
|
|
|
|
{
|
|
|
|
BOX2I nonFieldsBBox;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : aSelection.Items() )
|
|
|
|
{
|
|
|
|
if( !item->IsType( { PCB_TEXT_T, PCB_FIELD_T } ) )
|
|
|
|
nonFieldsBBox.Merge( item->GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nonFieldsBBox.IsValid() )
|
|
|
|
refPt = nonFieldsBBox.GetCenter();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSelection.SetReferencePoint( grid.BestSnapAnchor( refPt, nullptr ) );
|
2014-02-04 16:27:00 +00:00
|
|
|
}
|
2017-09-28 16:38:54 +00:00
|
|
|
|
|
|
|
return true;
|
2014-02-04 16:27:00 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
|
2020-07-05 21:36:12 +00:00
|
|
|
bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage,
|
|
|
|
const wxString& aCanceledMessage, VECTOR2I& aReferencePoint )
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
2022-08-25 22:50:47 +00:00
|
|
|
std::optional<VECTOR2I> pickedPoint;
|
2020-12-16 13:31:32 +00:00
|
|
|
bool done = false;
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->SetText( aTooltip );
|
2019-07-09 14:01:43 +00:00
|
|
|
|
2021-10-10 15:52:35 +00:00
|
|
|
/// This allow the option of snapping in the tool
|
|
|
|
picker->SetSnapping( true );
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetClickHandler(
|
2020-07-05 21:36:12 +00:00
|
|
|
[&]( const VECTOR2D& aPoint ) -> bool
|
|
|
|
{
|
|
|
|
pickedPoint = aPoint;
|
|
|
|
|
|
|
|
if( !aSuccessMessage.empty() )
|
|
|
|
{
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->SetText( aSuccessMessage );
|
|
|
|
m_statusPopup->Expire( 800 );
|
2020-07-05 21:36:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->Hide();
|
2020-07-05 21:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false; // we don't need any more points
|
|
|
|
} );
|
2019-07-15 23:44:01 +00:00
|
|
|
|
|
|
|
picker->SetMotionHandler(
|
2020-07-05 21:36:12 +00:00
|
|
|
[&]( const VECTOR2D& aPos )
|
|
|
|
{
|
2023-09-18 03:13:09 +00:00
|
|
|
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, -50 ) );
|
2020-07-05 21:36:12 +00:00
|
|
|
} );
|
2019-07-15 23:44:01 +00:00
|
|
|
|
|
|
|
picker->SetCancelHandler(
|
2020-07-05 21:36:12 +00:00
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
if( !aCanceledMessage.empty() )
|
|
|
|
{
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->SetText( aCanceledMessage );
|
|
|
|
m_statusPopup->Expire( 800 );
|
2020-07-05 21:36:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->Hide();
|
2020-07-05 21:36:12 +00:00
|
|
|
}
|
|
|
|
} );
|
2019-07-17 20:19:23 +00:00
|
|
|
|
|
|
|
picker->SetFinalizeHandler(
|
2020-07-05 21:36:12 +00:00
|
|
|
[&]( const int& aFinalState )
|
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
} );
|
2018-08-22 18:05:40 +00:00
|
|
|
|
2023-09-18 03:13:09 +00:00
|
|
|
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, -50 ) );
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->Popup();
|
2022-09-04 20:04:17 +00:00
|
|
|
canvas()->SetStatusPopup( m_statusPopup->GetPanel() );
|
2018-08-22 18:05:40 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerSubTool );
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2019-07-17 20:19:23 +00:00
|
|
|
while( !done )
|
2020-10-27 00:32:41 +00:00
|
|
|
{
|
|
|
|
// Pass events unless we receive a null event, then we must shut down
|
|
|
|
if( TOOL_EVENT* evt = Wait() )
|
|
|
|
evt->SetPassEvent();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2019-07-17 20:19:23 +00:00
|
|
|
|
2020-01-31 15:41:47 +00:00
|
|
|
// Ensure statusPopup is hidden after use and before deleting it:
|
2022-09-04 20:04:17 +00:00
|
|
|
canvas()->SetStatusPopup( nullptr );
|
2020-09-21 20:22:45 +00:00
|
|
|
m_statusPopup->Hide();
|
2020-01-31 15:41:47 +00:00
|
|
|
|
2022-08-25 22:50:47 +00:00
|
|
|
if( pickedPoint )
|
2022-08-30 20:58:43 +00:00
|
|
|
aReferencePoint = *pickedPoint;
|
2019-07-17 20:19:23 +00:00
|
|
|
|
2022-08-25 22:50:47 +00:00
|
|
|
return pickedPoint.has_value();
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
2017-10-02 06:49:25 +00:00
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
2017-09-17 17:49:06 +00:00
|
|
|
{
|
|
|
|
CLIPBOARD_IO io;
|
2021-07-19 23:56:05 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr,
|
|
|
|
getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
|
2022-09-14 17:31:56 +00:00
|
|
|
TOOL_EVENT selectReferencePoint( aEvent.Category(), aEvent.Action(),
|
|
|
|
"pcbnew.InteractiveEdit.selectReferencePoint",
|
|
|
|
TOOL_ACTION_SCOPE::AS_GLOBAL );
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
frame()->PushTool( selectReferencePoint );
|
2017-09-22 15:17:38 +00:00
|
|
|
Activate();
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
2020-09-29 00:35:31 +00:00
|
|
|
{
|
2021-02-22 00:59:16 +00:00
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = aCollector[i];
|
|
|
|
|
|
|
|
// We can't copy both a footprint and its text in the same operation, so if
|
|
|
|
// both are selected, remove the text
|
2023-06-06 15:09:34 +00:00
|
|
|
if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T )
|
|
|
|
&& aCollector.HasItem( item->GetParentFootprint() ) )
|
|
|
|
{
|
2021-02-22 00:59:16 +00:00
|
|
|
aCollector.Remove( item );
|
2023-06-06 15:09:34 +00:00
|
|
|
}
|
2023-12-11 22:22:19 +00:00
|
|
|
else if( item->Type() == PCB_MARKER_T )
|
|
|
|
{
|
|
|
|
// Don't allow copying marker objects
|
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
2021-02-22 00:59:16 +00:00
|
|
|
}
|
2020-12-15 22:32:02 +00:00
|
|
|
},
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
// Prompt user regarding locked items.
|
|
|
|
aEvent.IsAction( &ACTIONS::cut ) && !m_isFootprintEditor );
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2020-08-24 21:44:34 +00:00
|
|
|
if( !selection.Empty() )
|
|
|
|
{
|
2020-09-21 20:22:45 +00:00
|
|
|
std::vector<BOARD_ITEM*> items;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
2023-07-13 10:24:33 +00:00
|
|
|
{
|
|
|
|
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
|
|
|
items.push_back( boardItem );
|
|
|
|
}
|
2020-09-21 20:22:45 +00:00
|
|
|
|
2020-10-25 21:09:32 +00:00
|
|
|
VECTOR2I refPoint;
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::copyWithReference ) )
|
|
|
|
{
|
|
|
|
if( !pickReferencePoint( _( "Select reference point for the copy..." ),
|
|
|
|
_( "Selection copied" ),
|
2021-07-19 23:56:05 +00:00
|
|
|
_( "Copy canceled" ),
|
2020-10-25 21:09:32 +00:00
|
|
|
refPoint ) )
|
2021-10-10 15:30:27 +00:00
|
|
|
{
|
2022-09-14 17:31:56 +00:00
|
|
|
frame()->PopTool( selectReferencePoint );
|
2020-10-25 21:09:32 +00:00
|
|
|
return 0;
|
2021-10-10 15:30:27 +00:00
|
|
|
}
|
2020-10-25 21:09:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-13 21:43:09 +00:00
|
|
|
refPoint = grid.BestDragOrigin( getViewControls()->GetCursorPosition(), items );
|
2020-10-25 21:09:32 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 20:22:45 +00:00
|
|
|
selection.SetReferencePoint( refPoint );
|
|
|
|
|
|
|
|
io.SetBoard( board() );
|
2020-11-07 17:50:22 +00:00
|
|
|
io.SaveSelection( selection, m_isFootprintEditor );
|
2020-09-26 23:26:18 +00:00
|
|
|
frame()->SetStatusText( _( "Selection copied" ) );
|
2020-08-24 21:44:34 +00:00
|
|
|
}
|
2017-09-17 17:49:06 +00:00
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
frame()->PopTool( selectReferencePoint );
|
2017-09-17 17:49:06 +00:00
|
|
|
|
2023-01-19 14:44:23 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_selectionTool->ClearSelection();
|
|
|
|
|
2017-09-17 17:49:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-02 06:49:25 +00:00
|
|
|
|
2017-09-17 17:49:06 +00:00
|
|
|
int EDIT_TOOL::cutToClipboard( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2018-04-04 22:03:34 +00:00
|
|
|
if( !copyToClipboard( aEvent ) )
|
2019-01-12 01:27:29 +00:00
|
|
|
{
|
2020-12-02 00:10:56 +00:00
|
|
|
// N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items
|
|
|
|
// that were copied to the clipboard, no more, no fewer. Filtering for locked item, if
|
|
|
|
// any will be done in the copyToClipboard() routine
|
2022-09-14 17:31:56 +00:00
|
|
|
TOOL_EVENT evt = aEvent;
|
2019-01-12 01:27:29 +00:00
|
|
|
evt.SetParameter( PCB_ACTIONS::REMOVE_FLAGS::CUT );
|
|
|
|
Remove( evt );
|
|
|
|
}
|
2018-04-04 22:03:34 +00:00
|
|
|
|
2017-09-17 17:49:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2019-05-14 19:21:10 +00:00
|
|
|
|
|
|
|
|
2022-11-30 14:11:03 +00:00
|
|
|
void EDIT_TOOL::rebuildConnectivity()
|
|
|
|
{
|
|
|
|
board()->BuildConnectivity();
|
|
|
|
m_toolMgr->PostEvent( EVENTS::ConnectivityChangedEvent );
|
|
|
|
canvas()->RedrawRatsnest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
void EDIT_TOOL::setTransitions()
|
|
|
|
{
|
2022-09-27 13:30:17 +00:00
|
|
|
Go( &EDIT_TOOL::GetAndPlace, PCB_ACTIONS::getAndPlace.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Move, PCB_ACTIONS::move.MakeEvent() );
|
2022-11-13 13:14:18 +00:00
|
|
|
Go( &EDIT_TOOL::Move, PCB_ACTIONS::moveIndividually.MakeEvent() );
|
2022-09-27 13:30:17 +00:00
|
|
|
Go( &EDIT_TOOL::Drag, PCB_ACTIONS::drag45Degree.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Drag, PCB_ACTIONS::dragFreeAngle.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Remove, ACTIONS::doDelete.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Remove, PCB_ACTIONS::deleteFull.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Properties, PCB_ACTIONS::properties.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::MoveExact, PCB_ACTIONS::moveExact.MakeEvent() );
|
2022-11-13 13:14:18 +00:00
|
|
|
Go( &EDIT_TOOL::Move, PCB_ACTIONS::moveWithReference.MakeEvent() );
|
2022-09-27 13:30:17 +00:00
|
|
|
Go( &EDIT_TOOL::Duplicate, ACTIONS::duplicate.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Duplicate, PCB_ACTIONS::duplicateIncrement.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::CreateArray, PCB_ACTIONS::createArray.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirrorH.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirrorV.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::Swap, PCB_ACTIONS::swap.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::PackAndMoveFootprints, PCB_ACTIONS::packAndMoveFootprints.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::ChangeTrackWidth, PCB_ACTIONS::changeTrackWidth.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::FilletTracks, PCB_ACTIONS::filletTracks.MakeEvent() );
|
2023-07-02 17:59:04 +00:00
|
|
|
Go( &EDIT_TOOL::ModifyLines, PCB_ACTIONS::filletLines.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::ModifyLines, PCB_ACTIONS::chamferLines.MakeEvent() );
|
2024-04-30 00:47:34 +00:00
|
|
|
Go( &EDIT_TOOL::SimplifyPolygons, PCB_ACTIONS::simplifyPolygons.MakeEvent() );
|
2023-10-17 07:27:59 +00:00
|
|
|
Go( &EDIT_TOOL::HealShapes, PCB_ACTIONS::healShapes.MakeEvent() );
|
2023-07-02 17:59:04 +00:00
|
|
|
Go( &EDIT_TOOL::ModifyLines, PCB_ACTIONS::extendLines.MakeEvent() );
|
2023-07-22 00:23:59 +00:00
|
|
|
Go( &EDIT_TOOL::BooleanPolygons, PCB_ACTIONS::mergePolygons.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::BooleanPolygons, PCB_ACTIONS::subtractPolygons.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::BooleanPolygons, PCB_ACTIONS::intersectPolygons.MakeEvent() );
|
2023-11-21 23:43:48 +00:00
|
|
|
Go( &EDIT_TOOL::JustifyText, ACTIONS::leftJustify.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::JustifyText, ACTIONS::centerJustify.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::JustifyText, ACTIONS::rightJustify.MakeEvent() );
|
2022-09-27 13:30:17 +00:00
|
|
|
|
|
|
|
Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::copyToClipboard, PCB_ACTIONS::copyWithReference.MakeEvent() );
|
|
|
|
Go( &EDIT_TOOL::cutToClipboard, ACTIONS::cut.MakeEvent() );
|
2019-05-14 19:21:10 +00:00
|
|
|
}
|