KiCad PCB EDA Suite
PNS::ROUTER Class Reference

#include <pns_router.h>

Public Member Functions

 ROUTER ()
 
 ~ROUTER ()
 
void SetInterface (ROUTER_IFACE *aIface)
 
void SetMode (ROUTER_MODE aMode)
 
ROUTER_MODE Mode () const
 
void ClearWorld ()
 
void SyncWorld ()
 
void SetView (KIGFX::VIEW *aView)
 
bool RoutingInProgress () const
 
bool StartRouting (const VECTOR2I &aP, ITEM *aItem, int aLayer)
 
void Move (const VECTOR2I &aP, ITEM *aItem)
 
bool FixRoute (const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
 
void BreakSegment (ITEM *aItem, const VECTOR2I &aP)
 
void StopRouting ()
 
int GetClearance (const ITEM *aA, const ITEM *aB) const
 
NODEGetWorld () const
 
void FlipPosture ()
 
void DisplayItem (const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)
 
void DisplayItems (const ITEM_SET &aItems)
 
void DeleteTraces (ITEM *aStartItem, bool aWholeTrack)
 
void SwitchLayer (int layer)
 
void ToggleViaPlacement ()
 
void SetOrthoMode (bool aEnable)
 
int GetCurrentLayer () const
 
const std::vector< int > GetCurrentNets () const
 
void DumpLog ()
 
RULE_RESOLVERGetRuleResolver () const
 
bool IsPlacingVia () const
 
const ITEM_SET QueryHoverItems (const VECTOR2I &aP)
 
const VECTOR2I SnapToItem (ITEM *aItem, VECTOR2I aP, bool &aSplitsSegment)
 
bool StartDragging (const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
 
void SetIterLimit (int aX)
 
int GetIterLimit () const
 
void SetShowIntermediateSteps (bool aX, int aSnapshotIter=-1)
 
bool GetShowIntermediateSteps () const
 
int GetShapshotIter () const
 
ROUTING_SETTINGSSettings ()
 
void CommitRouting (NODE *aNode)
 
void UpdateSizes (const SIZES_SETTINGS &aSizes)
 Applies stored settings. More...
 
void LoadSettings (const ROUTING_SETTINGS &aSettings)
 Changes routing settings to ones passed in the parameter. More...
 
SIZES_SETTINGSSizes ()
 
ITEMQueryItemByParent (const BOARD_ITEM *aItem) const
 
void SetFailureReason (const wxString &aReason)
 
const wxString & FailureReason () const
 
PLACEMENT_ALGOPlacer ()
 
ROUTER_IFACEGetInterface () const
 

Static Public Member Functions

static ROUTERGetInstance ()
 

Private Types

enum  RouterState { IDLE, DRAG_SEGMENT, ROUTE_TRACK }
 

Private Member Functions

void movePlacing (const VECTOR2I &aP, ITEM *aItem)
 
void moveDragging (const VECTOR2I &aP, ITEM *aItem)
 
void eraseView ()
 
void updateView (NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
 
void clearViewFlags ()
 
ITEMpickSingleItem (ITEM_SET &aItems) const
 
void splitAdjacentSegments (NODE *aNode, ITEM *aSeg, const VECTOR2I &aP)
 
ITEMsyncPad (D_PAD *aPad)
 
ITEMsyncTrack (TRACK *aTrack)
 
ITEMsyncVia (VIA *aVia)
 
void commitPad (SOLID *aPad)
 
void commitSegment (SEGMENT *aTrack)
 
void commitVia (VIA *aVia)
 
void highlightCurrent (bool enabled)
 
void markViolations (NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
 
bool isStartingPointRoutable (const VECTOR2I &aWhere, int aLayer)
 

Private Attributes

VECTOR2I m_currentEnd
 
RouterState m_state
 
std::unique_ptr< NODEm_world
 
NODEm_lastNode
 
std::unique_ptr< PLACEMENT_ALGOm_placer
 
std::unique_ptr< DRAGGERm_dragger
 
std::unique_ptr< SHOVEm_shove
 
ROUTER_IFACEm_iface
 
int m_iterLimit
 
bool m_showInterSteps
 
int m_snapshotIter
 
bool m_violation
 
bool m_forceMarkObstaclesMode = false
 
ROUTING_SETTINGS m_settings
 
SIZES_SETTINGS m_sizes
 
ROUTER_MODE m_mode
 
wxString m_toolStatusbarName
 
wxString m_failureReason
 

Detailed Description

Definition at line 111 of file pns_router.h.

Member Enumeration Documentation

◆ RouterState

Enumerator
IDLE 
DRAG_SEGMENT 
ROUTE_TRACK 

Definition at line 114 of file pns_router.h.

Constructor & Destructor Documentation

◆ ROUTER()

PNS::ROUTER::ROUTER ( )

Definition at line 60 of file pns_router.cpp.

61 {
62  theRouter = this;
63 
64  m_state = IDLE;
66 
67  // Initialize all other variables:
68  m_lastNode = nullptr;
69  m_iterLimit = 0;
70  m_showInterSteps = false;
71  m_snapshotIter = 0;
72  m_violation = false;
73  m_iface = nullptr;
74 }
int m_snapshotIter
Definition: pns_router.h:267
int m_iterLimit
Definition: pns_router.h:265
bool m_showInterSteps
Definition: pns_router.h:266
NODE * m_lastNode
Definition: pns_router.h:257
RouterState m_state
Definition: pns_router.h:254
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
static ROUTER * theRouter
Definition: pns_router.cpp:58
bool m_violation
Definition: pns_router.h:268
ROUTER_MODE m_mode
Definition: pns_router.h:273

References IDLE, m_iface, m_iterLimit, m_lastNode, m_mode, m_showInterSteps, m_snapshotIter, m_state, m_violation, PNS::PNS_MODE_ROUTE_SINGLE, and PNS::theRouter.

◆ ~ROUTER()

PNS::ROUTER::~ROUTER ( )

Definition at line 83 of file pns_router.cpp.

84 {
85  ClearWorld();
86  theRouter = nullptr;
87 }
void ClearWorld()
Definition: pns_router.cpp:99
static ROUTER * theRouter
Definition: pns_router.cpp:58

References ClearWorld(), and PNS::theRouter.

Member Function Documentation

◆ BreakSegment()

void PNS::ROUTER::BreakSegment ( ITEM aItem,
const VECTOR2I aP 
)

Definition at line 528 of file pns_router.cpp.

529 {
530  NODE *node = m_world->Branch();
531 
532  LINE_PLACER placer( this );
533 
534  if ( placer.SplitAdjacentSegments( node, aItem, aP ) )
535  {
536  CommitRouting( node );
537  }
538  else
539  {
540  delete node;
541  }
542 
543 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:356

References CommitRouting(), m_world, and PNS::LINE_PLACER::SplitAdjacentSegments().

Referenced by ROUTER_TOOL::breakTrack().

◆ clearViewFlags()

void PNS::ROUTER::clearViewFlags ( )
private

◆ ClearWorld()

void PNS::ROUTER::ClearWorld ( )

Definition at line 99 of file pns_router.cpp.

100 {
101  if( m_world )
102  {
103  m_world->KillChildren();
104  m_world.reset();
105  }
106 
107  m_placer.reset();
108 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259

References m_placer, and m_world.

Referenced by ROUTER_TOOL::MainLoop(), PNS::TOOL_BASE::Reset(), SyncWorld(), and ~ROUTER().

◆ commitPad()

void PNS::ROUTER::commitPad ( SOLID aPad)
private

◆ CommitRouting()

void PNS::ROUTER::CommitRouting ( NODE aNode)

Definition at line 356 of file pns_router.cpp.

357 {
358  NODE::ITEM_VECTOR removed, added;
359 
360  aNode->GetUpdatedItems( removed, added );
361 
362  for( auto item : removed )
363  m_iface->RemoveItem( item );
364 
365  for( auto item : added )
366  m_iface->AddItem( item );
367 
368  m_iface->Commit();
369  m_world->Commit( aNode );
370 }
virtual void AddItem(ITEM *aItem)=0
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
virtual void Commit()=0
virtual void RemoveItem(ITEM *aItem)=0
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:144

References PNS::ROUTER_IFACE::AddItem(), PNS::ROUTER_IFACE::Commit(), PNS::NODE::GetUpdatedItems(), m_iface, m_world, and PNS::ROUTER_IFACE::RemoveItem().

Referenced by BreakSegment(), PNS::TOOL_BASE::deleteTraces(), PNS::MEANDER_PLACER::FixRoute(), PNS::DP_MEANDER_PLACER::FixRoute(), PNS::DRAGGER::FixRoute(), PNS::LINE_PLACER::FixRoute(), and PNS::DIFF_PAIR_PLACER::FixRoute().

◆ commitSegment()

void PNS::ROUTER::commitSegment ( SEGMENT aTrack)
private

◆ commitVia()

void PNS::ROUTER::commitVia ( VIA aVia)
private

◆ DeleteTraces()

void PNS::ROUTER::DeleteTraces ( ITEM aStartItem,
bool  aWholeTrack 
)

◆ DisplayItem()

void PNS::ROUTER::DisplayItem ( const ITEM aItem,
int  aColor = -1,
int  aClearance = -1,
bool  aEdit = false 
)

◆ DisplayItems()

void PNS::ROUTER::DisplayItems ( const ITEM_SET aItems)

Definition at line 223 of file pns_router.cpp.

224 {
225  for( const ITEM* item : aItems.CItems() )
226  m_iface->DisplayItem( item );
227 }
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:263

References PNS::ITEM_SET::CItems(), PNS::ROUTER_IFACE::DisplayItem(), and m_iface.

◆ DumpLog()

void PNS::ROUTER::DumpLog ( )

Definition at line 475 of file pns_router.cpp.

476 {
477  LOGGER* logger = nullptr;
478 
479  switch( m_state )
480  {
481  case DRAG_SEGMENT:
482  logger = m_dragger->Logger();
483  break;
484 
485  case ROUTE_TRACK:
486  logger = m_placer->Logger();
487  break;
488 
489  default:
490  break;
491  }
492 
493  if( logger )
494  logger->Save( "/tmp/shove.log" );
495 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:260

References DRAG_SEGMENT, m_dragger, m_placer, m_state, ROUTE_TRACK, and PNS::LOGGER::Save().

Referenced by ROUTER_TOOL::handleCommonEvents().

◆ eraseView()

void PNS::ROUTER::eraseView ( )
private

◆ FailureReason()

const wxString& PNS::ROUTER::FailureReason ( ) const
inline

Definition at line 217 of file pns_router.h.

217 { return m_failureReason; }
wxString m_failureReason
Definition: pns_router.h:276

References m_failureReason.

Referenced by LENGTH_TUNER_TOOL::performTuning(), and ROUTER_TOOL::prepareInteractive().

◆ FixRoute()

bool PNS::ROUTER::FixRoute ( const VECTOR2I aP,
ITEM aItem,
bool  aForceFinish = false 
)

Definition at line 373 of file pns_router.cpp.

374 {
375  bool rv = false;
376 
377  switch( m_state )
378  {
379  case ROUTE_TRACK:
380  rv = m_placer->FixRoute( aP, aEndItem, aForceFinish );
381  break;
382 
383  case DRAG_SEGMENT:
384  rv = m_dragger->FixRoute();
385  break;
386 
387  default:
388  break;
389  }
390 
391  if( rv )
392  StopRouting();
393 
394  return rv;
395 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:260
void StopRouting()
Definition: pns_router.cpp:398

References DRAG_SEGMENT, m_dragger, m_placer, m_state, ROUTE_TRACK, and StopRouting().

Referenced by ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), and LENGTH_TUNER_TOOL::performTuning().

◆ FlipPosture()

void PNS::ROUTER::FlipPosture ( )

Definition at line 426 of file pns_router.cpp.

427 {
428  if( m_state == ROUTE_TRACK )
429  {
430  m_placer->FlipPosture();
431  }
432 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::performRouting().

◆ GetClearance()

int PNS::ROUTER::GetClearance ( const ITEM aA,
const ITEM aB 
) const

◆ GetCurrentLayer()

int PNS::ROUTER::GetCurrentLayer ( ) const

Definition at line 467 of file pns_router.cpp.

468 {
469  if( m_placer )
470  return m_placer->CurrentLayer();
471  return -1;
472 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259

References m_placer.

Referenced by ROUTER_TOOL::onViaCommand(), ROUTER_TOOL::performRouting(), ROUTER_TOOL::switchLayerOnViaPlacement(), and PNS::TOOL_BASE::updateEndItem().

◆ GetCurrentNets()

const std::vector< int > PNS::ROUTER::GetCurrentNets ( ) const

Definition at line 458 of file pns_router.cpp.

459 {
460  if( m_placer )
461  return m_placer->CurrentNets();
462 
463  return std::vector<int>();
464 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259

References m_placer.

Referenced by PNS::TOOL_BASE::updateEndItem().

◆ GetInstance()

ROUTER * PNS::ROUTER::GetInstance ( )
static

Definition at line 77 of file pns_router.cpp.

78 {
79  return theRouter;
80 }
static ROUTER * theRouter
Definition: pns_router.cpp:58

References PNS::theRouter.

◆ GetInterface()

ROUTER_IFACE* PNS::ROUTER::GetInterface ( ) const
inline

Definition at line 221 of file pns_router.h.

222  {
223  return m_iface;
224  }
ROUTER_IFACE * m_iface
Definition: pns_router.h:263

References m_iface.

Referenced by PNS::SHOVE::SHOVE().

◆ GetIterLimit()

int PNS::ROUTER::GetIterLimit ( ) const
inline

Definition at line 179 of file pns_router.h.

179 { return m_iterLimit; };
int m_iterLimit
Definition: pns_router.h:265

References m_iterLimit.

◆ GetRuleResolver()

RULE_RESOLVER* PNS::ROUTER::GetRuleResolver ( ) const
inline

Definition at line 166 of file pns_router.h.

167  {
168  return m_iface->GetRuleResolver();
169  }
virtual RULE_RESOLVER * GetRuleResolver()=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:263

References PNS::ROUTER_IFACE::GetRuleResolver(), and m_iface.

Referenced by movePlacing(), and updateView().

◆ GetShapshotIter()

int PNS::ROUTER::GetShapshotIter ( ) const
inline

Definition at line 188 of file pns_router.h.

188 { return m_snapshotIter; }
int m_snapshotIter
Definition: pns_router.h:267

References m_snapshotIter.

◆ GetShowIntermediateSteps()

bool PNS::ROUTER::GetShowIntermediateSteps ( ) const
inline

Definition at line 187 of file pns_router.h.

187 { return m_showInterSteps; }
bool m_showInterSteps
Definition: pns_router.h:266

References m_showInterSteps.

◆ GetWorld()

◆ highlightCurrent()

void PNS::ROUTER::highlightCurrent ( bool  enabled)
private

◆ IsPlacingVia()

bool PNS::ROUTER::IsPlacingVia ( ) const

Definition at line 498 of file pns_router.cpp.

499 {
500  if( !m_placer )
501  return false;
502 
503  return m_placer->IsPlacingVia();
504 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259

References m_placer.

Referenced by ROUTER_TOOL::onViaCommand(), ROUTER_TOOL::performRouting(), and PNS::TOOL_BASE::updateEndItem().

◆ isStartingPointRoutable()

bool PNS::ROUTER::isStartingPointRoutable ( const VECTOR2I aWhere,
int  aLayer 
)
private

Definition at line 157 of file pns_router.cpp.

158 {
159  if( Settings().CanViolateDRC() && Settings().Mode() == RM_MarkObstacles )
160  return true;
161 
162  auto candidates = QueryHoverItems( aWhere );
163 
164  for( ITEM* item : candidates.Items() )
165  {
166  if( ! item->IsRoutable() && item->Layers().Overlaps( aLayer ) )
167  {
168  return false;
169  }
170  }
171 
172  return true;
173 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:117
ROUTER_MODE Mode() const
Definition: pns_router.h:127
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190

References Mode(), QueryHoverItems(), PNS::RM_MarkObstacles, and Settings().

Referenced by StartRouting().

◆ LoadSettings()

void PNS::ROUTER::LoadSettings ( const ROUTING_SETTINGS aSettings)
inline

Changes routing settings to ones passed in the parameter.

Parameters
aSettingsare the new settings.

Definition at line 204 of file pns_router.h.

205  {
206  m_settings = aSettings;
207  }
ROUTING_SETTINGS m_settings
Definition: pns_router.h:271

References m_settings.

Referenced by PNS::TOOL_BASE::Reset().

◆ markViolations()

void PNS::ROUTER::markViolations ( NODE aNode,
ITEM_SET aCurrent,
NODE::ITEM_VECTOR aRemoved 
)
private

Definition at line 261 of file pns_router.cpp.

262 {
263  for( ITEM* item : aCurrent.Items() )
264  {
265  NODE::OBSTACLES obstacles;
266 
267  aNode->QueryColliding( item, obstacles, ITEM::ANY_T );
268 
269  if( item->OfKind( ITEM::LINE_T ) )
270  {
271  LINE* l = static_cast<LINE*>( item );
272 
273  if( l->EndsWithVia() )
274  {
275  VIA v( l->Via() );
276  aNode->QueryColliding( &v, obstacles, ITEM::ANY_T );
277  }
278  }
279 
280  for( OBSTACLE& obs : obstacles )
281  {
282  int clearance = aNode->GetClearance( item, obs.m_item );
283  std::unique_ptr<ITEM> tmp( obs.m_item->Clone() );
284  tmp->Mark( MK_VIOLATION );
285  m_iface->DisplayItem( tmp.get(), -1, clearance );
286  aRemoved.push_back( obs.m_item );
287  }
288  }
289 }
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:145

References PNS::ITEM::ANY_T, PNS::ROUTER_IFACE::DisplayItem(), PNS::LINE::EndsWithVia(), PNS::NODE::GetClearance(), PNS::ITEM_SET::Items(), PNS::ITEM::LINE_T, m_iface, PNS::MK_VIOLATION, PNS::NODE::QueryColliding(), and PNS::LINE::Via().

Referenced by updateView().

◆ Mode()

ROUTER_MODE PNS::ROUTER::Mode ( ) const
inline

Definition at line 127 of file pns_router.h.

127 { return m_mode; }
ROUTER_MODE m_mode
Definition: pns_router.h:273

References m_mode.

Referenced by isStartingPointRoutable(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), and updateView().

◆ Move()

void PNS::ROUTER::Move ( const VECTOR2I aP,
ITEM aItem 
)

Definition at line 230 of file pns_router.cpp.

231 {
232  m_currentEnd = aP;
233 
234  switch( m_state )
235  {
236  case ROUTE_TRACK:
237  movePlacing( aP, endItem );
238  break;
239 
240  case DRAG_SEGMENT:
241  moveDragging( aP, endItem );
242  break;
243 
244  default:
245  break;
246  }
247 }
void moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:250
VECTOR2I m_currentEnd
Definition: pns_router.h:253
RouterState m_state
Definition: pns_router.h:254
void movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:329

References DRAG_SEGMENT, m_currentEnd, m_state, moveDragging(), movePlacing(), and ROUTE_TRACK.

Referenced by ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), and LENGTH_TUNER_TOOL::performTuning().

◆ moveDragging()

void PNS::ROUTER::moveDragging ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 250 of file pns_router.cpp.

251 {
252  m_iface->EraseView();
253 
254  m_dragger->Drag( aP );
255  ITEM_SET dragged = m_dragger->Traces();
256 
257  updateView( m_dragger->CurrentNode(), dragged, true );
258 }
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:292
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:260
virtual void EraseView()=0

References PNS::ROUTER_IFACE::EraseView(), m_dragger, m_iface, and updateView().

Referenced by Move().

◆ movePlacing()

void PNS::ROUTER::movePlacing ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 329 of file pns_router.cpp.

330 {
331  m_iface->EraseView();
332 
333  m_placer->Move( aP, aEndItem );
334  ITEM_SET current = m_placer->Traces();
335 
336  for( const ITEM* item : current.CItems() )
337  {
338  if( !item->OfKind( ITEM::LINE_T ) )
339  continue;
340 
341  const LINE* l = static_cast<const LINE*>( item );
342  int clearance = GetRuleResolver()->Clearance( item->Net() );
343 
344  m_iface->DisplayItem( l, -1, clearance );
345 
346  if( l->EndsWithVia() )
347  m_iface->DisplayItem( &l->Via(), -1, clearance );
348  }
349 
350  //ITEM_SET tmp( &current );
351 
352  updateView( m_placer->CurrentNode( true ), current );
353 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:166
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:292
virtual int Clearance(const ITEM *aA, const ITEM *aB) const =0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
virtual void EraseView()=0

References PNS::ITEM_SET::CItems(), PNS::RULE_RESOLVER::Clearance(), PNS::ROUTER_IFACE::DisplayItem(), PNS::LINE::EndsWithVia(), PNS::ROUTER_IFACE::EraseView(), GetRuleResolver(), PNS::ITEM::LINE_T, m_iface, m_placer, updateView(), and PNS::LINE::Via().

Referenced by Move().

◆ pickSingleItem()

ITEM* PNS::ROUTER::pickSingleItem ( ITEM_SET aItems) const
private

◆ Placer()

PLACEMENT_ALGO* PNS::ROUTER::Placer ( )
inline

Definition at line 219 of file pns_router.h.

219 { return m_placer.get(); }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259

References m_placer.

Referenced by LENGTH_TUNER_TOOL::meanderSettingsDialog(), LENGTH_TUNER_TOOL::performTuning(), and PNS_TUNE_STATUS_POPUP::UpdateStatus().

◆ QueryHoverItems()

const ITEM_SET PNS::ROUTER::QueryHoverItems ( const VECTOR2I aP)

Definition at line 117 of file pns_router.cpp.

118 {
119  if( m_state == IDLE || m_placer == nullptr )
120  return m_world->HitTest( aP );
121  else
122  return m_placer->CurrentNode()->HitTest( aP );
123 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254

References IDLE, m_placer, m_state, and m_world.

Referenced by isStartingPointRoutable(), and PNS::TOOL_BASE::pickSingleItem().

◆ QueryItemByParent()

ITEM* PNS::ROUTER::QueryItemByParent ( const BOARD_ITEM aItem) const

◆ RoutingInProgress()

bool PNS::ROUTER::RoutingInProgress ( ) const

◆ SetFailureReason()

void PNS::ROUTER::SetFailureReason ( const wxString &  aReason)
inline

◆ SetInterface()

void PNS::ROUTER::SetInterface ( ROUTER_IFACE aIface)

Definition at line 522 of file pns_router.cpp.

523 {
524  m_iface = aIface;
525  m_iface->SetRouter( this );
526 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
virtual void SetRouter(ROUTER *aRouter)=0

References m_iface, and PNS::ROUTER_IFACE::SetRouter().

Referenced by PNS::TOOL_BASE::Reset().

◆ SetIterLimit()

void PNS::ROUTER::SetIterLimit ( int  aX)
inline

Definition at line 178 of file pns_router.h.

178 { m_iterLimit = aX; }
int m_iterLimit
Definition: pns_router.h:265

References m_iterLimit.

◆ SetMode()

void PNS::ROUTER::SetMode ( ROUTER_MODE  aMode)

Definition at line 516 of file pns_router.cpp.

517 {
518  m_mode = aMode;
519 }
ROUTER_MODE m_mode
Definition: pns_router.h:273

References m_mode.

Referenced by ROUTER_TOOL::MainLoop(), and LENGTH_TUNER_TOOL::MainLoop().

◆ SetOrthoMode()

void PNS::ROUTER::SetOrthoMode ( bool  aEnable)

Definition at line 507 of file pns_router.cpp.

508 {
509  if( !m_placer )
510  return;
511 
512  m_placer->SetOrthoMode( aEnable );
513 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259

References m_placer.

Referenced by ROUTER_TOOL::performRouting().

◆ SetShowIntermediateSteps()

void PNS::ROUTER::SetShowIntermediateSteps ( bool  aX,
int  aSnapshotIter = -1 
)
inline

Definition at line 181 of file pns_router.h.

182  {
183  m_showInterSteps = aX;
184  m_snapshotIter = aSnapshotIter;
185  }
int m_snapshotIter
Definition: pns_router.h:267
bool m_showInterSteps
Definition: pns_router.h:266

References m_showInterSteps, and m_snapshotIter.

◆ Settings()

◆ SetView()

void PNS::ROUTER::SetView ( KIGFX::VIEW aView)

◆ Sizes()

◆ SnapToItem()

const VECTOR2I PNS::ROUTER::SnapToItem ( ITEM aItem,
VECTOR2I  aP,
bool &  aSplitsSegment 
)

◆ splitAdjacentSegments()

void PNS::ROUTER::splitAdjacentSegments ( NODE aNode,
ITEM aSeg,
const VECTOR2I aP 
)
private

◆ StartDragging()

bool PNS::ROUTER::StartDragging ( const VECTOR2I aP,
ITEM aItem,
int  aDragMode = DM_ANY 
)

Definition at line 126 of file pns_router.cpp.

127 {
128 
129  if( aDragMode & DM_FREE_ANGLE )
131  else
132  m_forceMarkObstaclesMode = false;
133 
134  if( !aStartItem || aStartItem->OfKind( ITEM::SOLID_T ) )
135  return false;
136 
137  m_placer = std::make_unique<LINE_PLACER>( this );
138  m_placer->Start( aP, aStartItem );
139 
140  m_dragger = std::make_unique<DRAGGER>( this );
141  m_dragger->SetMode( aDragMode );
142  m_dragger->SetWorld( m_world.get() );
143  m_dragger->SetDebugDecorator ( m_iface->GetDebugDecorator () );
144 
145  if( m_dragger->Start ( aP, aStartItem ) )
147  else
148  {
149  m_dragger.reset();
150  m_state = IDLE;
151  return false;
152  }
153 
154  return true;
155 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:260
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
bool m_forceMarkObstaclesMode
Definition: pns_router.h:269

References PNS::DM_FREE_ANGLE, DRAG_SEGMENT, PNS::ROUTER_IFACE::GetDebugDecorator(), IDLE, m_dragger, m_forceMarkObstaclesMode, m_iface, m_placer, m_state, m_world, PNS::ITEM::OfKind(), and PNS::ITEM::SOLID_T.

Referenced by ROUTER_TOOL::InlineDrag(), and ROUTER_TOOL::performDragging().

◆ StartRouting()

bool PNS::ROUTER::StartRouting ( const VECTOR2I aP,
ITEM aItem,
int  aLayer 
)

Definition at line 175 of file pns_router.cpp.

176 {
177 
178  if( ! isStartingPointRoutable( aP, aLayer ) )
179  {
180  SetFailureReason( _("Cannot start routing inside a keepout area or board outline." ) );
181  return false;
182  }
183 
184  m_forceMarkObstaclesMode = false;
185 
186  switch( m_mode )
187  {
189  m_placer = std::make_unique<LINE_PLACER>( this );
190  break;
192  m_placer = std::make_unique<DIFF_PAIR_PLACER>( this );
193  break;
195  m_placer = std::make_unique<MEANDER_PLACER>( this );
196  break;
198  m_placer = std::make_unique<DP_MEANDER_PLACER>( this );
199  break;
201  m_placer = std::make_unique<MEANDER_SKEW_PLACER>( this );
202  break;
203 
204  default:
205  return false;
206  }
207 
208  m_placer->UpdateSizes ( m_sizes );
209  m_placer->SetLayer( aLayer );
210  m_placer->SetDebugDecorator ( m_iface->GetDebugDecorator () );
211 
212  bool rv = m_placer->Start( aP, aStartItem );
213 
214  if( !rv )
215  return false;
216 
217  m_currentEnd = aP;
219  return rv;
220 }
bool isStartingPointRoutable(const VECTOR2I &aWhere, int aLayer)
Definition: pns_router.cpp:157
VECTOR2I m_currentEnd
Definition: pns_router.h:253
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:216
RouterState m_state
Definition: pns_router.h:254
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
#define _(s)
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
SIZES_SETTINGS m_sizes
Definition: pns_router.h:272
ROUTER_MODE m_mode
Definition: pns_router.h:273
bool m_forceMarkObstaclesMode
Definition: pns_router.h:269

References _, PNS::ROUTER_IFACE::GetDebugDecorator(), isStartingPointRoutable(), m_currentEnd, m_forceMarkObstaclesMode, m_iface, m_mode, m_placer, m_sizes, m_state, PNS::PNS_MODE_ROUTE_DIFF_PAIR, PNS::PNS_MODE_ROUTE_SINGLE, PNS::PNS_MODE_TUNE_DIFF_PAIR, PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW, PNS::PNS_MODE_TUNE_SINGLE, ROUTE_TRACK, and SetFailureReason().

Referenced by LENGTH_TUNER_TOOL::performTuning(), and ROUTER_TOOL::prepareInteractive().

◆ StopRouting()

void PNS::ROUTER::StopRouting ( )

Definition at line 398 of file pns_router.cpp.

399 {
400  // Update the ratsnest with new changes
401 
402  if( m_placer )
403  {
404  std::vector<int> nets;
405  m_placer->GetModifiedNets( nets );
406 
407  // Update the ratsnest with new changes
408  for ( auto n : nets )
409  m_iface->UpdateNet( n );
410  }
411 
412  if( !RoutingInProgress() )
413  return;
414 
415  m_placer.reset();
416  m_dragger.reset();
417 
418  m_iface->EraseView();
419 
420  m_state = IDLE;
421  m_world->KillChildren();
422  m_world->ClearRanks();
423 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
virtual void UpdateNet(int aNetCode)=0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:260
virtual void EraseView()=0
bool RoutingInProgress() const
Definition: pns_router.cpp:111

References PNS::ROUTER_IFACE::EraseView(), IDLE, m_dragger, m_iface, m_placer, m_state, m_world, RoutingInProgress(), and PNS::ROUTER_IFACE::UpdateNet().

Referenced by ROUTER_TOOL::finishInteractive(), FixRoute(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::performDragging(), and LENGTH_TUNER_TOOL::performTuning().

◆ SwitchLayer()

void PNS::ROUTER::SwitchLayer ( int  layer)

Definition at line 435 of file pns_router.cpp.

436 {
437  switch( m_state )
438  {
439  case ROUTE_TRACK:
440  m_placer->SetLayer( aLayer );
441  break;
442  default:
443  break;
444  }
445 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::MainLoop(), ROUTER_TOOL::performRouting(), and ROUTER_TOOL::switchLayerOnViaPlacement().

◆ syncPad()

ITEM* PNS::ROUTER::syncPad ( D_PAD aPad)
private

◆ syncTrack()

ITEM* PNS::ROUTER::syncTrack ( TRACK aTrack)
private

◆ syncVia()

ITEM* PNS::ROUTER::syncVia ( VIA aVia)
private

◆ SyncWorld()

void PNS::ROUTER::SyncWorld ( )

Definition at line 90 of file pns_router.cpp.

91 {
92  ClearWorld();
93 
94  m_world = std::make_unique<NODE>( );
95  m_iface->SyncWorld( m_world.get() );
96 
97 }
void ClearWorld()
Definition: pns_router.cpp:99
std::unique_ptr< NODE > m_world
Definition: pns_router.h:256
virtual void SyncWorld(NODE *aNode)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:263

References ClearWorld(), m_iface, m_world, and PNS::ROUTER_IFACE::SyncWorld().

Referenced by ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::MainLoop(), and PNS::TOOL_BASE::Reset().

◆ ToggleViaPlacement()

void PNS::ROUTER::ToggleViaPlacement ( )

Definition at line 448 of file pns_router.cpp.

449 {
450  if( m_state == ROUTE_TRACK )
451  {
452  bool toggle = !m_placer->IsPlacingVia();
453  m_placer->ToggleVia( toggle );
454  }
455 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::onViaCommand().

◆ UpdateSizes()

void PNS::ROUTER::UpdateSizes ( const SIZES_SETTINGS aSizes)

Applies stored settings.

See also
Settings()

Definition at line 317 of file pns_router.cpp.

318 {
319  m_sizes = aSizes;
320 
321  // Change track/via size settings
322  if( m_state == ROUTE_TRACK)
323  {
324  m_placer->UpdateSizes( m_sizes );
325  }
326 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:259
RouterState m_state
Definition: pns_router.h:254
SIZES_SETTINGS m_sizes
Definition: pns_router.h:272

References m_placer, m_sizes, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::DpDimensionsDialog(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), ROUTER_TOOL::prepareInteractive(), and PNS::TOOL_BASE::Reset().

◆ updateView()

void PNS::ROUTER::updateView ( NODE aNode,
ITEM_SET aCurrent,
bool  aDragging = false 
)
private

Definition at line 292 of file pns_router.cpp.

293 {
294  NODE::ITEM_VECTOR removed, added;
295  NODE::OBSTACLES obstacles;
296 
297  if( !aNode )
298  return;
299 
301  markViolations( aNode, aCurrent, removed );
302 
303  aNode->GetUpdatedItems( removed, added );
304 
305  for( auto item : added )
306  {
307  int clearance = GetRuleResolver()->Clearance( item->Net() );
308 
309  m_iface->DisplayItem( item, -1, clearance, aDragging );
310  }
311 
312  for( auto item : removed )
313  m_iface->HideItem( item );
314 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:166
virtual void HideItem(ITEM *aItem)=0
virtual int Clearance(const ITEM *aA, const ITEM *aB) const =0
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:263
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:145
ROUTER_MODE Mode() const
Definition: pns_router.h:127
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190
bool m_forceMarkObstaclesMode
Definition: pns_router.h:269
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:144
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:261

References PNS::RULE_RESOLVER::Clearance(), PNS::ROUTER_IFACE::DisplayItem(), GetRuleResolver(), PNS::NODE::GetUpdatedItems(), PNS::ROUTER_IFACE::HideItem(), m_forceMarkObstaclesMode, m_iface, markViolations(), Mode(), PNS::RM_MarkObstacles, and Settings().

Referenced by moveDragging(), and movePlacing().

Member Data Documentation

◆ m_currentEnd

VECTOR2I PNS::ROUTER::m_currentEnd
private

Definition at line 253 of file pns_router.h.

Referenced by Move(), and StartRouting().

◆ m_dragger

std::unique_ptr< DRAGGER > PNS::ROUTER::m_dragger
private

Definition at line 260 of file pns_router.h.

Referenced by DumpLog(), FixRoute(), moveDragging(), StartDragging(), and StopRouting().

◆ m_failureReason

wxString PNS::ROUTER::m_failureReason
private

Definition at line 276 of file pns_router.h.

Referenced by FailureReason(), and SetFailureReason().

◆ m_forceMarkObstaclesMode

bool PNS::ROUTER::m_forceMarkObstaclesMode = false
private

Definition at line 269 of file pns_router.h.

Referenced by StartDragging(), StartRouting(), and updateView().

◆ m_iface

◆ m_iterLimit

int PNS::ROUTER::m_iterLimit
private

Definition at line 265 of file pns_router.h.

Referenced by GetIterLimit(), ROUTER(), and SetIterLimit().

◆ m_lastNode

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 257 of file pns_router.h.

Referenced by ROUTER().

◆ m_mode

ROUTER_MODE PNS::ROUTER::m_mode
private

Definition at line 273 of file pns_router.h.

Referenced by Mode(), ROUTER(), SetMode(), and StartRouting().

◆ m_placer

◆ m_settings

ROUTING_SETTINGS PNS::ROUTER::m_settings
private

Definition at line 271 of file pns_router.h.

Referenced by LoadSettings(), and Settings().

◆ m_shove

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

Definition at line 261 of file pns_router.h.

◆ m_showInterSteps

bool PNS::ROUTER::m_showInterSteps
private

Definition at line 266 of file pns_router.h.

Referenced by GetShowIntermediateSteps(), ROUTER(), and SetShowIntermediateSteps().

◆ m_sizes

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

Definition at line 272 of file pns_router.h.

Referenced by Sizes(), StartRouting(), and UpdateSizes().

◆ m_snapshotIter

int PNS::ROUTER::m_snapshotIter
private

Definition at line 267 of file pns_router.h.

Referenced by GetShapshotIter(), ROUTER(), and SetShowIntermediateSteps().

◆ m_state

◆ m_toolStatusbarName

wxString PNS::ROUTER::m_toolStatusbarName
private

Definition at line 275 of file pns_router.h.

◆ m_violation

bool PNS::ROUTER::m_violation
private

Definition at line 268 of file pns_router.h.

Referenced by ROUTER().

◆ m_world

std::unique_ptr< NODE > PNS::ROUTER::m_world
private

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