24using namespace std::placeholders;
103 settings->
m_PnsSettings = std::make_unique<ROUTING_SETTINGS>( settings,
"tools.pns" );
112 bool aIgnorePads,
const std::vector<ITEM*> aAvoidItems )
114 int tl = aLayer > 0 ? aLayer
115 :
m_router->GetInterface()->GetPNSLayerFromBoardLayer(
119 static const int candidateCount = 5;
120 ITEM* prioritized[candidateCount];
123 for(
int i = 0; i < candidateCount; i++ )
125 prioritized[i] =
nullptr;
129 auto haveCandidates =
132 for(
ITEM* item : prioritized )
141 for(
int slopRadius : { 0, maxSlopRadius } )
147 if( !item->IsRoutable() )
150 if( !
m_iface->IsPNSCopperLayer( item->Layers().Start() ) )
153 if( !
m_iface->IsAnyLayerVisible( item->Layers() ) )
171 SEG::ecoord d = ( item->Shape( aLayer )->Centre() - aWhere ).SquaredEuclideanNorm();
175 prioritized[2] = item;
179 if( item->Layers().Overlaps( tl ) && d < dist[0] )
181 prioritized[0] = item;
189 ( li->
Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
193 prioritized[3] = item;
197 if( item->Layers().Overlaps( tl ) && d < dist[1] )
199 prioritized[1] = item;
204 else if( item->OfKind(
ITEM::SOLID_T ) && item->IsFreePad() )
207 if( item->Shape( -1 )->Collide( aWhere ) )
209 prioritized[0] = item;
216 if( item->Layers().Overlaps( tl ) )
217 prioritized[4] = item;
221 if( haveCandidates() )
229 for(
ITEM* item : prioritized )
231 if( highContrast && item && !item->Layers().Overlaps( tl ) )
234 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
243 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d, tl: %d" ),
256 std::set<int> netcodes;
259 netcodes.insert(
m_router->GetInterface()->GetNetCode( net ) );
261 if( netcodes.size() > 0 && aEnabled )
269 for(
const int& netcode : netcodes )
271 if( currentNetCodes.find( netcode ) != currentNetCodes.end() )
348 m_toolMgr->GetView()->SyncLayerVisibilityCache();
370 m_toolMgr->GetView()->SyncLayerVisibilityCache();
388 (
m_router->GetCurrentNets().empty() ||
m_router->GetCurrentNets().front() ==
nullptr ) )
400 layer =
m_router->GetCurrentLayer();
402 ITEM* endItem =
nullptr;
404 std::vector<NET_HANDLE> nets =
m_router->GetCurrentNets();
431 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d" ),
452 if( !aItem || !
m_iface->IsItemVisible( aItem ) )
457 switch( aItem->
Kind() )
464 return solid->
Anchor( 0 );
467 SEG::ecoord minDist = std::numeric_limits<SEG::ecoord>::max();
471 SEG::ecoord distSq = ( aP - anchorCandidate ).SquaredEuclideanNorm();
473 if( distSq < minDist )
484 return static_cast<VIA*
>( aItem )->Pos();
493 SEG::ecoord distA_sq = ( aP -
A ).SquaredEuclideanNorm();
494 SEG::ecoord distB_sq = ( aP -
B ).SquaredEuclideanNorm();
496 if( distA_sq < w_sq || distB_sq < w_sq )
498 return ( distA_sq < distB_sq ) ?
A :
B;
508 ARC* arc =
static_cast<ARC*
>( li );
constexpr EDA_IU_SCALE pcbIUScale
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
Abstract interface for drawing on a 2D-surface.
bool GetGridSnapping() const
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
bool IsHighlightEnabled() const
Return current highlight setting.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
bool IsDragOrigin(const ITEM *aItem) const
Return true if aItem is a world item that moves with the drag: a link of the original line,...
Base class for PNS router board items.
const PNS_LAYER_RANGE & Layers() const
PnsKind Kind() const
Return the type (kind) of the item.
bool OfKind(int aKindMask) const
virtual VECTOR2I Anchor(int n) const
std::string KindStr() const
virtual int Width() const
Contain all persistent settings of the router, such as the mode, optimization effort,...
bool GetSnapToTracks() const
bool GetSnapToPads() const
void SetSnapToTracks(bool aSnap)
void SetSnapToPads(bool aSnap)
const std::vector< VECTOR2I > & AnchorPoints() const
virtual VECTOR2I Anchor(int aN) const override
VECTOR2I::extended_type ecoord
static SEG::ecoord Square(int a)
static constexpr extended_type ECOORD_MAX
a few functions useful in geometry calculations.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamp a vector to values that can be negated, respecting numeric limits of coordinates data type with...
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
The Cairo implementation of the graphics abstraction layer.
Push and Shove diff pair dimensions (gap) settings dialog.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ PNS_MODE_ROUTE_DIFF_PAIR
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
@ CAPTURE_CURSOR_IN_TRACK_TOOL
static std::vector< int > candidates(const SEGMENT_INDEX &aIndex, const SEG &aQuery, int aPadding)
VECTOR2< int32_t > VECTOR2I