KiCad PCB EDA Suite
PNS::ROUTER Class Reference

#include <pns_router.h>

Public Types

enum  RouterState { IDLE , DRAG_SEGMENT , DRAG_COMPONENT , 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)
 
bool Move (const VECTOR2I &aP, ITEM *aItem)
 
bool Finish ()
 
bool ContinueFromEnd ()
 
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 ToggleCornerMode ()
 
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

bool movePlacing (const VECTOR2I &aP, ITEM *aItem)
 
bool 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)
 
bool getNearestRatnestAnchor (VECTOR2I &aOtherEnd, LAYER_RANGE &aOtherEndLayers)
 

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 
DRAG_COMPONENT 
ROUTE_TRACK 

Definition at line 118 of file pns_router.h.

119 {
120 IDLE,
124 };

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}
void SetMaximum()
Definition: box2.h:63
int m_iterLimit
Definition: pns_router.h:242
NODE * m_lastNode
Definition: pns_router.h:234
RouterState m_state
Definition: pns_router.h:231
ROUTER_IFACE * m_iface
Definition: pns_router.h:240
BOX2I m_visibleViewArea
Definition: pns_router.h:230
LOGGER * m_logger
Definition: pns_router.h:248
ROUTING_SETTINGS * m_settings
Definition: pns_router.h:245
ROUTER_MODE m_mode
Definition: pns_router.h:247
static ROUTER * theRouter
Definition: pns_router.cpp:58
@ PNS_MODE_ROUTE_SINGLE
Definition: pns_router.h:63

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

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

Member Function Documentation

◆ BreakSegment()

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

Definition at line 989 of file pns_router.cpp.

990{
991 NODE *node = m_world->Branch();
992
993 LINE_PLACER placer( this );
994
995 if( placer.SplitAdjacentSegments( node, aItem, aP ) )
996 {
997 CommitRouting( node );
998 }
999 else
1000 {
1001 delete node;
1002 }
1003}
void CommitRouting()
Definition: pns_router.cpp:840
std::unique_ptr< NODE > m_world
Definition: pns_router.h:233

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

Referenced by ROUTER_TOOL::breakTrack().

◆ ClearViewDecorations()

void PNS::ROUTER::ClearViewDecorations ( )

Definition at line 877 of file pns_router.cpp.

878{
880}
virtual void EraseView()=0

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

Referenced by ROUTER_TOOL::MainLoop(), ROUTER_TOOL::performDragging(), and ROUTER_TOOL::performRouting().

◆ 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:236

References m_placer, and m_world.

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

◆ CommitRouting() [1/2]

◆ CommitRouting() [2/2]

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

Definition at line 748 of file pns_router.cpp.

749{
750 if( m_state == ROUTE_TRACK && !m_placer->HasPlacedAnything() )
751 return;
752
753 NODE::ITEM_VECTOR removed;
754 NODE::ITEM_VECTOR added;
755 NODE::ITEM_VECTOR changed;
756
757 aNode->GetUpdatedItems( removed, added );
758
759 for( ITEM* item : removed )
760 {
761 bool is_changed = false;
762
763 // Items in remove/add that share the same parent are just updated versions
764 // We move them to the updated vector to preserve attributes such as UUID and pad data
765 if( item->Parent() )
766 {
767 for( NODE::ITEM_VECTOR::iterator added_it = added.begin();
768 added_it != added.end(); ++added_it )
769 {
770 if( ( *added_it )->Parent() && ( *added_it )->Parent() == item->Parent() )
771 {
772 changed.push_back( *added_it );
773 added.erase( added_it );
774 is_changed = true;
775 break;
776 }
777 }
778 }
779
780 if( !is_changed && !item->IsVirtual() )
781 m_iface->RemoveItem( item );
782 }
783
784 for( ITEM* item : added )
785 {
786 if( !item->IsVirtual() )
787 {
788 m_iface->AddItem( item );
789 }
790 }
791
792 for( ITEM* item : changed )
793 {
794 if( !item->IsVirtual() )
795 {
796 m_iface->UpdateItem( item );
797 }
798 }
799
800 m_iface->Commit();
801 m_world->Commit( aNode );
802}
std::vector< ITEM * > ITEM_VECTOR
Definition: pns_node.h:166
virtual void RemoveItem(ITEM *aItem)=0
virtual void UpdateItem(ITEM *aItem)=0
virtual void Commit()=0
virtual void AddItem(ITEM *aItem)=0

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

◆ ContinueFromEnd()

bool PNS::ROUTER::ContinueFromEnd ( )

Definition at line 545 of file pns_router.cpp.

