KiCad PCB EDA Suite
PNS::DRAGGER Class Reference

DRAGGER. More...

#include <pns_dragger.h>

Inheritance diagram for PNS::DRAGGER:
PNS::DRAG_ALGO PNS::ALGO_BASE

Public Member Functions

 DRAGGER (ROUTER *aRouter)
 
 ~DRAGGER ()
 
virtual bool Start (const VECTOR2I &aP, ITEM_SET &aPrimitives) override
 Function Start() More...
 
bool Drag (const VECTOR2I &aP) override
 Function Drag() More...
 
bool FixRoute () override
 Function FixRoute() More...
 
NODECurrentNode () const override
 Function CurrentNode() More...
 
const std::vector< int > CurrentNets () const override
 Function CurrentNets() More...
 
int CurrentLayer () const override
 Function CurrentLayer() More...
 
const ITEM_SET Traces () override
 Function Traces() More...
 
void SetMode (int aDragMode) override
 
virtual void SetWorld (NODE *aWorld)
 Function SetWorld() More...
 
ROUTERRouter () const
 Return current router settings. More...
 
ROUTING_SETTINGSSettings () const
 Return the logger object, allowing to dump geometry to a file. More...
 
virtual LOGGERLogger ()
 
void SetLogger (LOGGER *aLogger)
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Assign a debug decorator allowing this algo to draw extra graphics for visual debugging. More...
 
DEBUG_DECORATORDbg () const
 
const BOX2IVisibleViewArea () const
 

Protected Attributes

NODEm_world
 
DEBUG_DECORATORm_debugDecorator
 
ROUTERm_router
 
LOGGERm_logger
 

Private Member Functions

const ITEM_SET findViaFanoutByHandle (NODE *aNode, const VIA_HANDLE &handle)
 
bool dragMarkObstacles (const VECTOR2I &aP)
 
bool dragShove (const VECTOR2I &aP)
 
bool dragWalkaround (const VECTOR2I &aP)
 
bool startDragSegment (const VECTOR2D &aP, SEGMENT *aSeg)
 
bool startDragArc (const VECTOR2D &aP, ARC *aArc)
 
bool startDragVia (VIA *aVia)
 
bool dragViaMarkObstacles (const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
 
bool dragViaWalkaround (const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
 
void optimizeAndUpdateDraggedLine (LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
 
bool propagateViaForces (NODE *node, std::set< VIA * > &vias)
 
bool tryWalkaround (NODE *aNode, LINE &aOrig, LINE &aWalk)
 
VVIAcheckVirtualVia (const VECTOR2D &aP, SEGMENT *aSeg)
 

Private Attributes

VIA_HANDLE m_initialVia
 
VIA_HANDLE m_draggedVia
 
NODEm_lastNode
 
int m_mode
 
LINE m_draggedLine
 
LINE m_lastDragSolution
 
std::unique_ptr< SHOVEm_shove
 
int m_draggedSegmentIndex
 
bool m_dragStatus
 
PNS_MODE m_currentMode
 
ITEM_SET m_origViaConnections
 
VECTOR2D m_lastValidPoint
 Contains the list of items that are currently modified by the dragger. More...
 
ITEM_SET m_draggedItems
 If true, moves the connection lines without maintaining 45 degrees corners. More...
 
bool m_freeAngleMode
 
MOUSE_TRAIL_TRACER m_mouseTrailTracer
 

Detailed Description

DRAGGER.

Via, segment and corner dragging algorithm.

Definition at line 47 of file pns_dragger.h.

Constructor & Destructor Documentation

◆ DRAGGER()

PNS::DRAGGER::DRAGGER ( ROUTER aRouter)

Definition at line 32 of file pns_dragger.cpp.

32  :
33  DRAG_ALGO( aRouter ),
34  m_initialVia( {} ),
35  m_draggedVia( {} )
36 {
37  m_world = nullptr;
38  m_lastNode = nullptr;
41  m_dragStatus = false;
43  m_freeAngleMode = false;
44 }
bool m_dragStatus
Definition: pns_dragger.h:141
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:133
DRAG_ALGO(ROUTER *aRouter)
Definition: pns_drag_algo.h:45
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
NODE * m_lastNode
Definition: pns_dragger.h:135
Ignore collisions, mark obstacles.
PNS_MODE m_currentMode
Definition: pns_dragger.h:142
VIA_HANDLE m_initialVia
Definition: pns_dragger.h:132
bool m_freeAngleMode
Definition: pns_dragger.h:150

◆ ~DRAGGER()

PNS::DRAGGER::~DRAGGER ( )

Definition at line 47 of file pns_dragger.cpp.

48 {
49 }

Member Function Documentation

◆ checkVirtualVia()

VVIA * PNS::DRAGGER::checkVirtualVia ( const VECTOR2D aP,
SEGMENT aSeg 
)
private

Definition at line 71 of file pns_dragger.cpp.

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 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
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

References SEG::A, SEG::B, EuclideanNorm(), PNS::NODE::FindJoint(), PNS::JOINT::LinkList(), PNS::DRAG_ALGO::m_world, PNS::SEGMENT::Seg(), PNS::ITEM::VIA_T, and PNS::SEGMENT::Width().

Referenced by Start().

◆ CurrentLayer()

int PNS::DRAGGER::CurrentLayer ( ) const
inlineoverridevirtual

Function CurrentLayer()

Returns the layer of currently routed track.

Implements PNS::DRAG_ALGO.

Definition at line 101 of file pns_dragger.h.

102  {
103  return m_draggedLine.Layer();
104  }
virtual int Layer() const
Definition: pns_item.h:158
LINE m_draggedLine
Definition: pns_dragger.h:137

References PNS::ITEM::Layer(), and m_draggedLine.

◆ CurrentNets()

const std::vector<int> PNS::DRAGGER::CurrentNets ( ) const
inlineoverridevirtual

Function CurrentNets()

Returns the net code(s) of currently routed track(s).

Implements PNS::DRAG_ALGO.

Definition at line 91 of file pns_dragger.h.

92  {
93  return std::vector<int>( 1, m_draggedLine.Net() );
94  }
LINE m_draggedLine
Definition: pns_dragger.h:137
int Net() const
Definition: pns_item.h:152

References m_draggedLine, and PNS::ITEM::Net().

◆ CurrentNode()

NODE * PNS::DRAGGER::CurrentNode ( ) const
overridevirtual

Function CurrentNode()

Returns the most recent world state, including all items changed due to dragging operation.

Implements PNS::DRAG_ALGO.

Definition at line 745 of file pns_dragger.cpp.

746 {
747  return m_lastNode ? m_lastNode : m_world;
748 }
NODE * m_lastNode
Definition: pns_dragger.h:135

References m_lastNode, and PNS::DRAG_ALGO::m_world.

Referenced by FixRoute().

◆ Dbg()

◆ Drag()

bool PNS::DRAGGER::Drag ( const VECTOR2I aP)
overridevirtual

Function Drag()

Drags the current segment/corner/via to the point aP.

Returns
true, if dragging finished with success.

Implements PNS::DRAG_ALGO.

Definition at line 706 of file pns_dragger.cpp.

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 }
void AddTrailPoint(const VECTOR2I &aP)
MOUSE_TRAIL_TRACER m_mouseTrailTracer
Definition: pns_dragger.h:151
Guess what's better, try to make least mess on the PCB.
bool dragWalkaround(const VECTOR2I &aP)
Ignore collisions, mark obstacles.
bool dragShove(const VECTOR2I &aP)
PNS_MODE m_currentMode
Definition: pns_dragger.h:142
bool dragMarkObstacles(const VECTOR2I &aP)
Only walk around.
bool m_freeAngleMode
Definition: pns_dragger.h:150
VECTOR2D m_lastValidPoint
Contains the list of items that are currently modified by the dragger.
Definition: pns_dragger.h:144

References PNS::MOUSE_TRAIL_TRACER::AddTrailPoint(), dragMarkObstacles(), dragShove(), dragWalkaround(), m_currentMode, m_freeAngleMode, m_lastValidPoint, m_mouseTrailTracer, PNS::RM_MarkObstacles, PNS::RM_Shove, PNS::RM_Smart, and PNS::RM_Walkaround.

Referenced by FixRoute().

◆ dragMarkObstacles()

bool PNS::DRAGGER::dragMarkObstacles ( const VECTOR2I aP)
private

Definition at line 269 of file pns_dragger.cpp.

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
295  dragged.DragCorner( aP, m_draggedSegmentIndex, m_freeAngleMode );
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 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
bool m_dragStatus
Definition: pns_dragger.h:141
LINE m_draggedLine
Definition: pns_dragger.h:137
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
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:836
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
bool dragViaMarkObstacles(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
NODE * m_lastNode
Definition: pns_dragger.h:135
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
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 m_freeAngleMode
Definition: pns_dragger.h:150
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:638

References PNS::ITEM_SET::Add(), PNS::NODE::Add(), PNS::NODE::Branch(), PNS::NODE::CheckColliding(), PNS::ITEM_SET::Clear(), PNS::LINK_HOLDER::ClearLinks(), PNS::DM_CORNER, PNS::DM_SEGMENT, PNS::DM_VIA, PNS::LINE::DragCorner(), PNS::LINE::DragSegment(), dragViaMarkObstacles(), m_draggedItems, m_draggedLine, m_draggedSegmentIndex, m_dragStatus, m_freeAngleMode, m_initialVia, m_lastNode, m_mode, PNS::DRAG_ALGO::m_world, PNS::NODE::Remove(), PNS::LINE::SetSnapThreshhold(), PNS::ALGO_BASE::Settings(), PNS::ROUTING_SETTINGS::SmoothDraggedSegments(), and PNS::LINE::Width().

Referenced by Drag().

◆ dragShove()

bool PNS::DRAGGER::dragShove ( const VECTOR2I aP)
private

Definition at line 591 of file pns_dragger.cpp.

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 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:139
bool m_dragStatus
Definition: pns_dragger.h:141
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:133
LINE m_draggedLine
Definition: pns_dragger.h:137
LINE m_lastDragSolution
Definition: pns_dragger.h:138
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
#define PNS_DBG(dbg, method,...)
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
NODE * m_lastNode
Definition: pns_dragger.h:135
Definition: color4d.h:56
Do not attempt to optimize if the resulting line's corner count is outside the predefined range.
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition: pns_line.h:156
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:638

References PNS::NODE::Add(), BLUE, PNS::ITEM_SET::Clear(), PNS::LINK_HOLDER::ClearLinks(), PNS::LINE::CLine(), PNS::ALGO_BASE::Dbg(), PNS::DM_CORNER, PNS::DM_SEGMENT, PNS::DM_VIA, PNS::LINE::DragCorner(), PNS::LINE::DragSegment(), PNS::OPTIMIZER::LIMIT_CORNER_COUNT, m_draggedItems, m_draggedLine, m_draggedSegmentIndex, m_draggedVia, m_dragStatus, m_lastDragSolution, m_lastNode, m_mode, m_shove, optimizeAndUpdateDraggedLine(), PNS_DBG, PNS::LINE::SetSnapThreshhold(), PNS::ALGO_BASE::Settings(), PNS::SHOVE::SH_HEAD_MODIFIED, PNS::SHOVE::SH_OK, PNS::ROUTING_SETTINGS::SmoothDraggedSegments(), PNS::LINE::Unmark(), PNS::VIA_HANDLE::valid, and PNS::LINE::Width().

Referenced by Drag().

◆ dragViaMarkObstacles()

bool PNS::DRAGGER::dragViaMarkObstacles ( const VIA_HANDLE aHandle,
NODE aNode,
const VECTOR2I aP 
)
private

Definition at line 323 of file pns_dragger.cpp.

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 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:836
NODE * m_lastNode
Definition: pns_dragger.h:135
const ITEM_SET findViaFanoutByHandle(NODE *aNode, const VIA_HANDLE &handle)
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:271
bool m_freeAngleMode
Definition: pns_dragger.h:150
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:638

References PNS::ITEM_SET::Add(), PNS::NODE::Add(), PNS::ITEM_SET::Clear(), PNS::LINK_HOLDER::ClearLinks(), PNS::LINE::CLine(), PNS::Clone(), PNS::LINE::DragCorner(), PNS::ITEM_SET::Empty(), SHAPE_LINE_CHAIN::Find(), findViaFanoutByHandle(), PNS::ITEM_SET::Items(), m_draggedItems, m_freeAngleMode, m_lastNode, PNS::VIA_HANDLE::pos, PNS::NODE::Remove(), and via.

Referenced by dragMarkObstacles().

◆ dragViaWalkaround()

bool PNS::DRAGGER::dragViaWalkaround ( const VIA_HANDLE aHandle,
NODE aNode,
const VECTOR2I aP 
)
private

Definition at line 365 of file pns_dragger.cpp.

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 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
bool propagateViaForces(NODE *node, std::set< VIA * > &vias)
Definition: pns_dragger.cpp:52
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:836
NODE * m_lastNode
Definition: pns_dragger.h:135
const ITEM_SET findViaFanoutByHandle(NODE *aNode, const VIA_HANDLE &handle)
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:271
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
bool m_freeAngleMode
Definition: pns_dragger.h:150
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:638

References PNS::ITEM_SET::Add(), PNS::NODE::Add(), PNS::NODE::CheckColliding(), PNS::ITEM_SET::Clear(), PNS::LINK_HOLDER::ClearLinks(), PNS::LINE::CLine(), PNS::Clone(), PNS::LINE::DragCorner(), PNS::ITEM_SET::Empty(), SHAPE_LINE_CHAIN::Find(), findViaFanoutByHandle(), PNS::ITEM_SET::Items(), m_draggedItems, m_freeAngleMode, m_lastNode, PNS::DRAG_ALGO::m_world, optimizeAndUpdateDraggedLine(), PNS::VIA_HANDLE::pos, propagateViaForces(), PNS::NODE::Remove(), tryWalkaround(), and via.

Referenced by dragWalkaround().

◆ dragWalkaround()

bool PNS::DRAGGER::dragWalkaround ( const VECTOR2I aP)
private

Definition at line 528 of file pns_dragger.cpp.

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 }
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
bool m_dragStatus
Definition: pns_dragger.h:141
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
LINE m_draggedLine
Definition: pns_dragger.h:137
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:137
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:836
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
#define PNS_DBG(dbg, method,...)
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
Definition: color4d.h:58
bool dragViaWalkaround(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
NODE * m_lastNode
Definition: pns_dragger.h:135
Definition: color4d.h:56
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
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

References BLUE, PNS::NODE::Branch(), PNS::NODE::CheckColliding(), PNS::LINE::CLine(), CYAN, PNS::ALGO_BASE::Dbg(), PNS::DM_CORNER, PNS::DM_SEGMENT, PNS::DM_VIA, PNS::LINE::DragCorner(), PNS::LINE::DragSegment(), dragViaWalkaround(), m_draggedLine, m_draggedSegmentIndex, m_dragStatus, m_initialVia, m_lastNode, m_mode, PNS::DRAG_ALGO::m_world, optimizeAndUpdateDraggedLine(), PNS_DBG, PNS::NODE::Remove(), PNS::LINE::SetSnapThreshhold(), PNS::ALGO_BASE::Settings(), PNS::ROUTING_SETTINGS::SmoothDraggedSegments(), tryWalkaround(), and PNS::LINE::Width().

Referenced by Drag().

◆ findViaFanoutByHandle()

const ITEM_SET PNS::DRAGGER::findViaFanoutByHandle ( NODE aNode,
const VIA_HANDLE handle 
)
private

Definition at line 176 of file pns_dragger.cpp.

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 }

References PNS::ITEM_SET::Add(), PNS::ITEM::ARC_T, PNS::NODE::AssembleLine(), PNS::NODE::FindJoint(), PNS::VIA_HANDLE::layers, PNS::JOINT::LinkList(), PNS::VIA_HANDLE::net, PNS::VIA_HANDLE::pos, PNS::LINE::Reverse(), PNS::ITEM::SEGMENT_T, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

Referenced by dragViaMarkObstacles(), and dragViaWalkaround().

◆ FixRoute()

bool PNS::DRAGGER::FixRoute ( )
overridevirtual

Function FixRoute()

Checks if the result of current dragging operation is correct and eventually commits it to the world.

Returns
true, if dragging finished with success.

Implements PNS::DRAG_ALGO.

Definition at line 677 of file pns_dragger.cpp.

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 }
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
bool Drag(const VECTOR2I &aP) override
Function Drag()
void CommitRouting()
Definition: pns_router.cpp:707
bool m_dragStatus
Definition: pns_dragger.h:141
NODE * CurrentNode() const override
Function CurrentNode()
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
VECTOR2D m_lastValidPoint
Contains the list of items that are currently modified by the dragger.
Definition: pns_dragger.h:144

References PNS::ROUTER::CommitRouting(), CurrentNode(), Drag(), m_dragStatus, m_lastValidPoint, PNS::ALGO_BASE::Router(), and PNS::ALGO_BASE::Settings().

◆ Logger()

LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Reimplemented in PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

35 {
36  return nullptr;
37 }

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), Start(), and tryWalkaround().

