24using namespace std::placeholders;
90 settings->
m_PnsSettings = std::make_unique<ROUTING_SETTINGS>( settings,
"tools.pns" );
99 const std::vector<ITEM*> aAvoidItems )
103 static const int candidateCount = 5;
104 ITEM* prioritized[candidateCount];
107 for(
int i = 0; i < candidateCount; i++ )
109 prioritized[i] =
nullptr;
113 auto haveCandidates =
116 for(
ITEM* item : prioritized )
125 for(
bool useClearance : {
false,
true } )
131 if( !item->IsRoutable() )
151 else if( aNet <= 0 || item->Net() == aNet )
155 SEG::ecoord d = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
159 prioritized[2] = item;
163 if( item->Layers().Overlaps( tl ) && d < dist[0] )
165 prioritized[0] = item;
173 ( li->
Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
177 prioritized[3] = item;
181 if( item->Layers().Overlaps( tl ) && d < dist[1] )
183 prioritized[1] = item;
188 else if( item->OfKind(
ITEM::SOLID_T ) && item->IsFreePad() )
191 if( item->Shape()->Collide( aWhere ) )
193 prioritized[0] = item;
200 if( item->Layers().Overlaps( tl ) )
201 prioritized[4] = item;
205 if( haveCandidates() )
213 for(
ITEM* item : prioritized )
215 if( highContrast && item && !item->Layers().Overlaps( tl ) )
218 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
227 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d, tl: %d" ),
241 if( aNetcodes.size() > 0 && aEnabled )
249 for(
const int& netcode : aNetcodes )
251 if( currentNetCodes.find( netcode ) != currentNetCodes.end() )
298 pnss.SetSnapToTracks(
305 return pnss.GetSnapToTracks();
307 return pnss.GetSnapToPads();
376 ITEM* endItem =
nullptr;
380 for(
int net : nets )
403 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d" ),
423 switch( aItem->
Kind() )
426 return static_cast<SOLID*
>( aItem )->Pos();
429 return static_cast<VIA*
>( aItem )->Pos();
438 SEG::ecoord distA_sq = ( aP -
A ).SquaredEuclideanNorm();
439 SEG::ecoord distB_sq = ( aP -
B ).SquaredEuclideanNorm();
441 if( distA_sq < w_sq || distB_sq < w_sq )
443 return ( distA_sq < distB_sq ) ?
A :
B;
453 ARC* arc =
static_cast<ARC*
>( li );
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
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.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
virtual int GetTopLayer() const
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.
bool Overlaps(const LAYER_RANGE &aOther) const
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
const SHAPE * Shape() const override
Return the geometrical shape of the item.
const LINE & GetOriginalLine()
std::vector< ITEM * > & Items()
Base class for PNS router board items.
PnsKind Kind() const
Return the type (kind) of the item.
const LAYER_RANGE & Layers() const
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
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
void LoadSettings(ROUTING_SETTINGS *aSettings)
Changes routing settings to ones passed in the parameter.
const std::vector< int > GetCurrentNets() const
void SetInterface(ROUTER_IFACE *aIface)
bool IsPlacingVia() const
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
ROUTING_SETTINGS & Settings()
RouterState GetState() const
int GetCurrentLayer() const
PNS_MODE Mode() const
Set the routing mode.
void SetBoard(BOARD *aBoard)
void SetView(KIGFX::VIEW *aView)
void SetHostTool(PCB_TOOL_BASE *aTool)
bool IsItemVisible(const PNS::ITEM *aItem) const override
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override
VECTOR2I::extended_type ecoord
static SEG::ecoord Square(int a)
static constexpr extended_type ECOORD_MAX
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
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.