2022-05-20 09:08:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2017 CERN
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-05-20 09:08:33 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
#include <functional>
|
2022-05-20 09:08:33 +00:00
|
|
|
#include <limits>
|
2023-09-18 03:13:09 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2022-05-20 09:08:33 +00:00
|
|
|
#include <board.h>
|
2023-06-27 15:52:50 +00:00
|
|
|
#include <board_commit.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2023-06-27 15:52:50 +00:00
|
|
|
#include <pad.h>
|
|
|
|
#include <pcb_group.h>
|
2023-10-06 17:04:00 +00:00
|
|
|
#include <pcb_generator.h>
|
2022-05-20 09:08:33 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2022-09-27 13:30:17 +00:00
|
|
|
#include <spread_footprints.h>
|
2022-05-20 09:08:33 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
|
|
|
#include <tools/pcb_selection_tool.h>
|
|
|
|
#include <tools/edit_tool.h>
|
|
|
|
#include <tools/pcb_grid_helper.h>
|
2022-06-18 12:02:00 +00:00
|
|
|
#include <tools/drc_tool.h>
|
2022-11-14 23:39:08 +00:00
|
|
|
#include <tools/zone_filler_tool.h>
|
2022-05-20 09:08:33 +00:00
|
|
|
#include <router/router_tool.h>
|
|
|
|
#include <dialogs/dialog_move_exact.h>
|
|
|
|
#include <zone_filler.h>
|
|
|
|
#include <drc/drc_engine.h>
|
|
|
|
#include <drc/drc_item.h>
|
|
|
|
#include <drc/drc_rule.h>
|
2022-10-13 23:47:59 +00:00
|
|
|
#include <drc/drc_interactive_courtyard_clearance.h>
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
|
2022-08-29 19:07:16 +00:00
|
|
|
int EDIT_TOOL::Swap( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2022-11-28 16:07:43 +00:00
|
|
|
if( isRouterActive() )
|
2022-08-29 19:07:16 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
2022-09-29 21:03:40 +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];
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( item->Type() == PCB_TRACE_T )
|
|
|
|
aCollector.Remove( item );
|
2022-09-29 21:03:40 +00:00
|
|
|
}
|
2022-08-29 19:07:16 +00:00
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
|
|
|
|
if( selection.Size() < 2 )
|
|
|
|
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;
|
|
|
|
|
2022-08-29 19:07:16 +00:00
|
|
|
std::vector<EDA_ITEM*> sorted = selection.GetItemsSortedBySelectionOrder();
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
// Save items, so changes can be undone
|
|
|
|
for( EDA_ITEM* item : selection )
|
2022-08-29 19:07:16 +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 );
|
2022-08-29 19:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( size_t i = 0; i < sorted.size() - 1; i++ )
|
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
BOARD_ITEM* a = dynamic_cast<BOARD_ITEM*>( sorted[i] );
|
|
|
|
BOARD_ITEM* b = dynamic_cast<BOARD_ITEM*>( sorted[( i + 1 ) % sorted.size()] );
|
|
|
|
|
|
|
|
wxCHECK2( a && b, continue );
|
2022-08-29 19:07:16 +00:00
|
|
|
|
|
|
|
// Swap X,Y position
|
|
|
|
VECTOR2I aPos = a->GetPosition(), bPos = b->GetPosition();
|
|
|
|
std::swap( aPos, bPos );
|
|
|
|
a->SetPosition( aPos );
|
|
|
|
b->SetPosition( bPos );
|
|
|
|
|
|
|
|
// Handle footprints specially. They can be flipped to the back of the board which
|
|
|
|
// requires a special transformation.
|
|
|
|
if( a->Type() == PCB_FOOTPRINT_T && b->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
FOOTPRINT* aFP = static_cast<FOOTPRINT*>( a );
|
|
|
|
FOOTPRINT* bFP = static_cast<FOOTPRINT*>( b );
|
|
|
|
|
2023-11-05 14:09:48 +00:00
|
|
|
// Store initial orientation of footprints, before flipping them.
|
|
|
|
EDA_ANGLE aAngle = aFP->GetOrientation();
|
|
|
|
EDA_ANGLE bAngle = bFP->GetOrientation();
|
|
|
|
|
2022-08-29 19:07:16 +00:00
|
|
|
// Flip both if needed
|
|
|
|
if( aFP->IsFlipped() != bFP->IsFlipped() )
|
|
|
|
{
|
|
|
|
aFP->Flip( aPos, false );
|
|
|
|
bFP->Flip( bPos, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set orientation
|
|
|
|
std::swap( aAngle, bAngle );
|
|
|
|
aFP->SetOrientation( aAngle );
|
|
|
|
bFP->SetOrientation( bAngle );
|
|
|
|
}
|
|
|
|
// We can also do a layer swap safely for two objects of the same type,
|
|
|
|
// except groups which don't support layer swaps.
|
|
|
|
else if( a->Type() == b->Type() && a->Type() != PCB_GROUP_T )
|
|
|
|
{
|
|
|
|
// Swap layers
|
|
|
|
PCB_LAYER_ID aLayer = a->GetLayer(), bLayer = b->GetLayer();
|
|
|
|
std::swap( aLayer, bLayer );
|
|
|
|
a->SetLayer( aLayer );
|
|
|
|
b->SetLayer( bLayer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
if( !localCommit.Empty() )
|
|
|
|
localCommit.Push( _( "Swap" ) );
|
2022-08-29 19:07:16 +00:00
|
|
|
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-27 13:30:17 +00:00
|
|
|
int EDIT_TOOL::PackAndMoveFootprints( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-09-03 13:01:54 +00:00
|
|
|
if( isRouterActive() || m_dragging )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
2022-09-27 13:30:17 +00:00
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
2022-12-09 17:42:35 +00:00
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2023-09-03 21:04:00 +00:00
|
|
|
sTool->FilterCollectorForFreePads( aCollector, true );
|
2022-12-09 17:42:35 +00:00
|
|
|
|
2022-09-27 13:30:17 +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];
|
|
|
|
|
|
|
|
if( !dynamic_cast<FOOTPRINT*>( item ) )
|
|
|
|
aCollector.Remove( item );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
|
|
|
|
std::vector<FOOTPRINT*> footprintsToPack;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
footprintsToPack.push_back( static_cast<FOOTPRINT*>( item ) );
|
|
|
|
|
|
|
|
if( footprintsToPack.empty() )
|
|
|
|
return 0;
|
|
|
|
|
2022-12-09 17:41:56 +00:00
|
|
|
BOX2I footprintsBbox;
|
2022-09-27 13:30:17 +00:00
|
|
|
|
|
|
|
for( FOOTPRINT* item : footprintsToPack )
|
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( item );
|
|
|
|
item->SetFlags( IS_MOVING );
|
2022-09-27 13:30:17 +00:00
|
|
|
footprintsBbox.Merge( item->GetBoundingBox( false, false ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
SpreadFootprints( &footprintsToPack, footprintsBbox.Normalize().GetOrigin(), false );
|
|
|
|
|
2024-02-15 13:06:55 +00:00
|
|
|
if( doMoveSelection( aEvent, &commit, true ) )
|
2024-02-03 13:43:41 +00:00
|
|
|
commit.Push( _( "Pack Footprints" ) );
|
2023-06-27 15:52:50 +00:00
|
|
|
else
|
|
|
|
commit.Revert();
|
|
|
|
|
|
|
|
return 0;
|
2022-09-27 13:30:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
int EDIT_TOOL::Move( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-04-17 16:26:18 +00:00
|
|
|
if( isRouterActive() || m_dragging )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-30 17:57:01 +00:00
|
|
|
if( BOARD_COMMIT* commit = dynamic_cast<BOARD_COMMIT*>( aEvent.Commit() ) )
|
|
|
|
{
|
|
|
|
wxCHECK( aEvent.SynchronousState(), 0 );
|
|
|
|
aEvent.SynchronousState()->store( STS_RUNNING );
|
2023-06-27 15:52:50 +00:00
|
|
|
|
2024-02-15 13:06:55 +00:00
|
|
|
if( doMoveSelection( aEvent, commit, true ) )
|
2023-06-30 17:57:01 +00:00
|
|
|
aEvent.SynchronousState()->store( STS_FINISHED );
|
|
|
|
else
|
|
|
|
aEvent.SynchronousState()->store( STS_CANCELLED );
|
|
|
|
}
|
2023-06-27 15:52:50 +00:00
|
|
|
else
|
2023-06-30 17:57:01 +00:00
|
|
|
{
|
|
|
|
BOARD_COMMIT localCommit( this );
|
|
|
|
|
2024-02-15 13:06:55 +00:00
|
|
|
if( doMoveSelection( aEvent, &localCommit, false ) )
|
2023-11-12 09:17:03 +00:00
|
|
|
localCommit.Push( _( "Move" ) );
|
2023-06-30 17:57:01 +00:00
|
|
|
else
|
2023-11-12 09:17:03 +00:00
|
|
|
localCommit.Revert();
|
2023-06-30 17:57:01 +00:00
|
|
|
}
|
2023-06-27 15:52:50 +00:00
|
|
|
|
2023-12-17 21:55:15 +00:00
|
|
|
// Notify point editor. (While doMoveSelection() will re-select the items and post this
|
|
|
|
// event, it's done before the edit flags are cleared in BOARD_COMMIT::Push() so the point
|
|
|
|
// editor doesn't fire up.)
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
return 0;
|
2022-05-20 09:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
VECTOR2I EDIT_TOOL::getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSourceBBox,
|
|
|
|
const VECTOR2D& aBBoxOffset )
|
|
|
|
{
|
|
|
|
typedef std::numeric_limits<int> coord_limits;
|
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
static const double max = coord_limits::max() - (int) COORDS_PADDING;
|
|
|
|
static const double min = -max;
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
BOX2D testBox( aSourceBBox.GetPosition(), aSourceBBox.GetSize() );
|
|
|
|
testBox.Offset( aBBoxOffset );
|
2021-12-11 23:57:51 +00:00
|
|
|
|
|
|
|
// Do not restrict movement if bounding box is already out of bounds
|
2024-04-06 06:50:12 +00:00
|
|
|
if( testBox.GetLeft() < min || testBox.GetTop() < min || testBox.GetRight() > max
|
|
|
|
|| testBox.GetBottom() > max )
|
|
|
|
{
|
2021-12-11 23:57:51 +00:00
|
|
|
return aMovement;
|
2024-04-06 06:50:12 +00:00
|
|
|
}
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
testBox.Offset( aMovement );
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
if( testBox.GetLeft() < min )
|
|
|
|
testBox.Offset( min - testBox.GetLeft(), 0 );
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
if( max < testBox.GetRight() )
|
|
|
|
testBox.Offset( -( testBox.GetRight() - max ), 0 );
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
if( testBox.GetTop() < min )
|
|
|
|
testBox.Offset( 0, min - testBox.GetTop() );
|
2021-12-11 23:57:51 +00:00
|
|
|
|
2024-04-06 06:50:12 +00:00
|
|
|
if( max < testBox.GetBottom() )
|
|
|
|
testBox.Offset( 0, -( testBox.GetBottom() - max ) );
|
|
|
|
|
|
|
|
return KiROUND( testBox.GetPosition() - aBBoxOffset - aSourceBBox.GetPosition() );
|
2021-12-11 23:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-15 13:06:55 +00:00
|
|
|
bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit, bool aAutoStart )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2022-11-13 13:14:18 +00:00
|
|
|
bool moveWithReference = aEvent.IsAction( &PCB_ACTIONS::moveWithReference );
|
|
|
|
bool moveIndividually = aEvent.IsAction( &PCB_ACTIONS::moveIndividually );
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
2022-10-19 10:32:16 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = editFrame->GetPcbNewSettings();
|
2022-06-20 20:15:06 +00:00
|
|
|
BOARD* board = editFrame->GetBoard();
|
2022-05-20 09:08:33 +00:00
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
|
|
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
2022-11-13 13:14:18 +00:00
|
|
|
STATUS_TEXT_POPUP statusPopup( frame() );
|
|
|
|
wxString status;
|
|
|
|
size_t itemIdx = 0;
|
2022-05-20 09:08:33 +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)
|
|
|
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
sTool->FilterCollectorForMarkers( aCollector );
|
|
|
|
sTool->FilterCollectorForHierarchy( aCollector, true );
|
2024-01-20 22:04:39 +00:00
|
|
|
sTool->FilterCollectorForFreePads( aCollector );
|
2024-01-15 17:29:55 +00:00
|
|
|
sTool->FilterCollectorForTableCells( aCollector );
|
2022-05-20 09:08:33 +00:00
|
|
|
},
|
2024-01-20 22:04:39 +00:00
|
|
|
true /* prompt user regarding locked items */ );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
if( m_dragging || selection.Empty() )
|
2023-06-27 15:52:50 +00:00
|
|
|
return false;
|
2022-05-20 09:08:33 +00:00
|
|
|
|
2023-04-26 10:40:44 +00:00
|
|
|
editFrame->PushTool( aEvent );
|
2022-05-20 09:08:33 +00:00
|
|
|
Activate();
|
2023-04-26 10:40:44 +00:00
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
// Must be done after Activate() so that it gets set into the correct context
|
|
|
|
controls->ShowCursor( true );
|
|
|
|
controls->SetAutoPan( true );
|
|
|
|
controls->ForceCursorPosition( false );
|
|
|
|
|
2022-07-27 12:37:20 +00:00
|
|
|
auto displayConstraintsMessage =
|
|
|
|
[editFrame]( bool constrained )
|
|
|
|
{
|
|
|
|
editFrame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" )
|
2023-02-12 21:29:26 +00:00
|
|
|
: wxString( wxT( "" ) ) );
|
2022-07-27 12:37:20 +00:00
|
|
|
};
|
|
|
|
|
2022-11-13 13:14:18 +00:00
|
|
|
auto updateStatusPopup =
|
|
|
|
[&]( EDA_ITEM* item, size_t ii, size_t count )
|
|
|
|
{
|
2023-06-05 01:07:56 +00:00
|
|
|
wxString popuptext = _( "Click to place %s (item %zu of %zu)\n"
|
2022-11-13 13:14:18 +00:00
|
|
|
"Press <esc> to cancel all; double-click to finish" );
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
|
|
|
|
msg = fp->GetReference();
|
|
|
|
}
|
|
|
|
else if( item->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
PAD* pad = static_cast<PAD*>( item );
|
2023-03-30 11:49:23 +00:00
|
|
|
FOOTPRINT* fp = pad->GetParentFootprint();
|
2022-11-13 13:14:18 +00:00
|
|
|
msg = wxString::Format( _( "%s pad %s" ), fp->GetReference(), pad->GetNumber() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg = item->GetTypeDesc().Lower();
|
|
|
|
}
|
|
|
|
|
2022-11-14 08:02:40 +00:00
|
|
|
statusPopup.SetText( wxString::Format( popuptext, msg, ii, count ) );
|
2022-11-13 13:14:18 +00:00
|
|
|
};
|
|
|
|
|
2022-10-14 09:42:07 +00:00
|
|
|
std::vector<BOARD_ITEM*> sel_items; // All the items operated on by the move below
|
|
|
|
std::vector<BOARD_ITEM*> orig_items; // All the original items in the selection
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2023-07-15 16:37:17 +00:00
|
|
|
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2024-01-20 22:04:39 +00:00
|
|
|
if( !selection.IsHover() )
|
2022-07-21 12:09:23 +00:00
|
|
|
orig_items.push_back( boardItem );
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
sel_items.push_back( boardItem );
|
|
|
|
}
|
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
for( PAD* pad : footprint->Pads() )
|
|
|
|
sel_items.push_back( pad );
|
|
|
|
|
|
|
|
// Clear this flag here; it will be set by the netlist updater if the footprint is new
|
|
|
|
// so that it was skipped in the initial connectivity update in OnNetlistChanged
|
|
|
|
footprint->SetAttributes( footprint->GetAttributes() & ~FP_JUST_ADDED );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-20 22:04:39 +00:00
|
|
|
VECTOR2I pickedReferencePoint;
|
|
|
|
|
2022-11-13 13:14:18 +00:00
|
|
|
if( moveWithReference && !pickReferencePoint( _( "Select reference point for move..." ), "", "",
|
|
|
|
pickedReferencePoint ) )
|
|
|
|
{
|
2024-01-20 22:04:39 +00:00
|
|
|
if( selection.IsHover() )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2022-11-13 13:14:18 +00:00
|
|
|
|
|
|
|
editFrame->PopTool( aEvent );
|
2023-06-27 15:52:50 +00:00
|
|
|
return false;
|
2022-11-13 13:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( moveIndividually )
|
|
|
|
{
|
|
|
|
orig_items.clear();
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection.GetItemsSortedBySelectionOrder() )
|
2023-07-13 10:24:33 +00:00
|
|
|
{
|
|
|
|
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
|
|
|
|
orig_items.push_back( boardItem );
|
|
|
|
}
|
2022-11-13 13:14:18 +00:00
|
|
|
|
|
|
|
updateStatusPopup( orig_items[ itemIdx ], itemIdx + 1, orig_items.size() );
|
|
|
|
statusPopup.Popup();
|
2023-09-18 03:13:09 +00:00
|
|
|
statusPopup.Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
|
2022-11-13 13:14:18 +00:00
|
|
|
canvas()->SetStatusPopup( statusPopup.GetPanel() );
|
|
|
|
|
|
|
|
m_selectionTool->ClearSelection();
|
|
|
|
m_selectionTool->AddItemToSel( orig_items[ itemIdx ] );
|
|
|
|
|
|
|
|
sel_items.clear();
|
|
|
|
sel_items.push_back( orig_items[ itemIdx ] );
|
|
|
|
}
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
bool restore_state = false;
|
|
|
|
VECTOR2I originalPos;
|
2021-12-11 23:57:51 +00:00
|
|
|
VECTOR2D bboxMovement;
|
|
|
|
BOX2I originalBBox;
|
|
|
|
bool updateBBox = true;
|
2024-01-20 22:04:39 +00:00
|
|
|
LSET layers( editFrame->GetActiveLayer() );
|
2022-05-20 09:08:33 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
|
2022-09-14 17:31:56 +00:00
|
|
|
TOOL_EVENT copy = aEvent;
|
|
|
|
TOOL_EVENT* evt = ©
|
2022-05-20 09:08:33 +00:00
|
|
|
VECTOR2I prevPos;
|
2024-02-20 02:38:05 +00:00
|
|
|
bool enableLocalRatsnest = true;
|
2022-05-20 09:08:33 +00:00
|
|
|
|
2022-05-29 13:16:13 +00:00
|
|
|
bool hv45Mode = false;
|
2022-05-20 09:08:33 +00:00
|
|
|
bool eatFirstMouseUp = true;
|
2022-10-19 10:32:16 +00:00
|
|
|
bool allowRedraw3D = cfg->m_Display.m_Live3DRefresh;
|
|
|
|
bool showCourtyardConflicts = !m_isFootprintEditor && cfg->m_ShowCourtyardCollisions;
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
// Used to test courtyard overlaps
|
2022-10-16 17:37:19 +00:00
|
|
|
std::unique_ptr<DRC_INTERACTIVE_COURTYARD_CLEARANCE> drc_on_move = nullptr;
|
2022-06-20 20:15:06 +00:00
|
|
|
|
|
|
|
if( showCourtyardConflicts )
|
2022-10-16 17:37:19 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<DRC_ENGINE> drcEngine = m_toolMgr->GetTool<DRC_TOOL>()->GetDRCEngine();
|
|
|
|
drc_on_move.reset( new DRC_INTERACTIVE_COURTYARD_CLEARANCE( drcEngine ) );
|
|
|
|
drc_on_move->Init( board );
|
|
|
|
}
|
2022-10-14 09:42:07 +00:00
|
|
|
|
|
|
|
displayConstraintsMessage( hv45Mode );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
// Prime the pump
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( ACTIONS::refreshPreview );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
// Main loop: keep receiving events
|
|
|
|
do
|
|
|
|
{
|
|
|
|
VECTOR2I movement;
|
|
|
|
editFrame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
|
|
|
|
2022-11-28 19:14:22 +00:00
|
|
|
bool isSkip = evt->IsAction( &PCB_ACTIONS::skip ) && moveIndividually;
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
|
|
|
|
eatFirstMouseUp = false;
|
|
|
|
|
|
|
|
if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
|
|
|
|| evt->IsAction( &ACTIONS::refreshPreview )
|
2022-09-15 14:19:47 +00:00
|
|
|
|| evt->IsAction( &PCB_ACTIONS::moveWithReference )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::moveIndividually ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
if( m_dragging && evt->Category() == TC_MOUSE )
|
|
|
|
{
|
|
|
|
bool redraw3D = false;
|
|
|
|
|
|
|
|
VECTOR2I mousePos( controls->GetMousePosition() );
|
|
|
|
|
2024-01-20 22:04:39 +00:00
|
|
|
m_cursor = grid.BestSnapAnchor( mousePos, layers,
|
2023-08-24 14:13:59 +00:00
|
|
|
grid.GetSelectionGrid( selection ), sel_items );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
if( controls->GetSettings().m_lastKeyboardCursorPositionValid )
|
|
|
|
{
|
|
|
|
long action = controls->GetSettings().m_lastKeyboardCursorCommand;
|
|
|
|
|
|
|
|
// The arrow keys are by definition SINGLE AXIS. Do not allow the other
|
|
|
|
// axis to be snapped to the grid.
|
|
|
|
if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
|
|
|
|
m_cursor.y = prevPos.y;
|
|
|
|
else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
|
|
|
|
m_cursor.x = prevPos.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !selection.HasReferencePoint() )
|
|
|
|
originalPos = m_cursor;
|
|
|
|
|
2022-05-29 13:16:13 +00:00
|
|
|
if( hv45Mode )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
VECTOR2I moveVector = m_cursor - originalPos;
|
|
|
|
m_cursor = originalPos + GetVectorSnapped45( moveVector );
|
|
|
|
}
|
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
if( updateBBox )
|
|
|
|
{
|
|
|
|
originalBBox = BOX2I();
|
|
|
|
bboxMovement = VECTOR2D();
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : sel_items )
|
|
|
|
{
|
2024-04-06 06:50:12 +00:00
|
|
|
originalBBox.Merge( item->ViewBBox() );
|
2021-12-11 23:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateBBox = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constrain selection bounding box to coordinates limits
|
|
|
|
movement = getSafeMovement( m_cursor - prevPos, originalBBox, bboxMovement );
|
|
|
|
|
|
|
|
// Apply constrained movement
|
|
|
|
m_cursor = prevPos + movement;
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
controls->ForceCursorPosition( true, m_cursor );
|
|
|
|
selection.SetReferencePoint( m_cursor );
|
|
|
|
|
|
|
|
prevPos = m_cursor;
|
2021-12-11 23:57:51 +00:00
|
|
|
bboxMovement += movement;
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
// Drag items to the current cursor position
|
|
|
|
for( EDA_ITEM* item : sel_items )
|
|
|
|
{
|
2023-10-10 12:42:42 +00:00
|
|
|
// Don't double move child items.
|
2022-05-20 09:08:33 +00:00
|
|
|
if( !item->GetParent() || !item->GetParent()->IsSelected() )
|
|
|
|
static_cast<BOARD_ITEM*>( item )->Move( movement );
|
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
if( item->Type() == PCB_GENERATOR_T && sel_items.size() == 1 )
|
2023-10-06 17:04:00 +00:00
|
|
|
{
|
2023-10-18 16:11:21 +00:00
|
|
|
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genUpdateEdit, aCommit,
|
|
|
|
static_cast<PCB_GENERATOR*>( item ) );
|
2023-10-06 17:04:00 +00:00
|
|
|
}
|
2023-11-09 13:55:00 +00:00
|
|
|
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
2023-10-10 12:42:42 +00:00
|
|
|
redraw3D = true;
|
2023-10-06 17:04:00 +00:00
|
|
|
}
|
|
|
|
|
2023-10-10 12:42:42 +00:00
|
|
|
if( redraw3D && allowRedraw3D )
|
|
|
|
editFrame->Update3DView( false, true );
|
|
|
|
|
2022-10-16 17:37:19 +00:00
|
|
|
if( showCourtyardConflicts && drc_on_move->m_FpInMove.size() )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2022-10-16 17:37:19 +00:00
|
|
|
drc_on_move->Run();
|
|
|
|
drc_on_move->UpdateConflicts( m_toolMgr->GetView(), true );
|
2022-05-20 09:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved );
|
|
|
|
}
|
2024-02-15 13:06:55 +00:00
|
|
|
else if( !m_dragging && ( aAutoStart || !evt->IsAction( &ACTIONS::refreshPreview ) ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
// Prepare to start dragging
|
|
|
|
editFrame->HideSolderMask();
|
|
|
|
|
|
|
|
m_dragging = true;
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
|
|
|
continue;
|
2022-05-20 09:08:33 +00:00
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
if( !item->IsNew() && !item->IsMoving() )
|
2023-06-27 15:52:50 +00:00
|
|
|
{
|
2023-11-09 13:55:00 +00:00
|
|
|
if( item->Type() == PCB_GENERATOR_T && sel_items.size() == 1 )
|
2023-10-06 17:04:00 +00:00
|
|
|
{
|
2024-02-20 02:38:05 +00:00
|
|
|
enableLocalRatsnest = false;
|
|
|
|
|
2023-10-18 16:11:21 +00:00
|
|
|
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genStartEdit, aCommit,
|
|
|
|
static_cast<PCB_GENERATOR*>( item ) );
|
2023-10-06 17:04:00 +00:00
|
|
|
}
|
|
|
|
else
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2023-10-06 17:04:00 +00:00
|
|
|
aCommit->Modify( item );
|
2023-11-12 09:17:03 +00:00
|
|
|
}
|
2023-11-09 13:55:00 +00:00
|
|
|
|
2023-11-12 09:17:03 +00:00
|
|
|
item->SetFlags( IS_MOVING );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-11-12 09:17:03 +00:00
|
|
|
static_cast<BOARD_ITEM*>( item )->RunOnDescendants(
|
|
|
|
[&]( BOARD_ITEM* bItem )
|
|
|
|
{
|
|
|
|
item->SetFlags( IS_MOVING );
|
|
|
|
} );
|
2022-05-20 09:08:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_cursor = controls->GetCursorPosition();
|
|
|
|
|
|
|
|
if( selection.HasReferencePoint() )
|
|
|
|
{
|
|
|
|
// start moving with the reference point attached to the cursor
|
|
|
|
grid.SetAuxAxes( false );
|
|
|
|
|
2022-05-29 13:16:13 +00:00
|
|
|
if( hv45Mode )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
VECTOR2I moveVector = m_cursor - originalPos;
|
|
|
|
m_cursor = originalPos + GetVectorSnapped45( moveVector );
|
|
|
|
}
|
|
|
|
|
|
|
|
movement = m_cursor - selection.GetReferencePoint();
|
|
|
|
|
|
|
|
// Drag items to the current cursor position
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
// Don't double move footprint pads, fields, etc.
|
|
|
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
static_cast<BOARD_ITEM*>( item )->Move( movement );
|
|
|
|
}
|
|
|
|
|
|
|
|
selection.SetReferencePoint( m_cursor );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-24 19:40:10 +00:00
|
|
|
if( showCourtyardConflicts )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2023-12-24 19:40:10 +00:00
|
|
|
std::vector<FOOTPRINT*>& FPs = drc_on_move->m_FpInMove;
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : sel_items )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
|
|
|
FPs.push_back( static_cast<FOOTPRINT*>( item ) );
|
|
|
|
|
|
|
|
item->RunOnDescendants(
|
|
|
|
[&]( BOARD_ITEM* descendent )
|
|
|
|
{
|
|
|
|
if( descendent->Type() == PCB_FOOTPRINT_T )
|
|
|
|
FPs.push_back( static_cast<FOOTPRINT*>( descendent ) );
|
|
|
|
} );
|
|
|
|
}
|
2022-05-20 09:08:33 +00:00
|
|
|
}
|
|
|
|
|
2022-11-13 13:14:18 +00:00
|
|
|
m_cursor = grid.BestDragOrigin( originalCursorPos, sel_items,
|
2023-08-24 14:13:59 +00:00
|
|
|
grid.GetSelectionGrid( selection ),
|
2022-11-08 16:26:42 +00:00
|
|
|
&m_selectionTool->GetFilter() );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
// Set the current cursor position to the first dragged item origin, so the
|
|
|
|
// movement vector could be computed later
|
2022-11-13 13:14:18 +00:00
|
|
|
if( moveWithReference )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
selection.SetReferencePoint( pickedReferencePoint );
|
|
|
|
controls->ForceCursorPosition( true, pickedReferencePoint );
|
|
|
|
m_cursor = pickedReferencePoint;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Check if user wants to warp the mouse to origin of moved object
|
|
|
|
if( !editFrame->GetMoveWarpsCursor() )
|
|
|
|
m_cursor = originalCursorPos; // No, so use original mouse pos instead
|
|
|
|
|
|
|
|
selection.SetReferencePoint( m_cursor );
|
|
|
|
grid.SetAuxAxes( true, m_cursor );
|
|
|
|
}
|
|
|
|
|
|
|
|
originalPos = m_cursor;
|
|
|
|
}
|
|
|
|
|
2021-12-11 23:57:51 +00:00
|
|
|
// Update variables for bounding box collision calculations
|
|
|
|
updateBBox = true;
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
controls->SetCursorPosition( m_cursor, false );
|
|
|
|
|
|
|
|
prevPos = m_cursor;
|
|
|
|
controls->SetAutoPan( true );
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
}
|
|
|
|
|
2023-09-18 03:13:09 +00:00
|
|
|
statusPopup.Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
|
2022-11-13 13:14:18 +00:00
|
|
|
|
2024-02-20 02:38:05 +00:00
|
|
|
if( enableLocalRatsnest )
|
|
|
|
m_toolMgr->PostAction( PCB_ACTIONS::updateLocalRatsnest, movement );
|
2022-05-20 09:08:33 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( m_dragging && evt->IsCancelInteractive() )
|
|
|
|
evt->SetPassEvent( false );
|
|
|
|
|
|
|
|
restore_state = true; // Canceling the tool means that items have to be restored
|
|
|
|
break; // Finish
|
|
|
|
}
|
2024-02-15 18:06:54 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
|
|
|
m_menu.ShowContextMenu( selection );
|
|
|
|
}
|
2023-06-27 15:52:50 +00:00
|
|
|
else if( evt->IsAction( &ACTIONS::undo ) || evt->IsAction( &ACTIONS::doDelete ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
restore_state = true; // Perform undo locally
|
|
|
|
break; // Finish
|
|
|
|
}
|
2023-06-27 15:52:50 +00:00
|
|
|
else if( evt->IsAction( &ACTIONS::duplicate ) || evt->IsAction( &ACTIONS::cut ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::rotateCw )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::rotateCcw )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::flip )
|
2022-09-20 23:16:00 +00:00
|
|
|
|| evt->IsAction( &PCB_ACTIONS::mirrorH )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::mirrorV ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2021-12-11 23:57:51 +00:00
|
|
|
updateBBox = true;
|
2022-05-20 09:08:33 +00:00
|
|
|
eatFirstMouseUp = false;
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2022-11-28 19:14:22 +00:00
|
|
|
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) || isSkip )
|
2022-05-20 09:08:33 +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 ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
|
|
|
eatFirstMouseUp = false;
|
|
|
|
continue;
|
|
|
|
}
|
2022-11-13 13:14:18 +00:00
|
|
|
else if( moveIndividually && m_dragging )
|
|
|
|
{
|
2022-11-28 19:14:22 +00:00
|
|
|
// Put skipped items back where they started
|
|
|
|
if( isSkip )
|
|
|
|
orig_items[itemIdx]->SetPosition( originalPos );
|
|
|
|
|
2024-01-19 15:13:11 +00:00
|
|
|
view()->Update( orig_items[itemIdx] );
|
2022-11-30 14:11:03 +00:00
|
|
|
rebuildConnectivity();
|
|
|
|
|
2022-11-13 13:14:18 +00:00
|
|
|
if( ++itemIdx < orig_items.size() )
|
|
|
|
{
|
2022-12-21 19:44:39 +00:00
|
|
|
BOARD_ITEM* nextItem = orig_items[itemIdx];
|
|
|
|
|
2022-11-13 13:14:18 +00:00
|
|
|
m_selectionTool->ClearSelection();
|
2022-12-21 19:44:39 +00:00
|
|
|
|
|
|
|
originalPos = nextItem->GetPosition();
|
|
|
|
m_selectionTool->AddItemToSel( nextItem );
|
|
|
|
selection.SetReferencePoint( originalPos );
|
2022-11-13 13:14:18 +00:00
|
|
|
|
|
|
|
sel_items.clear();
|
2022-12-21 19:44:39 +00:00
|
|
|
sel_items.push_back( nextItem );
|
|
|
|
updateStatusPopup( nextItem, itemIdx + 1, orig_items.size() );
|
2022-11-13 13:14:18 +00:00
|
|
|
|
|
|
|
// Pick up new item
|
2023-06-27 15:52:50 +00:00
|
|
|
aCommit->Modify( nextItem );
|
2023-07-06 21:40:16 +00:00
|
|
|
nextItem->Move( controls->GetCursorPosition( true ) - nextItem->GetPosition() );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
2022-11-13 13:14:18 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break; // finish
|
|
|
|
}
|
|
|
|
else if( evt->IsDblClick( BUT_LEFT ) )
|
|
|
|
{
|
2022-12-21 19:44:39 +00:00
|
|
|
// The first click will move the new item, so put it back
|
|
|
|
if( moveIndividually )
|
|
|
|
orig_items[itemIdx]->SetPosition( originalPos );
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
break; // finish
|
|
|
|
}
|
2022-05-29 13:16:13 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::toggleHV45Mode ) )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2022-05-29 13:16:13 +00:00
|
|
|
hv45Mode = !hv45Mode;
|
2022-07-27 12:37:20 +00:00
|
|
|
displayConstraintsMessage( hv45Mode );
|
2022-05-20 09:08:33 +00:00
|
|
|
evt->SetPassEvent( false );
|
|
|
|
}
|
2023-06-30 19:21:29 +00:00
|
|
|
else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::moveExact )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::moveWithReference )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::copyWithReference )
|
|
|
|
|| evt->IsAction( &PCB_ACTIONS::positionRelative )
|
|
|
|
|| evt->IsAction( &ACTIONS::redo ) )
|
2022-11-14 23:39:08 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
}
|
2022-05-20 09:08:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
} while( ( evt = Wait() ) ); // Assignment (instead of equality test) is intentional
|
|
|
|
|
|
|
|
// Clear temporary COURTYARD_CONFLICT flag and ensure the conflict shadow is cleared
|
2022-10-16 17:37:19 +00:00
|
|
|
if( showCourtyardConflicts )
|
|
|
|
drc_on_move->ClearConflicts( m_toolMgr->GetView() );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
controls->ForceCursorPosition( false );
|
|
|
|
controls->ShowCursor( false );
|
|
|
|
controls->SetAutoPan( false );
|
|
|
|
|
|
|
|
m_dragging = false;
|
|
|
|
|
|
|
|
// Discard reference point when selection is "dropped" onto the board
|
|
|
|
selection.ClearReferencePoint();
|
|
|
|
|
2022-09-30 22:05:06 +00:00
|
|
|
// Unselect all items to clear selection flags and then re-select the originally selected
|
2023-06-27 15:52:50 +00:00
|
|
|
// items.
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2022-09-30 22:05:06 +00:00
|
|
|
|
2023-11-12 09:17:03 +00:00
|
|
|
if( restore_state )
|
|
|
|
{
|
|
|
|
if( sel_items.size() == 1 && sel_items.back()->Type() == PCB_GENERATOR_T )
|
|
|
|
{
|
|
|
|
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genRevertEdit, aCommit,
|
|
|
|
static_cast<PCB_GENERATOR*>( sel_items.back() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2022-11-05 16:36:10 +00:00
|
|
|
{
|
2023-11-12 09:17:03 +00:00
|
|
|
if( sel_items.size() == 1 && sel_items.back()->Type() == PCB_GENERATOR_T )
|
|
|
|
{
|
|
|
|
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genPushEdit, aCommit,
|
|
|
|
static_cast<PCB_GENERATOR*>( sel_items.back() ) );
|
|
|
|
}
|
|
|
|
|
2023-06-16 21:28:15 +00:00
|
|
|
EDA_ITEMS oItems( orig_items.begin(), orig_items.end() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction<EDA_ITEMS*>( PCB_ACTIONS::selectItems, &oItems );
|
2022-11-05 16:36:10 +00:00
|
|
|
}
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
// Remove the dynamic ratsnest from the screen
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::hideLocalRatsnest );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
editFrame->PopTool( aEvent );
|
2022-05-20 09:08:33 +00:00
|
|
|
editFrame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
return !restore_state;
|
2022-05-20 09:08:33 +00:00
|
|
|
}
|
|
|
|
|