24using namespace std::placeholders;
104 settings->
m_PnsSettings = std::make_unique<ROUTING_SETTINGS>( settings,
"tools.pns" );
119 bool aIgnorePads,
const std::vector<ITEM*> aAvoidItems,
int aPermittedItemMask )
121 int tl = aLayer > 0 ? aLayer
122 :
m_router->GetInterface()->GetPNSLayerFromBoardLayer(
126 static const int candidateCount = 5;
127 ITEM* prioritized[candidateCount];
130 for(
int i = 0; i < candidateCount; i++ )
132 prioritized[i] =
nullptr;
136 auto haveCandidates =
139 for(
ITEM* item : prioritized )
148 for(
int slopRadius : { 0, maxSlopRadius } )
154 if( (item->Kind() & aPermittedItemMask ) == 0 )
157 if( !item->IsRoutable() )
160 if( !
m_iface->IsPNSCopperLayer( item->Layers().Start() ) )
163 if( !
m_iface->IsAnyLayerVisible( item->Layers() ) )
181 SEG::ecoord d = ( item->Shape( aLayer )->Centre() - aWhere ).SquaredEuclideanNorm();
185 prioritized[2] = item;
189 if( item->Layers().Overlaps( tl ) && d < dist[0] )
191 prioritized[0] = item;
199 ( li->
Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
203 prioritized[3] = item;
207 if( item->Layers().Overlaps( tl ) && d < dist[1] )
209 prioritized[1] = item;
214 else if( item->OfKind(
ITEM::SOLID_T ) && item->IsFreePad() )
217 if( item->Shape( -1 )->Collide( aWhere ) )
219 prioritized[0] = item;
226 if( item->Layers().Overlaps( tl ) )
227 prioritized[4] = item;
231 if( haveCandidates() )
239 for(
ITEM* item : prioritized )
241 if( highContrast && item && !item->Layers().Overlaps( tl ) )
244 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
253 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d, tl: %d" ),
266 std::set<int> netcodes;
269 netcodes.insert(
m_router->GetInterface()->GetNetCode( net ) );
271 if( netcodes.size() > 0 && aEnabled )
279 for(
const int& netcode : netcodes )
281 if( currentNetCodes.find( netcode ) != currentNetCodes.end() )
358 m_toolMgr->GetView()->SyncLayerVisibilityCache();
380 m_toolMgr->GetView()->SyncLayerVisibilityCache();
398 (
m_router->GetCurrentNets().empty() ||
m_router->GetCurrentNets().front() ==
nullptr ) )
410 layer =
m_router->GetCurrentLayer();
412 ITEM* endItem =
nullptr;
414 std::vector<NET_HANDLE> nets =
m_router->GetCurrentNets();
441 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d" ),
462 if( !aItem || !
m_iface->IsItemVisible( aItem ) )
467 switch( aItem->
Kind() )
474 return solid->
Anchor( 0 );
477 SEG::ecoord minDist = std::numeric_limits<SEG::ecoord>::max();
481 SEG::ecoord distSq = ( aP - anchorCandidate ).SquaredEuclideanNorm();
483 if( distSq < minDist )
494 return static_cast<VIA*
>( aItem )->Pos();
503 SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
504 SEG::ecoord distB_sq = ( aP -
B ).SquaredEuclideanNorm();
506 if( distA_sq < w_sq || distB_sq < w_sq )
508 return ( distA_sq < distB_sq ) ? A :
B;
518 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