KiCad PCB EDA Suite
pns_dragger.cpp
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2014 CERN
5  * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <[email protected]>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "pns_arc.h"
23 
24 #include "pns_dragger.h"
25 #include "pns_shove.h"
26 #include "pns_router.h"
27 #include "pns_debug_decorator.h"
28 #include "pns_walkaround.h"
29 
30 namespace PNS {
31 
32 DRAGGER::DRAGGER( ROUTER* aRouter ) :
33  DRAG_ALGO( aRouter ),
34  m_initialVia( {} ),
35  m_draggedVia( {} )
36 {
37  m_world = nullptr;
38  m_lastNode = nullptr;
39  m_mode = DM_SEGMENT;
40  m_draggedSegmentIndex = 0;
41  m_dragStatus = false;
42  m_currentMode = RM_MarkObstacles;
43  m_freeAngleMode = false;
44 }
45 
46 
48 {
49 }
50 
51 
52 bool DRAGGER::propagateViaForces( NODE* node, std::set<VIA*>& vias )
53 {
54  VIA* via = *vias.begin();
55 
56  VECTOR2I force;
58 
59  bool solidsOnly = false;// ( m_currentMode != RM_Walkaround );
60 
61  if( via->PushoutForce( node, lead, force, solidsOnly, 40 ) )
62  {
63  via->SetPos( via->Pos() + force );
64  return true;
65  }
66 
67  return false;
68 }
69 
70 
72 {
73  int w2 = aSeg->Width() / 2;
74 
75  auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
76  auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
77 
78  VECTOR2I psnap;
79 
80  if( distA <= w2 )
81  {
82  psnap = aSeg->Seg().A;
83  }
84  else if( distB <= w2 )
85  {
86  psnap = aSeg->Seg().B;
87  }
88  else
89  {
90  return nullptr;
91  }
92 
93  JOINT *jt = m_world->FindJoint( psnap, aSeg );
94 
95  if ( !jt )
96  {
97  return nullptr;
98  }
99 
100  for( auto lnk : jt->LinkList() )
101  {
102  if( lnk.item->IsVirtual() && lnk.item->OfKind( ITEM::VIA_T ))
103  {
104  return static_cast<VVIA*>( lnk.item );
105  }
106  }
107 
108  return nullptr;
109 }
110 
111 
113 {
114  int w2 = aSeg->Width() / 2;
115 
118 
119  if( m_shove )
120  {
121  m_shove->SetInitialLine( m_draggedLine );
122  }
123 
124  auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
125  auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
126 
127  if( distA <= w2 )
128  {
129  m_mode = DM_CORNER;
130  }
131  else if( distB <= w2 )
132  {
134  m_mode = DM_CORNER;
135  }
136  else if( m_freeAngleMode )
137  {
138  if( distB < distA &&
140  ( !m_draggedLine.CLine().IsPtOnArc( static_cast<size_t>(m_draggedSegmentIndex) + 1 ) ) )
141  {
143  }
144 
145  m_mode = DM_CORNER;
146  }
147  else
148  {
149  m_mode = DM_SEGMENT;
150  }
151 
152  return true;
153 }
154 
155 
156 bool DRAGGER::startDragArc( const VECTOR2D& aP, ARC* aArc )
157 {
159  m_shove->SetInitialLine( m_draggedLine );
160  m_mode = DM_ARC;
161 
162  return true;
163 }
164 
165 
167 {
168  m_initialVia = aVia->MakeHandle();
170 
171  m_mode = DM_VIA;
172 
173  return true;
174 }
175 
177 {
178  ITEM_SET rv;
179 
180  JOINT* jt = aNode->FindJoint( handle.pos, handle.layers.Start(), handle.net );
181 
182  if( !jt )
183  return rv;
184 
185  for( ITEM* item : jt->LinkList() )
186  {
187  if( item->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
188  {
189  int segIndex;
190  LINKED_ITEM* seg = ( LINKED_ITEM*) item;
191  LINE l = aNode->AssembleLine( seg, &segIndex );
192 
193  if( segIndex != 0 )
194  l.Reverse();
195 
196  rv.Add( l );
197  }
198  else if( item->OfKind( ITEM::VIA_T ) )
199  {
200  rv.Add( item );
201  }
202  }
203 
204  return rv;
205 }
206 
207 bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
208 {
209  if( aPrimitives.Empty() )
210  return false;
211 
212  ITEM* startItem = aPrimitives[0];
213 
214  m_lastNode = nullptr;
218  m_lastValidPoint = aP;
219 
222 
224  {
225  m_shove = std::make_unique<SHOVE>( m_world, Router() );
226  m_shove->SetLogger( Logger() );
227  m_shove->SetDebugDecorator( Dbg() );
228  }
229 
230  startItem->Unmark( MK_LOCKED );
231 
232  PNS_DBG( Dbg(), Message, wxString::Format( "StartDragging: item %p [kind %d]",
233  startItem, (int) startItem->Kind() ) );
234 
235  switch( startItem->Kind() )
236  {
237  case ITEM::SEGMENT_T:
238  {
239  SEGMENT* seg = static_cast<SEGMENT*>( startItem );
240  VVIA* vvia = checkVirtualVia( aP, seg );
241 
242  if( vvia )
243  {
244  return startDragVia( vvia );
245  }
246  else
247  {
248  return startDragSegment( aP, seg );
249  }
250  }
251  case ITEM::VIA_T:
252  return startDragVia( static_cast<VIA*>( startItem ) );
253 
254  case ITEM::ARC_T:
255  return startDragArc( aP, static_cast<ARC*>( startItem ) );
256 
257  default:
258  return false;
259  }
260 }
261 
262 
263 void DRAGGER::SetMode( int aMode )
264 {
265  m_mode = aMode;
266 }
267 
268 
270 {
271  // fixme: rewrite using shared_ptr...
272  if( m_lastNode )
273  {
274  delete m_lastNode;
275  m_lastNode = nullptr;
276  }
277 
279 
280  switch( m_mode )
281  {
282  case DM_SEGMENT:
283  case DM_CORNER:
284  {
285  //TODO: Make threshold configurable
286  int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
287  LINE origLine( m_draggedLine );
288  LINE dragged( m_draggedLine );
289  dragged.SetSnapThreshhold( thresh );
290  dragged.ClearLinks();
291 
292  if( m_mode == DM_SEGMENT )
293  dragged.DragSegment( aP, m_draggedSegmentIndex );
294  else
296 
297  m_lastNode->Remove( origLine );
298  m_lastNode->Add( dragged );
299 
301  m_draggedItems.Add( dragged );
302 
303  break;
304  }
305 
306  case DM_VIA: // fixme...
307  {
309 
310  break;
311  }
312  }
313 
314  if( Settings().AllowDRCViolations() )
315  m_dragStatus = true;
316  else
318 
319  return true;
320 }
321 
322 
323 bool DRAGGER::dragViaMarkObstacles( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
324 {
326 
327  ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
328 
329  if( fanout.Empty() )
330  {
331  return true;
332  }
333 
334  for( ITEM* item : fanout.Items() )
335  {
336  if( const LINE* l = dyn_cast<const LINE*>( item ) )
337  {
338  LINE origLine( *l );
339  LINE draggedLine( *l );
340 
341  draggedLine.DragCorner( aP, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode );
342  draggedLine.ClearLinks();
343 
344  m_draggedItems.Add( draggedLine );
345 
346  m_lastNode->Remove( origLine );
347  m_lastNode->Add( draggedLine );
348  }
349  else if ( VIA *via = dyn_cast<VIA*>( item ) )
350  {
351  auto nvia = Clone( *via );
352 
353  nvia->SetPos( aP );
354  m_draggedItems.Add( nvia.get() );
355 
356  m_lastNode->Remove( via );
357  m_lastNode->Add( std::move( nvia ) );
358  }
359  }
360 
361  return true;
362 }
363 
364 
365 bool DRAGGER::dragViaWalkaround( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
366 {
368 
369  ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
370 
371  if( fanout.Empty() )
372  {
373  return true;
374  }
375 
376  bool viaPropOk = false;
377  VECTOR2I viaTargetPos;
378 
379  for( ITEM* item : fanout.Items() )
380  {
381  if ( VIA *via = dyn_cast<VIA*>( item ) )
382  {
383  auto draggedVia = Clone( *via );
384 
385  draggedVia->SetPos( aP );
386  m_draggedItems.Add( draggedVia.get() );
387 
388  std::set<VIA*> vias;
389 
390  vias.insert( draggedVia.get() );
391 
392  bool ok = propagateViaForces( m_lastNode, vias );
393 
394  if( ok )
395  {
396  viaTargetPos = draggedVia->Pos();
397  viaPropOk = true;
398  m_lastNode->Remove( via );
399  m_lastNode->Add( std::move(draggedVia) );
400  }
401  }
402  }
403 
404  if( !viaPropOk ) // can't force-propagate the via? bummer...
405  return false;
406 
407  for( ITEM* item : fanout.Items() )
408  {
409  if( const LINE* l = dyn_cast<const LINE*>( item ) )
410  {
411  LINE origLine( *l );
412  LINE draggedLine( *l );
413  LINE walkLine( *l );
414 
415  draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ),
416  m_freeAngleMode );
417  draggedLine.ClearLinks();
418 
419  if ( m_world->CheckColliding( &draggedLine ) )
420  {
421  bool ok = tryWalkaround( m_lastNode, draggedLine, walkLine );
422 
423  if( !ok )
424  return false;
425 
426  m_lastNode->Remove( origLine );
427  optimizeAndUpdateDraggedLine( walkLine, origLine, aP );
428  }
429  else
430  {
431  m_draggedItems.Add( draggedLine );
432 
433  m_lastNode->Remove( origLine );
434  m_lastNode->Add( draggedLine );
435  }
436  }
437  }
438 
439  return true;
440 }
441 
442 
443 void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, const VECTOR2I& aP )
444 {
445  VECTOR2D lockV;
446  aDragged.ClearLinks();
447  aDragged.Unmark();
448 
449  lockV = aDragged.CLine().NearestPoint( aP );
450 
451  OPTIMIZER optimizer( m_lastNode );
452 
454 
455  if( Settings().SmoothDraggedSegments() )
456  effort |= OPTIMIZER::MERGE_COLINEAR;
457 
458  optimizer.SetEffortLevel( effort );
459 
460  OPT_BOX2I affectedArea = aDragged.ChangedArea( &aOrig );
461  VECTOR2I anchor( aP );
462 
463  if( aDragged.CLine().Find( aP ) < 0 )
464  {
465  anchor = aDragged.CLine().NearestPoint( aP );
466  }
467 
468  optimizer.SetPreserveVertex( anchor );
469 
470  // People almost never want KiCad to reroute tracks in areas they can't even see, so restrict
471  // the area to what is visible even if we are optimizing the "entire" track.
472  if( Settings().GetOptimizeEntireDraggedTrack() )
473  affectedArea = VisibleViewArea();
474  else if( !affectedArea )
475  affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
476 
477  PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, "drag-anchor" );
478  PNS_DBG( Dbg(), AddBox, *affectedArea, RED, "drag-affected-area" );
479 
480  optimizer.SetRestrictArea( *affectedArea );
481  optimizer.Optimize( &aDragged );
482 
483  OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
484 
485  if( optArea )
486  PNS_DBG( Dbg(), AddBox, *optArea, BLUE, "drag-opt-area" );
487 
488  m_lastNode->Add( aDragged );
490  m_draggedItems.Add( aDragged );
491 }
492 
493 
494 bool DRAGGER::tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk )
495 {
496  WALKAROUND walkaround( aNode, Router() );
497  bool ok = false;
498  walkaround.SetSolidsOnly( false );
499  walkaround.SetDebugDecorator( Dbg() );
500  walkaround.SetLogger( Logger() );
501  walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
502 
503  aWalk = aOrig;
504 
505  WALKAROUND::RESULT wr = walkaround.Route( aWalk );
506 
507 
509  {
510  aWalk = ( wr.lineCw.CLine().Length() < wr.lineCcw.CLine().Length() ? wr.lineCw :
511  wr.lineCcw );
512  ok = true;
513  }
514  else if( wr.statusCw == WALKAROUND::DONE )
515  {
516  aWalk = wr.lineCw;
517  ok = true;
518  }
519  else if( wr.statusCcw == WALKAROUND::DONE )
520  {
521  aWalk = wr.lineCcw;
522  ok = true;
523  }
524  return ok;
525 }
526 
527 
529 {
530  bool ok = false;
531 
532  // fixme: rewrite using shared_ptr...
533  if( m_lastNode )
534  {
535  delete m_lastNode;
536  m_lastNode = nullptr;
537  }
538 
540 
541  switch( m_mode )
542  {
543  case DM_SEGMENT:
544  case DM_CORNER:
545  {
546  int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
547  LINE dragged( m_draggedLine );
548  LINE draggedWalk( m_draggedLine );
549  LINE origLine( m_draggedLine );
550 
551  dragged.SetSnapThreshhold( thresh );
552 
553  if( m_mode == DM_SEGMENT )
554  dragged.DragSegment( aP, m_draggedSegmentIndex );
555  else
556  dragged.DragCorner( aP, m_draggedSegmentIndex );
557 
558  if ( m_world->CheckColliding( &dragged ) )
559  {
560  ok = tryWalkaround( m_lastNode, dragged, draggedWalk );
561  }
562  else
563  {
564  draggedWalk = dragged;
565  ok = true;
566  }
567 
568  if( ok )
569  {
570  PNS_DBG( Dbg(), AddLine, origLine.CLine(), BLUE, 50000, "drag-orig-line" );
571  PNS_DBG( Dbg(), AddLine, draggedWalk.CLine(), CYAN, 75000, "drag-walk" );
572  m_lastNode->Remove( origLine );
573  optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
574  }
575 
576  break;
577  }
578  case DM_VIA: // fixme...
579  {
581  break;
582  }
583  }
584 
585  m_dragStatus = ok;
586 
587  return true;
588 }
589 
590 
591 bool DRAGGER::dragShove( const VECTOR2I& aP )
592 {
593  bool ok = false;
594 
595  if( m_lastNode )
596  {
597  delete m_lastNode;
598  m_lastNode = nullptr;
599  }
600 
601  switch( m_mode )
602  {
603  case DM_SEGMENT:
604  case DM_CORNER:
605  {
606  //TODO: Make threshold configurable
607  int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 2 : 0;
608  LINE dragged( m_draggedLine );
609  dragged.SetSnapThreshhold( thresh );
610 
611  if( m_mode == DM_SEGMENT )
612  dragged.DragSegment( aP, m_draggedSegmentIndex );
613  else
614  dragged.DragCorner( aP, m_draggedSegmentIndex );
615 
616  PNS_DBG( Dbg(), AddLine, dragged.CLine(), BLUE, 5000, "drag-shove-line" );
617 
618  SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
619 
620  if( st == SHOVE::SH_OK )
621  {
622  ok = true;
623  }
624  else if( st == SHOVE::SH_HEAD_MODIFIED )
625  {
626  dragged = m_shove->NewHead();
627  ok = true;
628  }
629 
630  m_lastNode = m_shove->CurrentNode()->Branch();
631 
632  if( ok )
633  {
634  VECTOR2D lockV;
635  dragged.ClearLinks();
636  dragged.Unmark();
638  m_lastDragSolution = dragged;
639  }
640  else
641  {
644  }
645 
646  break;
647  }
648 
649  case DM_VIA:
650  {
651  VIA_HANDLE newVia;
652 
653  // corner count limiter intended to avoid excessive optimization produces mediocre results for via shoving.
654  // this is a hack that disables it, before I figure out a more reliable solution
655  m_shove->DisablePostShoveOptimizations( OPTIMIZER::LIMIT_CORNER_COUNT );
656  SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, newVia );
657 
658  if( st == SHOVE::SH_OK || st == SHOVE::SH_HEAD_MODIFIED )
659  ok = true;
660 
661  m_lastNode = m_shove->CurrentNode()->Branch();
662 
663  if( newVia.valid )
664  m_draggedVia = newVia;
665 
667  break;
668  }
669  }
670 
671  m_dragStatus = ok;
672 
673  return ok;
674 }
675 
676 
678 {
679  NODE* node = CurrentNode();
680 
681  if( node )
682  {
683  // If collisions exist, we can fix in shove/smart mode because all tracks to be committed
684  // will be in valid positions (even if the current routing solution to the mouse cursor is
685  // invalid). In other modes, we can only commit if "Allow DRC violations" is enabled.
686  if( !m_dragStatus )
687  {
689  node = CurrentNode();
690 
691  if( !node )
692  return false;
693  }
694 
695  if( !m_dragStatus && !Settings().AllowDRCViolations() )
696  return false;
697 
698  Router()->CommitRouting( node );
699  return true;
700  }
701 
702  return false;
703 }
704 
705 
706 bool DRAGGER::Drag( const VECTOR2I& aP )
707 {
709 
710  bool ret = false;
711 
712  if( m_freeAngleMode )
713  {
714  ret = dragMarkObstacles( aP );
715  }
716  else
717  {
718  switch( m_currentMode )
719  {
720  case RM_MarkObstacles:
721  ret = dragMarkObstacles( aP );
722  break;
723 
724  case RM_Shove:
725  case RM_Smart:
726  ret = dragShove( aP );
727  break;
728 
729  case RM_Walkaround:
730  ret = dragWalkaround( aP );
731  break;
732 
733  default:
734  break;
735  }
736  }
737 
738  if( ret )
739  m_lastValidPoint = aP;
740 
741  return ret;
742 }
743 
744 
746 {
747  return m_lastNode ? m_lastNode : m_world;
748 }
749 
750 
752 {
753  return m_draggedItems;
754 }
755 
756 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
const SHAPE_LINE_CHAIN & CLine() const
Definition: pns_line.h:137
Base class for PNS router board items.
Definition: pns_item.h:55
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
const VIA_HANDLE MakeHandle() const
Definition: pns_via.cpp:123
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
long long int Length() const
Return length of the line chain in Euclidean metric.
bool Drag(const VECTOR2I &aP) override
Function Drag()
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
bool Empty() const
Definition: pns_itemset.h:130
Keep the router "world" - i.e.
Definition: pns_node.h:146
bool propagateViaForces(NODE *node, std::set< VIA * > &vias)
Definition: pns_dragger.cpp:52
OPT_BOX2I ChangedArea(const LINE *aOther) const
Definition: pns_line.cpp:1166
void DragSegment(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
Definition: pns_line.cpp:763
DRAGGER(ROUTER *aRouter)
Definition: pns_dragger.cpp:32
void CommitRouting()
Definition: pns_router.cpp:707
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:139
DRAG_ALGO.
Definition: pns_drag_algo.h:42
int Width() const override
Definition: pns_segment.h:79
WALKAROUND_STATUS statusCw
ENTRIES & Items()
Definition: pns_itemset.h:135
bool m_dragStatus
Definition: pns_dragger.h:141
void SetRestrictArea(const BOX2I &aArea, bool aStrict=true)
virtual LOGGER * Logger()
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
bool startDragSegment(const VECTOR2D &aP, SEGMENT *aSeg)
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:133
virtual bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Function Start()
LINE m_draggedLine
Definition: pns_dragger.h:137
const ITEM_SET Traces() override
Function Traces()
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
NODE * CurrentNode() const override
Function CurrentNode()
bool startDragArc(const VECTOR2D &aP, ARC *aArc)
const SEG & Seg() const
Definition: pns_segment.h:84
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:60
virtual void Unmark(int aMarker=-1) const
Definition: pns_item.h:211
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:137
bool startDragVia(VIA *aVia)
int PointCount() const
Definition: pns_line.h:140
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I &aV=VECTOR2I(0, 0))
LINE m_lastDragSolution
Definition: pns_dragger.h:138
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:836
int Start() const
Definition: pns_layerset.h:82
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
Definition: color4d.h:67
bool dragViaMarkObstacles(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
Definition: pns_joint.h:42
void Reverse()
Clip the line to the nearest obstacle, traversing from the line's start vertex (0).
Definition: pns_line.cpp:1038
int Find(const VECTOR2I &aP, int aThreshold=0) const
Search for point aP.
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
#define PNS_DBG(dbg, method,...)
void SetPreserveVertex(const VECTOR2I &aV)
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
void AddTrailPoint(const VECTOR2I &aP)
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
PNS_MODE Mode() const
Set the routing mode.
Definition: color4d.h:58
void SetSolidsOnly(bool aSolidsOnly)
bool dragViaWalkaround(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
const LINKED_ITEMS & LinkList() const
Definition: pns_joint.h:195
Reduce corner cost iteratively.
Definition: pns_optimizer.h:99
Definition: color4d.h:59
MOUSE_TRAIL_TRACER m_mouseTrailTracer
Definition: pns_dragger.h:151
bool IsPtOnArc(size_t aPtIndex) const
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1140
NODE * m_lastNode
Definition: pns_dragger.h:135
void DragCorner(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
Definition: pns_line.cpp:749
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool FixRoute() override
Function FixRoute()
const BOX2I & VisibleViewArea() const
Guess what's better, try to make least mess on the PCB.
const ITEM_SET findViaFanoutByHandle(NODE *aNode, const VIA_HANDLE &handle)
Definition: color4d.h:56
bool dragWalkaround(const VECTOR2I &aP)
Ignore collisions, mark obstacles.
bool dragShove(const VECTOR2I &aP)
PNS_MODE m_currentMode
Definition: pns_dragger.h:142
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:271
Do not attempt to optimize if the resulting line's corner count is outside the predefined range.
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.
Definition: pns_node.cpp:450
WALKAROUND_STATUS statusCcw
LAYER_RANGE layers
Definition: pns_via.h:44
VECTOR2I A
Definition: seg.h:48
VIA_HANDLE m_initialVia
Definition: pns_dragger.h:132
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition: pns_line.h:156
bool dragMarkObstacles(const VECTOR2I &aP)
Only walk around.
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:509
void SetDebugDecorator(DEBUG_DECORATOR *aDecorator)
Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.
Definition: pns_algo_base.h:73
VECTOR2I pos
Definition: pns_via.h:43
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:130
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
Definition: pns_optimizer.h:94
bool m_freeAngleMode
Definition: pns_dragger.h:150
Merge co-linear segments.
void SetEffortLevel(int aEffort)
Push and Shove diff pair dimensions (gap) settings dialog.
VECTOR2D m_lastValidPoint
Contains the list of items that are currently modified by the dragger.
Definition: pns_dragger.h:144
VVIA * checkVirtualVia(const VECTOR2D &aP, SEGMENT *aSeg)
Definition: pns_dragger.cpp:71
void SetLogger(LOGGER *aLogger)
Definition: pns_algo_base.h:65
void SetMode(int aDragMode) override
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:638
void SetIterationLimit(const int aIterLimit)
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=nullptr, bool aStopAtLockedJoints=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:946
virtual void Unmark(int aMarker=-1) const override
Definition: pns_line.cpp:99
void SetSnapThreshhold(int aThreshhold)
Definition: pns_line.h:221
VECTOR2I B
Definition: seg.h:49