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 = NULL;
38  m_lastNode = NULL;
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
#define NULL
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:148
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:1104

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:156
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:150

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 736 of file pns_dragger.cpp.

737 {
738  return m_lastNode ? m_lastNode : m_world;
739 }
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 697 of file pns_dragger.cpp.

698 {
700 
701  bool ret = false;
702 
703  if( m_freeAngleMode )
704  {
705  ret = dragMarkObstacles( aP );
706  }
707  else
708  {
709  switch( m_currentMode )
710  {
711  case RM_MarkObstacles:
712  ret = dragMarkObstacles( aP );
713  break;
714 
715  case RM_Shove:
716  case RM_Smart:
717  ret = dragShove( aP );
718  break;
719 
720  case RM_Walkaround:
721  ret = dragWalkaround( aP );
722  break;
723 
724  default:
725  break;
726  }
727  }
728 
729  if( ret )
730  m_lastValidPoint = aP;
731 
732  return ret;
733 }
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 268 of file pns_dragger.cpp.

269 {
270  // fixme: rewrite using shared_ptr...
271  if( m_lastNode )
272  {
273  delete m_lastNode;
274  m_lastNode = nullptr;
275  }
276 
278 
279  switch( m_mode )
280  {
281  case DM_SEGMENT:
282  case DM_CORNER:
283  {
284  //TODO: Make threshold configurable
285  int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
286  LINE origLine( m_draggedLine );
287  LINE dragged( m_draggedLine );
288  dragged.SetSnapThreshhold( thresh );
289  dragged.ClearLinks();
290 
291  if( m_mode == DM_SEGMENT )
292  dragged.DragSegment( aP, m_draggedSegmentIndex );
293  else
294  dragged.DragCorner( aP, m_draggedSegmentIndex, m_freeAngleMode );
295 
296  m_lastNode->Remove( origLine );
297  m_lastNode->Add( dragged );
298 
300  m_draggedItems.Add( dragged );
301 
302  break;
303  }
304 
305  case DM_VIA: // fixme...
306  {
308 
309  break;
310  }
311  }
312 
313  if( Settings().AllowDRCViolations() )
314  m_dragStatus = true;
315  else
317 
318  return true;
319 }
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:127
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:810
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:433
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:621

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 587 of file pns_dragger.cpp.

588 {
589  bool ok = false;
590 
591  if( m_lastNode )
592  {
593  delete m_lastNode;
594  m_lastNode = NULL;
595  }
596 
597  switch( m_mode )
598  {
599  case DM_SEGMENT:
600  case DM_CORNER:
601  {
602  //TODO: Make threshold configurable
603  int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 2 : 0;
604  LINE dragged( m_draggedLine );
605  dragged.SetSnapThreshhold( thresh );
606 
607  if( m_mode == DM_SEGMENT )
608  dragged.DragSegment( aP, m_draggedSegmentIndex );
609  else
610  dragged.DragCorner( aP, m_draggedSegmentIndex );
611 
612  PNS_DBG( Dbg(), AddLine, dragged.CLine(), BLUE, 5000, "drag-shove-line" );
613 
614  SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
615 
616  if( st == SHOVE::SH_OK )
617  ok = true;
618  else if( st == SHOVE::SH_HEAD_MODIFIED )
619  {
620  dragged = m_shove->NewHead();
621  ok = true;
622  }
623 
624  m_lastNode = m_shove->CurrentNode()->Branch();
625 
626  if( ok )
627  {
628  VECTOR2D lockV;
629  dragged.ClearLinks();
630  dragged.Unmark();
632  m_lastDragSolution = dragged;
633  }
634  else
635  {
638  }
639 
640  break;
641  }
642 
643  case DM_VIA:
644  {
645  VIA_HANDLE newVia;
646 
647  SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, newVia );
648 
649  if( st == SHOVE::SH_OK || st == SHOVE::SH_HEAD_MODIFIED )
650  ok = true;
651 
652  m_lastNode = m_shove->CurrentNode()->Branch();
653 
654  if( newVia.valid )
655  m_draggedVia = newVia;
656 
658  break;
659  }
660  }
661 
662  m_dragStatus = ok;
663 
664  return ok;
665 }
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.
#define NULL
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
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:621

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(), m_draggedItems, m_draggedLine, m_draggedSegmentIndex, m_draggedVia, m_dragStatus, m_lastDragSolution, m_lastNode, m_mode, m_shove, NULL, 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 322 of file pns_dragger.cpp.

