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

Member Enumeration Documentation

Enumerator
IDLE 
DRAG_SEGMENT 
ROUTE_TRACK 

Definition at line 111 of file pns_router.h.

Constructor & Destructor Documentation

PNS::ROUTER::ROUTER ( )

Definition at line 61 of file pns_router.cpp.

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

62 {
63  theRouter = this;
64 
65  m_state = IDLE;
67 
68  // Initialize all other variables:
69  m_lastNode = nullptr;
70  m_iterLimit = 0;
71  m_showInterSteps = false;
72  m_snapshotIter = 0;
73  m_violation = false;
74  m_iface = nullptr;
75 }
int m_snapshotIter
Definition: pns_router.h:264
int m_iterLimit
Definition: pns_router.h:262
bool m_showInterSteps
Definition: pns_router.h:263
NODE * m_lastNode
Definition: pns_router.h:254
RouterState m_state
Definition: pns_router.h:251
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
static ROUTER * theRouter
Definition: pns_router.cpp:59
bool m_violation
Definition: pns_router.h:265
ROUTER_MODE m_mode
Definition: pns_router.h:270
PNS::ROUTER::~ROUTER ( )

Definition at line 84 of file pns_router.cpp.

References ClearWorld().

85 {
86  ClearWorld();
87  theRouter = nullptr;
88 }
void ClearWorld()
Definition: pns_router.cpp:100
static ROUTER * theRouter
Definition: pns_router.cpp:59

Member Function Documentation

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

Definition at line 519 of file pns_router.cpp.

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

Referenced by ROUTER_TOOL::breakTrack().