◆ optimizeAndUpdateDraggedLine()

void PNS::DRAGGER::optimizeAndUpdateDraggedLine ( LINE aDragged,
const LINE aOrig,
const VECTOR2I aP 
)
private

Definition at line 443 of file pns_dragger.cpp.

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 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
Definition: color4d.h:67
#define PNS_DBG(dbg, method,...)
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
Reduce corner cost iteratively.
Definition: pns_optimizer.h:99
Definition: color4d.h:59
NODE * m_lastNode
Definition: pns_dragger.h:135
const BOX2I & VisibleViewArea() const
Definition: color4d.h:56
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:509
Merge co-linear segments.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:638

References PNS::ITEM_SET::Add(), PNS::NODE::Add(), anchor, BLUE, PNS::LINE::ChangedArea(), PNS::ITEM_SET::Clear(), PNS::LINK_HOLDER::ClearLinks(), PNS::LINE::CLine(), PNS::ALGO_BASE::Dbg(), SHAPE_LINE_CHAIN::Find(), PNS::OPTIMIZER::KEEP_TOPOLOGY, m_draggedItems, m_lastNode, PNS::OPTIMIZER::MERGE_COLINEAR, PNS::OPTIMIZER::MERGE_SEGMENTS, SHAPE_LINE_CHAIN::NearestPoint(), PNS::OPTIMIZER::Optimize(), PNS_DBG, RED, PNS::OPTIMIZER::RESTRICT_AREA, PNS::OPTIMIZER::SetEffortLevel(), PNS::OPTIMIZER::SetPreserveVertex(), PNS::OPTIMIZER::SetRestrictArea(), PNS::ALGO_BASE::Settings(), PNS::LINE::Unmark(), PNS::ALGO_BASE::VisibleViewArea(), and YELLOW.

