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 UndoLastSegment ()
 
void CommitRouting ()
 
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)
 
void ToggleRounded ()
 
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)
 
bool StartDragging (const VECTOR2I &aP, ITEM_SET aItems, int aDragMode=DM_COMPONENT)
 
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 (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< DRAG_ALGOm_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_SETTINGSm_settings
 
SIZES_SETTINGS m_sizes
 
ROUTER_MODE m_mode
 
wxString m_toolStatusbarName
 
wxString m_failureReason
 

Detailed Description

Definition at line 115 of file pns_router.h.

Member Enumeration Documentation

◆ RouterState

Enumerator
IDLE 
DRAG_SEGMENT 
ROUTE_TRACK 

Definition at line 118 of file pns_router.h.

Constructor & Destructor Documentation

◆ ROUTER()

PNS::ROUTER::ROUTER ( )

Definition at line 65 of file pns_router.cpp.

66 {
67  theRouter = this;
68 
69  m_state = IDLE;
71 
72  // Initialize all other variables:
73  m_lastNode = nullptr;
74  m_iterLimit = 0;
75  m_settings = nullptr;
76  m_showInterSteps = false;
77  m_snapshotIter = 0;
78  m_violation = false;
79  m_iface = nullptr;
80 }
int m_snapshotIter
Definition: pns_router.h:276
int m_iterLimit
Definition: pns_router.h:274
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:280
bool m_showInterSteps
Definition: pns_router.h:275
NODE * m_lastNode
Definition: pns_router.h:266
RouterState m_state
Definition: pns_router.h:263
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
static ROUTER * theRouter
Definition: pns_router.cpp:63
bool m_violation
Definition: pns_router.h:277
ROUTER_MODE m_mode
Definition: pns_router.h:282

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

◆ ~ROUTER()

PNS::ROUTER::~ROUTER ( )

Definition at line 89 of file pns_router.cpp.

90 {
91  ClearWorld();
92  theRouter = nullptr;
93 }
void ClearWorld()
Definition: pns_router.cpp:105
static ROUTER * theRouter
Definition: pns_router.cpp:63

References ClearWorld(), and PNS::theRouter.

Member Function Documentation

◆ BreakSegment()

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

Definition at line 567 of file pns_router.cpp.

568 {
569  NODE *node = m_world->Branch();
570 
571  LINE_PLACER placer( this );
572 
573  if ( placer.SplitAdjacentSegments( node, aItem, aP ) )
574  {
575  CommitRouting( node );
576  }
577  else
578  {
579  delete node;
580  }
581 
582 }
void CommitRouting()
Definition: pns_router.cpp:422
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265

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 105 of file pns_router.cpp.

106 {
107  if( m_world )
108  {
109  m_world->KillChildren();
110  m_world.reset();
111  }
112 
113  m_placer.reset();
114 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268

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() [1/2]

◆ CommitRouting() [2/2]

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

Definition at line 371 of file pns_router.cpp.

372 {
373  if( m_state == ROUTE_TRACK && !m_placer->HasPlacedAnything() )
374  return;
375 
376  NODE::ITEM_VECTOR removed, added;
377 
378  aNode->GetUpdatedItems( removed, added );
379 
380  for( auto item : removed )
381  m_iface->RemoveItem( item );
382 
383  for( auto item : added )
384  m_iface->AddItem( item );
385 
386  m_iface->Commit();
387  m_world->Commit( aNode );
388 }
virtual void AddItem(ITEM *aItem)=0
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
virtual void Commit()=0
virtual void RemoveItem(ITEM *aItem)=0
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:149

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

◆ 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 239 of file pns_router.cpp.

240 {
241  for( const ITEM* item : aItems.CItems() )
242  m_iface->DisplayItem( item );
243 }
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:272

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

◆ DumpLog()

void PNS::ROUTER::DumpLog ( )

Definition at line 508 of file pns_router.cpp.

509 {
510  LOGGER* logger = nullptr;
511 
512  switch( m_state )
513  {
514  case DRAG_SEGMENT:
515  logger = m_dragger->Logger();
516  break;
517 
518  case ROUTE_TRACK:
519  logger = m_placer->Logger();
520  break;
521 
522  default:
523  break;
524  }
525 
526  if( logger )
527  logger->Save( "/tmp/shove.log" );
528 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:269
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263

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 226 of file pns_router.h.

226 { return m_failureReason; }
wxString m_failureReason
Definition: pns_router.h:285

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 391 of file pns_router.cpp.

392 {
393  bool rv = false;
394 
395  switch( m_state )
396  {
397  case ROUTE_TRACK:
398  rv = m_placer->FixRoute( aP, aEndItem, aForceFinish );
399  break;
400 
401  case DRAG_SEGMENT:
402  rv = m_dragger->FixRoute();
403  break;
404 
405  default:
406  break;
407  }
408 
409  return rv;
410 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:269
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263

References DRAG_SEGMENT, m_dragger, m_placer, m_state, and ROUTE_TRACK.

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

◆ FlipPosture()

void PNS::ROUTER::FlipPosture ( )

Definition at line 459 of file pns_router.cpp.

460 {
461  if( m_state == ROUTE_TRACK )
462  {
463  m_placer->FlipPosture();
464  }
465 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263

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 500 of file pns_router.cpp.

501 {
502  if( m_placer )
503  return m_placer->CurrentLayer();
504  return -1;
505 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268

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 491 of file pns_router.cpp.

492 {
493  if( m_placer )
494  return m_placer->CurrentNets();
495 
496  return std::vector<int>();
497 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268

References m_placer.

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

◆ GetInstance()

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

Definition at line 83 of file pns_router.cpp.

84 {
85  return theRouter;
86 }
static ROUTER * theRouter
Definition: pns_router.cpp:63

References PNS::theRouter.

Referenced by PNS::clipToLoopStart(), and PNS::OPTIMIZER::Optimize().

◆ GetInterface()

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

Definition at line 230 of file pns_router.h.

231  {
232  return m_iface;
233  }
ROUTER_IFACE * m_iface
Definition: pns_router.h:272

References m_iface.

Referenced by PNS::clipToLoopStart(), PNS::OPTIMIZER::Optimize(), and PNS::SHOVE::SHOVE().

◆ GetIterLimit()

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

Definition at line 188 of file pns_router.h.

188 { return m_iterLimit; };
int m_iterLimit
Definition: pns_router.h:274

References m_iterLimit.

◆ GetRuleResolver()

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

Definition at line 174 of file pns_router.h.

175  {
176  return m_iface->GetRuleResolver();
177  }
virtual RULE_RESOLVER * GetRuleResolver()=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:272

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

Referenced by movePlacing(), and updateView().

◆ GetShapshotIter()

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

Definition at line 197 of file pns_router.h.

197 { return m_snapshotIter; }
int m_snapshotIter
Definition: pns_router.h:276

References m_snapshotIter.

◆ GetShowIntermediateSteps()

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

Definition at line 196 of file pns_router.h.

196 { return m_showInterSteps; }
bool m_showInterSteps
Definition: pns_router.h:275

References m_showInterSteps.

◆ GetWorld()

◆ highlightCurrent()

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

◆ IsPlacingVia()

bool PNS::ROUTER::IsPlacingVia ( ) const

Definition at line 531 of file pns_router.cpp.

532 {
533  if( !m_placer )
534  return false;
535 
536  return m_placer->IsPlacingVia();
537 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268

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 173 of file pns_router.cpp.

174 {
175  if( Settings().CanViolateDRC() && Settings().Mode() == RM_MarkObstacles )
176  return true;
177 
178  auto candidates = QueryHoverItems( aWhere );
179 
180  for( ITEM* item : candidates.Items() )
181  {
182  if( ! item->IsRoutable() && item->Layers().Overlaps( aLayer ) )
183  {
184  return false;
185  }
186  }
187 
188  return true;
189 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:123
ROUTER_MODE Mode() const
Definition: pns_router.h:131
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:199

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

Referenced by StartRouting().

◆ LoadSettings()

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

Changes routing settings to ones passed in the parameter.

Parameters
aSettingsare the new settings.

Definition at line 213 of file pns_router.h.

214  {
215  m_settings = aSettings;
216  }
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:280

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 277 of file pns_router.cpp.

278 {
279  for( ITEM* item : aCurrent.Items() )
280  {
281  NODE::OBSTACLES obstacles;
282 
283  aNode->QueryColliding( item, obstacles, ITEM::ANY_T );
284 
285  if( item->OfKind( ITEM::LINE_T ) )
286  {
287  LINE* l = static_cast<LINE*>( item );
288 
289  if( l->EndsWithVia() )
290  {
291  VIA v( l->Via() );
292  aNode->QueryColliding( &v, obstacles, ITEM::ANY_T );
293  }
294  }
295 
296  for( OBSTACLE& obs : obstacles )
297  {
298  int clearance = aNode->GetClearance( item, obs.m_item );
299  std::unique_ptr<ITEM> tmp( obs.m_item->Clone() );
300  tmp->Mark( MK_VIOLATION );
301  m_iface->DisplayItem( tmp.get(), -1, clearance );
302  aRemoved.push_back( obs.m_item );
303  }
304  }
305 }
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
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:150

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 131 of file pns_router.h.

131 { return m_mode; }
ROUTER_MODE m_mode
Definition: pns_router.h:282

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 246 of file pns_router.cpp.

247 {
248  m_currentEnd = aP;
249 
250  switch( m_state )
251  {
252  case ROUTE_TRACK:
253  movePlacing( aP, endItem );
254  break;
255 
256  case DRAG_SEGMENT:
257  moveDragging( aP, endItem );
258  break;
259 
260  default:
261  break;
262  }
263 }
void moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:266
VECTOR2I m_currentEnd
Definition: pns_router.h:262
RouterState m_state
Definition: pns_router.h:263
void movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:344

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 266 of file pns_router.cpp.

267 {
268  m_iface->EraseView();
269 
270  m_dragger->Drag( aP );
271  ITEM_SET dragged = m_dragger->Traces();
272 
273  updateView( m_dragger->CurrentNode(), dragged, true );
274 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:269
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:308
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
std::unordered_set< SCH_ITEM * > ITEM_SET
Definition: sch_item.h:138
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 344 of file pns_router.cpp.

345 {
346  m_iface->EraseView();
347 
348  m_placer->Move( aP, aEndItem );
349  ITEM_SET current = m_placer->Traces();
350 
351  for( const ITEM* item : current.CItems() )
352  {
353  if( !item->OfKind( ITEM::LINE_T ) )
354  continue;
355 
356  const LINE* l = static_cast<const LINE*>( item );
357  int clearance = GetRuleResolver()->Clearance( item->Net() );
358 
359  m_iface->DisplayItem( l, -1, clearance );
360 
361  if( l->EndsWithVia() )
362  m_iface->DisplayItem( &l->Via(), -1, clearance );
363  }
364 
365  //ITEM_SET tmp( &current );
366 
367  updateView( m_placer->CurrentNode( true ), current );
368 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:174
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:308
virtual int Clearance(const ITEM *aA, const ITEM *aB) const =0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
std::unordered_set< SCH_ITEM * > ITEM_SET
Definition: sch_item.h:138
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 228 of file pns_router.h.

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

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 123 of file pns_router.cpp.

124 {
125  if( m_state == IDLE || m_placer == nullptr )
126  return m_world->HitTest( aP );
127  else
128  return m_placer->CurrentNode()->HitTest( aP );
129 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263

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 561 of file pns_router.cpp.

562 {
563  m_iface = aIface;
564  m_iface->SetRouter( this );
565 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
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 187 of file pns_router.h.

187 { m_iterLimit = aX; }
int m_iterLimit
Definition: pns_router.h:274

References m_iterLimit.

◆ SetMode()

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

Definition at line 555 of file pns_router.cpp.

556 {
557  m_mode = aMode;
558 }
ROUTER_MODE m_mode
Definition: pns_router.h:282

References m_mode.

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

◆ SetOrthoMode()

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

Definition at line 546 of file pns_router.cpp.

547 {
548  if( !m_placer )
549  return;
550 
551  m_placer->SetOrthoMode( aEnable );
552 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268

References m_placer.

Referenced by ROUTER_TOOL::performRouting().

◆ SetShowIntermediateSteps()

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

Definition at line 190 of file pns_router.h.

191  {
192  m_showInterSteps = aX;
193  m_snapshotIter = aSnapshotIter;
194  }
int m_snapshotIter
Definition: pns_router.h:276
bool m_showInterSteps
Definition: pns_router.h:275

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() [1/2]

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

Definition at line 131 of file pns_router.cpp.

132 {
133  return StartDragging( aP, ITEM_SET( aItem ), aDragMode );
134 }
std::unordered_set< SCH_ITEM * > ITEM_SET
Definition: sch_item.h:138
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:131

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

◆ StartDragging() [2/2]

bool PNS::ROUTER::StartDragging ( const VECTOR2I aP,
ITEM_SET  aItems,
int  aDragMode = DM_COMPONENT 
)

Definition at line 137 of file pns_router.cpp.

138 {
139  if( aStartItems.Empty() )
140  return false;
141 
142  if( aStartItems.Count( ITEM::SOLID_T ) == aStartItems.Size() )
143  {
144  m_dragger = std::make_unique<COMPONENT_DRAGGER>( this );
146  }
147  else
148  {
149  if( aDragMode & DM_FREE_ANGLE )
151  else
152  m_forceMarkObstaclesMode = false;
153 
154  m_dragger = std::make_unique<DRAGGER>( this );
155  }
156 
157  m_dragger->SetMode( aDragMode );
158  m_dragger->SetWorld( m_world.get() );
159  m_dragger->SetDebugDecorator ( m_iface->GetDebugDecorator () );
160 
161  if( m_dragger->Start ( aP, aStartItems ) )
163  else
164  {
165  m_dragger.reset();
166  m_state = IDLE;
167  return false;
168  }
169 
170  return true;
171 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:269
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265
RouterState m_state
Definition: pns_router.h:263
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
bool m_forceMarkObstaclesMode
Definition: pns_router.h:278

References PNS::ITEM_SET::Count(), PNS::DM_FREE_ANGLE, DRAG_SEGMENT, PNS::ITEM_SET::Empty(), PNS::ROUTER_IFACE::GetDebugDecorator(), IDLE, m_dragger, m_forceMarkObstaclesMode, m_iface, m_state, m_world, PNS::ITEM_SET::Size(), and PNS::ITEM::SOLID_T.

◆ StartRouting()

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

Definition at line 191 of file pns_router.cpp.

192 {
193 
194  if( ! isStartingPointRoutable( aP, aLayer ) )
195  {
196  SetFailureReason( _("Cannot start routing inside a keepout area or board outline." ) );
197  return false;
198  }
199 
200  m_forceMarkObstaclesMode = false;
201 
202  switch( m_mode )
203  {
205  m_placer = std::make_unique<LINE_PLACER>( this );
206  break;
208  m_placer = std::make_unique<DIFF_PAIR_PLACER>( this );
209  break;
211  m_placer = std::make_unique<MEANDER_PLACER>( this );
212  break;
214  m_placer = std::make_unique<DP_MEANDER_PLACER>( this );
215  break;
217  m_placer = std::make_unique<MEANDER_SKEW_PLACER>( this );
218  break;
219 
220  default:
221  return false;
222  }
223 
224  m_placer->UpdateSizes ( m_sizes );
225  m_placer->SetLayer( aLayer );
226  m_placer->SetDebugDecorator ( m_iface->GetDebugDecorator () );
227 
228  bool rv = m_placer->Start( aP, aStartItem );
229 
230  if( !rv )
231  return false;
232 
233  m_currentEnd = aP;
235  return rv;
236 }
bool isStartingPointRoutable(const VECTOR2I &aWhere, int aLayer)
Definition: pns_router.cpp:173
VECTOR2I m_currentEnd
Definition: pns_router.h:262
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:225
RouterState m_state
Definition: pns_router.h:263
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
#define _(s)
Definition: 3d_actions.cpp:33
SIZES_SETTINGS m_sizes
Definition: pns_router.h:281
ROUTER_MODE m_mode
Definition: pns_router.h:282
bool m_forceMarkObstaclesMode
Definition: pns_router.h:278

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 431 of file pns_router.cpp.

432 {
433  // Update the ratsnest with new changes
434 
435  if( m_placer )
436  {
437  std::vector<int> nets;
438  m_placer->GetModifiedNets( nets );
439 
440  // Update the ratsnest with new changes
441  for ( auto n : nets )
442  m_iface->UpdateNet( n );
443  }
444 
445  if( !RoutingInProgress() )
446  return;
447 
448  m_placer.reset();
449  m_dragger.reset();
450 
451  m_iface->EraseView();
452 
453  m_state = IDLE;
454  m_world->KillChildren();
455  m_world->ClearRanks();
456 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:269
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265
virtual void UpdateNet(int aNetCode)=0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263
ROUTER_IFACE * m_iface
Definition: pns_router.h:272
virtual void EraseView()=0
bool RoutingInProgress() const
Definition: pns_router.cpp:117

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

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

◆ SwitchLayer()

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

Definition at line 468 of file pns_router.cpp.

469 {
470  switch( m_state )
471  {
472  case ROUTE_TRACK:
473  m_placer->SetLayer( aLayer );
474  break;
475  default:
476  break;
477  }
478 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263

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 96 of file pns_router.cpp.

97 {
98  ClearWorld();
99 
100  m_world = std::make_unique<NODE>( );
101  m_iface->SyncWorld( m_world.get() );
102 
103 }
void ClearWorld()
Definition: pns_router.cpp:105
std::unique_ptr< NODE > m_world
Definition: pns_router.h:265
virtual void SyncWorld(NODE *aNode)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:272

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().

◆ ToggleRounded()

void PNS::ROUTER::ToggleRounded ( )

Definition at line 540 of file pns_router.cpp.

541 {
543 }
void SetRounded(bool aRound)
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:280

References PNS::ROUTING_SETTINGS::GetRounded(), m_settings, and PNS::ROUTING_SETTINGS::SetRounded().

Referenced by ROUTER_TOOL::performRouting().

◆ ToggleViaPlacement()

void PNS::ROUTER::ToggleViaPlacement ( )

Definition at line 481 of file pns_router.cpp.

482 {
483  if( m_state == ROUTE_TRACK )
484  {
485  bool toggle = !m_placer->IsPlacingVia();
486  m_placer->ToggleVia( toggle );
487  }
488 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::onViaCommand().

◆ UndoLastSegment()

void PNS::ROUTER::UndoLastSegment ( )

Definition at line 413 of file pns_router.cpp.

414 {
415  if( !RoutingInProgress() )
416  return;
417 
418  m_placer->UnfixRoute();
419 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
bool RoutingInProgress() const
Definition: pns_router.cpp:117

References m_placer, and RoutingInProgress().

Referenced by ROUTER_TOOL::performRouting().

◆ UpdateSizes()

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

Applies stored settings.

See also
Settings()

Definition at line 332 of file pns_router.cpp.

333 {
334  m_sizes = aSizes;
335 
336  // Change track/via size settings
337  if( m_state == ROUTE_TRACK)
338  {
339  m_placer->UpdateSizes( m_sizes );
340  }
341 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:268
RouterState m_state
Definition: pns_router.h:263
SIZES_SETTINGS m_sizes
Definition: pns_router.h:281

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 308 of file pns_router.cpp.

309 {
310  NODE::ITEM_VECTOR removed, added;
311  NODE::OBSTACLES obstacles;
312 
313  if( !aNode )
314  return;
315 
317  markViolations( aNode, aCurrent, removed );
318 
319  aNode->GetUpdatedItems( removed, added );
320 
321  for( auto item : added )
322  {
323  int clearance = GetRuleResolver()->Clearance( item->Net() );
324  m_iface->DisplayItem( item, -1, clearance, aDragging );
325  }
326 
327  for( auto item : removed )
328  m_iface->HideItem( item );
329 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:174
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:272
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:150
ROUTER_MODE Mode() const
Definition: pns_router.h:131
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:199
bool m_forceMarkObstaclesMode
Definition: pns_router.h:278
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:149
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:277

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 262 of file pns_router.h.

Referenced by Move(), and StartRouting().

◆ m_dragger

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

Definition at line 269 of file pns_router.h.

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

◆ m_failureReason

wxString PNS::ROUTER::m_failureReason
private

Definition at line 285 of file pns_router.h.

Referenced by FailureReason(), and SetFailureReason().

◆ m_forceMarkObstaclesMode

bool PNS::ROUTER::m_forceMarkObstaclesMode = false
private

Definition at line 278 of file pns_router.h.

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

◆ m_iface

◆ m_iterLimit

int PNS::ROUTER::m_iterLimit
private

Definition at line 274 of file pns_router.h.

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

◆ m_lastNode

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 266 of file pns_router.h.

Referenced by ROUTER().

◆ m_mode

ROUTER_MODE PNS::ROUTER::m_mode
private

Definition at line 282 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 280 of file pns_router.h.

Referenced by LoadSettings(), ROUTER(), Settings(), and ToggleRounded().

◆ m_shove

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

Definition at line 270 of file pns_router.h.

◆ m_showInterSteps

bool PNS::ROUTER::m_showInterSteps
private

Definition at line 275 of file pns_router.h.

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

◆ m_sizes

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

Definition at line 281 of file pns_router.h.

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

◆ m_snapshotIter

int PNS::ROUTER::m_snapshotIter
private

Definition at line 276 of file pns_router.h.

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

◆ m_state

◆ m_toolStatusbarName

wxString PNS::ROUTER::m_toolStatusbarName
private

Definition at line 284 of file pns_router.h.

◆ m_violation

bool PNS::ROUTER::m_violation
private

Definition at line 277 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: