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

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
 
ROUTING_SETTINGS m_settings
 
SIZES_SETTINGS m_sizes
 
ROUTER_MODE m_mode
 
wxString m_toolStatusbarName
 
wxString m_failureReason
 

Detailed Description

Definition at line 100 of file pns_router.h.

Member Enumeration Documentation

Enumerator
IDLE 
DRAG_SEGMENT 
ROUTE_TRACK 

Definition at line 103 of file pns_router.h.

Constructor & Destructor Documentation

PNS::ROUTER::ROUTER ( )

Definition at line 68 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.

69 {
70  theRouter = this;
71 
72  m_state = IDLE;
74 
75  // Initialize all other variables:
76  m_lastNode = nullptr;
77  m_iterLimit = 0;
78  m_showInterSteps = false;
79  m_snapshotIter = 0;
80  m_violation = false;
81  m_iface = nullptr;
82 }
int m_snapshotIter
Definition: pns_router.h:254
int m_iterLimit
Definition: pns_router.h:252
bool m_showInterSteps
Definition: pns_router.h:253
NODE * m_lastNode
Definition: pns_router.h:244
RouterState m_state
Definition: pns_router.h:241
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
static ROUTER * theRouter
Definition: pns_router.cpp:66
bool m_violation
Definition: pns_router.h:255
ROUTER_MODE m_mode
Definition: pns_router.h:259
PNS::ROUTER::~ROUTER ( )

Definition at line 91 of file pns_router.cpp.

References ClearWorld().

92 {
93  ClearWorld();
94  theRouter = nullptr;
95 }
void ClearWorld()
Definition: pns_router.cpp:107
static ROUTER * theRouter
Definition: pns_router.cpp:66

Member Function Documentation

void PNS::ROUTER::clearViewFlags ( )
private
void PNS::ROUTER::ClearWorld ( )

Definition at line 107 of file pns_router.cpp.

References m_placer, and m_world.

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