546{
547 LINE_PLACER* placer = dynamic_cast<LINE_PLACER*>( Placer() );
548
549 if( placer == nullptr )
550 return false;
551
552 LINE current = placer->Trace();
553 int currentLayer = GetCurrentLayer();
554 VECTOR2I currentEnd = placer->CurrentEnd();
555 VECTOR2I otherEnd;
556 LAYER_RANGE otherEndLayers;
557
558 // Get the anchor nearest to the end of the trace the user is routing
559 if( !getNearestRatnestAnchor( otherEnd, otherEndLayers ) )
560 return false;
561
563
564 // Commit whatever we've fixed and restart routing from the other end
565 int nextLayer = otherEndLayers.Overlaps( currentLayer ) ? currentLayer : otherEndLayers.Start();
566
567 if( !StartRouting( otherEnd, &current, nextLayer ) )
568 return false;
569
570 // Attempt to route to our current position
571 Move( currentEnd, &current );
572
573 return true;
574}
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
int Start() const
Definition: pns_layerset.h:82
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
PLACEMENT_ALGO * Placer()
Definition: pns_router.h:208
bool getNearestRatnestAnchor(VECTOR2I &aOtherEnd, LAYER_RANGE &aOtherEndLayers)
Definition: pns_router.cpp:465
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:377
int GetCurrentLayer() const
Definition: pns_router.cpp:927
bool Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:443

References CommitRouting(), PNS::LINE_PLACER::CurrentEnd(), GetCurrentLayer(), getNearestRatnestAnchor(), Move(), LAYER_RANGE::Overlaps(), Placer(), LAYER_RANGE::Start(), StartRouting(), and PNS::LINE_PLACER::Trace().

Referenced by ROUTER_TOOL::performRouting().

◆ FailureReason()

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

Definition at line 206 of file pns_router.h.

206{ return m_failureReason; }
wxString m_failureReason
Definition: pns_router.h:251

References m_failureReason.

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

◆ Finish()

bool PNS::ROUTER::Finish ( )

Definition at line 507 of file pns_router.cpp.

508{
509 if( m_state != ROUTE_TRACK )
510 return false;
511
512 LINE_PLACER* placer = dynamic_cast<LINE_PLACER*>( Placer() );
513
514 if( placer == nullptr )
515 return false;
516
517 // Get our current line and position and nearest ratsnest to them if it exists
518 PNS::LINE current = placer->Trace();
519 VECTOR2I currentEnd = placer->CurrentEnd();
520 VECTOR2I otherEnd;
521 LAYER_RANGE otherEndLayers;
522
523 // Get the anchor nearest to the end of the trace the user is routing
524 if( !getNearestRatnestAnchor( otherEnd, otherEndLayers ) )
525 return false;
526
527 // Keep moving until we don't change position
528 VECTOR2I moveResultPoint;
529 do
530 {
531 moveResultPoint = Placer()->CurrentEnd();
532 Move( otherEnd, &current );
533 } while( Placer()->CurrentEnd() != moveResultPoint );
534
535 // If we've made it, fix the route and we're done
536 if( moveResultPoint == otherEnd && otherEndLayers.Overlaps( GetCurrentLayer() ) )
537 {
538 return FixRoute( otherEnd, &current, false );
539 }
540
541 return false;
542}
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:61
virtual const VECTOR2I & CurrentEnd() const =0
Function CurrentEnd()
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:805

References PNS::PLACEMENT_ALGO::CurrentEnd(), PNS::LINE_PLACER::CurrentEnd(), FixRoute(), GetCurrentLayer(), getNearestRatnestAnchor(), m_state, Move(), LAYER_RANGE::Overlaps(), Placer(), ROUTE_TRACK, and PNS::LINE_PLACER::Trace().

Referenced by ROUTER_TOOL::performRouting().

◆ FixRoute()

bool PNS::ROUTER::FixRoute ( const VECTOR2I aP,
ITEM aItem,
bool  aForceFinish = false 
)

Definition at line 805 of file pns_router.cpp.

806{
807 bool rv = false;
808
809 if( m_logger )
810 m_logger->Log( LOGGER::EVT_FIX, aP, aEndItem );
811
812 switch( m_state )
813 {
814 case ROUTE_TRACK:
815 rv = m_placer->FixRoute( aP, aEndItem, aForceFinish );
816 break;
817
818 case DRAG_SEGMENT:
819 case DRAG_COMPONENT:
820 rv = m_dragger->FixRoute();
821 break;
822
823 default:
824 break;
825 }
826
827 return rv;
828}
void Log(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), const ITEM *item=nullptr)
Definition: pns_logger.cpp:64
std::unique_ptr< DRAG_ALGO > m_dragger
Definition: pns_router.h:237

References DRAG_COMPONENT, DRAG_SEGMENT, PNS::LOGGER::EVT_FIX, PNS::LOGGER::Log(), m_dragger, m_logger, m_placer, m_state, and ROUTE_TRACK.

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

◆ FlipPosture()

void PNS::ROUTER::FlipPosture ( )

