24 using namespace std::placeholders;
38 using namespace KIGFX;
91 settings->
m_PnsSettings = std::make_unique<ROUTING_SETTINGS>( settings,
"tools.pns" );
100 const std::vector<ITEM*> aAvoidItems )
104 static const int candidateCount = 5;
105 ITEM* prioritized[candidateCount];
108 for(
int i = 0; i < candidateCount; i++ )
110 prioritized[i] =
nullptr;
116 if( candidates.
Empty() )
121 if( !item->IsRoutable() )
137 if( aNet <= 0 || item->Net() == aNet )
144 SEG::ecoord d = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
148 prioritized[2] = item;
152 if( item->Layers().Overlaps( tl ) && d < dist[0] )
154 prioritized[0] = item;
160 LINKED_ITEM* li = static_cast<LINKED_ITEM*>( item );
162 ( li->
Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
166 prioritized[3] = item;
170 if( item->Layers().Overlaps( tl ) && d < dist[1] )
172 prioritized[1] = item;
183 if( item->Layers().Overlaps( tl ) )
184 prioritized[4] = item;
192 for(
int i = 0; i < candidateCount; i++ )
194 ITEM* item = prioritized[i];
199 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
208 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d, tl: %d" ),
222 if( aNetcode >= 0 && aEnabled )
260 pnss.SetSnapToTracks(
267 return pnss.GetSnapToTracks();
269 return pnss.GetSnapToPads();
329 ITEM* endItem =
nullptr;
333 for(
int net : nets )
356 wxLogTrace( wxT(
"PNS" ), wxT(
"%s, layer : %d" ),
376 switch( aItem->
Kind() )
379 return static_cast<SOLID*>( aItem )->Pos();
382 return static_cast<VIA*>( aItem )->Pos();
387 LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
391 SEG::ecoord distA_sq = ( aP -
A ).SquaredEuclideanNorm();
392 SEG::ecoord distB_sq = ( aP -
B ).SquaredEuclideanNorm();
394 if( distA_sq < w_sq || distB_sq < w_sq )
396 return ( distA_sq < distB_sq ) ?
A :
B;
401 SEGMENT* seg = static_cast<SEGMENT*>( li );
406 ARC* arc = static_cast<ARC*>( li );
void SetHostTool(PCB_TOOL_BASE *aTool)
Base class for PNS router board items.
void SetView(KIGFX::VIEW *aView)
virtual int Layer() const
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
The Cairo implementation of the graphics abstraction layer.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
VECTOR2I::extended_type ecoord
bool IsPlacingVia() const
bool Overlaps(const LAYER_RANGE &aOther) const
const std::vector< int > GetCurrentNets() const
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
bool IsHighlightEnabled() const
Return current highlight setting.
static SEG::ecoord Square(int a)
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
virtual int Width() const
std::string KindStr() const
Returns the kind of the item, as string.
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
bool GetGridSnapping() const
static constexpr extended_type ECOORD_MAX
bool IsItemVisible(const PNS::ITEM *aItem) const override
virtual int GetTopLayer() const
Inactive layers are shown normally (no high-contrast mode)
PNS_MODE Mode() const
Set the routing mode.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
void SetSnapToPads(bool aSnap)
std::unique_ptr< PNS::ROUTING_SETTINGS > m_PnsSettings
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void SetInterface(ROUTER_IFACE *aIface)
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void SetBoard(BOARD *aBoard)
virtual VECTOR2I Anchor(int n) const
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
const SHAPE * Shape() const override
Return the geometrical shape of the item.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
void SetUseGrid(bool aSnapToGrid)
Ignore collisions, mark obstacles.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
PCBNEW_SETTINGS * GetPcbNewSettings() const
PnsKind Kind() const
Return the type (kind) of the item.
void LoadSettings(ROUTING_SETTINGS *aSettings)
Changes routing settings to ones passed in the parameter.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Push and Shove diff pair dimensions (gap) settings dialog.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS *aDispOptions)
ROUTING_SETTINGS & Settings()
RouterState GetState() const
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
const LAYER_RANGE & Layers() const
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
Abstract interface for drawing on a 2D-surface.
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override
int GetCurrentLayer() const