2019-05-04 13:02:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2024-02-28 16:57:20 +00:00
|
|
|
* Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-05-04 13:02: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
|
|
|
|
*/
|
|
|
|
|
2022-02-15 02:43:00 +00:00
|
|
|
#include <cmath>
|
2023-03-29 16:53:28 +00:00
|
|
|
#include <wx/log.h>
|
2022-02-10 18:38:40 +00:00
|
|
|
#include <trigo.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2019-05-04 13:02:05 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2020-09-09 17:08:24 +00:00
|
|
|
#include <tools/ee_grid_helper.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_selection_tool.h>
|
2019-06-16 13:42:40 +00:00
|
|
|
#include <tools/sch_line_wire_bus_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <ee_actions.h>
|
2023-06-09 21:41:33 +00:00
|
|
|
#include <sch_commit.h>
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2019-05-10 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2019-05-04 13:02:05 +00:00
|
|
|
#include <sch_sheet.h>
|
2021-04-06 21:15:49 +00:00
|
|
|
#include <sch_sheet_pin.h>
|
2019-05-04 13:02:05 +00:00
|
|
|
#include <sch_line.h>
|
2022-11-25 15:04:36 +00:00
|
|
|
#include <sch_junction.h>
|
2019-05-04 13:02:05 +00:00
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <eeschema_id.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2019-05-04 13:02:05 +00:00
|
|
|
#include "sch_move_tool.h"
|
|
|
|
|
|
|
|
|
|
|
|
// For adding to or removing from selections
|
|
|
|
#define QUIET_MODE true
|
|
|
|
|
|
|
|
|
|
|
|
SCH_MOVE_TOOL::SCH_MOVE_TOOL() :
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveMove" ),
|
2022-11-18 17:07:02 +00:00
|
|
|
m_inMoveTool( false ),
|
2019-05-04 13:02:05 +00:00
|
|
|
m_moveInProgress( false ),
|
2021-03-22 12:51:32 +00:00
|
|
|
m_isDrag( false ),
|
2019-05-04 13:02:05 +00:00
|
|
|
m_moveOffset( 0, 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_MOVE_TOOL::Init()
|
|
|
|
{
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE::Init();
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2020-12-27 12:36:11 +00:00
|
|
|
auto moveCondition =
|
|
|
|
[]( const SELECTION& aSel )
|
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( aSel.Empty() || SELECTION_CONDITIONS::OnlyTypes( { SCH_MARKER_T } )( aSel ) )
|
2020-12-27 12:36:11 +00:00
|
|
|
return false;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2020-12-27 12:36:11 +00:00
|
|
|
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
|
|
|
return false;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2020-12-27 12:36:11 +00:00
|
|
|
return true;
|
|
|
|
};
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
// Add move actions to the selection tool menu
|
|
|
|
//
|
|
|
|
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::move, moveCondition, 150 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::drag, moveCondition, 150 );
|
2020-09-17 19:26:54 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::alignToGrid, moveCondition, 150 );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void SCH_MOVE_TOOL::orthoLineDrag( SCH_COMMIT* aCommit, SCH_LINE* line, const VECTOR2I& splitDelta,
|
|
|
|
int& xBendCount, int& yBendCount, const EE_GRID_HELPER& grid )
|
2022-10-03 20:40:47 +00:00
|
|
|
{
|
|
|
|
// If the move is not the same angle as this move, then we need to do something special with
|
|
|
|
// the unselected end to maintain orthogonality. Either drag some connected line that is the
|
|
|
|
// same angle as the move or add two lines to make a 90 degree connection
|
|
|
|
if( !EDA_ANGLE( splitDelta ).IsParallelTo( line->Angle() ) || line->GetLength() == 0 )
|
|
|
|
{
|
|
|
|
VECTOR2I unselectedEnd = line->HasFlag( STARTPOINT ) ? line->GetEndPoint()
|
|
|
|
: line->GetStartPoint();
|
|
|
|
VECTOR2I selectedEnd = line->HasFlag( STARTPOINT ) ? line->GetStartPoint()
|
|
|
|
: line->GetEndPoint();
|
|
|
|
|
|
|
|
// Look for pre-existing lines we can drag with us instead of creating new ones
|
|
|
|
bool foundAttachment = false;
|
|
|
|
bool foundJunction = false;
|
|
|
|
bool foundPin = false;
|
|
|
|
SCH_LINE* foundLine = nullptr;
|
|
|
|
|
|
|
|
for( EDA_ITEM* cItem : m_lineConnectionCache[line] )
|
|
|
|
{
|
|
|
|
foundAttachment = true;
|
|
|
|
|
|
|
|
// If the move is the same angle as a connected line, we can shrink/extend that line
|
|
|
|
// endpoint
|
|
|
|
switch( cItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
|
|
|
{
|
|
|
|
SCH_LINE* cLine = static_cast<SCH_LINE*>( cItem );
|
|
|
|
|
|
|
|
// A matching angle on a non-zero-length line means lengthen/shorten will work
|
|
|
|
if( EDA_ANGLE( splitDelta ).IsParallelTo( cLine->Angle() )
|
|
|
|
&& cLine->GetLength() != 0 )
|
|
|
|
{
|
|
|
|
foundLine = cLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Zero length lines are lines that this algorithm has shortened to 0 so they also
|
|
|
|
// work but we should prefer using a segment with length and angle matching when
|
|
|
|
// we can (otherwise the zero length line will draw overlapping segments on them)
|
|
|
|
if( !foundLine && cLine->GetLength() == 0 )
|
|
|
|
foundLine = cLine;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
foundJunction = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_PIN_T:
|
|
|
|
foundPin = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok... what if our original line is length zero from moving in its direction, and the
|
|
|
|
// last added segment of the 90 bend we are connected to is zero from moving it in its
|
|
|
|
// direction after it was added?
|
|
|
|
//
|
|
|
|
// If we are moving in original direction, we should lengthen the original drag wire.
|
|
|
|
// Otherwise we should lengthen the new wire.
|
|
|
|
bool preferOriginalLine = false;
|
|
|
|
|
|
|
|
if( foundLine
|
|
|
|
&& foundLine->GetLength() == 0
|
|
|
|
&& line->GetLength() == 0
|
|
|
|
&& EDA_ANGLE( splitDelta ).IsParallelTo( line->GetStoredAngle() ) )
|
|
|
|
{
|
|
|
|
preferOriginalLine = true;
|
|
|
|
}
|
|
|
|
// If we have found an attachment, but not a line, we want to check if it's a junction.
|
|
|
|
// These are special-cased and get a single line added instead of a 90-degree bend. Except
|
|
|
|
// when we're on a pin, because pins always need bends, and junctions are just added to
|
|
|
|
// pins for visual clarity.
|
|
|
|
else if( !foundLine && foundJunction && !foundPin )
|
|
|
|
{
|
|
|
|
// Create a new wire ending at the unselected end
|
|
|
|
foundLine = new SCH_LINE( unselectedEnd, line->GetLayer() );
|
|
|
|
foundLine->SetFlags( IS_NEW );
|
|
|
|
foundLine->SetLastResolvedState( line );
|
|
|
|
m_frame->AddToScreen( foundLine, m_frame->GetScreen() );
|
|
|
|
m_newDragLines.insert( foundLine );
|
|
|
|
|
|
|
|
// We just broke off of the existing items, so replace all of them with our new
|
|
|
|
// end connection.
|
|
|
|
m_lineConnectionCache[foundLine] = m_lineConnectionCache[line];
|
|
|
|
m_lineConnectionCache[line].clear();
|
|
|
|
m_lineConnectionCache[line].emplace_back( foundLine );
|
|
|
|
}
|
|
|
|
|
|
|
|
// We want to drag our found line if it's in the same angle as the move or zero length,
|
|
|
|
// but if the original drag line is also zero and the same original angle we should extend
|
|
|
|
// that one first
|
|
|
|
if( foundLine && !preferOriginalLine )
|
|
|
|
{
|
|
|
|
// Move the connected line found oriented in the direction of our move.
|
|
|
|
//
|
|
|
|
// Make sure we grab the right endpoint, it's not always STARTPOINT since the user can
|
|
|
|
// draw a box of lines. We need to only move one though, and preferably the start point,
|
|
|
|
// in case we have a zero length line that we are extending (we want the foundLine
|
|
|
|
// start point to be attached to the unselected end of our drag line).
|
|
|
|
//
|
|
|
|
// Also, new lines are added already so they'll be in the undo list, skip adding them.
|
2023-03-06 12:12:11 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
if( !foundLine->HasFlag( IS_CHANGED ) && !foundLine->HasFlag( IS_NEW ) )
|
|
|
|
{
|
2023-06-09 21:41:33 +00:00
|
|
|
aCommit->Modify( (SCH_ITEM*) foundLine, m_frame->GetScreen() );
|
2022-10-03 20:40:47 +00:00
|
|
|
|
|
|
|
if( !foundLine->IsSelected() )
|
|
|
|
m_changedDragLines.insert( foundLine );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( foundLine->GetStartPoint() == unselectedEnd )
|
|
|
|
foundLine->MoveStart( splitDelta );
|
|
|
|
else if( foundLine->GetEndPoint() == unselectedEnd )
|
|
|
|
foundLine->MoveEnd( splitDelta );
|
|
|
|
|
|
|
|
updateItem( foundLine, true );
|
|
|
|
|
|
|
|
SCH_LINE* bendLine = nullptr;
|
|
|
|
|
|
|
|
if( m_lineConnectionCache.count( foundLine ) == 1
|
|
|
|
&& m_lineConnectionCache[foundLine][0]->Type() == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
bendLine = static_cast<SCH_LINE*>( m_lineConnectionCache[foundLine][0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remerge segments we've created if this is a segment that we've added whose only
|
|
|
|
// other connection is also an added segment
|
|
|
|
//
|
|
|
|
// bendLine is first added segment at the original attachment point, foundLine is the
|
|
|
|
// orthogonal line between bendLine and this line
|
|
|
|
if( foundLine->HasFlag( IS_NEW )
|
|
|
|
&& foundLine->GetLength() == 0
|
|
|
|
&& bendLine && bendLine->HasFlag( IS_NEW ) )
|
|
|
|
{
|
|
|
|
if( line->HasFlag( STARTPOINT ) )
|
|
|
|
line->SetEndPoint( bendLine->GetEndPoint() );
|
|
|
|
else
|
|
|
|
line->SetStartPoint( bendLine->GetEndPoint() );
|
|
|
|
|
|
|
|
// Update our cache of the connected items.
|
|
|
|
|
|
|
|
// First, re-attach our drag labels to the original line being re-merged.
|
|
|
|
for( EDA_ITEM* candidate : m_lineConnectionCache[bendLine] )
|
|
|
|
{
|
|
|
|
SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( candidate );
|
|
|
|
|
|
|
|
if( label && m_specialCaseLabels.count( label ) )
|
|
|
|
m_specialCaseLabels[label].attachedLine = line;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lineConnectionCache[line] = m_lineConnectionCache[bendLine];
|
|
|
|
m_lineConnectionCache[bendLine].clear();
|
|
|
|
m_lineConnectionCache[foundLine].clear();
|
|
|
|
|
|
|
|
m_frame->RemoveFromScreen( bendLine, m_frame->GetScreen() );
|
|
|
|
m_frame->RemoveFromScreen( foundLine, m_frame->GetScreen() );
|
|
|
|
|
|
|
|
m_newDragLines.erase( bendLine );
|
|
|
|
m_newDragLines.erase( foundLine );
|
|
|
|
|
|
|
|
delete bendLine;
|
|
|
|
delete foundLine;
|
|
|
|
}
|
|
|
|
//Ok, move the unselected end of our item
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( line->HasFlag( STARTPOINT ) )
|
|
|
|
line->MoveEnd( splitDelta );
|
|
|
|
else
|
|
|
|
line->MoveStart( splitDelta );
|
|
|
|
}
|
|
|
|
|
|
|
|
updateItem( line, true );
|
|
|
|
}
|
|
|
|
else if( line->GetLength() == 0 )
|
|
|
|
{
|
|
|
|
// We didn't find another line to shorten/lengthen, (or we did but it's also zero)
|
|
|
|
// so now is a good time to use our existing zero-length original line
|
|
|
|
}
|
|
|
|
// Either no line was at the "right" angle, or this was a junction, pin, sheet, etc. We
|
|
|
|
// need to add segments to keep the soon-to-move unselected end connected to these items.
|
|
|
|
//
|
|
|
|
// To keep our drag selections all the same, we'll move our unselected end point and then
|
|
|
|
// put wires between it and its original endpoint.
|
|
|
|
else if( foundAttachment && line->IsOrthogonal() )
|
|
|
|
{
|
2023-08-21 14:42:02 +00:00
|
|
|
VECTOR2D lineGrid = grid.GetGridSize( grid.GetItemGrid( line ) );
|
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
// The bend counter handles a group of wires all needing their offset one grid movement
|
|
|
|
// further out from each other to not overlap. The absolute value stuff finds the
|
|
|
|
// direction of the line and hence the the bend increment on that axis
|
|
|
|
unsigned int xMoveBit = splitDelta.x != 0;
|
|
|
|
unsigned int yMoveBit = splitDelta.y != 0;
|
|
|
|
int xLength = abs( unselectedEnd.x - selectedEnd.x );
|
|
|
|
int yLength = abs( unselectedEnd.y - selectedEnd.y );
|
2023-08-21 14:42:02 +00:00
|
|
|
int xMove = ( xLength - ( xBendCount * lineGrid.x ) )
|
2022-10-03 20:40:47 +00:00
|
|
|
* sign( selectedEnd.x - unselectedEnd.x );
|
2023-08-21 14:42:02 +00:00
|
|
|
int yMove = ( yLength - ( yBendCount * lineGrid.y ) )
|
2022-10-03 20:40:47 +00:00
|
|
|
* sign( selectedEnd.y - unselectedEnd.y );
|
|
|
|
|
|
|
|
// Create a new wire ending at the unselected end, we'll move the new wire's start
|
|
|
|
// point to the unselected end
|
|
|
|
SCH_LINE* a = new SCH_LINE( unselectedEnd, line->GetLayer() );
|
|
|
|
a->MoveStart( VECTOR2I( xMove, yMove ) );
|
|
|
|
a->SetFlags( IS_NEW );
|
|
|
|
a->SetConnectivityDirty( true );
|
|
|
|
a->SetLastResolvedState( line );
|
|
|
|
m_frame->AddToScreen( a, m_frame->GetScreen() );
|
|
|
|
m_newDragLines.insert( a );
|
|
|
|
|
|
|
|
SCH_LINE* b = new SCH_LINE( a->GetStartPoint(), line->GetLayer() );
|
|
|
|
b->MoveStart( VECTOR2I( splitDelta.x, splitDelta.y ) );
|
|
|
|
b->SetFlags( IS_NEW | STARTPOINT );
|
|
|
|
b->SetConnectivityDirty( true );
|
|
|
|
b->SetLastResolvedState( line );
|
|
|
|
m_frame->AddToScreen( b, m_frame->GetScreen() );
|
|
|
|
m_newDragLines.insert( b );
|
|
|
|
|
|
|
|
xBendCount += yMoveBit;
|
|
|
|
yBendCount += xMoveBit;
|
|
|
|
|
|
|
|
// Ok move the unselected end of our item
|
|
|
|
if( line->HasFlag( STARTPOINT ) )
|
|
|
|
{
|
|
|
|
line->MoveEnd( VECTOR2I( splitDelta.x ? splitDelta.x : xMove,
|
|
|
|
splitDelta.y ? splitDelta.y : yMove ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
line->MoveStart( VECTOR2I( splitDelta.x ? splitDelta.x : xMove,
|
|
|
|
splitDelta.y ? splitDelta.y : yMove ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update our cache of the connected items. First, attach our drag labels to the line
|
|
|
|
// left behind.
|
|
|
|
for( EDA_ITEM* candidate : m_lineConnectionCache[line] )
|
|
|
|
{
|
|
|
|
SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( candidate );
|
|
|
|
|
|
|
|
if( label && m_specialCaseLabels.count( label ) )
|
|
|
|
m_specialCaseLabels[label].attachedLine = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We just broke off of the existing items, so replace all of them with our new end
|
|
|
|
// connection.
|
|
|
|
m_lineConnectionCache[a] = m_lineConnectionCache[line];
|
|
|
|
m_lineConnectionCache[b].emplace_back( a );
|
|
|
|
m_lineConnectionCache[line].clear();
|
|
|
|
m_lineConnectionCache[line].emplace_back( b );
|
|
|
|
}
|
|
|
|
// Original line has no attachments, just move the unselected end
|
|
|
|
else if( !foundAttachment )
|
|
|
|
{
|
|
|
|
if( line->HasFlag( STARTPOINT ) )
|
|
|
|
line->MoveEnd( splitDelta );
|
|
|
|
else
|
|
|
|
line->MoveStart( splitDelta );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-07-15 22:11:24 +00:00
|
|
|
m_isDrag = aEvent.IsAction( &EE_ACTIONS::drag );
|
2023-06-30 17:57:01 +00:00
|
|
|
|
|
|
|
if( SCH_COMMIT* commit = dynamic_cast<SCH_COMMIT*>( aEvent.Commit() ) )
|
|
|
|
{
|
|
|
|
bool isSlice = false;
|
|
|
|
|
|
|
|
if( m_isDrag )
|
|
|
|
isSlice = aEvent.Parameter<bool>();
|
|
|
|
|
|
|
|
wxCHECK( aEvent.SynchronousState(), 0 );
|
|
|
|
aEvent.SynchronousState()->store( STS_RUNNING );
|
|
|
|
|
|
|
|
if( doMoveSelection( aEvent, commit, isSlice ) )
|
|
|
|
aEvent.SynchronousState()->store( STS_FINISHED );
|
|
|
|
else
|
|
|
|
aEvent.SynchronousState()->store( STS_CANCELLED );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCH_COMMIT localCommit( m_toolMgr );
|
|
|
|
|
|
|
|
if( doMoveSelection( aEvent, &localCommit, false ) )
|
|
|
|
localCommit.Push( m_isDrag ? _( "Drag" ) : _( "Move" ) );
|
|
|
|
else
|
|
|
|
localCommit.Revert();
|
2023-03-06 12:12:11 +00:00
|
|
|
}
|
2019-05-31 18:23:49 +00:00
|
|
|
|
2023-06-30 17:57:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COMMIT* aCommit, bool aIsSlice )
|
|
|
|
{
|
2023-10-27 20:48:03 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = nullptr;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( false, false, e.what() );
|
|
|
|
}
|
|
|
|
|
2023-06-30 17:57:01 +00:00
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
|
|
EE_GRID_HELPER grid( m_toolMgr );
|
|
|
|
bool wasDragging = m_moveInProgress && m_isDrag;
|
|
|
|
|
|
|
|
m_anchorPos.reset();
|
|
|
|
|
2019-05-31 18:23:49 +00:00
|
|
|
if( m_moveInProgress )
|
|
|
|
{
|
2021-03-22 12:51:32 +00:00
|
|
|
if( m_isDrag != wasDragging )
|
2019-05-31 18:23:49 +00:00
|
|
|
{
|
2021-04-07 09:48:51 +00:00
|
|
|
EDA_ITEM* sel = m_selectionTool->GetSelection().Front();
|
2021-03-22 12:51:32 +00:00
|
|
|
|
|
|
|
if( sel && !sel->IsNew() )
|
|
|
|
{
|
|
|
|
// Reset the selected items so we can start again with the current m_isDrag
|
|
|
|
// state.
|
2023-06-30 17:57:01 +00:00
|
|
|
aCommit->Revert();
|
2023-03-06 12:12:11 +00:00
|
|
|
|
2021-03-22 12:51:32 +00:00
|
|
|
m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
|
|
|
|
m_anchorPos = m_cursor - m_moveOffset;
|
|
|
|
m_moveInProgress = false;
|
|
|
|
controls->SetAutoPan( false );
|
|
|
|
|
|
|
|
// And give it a kick so it doesn't have to wait for the first mouse movement
|
|
|
|
// to refresh.
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( EE_ACTIONS::restartMove );
|
2021-03-22 12:51:32 +00:00
|
|
|
}
|
2019-05-31 18:23:49 +00:00
|
|
|
}
|
2022-06-09 15:53:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// The tool hotkey is interpreted as a click when already dragging/moving
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( ACTIONS::cursorClick );
|
2022-06-09 15:53:24 +00:00
|
|
|
}
|
2019-05-31 18:23:49 +00:00
|
|
|
|
2023-06-30 17:57:01 +00:00
|
|
|
return false;
|
2019-05-31 18:23:49 +00:00
|
|
|
}
|
2019-05-20 15:42:49 +00:00
|
|
|
|
2022-11-18 17:07:02 +00:00
|
|
|
if( m_inMoveTool ) // Must come after m_moveInProgress checks above...
|
2023-06-30 17:57:01 +00:00
|
|
|
return false;
|
2022-11-18 17:07:02 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inMoveTool );
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
// Be sure that there is at least one item that we can move. If there's no selection try
|
|
|
|
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
|
2023-11-25 12:38:24 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::MovableItems,
|
|
|
|
true );
|
2019-06-08 21:48:22 +00:00
|
|
|
bool unselect = selection.IsHover();
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2019-10-19 03:15:29 +00:00
|
|
|
// Keep an original copy of the starting points for cleanup after the move
|
|
|
|
std::vector<DANGLING_END_ITEM> internalPoints;
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
Activate();
|
2023-03-06 12:12:11 +00:00
|
|
|
|
2021-09-13 12:23:10 +00:00
|
|
|
// Must be done after Activate() so that it gets set into the correct context
|
2019-05-04 13:02:05 +00:00
|
|
|
controls->ShowCursor( true );
|
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PushTool( aEvent );
|
2020-10-18 10:29:08 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
{
|
|
|
|
// Note that it's important to go through push/pop even when the selection is empty.
|
|
|
|
// This keeps other tools from having to special-case an empty move.
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2023-06-30 17:57:01 +00:00
|
|
|
return false;
|
2020-10-18 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 13:43:22 +00:00
|
|
|
bool restore_state = false;
|
2022-09-14 17:31:56 +00:00
|
|
|
TOOL_EVENT copy = aEvent;
|
|
|
|
TOOL_EVENT* evt = ©
|
2019-06-17 13:43:22 +00:00
|
|
|
VECTOR2I prevPos;
|
2023-07-23 17:51:42 +00:00
|
|
|
GRID_HELPER_GRIDS snapLayer = GRID_CURRENT;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2019-05-20 15:42:49 +00:00
|
|
|
m_cursor = controls->GetCursorPosition();
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
// Main loop: keep receiving events
|
|
|
|
do
|
|
|
|
{
|
2020-10-08 00:50:28 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
2020-12-02 23:17:56 +00:00
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
2021-05-09 19:17:01 +00:00
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
2020-12-02 23:17:56 +00:00
|
|
|
|
2023-07-15 22:11:24 +00:00
|
|
|
if( evt->IsAction( &EE_ACTIONS::restartMove )
|
2020-12-02 23:17:56 +00:00
|
|
|
|| evt->IsAction( &EE_ACTIONS::move )
|
|
|
|
|| evt->IsAction( &EE_ACTIONS::drag )
|
|
|
|
|| evt->IsMotion()
|
|
|
|
|| evt->IsDrag( BUT_LEFT )
|
2019-07-04 20:56:21 +00:00
|
|
|
|| evt->IsAction( &ACTIONS::refreshPreview ) )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
|
|
|
if( !m_moveInProgress ) // Prepare to start moving/dragging
|
|
|
|
{
|
2019-06-11 20:17:05 +00:00
|
|
|
SCH_ITEM* sch_item = (SCH_ITEM*) selection.Front();
|
2020-01-10 17:22:23 +00:00
|
|
|
bool placingNewItems = sch_item && sch_item->IsNew();
|
2019-05-18 12:52:03 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Setup a drag or a move
|
|
|
|
//
|
2019-08-31 19:20:44 +00:00
|
|
|
m_dragAdditions.clear();
|
2020-05-06 10:53:56 +00:00
|
|
|
m_specialCaseLabels.clear();
|
2022-10-12 15:32:15 +00:00
|
|
|
m_specialCaseSheetPins.clear();
|
2019-10-19 03:15:29 +00:00
|
|
|
internalPoints.clear();
|
2022-02-10 18:38:40 +00:00
|
|
|
clearNewDragLines();
|
2019-08-31 19:20:44 +00:00
|
|
|
|
2020-10-12 09:32:51 +00:00
|
|
|
for( SCH_ITEM* it : m_frame->GetScreen()->Items() )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
it->ClearFlags( SELECTED_BY_DRAG );
|
2019-08-29 21:00:38 +00:00
|
|
|
|
2019-06-11 20:17:05 +00:00
|
|
|
if( !it->IsSelected() )
|
2019-08-29 21:00:38 +00:00
|
|
|
it->ClearFlags( STARTPOINT | ENDPOINT );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
2022-12-15 15:26:48 +00:00
|
|
|
// Drag of split items start over top of their other segment so
|
|
|
|
// we want to skip grabbing the segments we split from
|
2023-06-30 17:57:01 +00:00
|
|
|
if( m_isDrag && !aIsSlice )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2021-03-22 12:51:32 +00:00
|
|
|
EDA_ITEMS connectedDragItems;
|
|
|
|
|
2019-05-31 18:23:49 +00:00
|
|
|
// Add connections to the selection for a drag.
|
2022-12-27 16:23:34 +00:00
|
|
|
// Do all non-labels/entries first so we don't add junctions to drag
|
|
|
|
// when the line will eventually be drag selected.
|
|
|
|
std::vector<SCH_ITEM*> stageTwo;
|
|
|
|
|
2020-10-12 09:32:51 +00:00
|
|
|
for( EDA_ITEM* edaItem : selection )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2020-10-12 09:32:51 +00:00
|
|
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> connections;
|
2019-06-11 20:17:05 +00:00
|
|
|
|
2022-12-27 16:23:34 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
|
|
|
stageTwo.emplace_back(item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_LINE_T:
|
2020-09-11 16:31:38 +00:00
|
|
|
static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
|
2022-12-27 16:23:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-10-12 09:32:51 +00:00
|
|
|
connections = item->GetConnectionPoints();
|
2022-12-27 16:23:34 +00:00
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2023-01-12 15:17:26 +00:00
|
|
|
for( const VECTOR2I& point : connections )
|
2023-06-30 17:57:01 +00:00
|
|
|
getConnectedDragItems( aCommit, item, point, connectedDragItems );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
2022-12-27 16:23:34 +00:00
|
|
|
// Go back and get all label connections now that we can test for drag-selected
|
|
|
|
// lines the labels might be on
|
|
|
|
for( SCH_ITEM* item : stageTwo )
|
2023-01-12 15:17:26 +00:00
|
|
|
{
|
|
|
|
for( const VECTOR2I& point : item->GetConnectionPoints() )
|
2023-06-30 17:57:01 +00:00
|
|
|
getConnectedDragItems( aCommit, item, point, connectedDragItems );
|
2023-01-12 15:17:26 +00:00
|
|
|
}
|
2022-12-27 16:23:34 +00:00
|
|
|
|
2021-03-22 12:51:32 +00:00
|
|
|
for( EDA_ITEM* item : connectedDragItems )
|
|
|
|
{
|
|
|
|
m_dragAdditions.push_back( item->m_Uuid );
|
|
|
|
m_selectionTool->AddItemToSel( item, QUIET_MODE );
|
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
// Pre-cache all connections of our selected objects so we can keep track of
|
|
|
|
// what they were originally connected to as we drag them around
|
2022-02-10 18:38:40 +00:00
|
|
|
for( EDA_ITEM* edaItem : selection )
|
|
|
|
{
|
|
|
|
SCH_ITEM* schItem = static_cast<SCH_ITEM*>( edaItem );
|
|
|
|
|
|
|
|
if( schItem->Type() == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( schItem );
|
2022-10-12 14:14:41 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
//Also store the original angle of the line, is needed later to decide
|
|
|
|
//which segment to extend when they've become zero length
|
|
|
|
line->StoreAngle();
|
2022-10-12 14:14:41 +00:00
|
|
|
|
2023-01-12 15:17:26 +00:00
|
|
|
for( const VECTOR2I& point : line->GetConnectionPoints() )
|
2022-02-10 18:38:40 +00:00
|
|
|
getConnectedItems( line, point, m_lineConnectionCache[line] );
|
|
|
|
}
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2019-05-31 18:23:49 +00:00
|
|
|
else
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2019-05-31 18:23:49 +00:00
|
|
|
// Mark the edges of the block with dangling flags for a move.
|
2019-05-04 13:02:05 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
|
|
|
|
|
2024-02-12 08:01:45 +00:00
|
|
|
std::vector<DANGLING_END_ITEM> endPointsByType = internalPoints;
|
|
|
|
std::vector<DANGLING_END_ITEM> endPointsByPos = endPointsByType;
|
|
|
|
DANGLING_END_ITEM_HELPER::sort_dangling_end_items( endPointsByType,
|
|
|
|
endPointsByPos );
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2024-02-12 08:01:45 +00:00
|
|
|
static_cast<SCH_ITEM*>( item )->UpdateDanglingState( endPointsByType,
|
|
|
|
endPointsByPos );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2022-12-12 13:44:19 +00:00
|
|
|
|
2023-07-23 17:51:42 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
// Generic setup
|
2023-07-23 17:51:42 +00:00
|
|
|
snapLayer = grid.GetSelectionGrid( selection );
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2019-05-07 19:06:46 +00:00
|
|
|
if( item->IsNew() )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
// Item was added to commit in a previous command
|
2019-05-07 19:06:46 +00:00
|
|
|
}
|
|
|
|
else if( item->GetParent() && item->GetParent()->IsSelected() )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
// Item will be (or has been) added to commit by parent
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-02-09 10:19:26 +00:00
|
|
|
aCommit->Modify( item, m_frame->GetScreen() );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
2024-02-09 10:19:26 +00:00
|
|
|
item->SetFlags( IS_MOVING );
|
|
|
|
|
|
|
|
if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item ) )
|
|
|
|
schItem->SetStoredPos( schItem->GetPosition() );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the starting position and move/drag offset
|
|
|
|
//
|
|
|
|
m_cursor = controls->GetCursorPosition();
|
|
|
|
|
2019-06-11 14:17:24 +00:00
|
|
|
if( evt->IsAction( &EE_ACTIONS::restartMove ) )
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" );
|
|
|
|
}
|
2019-12-28 00:29:41 +00:00
|
|
|
else if( placingNewItems )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2019-05-31 18:23:49 +00:00
|
|
|
m_anchorPos = selection.GetReferencePoint();
|
2019-05-20 15:42:49 +00:00
|
|
|
}
|
|
|
|
|
2019-05-31 18:23:49 +00:00
|
|
|
if( m_anchorPos )
|
2019-05-20 15:42:49 +00:00
|
|
|
{
|
2019-05-31 18:23:49 +00:00
|
|
|
VECTOR2I delta = m_cursor - (*m_anchorPos);
|
2021-11-06 16:03:41 +00:00
|
|
|
bool isPasted = false;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
// Drag items to the current cursor position
|
2019-05-06 15:30:29 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
|
|
|
// Don't double move pins, fields, etc.
|
|
|
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
|
|
|
continue;
|
|
|
|
|
2020-04-19 16:04:14 +00:00
|
|
|
moveItem( item, delta );
|
2020-10-30 15:15:20 +00:00
|
|
|
updateItem( item, false );
|
2021-11-06 16:03:41 +00:00
|
|
|
|
2022-01-01 19:40:27 +00:00
|
|
|
isPasted |= ( item->GetFlags() & IS_PASTED ) != 0;
|
2021-11-06 16:03:41 +00:00
|
|
|
item->ClearFlags( IS_PASTED );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
// The first time pasted items are moved we need to store the position of the
|
|
|
|
// cursor so that rotate while moving works as expected (instead of around the
|
|
|
|
// original anchor point
|
2021-11-06 16:03:41 +00:00
|
|
|
if( isPasted )
|
|
|
|
selection.SetReferencePoint( m_cursor );
|
|
|
|
|
2019-05-31 18:23:49 +00:00
|
|
|
m_anchorPos = m_cursor;
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2019-06-11 14:17:24 +00:00
|
|
|
// For some items, moving the cursor to anchor is not good (for instance large
|
2021-03-29 10:46:05 +00:00
|
|
|
// hierarchical sheets or symbols can have the anchor outside the view)
|
2020-09-09 17:08:24 +00:00
|
|
|
else if( selection.Size() == 1 && !sch_item->IsMovableFromAnchorPoint() )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2020-09-09 17:08:24 +00:00
|
|
|
m_cursor = getViewControls()->GetCursorPosition( true );
|
|
|
|
m_anchorPos = m_cursor;
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-18 00:16:08 +00:00
|
|
|
if( m_frame->GetMoveWarpsCursor() )
|
|
|
|
{
|
|
|
|
// User wants to warp the mouse
|
2020-12-03 15:10:23 +00:00
|
|
|
m_cursor = grid.BestDragOrigin( m_cursor, snapLayer, selection );
|
2021-10-18 12:24:06 +00:00
|
|
|
selection.SetReferencePoint( m_cursor );
|
2020-09-18 00:16:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// User does not want to warp the mouse
|
|
|
|
m_cursor = getViewControls()->GetCursorPosition( true );
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
controls->SetCursorPosition( m_cursor, false );
|
|
|
|
|
|
|
|
prevPos = m_cursor;
|
|
|
|
controls->SetAutoPan( true );
|
|
|
|
m_moveInProgress = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Follow the mouse
|
|
|
|
//
|
2020-12-02 23:17:56 +00:00
|
|
|
m_cursor = grid.BestSnapAnchor( controls->GetCursorPosition( false ),
|
2020-12-03 15:10:23 +00:00
|
|
|
snapLayer, selection );
|
2020-12-02 23:17:56 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
VECTOR2I delta( m_cursor - prevPos );
|
2019-05-31 18:23:49 +00:00
|
|
|
m_anchorPos = m_cursor;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2022-02-14 22:52:34 +00:00
|
|
|
// We need to check if the movement will change the net offset direction on the
|
|
|
|
// X an Y axes. This is because we remerge added bend lines in realtime, and we
|
|
|
|
// also account for the direction of the move when adding bend lines. So, if the
|
|
|
|
// move direction changes, we need to split it into a move that gets us back to
|
|
|
|
// zero, then the rest of the move.
|
|
|
|
std::vector<VECTOR2I> splitMoves;
|
|
|
|
|
2022-03-22 16:49:38 +00:00
|
|
|
if( alg::signbit( m_moveOffset.x ) != alg::signbit( ( m_moveOffset + delta ).x ) )
|
2022-02-14 22:52:34 +00:00
|
|
|
{
|
|
|
|
splitMoves.emplace_back( VECTOR2I( -1 * m_moveOffset.x, 0 ) );
|
|
|
|
splitMoves.emplace_back( VECTOR2I( delta.x + m_moveOffset.x, 0 ) );
|
|
|
|
}
|
|
|
|
else
|
2022-06-09 15:53:24 +00:00
|
|
|
{
|
2022-02-14 22:52:34 +00:00
|
|
|
splitMoves.emplace_back( VECTOR2I( delta.x, 0 ) );
|
2022-06-09 15:53:24 +00:00
|
|
|
}
|
2022-02-14 22:52:34 +00:00
|
|
|
|
2022-03-22 16:49:38 +00:00
|
|
|
if( alg::signbit( m_moveOffset.y ) != alg::signbit( ( m_moveOffset + delta ).y ) )
|
2022-02-14 22:52:34 +00:00
|
|
|
{
|
|
|
|
splitMoves.emplace_back( VECTOR2I( 0, -1 * m_moveOffset.y ) );
|
|
|
|
splitMoves.emplace_back( VECTOR2I( 0, delta.y + m_moveOffset.y ) );
|
|
|
|
}
|
|
|
|
else
|
2022-06-09 15:53:24 +00:00
|
|
|
{
|
2022-02-14 22:52:34 +00:00
|
|
|
splitMoves.emplace_back( VECTOR2I( 0, delta.y ) );
|
2022-06-09 15:53:24 +00:00
|
|
|
}
|
2022-02-14 22:52:34 +00:00
|
|
|
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
m_moveOffset += delta;
|
|
|
|
prevPos = m_cursor;
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
// Used for tracking how far off a drag end should have its 90 degree elbow added
|
|
|
|
int xBendCount = 1;
|
|
|
|
int yBendCount = 1;
|
|
|
|
|
|
|
|
// Split the move into X and Y moves so we can correctly drag orthogonal lines
|
2023-01-12 15:17:26 +00:00
|
|
|
for( const VECTOR2I& splitDelta : splitMoves )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
// Skip non-moves
|
|
|
|
if( splitDelta == VECTOR2I( 0, 0 ) )
|
2019-05-04 13:02:05 +00:00
|
|
|
continue;
|
|
|
|
|
2022-09-27 13:11:38 +00:00
|
|
|
for( EDA_ITEM* item : selection.GetItemsSortedByTypeAndXY( ( delta.x >= 0 ),
|
|
|
|
( delta.y >= 0 ) ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
|
|
|
// Don't double move pins, fields, etc.
|
|
|
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
|
|
|
continue;
|
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2022-10-12 14:14:41 +00:00
|
|
|
// Only partially selected drag lines in orthogonal line mode need special
|
|
|
|
// handling
|
2022-09-27 13:11:38 +00:00
|
|
|
if( m_isDrag
|
|
|
|
&& cfg->m_Drawing.line_mode != LINE_MODE::LINE_MODE_FREE
|
|
|
|
&& line
|
|
|
|
&& line->HasFlag( STARTPOINT ) != line->HasFlag( ENDPOINT ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
2023-06-30 17:57:01 +00:00
|
|
|
orthoLineDrag( aCommit, line, splitDelta, xBendCount, yBendCount, grid );
|
2022-02-10 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:14:41 +00:00
|
|
|
// Move all other items normally, including the selected end of partially
|
|
|
|
// selected lines
|
2022-02-10 18:38:40 +00:00
|
|
|
moveItem( item, splitDelta );
|
|
|
|
updateItem( item, false );
|
2022-10-12 15:32:15 +00:00
|
|
|
|
|
|
|
// Update any lines connected to sheet pins to the sheet pin's location
|
|
|
|
// (which may not exactly follow the splitDelta as the pins are constrained
|
|
|
|
// along the sheet edges.
|
|
|
|
for( const auto& [pin, lineEnd] : m_specialCaseSheetPins )
|
|
|
|
{
|
2022-12-27 17:14:18 +00:00
|
|
|
if( lineEnd.second && lineEnd.first->HasFlag( STARTPOINT ) )
|
2022-10-12 15:32:15 +00:00
|
|
|
lineEnd.first->SetStartPoint( pin->GetPosition() );
|
2022-12-27 17:14:18 +00:00
|
|
|
else if( !lineEnd.second && lineEnd.first->HasFlag( ENDPOINT ) )
|
2022-10-12 15:32:15 +00:00
|
|
|
lineEnd.first->SetEndPoint( pin->GetPosition() );
|
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 12:24:06 +00:00
|
|
|
if( selection.HasReferencePoint() )
|
|
|
|
selection.SetReferencePoint( selection.GetReferencePoint() + delta );
|
|
|
|
|
2020-08-15 18:38:01 +00:00
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Handle cancel
|
|
|
|
//
|
2021-01-25 17:39:37 +00:00
|
|
|
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-03-17 15:26:49 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
|
|
|
m_frame->GetInfoBar()->Dismiss();
|
|
|
|
|
2021-01-25 17:39:37 +00:00
|
|
|
if( m_moveInProgress )
|
2021-05-08 19:49:09 +00:00
|
|
|
{
|
|
|
|
if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
// Allowing other tools to activate during a move runs the risk of race
|
|
|
|
// conditions in which we try to spool up both event loops at once.
|
|
|
|
|
|
|
|
if( m_isDrag )
|
|
|
|
m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel drag." ) );
|
|
|
|
else
|
|
|
|
m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel move." ) );
|
|
|
|
|
|
|
|
evt->SetPassEvent( false );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
evt->SetPassEvent( false );
|
2019-05-04 13:02:05 +00:00
|
|
|
restore_state = true;
|
2021-05-08 19:49:09 +00:00
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
clearNewDragLines();
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Handle TOOL_ACTION special cases
|
|
|
|
//
|
|
|
|
else if( evt->Action() == TA_UNDO_REDO_PRE )
|
|
|
|
{
|
|
|
|
unselect = true;
|
|
|
|
break;
|
|
|
|
}
|
2020-09-18 15:44:01 +00:00
|
|
|
else if( evt->IsAction( &ACTIONS::doDelete ) )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2021-03-15 14:23:17 +00:00
|
|
|
evt->SetPassEvent();
|
|
|
|
// Exit on a delete; there will no longer be anything to drag.
|
2020-09-18 15:44:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if( evt->IsAction( &ACTIONS::duplicate ) )
|
|
|
|
{
|
2023-07-01 21:35:39 +00:00
|
|
|
wxBell();
|
2020-09-18 15:44:01 +00:00
|
|
|
}
|
2022-07-21 12:35:35 +00:00
|
|
|
else if( evt->IsAction( &EE_ACTIONS::rotateCW ) )
|
|
|
|
{
|
2023-06-30 17:57:01 +00:00
|
|
|
m_toolMgr->RunSynchronousAction( EE_ACTIONS::rotateCW, aCommit );
|
2022-07-21 12:35:35 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsAction( &EE_ACTIONS::rotateCCW ) )
|
|
|
|
{
|
2023-06-30 17:57:01 +00:00
|
|
|
m_toolMgr->RunSynchronousAction( EE_ACTIONS::rotateCCW, aCommit );
|
2022-07-21 12:35:35 +00:00
|
|
|
}
|
2020-09-18 15:44:01 +00:00
|
|
|
else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
|
|
|
|
{
|
2023-08-28 11:29:47 +00:00
|
|
|
if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT
|
|
|
|
&& *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_END )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
|
2023-08-28 11:29:47 +00:00
|
|
|
int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT;
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
if( symbol )
|
2020-09-18 15:44:01 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
m_frame->SelectUnit( symbol, unit );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( ACTIONS::refreshPreview );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-21 12:25:22 +00:00
|
|
|
else if( evt->IsAction( &EE_ACTIONS::highlightNet )
|
|
|
|
|| evt->IsAction( &EE_ACTIONS::selectOnPCB ) )
|
|
|
|
{
|
|
|
|
// These don't make any sense during a move. Eat them.
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Handle context menu
|
|
|
|
//
|
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Handle drop
|
|
|
|
//
|
2020-12-14 22:03:17 +00:00
|
|
|
else if( evt->IsMouseUp( BUT_LEFT )
|
|
|
|
|| evt->IsClick( BUT_LEFT )
|
|
|
|
|| evt->IsDblClick( BUT_LEFT ) )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
|
|
|
break; // Finish
|
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2021-03-15 14:23:17 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2021-03-15 14:23:17 +00:00
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2019-05-31 17:45:43 +00:00
|
|
|
controls->SetAutoPan( m_moveInProgress );
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
} while( ( evt = Wait() ) ); //Should be assignment not equality test
|
|
|
|
|
2022-04-12 19:32:27 +00:00
|
|
|
// Create a selection of original selection, drag selected/changed items, and new
|
2023-06-30 17:57:01 +00:00
|
|
|
// bend lines for later before we clear them in the aCommit. We'll need these
|
2022-04-12 19:32:27 +00:00
|
|
|
// to check for new junctions needed, etc.
|
|
|
|
EE_SELECTION selectionCopy( selection );
|
|
|
|
|
|
|
|
for( SCH_LINE* line : m_newDragLines )
|
|
|
|
selectionCopy.Add( line );
|
|
|
|
|
|
|
|
for( SCH_LINE* line : m_changedDragLines )
|
|
|
|
selectionCopy.Add( line );
|
|
|
|
|
2022-02-18 17:40:39 +00:00
|
|
|
// Save whatever new bend lines and changed lines survived the drag
|
2023-06-09 16:24:49 +00:00
|
|
|
for( SCH_LINE* newLine : m_newDragLines )
|
|
|
|
{
|
|
|
|
newLine->ClearEditFlags();
|
2023-06-30 17:57:01 +00:00
|
|
|
aCommit->Added( newLine, m_frame->GetScreen() );
|
2023-06-09 16:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// These lines have been changed, but aren't selected. We need
|
|
|
|
// to manually clear these edit flags or they'll stick around.
|
|
|
|
for( SCH_LINE* oldLine : m_changedDragLines )
|
|
|
|
oldLine->ClearEditFlags();
|
|
|
|
|
|
|
|
m_newDragLines.clear();
|
|
|
|
m_changedDragLines.clear();
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
controls->ForceCursorPosition( false );
|
|
|
|
controls->ShowCursor( false );
|
|
|
|
controls->SetAutoPan( false );
|
|
|
|
|
2023-07-01 21:35:39 +00:00
|
|
|
m_moveOffset = { 0, 0 };
|
2019-05-31 18:23:49 +00:00
|
|
|
m_anchorPos.reset();
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
if( restore_state )
|
|
|
|
{
|
2019-06-25 23:39:58 +00:00
|
|
|
m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-30 15:15:20 +00:00
|
|
|
// One last update after exiting loop (for slower stuff, such as updating SCREEN's RTree).
|
2020-12-27 12:36:11 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2023-06-05 16:11:16 +00:00
|
|
|
{
|
2020-10-30 15:15:20 +00:00
|
|
|
updateItem( item, true );
|
2019-06-25 23:39:58 +00:00
|
|
|
|
2023-06-05 16:11:16 +00:00
|
|
|
if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
|
|
|
|
sch_item->SetConnectivityDirty( true );
|
|
|
|
}
|
|
|
|
|
2023-09-02 10:56:26 +00:00
|
|
|
if( selection.GetSize() == 1 && selection.Front()->IsNew() )
|
|
|
|
m_frame->SaveCopyForRepeatItem( static_cast<SCH_ITEM*>( selection.Front() ) );
|
|
|
|
|
2020-12-27 13:16:16 +00:00
|
|
|
m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
|
|
|
|
|
2019-10-19 03:15:29 +00:00
|
|
|
// If we move items away from a junction, we _may_ want to add a junction there
|
|
|
|
// to denote the state.
|
2020-12-27 12:36:11 +00:00
|
|
|
for( const DANGLING_END_ITEM& it : internalPoints )
|
2019-10-19 03:15:29 +00:00
|
|
|
{
|
2021-11-04 12:38:15 +00:00
|
|
|
if( m_frame->GetScreen()->IsExplicitJunctionNeeded( it.GetPosition()) )
|
2023-06-30 17:57:01 +00:00
|
|
|
m_frame->AddJunction( aCommit, m_frame->GetScreen(), it.GetPosition() );
|
2019-10-19 03:15:29 +00:00
|
|
|
}
|
|
|
|
|
2023-01-06 22:14:06 +00:00
|
|
|
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
2023-06-30 17:57:01 +00:00
|
|
|
lwbTool->TrimOverLappingWires( aCommit, &selectionCopy );
|
|
|
|
lwbTool->AddJunctionsIfNeeded( aCommit, &selectionCopy );
|
2019-10-19 03:15:29 +00:00
|
|
|
|
2022-11-30 21:45:31 +00:00
|
|
|
// This needs to run prior to `RecalculateConnections` because we need to identify
|
|
|
|
// the lines that are newly dangling
|
2023-06-30 17:57:01 +00:00
|
|
|
if( m_isDrag && !aIsSlice )
|
|
|
|
trimDanglingLines( aCommit );
|
2019-05-16 21:27:03 +00:00
|
|
|
|
2022-12-28 19:30:57 +00:00
|
|
|
// Auto-rotate any moved labels
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
m_frame->AutoRotateItem( m_frame->GetScreen(), static_cast<SCH_ITEM*>( item ) );
|
|
|
|
|
2023-06-30 17:57:01 +00:00
|
|
|
m_frame->SchematicCleanUp( aCommit );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 18:04:36 +00:00
|
|
|
for( EDA_ITEM* item : m_frame->GetScreen()->Items() )
|
2022-12-01 18:12:12 +00:00
|
|
|
item->ClearEditFlags();
|
|
|
|
|
2023-01-08 10:52:21 +00:00
|
|
|
// ensure any selected item not in screen main list (for instance symbol fields)
|
|
|
|
// has its edit flags cleared
|
|
|
|
for( EDA_ITEM* item : selectionCopy )
|
|
|
|
item->ClearEditFlags();
|
|
|
|
|
2019-08-29 21:00:38 +00:00
|
|
|
if( unselect )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection );
|
2019-08-29 21:00:38 +00:00
|
|
|
else
|
2019-08-31 19:20:44 +00:00
|
|
|
m_selectionTool->RebuildSelection(); // Schematic cleanup might have merged lines, etc.
|
2019-08-29 21:00:38 +00:00
|
|
|
|
2019-05-18 12:52:03 +00:00
|
|
|
m_dragAdditions.clear();
|
2022-02-10 18:38:40 +00:00
|
|
|
m_lineConnectionCache.clear();
|
2019-06-15 00:29:42 +00:00
|
|
|
m_moveInProgress = false;
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2023-01-08 10:52:21 +00:00
|
|
|
|
2023-06-30 17:57:01 +00:00
|
|
|
return !restore_state;
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void SCH_MOVE_TOOL::trimDanglingLines( SCH_COMMIT* aCommit )
|
2022-11-30 21:45:31 +00:00
|
|
|
{
|
|
|
|
// Need a local cleanup first to ensure we remove unneeded junctions
|
2023-06-09 16:24:49 +00:00
|
|
|
m_frame->SchematicCleanUp( aCommit, m_frame->GetScreen() );
|
2022-11-30 21:45:31 +00:00
|
|
|
|
|
|
|
std::set<SCH_ITEM*> danglers;
|
|
|
|
|
|
|
|
std::function<void( SCH_ITEM* )> changeHandler =
|
|
|
|
[&]( SCH_ITEM* aChangedItem ) -> void
|
|
|
|
{
|
|
|
|
m_toolMgr->GetView()->Update( aChangedItem, KIGFX::REPAINT );
|
|
|
|
|
2022-12-01 18:12:12 +00:00
|
|
|
// Delete newly dangling lines:
|
|
|
|
// Find split segments (one segment is new, the other is changed) that
|
|
|
|
// we aren't dragging and don't have selected
|
2023-03-06 12:12:11 +00:00
|
|
|
if( aChangedItem->HasFlag( IS_BROKEN) && aChangedItem->IsDangling()
|
|
|
|
&& !aChangedItem->IsSelected() )
|
2022-12-01 18:12:12 +00:00
|
|
|
{
|
2022-11-30 21:45:31 +00:00
|
|
|
danglers.insert( aChangedItem );
|
2022-12-01 18:12:12 +00:00
|
|
|
}
|
2022-11-30 21:45:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
m_frame->GetScreen()->TestDanglingEnds( nullptr, &changeHandler );
|
|
|
|
|
|
|
|
for( SCH_ITEM* line : danglers )
|
|
|
|
{
|
|
|
|
line->SetFlags( STRUCT_DELETED );
|
2023-06-09 16:24:49 +00:00
|
|
|
aCommit->Removed( line, m_frame->GetScreen() );
|
2022-11-30 21:45:31 +00:00
|
|
|
|
|
|
|
updateItem( line, false );
|
|
|
|
m_frame->RemoveFromScreen( line, m_frame->GetScreen() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
void SCH_MOVE_TOOL::getConnectedItems( SCH_ITEM* aOriginalItem, const VECTOR2I& aPoint,
|
|
|
|
EDA_ITEMS& aList )
|
|
|
|
{
|
|
|
|
EE_RTREE& items = m_frame->GetScreen()->Items();
|
|
|
|
EE_RTREE::EE_TYPE itemsOverlapping = items.Overlapping( aOriginalItem->GetBoundingBox() );
|
2022-03-03 14:35:57 +00:00
|
|
|
SCH_ITEM* foundJunction = nullptr;
|
|
|
|
SCH_ITEM* foundSymbol = nullptr;
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2022-03-03 14:35:57 +00:00
|
|
|
// If you're connected to a junction, you're only connected to the junction.
|
|
|
|
//
|
|
|
|
// But, if you're connected to a junction on a pin, you're only connected to the pin. This
|
2022-10-12 14:14:41 +00:00
|
|
|
// is because junctions and pins have different logic for how bend lines are generated and
|
|
|
|
// we need to prioritize the pin version in some cases.
|
2022-02-10 18:38:40 +00:00
|
|
|
for( SCH_ITEM* item : itemsOverlapping )
|
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
if( item != aOriginalItem && item->IsConnected( aPoint ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
if( item->Type() == SCH_JUNCTION_T )
|
|
|
|
foundJunction = item;
|
|
|
|
else if( item->Type() == SCH_SYMBOL_T )
|
|
|
|
foundSymbol = item;
|
2022-02-10 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 14:35:57 +00:00
|
|
|
if( foundSymbol && foundJunction )
|
|
|
|
{
|
|
|
|
aList.push_back( foundSymbol );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( foundJunction )
|
|
|
|
{
|
|
|
|
aList.push_back( foundJunction );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
for( SCH_ITEM* test : itemsOverlapping )
|
|
|
|
{
|
|
|
|
if( test == aOriginalItem || !test->CanConnect( aOriginalItem ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( test->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
|
|
|
{
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( test );
|
|
|
|
|
2022-10-12 14:14:41 +00:00
|
|
|
// When getting lines for the connection cache, it's important that we only add
|
|
|
|
// items at the unselected end, since that is the only end that is handled specially.
|
|
|
|
// Fully selected lines, and the selected end of a partially selected line, are moved
|
|
|
|
// around normally and don't care about their connections.
|
2022-02-10 18:38:40 +00:00
|
|
|
if( ( line->HasFlag( STARTPOINT ) && aPoint == line->GetStartPoint() )
|
|
|
|
|| ( line->HasFlag( ENDPOINT ) && aPoint == line->GetEndPoint() ) )
|
2022-10-12 14:14:41 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
continue;
|
2022-10-12 14:14:41 +00:00
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
|
|
|
|
if( test->IsConnected( aPoint ) )
|
|
|
|
aList.push_back( test );
|
|
|
|
|
|
|
|
// Labels can connect to a wire (or bus) anywhere along the length
|
2022-10-12 14:14:41 +00:00
|
|
|
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( aOriginalItem ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
2022-10-12 14:14:41 +00:00
|
|
|
if( static_cast<SCH_LINE*>( test )->HitTest( label->GetPosition(), 1 ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
aList.push_back( test );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2022-10-12 14:14:41 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
case SCH_SHEET_T:
|
2022-10-12 15:32:15 +00:00
|
|
|
if( aOriginalItem->Type() == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aOriginalItem );
|
|
|
|
|
|
|
|
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( test )->GetPins() )
|
|
|
|
{
|
|
|
|
if( pin->IsConnected( aPoint ) )
|
|
|
|
m_specialCaseSheetPins[ pin ] = { line, line->GetStartPoint() == aPoint };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
KI_FALLTHROUGH;
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
case SCH_SYMBOL_T:
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
if( test->IsConnected( aPoint ) )
|
|
|
|
aList.push_back( test );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
2022-10-12 14:14:41 +00:00
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
2022-02-10 18:38:40 +00:00
|
|
|
// Labels can connect to a wire (or bus) anywhere along the length
|
|
|
|
if( aOriginalItem->Type() == SCH_LINE_T && test->CanConnect( aOriginalItem ) )
|
|
|
|
{
|
2022-10-12 14:14:41 +00:00
|
|
|
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( test );
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aOriginalItem );
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2022-10-12 14:14:41 +00:00
|
|
|
if( line->HitTest( label->GetPosition(), 1 ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
aList.push_back( label );
|
|
|
|
}
|
2022-10-12 14:14:41 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
break;
|
2022-10-12 14:14:41 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
if( aOriginalItem->Type() == SCH_LINE_T && test->CanConnect( aOriginalItem ) )
|
|
|
|
{
|
|
|
|
SCH_TEXT* label = static_cast<SCH_TEXT*>( test );
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aOriginalItem );
|
|
|
|
|
|
|
|
if( line->HitTest( aPoint, 1 ) )
|
|
|
|
aList.push_back( label );
|
|
|
|
}
|
2022-10-12 14:14:41 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
break;
|
|
|
|
|
2022-10-12 14:14:41 +00:00
|
|
|
default:
|
|
|
|
break;
|
2022-02-10 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void SCH_MOVE_TOOL::getConnectedDragItems( SCH_COMMIT* aCommit, SCH_ITEM* aSelectedItem,
|
2023-06-09 16:24:49 +00:00
|
|
|
const VECTOR2I& aPoint, EDA_ITEMS& aList )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2020-10-12 09:32:51 +00:00
|
|
|
EE_RTREE& items = m_frame->GetScreen()->Items();
|
2022-10-12 15:32:15 +00:00
|
|
|
EE_RTREE::EE_TYPE itemsOverlappingRTree = items.Overlapping( aSelectedItem->GetBoundingBox() );
|
2022-02-10 18:38:40 +00:00
|
|
|
std::vector<SCH_ITEM*> itemsConnectable;
|
2020-10-13 12:52:15 +00:00
|
|
|
bool ptHasUnselectedJunction = false;
|
2022-10-12 15:32:15 +00:00
|
|
|
|
|
|
|
auto makeNewWire =
|
2023-06-09 21:41:33 +00:00
|
|
|
[this]( SCH_COMMIT* commit, SCH_ITEM* fixed, SCH_ITEM* selected, const VECTOR2I& start,
|
|
|
|
const VECTOR2I& end )
|
2022-10-12 15:32:15 +00:00
|
|
|
{
|
|
|
|
SCH_LINE* newWire;
|
|
|
|
|
|
|
|
// Add a new newWire between the fixed item and the selected item so the selected
|
|
|
|
// item can be dragged.
|
2023-01-12 15:17:26 +00:00
|
|
|
if( fixed->GetLayer() == LAYER_BUS_JUNCTION || fixed->GetLayer() == LAYER_BUS
|
|
|
|
|| selected->GetLayer() == LAYER_BUS )
|
|
|
|
{
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire = new SCH_LINE( start, LAYER_BUS );
|
2023-01-12 15:17:26 +00:00
|
|
|
}
|
2022-10-12 15:32:15 +00:00
|
|
|
else
|
2023-01-12 15:17:26 +00:00
|
|
|
{
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire = new SCH_LINE( start, LAYER_WIRE );
|
2023-01-12 15:17:26 +00:00
|
|
|
}
|
2022-10-12 15:32:15 +00:00
|
|
|
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire->SetFlags( IS_NEW );
|
2022-10-12 15:32:15 +00:00
|
|
|
newWire->SetConnectivityDirty( true );
|
2023-07-13 17:20:01 +00:00
|
|
|
|
|
|
|
if( dynamic_cast<const SCH_LINE*>( selected ) )
|
|
|
|
newWire->SetLastResolvedState( selected );
|
|
|
|
else if( dynamic_cast<const SCH_LINE*>( fixed ) )
|
|
|
|
newWire->SetLastResolvedState( fixed );
|
2022-10-12 15:32:15 +00:00
|
|
|
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire->SetEndPoint( end );
|
|
|
|
m_frame->AddToScreen( newWire, m_frame->GetScreen() );
|
2023-06-09 16:24:49 +00:00
|
|
|
commit->Added( newWire, m_frame->GetScreen() );
|
2022-10-12 15:32:15 +00:00
|
|
|
|
|
|
|
return newWire;
|
|
|
|
};
|
2020-10-12 09:32:51 +00:00
|
|
|
|
2022-11-25 15:04:36 +00:00
|
|
|
auto makeNewJunction =
|
2023-06-09 21:41:33 +00:00
|
|
|
[this]( SCH_COMMIT* commit, SCH_LINE* line, const VECTOR2I& pt )
|
2022-11-25 15:04:36 +00:00
|
|
|
{
|
|
|
|
SCH_JUNCTION* junction = new SCH_JUNCTION( pt );
|
|
|
|
junction->SetFlags( IS_NEW );
|
|
|
|
junction->SetConnectivityDirty( true );
|
|
|
|
junction->SetLastResolvedState( line );
|
|
|
|
|
2023-01-12 15:17:26 +00:00
|
|
|
if( line->IsBus() )
|
|
|
|
junction->SetLayer( LAYER_BUS_JUNCTION );
|
|
|
|
|
2022-11-25 15:04:36 +00:00
|
|
|
m_frame->AddToScreen( junction, m_frame->GetScreen() );
|
2023-06-09 16:24:49 +00:00
|
|
|
commit->Added( junction, m_frame->GetScreen() );
|
2022-11-25 15:04:36 +00:00
|
|
|
|
|
|
|
return junction;
|
|
|
|
};
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
for( SCH_ITEM* item : itemsOverlappingRTree )
|
|
|
|
{
|
|
|
|
// Skip ourselves, skip already selected items (but not lines, they need both ends tested)
|
|
|
|
// and skip unconnectable items
|
2022-10-12 15:32:15 +00:00
|
|
|
if( item == aSelectedItem || ( item->Type() != SCH_LINE_T && item->IsSelected() )
|
|
|
|
|| !item->CanConnect( aSelectedItem ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
itemsConnectable.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : itemsConnectable )
|
2020-10-12 09:32:51 +00:00
|
|
|
{
|
2020-10-13 12:52:15 +00:00
|
|
|
if( item->Type() == SCH_JUNCTION_T && item->IsConnected( aPoint ) && !item->IsSelected() )
|
2020-10-12 09:32:51 +00:00
|
|
|
{
|
2020-10-13 12:52:15 +00:00
|
|
|
ptHasUnselectedJunction = true;
|
2020-10-12 09:32:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-11 16:31:38 +00:00
|
|
|
|
2022-10-12 15:32:15 +00:00
|
|
|
SCH_LINE* newWire = nullptr;
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
for( SCH_ITEM* test : itemsConnectable )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2019-11-17 18:55:27 +00:00
|
|
|
KICAD_T testType = test->Type();
|
|
|
|
|
|
|
|
switch( testType )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
|
|
|
{
|
2020-10-13 12:52:15 +00:00
|
|
|
// Select the connected end of wires/bus connections that don't have an unselected
|
|
|
|
// junction isolating them from the drag
|
|
|
|
if( ptHasUnselectedJunction )
|
2020-10-12 09:32:51 +00:00
|
|
|
break;
|
|
|
|
|
2021-04-07 13:37:58 +00:00
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( test );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2021-04-07 13:37:58 +00:00
|
|
|
if( line->GetStartPoint() == aPoint )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
// It's possible to manually select one end of a line and get a drag
|
|
|
|
// connected other end, so we set the flag and then early exit the loop
|
|
|
|
// later if the other drag items like labels attached to the line have
|
|
|
|
// already been grabbed during the partial selection process.
|
|
|
|
line->SetFlags( STARTPOINT );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2022-03-03 14:35:57 +00:00
|
|
|
if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) )
|
2022-12-12 13:44:19 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
continue;
|
2022-12-12 13:44:19 +00:00
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
else
|
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
line->SetFlags( SELECTED_BY_DRAG );
|
2022-02-10 18:38:40 +00:00
|
|
|
aList.push_back( line );
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2021-04-07 13:37:58 +00:00
|
|
|
else if( line->GetEndPoint() == aPoint )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
line->SetFlags( ENDPOINT );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2022-03-03 14:35:57 +00:00
|
|
|
if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) )
|
2022-12-12 13:44:19 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
continue;
|
2022-12-12 13:44:19 +00:00
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
else
|
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
line->SetFlags( SELECTED_BY_DRAG );
|
2022-02-10 18:38:40 +00:00
|
|
|
aList.push_back( line );
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2020-05-06 19:35:46 +00:00
|
|
|
else
|
|
|
|
{
|
2022-10-12 15:32:15 +00:00
|
|
|
switch( aSelectedItem->Type() )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
|
|
|
// These items can connect anywhere along a line
|
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
2022-10-12 15:32:15 +00:00
|
|
|
// Only add a line if this line is unselected; if the label and line are both
|
|
|
|
// selected they'll move together
|
2022-12-27 16:23:34 +00:00
|
|
|
if( line->HitTest( aPoint, 1 ) && !line->HasFlag( SELECTED )
|
|
|
|
&& !line->HasFlag( SELECTED_BY_DRAG ) )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
newWire = makeNewWire( aCommit, line, aSelectedItem, aPoint, aPoint );
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
|
|
|
|
newWire->StoreAngle( ( line->Angle() + ANGLE_90 ).Normalize() );
|
|
|
|
aList.push_back( newWire );
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2022-10-03 21:11:30 +00:00
|
|
|
if( aPoint != line->GetStartPoint() && aPoint != line->GetEndPoint() )
|
|
|
|
{
|
2022-11-25 15:04:36 +00:00
|
|
|
// Split line in half
|
|
|
|
if( !line->IsNew() )
|
2023-06-09 16:24:49 +00:00
|
|
|
aCommit->Modify( line, m_frame->GetScreen() );
|
2022-11-25 15:04:36 +00:00
|
|
|
|
|
|
|
VECTOR2I oldEnd = line->GetEndPoint();
|
2022-10-03 21:11:30 +00:00
|
|
|
line->SetEndPoint( aPoint );
|
|
|
|
|
2023-06-09 16:24:49 +00:00
|
|
|
makeNewWire( aCommit, line, line, aPoint, oldEnd );
|
|
|
|
makeNewJunction( aCommit, line, aPoint );
|
2022-11-25 15:04:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_lineConnectionCache[ newWire ] = { line };
|
|
|
|
m_lineConnectionCache[ line ] = { newWire };
|
|
|
|
}
|
2022-02-10 18:38:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2022-10-03 20:40:47 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2022-02-10 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 19:35:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-06 10:53:56 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
// Since only one end is going to move, the movement vector of any labels attached to
|
|
|
|
// it is scaled by the proportion of the line length the label is from the moving end.
|
2022-02-10 18:38:40 +00:00
|
|
|
for( SCH_ITEM* item : items.Overlapping( line->GetBoundingBox() ) )
|
2020-05-06 10:53:56 +00:00
|
|
|
{
|
2022-10-03 20:40:47 +00:00
|
|
|
SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item );
|
2020-10-12 09:32:51 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
if( !label || label->IsSelected() )
|
|
|
|
continue; // These will be moved on their own because they're selected
|
2021-04-07 13:37:58 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
if( label->HasFlag( SELECTED_BY_DRAG ) )
|
|
|
|
continue;
|
2020-05-06 10:53:56 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
if( label->CanConnect( line ) && line->HitTest( label->GetPosition(), 1 ) )
|
|
|
|
{
|
|
|
|
label->SetFlags( SELECTED_BY_DRAG );
|
|
|
|
aList.push_back( label );
|
2022-02-10 18:38:40 +00:00
|
|
|
|
2022-10-03 20:40:47 +00:00
|
|
|
SPECIAL_CASE_LABEL_INFO info;
|
|
|
|
info.attachedLine = line;
|
|
|
|
info.originalLabelPos = label->GetPosition();
|
|
|
|
m_specialCaseLabels[label] = info;
|
2020-05-06 10:53:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
2022-10-12 15:32:15 +00:00
|
|
|
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( test )->GetPins() )
|
|
|
|
{
|
|
|
|
if( pin->IsConnected( aPoint ) )
|
|
|
|
{
|
|
|
|
if( pin->IsSelected() && aSelectedItem->Type() == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aSelectedItem );
|
|
|
|
m_specialCaseSheetPins[ pin ] = { line, line->GetStartPoint() == aPoint };
|
|
|
|
}
|
|
|
|
else if( !newWire )
|
|
|
|
{
|
|
|
|
// Add a new wire between the sheetpin and the selected item so the
|
|
|
|
// selected item can be dragged.
|
2023-06-09 16:24:49 +00:00
|
|
|
newWire = makeNewWire( aCommit, pin, aSelectedItem, aPoint, aPoint );
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
|
|
|
|
aList.push_back( newWire );
|
2022-10-12 15:32:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
case SCH_SYMBOL_T:
|
2020-10-12 09:32:51 +00:00
|
|
|
case SCH_JUNCTION_T:
|
2022-02-10 18:38:40 +00:00
|
|
|
if( test->IsConnected( aPoint ) && !newWire )
|
2019-05-07 11:00:24 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
// Add a new wire between the symbol or junction and the selected item so
|
2020-10-12 09:32:51 +00:00
|
|
|
// the selected item can be dragged.
|
2023-06-09 16:24:49 +00:00
|
|
|
newWire = makeNewWire( aCommit, test, aSelectedItem, aPoint, aPoint );
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
|
|
|
|
aList.push_back( newWire );
|
2019-05-31 20:52:07 +00:00
|
|
|
}
|
2022-10-12 15:32:15 +00:00
|
|
|
|
2019-05-31 20:52:07 +00:00
|
|
|
break;
|
2019-05-07 19:06:46 +00:00
|
|
|
|
2019-05-31 20:52:07 +00:00
|
|
|
case SCH_NO_CONNECT_T:
|
2020-10-12 09:32:51 +00:00
|
|
|
// Select no-connects that are connected to items being moved.
|
2022-03-03 14:35:57 +00:00
|
|
|
if( !test->HasFlag( SELECTED_BY_DRAG ) && test->IsConnected( aPoint ) )
|
2019-08-29 21:00:38 +00:00
|
|
|
{
|
2019-05-31 20:52:07 +00:00
|
|
|
aList.push_back( test );
|
2022-03-03 14:35:57 +00:00
|
|
|
test->SetFlags( SELECTED_BY_DRAG );
|
2019-08-29 21:00:38 +00:00
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
2022-01-24 13:40:39 +00:00
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
2021-04-07 13:37:58 +00:00
|
|
|
// Performance optimization:
|
2022-03-03 14:35:57 +00:00
|
|
|
if( test->HasFlag( SELECTED_BY_DRAG ) )
|
2021-04-07 13:37:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Select labels that are connected to a wire (or bus) being moved.
|
2022-10-12 15:32:15 +00:00
|
|
|
if( aSelectedItem->Type() == SCH_LINE_T && test->CanConnect( aSelectedItem ) )
|
2021-04-07 13:37:58 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( test );
|
2022-10-12 15:32:15 +00:00
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aSelectedItem );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
bool oneEndFixed = !line->HasFlag( STARTPOINT ) || !line->HasFlag( ENDPOINT );
|
2021-04-07 13:37:58 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
if( line->HitTest( label->GetTextPos(), 1 ) )
|
2021-04-07 13:37:58 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
if( ( !line->HasFlag( STARTPOINT )
|
|
|
|
&& label->GetPosition() == line->GetStartPoint() )
|
|
|
|
|| ( !line->HasFlag( ENDPOINT )
|
|
|
|
&& label->GetPosition() == line->GetEndPoint() ) )
|
2021-04-07 13:37:58 +00:00
|
|
|
{
|
2022-02-10 18:38:40 +00:00
|
|
|
//If we have a line selected at only one end, don't grab labels
|
|
|
|
//connected directly to the unselected endpoint
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
label->SetFlags( SELECTED_BY_DRAG );
|
2022-02-10 18:38:40 +00:00
|
|
|
aList.push_back( label );
|
|
|
|
|
|
|
|
if( oneEndFixed )
|
|
|
|
{
|
|
|
|
SPECIAL_CASE_LABEL_INFO info;
|
|
|
|
info.attachedLine = line;
|
|
|
|
info.originalLabelPos = label->GetPosition();
|
|
|
|
m_specialCaseLabels[label] = info;
|
|
|
|
}
|
2021-04-07 13:37:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-10 20:52:23 +00:00
|
|
|
else if( test->IsConnected( aPoint ) && !newWire )
|
|
|
|
{
|
|
|
|
// Add a new wire between the label and the selected item so the selected item
|
|
|
|
// can be dragged.
|
2023-06-09 16:24:49 +00:00
|
|
|
newWire = makeNewWire( aCommit, test, aSelectedItem, aPoint, aPoint );
|
2022-11-25 15:04:36 +00:00
|
|
|
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
|
|
|
|
aList.push_back( newWire );
|
2022-06-10 20:52:23 +00:00
|
|
|
}
|
2021-04-07 13:37:58 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
2019-08-31 19:20:44 +00:00
|
|
|
// Performance optimization:
|
2022-03-03 14:35:57 +00:00
|
|
|
if( test->HasFlag( SELECTED_BY_DRAG ) )
|
2019-08-31 19:20:44 +00:00
|
|
|
break;
|
|
|
|
|
2021-04-07 13:37:58 +00:00
|
|
|
// Select bus entries that are connected to a bus being moved.
|
2022-10-12 15:32:15 +00:00
|
|
|
if( aSelectedItem->Type() == SCH_LINE_T && test->CanConnect( aSelectedItem ) )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-10-12 15:32:15 +00:00
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aSelectedItem );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
if( ( !line->HasFlag( STARTPOINT ) && test->IsConnected( line->GetStartPoint() ) )
|
|
|
|
|| ( !line->HasFlag( ENDPOINT ) && test->IsConnected( line->GetEndPoint() ) ) )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2022-10-12 15:32:15 +00:00
|
|
|
// If we have a line selected at only one end, don't grab bus entries
|
|
|
|
// connected directly to the unselected endpoint
|
2021-04-07 13:37:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( VECTOR2I& point : test->GetConnectionPoints() )
|
2021-04-07 13:37:58 +00:00
|
|
|
{
|
|
|
|
if( line->HitTest( point, 1 ) )
|
2019-08-29 21:00:38 +00:00
|
|
|
{
|
2022-03-03 14:35:57 +00:00
|
|
|
test->SetFlags( SELECTED_BY_DRAG );
|
2019-05-04 13:02:05 +00:00
|
|
|
aList.push_back( test );
|
2019-11-17 18:55:27 +00:00
|
|
|
|
|
|
|
// A bus entry needs its wire & label as well
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> ends = test->GetConnectionPoints();
|
|
|
|
VECTOR2I otherEnd;
|
2019-11-17 18:55:27 +00:00
|
|
|
|
2021-04-07 13:37:58 +00:00
|
|
|
if( ends[0] == point )
|
|
|
|
otherEnd = ends[1];
|
|
|
|
else
|
|
|
|
otherEnd = ends[0];
|
2019-11-17 18:55:27 +00:00
|
|
|
|
2023-06-09 16:24:49 +00:00
|
|
|
getConnectedDragItems( aCommit, test, otherEnd, aList );
|
2021-04-07 13:37:58 +00:00
|
|
|
|
|
|
|
// No need to test the other end of the bus entry
|
2019-08-29 21:00:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-17 18:55:27 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
break;
|
2019-05-07 11:00:24 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-19 16:04:14 +00:00
|
|
|
void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
2020-04-19 16:04:14 +00:00
|
|
|
{
|
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
|
|
|
|
|
2022-12-12 19:43:32 +00:00
|
|
|
if( aItem->HasFlag( STARTPOINT ) || !m_isDrag )
|
2022-01-01 06:04:08 +00:00
|
|
|
line->MoveStart( aDelta );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2022-12-12 19:43:32 +00:00
|
|
|
if( aItem->HasFlag( ENDPOINT ) || !m_isDrag )
|
2022-01-01 06:04:08 +00:00
|
|
|
line->MoveEnd( aDelta );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
break;
|
2022-03-29 18:30:10 +00:00
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
case SCH_PIN_T:
|
|
|
|
case SCH_FIELD_T:
|
2019-05-06 15:58:53 +00:00
|
|
|
{
|
2020-03-06 20:02:58 +00:00
|
|
|
SCH_ITEM* parent = (SCH_ITEM*) aItem->GetParent();
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I delta( aDelta );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
if( parent && parent->Type() == SCH_SYMBOL_T )
|
2020-03-06 20:02:58 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem->GetParent();
|
|
|
|
TRANSFORM transform = symbol->GetTransform().InverseTransform();
|
2020-03-06 20:02:58 +00:00
|
|
|
|
|
|
|
delta = transform.TransformCoordinate( delta );
|
|
|
|
}
|
|
|
|
|
|
|
|
static_cast<SCH_ITEM*>( aItem )->Move( delta );
|
2019-10-01 14:31:25 +00:00
|
|
|
|
|
|
|
// If we're moving a field with respect to its parent then it's no longer auto-placed
|
2020-04-01 07:34:44 +00:00
|
|
|
if( aItem->Type() == SCH_FIELD_T && parent && !parent->IsSelected() )
|
2020-03-06 20:02:58 +00:00
|
|
|
parent->ClearFieldsAutoplaced();
|
2019-10-01 14:31:25 +00:00
|
|
|
|
2019-05-06 15:58:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2019-05-16 21:27:03 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
{
|
|
|
|
SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
pin->SetStoredPos( pin->GetStoredPos() + aDelta );
|
2023-06-25 18:54:58 +00:00
|
|
|
pin->ConstrainOnEdge( pin->GetStoredPos(), true );
|
2019-05-16 21:27:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2020-05-06 10:53:56 +00:00
|
|
|
case SCH_LABEL_T:
|
2022-01-24 13:40:39 +00:00
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
2022-02-10 18:38:40 +00:00
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
2020-05-06 10:53:56 +00:00
|
|
|
{
|
2022-01-25 22:33:37 +00:00
|
|
|
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
|
2020-05-06 10:53:56 +00:00
|
|
|
|
|
|
|
if( m_specialCaseLabels.count( label ) )
|
2020-05-07 17:59:06 +00:00
|
|
|
{
|
|
|
|
SPECIAL_CASE_LABEL_INFO info = m_specialCaseLabels[ label ];
|
|
|
|
SEG currentLine( info.attachedLine->GetStartPoint(), info.attachedLine->GetEndPoint() );
|
2022-01-01 06:04:08 +00:00
|
|
|
label->SetPosition( currentLine.NearestPoint( info.originalLabelPos ) );
|
2020-05-07 17:59:06 +00:00
|
|
|
}
|
2020-05-06 10:53:56 +00:00
|
|
|
else
|
2020-12-27 12:36:11 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
label->Move( aDelta );
|
2020-12-27 12:36:11 +00:00
|
|
|
}
|
2020-05-06 10:53:56 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
default:
|
2022-01-01 06:04:08 +00:00
|
|
|
static_cast<SCH_ITEM*>( aItem )->Move( aDelta );
|
2019-05-04 13:02:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-05-30 21:04:07 +00:00
|
|
|
aItem->SetFlags( IS_MOVING );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-15 12:48:29 +00:00
|
|
|
int SCH_MOVE_TOOL::AlignToGrid( const TOOL_EVENT& aEvent )
|
2020-09-17 19:26:54 +00:00
|
|
|
{
|
2023-08-26 12:29:24 +00:00
|
|
|
EE_GRID_HELPER grid( m_toolMgr);
|
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::MovableItems );
|
2023-07-27 14:42:38 +00:00
|
|
|
GRID_HELPER_GRIDS selectionGrid = grid.GetSelectionGrid( selection );
|
2023-08-26 12:29:24 +00:00
|
|
|
SCH_COMMIT commit( m_toolMgr );
|
2020-09-17 19:26:54 +00:00
|
|
|
|
2022-03-29 18:30:10 +00:00
|
|
|
auto doMoveItem =
|
|
|
|
[&]( EDA_ITEM* item, const VECTOR2I& delta )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
commit.Modify( item, m_frame->GetScreen() );
|
|
|
|
|
2023-01-07 08:06:03 +00:00
|
|
|
// Ensure only one end is moved when calling moveItem
|
|
|
|
// i.e. we are in drag mode
|
|
|
|
bool tmp_isDrag = m_isDrag;
|
|
|
|
m_isDrag = true;
|
2022-03-29 18:30:10 +00:00
|
|
|
moveItem( item, delta );
|
2023-01-07 08:06:03 +00:00
|
|
|
m_isDrag = tmp_isDrag;
|
|
|
|
|
2022-03-29 18:30:10 +00:00
|
|
|
item->ClearFlags( IS_MOVING );
|
|
|
|
updateItem( item, true );
|
|
|
|
};
|
|
|
|
|
2020-11-06 12:20:52 +00:00
|
|
|
for( SCH_ITEM* it : m_frame->GetScreen()->Items() )
|
|
|
|
{
|
|
|
|
if( !it->IsSelected() )
|
|
|
|
it->ClearFlags( STARTPOINT | ENDPOINT );
|
|
|
|
|
|
|
|
if( !selection.IsHover() && it->IsSelected() )
|
|
|
|
it->SetFlags( STARTPOINT | ENDPOINT );
|
|
|
|
|
|
|
|
it->SetStoredPos( it->GetPosition() );
|
|
|
|
|
|
|
|
if( it->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( it )->GetPins() )
|
|
|
|
pin->SetStoredPos( pin->GetPosition() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-17 19:26:54 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_LINE_T )
|
|
|
|
{
|
2022-11-25 15:04:36 +00:00
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
|
|
|
std::vector<int> flags{ STARTPOINT, ENDPOINT };
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> pts{ line->GetStartPoint(), line->GetEndPoint() };
|
2020-09-17 19:26:54 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < 2; ++ii )
|
|
|
|
{
|
|
|
|
EDA_ITEMS drag_items{ item };
|
|
|
|
line->ClearFlags();
|
2021-12-01 00:29:27 +00:00
|
|
|
line->SetFlags( SELECTED );
|
2020-09-17 19:26:54 +00:00
|
|
|
line->SetFlags( flags[ii] );
|
2023-06-09 16:24:49 +00:00
|
|
|
getConnectedDragItems( &commit, line, pts[ii], drag_items );
|
2020-09-17 19:26:54 +00:00
|
|
|
std::set<EDA_ITEM*> unique_items( drag_items.begin(), drag_items.end() );
|
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
VECTOR2I delta = grid.AlignGrid( pts[ii], selectionGrid ) - pts[ii];
|
2020-09-17 19:26:54 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
if( delta != VECTOR2I( 0, 0 ) )
|
2020-09-17 19:26:54 +00:00
|
|
|
{
|
2021-01-03 22:39:24 +00:00
|
|
|
for( EDA_ITEM* dragItem : unique_items )
|
2020-09-17 19:26:54 +00:00
|
|
|
{
|
2021-01-03 22:39:24 +00:00
|
|
|
if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
|
2020-09-17 19:26:54 +00:00
|
|
|
continue;
|
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
doMoveItem( dragItem, delta );
|
2020-09-17 19:26:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-27 14:42:38 +00:00
|
|
|
else if( item->Type() == SCH_FIELD_T || item->Type() == SCH_TEXT_T )
|
2021-01-03 22:39:24 +00:00
|
|
|
{
|
2023-08-28 15:34:48 +00:00
|
|
|
VECTOR2I delta = grid.AlignGrid( item->GetPosition(), selectionGrid ) - item->GetPosition();
|
2021-01-03 22:39:24 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
if( delta != VECTOR2I( 0, 0 ) )
|
|
|
|
doMoveItem( item, delta );
|
2022-03-29 18:30:10 +00:00
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
2022-04-18 05:56:48 +00:00
|
|
|
VECTOR2I topLeft = sheet->GetPosition();
|
|
|
|
VECTOR2I bottomRight = topLeft + sheet->GetSize();
|
2023-08-28 15:34:48 +00:00
|
|
|
VECTOR2I tl_delta = grid.AlignGrid( topLeft, selectionGrid ) - topLeft;
|
|
|
|
VECTOR2I br_delta = grid.AlignGrid( bottomRight, selectionGrid ) - bottomRight;
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
if( tl_delta != VECTOR2I( 0, 0 ) || br_delta != VECTOR2I( 0, 0 ) )
|
2021-01-03 22:39:24 +00:00
|
|
|
{
|
2023-08-28 15:34:48 +00:00
|
|
|
doMoveItem( sheet, tl_delta );
|
2021-01-03 22:39:24 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
VECTOR2I newSize = (VECTOR2I) sheet->GetSize() - tl_delta + br_delta;
|
2023-02-19 03:40:07 +00:00
|
|
|
sheet->SetSize( VECTOR2I( newSize.x, newSize.y ) );
|
2022-03-29 18:30:10 +00:00
|
|
|
updateItem( sheet, true );
|
2023-08-28 15:34:48 +00:00
|
|
|
}
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
|
|
|
|
{
|
|
|
|
VECTOR2I newPos;
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
if( pin->GetSide() == SHEET_SIDE::TOP || pin->GetSide() == SHEET_SIDE::LEFT )
|
|
|
|
newPos = pin->GetPosition() + tl_delta;
|
|
|
|
else
|
|
|
|
newPos = pin->GetPosition() + br_delta;
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2024-02-28 16:57:20 +00:00
|
|
|
VECTOR2I delta = grid.AlignGrid( newPos - pin->GetPosition(), selectionGrid );
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
if( delta != VECTOR2I( 0, 0 ) )
|
|
|
|
{
|
|
|
|
EDA_ITEMS drag_items;
|
|
|
|
getConnectedDragItems( &commit, pin, pin->GetConnectionPoints()[0],
|
|
|
|
drag_items );
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
doMoveItem( pin, delta );
|
2022-03-29 18:30:10 +00:00
|
|
|
|
2023-08-28 15:34:48 +00:00
|
|
|
for( EDA_ITEM* dragItem : drag_items )
|
|
|
|
{
|
|
|
|
if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
doMoveItem( dragItem, delta );
|
2022-03-29 18:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-03 22:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-17 19:26:54 +00:00
|
|
|
else
|
|
|
|
{
|
2022-11-25 15:04:36 +00:00
|
|
|
SCH_ITEM* schItem = static_cast<SCH_ITEM*>( item );
|
|
|
|
std::vector<VECTOR2I> connections = schItem->GetConnectionPoints();
|
2023-08-03 15:11:34 +00:00
|
|
|
EDA_ITEMS drag_items;
|
2020-09-17 19:26:54 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& point : connections )
|
2023-06-09 16:24:49 +00:00
|
|
|
getConnectedDragItems( &commit, schItem, point, drag_items );
|
2020-09-17 19:26:54 +00:00
|
|
|
|
|
|
|
std::map<VECTOR2I, int> shifts;
|
2022-11-25 15:04:36 +00:00
|
|
|
VECTOR2I most_common( 0, 0 );
|
|
|
|
int max_count = 0;
|
2020-09-17 19:26:54 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& conn : connections )
|
2020-09-17 19:26:54 +00:00
|
|
|
{
|
2023-07-27 14:42:38 +00:00
|
|
|
VECTOR2I gridpt = grid.AlignGrid( conn, selectionGrid ) - conn;
|
2020-09-17 19:26:54 +00:00
|
|
|
|
|
|
|
shifts[gridpt]++;
|
|
|
|
|
|
|
|
if( shifts[gridpt] > max_count )
|
|
|
|
{
|
|
|
|
most_common = gridpt;
|
|
|
|
max_count = shifts[most_common];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( most_common != VECTOR2I( 0, 0 ) )
|
|
|
|
{
|
2023-08-03 15:11:34 +00:00
|
|
|
doMoveItem( item, most_common );
|
|
|
|
|
2021-01-03 22:39:24 +00:00
|
|
|
for( EDA_ITEM* dragItem : drag_items )
|
2020-09-17 19:26:54 +00:00
|
|
|
{
|
2021-01-03 22:39:24 +00:00
|
|
|
if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
|
2020-09-17 19:26:54 +00:00
|
|
|
continue;
|
|
|
|
|
2022-03-29 18:30:10 +00:00
|
|
|
doMoveItem( dragItem, most_common );
|
2020-09-17 19:26:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-06 22:14:06 +00:00
|
|
|
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
2023-06-09 16:24:49 +00:00
|
|
|
lwbTool->TrimOverLappingWires( &commit, &selection );
|
|
|
|
lwbTool->AddJunctionsIfNeeded( &commit, &selection );
|
2023-01-06 22:14:06 +00:00
|
|
|
|
2020-09-17 19:26:54 +00:00
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved );
|
|
|
|
|
2023-06-09 16:24:49 +00:00
|
|
|
m_frame->SchematicCleanUp( &commit );
|
2024-02-15 12:48:29 +00:00
|
|
|
commit.Push( _( "Align Items to Grid" ) );
|
2020-09-17 19:26:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-10 18:38:40 +00:00
|
|
|
void SCH_MOVE_TOOL::clearNewDragLines()
|
|
|
|
{
|
|
|
|
// Remove new bend lines added during the drag
|
2022-10-03 20:40:47 +00:00
|
|
|
for( SCH_LINE* newLine : m_newDragLines )
|
2022-02-10 18:38:40 +00:00
|
|
|
{
|
|
|
|
m_frame->RemoveFromScreen( newLine, m_frame->GetScreen() );
|
|
|
|
delete newLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_newDragLines.clear();
|
|
|
|
}
|
2022-10-03 20:40:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_MOVE_TOOL::setTransitions()
|
|
|
|
{
|
|
|
|
Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
|
|
|
|
Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
|
2024-02-15 12:48:29 +00:00
|
|
|
Go( &SCH_MOVE_TOOL::AlignToGrid, EE_ACTIONS::alignToGrid.MakeEvent() );
|
2022-10-03 20:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|