Definition at line 883 of file pns_router.cpp.

884{
885 if( m_state == ROUTE_TRACK )
886 {
887 m_placer->FlipPosture();
888 }
889}

References m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::performRouting().

◆ GetCurrentLayer()

int PNS::ROUTER::GetCurrentLayer ( ) const

Definition at line 927 of file pns_router.cpp.

928{
929 if( m_placer )
930 return m_placer->CurrentLayer();
931 else if( m_dragger )
932 return m_dragger->CurrentLayer();
933
934 return -1;
935}

References m_dragger, and m_placer.

Referenced by ContinueFromEnd(), Finish(), ROUTER_TOOL::handleLayerSwitch(), ROUTER_TOOL::onViaCommand(), 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 916 of file pns_router.cpp.

917{
918 if( m_placer )
919 return m_placer->CurrentNets();
920 else if( m_dragger )
921 return m_dragger->CurrentNets();
922
923 return std::vector<int>();
924}

References m_dragger, and m_placer.

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

◆ GetDragger()

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

Definition at line 136 of file pns_router.h.

136{ return m_dragger.get(); }

References m_dragger.

◆ GetInstance()

◆ GetInterface()

◆ GetIterLimit()

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

Definition at line 182 of file pns_router.h.

182{ return m_iterLimit; };

References m_iterLimit.

◆ getNearestRatnestAnchor()

bool PNS::ROUTER::getNearestRatnestAnchor ( VECTOR2I aOtherEnd,
LAYER_RANGE aOtherEndLayers 
)
private

Definition at line 465 of file pns_router.cpp.

466{
467 // Can't finish something with no connections
468 if( GetCurrentNets().empty() )
469 return false;
470
471 PNS::LINE_PLACER* placer = dynamic_cast<PNS::LINE_PLACER*>( Placer() );
472
473 if( placer == nullptr )
474 return false;
475
476 PNS::LINE trace = placer->Trace();
477 PNS::NODE* lastNode = placer->CurrentNode( true );
478 PNS::TOPOLOGY topo( lastNode );
479
480 // If the user has drawn a line, get the anchor nearest to the line end
481 if( trace.SegmentCount() > 0 )
482 return topo.NearestUnconnectedAnchorPoint( &trace, aOtherEnd, aOtherEndLayers );
483
484 // Otherwise, find the closest anchor to our start point
485
486 // Get joint from placer start item
487 JOINT* jt = lastNode->FindJoint( placer->CurrentStart(), placer->CurrentLayer(),
488 placer->CurrentNets()[0] );
489
490 if( !jt )
491 return false;
492
493 // Get unconnected item from joint
494 int anchor;
495 PNS::ITEM* it = topo.NearestUnconnectedItem( jt, &anchor );
496
497 if( !it )
498 return false;
499
500 aOtherEnd = it->Anchor( anchor );
501 aOtherEndLayers = it->Layers();
502
503 return true;
504}
Base class for PNS router board items.
Definition: pns_item.h:56
const LAYER_RANGE & Layers() const
Definition: pns_item.h:156
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:219
Single track placement algorithm.
const LINE Trace() const
Return the complete routed line.
const std::vector< int > CurrentNets() const override
Return the net code of currently routed track.
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent world state.
int CurrentLayer() const override
Return the layer of currently routed track.
const VECTOR2I & CurrentStart() const override
Return the current start of the line being placed.
int SegmentCount() const
Definition: pns_line.h:139
Keep the router "world" - i.e.
Definition: pns_node.h:155
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1181
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:916
static bool empty(const wxTextEntryBase *aCtrl)

References anchor, PNS::ITEM::Anchor(), PNS::LINE_PLACER::CurrentLayer(), PNS::LINE_PLACER::CurrentNets(), PNS::LINE_PLACER::CurrentNode(), PNS::LINE_PLACER::CurrentStart(), empty(), PNS::NODE::FindJoint(), GetCurrentNets(), PNS::ITEM::Layers(), PNS::TOPOLOGY::NearestUnconnectedAnchorPoint(), PNS::TOPOLOGY::NearestUnconnectedItem(), Placer(), PNS::LINE::SegmentCount(), and PNS::LINE_PLACER::Trace().

Referenced by ContinueFromEnd(), and Finish().

◆ GetRuleResolver()

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

Definition at line 172 of file pns_router.h.

172{ return m_iface->GetRuleResolver(); }
virtual RULE_RESOLVER * GetRuleResolver()=0

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

◆ GetWorld()

◆ IsPlacingVia()

bool PNS::ROUTER::IsPlacingVia ( ) const

Definition at line 944 of file pns_router.cpp.

945{
946 if( !m_placer )
947 return false;
948
949 return m_placer->IsPlacingVia();
950}

References m_placer.

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

◆ isStartingPointRoutable()

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

Definition at line 212 of file pns_router.cpp.

213{
214 if( Settings().AllowDRCViolations() )
215 return true;
216
218 {
220 {
221 SetFailureReason( _( "Diff pair gap is less than board minimum clearance." ) );
222 return false;
223 }
224 }
225
226 ITEM_SET candidates = QueryHoverItems( aWhere );
227
228 for( ITEM* item : candidates.Items() )
229 {
230 if( item->Parent() && item->Parent()->GetLayer() == Edge_Cuts )
231 {
232 // Edge cuts are put on all layers, but they're not *really* on all layers
233 continue;
234 }
235
236 if( !item->IsRoutable() && item->Layers().Overlaps( aLayer ) )
237 {
238 BOARD_ITEM* parent = item->Parent();
239
240 switch( parent->Type() )
241 {
242 case PCB_PAD_T:
243 {
244 PAD* pad = static_cast<PAD*>( parent );
245
246 if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
247 SetFailureReason( _( "Cannot start routing from a non-plated hole." ) );
248 }
249 break;
250
251 case PCB_ZONE_T:
252 case PCB_FP_ZONE_T:
253 {
254 ZONE* zone = static_cast<ZONE*>( parent );
255
256 if( !zone->GetZoneName().IsEmpty() )
257 {
258 SetFailureReason( wxString::Format( _( "Rule area '%s' disallows tracks." ),
259 zone->GetZoneName() ) );
260 }
261 else
262 {
263 SetFailureReason( _( "Rule area disallows tracks." ) );
264 }
265 }
266 break;
267
268 case PCB_TEXT_T:
269 case PCB_FP_TEXT_T:
270 case PCB_TEXTBOX_T:
271 case PCB_FP_TEXTBOX_T:
272 SetFailureReason( _( "Cannot start routing from a text item." ) );
273 break;
274
275 case PCB_SHAPE_T:
276 case PCB_FP_SHAPE_T:
277 SetFailureReason( _( "Cannot start routing from a graphic." ) );
278
279 default:
280 break;
281 }
282
283 return false;
284 }
285 }
286
287 VECTOR2I startPoint = aWhere;
288
290 {
291 SHAPE_LINE_CHAIN dummyStartSeg;
292 LINE dummyStartLine;
293
294 dummyStartSeg.Append( startPoint );
295 dummyStartSeg.Append( startPoint, true );
296
297 dummyStartLine.SetShape( dummyStartSeg );
298 dummyStartLine.SetLayer( aLayer );
299 dummyStartLine.SetNet( aStartItem ? aStartItem->Net() : 0 );
300 dummyStartLine.SetWidth( m_sizes.TrackWidth() );
301
302 if( m_world->CheckColliding( &dummyStartLine, ITEM::ANY_T ) )
303 {
304 ITEM_SET dummyStartSet( &dummyStartLine );
305 NODE::ITEM_VECTOR highlightedItems;
306
307 markViolations( m_world.get(), dummyStartSet, highlightedItems );
308
309 for( ITEM* item : highlightedItems )
310 m_iface->HideItem( item );
311
312 SetFailureReason( _( "The routing start point violates DRC." ) );
313 return false;
314 }
315 }
316 else if( m_mode == PNS_MODE_ROUTE_DIFF_PAIR )
317 {
318 if( !aStartItem )
319 {
320 SetFailureReason( _( "Cannot start a differential pair in the middle of nowhere." ) );
321 return false;
322 }
323
324 DP_PRIMITIVE_PAIR dpPair;
325 wxString errorMsg;
326
327 if( !DIFF_PAIR_PLACER::FindDpPrimitivePair( m_world.get(), startPoint, aStartItem, dpPair,
328 &errorMsg ) )
329 {
330 SetFailureReason( errorMsg );
331 return false;
332 }
333
334 SHAPE_LINE_CHAIN dummyStartSegA;
335 SHAPE_LINE_CHAIN dummyStartSegB;
336 LINE dummyStartLineA;
337 LINE dummyStartLineB;
338
339 dummyStartSegA.Append( dpPair.AnchorN() );
340 dummyStartSegA.Append( dpPair.AnchorN(), true );
341
342 dummyStartSegB.Append( dpPair.AnchorP() );
343 dummyStartSegB.Append( dpPair.AnchorP(), true );
344
345 dummyStartLineA.SetShape( dummyStartSegA );
346 dummyStartLineA.SetLayer( aLayer );
347 dummyStartLineA.SetNet( dpPair.PrimN()->Net() );
348 dummyStartLineA.SetWidth( m_sizes.DiffPairWidth() );
349
350 dummyStartLineB.SetShape( dummyStartSegB );
351 dummyStartLineB.SetLayer( aLayer );
352 dummyStartLineB.SetNet( dpPair.PrimP()->Net() );
353 dummyStartLineB.SetWidth( m_sizes.DiffPairWidth() );
354
355 if( m_world->CheckColliding( &dummyStartLineA, ITEM::ANY_T )
356 || m_world->CheckColliding( &dummyStartLineB, ITEM::ANY_T ) )
357 {
358 ITEM_SET dummyStartSet;
359 NODE::ITEM_VECTOR highlightedItems;
360
361 dummyStartSet.Add( dummyStartLineA );
362 dummyStartSet.Add( dummyStartLineB );
363 markViolations( m_world.get(), dummyStartSet, highlightedItems );
364
365 for( ITEM* item : highlightedItems )
366 m_iface->HideItem( item );
367
368 SetFailureReason( _( "The routing start point violates DRC." ) );
369 return false;
370 }
371 }
372
373 return true;
374}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
Definition: pad.h:58
static bool FindDpPrimitivePair(NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
virtual void HideItem(ITEM *aItem)=0
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:205
void markViolations(NODE *aNode, ITEM_SET &aCurrent, NODE::ITEM_VECTOR &aRemoved)
Definition: pns_router.cpp:589
SIZES_SETTINGS m_sizes
Definition: pns_router.h:246
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
Definition: pns_router.cpp:120
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
wxString GetZoneName() const
Definition: zone.h:117
#define _(s)
@ Edge_Cuts
Definition: layer_ids.h:113
@ PNS_MODE_ROUTE_DIFF_PAIR
Definition: pns_router.h:64
@ NPTH
like PAD_PTH, but not plated
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
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

References _, PNS::ITEM_SET::Add(), PNS::DP_PRIMITIVE_PAIR::AnchorN(), PNS::DP_PRIMITIVE_PAIR::AnchorP(), PNS::ITEM::ANY_T, SHAPE_LINE_CHAIN::Append(), PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), Edge_Cuts, 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, pad, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_ZONE_T, PNS::PNS_MODE_ROUTE_DIFF_PAIR, PNS::PNS_MODE_ROUTE_SINGLE, PNS::DP_PRIMITIVE_PAIR::PrimN(), PNS::DP_PRIMITIVE_PAIR::PrimP(), QueryHoverItems(), 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 198 of file pns_router.h.