Referenced by dragShove(), dragViaWalkaround(), and dragWalkaround().

◆ propagateViaForces()

bool PNS::DRAGGER::propagateViaForces ( NODE node,
std::set< VIA * > &  vias 
)
private

Definition at line 52 of file pns_dragger.cpp.

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 }
Normal via.
Definition: router_tool.cpp:72
MOUSE_TRAIL_TRACER m_mouseTrailTracer
Definition: pns_dragger.h:151

References PNS::MOUSE_TRAIL_TRACER::GetTrailLeadVector(), m_mouseTrailTracer, and via.

Referenced by dragViaWalkaround().

◆ Router()

◆ SetDebugDecorator()

void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.

Definition at line 73 of file pns_algo_base.h.

74  {
75  m_debugDecorator = aDecorator;
76  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:86

References PNS::ALGO_BASE::m_debugDecorator.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::SHOVE::SHOVE(), and tryWalkaround().

◆ SetLogger()

void PNS::ALGO_BASE::SetLogger ( LOGGER aLogger)
inlineinherited

Definition at line 65 of file pns_algo_base.h.

66  {
67  m_logger = aLogger;
68  }
LOGGER * m_logger
Definition: pns_algo_base.h:88

References PNS::ALGO_BASE::m_logger.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and tryWalkaround().

◆ SetMode()

void PNS::DRAGGER::SetMode ( int  aDragMode)
overridevirtual

Reimplemented from PNS::DRAG_ALGO.

Definition at line 263 of file pns_dragger.cpp.

264 {
265  m_mode = aMode;
266 }

References m_mode.

◆ Settings()

◆ SetWorld()

virtual void PNS::DRAG_ALGO::SetWorld ( NODE aWorld)
inlinevirtualinherited

Function SetWorld()

Sets the board to work on.

Definition at line 60 of file pns_drag_algo.h.

61  {
62  m_world = aWorld;
63  }

References PNS::DRAG_ALGO::m_world.

◆ Start()

bool PNS::DRAGGER::Start ( const VECTOR2I aP,
ITEM_SET aPrimitives 
)
overridevirtual

Function Start()

Starts routing a single track at point aP, taking item aStartItem as anchor (unless NULL). Returns true if a dragging operation has started.

Implements PNS::DRAG_ALGO.

Definition at line 207 of file pns_dragger.cpp.

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 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:139
virtual LOGGER * Logger()
bool startDragSegment(const VECTOR2D &aP, SEGMENT *aSeg)
bool startDragArc(const VECTOR2D &aP, ARC *aArc)
bool startDragVia(VIA *aVia)
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
#define PNS_DBG(dbg, method,...)
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
void AddTrailPoint(const VECTOR2I &aP)
PNS_MODE Mode() const
Set the routing mode.
MOUSE_TRAIL_TRACER m_mouseTrailTracer
Definition: pns_dragger.h:151
NODE * m_lastNode
Definition: pns_dragger.h:135
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
PNS_MODE m_currentMode
Definition: pns_dragger.h:142
bool m_freeAngleMode
Definition: pns_dragger.h:150
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

References PNS::MOUSE_TRAIL_TRACER::AddTrailPoint(), PNS::ITEM::ARC_T, checkVirtualVia(), PNS::MOUSE_TRAIL_TRACER::Clear(), PNS::ITEM_SET::Clear(), PNS::ALGO_BASE::Dbg(), PNS::DM_FREE_ANGLE, PNS::ITEM_SET::Empty(), Format(), PNS::ITEM::Kind(), PNS::ALGO_BASE::Logger(), m_currentMode, m_draggedItems, m_freeAngleMode, m_lastNode, m_lastValidPoint, m_mode, m_mouseTrailTracer, m_shove, PNS::DRAG_ALGO::m_world, PNS::MK_LOCKED, PNS::ROUTING_SETTINGS::Mode(), PNS_DBG, PNS::RM_Shove, PNS::ALGO_BASE::Router(), PNS::ITEM::SEGMENT_T, PNS::ALGO_BASE::Settings(), startDragArc(), startDragSegment(), startDragVia(), PNS::ITEM::Unmark(), and PNS::ITEM::VIA_T.

◆ startDragArc()

bool PNS::DRAGGER::startDragArc ( const VECTOR2D aP,
ARC aArc 
)
private

Definition at line 156 of file pns_dragger.cpp.

157 {
159  m_shove->SetInitialLine( m_draggedLine );
160  m_mode = DM_ARC;
161 
162  return true;
163 }
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:139
LINE m_draggedLine
Definition: pns_dragger.h:137
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
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

References PNS::NODE::AssembleLine(), PNS::DM_ARC, m_draggedLine, m_draggedSegmentIndex, m_mode, m_shove, and PNS::DRAG_ALGO::m_world.

Referenced by Start().

◆ startDragSegment()

bool PNS::DRAGGER::startDragSegment ( const VECTOR2D aP,
SEGMENT aSeg 
)
private

Definition at line 112 of file pns_dragger.cpp.

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 }
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
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:139
LINE m_draggedLine
Definition: pns_dragger.h:137
int PointCount() const
Definition: pns_line.h:140
LINE m_lastDragSolution
Definition: pns_dragger.h:138
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
bool IsPtOnArc(size_t aPtIndex) const
bool m_freeAngleMode
Definition: pns_dragger.h:150
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

