40 m_draggedSegmentIndex = 0;
43 m_freeAngleMode =
false;
44 m_forceMarkObstaclesMode =
false;
62 if(
via->PushoutForce( node, lead, force,
ITEM::ANY_T, iterLimit ) )
64 via->SetPos(
via->Pos() + force );
74 int w2 = aSeg->
Width() / 2;
76 auto distA = ( aP - aSeg->
Seg().
A ).EuclideanNorm();
77 auto distB = ( aP - aSeg->
Seg().
B ).EuclideanNorm();
83 psnap = aSeg->
Seg().
A;
85 else if( distB <= w2 )
87 psnap = aSeg->
Seg().
B;
101 if( item->IsVirtual() && item->OfKind(
ITEM::VIA_T ))
102 return static_cast<VVIA*
>( item );
111 int w2 = aSeg->
Width() / 2;
126 auto distA = ( aP - aSeg->
Seg().
A ).EuclideanNorm();
127 auto distB = ( aP - aSeg->
Seg().
B ).EuclideanNorm();
129 if( distA < w2 || distB < w2 )
199 bool foundVia =
false;
229 if( aPrimitives.
Empty() )
232 ITEM* startItem = aPrimitives[0];
253 PNS_DBG(
Dbg(), Message, wxString::Format(
"StartDragging: item %p [kind %d]",
254 startItem, (
int) startItem->
Kind() ) );
256 switch( startItem->
Kind() )
282 m_mode =
static_cast<int>( aMode );
344 if(
Settings().AllowDRCViolations() )
364 if(
const LINE* l = dyn_cast<const LINE*>( item ) )
367 LINE draggedLine( *l );
377 else if (
VIA *
via = dyn_cast<VIA*>( item ) )
402 bool viaPropOk =
false;
407 if(
VIA *
via = dyn_cast<VIA*>( item ) )
409 std::unique_ptr<VIA> draggedVia =
Clone( *
via );
411 draggedVia->SetPos( aP );
416 vias.insert( draggedVia.get() );
424 viaTargetPos = draggedVia->Pos();
436 if(
const LINE* l = dyn_cast<const LINE*>( item ) )
439 LINE draggedLine( *l );
479 if(
Settings().SmoothDraggedSegments() )
494 if(
Settings().GetOptimizeEntireDraggedTrack() )
496 else if( !affectedArea )
497 affectedArea =
BOX2I( aP );
500 PNS_DBG(
Dbg(), AddShape, *affectedArea,
RED, 0, wxT(
"drag-affected-area" ) );
508 PNS_DBG(
Dbg(), AddShape, *optArea,
BLUE, 0, wxT(
"drag-opt-area" ) );
594 draggedWalk = dragged;
std::optional< BOX2I > OPT_BOX2I
const BOX2I & VisibleViewArea() const
void SetDebugDecorator(DEBUG_DECORATOR *aDecorator)
Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.
void SetLogger(LOGGER *aLogger)
virtual LOGGER * Logger()
ROUTER * Router() const
Return current router settings.
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
DEBUG_DECORATOR * Dbg() const
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
PNS::DRAG_MODE Mode() const override
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
const ITEM_SET findViaFanoutByHandle(NODE *aNode, const VIA_HANDLE &handle)
bool startDragSegment(const VECTOR2D &aP, SEGMENT *aSeg)
VECTOR2D m_lastValidPoint
Contains the list of items that are currently modified by the dragger.
virtual bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Function Start()
NODE * CurrentNode() const override
Function CurrentNode()
bool dragViaMarkObstacles(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
bool Drag(const VECTOR2I &aP) override
Function Drag()
bool startDragVia(VIA *aVia)
int m_draggedSegmentIndex
const std::vector< NET_HANDLE > CurrentNets() const override
Function CurrentNets()
bool dragShove(const VECTOR2I &aP)
void SetMode(PNS::DRAG_MODE aDragMode) override
bool dragMarkObstacles(const VECTOR2I &aP)
bool FixRoute(bool aForceCommit) override
Function FixRoute()
std::unique_ptr< SHOVE > m_shove
bool dragWalkaround(const VECTOR2I &aP)
VVIA * checkVirtualVia(const VECTOR2D &aP, SEGMENT *aSeg)
bool dragViaWalkaround(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
bool m_forceMarkObstaclesMode
const ITEM_SET Traces() override
Function Traces()
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
bool startDragArc(const VECTOR2D &aP, ARC *aArc)
MOUSE_TRAIL_TRACER m_mouseTrailTracer
bool propagateViaForces(NODE *node, std::set< VIA * > &vias)
void Add(const LINE &aLine)
std::vector< ITEM * > & Items()
Base class for PNS router board items.
virtual void Unmark(int aMarker=-1) const
virtual NET_HANDLE Net() const
PnsKind Kind() const
Return the type (kind) of the item.
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
const std::vector< ITEM * > & LinkList() const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
OPT_BOX2I ChangedArea(const LINE *aOther) const
const SHAPE_LINE_CHAIN & CLine() const
void SetSnapThreshhold(int aThreshhold)
void DragCorner(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
virtual void Unmark(int aMarker=-1) const override
void DragSegment(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
void Reverse()
Clip the line to the nearest obstacle, traversing from the line's start vertex (0).
int Width() const
Return true if the line is geometrically identical as line aOther.
virtual void ClearLinks()
Return the number of segments that were assembled together to form this line.
void AddTrailPoint(const VECTOR2I &aP)
VECTOR2I GetTrailLeadVector() const
Keep the router "world" - i.e.
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Check if the item collides with anything else in the world, and if found, returns the obstacle.
const JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, NET_HANDLE aNet) const
Search for a joint at a given position, layer and belonging to given net.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
void Remove(ARC *aArc)
Remove an item from this branch.
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=nullptr, bool aStopAtLockedJoints=false, bool aFollowLockedSegments=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
void SetPreserveVertex(const VECTOR2I &aV)
void SetRestrictArea(const BOX2I &aArea, bool aStrict=true)
void SetEffortLevel(int aEffort)
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I &aV=VECTOR2I(0, 0))
@ LIMIT_CORNER_COUNT
Do not attempt to optimize if the resulting line's corner count is outside the predefined range.
@ MERGE_SEGMENTS
Reduce corner cost iteratively.
@ MERGE_COLINEAR
Merge co-linear segments.
int ViaForcePropIterationLimit() const
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
PNS_MODE Mode() const
Set the routing mode.
int Width() const override
const VIA_HANDLE MakeHandle() const
void SetIterationLimit(const int aIterLimit)
void SetSolidsOnly(bool aSolidsOnly)
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
bool IsPtOnArc(size_t aPtIndex) const
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
long long int Length() const
Return length of the line chain in Euclidean metric.
int Find(const VECTOR2I &aP, int aThreshold=0) const
Search for point aP.
Push and Shove diff pair dimensions (gap) settings dialog.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
#define PNS_DBG(dbg, method,...)
WALKAROUND_STATUS statusCcw
WALKAROUND_STATUS statusCw