199 {
200 m_settings = aSettings;
201 }

References m_settings.

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

◆ Logger()

LOGGER * PNS::ROUTER::Logger ( )

Definition at line 938 of file pns_router.cpp.

939{
940 return m_logger;
941}

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

590{
591 auto updateItem =
592 [&]( ITEM* currentItem, ITEM* itemToMark )
593 {
594 std::unique_ptr<ITEM> tmp( itemToMark->Clone() );
595
596 int clearance;
597 bool removeOriginal = true;
598 bool holeOnly = ( ( itemToMark->Marker() & MK_HOLE )
599 && !( itemToMark->Marker() & MK_VIOLATION ) );
600
601 if( holeOnly )
602 clearance = aNode->GetHoleClearance( currentItem, itemToMark );
603 else
604 clearance = aNode->GetClearance( currentItem, itemToMark );
605
606 if( itemToMark->Layers().IsMultilayer() && !currentItem->Layers().IsMultilayer() )
607 tmp->SetLayer( currentItem->Layer() );
608
609 if( itemToMark->Kind() == ITEM::SOLID_T )
610 {
611 if( holeOnly || !m_iface->IsFlashedOnLayer( itemToMark, currentItem->Layer() ) )
612 {
613 SOLID* solid = static_cast<SOLID*>( tmp.get() );
614
615 if( solid->Hole() )
616 {
617 solid->SetShape( solid->Hole()->Clone() );
618
619 // Leave the pad flashing around the highlighted hole
620 removeOriginal = false;
621 }
622 }
623
624 if( itemToMark->IsCompoundShapePrimitive() )
625 {
626 // We're only highlighting one (or more) of several primitives so we
627 // don't want all the other parts of the object to disappear
628 removeOriginal = false;
629 }
630 }
631
632 m_iface->DisplayItem( tmp.get(), clearance );
633
634 if( removeOriginal )
635 aRemoved.push_back( itemToMark );
636 };
637
638 for( ITEM* item : aCurrent.Items() )
639 {
640 NODE::OBSTACLES obstacles;
641
642 aNode->QueryColliding( item, obstacles, ITEM::ANY_T );
643
644 if( item->OfKind( ITEM::LINE_T ) )
645 {
646 LINE* l = static_cast<LINE*>( item );
647
648 if( l->EndsWithVia() )
649 {
650 VIA v( l->Via() );
651 aNode->QueryColliding( &v, obstacles, ITEM::ANY_T );
652 }
653 }
654
655 for( OBSTACLE& obs : obstacles )
656 {
657 obs.m_item->Mark( obs.m_item->Marker() | MK_VIOLATION );
658 updateItem( item, obs.m_item );
659 }
660
661 if( item->Kind() == ITEM::LINE_T )
662 {
663 LINE* line = static_cast<LINE*>( item );
664
665 // Show clearance on any blocking obstacles
666 if( line->GetBlockingObstacle() )
667 updateItem( item, line->GetBlockingObstacle() );
668 }
669 }
670}
@ SOLID_T
Definition: pns_item.h:63
@ LINE_T
Definition: pns_item.h:64
std::vector< OBSTACLE > OBSTACLES
Definition: pns_node.h:167
virtual void DisplayItem(const ITEM *aItem, int aClearance, bool aEdit=false)=0
virtual bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const =0
@ MK_VIOLATION
Definition: pns_item.h:42
@ MK_HOLE
Definition: pns_item.h:45
@ VIA
Normal via.
Definition: router_tool.cpp:82

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