323 {
325 
326  ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
327 
328  if( fanout.Empty() )
329  {
330  return true;
331  }
332 
333  for( ITEM* item : fanout.Items() )
334  {
335  if( const LINE* l = dyn_cast<const LINE*>( item ) )
336  {
337  LINE origLine( *l );
338  LINE draggedLine( *l );
339 
340  draggedLine.DragCorner( aP, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode );
341  draggedLine.ClearLinks();
342 
343  m_draggedItems.Add( draggedLine );
344 
345  m_lastNode->Remove( origLine );
346  m_lastNode->Add( draggedLine );
347  }
348  else if ( VIA *via = dyn_cast<VIA*>( item ) )
349  {
350  auto nvia = Clone( *via );
351 
352  nvia->SetPos( aP );
353  m_draggedItems.Add( nvia.get() );
354 
355  m_lastNode->Remove( via );
356  m_lastNode->Add( std::move( nvia ) );
357  }
358  }
359 
360  return true;
361 }
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:810
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:265
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:621

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 364 of file pns_dragger.cpp.

365 {
367 
368  ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
369 
370  if( fanout.Empty() )
371  {
372  return true;
373  }
374 
375  bool viaPropOk = false;
376  VECTOR2I viaTargetPos;
377 
378  for( ITEM* item : fanout.Items() )
379  {
380  if ( VIA *via = dyn_cast<VIA*>( item ) )
381  {
382  auto draggedVia = Clone( *via );
383 
384  draggedVia->SetPos( aP );
385  m_draggedItems.Add( draggedVia.get() );
386 
387  std::set<VIA*> vias;
388 
389  vias.insert( draggedVia.get() );
390 
391  bool ok = propagateViaForces( m_lastNode, vias );
392 
393  if( ok )
394  {
395  viaTargetPos = draggedVia->Pos();
396  viaPropOk = true;
397  m_lastNode->Remove( via );
398  m_lastNode->Add( std::move(draggedVia) );
399  }
400  }
401  }
402 
403  if( !viaPropOk ) // can't force-propagate the via? bummer...
404  return false;
405 
406  for( ITEM* item : fanout.Items() )
407  {
408  if( const LINE* l = dyn_cast<const LINE*>( item ) )
409  {
410  LINE origLine( *l );
411  LINE draggedLine( *l );
412  LINE walkLine( *l );
413 
414  draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode );
415  draggedLine.ClearLinks();
416 
417  if ( m_world->CheckColliding( &draggedLine ) )
418  {
419  bool ok = tryWalkaround( m_lastNode, draggedLine, walkLine );
420 
421  if( !ok )
422  return false;
423 
424  m_lastNode->Remove( origLine );
425  optimizeAndUpdateDraggedLine( walkLine, origLine, aP );
426  }
427  else
428  {
429  m_draggedItems.Add( draggedLine );
430 
431  m_lastNode->Remove( origLine );
432  m_lastNode->Add( draggedLine );
433  }
434  }
435  }
436 
437  return true;
438 }
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:810
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:265
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:433
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:621

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 526 of file pns_dragger.cpp.

527 {
528  bool ok = false;
529 // fixme: rewrite using shared_ptr...
530  if( m_lastNode )
531  {
532  delete m_lastNode;
533  m_lastNode = nullptr;
534  }
535 
537 
538  switch( m_mode )
539  {
540  case DM_SEGMENT:
541  case DM_CORNER:
542  {
543  int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
544  LINE dragged( m_draggedLine );
545  LINE draggedWalk( m_draggedLine );
546  LINE origLine( m_draggedLine );
547 
548  dragged.SetSnapThreshhold( thresh );
549 
550  if( m_mode == DM_SEGMENT )
551  dragged.DragSegment( aP, m_draggedSegmentIndex );
552  else
553  dragged.DragCorner( aP, m_draggedSegmentIndex );
554 
555  if ( m_world->CheckColliding( &dragged ) )
556  {
557  ok = tryWalkaround( m_lastNode, dragged, draggedWalk );
558  }
559  else
560  {
561  draggedWalk = dragged;
562  ok = true;
563  }
564 
565  if( ok )
566  {
567  PNS_DBG( Dbg(), AddLine, origLine.CLine(), BLUE, 50000, "drag-orig-line" );
568  PNS_DBG( Dbg(), AddLine, draggedWalk.CLine(), CYAN, 75000, "drag-walk" );
569  m_lastNode->Remove( origLine );
570  optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
571  }
572  break;
573  }
574  case DM_VIA: // fixme...
575  {
577  break;
578  }
579  }
580 
581  m_dragStatus = ok;
582 
583  return true;
584 }
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:127
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:810
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:433
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 668 of file pns_dragger.cpp.

669 {
670  NODE* node = CurrentNode();
671 
672  if( node )
673  {
674  // If collisions exist, we can fix in shove/smart mode because all tracks to be committed
675  // will be in valid positions (even if the current routing solution to the mouse cursor is
676  // invalid). In other modes, we can only commit if "Allow DRC violations" is enabled.
677  if( !m_dragStatus )
678  {
680  node = CurrentNode();
681 
682  if( !node )
683  return false;
684  }
685 
686  if( !m_dragStatus && !Settings().AllowDRCViolations() )
687  return false;
688 
689  Router()->CommitRouting( node );
690  return true;
691  }
692 
693  return false;
694 }
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:694
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 NULL;
37 }
#define NULL

References NULL.

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 441 of file pns_dragger.cpp.

442 {
443  VECTOR2D lockV;
444  aDragged.ClearLinks();
445  aDragged.Unmark();
446 
447  lockV = aDragged.CLine().NearestPoint( aP );
448 
449  OPTIMIZER optimizer( m_lastNode );
450 
452 
453  if( Settings().SmoothDraggedSegments() )
454  effort |= OPTIMIZER::MERGE_COLINEAR;
455 
456  optimizer.SetEffortLevel( effort );
457 
458  OPT_BOX2I affectedArea = aDragged.ChangedArea( &aOrig );
459  VECTOR2I anchor( aP );
460 
461  if( aDragged.CLine().Find( aP ) < 0 )
462  {
463  anchor = aDragged.CLine().NearestPoint( aP );
464  }
465 
466  optimizer.SetPreserveVertex( anchor );
467 
468  // People almost never want KiCad to reroute tracks in areas they can't even see, so restrict
469  // the area to what is visible even if we are optimizing the "entire" track.
470  if( Settings().GetOptimizeEntireDraggedTrack() )
471  affectedArea = VisibleViewArea();
472  else if( !affectedArea )
473  affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
474 
475  PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, "drag-anchor" );
476  PNS_DBG( Dbg(), AddBox, *affectedArea, RED, "drag-affected-area" );
477 
478  optimizer.SetRestrictArea( *affectedArea );
479  optimizer.Optimize( &aDragged );
480 
481  OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
482 
483  if( optArea )
484  PNS_DBG( Dbg(), AddBox, *optArea, BLUE, "drag-opt-area" );
485 
486  m_lastNode->Add( aDragged );
488  m_draggedItems.Add( aDragged );
489 }
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:512
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:515
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:621

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:70
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 262 of file pns_dragger.cpp.

263 {
264  m_mode = aMode;
265 }

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 = NULL;
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]", startItem, (int) startItem->Kind() ) );
233 
234  switch( startItem->Kind() )
235  {
236  case ITEM::SEGMENT_T:
237  {
238  SEGMENT* seg = static_cast<SEGMENT*>( startItem );
239  VVIA* vvia = checkVirtualVia( aP, seg );
240 
241  if( vvia )
242  {
243  return startDragVia( vvia );
244  }
245  else
246  {
247  return startDragSegment( aP, seg );
248  }
249  }
250  case ITEM::VIA_T:
251  return startDragVia( static_cast<VIA*>( startItem ) );
252 
253  case ITEM::ARC_T:
254  return startDragArc( aP, static_cast<ARC*>( startItem ) );
255 
256  default:
257  return false;
258  }
259 }
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 NULL
#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
usual segment : line with rounded ends
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(), NULL, 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
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:920
int m_draggedSegmentIndex
Definition: pns_dragger.h:140

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().CShapes()[ m_draggedSegmentIndex + 1 ] < 0 ) )
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:148
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
const std::vector< ssize_t > & CShapes() const
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:920
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
bool m_freeAngleMode
Definition: pns_dragger.h:150

References SEG::A, PNS::NODE::AssembleLine(), SEG::B, PNS::LINE::CLine(), SHAPE_LINE_CHAIN::CShapes(), PNS::DM_CORNER, PNS::DM_SEGMENT, EuclideanNorm(), 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 742 of file pns_dragger.cpp.

743 {
744  return m_draggedItems;
745 }
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 492 of file pns_dragger.cpp.

493 {
494  WALKAROUND walkaround( aNode, Router() );
495  bool ok = false;
496  walkaround.SetSolidsOnly( false );
497  walkaround.SetDebugDecorator( Dbg() );
498  walkaround.SetLogger( Logger() );
499  walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
500 
501  aWalk = aOrig;
502 
503  WALKAROUND::RESULT wr = walkaround.Route( aWalk );
504 
505 
506  if( wr.statusCcw == WALKAROUND::DONE && wr.statusCw == WALKAROUND::DONE )
507  {
508  aWalk = ( wr.lineCw.CLine().Length() < wr.lineCcw.CLine().Length() ? wr.lineCw :
509  wr.lineCcw );
510  ok = true;
511  }
512  else if( wr.statusCw == WALKAROUND::DONE )
513  {
514  aWalk = wr.lineCw;
515  ok = true;
516  }
517  else if( wr.statusCcw == WALKAROUND::DONE )
518  {
519  aWalk = wr.lineCcw;
520  ok = true;
521  }
522  return ok;
523 }
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 39 of file pns_algo_base.cpp.

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

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: