KiCad PCB EDA Suite
PNS::ROUTER Class Reference

#include <pns_router.h>

Public Types

enum  RouterState { IDLE, DRAG_SEGMENT, ROUTE_TRACK }
 

Public Member Functions

 ROUTER ()
 
 ~ROUTER ()
 
void SetInterface (ROUTER_IFACE *aIface)
 
void SetMode (ROUTER_MODE aMode)
 
ROUTER_MODE Mode () const
 
RouterState GetState () const
 
DRAG_ALGOGetDragger ()
 
void ClearWorld ()
 
void SyncWorld ()
 
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 ()
 
void ClearViewDecorations ()
 
NODEGetWorld () const
 
void FlipPosture ()
 
bool SwitchLayer (int layer)
 
void ToggleViaPlacement ()
 
void SetOrthoMode (bool aEnable)
 
void ToggleRounded ()
 
int GetCurrentLayer () const
 
const std::vector< int > GetCurrentNets () const
 
LOGGERLogger ()
 
RULE_RESOLVERGetRuleResolver () const
 
bool IsPlacingVia () const
 
const ITEM_SET QueryHoverItems (const VECTOR2I &aP, bool aUseClearance=false)
 
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
 
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 ()
 
void SetFailureReason (const wxString &aReason)
 
const wxString & FailureReason () const
 
PLACEMENT_ALGOPlacer ()
 
ROUTER_IFACEGetInterface () const
 
void SetVisibleViewArea (const BOX2I &aExtents)
 
const BOX2IVisibleViewArea () const
 

Static Public Member Functions

static ROUTERGetInstance ()
 

Private Member Functions

void movePlacing (const VECTOR2I &aP, ITEM *aItem)
 
void moveDragging (const VECTOR2I &aP, ITEM *aItem)
 
void updateView (NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
 
void markViolations (NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
 
bool isStartingPointRoutable (const VECTOR2I &aWhere, ITEM *aItem, int aLayer)
 

Private Attributes

BOX2I m_visibleViewArea
 
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_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 115 of file pns_router.h.

Member Enumeration Documentation

◆ RouterState

Enumerator
IDLE 
DRAG_SEGMENT 
ROUTE_TRACK 

Definition at line 118 of file pns_router.h.

Constructor & Destructor Documentation

◆ ROUTER()

PNS::ROUTER::ROUTER ( )

Definition at line 60 of file pns_router.cpp.

61 {
62  theRouter = this;
63 
64  m_state = IDLE;
66 
67  m_logger = new LOGGER;
68 
69  // Initialize all other variables:
70  m_lastNode = nullptr;
71  m_iterLimit = 0;
72  m_settings = nullptr;
73  m_iface = nullptr;
75 }
BOX2I m_visibleViewArea
Definition: pns_router.h:224
int m_iterLimit
Definition: pns_router.h:236
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:239
NODE * m_lastNode
Definition: pns_router.h:228
void SetMaximum()
Definition: box2.h:57
RouterState m_state
Definition: pns_router.h:225
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
LOGGER * m_logger
Definition: pns_router.h:242
static ROUTER * theRouter
Definition: pns_router.cpp:58
ROUTER_MODE m_mode
Definition: pns_router.h:241

References IDLE, m_iface, m_iterLimit, m_lastNode, m_logger, m_mode, m_settings, m_state, m_visibleViewArea, PNS::PNS_MODE_ROUTE_SINGLE, BOX2< Vec >::SetMaximum(), and PNS::theRouter.

◆ ~ROUTER()

PNS::ROUTER::~ROUTER ( )

Definition at line 84 of file pns_router.cpp.

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

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

Member Function Documentation

◆ BreakSegment()

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

Definition at line 845 of file pns_router.cpp.

846 {
847  NODE *node = m_world->Branch();
848 
849  LINE_PLACER placer( this );
850 
851  if( placer.SplitAdjacentSegments( node, aItem, aP ) )
852  {
853  CommitRouting( node );
854  }
855  else
856  {
857  delete node;
858  }
859 }
void CommitRouting()
Definition: pns_router.cpp:699
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227

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

Referenced by ROUTER_TOOL::breakTrack().

◆ ClearViewDecorations()

void PNS::ROUTER::ClearViewDecorations ( )

◆ 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< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227

References m_placer, and m_world.

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

◆ CommitRouting() [1/2]

◆ CommitRouting() [2/2]

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

Definition at line 608 of file pns_router.cpp.

609 {
610  if( m_state == ROUTE_TRACK && !m_placer->HasPlacedAnything() )
611  return;
612 
613  NODE::ITEM_VECTOR removed;
614  NODE::ITEM_VECTOR added;
615  NODE::ITEM_VECTOR changed;
616 
617  aNode->GetUpdatedItems( removed, added );
618 
619  for( ITEM* item : removed )
620  {
621  bool is_changed = false;
622 
623  // Items in remove/add that share the same parent are just updated versions
624  // We move them to the updated vector to preserve attributes such as UUID and pad data
625  if( item->Parent() )
626  {
627  for( NODE::ITEM_VECTOR::iterator added_it = added.begin();
628  added_it != added.end(); ++added_it )
629  {
630  if( ( *added_it )->Parent() && ( *added_it )->Parent() == item->Parent() )
631  {
632  changed.push_back( *added_it );
633  added.erase( added_it );
634  is_changed = true;
635  break;
636  }
637  }
638  }
639 
640  if( !is_changed && !item->IsVirtual() )
641  m_iface->RemoveItem( item );
642  }
643 
644  for( ITEM* item : added )
645  {
646  if( !item->IsVirtual() )
647  {
648  m_iface->AddItem( item );
649  }
650  }
651 
652  for( ITEM* item : changed )
653  {
654  if( !item->IsVirtual() )
655  {
656  m_iface->UpdateItem( item );
657  }
658  }
659 
660  m_iface->Commit();
661  m_world->Commit( aNode );
662 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
virtual void AddItem(ITEM *aItem)=0
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227
RouterState m_state
Definition: pns_router.h:225
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
virtual void UpdateItem(ITEM *aItem)=0
virtual void Commit()=0
virtual void RemoveItem(ITEM *aItem)=0
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:148

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

◆ FailureReason()

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

Definition at line 203 of file pns_router.h.

203 { return m_failureReason; }
wxString m_failureReason
Definition: pns_router.h:245

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

666 {
667  bool rv = false;
668 
669  if( m_logger )
670  m_logger->Log( LOGGER::EVT_FIX, aP, aEndItem );
671 
672  switch( m_state )
673  {
674  case ROUTE_TRACK:
675  rv = m_placer->FixRoute( aP, aEndItem, aForceFinish );
676  break;
677 
678  case DRAG_SEGMENT:
679  rv = m_dragger->FixRoute();
680  break;
681 
682  default:
683  break;
684  }
685 
686  return rv;
687 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231
RouterState m_state
Definition: pns_router.h:225
LOGGER * m_logger
Definition: pns_router.h:242
void Log(EVENT_TYPE evt, const VECTOR2I &pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:64

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

743 {
744  if( m_state == ROUTE_TRACK )
745  {
746  m_placer->FlipPosture();
747  }
748 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
RouterState m_state
Definition: pns_router.h:225

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::performRouting().

◆ GetCurrentLayer()

int PNS::ROUTER::GetCurrentLayer ( ) const

Definition at line 781 of file pns_router.cpp.

782 {
783  if( m_placer )
784  return m_placer->CurrentLayer();
785  else if( m_dragger )
786  return m_dragger->CurrentLayer();
787 
788  return -1;
789 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231

References m_dragger, and m_placer.

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

◆ GetCurrentNets()

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

Definition at line 770 of file pns_router.cpp.

771 {
772  if( m_placer )
773  return m_placer->CurrentNets();
774  else if( m_dragger )
775  return m_dragger->CurrentNets();
776 
777  return std::vector<int>();
778 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231

References m_dragger, and m_placer.

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

◆ GetDragger()

DRAG_ALGO* PNS::ROUTER::GetDragger ( )
inline

Definition at line 135 of file pns_router.h.

135 { return m_dragger.get(); }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231

References m_dragger.

◆ GetInstance()

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

◆ GetInterface()

◆ GetIterLimit()

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

Definition at line 179 of file pns_router.h.

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

References m_iterLimit.

◆ GetRuleResolver()

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

Definition at line 169 of file pns_router.h.

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

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

Referenced by PNS::MEANDER_PLACER_BASE::Clearance(), movePlacing(), and updateView().

◆ GetState()

RouterState PNS::ROUTER::GetState ( ) const
inline

Definition at line 133 of file pns_router.h.

133 { return m_state; }
RouterState m_state
Definition: pns_router.h:225

References m_state.

◆ GetWorld()

◆ IsPlacingVia()

bool PNS::ROUTER::IsPlacingVia ( ) const

Definition at line 798 of file pns_router.cpp.

799 {
800  if( !m_placer )
801  return false;
802 
803  return m_placer->IsPlacingVia();
804 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230

References m_placer.

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

◆ isStartingPointRoutable()

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

Definition at line 202 of file pns_router.cpp.

203 {
204  if( Settings().AllowDRCViolations() )
205  return true;
206 
208  {
210  {
211  SetFailureReason( _( "Diff pair gap is less than board minimum clearance." ) );
212  return false;
213  }
214  }
215 
216  ITEM_SET candidates = QueryHoverItems( aWhere );
217 
218  for( ITEM* item : candidates.Items() )
219  {
220  if( !item->IsRoutable() && item->Layers().Overlaps( aLayer ) )
221  {
222  BOARD_ITEM* parent = item->Parent();
223 
224  switch( parent->Type() )
225  {
226  case PCB_PAD_T:
227  {
228  PAD* pad = static_cast<PAD*>( parent );
229 
230  if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
231  SetFailureReason( _( "Cannot start routing from a non-plated hole." ) );
232  }
233  break;
234 
235  case PCB_ZONE_T:
236  case PCB_FP_ZONE_T:
237  {
238  ZONE* zone = static_cast<ZONE*>( parent );
239 
240  if( !zone->GetZoneName().IsEmpty() )
241  {
242  SetFailureReason( wxString::Format( _( "Rule area '%s' disallows tracks." ),
243  zone->GetZoneName() ) );
244  }
245  else
246  {
247  SetFailureReason( _( "Rule area disallows tracks." ) );
248  }
249  }
250  break;
251 
252  case PCB_TEXT_T:
253  case PCB_FP_TEXT_T:
254  SetFailureReason( _( "Cannot start routing from a text item." ) );
255  break;
256 
257  case PCB_SHAPE_T:
258  case PCB_FP_SHAPE_T:
259  SetFailureReason( _( "Cannot start routing from a graphic." ) );
260 
261  default:
262  break;
263  }
264 
265  return false;
266  }
267  }
268 
269  VECTOR2I startPoint = aStartItem ? aStartItem->Anchor( 0 ) : aWhere;
270 
271  if( aStartItem && aStartItem->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
272  {
273  VECTOR2I otherEnd = aStartItem->Anchor( 1 );
274 
275  if( ( otherEnd - aWhere ).SquaredEuclideanNorm()
276  < ( startPoint - aWhere ).SquaredEuclideanNorm() )
277  {
278  startPoint = otherEnd;
279  }
280  }
281 
283  {
284  SHAPE_LINE_CHAIN dummyStartSeg;
285  LINE dummyStartLine;
286 
287  dummyStartSeg.Append( startPoint );
288  dummyStartSeg.Append( startPoint, true );
289 
290  dummyStartLine.SetShape( dummyStartSeg );
291  dummyStartLine.SetLayer( aLayer );
292  dummyStartLine.SetNet( aStartItem ? aStartItem->Net() : 0 );
293  dummyStartLine.SetWidth( m_sizes.TrackWidth() );
294 
295  if( m_world->CheckColliding( &dummyStartLine, ITEM::ANY_T ) )
296  {
297  ITEM_SET dummyStartSet( &dummyStartLine );
298  NODE::ITEM_VECTOR highlightedItems;
299 
300  markViolations( m_world.get(), dummyStartSet, highlightedItems );
301 
302  for( ITEM* item : highlightedItems )
303  m_iface->HideItem( item );
304 
305  SetFailureReason( _( "The routing start point violates DRC." ) );
306  return false;
307  }
308  }
309  else if( m_mode == PNS_MODE_ROUTE_DIFF_PAIR )
310  {
311  if( !aStartItem )
312  {
313  SetFailureReason( _( "Cannot start a differential pair in the middle of nowhere." ) );
314  return false;
315  }
316 
317  DP_PRIMITIVE_PAIR dpPair;
318  wxString errorMsg;
319 
320  if( !DIFF_PAIR_PLACER::FindDpPrimitivePair( m_world.get(), startPoint, aStartItem, dpPair,
321  &errorMsg ) )
322  {
323  SetFailureReason( errorMsg );
324  return false;
325  }
326 
327  SHAPE_LINE_CHAIN dummyStartSegA;
328  SHAPE_LINE_CHAIN dummyStartSegB;
329  LINE dummyStartLineA;
330  LINE dummyStartLineB;
331 
332  dummyStartSegA.Append( dpPair.AnchorN() );
333  dummyStartSegA.Append( dpPair.AnchorN(), true );
334 
335  dummyStartSegB.Append( dpPair.AnchorP() );
336  dummyStartSegB.Append( dpPair.AnchorP(), true );
337 
338  dummyStartLineA.SetShape( dummyStartSegA );
339  dummyStartLineA.SetLayer( aLayer );
340  dummyStartLineA.SetNet( dpPair.PrimN()->Net() );
341  dummyStartLineA.SetWidth( m_sizes.DiffPairWidth() );
342 
343  dummyStartLineB.SetShape( dummyStartSegB );
344  dummyStartLineB.SetLayer( aLayer );
345  dummyStartLineB.SetNet( dpPair.PrimP()->Net() );
346  dummyStartLineB.SetWidth( m_sizes.DiffPairWidth() );
347 
348  if( m_world->CheckColliding( &dummyStartLineA, ITEM::ANY_T )
349  || m_world->CheckColliding( &dummyStartLineB, ITEM::ANY_T ) )
350  {
351  ITEM_SET dummyStartSet;
352  NODE::ITEM_VECTOR highlightedItems;
353 
354  dummyStartSet.Add( dummyStartLineA );
355  dummyStartSet.Add( dummyStartLineB );
356  markViolations( m_world.get(), dummyStartSet, highlightedItems );
357 
358  for( ITEM* item : highlightedItems )
359  m_iface->HideItem( item );
360 
361  SetFailureReason( _( "The routing start point violates DRC." ) );
362  return false;
363  }
364  }
365 
366  return true;
367 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
Definition: pns_router.cpp:120
virtual void HideItem(ITEM *aItem)=0
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227
like PAD_PTH, but not plated
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:202
#define _(s)
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Represent a polyline (an zero-thickness chain of connected line segments).
class ZONE, managed by a footprint
Definition: typeinfo.h:94
static bool FindDpPrimitivePair(NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
SIZES_SETTINGS m_sizes
Definition: pns_router.h:240
ROUTER_MODE m_mode
Definition: pns_router.h:241
Definition: pad.h:57
wxString GetZoneName() const
Definition: zone.h:129
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:148
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:459

References _, PNS::ITEM_SET::Add(), PNS::ITEM::Anchor(), PNS::ITEM::ANY_T, SHAPE_LINE_CHAIN::Append(), PNS::ITEM::ARC_T, PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PNS::DIFF_PAIR_PLACER::FindDpPrimitivePair(), Format(), ZONE::GetZoneName(), PNS::ROUTER_IFACE::HideItem(), PNS::ITEM_SET::Items(), m_iface, m_mode, m_sizes, m_world, markViolations(), PNS::SIZES_SETTINGS::MinClearance(), PNS::ITEM::Net(), NPTH, PNS::ITEM::OfKind(), pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_ZONE_T, PNS::PNS_MODE_ROUTE_DIFF_PAIR, PNS::PNS_MODE_ROUTE_SINGLE, QueryHoverItems(), PNS::ITEM::SEGMENT_T, SetFailureReason(), PNS::ITEM::SetLayer(), PNS::ITEM::SetNet(), PNS::LINE::SetShape(), Settings(), PNS::LINE::SetWidth(), PNS::SIZES_SETTINGS::TrackWidth(), and EDA_ITEM::Type().

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

196  {
197  m_settings = aSettings;
198  }
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:239

References m_settings.

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

◆ Logger()

LOGGER * PNS::ROUTER::Logger ( )

Definition at line 792 of file pns_router.cpp.

793 {
794  return m_logger;
795 }
LOGGER * m_logger
Definition: pns_router.h:242

References m_logger.

Referenced by ROUTER_TOOL::saveRouterDebugLog().

◆ markViolations()

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

Definition at line 459 of file pns_router.cpp.

460 {
461  auto updateItem =
462  [&]( ITEM* currentItem, ITEM* itemToMark )
463  {
464  std::unique_ptr<ITEM> tmp( itemToMark->Clone() );
465 
466  int clearance;
467  bool removeOriginal = true;
468  bool holeOnly = ( ( itemToMark->Marker() & MK_HOLE )
469  && !( itemToMark->Marker() & MK_VIOLATION ) );
470 
471  if( holeOnly )
472  clearance = aNode->GetHoleClearance( currentItem, itemToMark );
473  else
474  clearance = aNode->GetClearance( currentItem, itemToMark );
475 
476  if( itemToMark->Layers().IsMultilayer() && !currentItem->Layers().IsMultilayer() )
477  tmp->SetLayer( currentItem->Layer() );
478 
479  if( itemToMark->Kind() == ITEM::SOLID_T )
480  {
481  if( holeOnly || !m_iface->IsFlashedOnLayer( itemToMark, currentItem->Layer() ) )
482  {
483  SOLID* solid = static_cast<SOLID*>( tmp.get() );
484 
485  if( solid->Hole() )
486  {
487  solid->SetShape( solid->Hole()->Clone() );
488 
489  // Leave the pad flashing around the highlighted hole
490  removeOriginal = false;
491  }
492  }
493  }
494 
495  m_iface->DisplayItem( tmp.get(), clearance );
496 
497  if( removeOriginal )
498  aRemoved.push_back( itemToMark );
499  };
500 
501  for( ITEM* item : aCurrent.Items() )
502  {
503  NODE::OBSTACLES obstacles;
504 
505  aNode->QueryColliding( item, obstacles, ITEM::ANY_T );
506 
507  if( item->OfKind( ITEM::LINE_T ) )
508  {
509  LINE* l = static_cast<LINE*>( item );
510 
511  if( l->EndsWithVia() )
512  {
513  VIA v( l->Via() );
514  aNode->QueryColliding( &v, obstacles, ITEM::ANY_T );
515  }
516  }
517 
518  for( OBSTACLE& obs : obstacles )
519  {
520  obs.m_item->Mark( obs.m_item->Marker() | MK_VIOLATION );
521  updateItem( item, obs.m_item );
522  }
523 
524  if( item->Kind() == ITEM::LINE_T )
525  {
526  LINE* line = static_cast<LINE*>( item );
527 
528  // Show clearance on any blocking obstacles
529  if( line->GetBlockingObstacle() )
530  updateItem( item, line->GetBlockingObstacle() );
531  }
532  }
533 }
virtual void DisplayItem(const ITEM *aItem, int aClearance, bool aEdit=false)=0
Normal via.
Definition: router_tool.cpp:70
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
virtual bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const =0
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:149

References PNS::ITEM::ANY_T, SHAPE::Clone(), PNS::ROUTER_IFACE::DisplayItem(), PNS::LINE::EndsWithVia(), PNS::LINE::GetBlockingObstacle(), PNS::NODE::GetClearance(), PNS::NODE::GetHoleClearance(), PNS::SOLID::Hole(), PNS::ROUTER_IFACE::IsFlashedOnLayer(), LAYER_RANGE::IsMultilayer(), PNS::ITEM_SET::Items(), PNS::ITEM::Layer(), PNS::ITEM::Layers(), PNS::ITEM::LINE_T, m_iface, PNS::MK_HOLE, PNS::MK_VIOLATION, PNS::NODE::QueryColliding(), PNS::SOLID::SetShape(), PNS::ITEM::SOLID_T, and PNS::LINE::Via().

Referenced by isStartingPointRoutable(), and updateView().

◆ Mode()

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

◆ Move()

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

Definition at line 427 of file pns_router.cpp.

428 {
429  if( m_logger )
430  m_logger->Log( LOGGER::EVT_MOVE, aP, endItem );
431 
432  switch( m_state )
433  {
434  case ROUTE_TRACK:
435  movePlacing( aP, endItem );
436  break;
437 
438  case DRAG_SEGMENT:
439  moveDragging( aP, endItem );
440  break;
441 
442  default:
443  break;
444  }
445 }
void moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:448
RouterState m_state
Definition: pns_router.h:225
void movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:572
LOGGER * m_logger
Definition: pns_router.h:242
void Log(EVENT_TYPE evt, const VECTOR2I &pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:64

References DRAG_SEGMENT, PNS::LOGGER::EVT_MOVE, PNS::LOGGER::Log(), m_logger, m_state, moveDragging(), movePlacing(), and ROUTE_TRACK.

Referenced by ROUTER_TOOL::handleLayerSwitch(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::onTrackViaSizeChanged(), 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 448 of file pns_router.cpp.

449 {
450  m_iface->EraseView();
451 
452  m_dragger->Drag( aP );
453  ITEM_SET dragged = m_dragger->Traces();
454 
455  updateView( m_dragger->CurrentNode(), dragged, true );
456 }
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:536
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
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 572 of file pns_router.cpp.

573 {
574  m_iface->EraseView();
575 
576  m_placer->Move( aP, aEndItem );
577  ITEM_SET current = m_placer->Traces();
578 
579  for( const ITEM* item : current.CItems() )
580  {
581  if( !item->OfKind( ITEM::LINE_T ) )
582  continue;
583 
584  const LINE* l = static_cast<const LINE*>( item );
585  int clearance = GetRuleResolver()->Clearance( item, nullptr );
586 
587  m_iface->DisplayItem( l, clearance );
588 
589  if( l->EndsWithVia() )
590  {
591  const VIA& via = l->Via();
592  int viaClearance = GetRuleResolver()->Clearance( &via, nullptr );
593  int holeClearance = GetRuleResolver()->HoleClearance( &via, nullptr );
594 
595  if( holeClearance + via.Drill() / 2 > viaClearance + via.Diameter() / 2 )
596  viaClearance = holeClearance + via.Drill() / 2 - via.Diameter() / 2;
597 
598  m_iface->DisplayItem( &l->Via(), viaClearance );
599  }
600  }
601 
602  //ITEM_SET tmp( &current );
603 
604  updateView( m_placer->CurrentNode( true ), current );
605 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:169
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
virtual int Clearance(const ITEM *aA, const ITEM *aB)=0
virtual void DisplayItem(const ITEM *aItem, int aClearance, bool aEdit=false)=0
Normal via.
Definition: router_tool.cpp:70
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:536
virtual int HoleClearance(const ITEM *aA, const ITEM *aB)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
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::RULE_RESOLVER::HoleClearance(), PNS::ITEM::LINE_T, m_iface, m_placer, updateView(), PNS::LINE::Via(), and via.

Referenced by Move().

◆ Placer()

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

Definition at line 205 of file pns_router.h.

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

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,
bool  aUseClearance = false 
)

Definition at line 120 of file pns_router.cpp.

121 {
122  if( m_state == IDLE || m_placer == nullptr )
123  {
124  if( aUseClearance )
125  {
126  SEGMENT test( SEG( aP, aP ), -1 );
127  test.SetWidth( 1 );
128  test.SetLayers( LAYER_RANGE::All() );
129  NODE::OBSTACLES obs;
130  m_world->QueryColliding( &test, obs, ITEM::ANY_T, -1, false );
131 
132  PNS::ITEM_SET ret;
133 
134  for( OBSTACLE& obstacle : obs )
135  ret.Add( obstacle.m_item, false );
136 
137  return ret;
138  }
139  else
140  {
141  return m_world->HitTest( aP );
142  }
143  }
144  else
145  return m_placer->CurrentNode()->HitTest( aP );
146 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
static LAYER_RANGE All()
Definition: pns_layerset.h:109
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227
RouterState m_state
Definition: pns_router.h:225
Definition: seg.h:40
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:149

References PNS::ITEM_SET::Add(), LAYER_RANGE::All(), PNS::ITEM::ANY_T, IDLE, m_placer, m_state, and m_world.

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

◆ RoutingInProgress()

◆ SetFailureReason()

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

◆ SetInterface()

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

Definition at line 840 of file pns_router.cpp.

841 {
842  m_iface = aIface;
843 }
ROUTER_IFACE * m_iface
Definition: pns_router.h:234

References m_iface.

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

◆ SetIterLimit()

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

Definition at line 178 of file pns_router.h.

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

References m_iterLimit.

◆ SetMode()

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

Definition at line 834 of file pns_router.cpp.

835 {
836  m_mode = aMode;
837 }
ROUTER_MODE m_mode
Definition: pns_router.h:241

References m_mode.

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

◆ SetOrthoMode()

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

Definition at line 825 of file pns_router.cpp.

826 {
827  if( !m_placer )
828  return;
829 
830  m_placer->SetOrthoMode( aEnable );
831 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230

References m_placer.

◆ Settings()

◆ SetVisibleViewArea()

void PNS::ROUTER::SetVisibleViewArea ( const BOX2I aExtents)
inline

Definition at line 209 of file pns_router.h.

209 { m_visibleViewArea = aExtents; }
BOX2I m_visibleViewArea
Definition: pns_router.h:224

References m_visibleViewArea.

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

◆ Sizes()

◆ StartDragging() [1/2]

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

Definition at line 149 of file pns_router.cpp.

150 {
151  return StartDragging( aP, ITEM_SET( aItem ), aDragMode );
152 }
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:149

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

156 {
157  if( aStartItems.Empty() )
158  return false;
159 
160  if( aStartItems.Count( ITEM::SOLID_T ) == aStartItems.Size() )
161  {
162  m_dragger = std::make_unique<COMPONENT_DRAGGER>( this );
164  }
165  else
166  {
167  if( aDragMode & DM_FREE_ANGLE )
169  else
170  m_forceMarkObstaclesMode = false;
171 
172  m_dragger = std::make_unique<DRAGGER>( this );
173  }
174 
175  m_dragger->SetMode( aDragMode );
176  m_dragger->SetWorld( m_world.get() );
177  m_dragger->SetLogger( m_logger );
178  m_dragger->SetDebugDecorator( m_iface->GetDebugDecorator() );
179 
180  if( m_logger )
181  m_logger->Clear();
182 
183  if( m_logger && aStartItems.Size() )
184  {
185  m_logger->Log( LOGGER::EVT_START_DRAG, aP, aStartItems[0] );
186  }
187 
188  if( m_dragger->Start( aP, aStartItems ) )
189  {
191  return true;
192  }
193  else
194  {
195  m_dragger.reset();
196  m_state = IDLE;
197  return false;
198  }
199 }
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231
RouterState m_state
Definition: pns_router.h:225
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
void Clear()
Definition: pns_logger.cpp:40
LOGGER * m_logger
Definition: pns_router.h:242
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
void Log(EVENT_TYPE evt, const VECTOR2I &pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:64
bool m_forceMarkObstaclesMode
Definition: pns_router.h:237

References PNS::LOGGER::Clear(), PNS::ITEM_SET::Count(), PNS::DM_FREE_ANGLE, DRAG_SEGMENT, PNS::ITEM_SET::Empty(), PNS::LOGGER::EVT_START_DRAG, PNS::ROUTER_IFACE::GetDebugDecorator(), IDLE, PNS::LOGGER::Log(), 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 370 of file pns_router.cpp.

371 {
372  if( !isStartingPointRoutable( aP, aStartItem, aLayer ) )
373  return false;
374 
375  m_forceMarkObstaclesMode = false;
376 
377  switch( m_mode )
378  {
380  m_placer = std::make_unique<LINE_PLACER>( this );
381  break;
382 
384  m_placer = std::make_unique<DIFF_PAIR_PLACER>( this );
385  break;
386 
388  m_placer = std::make_unique<MEANDER_PLACER>( this );
389  break;
390 
392  m_placer = std::make_unique<DP_MEANDER_PLACER>( this );
393  break;
394 
396  m_placer = std::make_unique<MEANDER_SKEW_PLACER>( this );
397  break;
398 
399  default:
400  return false;
401  }
402 
403  m_placer->UpdateSizes( m_sizes );
404  m_placer->SetLayer( aLayer );
405  m_placer->SetDebugDecorator( m_iface->GetDebugDecorator() );
406  m_placer->SetLogger( m_logger );
407 
408  if( m_logger )
409  {
410  m_logger->Clear();
411  m_logger->Log( LOGGER::EVT_START_ROUTE, aP, aStartItem );
412  }
413 
414  if( m_placer->Start( aP, aStartItem ) )
415  {
417  return true;
418  }
419  else
420  {
421  m_state = IDLE;
422  return false;
423  }
424 }
bool isStartingPointRoutable(const VECTOR2I &aWhere, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:202
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
RouterState m_state
Definition: pns_router.h:225
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
void Clear()
Definition: pns_logger.cpp:40
LOGGER * m_logger
Definition: pns_router.h:242
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
SIZES_SETTINGS m_sizes
Definition: pns_router.h:240
ROUTER_MODE m_mode
Definition: pns_router.h:241
void Log(EVENT_TYPE evt, const VECTOR2I &pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:64
bool m_forceMarkObstaclesMode
Definition: pns_router.h:237

References PNS::LOGGER::Clear(), PNS::LOGGER::EVT_START_ROUTE, PNS::ROUTER_IFACE::GetDebugDecorator(), IDLE, isStartingPointRoutable(), PNS::LOGGER::Log(), 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, and ROUTE_TRACK.

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

◆ StopRouting()

void PNS::ROUTER::StopRouting ( )

Definition at line 708 of file pns_router.cpp.

709 {
710  // Update the ratsnest with new changes
711 
712  if( m_placer )
713  {
714  std::vector<int> nets;
715  m_placer->GetModifiedNets( nets );
716 
717  // Update the ratsnest with new changes
718  for( int n : nets )
719  m_iface->UpdateNet( n );
720  }
721 
722  if( !RoutingInProgress() )
723  return;
724 
725  m_placer.reset();
726  m_dragger.reset();
727 
728  m_iface->EraseView();
729 
730  m_state = IDLE;
731  m_world->KillChildren();
732  m_world->ClearRanks();
733 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
std::unique_ptr< NODE > m_world
Definition: pns_router.h:227
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:231
virtual void UpdateNet(int aNetCode)=0
RouterState m_state
Definition: pns_router.h:225
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
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::MainLoop(), ROUTER_TOOL::performDragging(), and LENGTH_TUNER_TOOL::performTuning().

◆ SwitchLayer()

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

Definition at line 751 of file pns_router.cpp.

752 {
753  if( m_state == ROUTE_TRACK )
754  return m_placer->SetLayer( aLayer );
755 
756  return false;
757 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
RouterState m_state
Definition: pns_router.h:225

References m_placer, m_state, and ROUTE_TRACK.

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

◆ SyncWorld()

void PNS::ROUTER::SyncWorld ( )

Definition at line 92 of file pns_router.cpp.

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

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

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

◆ ToggleRounded()

void PNS::ROUTER::ToggleRounded ( )

Definition at line 807 of file pns_router.cpp.

808 {
810 
811  switch( m_settings->GetCornerMode() )
812  {
814  newMode = CORNER_MODE::ROUNDED_45;
815  break;
816 
817  default:
818  break;
819  }
820 
821  m_settings->SetCornerMode( newMode );
822 }
void SetCornerMode(CORNER_MODE aMode)
H/V/45 with filleted corners.
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:239
CORNER_MODE GetCornerMode() const
H/V/45 with mitered corners (default)

References PNS::ROUTING_SETTINGS::GetCornerMode(), m_settings, PNS::MITERED_45, PNS::ROUNDED_45, and PNS::ROUTING_SETTINGS::SetCornerMode().

Referenced by ROUTER_TOOL::performRouting().

◆ ToggleViaPlacement()

void PNS::ROUTER::ToggleViaPlacement ( )

Definition at line 760 of file pns_router.cpp.

761 {
762  if( m_state == ROUTE_TRACK )
763  {
764  bool toggle = !m_placer->IsPlacingVia();
765  m_placer->ToggleVia( toggle );
766  }
767 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
RouterState m_state
Definition: pns_router.h:225

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::handleLayerSwitch().

◆ UndoLastSegment()

void PNS::ROUTER::UndoLastSegment ( )

Definition at line 690 of file pns_router.cpp.

691 {
692  if( !RoutingInProgress() )
693  return;
694 
695  m_placer->UnfixRoute();
696 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
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 560 of file pns_router.cpp.

561 {
562  m_sizes = aSizes;
563 
564  // Change track/via size settings
565  if( m_state == ROUTE_TRACK )
566  {
567  m_placer->UpdateSizes( m_sizes );
568  }
569 }
std::unique_ptr< PLACEMENT_ALGO > m_placer
Definition: pns_router.h:230
RouterState m_state
Definition: pns_router.h:225
SIZES_SETTINGS m_sizes
Definition: pns_router.h:240

References m_placer, m_sizes, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::DpDimensionsDialog(), ROUTER_TOOL::handleLayerSwitch(), ROUTER_TOOL::onTrackViaSizeChanged(), 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 536 of file pns_router.cpp.

537 {
538  NODE::ITEM_VECTOR removed, added;
539  NODE::OBSTACLES obstacles;
540 
541  if( !aNode )
542  return;
543 
545  markViolations( aNode, aCurrent, removed );
546 
547  aNode->GetUpdatedItems( removed, added );
548 
549  for( ITEM* item : added )
550  {
551  int clearance = GetRuleResolver()->Clearance( item, nullptr );
552  m_iface->DisplayItem( item, clearance, aDragging );
553  }
554 
555  for( ITEM* item : removed )
556  m_iface->HideItem( item );
557 }
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:169
virtual void HideItem(ITEM *aItem)=0
virtual int Clearance(const ITEM *aA, const ITEM *aB)=0
virtual void DisplayItem(const ITEM *aItem, int aClearance, bool aEdit=false)=0
ROUTER_IFACE * m_iface
Definition: pns_router.h:234
Ignore collisions, mark obstacles.
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:149
ROUTER_MODE Mode() const
Definition: pns_router.h:131
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181
bool m_forceMarkObstaclesMode
Definition: pns_router.h:237
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:148
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:459

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

◆ VisibleViewArea()

const BOX2I& PNS::ROUTER::VisibleViewArea ( ) const
inline

Definition at line 210 of file pns_router.h.

210 { return m_visibleViewArea; }
BOX2I m_visibleViewArea
Definition: pns_router.h:224

References m_visibleViewArea.

Referenced by PNS::ALGO_BASE::VisibleViewArea().

Member Data Documentation

◆ m_dragger

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

◆ m_failureReason

wxString PNS::ROUTER::m_failureReason
private

Definition at line 245 of file pns_router.h.

Referenced by FailureReason(), and SetFailureReason().

◆ m_forceMarkObstaclesMode

bool PNS::ROUTER::m_forceMarkObstaclesMode = false
private

Definition at line 237 of file pns_router.h.

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

◆ m_iface

◆ m_iterLimit

int PNS::ROUTER::m_iterLimit
private

Definition at line 236 of file pns_router.h.

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

◆ m_lastNode

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 228 of file pns_router.h.

Referenced by ROUTER().

◆ m_logger

LOGGER* PNS::ROUTER::m_logger
private

Definition at line 242 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 241 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 239 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 232 of file pns_router.h.

◆ m_sizes

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

Definition at line 240 of file pns_router.h.

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

◆ m_state

◆ m_toolStatusbarName

wxString PNS::ROUTER::m_toolStatusbarName
private

Definition at line 244 of file pns_router.h.

◆ m_visibleViewArea

BOX2I PNS::ROUTER::m_visibleViewArea
private

Definition at line 224 of file pns_router.h.

Referenced by ROUTER(), SetVisibleViewArea(), and VisibleViewArea().

◆ m_world

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

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