◆ Move()

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

Definition at line 443 of file pns_router.cpp.

444{
445 if( m_logger )
446 m_logger->Log( LOGGER::EVT_MOVE, aP, endItem );
447
448 switch( m_state )
449 {
450 case ROUTE_TRACK:
451 return movePlacing( aP, endItem );
452
453 case DRAG_SEGMENT:
454 case DRAG_COMPONENT:
455 return moveDragging( aP, endItem );
456
457 default:
458 break;
459 }
460
461 return false;
462}
bool moveDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:577
bool movePlacing(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:710

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

Referenced by ContinueFromEnd(), Finish(), ROUTER_TOOL::handleLayerSwitch(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), and LENGTH_TUNER_TOOL::performTuning().

◆ moveDragging()

bool PNS::ROUTER::moveDragging ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 577 of file pns_router.cpp.

578{
580
581 bool ret = m_dragger->Drag( aP );
582 ITEM_SET dragged = m_dragger->Traces();
583
584 updateView( m_dragger->CurrentNode(), dragged, true );
585 return ret;
586}
void updateView(NODE *aNode, ITEM_SET &aCurrent, bool aDragging=false)
Definition: pns_router.cpp:673

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

Referenced by Move().

◆ movePlacing()

bool PNS::ROUTER::movePlacing ( const VECTOR2I aP,
ITEM aItem 
)
private

Definition at line 710 of file pns_router.cpp.

711{
713
714 bool ret = m_placer->Move( aP, aEndItem );
715 ITEM_SET current = m_placer->Traces();
716
717 for( const ITEM* item : current.CItems() )
718 {
719 if( !item->OfKind( ITEM::LINE_T ) )
720 continue;
721
722 const LINE* l = static_cast<const LINE*>( item );
723 int clearance = GetRuleResolver()->Clearance( item, nullptr );
724
725 m_iface->DisplayItem( l, clearance );
726
727 if( l->EndsWithVia() )
728 {
729 const VIA& via = l->Via();
730 int viaClearance = GetRuleResolver()->Clearance( &via, nullptr );
731 int holeClearance = GetRuleResolver()->HoleClearance( &via, nullptr );
732
733 if( holeClearance + via.Drill() / 2 > viaClearance + via.Diameter() / 2 )
734 viaClearance = holeClearance + via.Drill() / 2 - via.Diameter() / 2;
735
736 m_iface->DisplayItem( &l->Via(), viaClearance );
737 }
738 }
739
740 //ITEM_SET tmp( &current );
741
742 updateView( m_placer->CurrentNode( true ), current );
743
744 return ret;
745}
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:172
virtual int Clearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true)=0
virtual int HoleClearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true)=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(), via, and PNS::LINE::Via().

Referenced by Move().

◆ Placer()

◆ 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}
static LAYER_RANGE All()
Definition: pns_layerset.h:109
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
Definition: seg.h:42

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

985{
986 m_iface = aIface;
987}

References m_iface.

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

◆ SetIterLimit()

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

Definition at line 181 of file pns_router.h.

181{ m_iterLimit = aX; }

References m_iterLimit.

◆ SetMode()

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

Definition at line 978 of file pns_router.cpp.

979{
980 m_mode = aMode;
981}

References m_mode.

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

◆ SetOrthoMode()

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

Definition at line 969 of file pns_router.cpp.

970{
971 if( !m_placer )
972 return;
973
974 m_placer->SetOrthoMode( aEnable );
975}

References m_placer.

◆ Settings()

◆ SetVisibleViewArea()

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

Definition at line 212 of file pns_router.h.

212{ m_visibleViewArea = aExtents; }

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

References StartDragging().

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

