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() ) )
167 else if(
m_router->GetInterface()->GetNetCode( aNet) <= 0 || item->Net() == aNet )
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() )
334 int tl =
m_router->GetInterface()->GetPNSLayerFromBoardLayer(
384 (
m_router->GetCurrentNets().empty() ||
m_router->GetCurrentNets().front() ==
nullptr ) )
396 layer =
m_router->GetCurrentLayer();
398 ITEM* endItem =
nullptr;
400 std::vector<NET_HANDLE> nets =
m_router->GetCurrentNets();
440 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d" ),
461 if( !aItem || !
m_iface->IsItemVisible( aItem ) )
466 switch( aItem->
Kind() )
473 return solid->
Anchor( 0 );
476 SEG::ecoord minDist = std::numeric_limits<SEG::ecoord>::max();
480 SEG::ecoord distSq = ( aP - anchorCandidate ).SquaredEuclideanNorm();
482 if( distSq < minDist )
493 return static_cast<VIA*
>( aItem )->Pos();
502 SEG::ecoord distA_sq = ( aP -
A ).SquaredEuclideanNorm();
503 SEG::ecoord distB_sq = ( aP -
B ).SquaredEuclideanNorm();
505 if( distA_sq < w_sq || distB_sq < w_sq )
507 return ( distA_sq < distB_sq ) ?
A :
B;
517 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_ITEMS.
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
const LINE & GetOriginalLine()
std::vector< ITEM * > & Items()
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
bool ContainsLink(const LINKED_ITEM *aItem) 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< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
@ DIRECT
Unconstrained point-to-point.
VECTOR2< T > GetVectorSnapped90(const VECTOR2< T > &aVec)
Snap a vector onto the nearest horizontal or vertical line.
PCB_LAYER_ID
A quick note on layer IDs:
The Cairo implementation of the graphics abstraction layer.
Push and Shove diff pair dimensions (gap) settings dialog.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
@ CAPTURE_CURSOR_IN_TRACK_TOOL
VECTOR2< int32_t > VECTOR2I