520 {
521  NODE *node = m_world->Branch();
522 
523  LINE_PLACER placer( this );
524 
525  if ( placer.SplitAdjacentSegments( node, aItem, aP ) )
526  {
527  CommitRouting( node );
528  }
529  else
530  {
531  delete node;
532  }
533 
534 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:347
void PNS::ROUTER::clearViewFlags ( )
private
void PNS::ROUTER::ClearWorld ( )

Definition at line 100 of file pns_router.cpp.

References m_placer, and m_world.

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

101 {
102  if( m_world )
103  {
104  m_world->KillChildren();
105  m_world.reset();
106  }
107 
108  m_placer.reset();
109 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
void PNS::ROUTER::commitPad ( SOLID aPad)
private
void PNS::ROUTER::CommitRouting ( NODE aNode)

Definition at line 347 of file pns_router.cpp.

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::DRAGGER::FixRoute(), PNS::DP_MEANDER_PLACER::FixRoute(), PNS::LINE_PLACER::FixRoute(), and PNS::DIFF_PAIR_PLACER::FixRoute().

348 {
349  NODE::ITEM_VECTOR removed, added;
350 
351  aNode->GetUpdatedItems( removed, added );
352 
353  for( auto item : removed )
354  m_iface->RemoveItem( item );
355 
356  for( auto item : added )
357  m_iface->AddItem( item );
358 
359  m_iface->Commit();
360  m_world->Commit( aNode );
361 }
virtual void AddItem(ITEM *aItem)=0
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
virtual void Commit()=0
virtual void RemoveItem(ITEM *aItem)=0
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:141
void PNS::ROUTER::commitSegment ( SEGMENT aTrack)
private
void PNS::ROUTER::commitVia ( VIA aVia)
private
void PNS::ROUTER::DeleteTraces ( ITEM aStartItem,
bool  aWholeTrack 
)
void PNS::ROUTER::DisplayItem ( const ITEM aItem,
int  aColor = -1,
int  aClearance = -1 
)
void PNS::ROUTER::DisplayItems ( const ITEM_SET aItems)

Definition at line 218 of file pns_router.cpp.

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

219 {
220  for( const ITEM* item : aItems.CItems() )
221  m_iface->DisplayItem( item );
222 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1)=0
void PNS::ROUTER::DumpLog ( )

Definition at line 466 of file pns_router.cpp.

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

Referenced by ROUTER_TOOL::handleCommonEvents().

467 {
468  LOGGER* logger = nullptr;
469 
470  switch( m_state )
471  {
472  case DRAG_SEGMENT:
473  logger = m_dragger->Logger();
474  break;
475 
476  case ROUTE_TRACK:
477  logger = m_placer->Logger();
478  break;
479 
480  default:
481  break;
482  }
483 
484  if( logger )
485  logger->Save( "/tmp/shove.log" );
486 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:257
void PNS::ROUTER::eraseView ( )
private
const wxString& PNS::ROUTER::FailureReason ( ) const
inline

Definition at line 214 of file pns_router.h.

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

214 { return m_failureReason; }
wxString m_failureReason
Definition: pns_router.h:273
bool PNS::ROUTER::FixRoute ( const VECTOR2I aP,
ITEM aItem 
)

Definition at line 364 of file pns_router.cpp.

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

365 {
366  bool rv = false;
367 
368  switch( m_state )
369  {
370  case ROUTE_TRACK:
371  rv = m_placer->FixRoute( aP, aEndItem );
372  break;
373 
374  case DRAG_SEGMENT:
375  rv = m_dragger->FixRoute();
376  break;
377 
378  default:
379  break;
380  }
381 
382  if( rv )
383  StopRouting();
384 
385  return rv;
386 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:257
void StopRouting()
Definition: pns_router.cpp:389
void PNS::ROUTER::FlipPosture ( )

Definition at line 417 of file pns_router.cpp.

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::performRouting().

418 {
419  if( m_state == ROUTE_TRACK )
420  {
421  m_placer->FlipPosture();
422  }
423 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
int PNS::ROUTER::GetClearance ( const ITEM aA,
const ITEM aB 
) const
int PNS::ROUTER::GetCurrentLayer ( ) const

Definition at line 458 of file pns_router.cpp.

References m_placer.

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

459 {
460  if( m_placer )
461  return m_placer->CurrentLayer();
462  return -1;
463 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
const std::vector< int > PNS::ROUTER::GetCurrentNets ( ) const

Definition at line 449 of file pns_router.cpp.

References m_placer.

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

450 {
451  if( m_placer )
452  return m_placer->CurrentNets();
453 
454  return std::vector<int>();
455 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
ROUTER * PNS::ROUTER::GetInstance ( )
static

Definition at line 78 of file pns_router.cpp.

References PNS::theRouter.

Referenced by PNS::ApproximateSegmentAsRect().

79 {
80  return theRouter;
81 }
static ROUTER * theRouter
Definition: pns_router.cpp:59
ROUTER_IFACE* PNS::ROUTER::GetInterface ( ) const
inline

Definition at line 218 of file pns_router.h.

219  {
220  return m_iface;
221  }
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
int PNS::ROUTER::GetIterLimit ( ) const
inline

Definition at line 176 of file pns_router.h.

176 { return m_iterLimit; };
int m_iterLimit
Definition: pns_router.h:262
RULE_RESOLVER* PNS::ROUTER::GetRuleResolver ( ) const
inline

Definition at line 163 of file pns_router.h.

References PNS::DM_ANY.

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), and movePlacing().

164  {
165  return m_iface->GetRuleResolver();
166  }
virtual RULE_RESOLVER * GetRuleResolver()=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
int PNS::ROUTER::GetShapshotIter ( ) const
inline

Definition at line 185 of file pns_router.h.

185 { return m_snapshotIter; }
int m_snapshotIter
Definition: pns_router.h:264
bool PNS::ROUTER::GetShowIntermediateSteps ( ) const
inline

Definition at line 184 of file pns_router.h.

184 { return m_showInterSteps; }
bool m_showInterSteps
Definition: pns_router.h:263
void PNS::ROUTER::highlightCurrent ( bool  enabled)
private
bool PNS::ROUTER::IsPlacingVia ( ) const

Definition at line 489 of file pns_router.cpp.

References m_placer.

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

490 {
491  if( !m_placer )
492  return false;
493 
494  return m_placer->IsPlacingVia();
495 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
bool PNS::ROUTER::isStartingPointRoutable ( const VECTOR2I aWhere,
int  aLayer 
)
private

Definition at line 155 of file pns_router.cpp.

References QueryHoverItems().

Referenced by StartRouting().

156 {
157  auto candidates = QueryHoverItems( aWhere );
158 
159  for( ITEM* item : candidates.Items() )
160  {
161  if( ! item->IsRoutable() && item->Layers().Overlaps( aLayer ) )
162  {
163  return false;
164  }
165  }
166 
167  return true;
168 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:118
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 201 of file pns_router.h.

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

202  {
203  m_settings = aSettings;
204  }
ROUTING_SETTINGS m_settings
Definition: pns_router.h:268
void PNS::ROUTER::markViolations ( NODE aNode,
ITEM_SET aCurrent,
NODE::ITEM_VECTOR aRemoved 
)
private

Definition at line 256 of file pns_router.cpp.

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

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

Definition at line 124 of file pns_router.h.

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

124 { return m_mode; }
ROUTER_MODE m_mode
Definition: pns_router.h:270
void PNS::ROUTER::Move ( const VECTOR2I aP,
ITEM aItem 
)

Definition at line 225 of file pns_router.cpp.

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

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

226 {
227  m_currentEnd = aP;
228 
229  switch( m_state )
230  {
231  case ROUTE_TRACK:
232  movePlacing( aP, endItem );
233  break;
234 
235  case DRAG_SEGMENT:
236  moveDragging( aP, endItem );
237  break;
238 
239  default:
240  break;
241  }
242 }
void moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:245
VECTOR2I m_currentEnd
Definition: pns_router.h:250
RouterState m_state
Definition: pns_router.h:251
void movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:320
void PNS::ROUTER::moveDragging ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 245 of file pns_router.cpp.

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

Referenced by Move().

246 {
247  m_iface->EraseView();
248 
249  m_dragger->Drag( aP );
250  ITEM_SET dragged = m_dragger->Traces();
251 
252  updateView( m_dragger->CurrentNode(), dragged );
253 }
void updateView(NODE *aNode, ITEM_SET &aCurrent)
Definition: pns_router.cpp:287
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:257
virtual void EraseView()=0
void PNS::ROUTER::movePlacing ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 320 of file pns_router.cpp.

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

321 {
322  m_iface->EraseView();
323 
324  m_placer->Move( aP, aEndItem );
325  ITEM_SET current = m_placer->Traces();
326 
327  for( const ITEM* item : current.CItems() )
328  {
329  if( !item->OfKind( ITEM::LINE_T ) )
330  continue;
331 
332  const LINE* l = static_cast<const LINE*>( item );
333  int clearance = GetRuleResolver()->Clearance( item->Net() );
334 
335  m_iface->DisplayItem( l, -1, clearance );
336 
337  if( l->EndsWithVia() )
338  m_iface->DisplayItem( &l->Via(), -1, clearance );
339  }
340 
341  //ITEM_SET tmp( &current );
342 
343  updateView( m_placer->CurrentNode( true ), current );
344 }
void updateView(NODE *aNode, ITEM_SET &aCurrent)
Definition: pns_router.cpp:287
virtual int Clearance(const ITEM *aA, const ITEM *aB) const =0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
virtual void EraseView()=0
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:163
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1)=0
ITEM* PNS::ROUTER::pickSingleItem ( ITEM_SET aItems) const
private
PLACEMENT_ALGO* PNS::ROUTER::Placer ( )
inline

Definition at line 216 of file pns_router.h.

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

216 { return m_placer.get(); }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
const ITEM_SET PNS::ROUTER::QueryHoverItems ( const VECTOR2I aP)

Definition at line 118 of file pns_router.cpp.

References IDLE, m_placer, m_state, and m_world.

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

119 {
120  if( m_state == IDLE || m_placer == nullptr )
121  return m_world->HitTest( aP );
122  else
123  return m_placer->CurrentNode()->HitTest( aP );
124 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
ITEM* PNS::ROUTER::QueryItemByParent ( const BOARD_ITEM aItem) const
bool PNS::ROUTER::RoutingInProgress ( ) const

Definition at line 112 of file pns_router.cpp.

References IDLE, and m_state.

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

113 {
114  return m_state != IDLE;
115 }
RouterState m_state
Definition: pns_router.h:251
void PNS::ROUTER::SetFailureReason ( const wxString &  aReason)
inline
void PNS::ROUTER::SetInterface ( ROUTER_IFACE aIface)

Definition at line 513 of file pns_router.cpp.

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

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

514 {
515  m_iface = aIface;
516  m_iface->SetRouter( this );
517 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
virtual void SetRouter(ROUTER *aRouter)=0
void PNS::ROUTER::SetIterLimit ( int  aX)
inline

Definition at line 175 of file pns_router.h.

175 { m_iterLimit = aX; }
int m_iterLimit
Definition: pns_router.h:262
void PNS::ROUTER::SetMode ( ROUTER_MODE  aMode)

Definition at line 507 of file pns_router.cpp.

References m_mode.

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

508 {
509  m_mode = aMode;
510 }
ROUTER_MODE m_mode
Definition: pns_router.h:270
void PNS::ROUTER::SetOrthoMode ( bool  aEnable)

Definition at line 498 of file pns_router.cpp.

References m_placer.

Referenced by ROUTER_TOOL::performRouting().

499 {
500  if( !m_placer )
501  return;
502 
503  m_placer->SetOrthoMode( aEnable );
504 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
void PNS::ROUTER::SetShowIntermediateSteps ( bool  aX,
int  aSnapshotIter = -1 
)
inline

Definition at line 178 of file pns_router.h.

179  {
180  m_showInterSteps = aX;
181  m_snapshotIter = aSnapshotIter;
182  }
int m_snapshotIter
Definition: pns_router.h:264
bool m_showInterSteps
Definition: pns_router.h:263
void PNS::ROUTER::SetView ( KIGFX::VIEW aView)
const VECTOR2I PNS::ROUTER::SnapToItem ( ITEM aItem,
VECTOR2I  aP,
bool &  aSplitsSegment 
)
void PNS::ROUTER::splitAdjacentSegments ( NODE aNode,
ITEM aSeg,
const VECTOR2I aP 
)
private
bool PNS::ROUTER::StartDragging ( const VECTOR2I aP,
ITEM aItem,
int  aDragMode = DM_ANY 
)

Definition at line 127 of file pns_router.cpp.

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

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

128 {
129 
130  if( aDragMode & DM_FREE_ANGLE )
132  else
133  m_forceMarkObstaclesMode = false;
134 
135  if( !aStartItem || aStartItem->OfKind( ITEM::SOLID_T ) )
136  return false;
137 
138  m_dragger.reset( new DRAGGER( this ) );
139  m_dragger->SetMode( aDragMode );
140  m_dragger->SetWorld( m_world.get() );
141  m_dragger->SetDebugDecorator ( m_iface->GetDebugDecorator () );
142 
143  if( m_dragger->Start ( aP, aStartItem ) )
145  else
146  {
147  m_dragger.reset();
148  m_state = IDLE;
149  return false;
150  }
151 
152  return true;
153 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
RouterState m_state
Definition: pns_router.h:251
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:257
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
bool m_forceMarkObstaclesMode
Definition: pns_router.h:266
bool PNS::ROUTER::StartRouting ( const VECTOR2I aP,
ITEM aItem,
int  aLayer 
)

Definition at line 170 of file pns_router.cpp.

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

171 {
172 
173  if( ! isStartingPointRoutable( aP, aLayer ) )
174  {
175  SetFailureReason( _("Cannot start routing inside a keepout area or board outline." ) );
176  return false;
177  }
178 
179  m_forceMarkObstaclesMode = false;
180 
181  switch( m_mode )
182  {
184  m_placer.reset( new LINE_PLACER( this ) );
185  break;
187  m_placer.reset( new DIFF_PAIR_PLACER( this ) );
188  break;
190  m_placer.reset( new MEANDER_PLACER( this ) );
191  break;
193  m_placer.reset( new DP_MEANDER_PLACER( this ) );
194  break;
196  m_placer.reset( new MEANDER_SKEW_PLACER( this ) );
197  break;
198 
199  default:
200  return false;
201  }
202 
203  m_placer->UpdateSizes ( m_sizes );
204  m_placer->SetLayer( aLayer );
205  m_placer->SetDebugDecorator ( m_iface->GetDebugDecorator () );
206 
207  bool rv = m_placer->Start( aP, aStartItem );
208 
209  if( !rv )
210  return false;
211 
212  m_currentEnd = aP;
214  return rv;
215 }
bool isStartingPointRoutable(const VECTOR2I &aWhere, int aLayer)
Definition: pns_router.cpp:155
VECTOR2I m_currentEnd
Definition: pns_router.h:250
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:213
RouterState m_state
Definition: pns_router.h:251
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
SIZES_SETTINGS m_sizes
Definition: pns_router.h:269
ROUTER_MODE m_mode
Definition: pns_router.h:270
bool m_forceMarkObstaclesMode
Definition: pns_router.h:266
void PNS::ROUTER::StopRouting ( )

Definition at line 389 of file pns_router.cpp.

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::InlineDrag(), ROUTER_TOOL::performDragging(), and LENGTH_TUNER_TOOL::performTuning().

390 {
391  // Update the ratsnest with new changes
392 
393  if( m_placer )
394  {
395  std::vector<int> nets;
396  m_placer->GetModifiedNets( nets );
397 
398  // Update the ratsnest with new changes
399  for ( auto n : nets )
400  m_iface->UpdateNet( n );
401  }
402 
403  if( !RoutingInProgress() )
404  return;
405 
406  m_placer.reset();
407  m_dragger.reset();
408 
409  m_iface->EraseView();
410 
411  m_state = IDLE;
412  m_world->KillChildren();
413  m_world->ClearRanks();
414 }
bool RoutingInProgress() const
Definition: pns_router.cpp:112
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
virtual void UpdateNet(int aNetCode)=0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:257
virtual void EraseView()=0
void PNS::ROUTER::SwitchLayer ( int  layer)

Definition at line 426 of file pns_router.cpp.

References m_placer, m_state, and ROUTE_TRACK.

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

427 {
428  switch( m_state )
429  {
430  case ROUTE_TRACK:
431  m_placer->SetLayer( aLayer );
432  break;
433  default:
434  break;
435  }
436 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
ITEM* PNS::ROUTER::syncPad ( D_PAD aPad)
private
ITEM* PNS::ROUTER::syncTrack ( TRACK aTrack)
private
ITEM* PNS::ROUTER::syncVia ( VIA aVia)
private
void PNS::ROUTER::SyncWorld ( )

Definition at line 91 of file pns_router.cpp.

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

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

92 {
93  ClearWorld();
94 
95  m_world = std::unique_ptr<NODE>( new NODE );
96  m_iface->SyncWorld( m_world.get() );
97 
98 }
void ClearWorld()
Definition: pns_router.cpp:100
std::unique_ptr< NODE > m_world
Definition: pns_router.h:253
virtual void SyncWorld(NODE *aNode)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
void PNS::ROUTER::ToggleViaPlacement ( )

Definition at line 439 of file pns_router.cpp.

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::onViaCommand().

440 {
441  if( m_state == ROUTE_TRACK )
442  {
443  bool toggle = !m_placer->IsPlacingVia();
444  m_placer->ToggleVia( toggle );
445  }
446 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
void PNS::ROUTER::UpdateSizes ( const SIZES_SETTINGS aSizes)

Applies stored settings.

See also
Settings()

Definition at line 308 of file pns_router.cpp.

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

309 {
310  m_sizes = aSizes;
311 
312  // Change track/via size settings
313  if( m_state == ROUTE_TRACK)
314  {
315  m_placer->UpdateSizes( m_sizes );
316  }
317 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:256
RouterState m_state
Definition: pns_router.h:251
SIZES_SETTINGS m_sizes
Definition: pns_router.h:269
void PNS::ROUTER::updateView ( NODE aNode,
ITEM_SET aCurrent 
)
private

Definition at line 287 of file pns_router.cpp.

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

Referenced by moveDragging(), and movePlacing().

288 {
289  NODE::ITEM_VECTOR removed, added;
290  NODE::OBSTACLES obstacles;
291 
292  if( !aNode )
293  return;
294 
296  markViolations( aNode, aCurrent, removed );
297 
298  aNode->GetUpdatedItems( removed, added );
299 
300  for( auto item : added )
301  m_iface->DisplayItem( item );
302 
303  for( auto item : removed )
304  m_iface->HideItem( item );
305 }
virtual void HideItem(ITEM *aItem)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:260
ROUTER_MODE Mode() const
Definition: pns_router.h:124
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1)=0
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:142
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:187
bool m_forceMarkObstaclesMode
Definition: pns_router.h:266
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:141
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:256

Member Data Documentation

VECTOR2I PNS::ROUTER::m_currentEnd
private

Definition at line 250 of file pns_router.h.

Referenced by Move(), and StartRouting().

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

Definition at line 257 of file pns_router.h.

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

wxString PNS::ROUTER::m_failureReason
private

Definition at line 273 of file pns_router.h.

bool PNS::ROUTER::m_forceMarkObstaclesMode = false
private

Definition at line 266 of file pns_router.h.

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

int PNS::ROUTER::m_iterLimit
private

Definition at line 262 of file pns_router.h.

Referenced by ROUTER().

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 254 of file pns_router.h.

Referenced by ROUTER().

ROUTER_MODE PNS::ROUTER::m_mode
private

Definition at line 270 of file pns_router.h.

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

ROUTING_SETTINGS PNS::ROUTER::m_settings
private

Definition at line 268 of file pns_router.h.

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

Definition at line 258 of file pns_router.h.

bool PNS::ROUTER::m_showInterSteps
private

Definition at line 263 of file pns_router.h.

Referenced by ROUTER().

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

Definition at line 269 of file pns_router.h.

Referenced by StartRouting(), and UpdateSizes().

int PNS::ROUTER::m_snapshotIter
private

Definition at line 264 of file pns_router.h.

Referenced by ROUTER().

wxString PNS::ROUTER::m_toolStatusbarName
private

Definition at line 272 of file pns_router.h.

bool PNS::ROUTER::m_violation
private

Definition at line 265 of file pns_router.h.

Referenced by ROUTER().

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

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