◆ 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( Settings().Mode() == RM_MarkObstacles )
161 {
162 m_world->SetCollisionQueryScope( NODE::CQS_ALL_RULES );
163 }
164 else
165 {
166 m_world->SetCollisionQueryScope( NODE::CQS_IGNORE_HOLE_CLEARANCE );
167 }
168
169 if( aStartItems.Count( ITEM::SOLID_T ) == aStartItems.Size() )
170 {
171 m_dragger = std::make_unique<COMPONENT_DRAGGER>( this );
174 }
175 else
176 {
177 if( aDragMode & DM_FREE_ANGLE )
179 else
181
182 m_dragger = std::make_unique<DRAGGER>( this );
184 }
185
186 m_dragger->SetMode( aDragMode );
187 m_dragger->SetWorld( m_world.get() );
188 m_dragger->SetLogger( m_logger );
189 m_dragger->SetDebugDecorator( m_iface->GetDebugDecorator() );
190
191 if( m_logger )
192 m_logger->Clear();
193
194 if( m_logger && aStartItems.Size() )
195 {
196 m_logger->Log( LOGGER::EVT_START_DRAG, aP, aStartItems[0] );
197 }
198
199 if( m_dragger->Start( aP, aStartItems ) )
200 {
201 return true;
202 }
203 else
204 {
205 m_dragger.reset();
206 m_state = IDLE;
207 return false;
208 }
209}
void Clear()
Definition: pns_logger.cpp:40
@ EVT_START_DRAG
Definition: pns_logger.h:46
@ CQS_IGNORE_HOLE_CLEARANCE
check everything except hole2hole / hole2copper
Definition: pns_node.h:162
@ CQS_ALL_RULES
check all rules
Definition: pns_node.h:161
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
ROUTER_MODE Mode() const
Definition: pns_router.h:132
bool m_forceMarkObstaclesMode
Definition: pns_router.h:243
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ DM_FREE_ANGLE
Definition: pns_router.h:75

References PNS::LOGGER::Clear(), PNS::ITEM_SET::Count(), PNS::NODE::CQS_ALL_RULES, PNS::NODE::CQS_IGNORE_HOLE_CLEARANCE, PNS::DM_FREE_ANGLE, DRAG_COMPONENT, 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, Mode(), PNS::RM_MarkObstacles, Settings(), PNS::ITEM_SET::Size(), and PNS::ITEM::SOLID_T.

◆ StartRouting()

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

Definition at line 377 of file pns_router.cpp.

378{
379 if( Settings().Mode() == RM_MarkObstacles )
380 {
381 m_world->SetCollisionQueryScope( NODE::CQS_ALL_RULES );
382 }
383 else
384 {
385 m_world->SetCollisionQueryScope( NODE::CQS_IGNORE_HOLE_CLEARANCE );
386 }
387
388 if( !isStartingPointRoutable( aP, aStartItem, aLayer ) )
389 return false;
390
392
393 switch( m_mode )
394 {
396 m_placer = std::make_unique<LINE_PLACER>( this );
397 break;
398
400 m_placer = std::make_unique<DIFF_PAIR_PLACER>( this );
401 break;
402
404 m_placer = std::make_unique<MEANDER_PLACER>( this );
405 break;
406
408 m_placer = std::make_unique<DP_MEANDER_PLACER>( this );
409 break;
410
412 m_placer = std::make_unique<MEANDER_SKEW_PLACER>( this );
413 break;
414
415 default:
416 return false;
417 }
418
419 m_placer->UpdateSizes( m_sizes );
420 m_placer->SetLayer( aLayer );
421 m_placer->SetDebugDecorator( m_iface->GetDebugDecorator() );
422 m_placer->SetLogger( m_logger );
423
424 if( m_logger )
425 {
426 m_logger->Clear();
427 m_logger->Log( LOGGER::EVT_START_ROUTE, aP, aStartItem );
428 }
429
430 if( m_placer->Start( aP, aStartItem ) )
431 {
433 return true;
434 }
435 else
436 {
437 m_state = IDLE;
438 return false;
439 }
440}
@ EVT_START_ROUTE
Definition: pns_logger.h:45
bool isStartingPointRoutable(const VECTOR2I &aWhere, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:212
@ PNS_MODE_TUNE_DIFF_PAIR
Definition: pns_router.h:66
@ PNS_MODE_TUNE_SINGLE
Definition: pns_router.h:65
@ PNS_MODE_TUNE_DIFF_PAIR_SKEW
Definition: pns_router.h:67

References PNS::LOGGER::Clear(), PNS::NODE::CQS_ALL_RULES, PNS::NODE::CQS_IGNORE_HOLE_CLEARANCE, 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, m_world, Mode(), 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, PNS::RM_MarkObstacles, ROUTE_TRACK, and Settings().

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

◆ StopRouting()

void PNS::ROUTER::StopRouting ( )

Definition at line 849 of file pns_router.cpp.

850{
851 // Update the ratsnest with new changes
852
853 if( m_placer )
854 {
855 std::vector<int> nets;
856 m_placer->GetModifiedNets( nets );
857
858 // Update the ratsnest with new changes
859 for( int n : nets )
860 m_iface->UpdateNet( n );
861 }
862
863 if( !RoutingInProgress() )
864 return;
865
866 m_placer.reset();
867 m_dragger.reset();
868
870
871 m_state = IDLE;
872 m_world->KillChildren();
873 m_world->ClearRanks();
874}
virtual void UpdateNet(int aNetCode)=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 892 of file pns_router.cpp.

893{
894 if( m_state == ROUTE_TRACK )
895 return m_placer->SetLayer( aLayer );
896
897 return false;
898}

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}
virtual void SyncWorld(NODE *aNode)=0

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

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

