2014-05-14 13:53:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 CERN
|
2023-08-22 12:06:33 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-05-14 13:53:54 +00:00
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
#include "pns_arc.h"
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
#include "pns_dragger.h"
|
|
|
|
#include "pns_shove.h"
|
|
|
|
#include "pns_router.h"
|
2020-02-20 23:03:23 +00:00
|
|
|
#include "pns_debug_decorator.h"
|
2020-02-05 15:33:14 +00:00
|
|
|
#include "pns_walkaround.h"
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DRAGGER::DRAGGER( ROUTER* aRouter ) :
|
2021-04-08 03:16:56 +00:00
|
|
|
DRAG_ALGO( aRouter ),
|
|
|
|
m_initialVia( {} ),
|
|
|
|
m_draggedVia( {} )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
m_world = nullptr;
|
|
|
|
m_lastNode = nullptr;
|
2017-08-03 15:53:07 +00:00
|
|
|
m_mode = DM_SEGMENT;
|
2015-03-10 14:38:27 +00:00
|
|
|
m_draggedSegmentIndex = 0;
|
|
|
|
m_dragStatus = false;
|
|
|
|
m_currentMode = RM_MarkObstacles;
|
2017-11-01 09:20:13 +00:00
|
|
|
m_freeAngleMode = false;
|
2014-05-16 11:37:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DRAGGER::~DRAGGER()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
bool DRAGGER::propagateViaForces( NODE* node, std::set<VIA*>& vias )
|
|
|
|
{
|
|
|
|
VIA* via = *vias.begin();
|
|
|
|
|
|
|
|
VECTOR2I force;
|
2022-11-18 14:08:39 +00:00
|
|
|
VECTOR2I lead = -m_mouseTrailTracer.GetTrailLeadVector();
|
2020-10-19 21:33:32 +00:00
|
|
|
|
2022-11-18 14:08:39 +00:00
|
|
|
const int iterLimit = Settings().ViaForcePropIterationLimit();
|
2020-10-19 21:33:32 +00:00
|
|
|
|
2022-11-18 14:08:39 +00:00
|
|
|
if( via->PushoutForce( node, lead, force, ITEM::ANY_T, iterLimit ) )
|
2020-10-19 21:33:32 +00:00
|
|
|
{
|
|
|
|
via->SetPos( via->Pos() + force );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-03 20:36:06 +00:00
|
|
|
|
|
|
|
VVIA* DRAGGER::checkVirtualVia( const VECTOR2D& aP, SEGMENT* aSeg )
|
|
|
|
{
|
|
|
|
int w2 = aSeg->Width() / 2;
|
|
|
|
|
|
|
|
auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
|
|
|
|
auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
|
|
|
|
|
|
|
|
VECTOR2I psnap;
|
|
|
|
|
|
|
|
if( distA <= w2 )
|
|
|
|
{
|
|
|
|
psnap = aSeg->Seg().A;
|
|
|
|
}
|
|
|
|
else if( distB <= w2 )
|
|
|
|
{
|
|
|
|
psnap = aSeg->Seg().B;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
const JOINT *jt = m_world->FindJoint( psnap, aSeg );
|
2021-06-03 20:36:06 +00:00
|
|
|
|
|
|
|
if ( !jt )
|
|
|
|
return nullptr;
|
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
for( ITEM* item : jt->LinkList() )
|
2021-06-03 20:36:06 +00:00
|
|
|
{
|
2022-08-29 20:21:46 +00:00
|
|
|
if( item->IsVirtual() && item->OfKind( ITEM::VIA_T ))
|
|
|
|
return static_cast<VVIA*>( item );
|
2021-06-03 20:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DRAGGER::startDragSegment( const VECTOR2D& aP, SEGMENT* aSeg )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
int w2 = aSeg->Width() / 2;
|
|
|
|
|
2021-04-08 01:59:23 +00:00
|
|
|
m_draggedLine = m_world->AssembleLine( aSeg, &m_draggedSegmentIndex );
|
|
|
|
m_lastDragSolution = m_draggedLine;
|
2019-08-07 21:49:35 +00:00
|
|
|
|
|
|
|
if( m_shove )
|
|
|
|
{
|
|
|
|
m_shove->SetInitialLine( m_draggedLine );
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
|
|
|
|
auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
|
|
|
|
|
2022-12-21 17:55:41 +00:00
|
|
|
if( distA < w2 || distB < w2 )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2017-08-03 15:53:07 +00:00
|
|
|
m_mode = DM_CORNER;
|
2022-12-21 17:55:41 +00:00
|
|
|
|
|
|
|
if( distB <= distA )
|
|
|
|
m_draggedSegmentIndex++;
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
2021-04-11 19:15:13 +00:00
|
|
|
else if( m_freeAngleMode )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
2021-04-11 19:15:13 +00:00
|
|
|
if( distB < distA &&
|
2021-04-12 02:12:53 +00:00
|
|
|
( m_draggedSegmentIndex < m_draggedLine.PointCount() - 2 ) &&
|
2021-05-06 22:10:39 +00:00
|
|
|
( !m_draggedLine.CLine().IsPtOnArc( static_cast<size_t>(m_draggedSegmentIndex) + 1 ) ) )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
|
|
|
m_draggedSegmentIndex++;
|
|
|
|
}
|
2021-04-11 19:15:13 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
m_mode = DM_CORNER;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_mode = DM_SEGMENT;
|
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
bool DRAGGER::startDragArc( const VECTOR2D& aP, ARC* aArc )
|
|
|
|
{
|
|
|
|
m_draggedLine = m_world->AssembleLine( aArc, &m_draggedSegmentIndex );
|
|
|
|
m_shove->SetInitialLine( m_draggedLine );
|
|
|
|
m_mode = DM_ARC;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
bool DRAGGER::startDragVia( VIA* aVia )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2019-08-07 21:49:35 +00:00
|
|
|
m_initialVia = aVia->MakeHandle();
|
|
|
|
m_draggedVia = m_initialVia;
|
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
m_mode = DM_VIA;
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ITEM_SET DRAGGER::findViaFanoutByHandle ( NODE *aNode, const VIA_HANDLE& handle )
|
|
|
|
{
|
|
|
|
ITEM_SET rv;
|
|
|
|
|
2022-08-29 20:21:46 +00:00
|
|
|
const JOINT* jt = aNode->FindJoint( handle.pos, handle.layers.Start(), handle.net );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-08-04 09:37:16 +00:00
|
|
|
if( !jt )
|
2019-08-07 21:49:35 +00:00
|
|
|
return rv;
|
2015-08-04 09:37:16 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* item : jt->LinkList() )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2019-05-17 00:13:21 +00:00
|
|
|
if( item->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
int segIndex;
|
2019-05-17 00:13:21 +00:00
|
|
|
LINKED_ITEM* seg = ( LINKED_ITEM*) item;
|
2019-08-07 21:49:35 +00:00
|
|
|
LINE l = aNode->AssembleLine( seg, &segIndex );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
if( segIndex != 0 )
|
2015-08-03 19:11:51 +00:00
|
|
|
l.Reverse();
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
rv.Add( l );
|
2020-11-24 22:16:41 +00:00
|
|
|
}
|
|
|
|
else if( item->OfKind( ITEM::VIA_T ) )
|
2019-08-07 21:49:35 +00:00
|
|
|
{
|
|
|
|
rv.Add( item );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
return rv;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 22:08:34 +00:00
|
|
|
bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-02-28 22:08:34 +00:00
|
|
|
if( aPrimitives.Empty() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ITEM* startItem = aPrimitives[0];
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
m_lastNode = nullptr;
|
2014-05-14 13:53:54 +00:00
|
|
|
m_draggedItems.Clear();
|
|
|
|
m_currentMode = Settings().Mode();
|
2017-08-22 17:33:38 +00:00
|
|
|
m_freeAngleMode = (m_mode & DM_FREE_ANGLE);
|
2020-12-28 21:36:42 +00:00
|
|
|
m_lastValidPoint = aP;
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
m_mouseTrailTracer.Clear();
|
|
|
|
m_mouseTrailTracer.AddTrailPoint( aP );
|
|
|
|
|
2020-02-05 15:33:14 +00:00
|
|
|
if( m_currentMode == RM_Shove && !m_freeAngleMode )
|
|
|
|
{
|
2019-08-12 14:30:46 +00:00
|
|
|
m_shove = std::make_unique<SHOVE>( m_world, Router() );
|
2020-02-05 15:33:14 +00:00
|
|
|
m_shove->SetLogger( Logger() );
|
|
|
|
m_shove->SetDebugDecorator( Dbg() );
|
|
|
|
}
|
2019-08-07 21:49:35 +00:00
|
|
|
|
2020-02-28 22:08:34 +00:00
|
|
|
startItem->Unmark( MK_LOCKED );
|
2016-08-15 15:16:50 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
PNS_DBG( Dbg(), Message, wxString::Format( "StartDragging: item %p [kind %d]",
|
|
|
|
startItem, (int) startItem->Kind() ) );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2020-02-28 22:08:34 +00:00
|
|
|
switch( startItem->Kind() )
|
2014-11-14 19:19:00 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
case ITEM::SEGMENT_T:
|
2021-06-03 20:36:06 +00:00
|
|
|
{
|
|
|
|
SEGMENT* seg = static_cast<SEGMENT*>( startItem );
|
|
|
|
VVIA* vvia = checkVirtualVia( aP, seg );
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2021-06-03 20:36:06 +00:00
|
|
|
if( vvia )
|
|
|
|
{
|
|
|
|
return startDragVia( vvia );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return startDragSegment( aP, seg );
|
|
|
|
}
|
|
|
|
}
|
2016-08-29 17:31:13 +00:00
|
|
|
case ITEM::VIA_T:
|
2020-02-28 22:08:34 +00:00
|
|
|
return startDragVia( static_cast<VIA*>( startItem ) );
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
case ITEM::ARC_T:
|
2020-02-28 22:08:34 +00:00
|
|
|
return startDragArc( aP, static_cast<ARC*>( startItem ) );
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2014-11-14 19:19:00 +00:00
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2018-05-08 09:47:14 +00:00
|
|
|
|
2023-01-27 08:06:33 +00:00
|
|
|
void DRAGGER::SetMode( PNS::DRAG_MODE aMode )
|
2017-08-03 15:53:07 +00:00
|
|
|
{
|
2023-01-27 08:06:33 +00:00
|
|
|
m_mode = static_cast<int>( aMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PNS::DRAG_MODE DRAGGER::Mode() const
|
|
|
|
{
|
|
|
|
return static_cast<PNS::DRAG_MODE>( m_mode );
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2018-05-08 09:47:14 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
const std::vector<NET_HANDLE> DRAGGER::CurrentNets() const
|
2022-10-10 10:26:51 +00:00
|
|
|
{
|
|
|
|
if( m_mode == PNS::DM_VIA )
|
2023-08-22 12:06:33 +00:00
|
|
|
return std::vector<NET_HANDLE>( 1, m_draggedVia.net );
|
2022-10-10 10:26:51 +00:00
|
|
|
else
|
2023-08-22 12:06:33 +00:00
|
|
|
return std::vector<NET_HANDLE>( 1, m_draggedLine.Net() );
|
2022-10-10 10:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
|
2014-11-14 19:19:00 +00:00
|
|
|
{
|
2019-08-07 21:49:35 +00:00
|
|
|
// fixme: rewrite using shared_ptr...
|
2014-05-16 11:37:31 +00:00
|
|
|
if( m_lastNode )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
delete m_lastNode;
|
2019-08-07 21:49:35 +00:00
|
|
|
m_lastNode = nullptr;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
m_lastNode = m_world->Branch();
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
switch( m_mode )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2017-08-03 15:53:07 +00:00
|
|
|
case DM_SEGMENT:
|
|
|
|
case DM_CORNER:
|
2015-10-05 16:28:41 +00:00
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
//TODO: Make threshold configurable
|
2019-05-17 00:13:21 +00:00
|
|
|
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
|
2019-08-07 21:49:35 +00:00
|
|
|
LINE origLine( m_draggedLine );
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE dragged( m_draggedLine );
|
2019-05-17 00:13:21 +00:00
|
|
|
dragged.SetSnapThreshhold( thresh );
|
2020-04-15 20:16:24 +00:00
|
|
|
dragged.ClearLinks();
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
if( m_mode == DM_SEGMENT )
|
2019-05-17 00:13:21 +00:00
|
|
|
dragged.DragSegment( aP, m_draggedSegmentIndex );
|
2015-10-05 16:28:41 +00:00
|
|
|
else
|
2019-05-17 00:13:21 +00:00
|
|
|
dragged.DragCorner( aP, m_draggedSegmentIndex, m_freeAngleMode );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
m_lastNode->Remove( origLine );
|
|
|
|
m_lastNode->Add( dragged );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
m_draggedItems.Clear();
|
2019-08-07 21:49:35 +00:00
|
|
|
m_draggedItems.Add( dragged );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
case DM_VIA: // fixme...
|
2015-10-05 16:28:41 +00:00
|
|
|
{
|
2020-02-06 17:03:18 +00:00
|
|
|
dragViaMarkObstacles( m_initialVia, m_lastNode, aP );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 09:31:42 +00:00
|
|
|
if( Settings().AllowDRCViolations() )
|
2014-05-14 13:53:54 +00:00
|
|
|
m_dragStatus = true;
|
|
|
|
else
|
2023-05-24 23:18:53 +00:00
|
|
|
m_dragStatus = !m_lastNode->CheckColliding( m_draggedItems );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
bool DRAGGER::dragViaMarkObstacles( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2015-08-19 15:27:23 +00:00
|
|
|
m_draggedItems.Clear();
|
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
if( fanout.Empty() )
|
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
return true;
|
2019-08-07 21:49:35 +00:00
|
|
|
}
|
2021-04-08 01:59:23 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
for( ITEM* item : fanout.Items() )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
2015-08-03 19:11:51 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE origLine( *l );
|
|
|
|
LINE draggedLine( *l );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
draggedLine.DragCorner( aP, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode );
|
2020-04-15 20:16:24 +00:00
|
|
|
draggedLine.ClearLinks();
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-08-03 19:11:51 +00:00
|
|
|
m_draggedItems.Add( draggedLine );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2016-08-30 17:01:30 +00:00
|
|
|
m_lastNode->Remove( origLine );
|
2016-08-30 15:28:35 +00:00
|
|
|
m_lastNode->Add( draggedLine );
|
2015-08-03 19:11:51 +00:00
|
|
|
}
|
2019-08-07 21:49:35 +00:00
|
|
|
else if ( VIA *via = dyn_cast<VIA*>( item ) )
|
|
|
|
{
|
|
|
|
auto nvia = Clone( *via );
|
|
|
|
|
|
|
|
nvia->SetPos( aP );
|
|
|
|
m_draggedItems.Add( nvia.get() );
|
|
|
|
|
|
|
|
m_lastNode->Remove( via );
|
|
|
|
m_lastNode->Add( std::move( nvia ) );
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2020-10-19 21:33:32 +00:00
|
|
|
|
|
|
|
return true;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 17:03:18 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
bool DRAGGER::dragViaWalkaround( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
|
2020-02-06 17:03:18 +00:00
|
|
|
{
|
|
|
|
m_draggedItems.Clear();
|
|
|
|
|
|
|
|
ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
|
|
|
|
|
|
|
|
if( fanout.Empty() )
|
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
return true;
|
2020-02-06 17:03:18 +00:00
|
|
|
}
|
2020-10-18 20:59:16 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
bool viaPropOk = false;
|
|
|
|
VECTOR2I viaTargetPos;
|
|
|
|
|
2020-02-06 17:03:18 +00:00
|
|
|
for( ITEM* item : fanout.Items() )
|
|
|
|
{
|
2020-10-18 20:59:16 +00:00
|
|
|
if ( VIA *via = dyn_cast<VIA*>( item ) )
|
|
|
|
{
|
|
|
|
auto draggedVia = Clone( *via );
|
|
|
|
|
|
|
|
draggedVia->SetPos( aP );
|
|
|
|
m_draggedItems.Add( draggedVia.get() );
|
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
std::set<VIA*> vias;
|
|
|
|
|
|
|
|
vias.insert( draggedVia.get() );
|
|
|
|
|
2023-05-24 23:18:53 +00:00
|
|
|
m_lastNode->Remove( via );
|
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
bool ok = propagateViaForces( m_lastNode, vias );
|
|
|
|
|
|
|
|
if( ok )
|
|
|
|
{
|
|
|
|
viaTargetPos = draggedVia->Pos();
|
|
|
|
viaPropOk = true;
|
|
|
|
m_lastNode->Add( std::move(draggedVia) );
|
|
|
|
}
|
2020-10-18 20:59:16 +00:00
|
|
|
}
|
2020-10-19 21:33:32 +00:00
|
|
|
}
|
2020-10-18 20:59:16 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
if( !viaPropOk ) // can't force-propagate the via? bummer...
|
|
|
|
return false;
|
2021-04-08 01:59:23 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
for( ITEM* item : fanout.Items() )
|
|
|
|
{
|
2020-02-06 17:03:18 +00:00
|
|
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
|
|
|
{
|
|
|
|
LINE origLine( *l );
|
|
|
|
LINE draggedLine( *l );
|
2020-10-19 21:33:32 +00:00
|
|
|
LINE walkLine( *l );
|
2020-02-06 17:03:18 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ),
|
|
|
|
m_freeAngleMode );
|
2020-04-15 20:16:24 +00:00
|
|
|
draggedLine.ClearLinks();
|
2020-02-06 17:03:18 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
if ( m_world->CheckColliding( &draggedLine ) )
|
|
|
|
{
|
|
|
|
bool ok = tryWalkaround( m_lastNode, draggedLine, walkLine );
|
2021-04-08 01:59:23 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
if( !ok )
|
|
|
|
return false;
|
2020-02-06 17:03:18 +00:00
|
|
|
|
2021-02-25 16:18:13 +00:00
|
|
|
m_lastNode->Remove( origLine );
|
2020-10-19 21:33:32 +00:00
|
|
|
optimizeAndUpdateDraggedLine( walkLine, origLine, aP );
|
2021-02-25 16:18:13 +00:00
|
|
|
}
|
2020-10-19 21:33:32 +00:00
|
|
|
else
|
2021-02-25 16:18:13 +00:00
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
m_draggedItems.Add( draggedLine );
|
|
|
|
|
|
|
|
m_lastNode->Remove( origLine );
|
|
|
|
m_lastNode->Add( draggedLine );
|
2021-02-25 16:18:13 +00:00
|
|
|
}
|
2021-02-11 22:06:34 +00:00
|
|
|
}
|
2020-02-06 17:03:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-06 17:03:18 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, const VECTOR2I& aP )
|
2020-02-05 15:33:14 +00:00
|
|
|
{
|
|
|
|
VECTOR2D lockV;
|
2020-10-18 20:59:16 +00:00
|
|
|
aDragged.ClearLinks();
|
|
|
|
aDragged.Unmark();
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2020-10-18 20:59:16 +00:00
|
|
|
lockV = aDragged.CLine().NearestPoint( aP );
|
2020-02-05 15:33:14 +00:00
|
|
|
|
2021-04-10 19:17:29 +00:00
|
|
|
OPTIMIZER optimizer( m_lastNode );
|
2020-10-08 22:00:12 +00:00
|
|
|
|
2021-04-12 02:32:11 +00:00
|
|
|
int effort = OPTIMIZER::MERGE_SEGMENTS | OPTIMIZER::KEEP_TOPOLOGY | OPTIMIZER::RESTRICT_AREA;
|
|
|
|
|
|
|
|
if( Settings().SmoothDraggedSegments() )
|
|
|
|
effort |= OPTIMIZER::MERGE_COLINEAR;
|
|
|
|
|
|
|
|
optimizer.SetEffortLevel( effort );
|
2020-10-08 22:00:12 +00:00
|
|
|
|
2021-04-10 19:17:29 +00:00
|
|
|
OPT_BOX2I affectedArea = aDragged.ChangedArea( &aOrig );
|
|
|
|
VECTOR2I anchor( aP );
|
2020-10-08 22:00:12 +00:00
|
|
|
|
2021-04-10 19:17:29 +00:00
|
|
|
if( aDragged.CLine().Find( aP ) < 0 )
|
|
|
|
{
|
|
|
|
anchor = aDragged.CLine().NearestPoint( aP );
|
|
|
|
}
|
2021-02-11 23:14:39 +00:00
|
|
|
|
2021-04-10 19:17:29 +00:00
|
|
|
optimizer.SetPreserveVertex( anchor );
|
2021-04-05 23:34:49 +00:00
|
|
|
|
2021-04-10 20:31:39 +00:00
|
|
|
// People almost never want KiCad to reroute tracks in areas they can't even see, so restrict
|
|
|
|
// the area to what is visible even if we are optimizing the "entire" track.
|
|
|
|
if( Settings().GetOptimizeEntireDraggedTrack() )
|
2021-04-10 20:13:01 +00:00
|
|
|
affectedArea = VisibleViewArea();
|
2021-04-10 20:31:39 +00:00
|
|
|
else if( !affectedArea )
|
|
|
|
affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
|
2021-04-10 19:17:29 +00:00
|
|
|
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, wxT( "drag-anchor" ) );
|
|
|
|
PNS_DBG( Dbg(), AddShape, *affectedArea, RED, 0, wxT( "drag-affected-area" ) );
|
2021-05-28 22:09:21 +00:00
|
|
|
|
2021-04-10 20:13:01 +00:00
|
|
|
optimizer.SetRestrictArea( *affectedArea );
|
|
|
|
optimizer.Optimize( &aDragged );
|
2021-04-10 19:17:29 +00:00
|
|
|
|
2021-04-10 20:13:01 +00:00
|
|
|
OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
|
|
|
|
|
|
|
|
if( optArea )
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddShape, *optArea, BLUE, 0, wxT( "drag-opt-area" ) );
|
2020-02-05 15:33:14 +00:00
|
|
|
|
2020-10-18 20:59:16 +00:00
|
|
|
m_lastNode->Add( aDragged );
|
2020-02-05 15:33:14 +00:00
|
|
|
m_draggedItems.Clear();
|
2020-10-18 20:59:16 +00:00
|
|
|
m_draggedItems.Add( aDragged );
|
2020-02-05 15:33:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
bool DRAGGER::tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk )
|
|
|
|
{
|
|
|
|
WALKAROUND walkaround( aNode, Router() );
|
|
|
|
bool ok = false;
|
|
|
|
walkaround.SetSolidsOnly( false );
|
|
|
|
walkaround.SetDebugDecorator( Dbg() );
|
|
|
|
walkaround.SetLogger( Logger() );
|
|
|
|
walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
|
|
|
|
|
|
|
|
aWalk = aOrig;
|
|
|
|
|
|
|
|
WALKAROUND::RESULT wr = walkaround.Route( aWalk );
|
|
|
|
|
|
|
|
if( wr.statusCcw == WALKAROUND::DONE && wr.statusCw == WALKAROUND::DONE )
|
|
|
|
{
|
2022-01-29 15:05:34 +00:00
|
|
|
if( wr.lineCw.CLine().PointCount() > 1
|
|
|
|
&& wr.lineCw.CLine().Length() < wr.lineCcw.CLine().Length() )
|
|
|
|
{
|
|
|
|
aWalk = wr.lineCw;
|
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
else if( wr.lineCcw.CLine().PointCount() > 1 )
|
|
|
|
{
|
|
|
|
aWalk = wr.lineCcw;
|
|
|
|
ok = true;
|
|
|
|
}
|
2020-10-19 21:33:32 +00:00
|
|
|
}
|
2022-01-28 23:18:05 +00:00
|
|
|
else if( wr.statusCw == WALKAROUND::DONE && wr.lineCw.CLine().PointCount() > 1 )
|
2020-10-19 21:33:32 +00:00
|
|
|
{
|
|
|
|
aWalk = wr.lineCw;
|
|
|
|
ok = true;
|
|
|
|
}
|
2022-01-28 23:18:05 +00:00
|
|
|
else if( wr.statusCcw == WALKAROUND::DONE && wr.lineCcw.CLine().PointCount() > 1 )
|
2020-10-19 21:33:32 +00:00
|
|
|
{
|
|
|
|
aWalk = wr.lineCcw;
|
|
|
|
ok = true;
|
|
|
|
}
|
2022-01-29 15:05:34 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-05 15:33:14 +00:00
|
|
|
bool DRAGGER::dragWalkaround( const VECTOR2I& aP )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
bool ok = false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
// fixme: rewrite using shared_ptr...
|
2020-02-05 15:33:14 +00:00
|
|
|
if( m_lastNode )
|
|
|
|
{
|
|
|
|
delete m_lastNode;
|
|
|
|
m_lastNode = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastNode = m_world->Branch();
|
|
|
|
|
|
|
|
switch( m_mode )
|
|
|
|
{
|
|
|
|
case DM_SEGMENT:
|
|
|
|
case DM_CORNER:
|
|
|
|
{
|
|
|
|
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
|
|
|
|
LINE dragged( m_draggedLine );
|
2020-10-19 21:33:32 +00:00
|
|
|
LINE draggedWalk( m_draggedLine );
|
2020-02-05 15:33:14 +00:00
|
|
|
LINE origLine( m_draggedLine );
|
2021-04-08 01:30:18 +00:00
|
|
|
|
2020-10-19 21:33:32 +00:00
|
|
|
dragged.SetSnapThreshhold( thresh );
|
|
|
|
|
2020-02-05 15:33:14 +00:00
|
|
|
if( m_mode == DM_SEGMENT )
|
2020-07-22 23:04:52 +00:00
|
|
|
dragged.DragSegment( aP, m_draggedSegmentIndex );
|
2020-02-05 15:33:14 +00:00
|
|
|
else
|
2020-07-22 23:04:52 +00:00
|
|
|
dragged.DragCorner( aP, m_draggedSegmentIndex );
|
2020-02-05 15:33:14 +00:00
|
|
|
|
|
|
|
if ( m_world->CheckColliding( &dragged ) )
|
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
ok = tryWalkaround( m_lastNode, dragged, draggedWalk );
|
2020-02-05 15:33:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
draggedWalk = dragged;
|
2020-02-05 15:33:14 +00:00
|
|
|
ok = true;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2022-02-01 00:08:15 +00:00
|
|
|
if( draggedWalk.CLine().PointCount() < 2 )
|
|
|
|
ok = false;
|
|
|
|
|
2021-02-11 22:06:34 +00:00
|
|
|
if( ok )
|
2020-02-05 15:33:14 +00:00
|
|
|
{
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddShape, &origLine.CLine(), BLUE, 50000, wxT( "drag-orig-line" ) );
|
|
|
|
PNS_DBG( Dbg(), AddShape, &draggedWalk.CLine(), CYAN, 75000, wxT( "drag-walk" ) );
|
2020-02-05 15:33:14 +00:00
|
|
|
m_lastNode->Remove( origLine );
|
2020-10-19 21:33:32 +00:00
|
|
|
optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
|
2020-02-05 15:33:14 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
break;
|
2020-02-05 15:33:14 +00:00
|
|
|
}
|
2020-02-06 17:03:18 +00:00
|
|
|
case DM_VIA: // fixme...
|
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
ok = dragViaWalkaround( m_initialVia, m_lastNode, aP );
|
2021-01-02 00:30:22 +00:00
|
|
|
break;
|
2020-02-05 15:33:14 +00:00
|
|
|
}
|
2020-10-19 21:33:32 +00:00
|
|
|
}
|
2020-02-05 15:33:14 +00:00
|
|
|
|
|
|
|
m_dragStatus = ok;
|
|
|
|
|
2023-05-24 23:18:53 +00:00
|
|
|
return ok;
|
2020-02-05 15:33:14 +00:00
|
|
|
}
|
|
|
|
|
2021-04-08 01:59:23 +00:00
|
|
|
|
2020-02-05 15:33:14 +00:00
|
|
|
bool DRAGGER::dragShove( const VECTOR2I& aP )
|
|
|
|
{
|
|
|
|
bool ok = false;
|
2020-02-07 19:57:24 +00:00
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
if( m_lastNode )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
delete m_lastNode;
|
2021-07-19 23:56:05 +00:00
|
|
|
m_lastNode = nullptr;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
switch( m_mode )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2017-08-03 15:53:07 +00:00
|
|
|
case DM_SEGMENT:
|
|
|
|
case DM_CORNER:
|
2015-10-05 16:28:41 +00:00
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
//TODO: Make threshold configurable
|
2019-05-17 00:13:21 +00:00
|
|
|
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 2 : 0;
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE dragged( m_draggedLine );
|
2019-05-17 00:13:21 +00:00
|
|
|
dragged.SetSnapThreshhold( thresh );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
if( m_mode == DM_SEGMENT )
|
2019-05-17 00:13:21 +00:00
|
|
|
dragged.DragSegment( aP, m_draggedSegmentIndex );
|
2015-10-05 16:28:41 +00:00
|
|
|
else
|
2019-05-17 00:13:21 +00:00
|
|
|
dragged.DragCorner( aP, m_draggedSegmentIndex );
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddShape, &dragged.CLine(), BLUE, 5000, wxT( "drag-shove-line" ) );
|
2021-04-10 19:17:29 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
if( st == SHOVE::SH_OK )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2015-10-05 16:28:41 +00:00
|
|
|
ok = true;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2016-08-29 17:31:13 +00:00
|
|
|
else if( st == SHOVE::SH_HEAD_MODIFIED )
|
2015-10-05 16:28:41 +00:00
|
|
|
{
|
|
|
|
dragged = m_shove->NewHead();
|
|
|
|
ok = true;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
m_lastNode = m_shove->CurrentNode()->Branch();
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
if( ok )
|
2019-08-07 21:49:35 +00:00
|
|
|
{
|
2020-02-20 23:03:23 +00:00
|
|
|
VECTOR2D lockV;
|
2020-04-15 20:16:24 +00:00
|
|
|
dragged.ClearLinks();
|
2019-08-07 21:49:35 +00:00
|
|
|
dragged.Unmark();
|
2020-10-19 21:33:32 +00:00
|
|
|
optimizeAndUpdateDraggedLine( dragged, m_draggedLine, aP );
|
2021-04-08 01:59:23 +00:00
|
|
|
m_lastDragSolution = dragged;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_lastDragSolution.ClearLinks();
|
|
|
|
m_lastNode->Add( m_lastDragSolution );
|
2019-08-07 21:49:35 +00:00
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
case DM_VIA:
|
2015-10-05 16:28:41 +00:00
|
|
|
{
|
2019-08-07 21:49:35 +00:00
|
|
|
VIA_HANDLE newVia;
|
|
|
|
|
2021-11-21 21:56:26 +00:00
|
|
|
// corner count limiter intended to avoid excessive optimization produces mediocre results for via shoving.
|
|
|
|
// this is a hack that disables it, before I figure out a more reliable solution
|
|
|
|
m_shove->DisablePostShoveOptimizations( OPTIMIZER::LIMIT_CORNER_COUNT );
|
2019-08-07 21:49:35 +00:00
|
|
|
SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, newVia );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
if( st == SHOVE::SH_OK || st == SHOVE::SH_HEAD_MODIFIED )
|
2015-10-05 16:28:41 +00:00
|
|
|
ok = true;
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
m_lastNode = m_shove->CurrentNode()->Branch();
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
if( newVia.valid )
|
|
|
|
m_draggedVia = newVia;
|
2015-10-05 16:28:41 +00:00
|
|
|
|
2019-08-07 21:49:35 +00:00
|
|
|
m_draggedItems.Clear();
|
2023-08-01 23:03:04 +00:00
|
|
|
|
|
|
|
// If drag didn't work (i.e. dragged onto a collision) try walkaround instead
|
|
|
|
if( !ok )
|
|
|
|
ok = dragViaWalkaround( m_draggedVia, m_lastNode, aP );
|
|
|
|
|
2015-10-05 16:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
m_dragStatus = ok;
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DRAGGER::FixRoute()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2018-05-08 09:47:14 +00:00
|
|
|
NODE* node = CurrentNode();
|
|
|
|
|
|
|
|
if( node )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-12-27 22:14:38 +00:00
|
|
|
// If collisions exist, we can fix in shove/smart mode because all tracks to be committed
|
|
|
|
// will be in valid positions (even if the current routing solution to the mouse cursor is
|
|
|
|
// invalid). In other modes, we can only commit if "Allow DRC violations" is enabled.
|
2018-09-27 15:07:02 +00:00
|
|
|
if( !m_dragStatus )
|
2020-12-27 22:14:38 +00:00
|
|
|
{
|
2020-12-28 21:36:42 +00:00
|
|
|
Drag( m_lastValidPoint );
|
|
|
|
node = CurrentNode();
|
|
|
|
|
|
|
|
if( !node )
|
|
|
|
return false;
|
2020-12-27 22:14:38 +00:00
|
|
|
}
|
2018-09-27 15:07:02 +00:00
|
|
|
|
2021-04-10 09:31:42 +00:00
|
|
|
if( !m_dragStatus && !Settings().AllowDRCViolations() )
|
2020-12-28 21:36:42 +00:00
|
|
|
return false;
|
|
|
|
|
2018-05-08 09:47:14 +00:00
|
|
|
Router()->CommitRouting( node );
|
2014-05-14 13:53:54 +00:00
|
|
|
return true;
|
2014-11-14 19:19:00 +00:00
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DRAGGER::Drag( const VECTOR2I& aP )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-10-19 21:33:32 +00:00
|
|
|
m_mouseTrailTracer.AddTrailPoint( aP );
|
|
|
|
|
2020-12-28 21:36:42 +00:00
|
|
|
bool ret = false;
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2020-12-28 21:36:42 +00:00
|
|
|
if( m_freeAngleMode )
|
2014-11-14 19:19:00 +00:00
|
|
|
{
|
2020-12-28 21:36:42 +00:00
|
|
|
ret = dragMarkObstacles( aP );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-11 22:06:34 +00:00
|
|
|
switch( m_currentMode )
|
|
|
|
{
|
2021-12-01 09:52:37 +00:00
|
|
|
case RM_MarkObstacles: ret = dragMarkObstacles( aP ); break;
|
|
|
|
case RM_Shove: ret = dragShove( aP ); break;
|
|
|
|
case RM_Walkaround: ret = dragWalkaround( aP ); break;
|
|
|
|
default: break;
|
2021-02-11 22:06:34 +00:00
|
|
|
}
|
2014-11-14 19:19:00 +00:00
|
|
|
}
|
2020-12-28 21:36:42 +00:00
|
|
|
|
|
|
|
if( ret )
|
2023-05-24 23:18:53 +00:00
|
|
|
{
|
2020-12-28 21:36:42 +00:00
|
|
|
m_lastValidPoint = aP;
|
2023-05-24 23:18:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_lastNode )
|
|
|
|
{
|
|
|
|
delete m_lastNode;
|
2023-05-31 20:20:18 +00:00
|
|
|
m_draggedItems.Clear();
|
2023-05-24 23:18:53 +00:00
|
|
|
m_lastNode = nullptr;
|
|
|
|
}
|
|
|
|
}
|
2020-12-28 21:36:42 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
NODE* DRAGGER::CurrentNode() const
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2020-10-18 20:59:16 +00:00
|
|
|
return m_lastNode ? m_lastNode : m_world;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const ITEM_SET DRAGGER::Traces()
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
return m_draggedItems;
|
|
|
|
}
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
}
|