24using namespace std::placeholders;
102 settings->
m_PnsSettings = std::make_unique<ROUTING_SETTINGS>( settings,
"tools.pns" );
111 bool aIgnorePads,
const std::vector<ITEM*> aAvoidItems )
113 int tl = aLayer > 0 ? aLayer
118 static const int candidateCount = 5;
119 ITEM* prioritized[candidateCount];
122 for(
int i = 0; i < candidateCount; i++ )
124 prioritized[i] =
nullptr;
128 auto haveCandidates =
131 for(
ITEM* item : prioritized )
140 for(
int slopRadius : { 0, maxSlopRadius } )
146 if( !item->IsRoutable() )
170 SEG::ecoord d = ( item->Shape( aLayer )->Centre() - aWhere ).SquaredEuclideanNorm();
174 prioritized[2] = item;
178 if( item->Layers().Overlaps( tl ) && d < dist[0] )
180 prioritized[0] = item;
188 ( li->
Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
192 prioritized[3] = item;
196 if( item->Layers().Overlaps( tl ) && d < dist[1] )
198 prioritized[1] = item;
203 else if( item->OfKind(
ITEM::SOLID_T ) && item->IsFreePad() )
206 if( item->Shape( -1 )->Collide( aWhere ) )
208 prioritized[0] = item;
215 if( item->Layers().Overlaps( tl ) )
216 prioritized[4] = item;
220 if( haveCandidates() )
226 bool highContrast = (
frame()->GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL );
228 for(
ITEM* item : prioritized )
230 if( highContrast && item && !item->Layers().Overlaps( tl ) )
233 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
242 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d, tl: %d" ),
255 std::set<int> netcodes;
260 if( netcodes.size() > 0 && aEnabled )
268 for(
const int& netcode : netcodes )
270 if( currentNetCodes.find( netcode ) != currentNetCodes.end() )
313 pnss.
SetSnapToPads( magSettings->
pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
314 || magSettings->
pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
317 || magSettings->
tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
397 ITEM* endItem =
nullptr;
425 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d" ),
451 switch( aItem->
Kind() )
458 return solid->
Anchor( 0 );
461 SEG::ecoord minDist = std::numeric_limits<SEG::ecoord>::max();
465 SEG::ecoord distSq = ( aP - anchorCandidate ).SquaredEuclideanNorm();
467 if( distSq < minDist )
478 return static_cast<VIA*
>( aItem )->Pos();
487 SEG::ecoord distA_sq = ( aP -
A ).SquaredEuclideanNorm();
488 SEG::ecoord distB_sq = ( aP -
B ).SquaredEuclideanNorm();
490 if( distA_sq < w_sq || distB_sq < w_sq )
492 return ( distA_sq < distB_sq ) ?
A :
B;
502 ARC* arc =
static_cast<ARC*
>( li );
constexpr EDA_IU_SCALE pcbIUScale
void SetUseGrid(bool aSnapToGrid)
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.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
virtual VECTOR2I Align(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
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
virtual int GetPNSLayerFromBoardLayer(PCB_LAYER_ID aLayer) const =0
virtual int GetNetCode(NET_HANDLE aNet) const =0
ROUTER_IFACE * GetInterface() const
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
void LoadSettings(ROUTING_SETTINGS *aSettings)
Changes routing settings to ones passed in the parameter.
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, int aSlopRadius=0)
void SetInterface(ROUTER_IFACE *aIface)
bool IsPlacingVia() const
ROUTING_SETTINGS & Settings()
RouterState GetState() const
int GetCurrentLayer() const
const std::vector< NET_HANDLE > GetCurrentNets() 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)
PNS_MODE Mode() const
Set the routing mode.
const std::vector< VECTOR2I > & AnchorPoints() const
virtual VECTOR2I Anchor(int aN) const override
void SetBoard(BOARD *aBoard)
bool IsPNSCopperLayer(int aPNSLayer) const override
void SetView(KIGFX::VIEW *aView)
virtual void SetHostTool(PCB_TOOL_BASE *aTool)
bool IsItemVisible(const PNS::ITEM *aItem) const override
bool IsAnyLayerVisible(const PNS_LAYER_RANGE &aLayer) const override
bool Overlaps(const PNS_LAYER_RANGE &aOther) const
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)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
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.
constexpr int mmToIU(double mm) const
VECTOR2< int32_t > VECTOR2I