◆ ToggleCornerMode()

void PNS::ROUTER::ToggleCornerMode ( )

Definition at line 953 of file pns_router.cpp.

954{
956
957 switch( m_settings->GetCornerMode() )
958 {
959 case DIRECTION_45::CORNER_MODE::MITERED_45: mode = DIRECTION_45::CORNER_MODE::ROUNDED_45; break;
960 case DIRECTION_45::CORNER_MODE::ROUNDED_45: mode = DIRECTION_45::CORNER_MODE::MITERED_90; break;
961 case DIRECTION_45::CORNER_MODE::MITERED_90: mode = DIRECTION_45::CORNER_MODE::ROUNDED_90; break;
962 case DIRECTION_45::CORNER_MODE::ROUNDED_90: mode = DIRECTION_45::CORNER_MODE::MITERED_45; break;
963 }
964
965 m_settings->SetCornerMode( mode );
966}
CORNER_MODE
Corner modes.
Definition: direction45.h:67
void SetCornerMode(DIRECTION_45::CORNER_MODE aMode)
DIRECTION_45::CORNER_MODE GetCornerMode() const

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

Referenced by ROUTER_TOOL::performRouting().

◆ ToggleViaPlacement()

void PNS::ROUTER::ToggleViaPlacement ( )

Definition at line 901 of file pns_router.cpp.

902{
903 if( m_state == ROUTE_TRACK )
904 {
905 bool toggle = !m_placer->IsPlacingVia();
906 m_placer->ToggleVia( toggle );
907
908 if( m_logger )
909 {
911 }
912 }
913}
@ EVT_TOGGLE_VIA
Definition: pns_logger.h:50

References PNS::LOGGER::EVT_TOGGLE_VIA, PNS::LOGGER::Log(), m_logger, m_placer, m_state, and ROUTE_TRACK.

Referenced by ROUTER_TOOL::handleLayerSwitch(), and ROUTER_TOOL::onViaCommand().

◆ UndoLastSegment()

void PNS::ROUTER::UndoLastSegment ( )

Definition at line 831 of file pns_router.cpp.

832{
833 if( !RoutingInProgress() )
834 return;
835
836 m_placer->UnfixRoute();
837}

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

699{
700 m_sizes = aSizes;
701
702 // Change track/via size settings
703 if( m_state == ROUTE_TRACK )
704 {
705 m_placer->UpdateSizes( m_sizes );
706 }
707}

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

674{
675 NODE::ITEM_VECTOR removed, added;
676 NODE::OBSTACLES obstacles;
677
678 if( !aNode )
679 return;
680
682 markViolations( aNode, aCurrent, removed );
683
684 aNode->GetUpdatedItems( removed, added );
685
686 for( ITEM* item : added )
687 {
689 int clearance = GetRuleResolver()->Clearance( item, nullptr );
690 m_iface->DisplayItem( item, clearance, aDragging );
691 }
692
693 for( ITEM* item : removed )
694 m_iface->HideItem( item );
695}
virtual void ClearCacheForItem(const ITEM *aItem)
Definition: pns_node.h:105

References PNS::RULE_RESOLVER::Clearance(), PNS::RULE_RESOLVER::ClearCacheForItem(), 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 213 of file pns_router.h.

213{ return m_visibleViewArea; }

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

Referenced by FailureReason(), and SetFailureReason().

◆ m_forceMarkObstaclesMode

bool PNS::ROUTER::m_forceMarkObstaclesMode = false
private

Definition at line 243 of file pns_router.h.

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

◆ m_iface

◆ m_iterLimit

int PNS::ROUTER::m_iterLimit
private

Definition at line 242 of file pns_router.h.

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

◆ m_lastNode

NODE* PNS::ROUTER::m_lastNode
private

Definition at line 234 of file pns_router.h.

Referenced by ROUTER().

◆ m_logger

LOGGER* PNS::ROUTER::m_logger
private

◆ m_mode

ROUTER_MODE PNS::ROUTER::m_mode
private

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

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

◆ m_shove

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

Definition at line 238 of file pns_router.h.

◆ m_sizes

SIZES_SETTINGS PNS::ROUTER::m_sizes
private

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

◆ m_visibleViewArea

BOX2I PNS::ROUTER::m_visibleViewArea
private

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