References SEG::A, PNS::NODE::AssembleLine(), SEG::B, PNS::LINE::CLine(), PNS::DM_CORNER, PNS::DM_SEGMENT, EuclideanNorm(), SHAPE_LINE_CHAIN::IsPtOnArc(), m_draggedLine, m_draggedSegmentIndex, m_freeAngleMode, m_lastDragSolution, m_mode, m_shove, PNS::DRAG_ALGO::m_world, PNS::LINE::PointCount(), PNS::SEGMENT::Seg(), and PNS::SEGMENT::Width().

Referenced by Start().

◆ startDragVia()

bool PNS::DRAGGER::startDragVia ( VIA aVia)
private

Definition at line 166 of file pns_dragger.cpp.

167 {
168  m_initialVia = aVia->MakeHandle();
170 
171  m_mode = DM_VIA;
172 
173  return true;
174 }
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:133
VIA_HANDLE m_initialVia
Definition: pns_dragger.h:132

References PNS::DM_VIA, m_draggedVia, m_initialVia, m_mode, and PNS::VIA::MakeHandle().

Referenced by Start().

◆ Traces()

const ITEM_SET PNS::DRAGGER::Traces ( )
overridevirtual

Function Traces()

Returns the set of dragged items.

Implements PNS::DRAG_ALGO.

Definition at line 751 of file pns_dragger.cpp.

752 {
753  return m_draggedItems;
754 }
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147

References m_draggedItems.

◆ tryWalkaround()

bool PNS::DRAGGER::tryWalkaround ( NODE aNode,
LINE aOrig,
LINE aWalk 
)
private

Definition at line 494 of file pns_dragger.cpp.

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 
508  if( wr.statusCcw == WALKAROUND::DONE && wr.statusCw == WALKAROUND::DONE )
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 }
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
virtual LOGGER * Logger()
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78

References PNS::LINE::CLine(), PNS::ALGO_BASE::Dbg(), PNS::WALKAROUND::DONE, SHAPE_LINE_CHAIN::Length(), PNS::WALKAROUND::RESULT::lineCcw, PNS::WALKAROUND::RESULT::lineCw, PNS::ALGO_BASE::Logger(), PNS::WALKAROUND::Route(), PNS::ALGO_BASE::Router(), PNS::ALGO_BASE::SetDebugDecorator(), PNS::WALKAROUND::SetIterationLimit(), PNS::ALGO_BASE::SetLogger(), PNS::WALKAROUND::SetSolidsOnly(), PNS::ALGO_BASE::Settings(), PNS::WALKAROUND::RESULT::statusCcw, and PNS::WALKAROUND::RESULT::statusCw.