108 {
109  if( m_world )
110  {
111  m_world->KillChildren();
112  m_world.reset();
113  }
114 
115  m_placer.reset();
116 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:243
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
void PNS::ROUTER::commitPad ( SOLID aPad)
private
void PNS::ROUTER::CommitRouting ( NODE aNode)

Definition at line 324 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 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().

325 {
326  NODE::ITEM_VECTOR removed, added;
327 
328  aNode->GetUpdatedItems( removed, added );
329 
330  for( auto item : removed )
331  m_iface->RemoveItem( item );
332 
333  for( auto item : added )
334  m_iface->AddItem( item );
335 
336  m_iface->Commit();
337  m_world->Commit( aNode );
338 }
virtual void AddItem(ITEM *aItem)=0
std::unique_ptr< NODE > m_world
Definition: pns_router.h:243
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
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 195 of file pns_router.cpp.

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

196 {
197  for( const ITEM* item : aItems.CItems() )
198  m_iface->DisplayItem( item );
199 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
virtual void DisplayItem(const ITEM *aItem, int aColor=-1, int aClearance=-1)=0
void PNS::ROUTER::DumpLog ( )

Definition at line 443 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().

444 {
445  LOGGER* logger = nullptr;
446 
447  switch( m_state )
448  {
449  case DRAG_SEGMENT:
450  logger = m_dragger->Logger();
451  break;
452 
453  case ROUTE_TRACK:
454  logger = m_placer->Logger();
455  break;
456 
457  default:
458  break;
459  }
460 
461  if( logger )
462  logger->Save( "/tmp/shove.log" );
463 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:247
void PNS::ROUTER::eraseView ( )
private
const wxString& PNS::ROUTER::FailureReason ( ) const
inline

Definition at line 205 of file pns_router.h.

References m_failureReason.

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

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

Definition at line 341 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().

342 {
343  bool rv = false;
344 
345  switch( m_state )
346  {
347  case ROUTE_TRACK:
348  rv = m_placer->FixRoute( aP, aEndItem );
349  break;
350 
351  case DRAG_SEGMENT:
352  rv = m_dragger->FixRoute();
353  break;
354 
355  default:
356  break;
357  }
358 
359  if( rv )
360  StopRouting();
361 
362  return rv;
363 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:247
void StopRouting()
Definition: pns_router.cpp:366
void PNS::ROUTER::FlipPosture ( )

Definition at line 394 of file pns_router.cpp.

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::performRouting().

395 {
396  if( m_state == ROUTE_TRACK )
397  {
398  m_placer->FlipPosture();
399  }
400 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
int PNS::ROUTER::GetClearance ( const ITEM aA,
const ITEM aB 
) const
int PNS::ROUTER::GetCurrentLayer ( ) const

Definition at line 435 of file pns_router.cpp.

References m_placer.

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

436 {
437  if( m_placer )
438  return m_placer->CurrentLayer();
439  return -1;
440 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
const std::vector< int > PNS::ROUTER::GetCurrentNets ( ) const

Definition at line 426 of file pns_router.cpp.

References m_placer.

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

427 {
428  if( m_placer )
429  return m_placer->CurrentNets();
430 
431  return std::vector<int>();
432 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
ROUTER * PNS::ROUTER::GetInstance ( )
static

Definition at line 85 of file pns_router.cpp.

References PNS::theRouter.

86 {
87  return theRouter;
88 }
static ROUTER * theRouter
Definition: pns_router.cpp:66
ROUTER_IFACE* PNS::ROUTER::GetInterface ( ) const
inline

Definition at line 209 of file pns_router.h.

References m_iface.

210  {
211  return m_iface;
212  }
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
int PNS::ROUTER::GetIterLimit ( ) const
inline

Definition at line 167 of file pns_router.h.

References m_iterLimit.

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

Definition at line 154 of file pns_router.h.

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

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

155  {
156  return m_iface->GetRuleResolver();
157  }
virtual RULE_RESOLVER * GetRuleResolver()=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
int PNS::ROUTER::GetShapshotIter ( ) const
inline

Definition at line 176 of file pns_router.h.

References m_snapshotIter.

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

Definition at line 175 of file pns_router.h.

References m_showInterSteps.

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

Definition at line 466 of file pns_router.cpp.

References m_placer.

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

467 {
468  if( !m_placer )
469  return false;
470 
471  return m_placer->IsPlacingVia();
472 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
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 192 of file pns_router.h.

References m_settings.

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

193  {
194  m_settings = aSettings;
195  }
ROUTING_SETTINGS m_settings
Definition: pns_router.h:257
void PNS::ROUTER::markViolations ( NODE aNode,
ITEM_SET aCurrent,
NODE::ITEM_VECTOR aRemoved 
)
private

Definition at line 233 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().

234 {
235  for( ITEM* item : aCurrent.Items() )
236  {
237  NODE::OBSTACLES obstacles;
238 
239  aNode->QueryColliding( item, obstacles, ITEM::ANY_T );
240 
241  if( item->OfKind( ITEM::LINE_T ) )
242  {
243  LINE* l = static_cast<LINE*>( item );
244 
245  if( l->EndsWithVia() )
246  {
247  VIA v( l->Via() );
248  aNode->QueryColliding( &v, obstacles, ITEM::ANY_T );
249  }
250  }
251 
252  for( OBSTACLE& obs : obstacles )
253  {
254  int clearance = aNode->GetClearance( item, obs.m_item );
255  std::unique_ptr<ITEM> tmp( obs.m_item->Clone() );
256  tmp->Mark( MK_VIOLATION );
257  m_iface->DisplayItem( tmp.get(), -1, clearance );
258  aRemoved.push_back( obs.m_item );
259  }
260  }
261 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
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 116 of file pns_router.h.

References m_mode.

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

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

Definition at line 202 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().

203 {
204  m_currentEnd = aP;
205 
206  switch( m_state )
207  {
208  case ROUTE_TRACK:
209  movePlacing( aP, endItem );
210  break;
211 
212  case DRAG_SEGMENT:
213  moveDragging( aP, endItem );
214  break;
215 
216  default:
217  break;
218  }
219 }
void moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:222
VECTOR2I m_currentEnd
Definition: pns_router.h:240
RouterState m_state
Definition: pns_router.h:241
void movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:297
void PNS::ROUTER::moveDragging ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 222 of file pns_router.cpp.

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

Referenced by Move().

223 {
224  m_iface->EraseView();
225 
226  m_dragger->Drag( aP );
227  ITEM_SET dragged = m_dragger->Traces();
228 
229  updateView( m_dragger->CurrentNode(), dragged );
230 }
void updateView(NODE *aNode, ITEM_SET &aCurrent)
Definition: pns_router.cpp:264
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:247
virtual void EraseView()=0
void PNS::ROUTER::movePlacing ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 297 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().

298 {
299  m_iface->EraseView();
300 
301  m_placer->Move( aP, aEndItem );
302  ITEM_SET current = m_placer->Traces();
303 
304  for( const ITEM* item : current.CItems() )
305  {
306  if( !item->OfKind( ITEM::LINE_T ) )
307  continue;
308 
309  const LINE* l = static_cast<const LINE*>( item );
310  int clearance = GetRuleResolver()->Clearance( item->Net() );
311 
312  m_iface->DisplayItem( l, -1, clearance );
313 
314  if( l->EndsWithVia() )
315  m_iface->DisplayItem( &l->Via(), -1, clearance );
316  }
317 
318  //ITEM_SET tmp( &current );
319 
320  updateView( m_placer->CurrentNode( true ), current );
321 }
void updateView(NODE *aNode, ITEM_SET &aCurrent)
Definition: pns_router.cpp:264
virtual int Clearance(const ITEM *aA, const ITEM *aB) const =0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
virtual void EraseView()=0
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:154
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 207 of file pns_router.h.

References m_placer.

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

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

Definition at line 125 of file pns_router.cpp.

References IDLE, m_placer, m_state, and m_world.

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

126 {
127  if( m_state == IDLE )
128  return m_world->HitTest( aP );
129  else
130  return m_placer->CurrentNode()->HitTest( aP );
131 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:243
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
ITEM* PNS::ROUTER::QueryItemByParent ( const BOARD_ITEM aItem) const
bool PNS::ROUTER::RoutingInProgress ( ) const

Definition at line 119 of file pns_router.cpp.

References IDLE, and m_state.

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

120 {
121  return m_state != IDLE;
122 }
RouterState m_state
Definition: pns_router.h:241
void PNS::ROUTER::SetFailureReason ( const wxString &  aReason)
inline
void PNS::ROUTER::SetInterface ( ROUTER_IFACE aIface)

Definition at line 490 of file pns_router.cpp.

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

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

491 {
492  m_iface = aIface;
493  m_iface->SetRouter( this );
494 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
virtual void SetRouter(ROUTER *aRouter)=0
void PNS::ROUTER::SetIterLimit ( int  aX)
inline

Definition at line 166 of file pns_router.h.

References m_iterLimit.

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

Definition at line 484 of file pns_router.cpp.

References m_mode.

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

485 {
486  m_mode = aMode;
487 }
ROUTER_MODE m_mode
Definition: pns_router.h:259
void PNS::ROUTER::SetOrthoMode ( bool  aEnable)

Definition at line 475 of file pns_router.cpp.

References m_placer.

Referenced by ROUTER_TOOL::performRouting().

476 {
477  if( !m_placer )
478  return;
479 
480  m_placer->SetOrthoMode( aEnable );
481 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
void PNS::ROUTER::SetShowIntermediateSteps ( bool  aX,
int  aSnapshotIter = -1 
)
inline

Definition at line 169 of file pns_router.h.

References m_showInterSteps, and m_snapshotIter.

170  {
171  m_showInterSteps = aX;
172  m_snapshotIter = aSnapshotIter;
173  }
int m_snapshotIter
Definition: pns_router.h:254
bool m_showInterSteps
Definition: pns_router.h:253
ROUTING_SETTINGS& PNS::ROUTER::Settings ( )
inline
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 
)

Definition at line 134 of file pns_router.cpp.

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

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

135 {
136  if( !aStartItem || aStartItem->OfKind( ITEM::SOLID_T ) )
137  return false;
138 
139  m_dragger.reset( new DRAGGER( this ) );
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:243
RouterState m_state
Definition: pns_router.h:241
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:247
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
bool PNS::ROUTER::StartRouting ( const VECTOR2I aP,
ITEM aItem,
int  aLayer 
)

Definition at line 156 of file pns_router.cpp.

References PNS::ROUTER_IFACE::GetDebugDecorator(), m_currentEnd, 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, and ROUTE_TRACK.

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

157 {
158  switch( m_mode )
159  {
161  m_placer.reset( new LINE_PLACER( this ) );
162  break;
164  m_placer.reset( new DIFF_PAIR_PLACER( this ) );
165  break;
167  m_placer.reset( new MEANDER_PLACER( this ) );
168  break;
170  m_placer.reset( new DP_MEANDER_PLACER( this ) );
171  break;
173  m_placer.reset( new MEANDER_SKEW_PLACER( this ) );
174  break;
175 
176  default:
177  return false;
178  }
179 
180  m_placer->UpdateSizes ( m_sizes );
181  m_placer->SetLayer( aLayer );
182  m_placer->SetDebugDecorator ( m_iface->GetDebugDecorator () );
183 
184  bool rv = m_placer->Start( aP, aStartItem );
185 
186  if( !rv )
187  return false;
188 
189  m_currentEnd = aP;
191  return rv;
192 }
VECTOR2I m_currentEnd
Definition: pns_router.h:240
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
SIZES_SETTINGS m_sizes
Definition: pns_router.h:258
ROUTER_MODE m_mode
Definition: pns_router.h:259
void PNS::ROUTER::StopRouting ( )

Definition at line 366 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().

367 {
368  // Update the ratsnest with new changes
369 
370  if( m_placer )
371  {
372  std::vector<int> nets;
373  m_placer->GetModifiedNets( nets );
374 
375  // Update the ratsnest with new changes
376  for ( auto n : nets )
377  m_iface->UpdateNet( n );
378  }
379 
380  if( !RoutingInProgress() )
381  return;
382 
383  m_placer.reset();
384  m_dragger.reset();
385 
386  m_iface->EraseView();
387 
388  m_state = IDLE;
389  m_world->KillChildren();
390  m_world->ClearRanks();
391 }
bool RoutingInProgress() const
Definition: pns_router.cpp:119
std::unique_ptr< NODE > m_world
Definition: pns_router.h:243
virtual void UpdateNet(int aNetCode)=0
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
std::unique_ptr< DRAGGER > m_dragger
Definition: pns_router.h:247
virtual void EraseView()=0
void PNS::ROUTER::SwitchLayer ( int  layer)

Definition at line 403 of file pns_router.cpp.

References m_placer, m_state, and ROUTE_TRACK.

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

404 {
405  switch( m_state )
406  {
407  case ROUTE_TRACK:
408  m_placer->SetLayer( aLayer );
409  break;
410  default:
411  break;
412  }
413 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
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 98 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().

99 {
100  ClearWorld();
101 
102  m_world = std::unique_ptr<NODE>( new NODE );
103  m_iface->SyncWorld( m_world.get() );
104 
105 }
void ClearWorld()
Definition: pns_router.cpp:107
std::unique_ptr< NODE > m_world
Definition: pns_router.h:243
virtual void SyncWorld(NODE *aNode)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
void PNS::ROUTER::ToggleViaPlacement ( )

Definition at line 416 of file pns_router.cpp.

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::onViaCommand().

417 {
418  if( m_state == ROUTE_TRACK )
419  {
420  bool toggle = !m_placer->IsPlacingVia();
421  m_placer->ToggleVia( toggle );
422  }
423 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
void PNS::ROUTER::UpdateSizes ( const SIZES_SETTINGS aSizes)

Applies stored settings.

See also
Settings()

Definition at line 285 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().

286 {
287  m_sizes = aSizes;
288 
289  // Change track/via size settings
290  if( m_state == ROUTE_TRACK)
291  {
292  m_placer->UpdateSizes( m_sizes );
293  }
294 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:246
RouterState m_state
Definition: pns_router.h:241
SIZES_SETTINGS m_sizes
Definition: pns_router.h:258
void PNS::ROUTER::updateView ( NODE aNode,
ITEM_SET aCurrent 
)
private

Definition at line 264 of file pns_router.cpp.

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

Referenced by moveDragging(), and movePlacing().

265 {
266  NODE::ITEM_VECTOR removed, added;
267  NODE::OBSTACLES obstacles;
268 
269  if( !aNode )
270  return;
271 
272  if( Settings().Mode() == RM_MarkObstacles )
273  markViolations( aNode, aCurrent, removed );
274 
275  aNode->GetUpdatedItems( removed, added );
276 
277  for( auto item : added )
278  m_iface->DisplayItem( item );
279 
280  for( auto item : removed )
281  m_iface->HideItem( item );
282 }
virtual void HideItem(ITEM *aItem)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:250
ROUTER_MODE Mode() const
Definition: pns_router.h:116
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:178
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:233

Member Data Documentation

VECTOR2I PNS::ROUTER::m_currentEnd
private

Definition at line 240 of file pns_router.h.

Referenced by Move(), and StartRouting().

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

Definition at line 247 of file pns_router.h.

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

wxString PNS::ROUTER::m_failureReason
private

Definition at line 262 of file pns_router.h.

Referenced by FailureReason(), and SetFailureReason().

int PNS::ROUTER::m_iterLimit
private

Definition at line 252 of file pns_router.h.

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

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 244 of file pns_router.h.

Referenced by ROUTER().

ROUTER_MODE PNS::ROUTER::m_mode
private

Definition at line 259 of file pns_router.h.

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

ROUTING_SETTINGS PNS::ROUTER::m_settings
private

Definition at line 257 of file pns_router.h.

Referenced by LoadSettings(), and Settings().

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

Definition at line 248 of file pns_router.h.

bool PNS::ROUTER::m_showInterSteps
private

Definition at line 253 of file pns_router.h.

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

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

Definition at line 258 of file pns_router.h.

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

int PNS::ROUTER::m_snapshotIter
private

Definition at line 254 of file pns_router.h.

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

wxString PNS::ROUTER::m_toolStatusbarName
private

Definition at line 261 of file pns_router.h.

bool PNS::ROUTER::m_violation
private

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