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 ()
 
NODEGetWorld () const
 
void FlipPosture ()
 
void SwitchLayer (int layer)
 
void ToggleViaPlacement ()
 
void SetOrthoMode (bool aEnable)
 
void ToggleRounded ()
 
int GetCurrentLayer () const
 
const std::vector< int > GetCurrentNets () const
 
void DumpLog ()
 
LOGGERLogger ()
 
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 (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, ITEM *aItem, 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
 
LOGGERm_logger
 
wxString m_toolStatusbarName
 
wxString m_failureReason
 

Detailed Description

Definition at line 120 of file pns_router.h.

Member Enumeration Documentation

◆ RouterState

Enumerator
IDLE 
DRAG_SEGMENT 
ROUTE_TRACK 

Definition at line 123 of file pns_router.h.

Constructor & Destructor Documentation

◆ ROUTER()

PNS::ROUTER::ROUTER ( )

Definition at line 59 of file pns_router.cpp.

60 {
61  theRouter = this;
62 
63  m_state = IDLE;
65 
66  m_logger = new LOGGER;
67 
68  // Initialize all other variables:
69  m_lastNode = nullptr;
70  m_iterLimit = 0;
71  m_settings = nullptr;
72  m_showInterSteps = false;
73  m_snapshotIter = 0;
74  m_violation = false;
75  m_iface = nullptr;
76 }
int m_snapshotIter
Definition: pns_router.h:277
int m_iterLimit
Definition: pns_router.h:275
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:281
bool m_showInterSteps
Definition: pns_router.h:276
NODE * m_lastNode
Definition: pns_router.h:267
RouterState m_state
Definition: pns_router.h:264
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
LOGGER * m_logger
Definition: pns_router.h:284
static ROUTER * theRouter
Definition: pns_router.cpp:57
bool m_violation
Definition: pns_router.h:278
ROUTER_MODE m_mode
Definition: pns_router.h:283

References IDLE, m_iface, m_iterLimit, m_lastNode, m_logger, 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 85 of file pns_router.cpp.

86 {
87  ClearWorld();
88  theRouter = nullptr;
89  delete m_logger;
90 }
void ClearWorld()
Definition: pns_router.cpp:102
LOGGER * m_logger
Definition: pns_router.h:284
static ROUTER * theRouter
Definition: pns_router.cpp:57

References ClearWorld(), m_logger, and PNS::theRouter.

Member Function Documentation

◆ BreakSegment()

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

Definition at line 572 of file pns_router.cpp.

573 {
574  NODE *node = m_world->Branch();
575 
576  LINE_PLACER placer( this );
577 
578  if ( placer.SplitAdjacentSegments( node, aItem, aP ) )
579  {
580  CommitRouting( node );
581  }
582  else
583  {
584  delete node;
585  }
586 
587 }
void CommitRouting()
Definition: pns_router.cpp:440
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266

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

103 {
104  if( m_world )
105  {
106  m_world->KillChildren();
107  m_world.reset();
108  }
109 
110  m_placer.reset();
111 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269

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

385 {
386  if( m_state == ROUTE_TRACK && !m_placer->HasPlacedAnything() )
387  return;
388 
389  NODE::ITEM_VECTOR removed, added;
390 
391  aNode->GetUpdatedItems( removed, added );
392 
393  for( auto item : removed )
394  m_iface->RemoveItem( item );
395 
396  for( auto item : added )
397  m_iface->AddItem( item );
398 
399  m_iface->Commit();
400  m_world->Commit( aNode );
401 }
virtual void AddItem(ITEM *aItem)=0
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
virtual void Commit()=0
virtual void RemoveItem(ITEM *aItem)=0
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:173

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

◆ DumpLog()

void PNS::ROUTER::DumpLog ( )

◆ eraseView()

void PNS::ROUTER::eraseView ( )
private

◆ FailureReason()

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

Definition at line 227 of file pns_router.h.

227 { return m_failureReason; }
wxString m_failureReason
Definition: pns_router.h:287

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

405 {
406  bool rv = false;
407 
408  if( m_logger )
409  {
410  m_logger->Log( LOGGER::EVT_FIX, aP, aEndItem );
411  }
412 
413  switch( m_state )
414  {
415  case ROUTE_TRACK:
416  rv = m_placer->FixRoute( aP, aEndItem, aForceFinish );
417  break;
418 
419  case DRAG_SEGMENT:
420  rv = m_dragger->FixRoute();
421  break;
422 
423  default:
424  break;
425  }
426 
427  return rv;
428 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:270
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264
LOGGER * m_logger
Definition: pns_router.h:284
void Log(EVENT_TYPE evt, VECTOR2I pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:73

References DRAG_SEGMENT, PNS::LOGGER::EVT_FIX, PNS::LOGGER::Log(), m_dragger, m_logger, 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 477 of file pns_router.cpp.

478 {
479  if( m_state == ROUTE_TRACK )
480  {
481  m_placer->FlipPosture();
482  }
483 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::performRouting().

◆ GetCurrentLayer()

int PNS::ROUTER::GetCurrentLayer ( ) const

Definition at line 520 of file pns_router.cpp.

521 {
522  if( m_placer )
523  return m_placer->CurrentLayer();
524  else if( m_dragger )
525  return m_dragger->CurrentLayer();
526 
527  return -1;
528 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:270
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269

References m_dragger, and 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 509 of file pns_router.cpp.

510 {
511  if( m_placer )
512  return m_placer->CurrentNets();
513  else if( m_dragger )
514  return m_dragger->CurrentNets();
515 
516  return std::vector<int>();
517 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:270
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269

References m_dragger, and m_placer.

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

◆ GetInstance()

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

◆ GetInterface()

◆ GetIterLimit()

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

Definition at line 189 of file pns_router.h.

189 { return m_iterLimit; };
int m_iterLimit
Definition: pns_router.h:275

References m_iterLimit.

◆ GetRuleResolver()

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

Definition at line 175 of file pns_router.h.

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

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

Referenced by movePlacing(), and updateView().

◆ GetShapshotIter()

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

Definition at line 198 of file pns_router.h.

198 { return m_snapshotIter; }
int m_snapshotIter
Definition: pns_router.h:277

References m_snapshotIter.

◆ GetShowIntermediateSteps()

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

Definition at line 197 of file pns_router.h.

197 { return m_showInterSteps; }
bool m_showInterSteps
Definition: pns_router.h:276

References m_showInterSteps.

◆ GetWorld()

NODE* PNS::ROUTER::GetWorld ( ) const
inline

◆ highlightCurrent()

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

◆ IsPlacingVia()

bool PNS::ROUTER::IsPlacingVia ( ) const

Definition at line 537 of file pns_router.cpp.

538 {
539  if( !m_placer )
540  return false;
541 
542  return m_placer->IsPlacingVia();
543 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269

References m_placer.

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

◆ isStartingPointRoutable()

bool PNS::ROUTER::isStartingPointRoutable ( const VECTOR2I aWhere,
ITEM aItem,
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  ITEM_SET candidates = QueryHoverItems( aWhere );
179 
180  for( ITEM* item : candidates.Items() )
181  {
182  if( !item->IsRoutable() && item->Layers().Overlaps( aLayer ) )
183  return false;
184  }
185 
186  if( m_mode == PNS_MODE_ROUTE_SINGLE && aStartItem )
187  {
188  VECTOR2I startPoint = aStartItem->Anchor( 0 );
189  SEGMENT dummyStartSeg( SEG( startPoint, startPoint ), aStartItem->Net() );
190 
191  dummyStartSeg.SetWidth( m_sizes.TrackWidth() );
192  dummyStartSeg.SetLayer( aLayer );
193 
194  if( m_world->CheckColliding( &dummyStartSeg, ITEM::ANY_T ) )
195  return false;
196  }
197  else if( m_mode == PNS_MODE_ROUTE_DIFF_PAIR && aStartItem )
198  {
199  // TODO
200  }
201 
202  return true;
203 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:120
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
Definition: seg.h:39
SIZES_SETTINGS m_sizes
Definition: pns_router.h:282
ROUTER_MODE m_mode
Definition: pns_router.h:283
ROUTER_MODE Mode() const
Definition: pns_router.h:136
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:200

References PNS::ITEM::Anchor(), PNS::ITEM::ANY_T, PNS::ITEM_SET::Items(), m_mode, m_sizes, m_world, Mode(), PNS::ITEM::Net(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, PNS::PNS_MODE_ROUTE_SINGLE, QueryHoverItems(), PNS::RM_MarkObstacles, Settings(), PNS::SEGMENT::SetWidth(), and PNS::SIZES_SETTINGS::TrackWidth().

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

215  {
216  m_settings = aSettings;
217  }
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:281

References m_settings.

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

◆ Logger()

LOGGER * PNS::ROUTER::Logger ( )

Definition at line 531 of file pns_router.cpp.

532 {
533  return m_logger;
534 }
LOGGER * m_logger
Definition: pns_router.h:284

References m_logger.

Referenced by ROUTER_TOOL::handleCommonEvents().

◆ markViolations()

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

Definition at line 290 of file pns_router.cpp.

291 {
292  for( ITEM* item : aCurrent.Items() )
293  {
294  NODE::OBSTACLES obstacles;
295 
296  aNode->QueryColliding( item, obstacles, ITEM::ANY_T );
297 
298  if( item->OfKind( ITEM::LINE_T ) )
299  {
300  LINE* l = static_cast<LINE*>( item );
301 
302  if( l->EndsWithVia() )
303  {
304  VIA v( l->Via() );
305  aNode->QueryColliding( &v, obstacles, ITEM::ANY_T );
306  }
307  }
308 
309  for( OBSTACLE& obs : obstacles )
310  {
311  int clearance = aNode->GetClearance( item, obs.m_item );
312  std::unique_ptr<ITEM> tmp( obs.m_item->Clone() );
313  tmp->Mark( tmp->Marker() | MK_VIOLATION );
314  m_iface->DisplayItem( tmp.get(), -1, clearance );
315  aRemoved.push_back( obs.m_item );
316  }
317  }
318 }
Definition: track.h:354
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:174

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

136 { return m_mode; }
ROUTER_MODE m_mode
Definition: pns_router.h:283

References m_mode.

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

◆ Move()

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

Definition at line 256 of file pns_router.cpp.

257 {
258  m_currentEnd = aP;
259 
260  if( m_logger )
261  m_logger->Log( LOGGER::EVT_MOVE, aP, endItem );
262 
263  switch( m_state )
264  {
265  case ROUTE_TRACK:
266  movePlacing( aP, endItem );
267  break;
268 
269  case DRAG_SEGMENT:
270  moveDragging( aP, endItem );
271  break;
272 
273  default:
274  break;
275  }
276 }
void moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:279
VECTOR2I m_currentEnd
Definition: pns_router.h:263
RouterState m_state
Definition: pns_router.h:264
void movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:357
LOGGER * m_logger
Definition: pns_router.h:284
void Log(EVENT_TYPE evt, VECTOR2I pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:73

References DRAG_SEGMENT, PNS::LOGGER::EVT_MOVE, PNS::LOGGER::Log(), m_currentEnd, m_logger, 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 279 of file pns_router.cpp.

280 {
281  m_iface->EraseView();
282 
283  m_dragger->Drag( aP );
284  ITEM_SET dragged = m_dragger->Traces();
285 
286  updateView( m_dragger->CurrentNode(), dragged, true );
287 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:270
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:321
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
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 357 of file pns_router.cpp.

358 {
359  m_iface->EraseView();
360 
361  m_placer->Move( aP, aEndItem );
362  ITEM_SET current = m_placer->Traces();
363 
364  for( const ITEM* item : current.CItems() )
365  {
366  if( !item->OfKind( ITEM::LINE_T ) )
367  continue;
368 
369  const LINE* l = static_cast<const LINE*>( item );
370  int clearance = GetRuleResolver()->Clearance( item, nullptr );
371 
372  m_iface->DisplayItem( l, -1, clearance );
373 
374  if( l->EndsWithVia() )
375  m_iface->DisplayItem( &l->Via(), -1, clearance );
376  }
377 
378  //ITEM_SET tmp( &current );
379 
380  updateView( m_placer->CurrentNode( true ), current );
381 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:175
virtual int Clearance(const ITEM *aA, const ITEM *aB)=0
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:321
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
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 229 of file pns_router.h.

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

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

121 {
122  if( m_state == IDLE || m_placer == nullptr )
123  return m_world->HitTest( aP );
124  else
125  return m_placer->CurrentNode()->HitTest( aP );
126 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264

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

568 {
569  m_iface = aIface;
570 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:273

References m_iface.

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

◆ SetIterLimit()

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

Definition at line 188 of file pns_router.h.

188 { m_iterLimit = aX; }
int m_iterLimit
Definition: pns_router.h:275

References m_iterLimit.

◆ SetMode()

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

Definition at line 561 of file pns_router.cpp.

562 {
563  m_mode = aMode;
564 }
ROUTER_MODE m_mode
Definition: pns_router.h:283

References m_mode.

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

◆ SetOrthoMode()

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

Definition at line 552 of file pns_router.cpp.

553 {
554  if( !m_placer )
555  return;
556 
557  m_placer->SetOrthoMode( aEnable );
558 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269

References m_placer.

Referenced by ROUTER_TOOL::performRouting().

◆ SetShowIntermediateSteps()

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

Definition at line 191 of file pns_router.h.

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

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

129 {
130  return StartDragging( aP, ITEM_SET( aItem ), aDragMode );
131 }
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:128

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

135 {
136  if( aStartItems.Empty() )
137  return false;
138 
139  if( aStartItems.Count( ITEM::SOLID_T ) == aStartItems.Size() )
140  {
141  m_dragger = std::make_unique<COMPONENT_DRAGGER>( this );
143  }
144  else
145  {
146  if( aDragMode & DM_FREE_ANGLE )
148  else
149  m_forceMarkObstaclesMode = false;
150 
151  m_dragger = std::make_unique<DRAGGER>( this );
152  }
153 
154  m_dragger->SetMode( aDragMode );
155  m_dragger->SetWorld( m_world.get() );
156  m_dragger->SetLogger( m_logger );
157  m_dragger->SetDebugDecorator ( m_iface->GetDebugDecorator () );
158 
159  if( m_dragger->Start ( aP, aStartItems ) )
160  {
162  }
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:270
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
RouterState m_state
Definition: pns_router.h:264
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
LOGGER * m_logger
Definition: pns_router.h:284
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
bool m_forceMarkObstaclesMode
Definition: pns_router.h:279

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_logger, 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 205 of file pns_router.cpp.

206 {
207  if( ! isStartingPointRoutable( aP, aStartItem, aLayer ) )
208  {
209  SetFailureReason( _( "The routing start point violates DRC." ) );
210  return false;
211  }
212 
213  m_forceMarkObstaclesMode = false;
214 
215  switch( m_mode )
216  {
218  m_placer = std::make_unique<LINE_PLACER>( this );
219  break;
221  m_placer = std::make_unique<DIFF_PAIR_PLACER>( this );
222  break;
224  m_placer = std::make_unique<MEANDER_PLACER>( this );
225  break;
227  m_placer = std::make_unique<DP_MEANDER_PLACER>( this );
228  break;
230  m_placer = std::make_unique<MEANDER_SKEW_PLACER>( this );
231  break;
232 
233  default:
234  return false;
235  }
236 
237  m_placer->UpdateSizes( m_sizes );
238  m_placer->SetLayer( aLayer );
239  m_placer->SetDebugDecorator( m_iface->GetDebugDecorator () );
240  m_placer->SetLogger( m_logger );
241 
242  if( m_logger )
243  m_logger->Log( LOGGER::EVT_START_ROUTE, aP, aStartItem );
244 
245  bool rv = m_placer->Start( aP, aStartItem );
246 
247  if( !rv )
248  return false;
249 
250  m_currentEnd = aP;
252  return rv;
253 }
bool isStartingPointRoutable(const VECTOR2I &aWhere, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:173
VECTOR2I m_currentEnd
Definition: pns_router.h:263
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:226
RouterState m_state
Definition: pns_router.h:264
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
LOGGER * m_logger
Definition: pns_router.h:284
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
#define _(s)
Definition: 3d_actions.cpp:33
SIZES_SETTINGS m_sizes
Definition: pns_router.h:282
ROUTER_MODE m_mode
Definition: pns_router.h:283
void Log(EVENT_TYPE evt, VECTOR2I pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:73
bool m_forceMarkObstaclesMode
Definition: pns_router.h:279

References _, PNS::LOGGER::EVT_START_ROUTE, PNS::ROUTER_IFACE::GetDebugDecorator(), isStartingPointRoutable(), PNS::LOGGER::Log(), m_currentEnd, m_forceMarkObstaclesMode, m_iface, m_logger, 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 449 of file pns_router.cpp.

450 {
451  // Update the ratsnest with new changes
452 
453  if( m_placer )
454  {
455  std::vector<int> nets;
456  m_placer->GetModifiedNets( nets );
457 
458  // Update the ratsnest with new changes
459  for ( auto n : nets )
460  m_iface->UpdateNet( n );
461  }
462 
463  if( !RoutingInProgress() )
464  return;
465 
466  m_placer.reset();
467  m_dragger.reset();
468 
469  m_iface->EraseView();
470 
471  m_state = IDLE;
472  m_world->KillChildren();
473  m_world->ClearRanks();
474 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:270
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
virtual void UpdateNet(int aNetCode)=0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264
ROUTER_IFACE * m_iface
Definition: pns_router.h:273
virtual void EraseView()=0
bool RoutingInProgress() const
Definition: pns_router.cpp:114

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

487 {
488  switch( m_state )
489  {
490  case ROUTE_TRACK:
491  m_placer->SetLayer( aLayer );
492  break;
493  default:
494  break;
495  }
496 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264

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

94 {
95  ClearWorld();
96 
97  m_world = std::make_unique<NODE>( );
98  m_iface->SyncWorld( m_world.get() );
99 
100 }
void ClearWorld()
Definition: pns_router.cpp:102
std::unique_ptr< NODE > m_world
Definition: pns_router.h:266
virtual void SyncWorld(NODE *aNode)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:273

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

547 {
549 }
void SetRounded(bool aRound)
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:281

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

500 {
501  if( m_state == ROUTE_TRACK )
502  {
503  bool toggle = !m_placer->IsPlacingVia();
504  m_placer->ToggleVia( toggle );
505  }
506 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::onViaCommand().

◆ UndoLastSegment()

void PNS::ROUTER::UndoLastSegment ( )

Definition at line 431 of file pns_router.cpp.

432 {
433  if( !RoutingInProgress() )
434  return;
435 
436  m_placer->UnfixRoute();
437 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
bool RoutingInProgress() const
Definition: pns_router.cpp:114

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

346 {
347  m_sizes = aSizes;
348 
349  // Change track/via size settings
350  if( m_state == ROUTE_TRACK)
351  {
352  m_placer->UpdateSizes( m_sizes );
353  }
354 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:269
RouterState m_state
Definition: pns_router.h:264
SIZES_SETTINGS m_sizes
Definition: pns_router.h:282

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

322 {
323  NODE::ITEM_VECTOR removed, added;
324  NODE::OBSTACLES obstacles;
325 
326  if( !aNode )
327  return;
328 
330  markViolations( aNode, aCurrent, removed );
331 
332  aNode->GetUpdatedItems( removed, added );
333 
334  for( auto item : added )
335  {
336  int clearance = GetRuleResolver()->Clearance( item, nullptr );
337  m_iface->DisplayItem( item, -1, clearance, aDragging );
338  }
339 
340  for( auto item : removed )
341  m_iface->HideItem( item );
342 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:175
virtual void HideItem(ITEM *aItem)=0
virtual int Clearance(const ITEM *aA, const ITEM *aB)=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:273
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:174
ROUTER_MODE Mode() const
Definition: pns_router.h:136
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:200
bool m_forceMarkObstaclesMode
Definition: pns_router.h:279
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:173
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:290

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

Referenced by Move(), and StartRouting().

◆ m_dragger

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

◆ m_failureReason

wxString PNS::ROUTER::m_failureReason
private

Definition at line 287 of file pns_router.h.

Referenced by FailureReason(), and SetFailureReason().

◆ m_forceMarkObstaclesMode

bool PNS::ROUTER::m_forceMarkObstaclesMode = false
private

Definition at line 279 of file pns_router.h.

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

◆ m_iface

◆ m_iterLimit

int PNS::ROUTER::m_iterLimit
private

Definition at line 275 of file pns_router.h.

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

◆ m_lastNode

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 267 of file pns_router.h.

Referenced by ROUTER().

◆ m_logger

LOGGER* PNS::ROUTER::m_logger
private

Definition at line 284 of file pns_router.h.

Referenced by FixRoute(), Logger(), Move(), ROUTER(), StartDragging(), StartRouting(), and ~ROUTER().

◆ m_mode

ROUTER_MODE PNS::ROUTER::m_mode
private

Definition at line 283 of file pns_router.h.

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

◆ m_placer

◆ m_settings

ROUTING_SETTINGS* PNS::ROUTER::m_settings
private

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

◆ m_showInterSteps

bool PNS::ROUTER::m_showInterSteps
private

Definition at line 276 of file pns_router.h.

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

◆ m_sizes

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

Definition at line 282 of file pns_router.h.

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

◆ m_snapshotIter

int PNS::ROUTER::m_snapshotIter
private

Definition at line 277 of file pns_router.h.

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

◆ m_state

◆ m_toolStatusbarName

wxString PNS::ROUTER::m_toolStatusbarName
private

Definition at line 286 of file pns_router.h.

◆ m_violation

bool PNS::ROUTER::m_violation
private

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