Referenced by dragViaWalkaround(), and dragWalkaround().

◆ VisibleViewArea()

const BOX2I & PNS::ALGO_BASE::VisibleViewArea ( ) const
inherited

Definition at line 40 of file pns_algo_base.cpp.

41 {
42  return m_router->VisibleViewArea();
43 }
ROUTER * m_router
Definition: pns_algo_base.h:87
const BOX2I & VisibleViewArea() const
Definition: pns_router.h:210

References PNS::ALGO_BASE::m_router, and PNS::ROUTER::VisibleViewArea().

Referenced by optimizeAndUpdateDraggedLine(), and PNS::SHOVE::runOptimizer().

Member Data Documentation

◆ m_currentMode

PNS_MODE PNS::DRAGGER::m_currentMode
private

Definition at line 142 of file pns_dragger.h.

Referenced by Drag(), and Start().

◆ m_debugDecorator

DEBUG_DECORATOR* PNS::ALGO_BASE::m_debugDecorator
protectedinherited

Definition at line 86 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Dbg(), and PNS::ALGO_BASE::SetDebugDecorator().

◆ m_draggedItems

ITEM_SET PNS::DRAGGER::m_draggedItems
private

If true, moves the connection lines without maintaining 45 degrees corners.

Definition at line 147 of file pns_dragger.h.

Referenced by dragMarkObstacles(), dragShove(), dragViaMarkObstacles(), dragViaWalkaround(), optimizeAndUpdateDraggedLine(), Start(), and Traces().

◆ m_draggedLine

LINE PNS::DRAGGER::m_draggedLine
private

◆ m_draggedSegmentIndex

int PNS::DRAGGER::m_draggedSegmentIndex
private

◆ m_draggedVia

VIA_HANDLE PNS::DRAGGER::m_draggedVia
private

Definition at line 133 of file pns_dragger.h.

Referenced by dragShove(), and startDragVia().

◆ m_dragStatus

bool PNS::DRAGGER::m_dragStatus
private

Definition at line 141 of file pns_dragger.h.

Referenced by dragMarkObstacles(), dragShove(), dragWalkaround(), and FixRoute().

◆ m_freeAngleMode

bool PNS::DRAGGER::m_freeAngleMode
private

◆ m_initialVia

VIA_HANDLE PNS::DRAGGER::m_initialVia
private

Definition at line 132 of file pns_dragger.h.

Referenced by dragMarkObstacles(), dragWalkaround(), and startDragVia().

◆ m_lastDragSolution

LINE PNS::DRAGGER::m_lastDragSolution
private

Definition at line 138 of file pns_dragger.h.

Referenced by dragShove(), and startDragSegment().

◆ m_lastNode

◆ m_lastValidPoint

VECTOR2D PNS::DRAGGER::m_lastValidPoint
private

Contains the list of items that are currently modified by the dragger.

Definition at line 144 of file pns_dragger.h.

Referenced by Drag(), FixRoute(), and Start().

◆ m_logger

LOGGER* PNS::ALGO_BASE::m_logger
protectedinherited

Definition at line 88 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::SetLogger().

◆ m_mode

int PNS::DRAGGER::m_mode
private

◆ m_mouseTrailTracer

MOUSE_TRAIL_TRACER PNS::DRAGGER::m_mouseTrailTracer
private

Definition at line 151 of file pns_dragger.h.

Referenced by Drag(), propagateViaForces(), and Start().

◆ m_origViaConnections

ITEM_SET PNS::DRAGGER::m_origViaConnections
private

Definition at line 143 of file pns_dragger.h.

◆ m_router

◆ m_shove

std::unique_ptr<SHOVE> PNS::DRAGGER::m_shove
private

Definition at line 139 of file pns_dragger.h.

Referenced by dragShove(), Start(), startDragArc(), and startDragSegment().

◆ m_world


The documentation for this class was generated from the following files: