38#include <geometry/rtree.h> 
   45#define MAGIC_TEARDROP_ZONE_ID 30000 
   58                                        std::vector<VECTOR2I>& aPoints, 
PCB_TRACK* aTrack )
 const 
   82        outline->
Append( pt.x, pt.y );
 
 
   97                                            std::vector<VECTOR2I>& aPoints, 
PCB_TRACK* aTrack )
 const 
  113        outline->
Append( pt.x, pt.y );
 
  123                          m_board->GetDesignSettings().m_MaxError );
 
 
  137                                                     std::vector<VECTOR2I>& aPoints,
 
  144    aCommit.
Added( new_teardrop );
 
  150        aCommit.
Added( new_teardrop_mask );
 
 
  161    std::vector<VECTOR2I> points;
 
 
  174                                        const std::vector<BOARD_ITEM*>* dirtyPadsAndVias,
 
  175                                        const std::set<PCB_TRACK*>* dirtyTracks )
 
  177    std::shared_ptr<CONNECTIVITY_DATA> connectivity = 
m_board->GetConnectivity();
 
  182                std::vector<PAD*>     connectedPads;
 
  183                std::vector<PCB_VIA*> connectedVias;
 
  185                connectivity->GetConnectedPadsAndVias( zone, &connectedPads, &connectedVias );
 
  187                for( 
PAD* 
pad : connectedPads )
 
  199                for( 
PCB_TRACK* track : connectivity->GetConnectedTracks( zone ) )
 
  210        if( zone->IsTeardropArea() && isStale( zone ) )
 
  214    m_board->BulkRemoveStaleTeardrops( aCommit );
 
 
  219                                        const std::vector<BOARD_ITEM*>* dirtyPadsAndVias,
 
  220                                        const std::set<PCB_TRACK*>* dirtyTracks,
 
  221                                        bool aForceFullUpdate )
 
  223    if( 
m_board->LegacyTeardrops() )
 
  232    if( aForceFullUpdate )
 
  236            if( zone->IsTeardropArea() )
 
  240        m_board->BulkRemoveStaleTeardrops( aCommit );
 
  243    std::shared_ptr<CONNECTIVITY_DATA> connectivity = 
m_board->GetConnectivity();
 
  250        std::vector<PAD*>     connectedPads;
 
  251        std::vector<PCB_VIA*> connectedVias;
 
  253        connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
 
  255        bool forceUpdate = aForceFullUpdate || dirtyTracks->contains( track );
 
  257        for( 
PAD* 
pad : connectedPads )
 
  263            VECTOR2I padSize = 
pad->GetSize( track->GetLayer() );
 
  264            int annularWidth = std::min( padSize.
x, padSize.
y );
 
  278            bool startHitsPad = 
pad->HitTest( track->GetStart(), 0, track->GetLayer() );
 
  279            bool endHitsPad = 
pad->HitTest( track->GetEnd(), 0, track->GetLayer() );
 
  282            if( startHitsPad && endHitsPad )
 
  296            if( !startHitsPad && !endHitsPad && track->HitTest( 
pad->GetPosition() ) )
 
  299                reversed.
SetStart( track->GetEnd() );
 
  302                reversed.
SetStart( track->GetStart() );
 
  313            int                 annularWidth = 
via->GetWidth( track->GetLayer() );
 
  327            bool startHitsVia = 
via->HitTest( track->GetStart() );
 
  328            bool endHitsVia = 
via->HitTest( track->GetEnd() );
 
  331            if( startHitsVia && endHitsVia )
 
  336                                    via->GetPosition() );
 
  342            if( !startHitsVia && !endHitsVia && track->HitTest( 
via->GetPosition() ) )
 
  345                reversed.
SetStart( track->GetEnd() );
 
  348                reversed.
SetStart( track->GetStart() );
 
  354    if( ( aForceFullUpdate || !dirtyTracks->empty() )
 
 
  373    m_board->BulkRemoveStaleTeardrops( aCommit );
 
 
  388        bool operator()(
ZONE* a, 
ZONE* b)
 const 
  398        td->CalculateOutlineArea();
 
  406        if( td->GetFirstLayer() != curr_layer )
 
  408            curr_layer = td->GetFirstLayer();
 
  412        td->SetAssignedPriority( priority_base++ );
 
 
  418                                             const std::set<PCB_TRACK*>* aTracks,
 
  419                                             bool aForceFullUpdate )
 
  421    std::shared_ptr<CONNECTIVITY_DATA> connectivity = 
m_board->GetConnectivity();
 
  430        std::vector<PCB_TRACK*>* sublist = grp.second;
 
  432        if( sublist->size() <= 1 )  
 
  442        std::sort( sublist->begin(), sublist->end(), compareLess );
 
  443        int min_width = sublist->front()->GetWidth();
 
  444        int max_width = sublist->back()->GetWidth();
 
  447        if( max_width == min_width )
 
  450        for( 
unsigned ii = 0; ii < sublist->size()-1; ii++ )
 
  453            int        track_len = (int) track->
GetLength();
 
  454            bool       track_needs_update = aForceFullUpdate || 
alg::contains( *aTracks, track );
 
  460            min_width = 
KiROUND( min_width * th );
 
  462            for( 
unsigned jj = ii+1; jj < sublist->size(); jj++ )
 
  467                if( min_width >= candidate->
GetWidth() )
 
  472                if( track_len <= candidate->
GetWidth() /2 )
 
  484                    pos = candidate->
GetEnd();
 
  491                if( !track_needs_update && 
alg::contains( *aTracks, candidate ) )
 
  495                bool                  existingPadOrVia = 
false;
 
  496                std::vector<PAD*>     connectedPads;
 
  497                std::vector<PCB_VIA*> connectedVias;
 
  499                connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
 
  501                for( 
PAD* 
pad : connectedPads )
 
  503                    if( 
pad->HitTest( pos ) )
 
  504                        existingPadOrVia = 
true;
 
  509                    if( 
via->HitTest( pos ) )
 
  510                        existingPadOrVia = 
true;
 
  513                if( existingPadOrVia )
 
 
constexpr EDA_IU_SCALE pcbIUScale
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
 
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
 
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
 
Information pertinent to a Pcbnew printed circuit board.
 
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
 
int GetSolderMaskExpansion() const
 
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
 
void SetEnd(const VECTOR2I &aEnd)
 
bool HasSolderMask() const
 
void SetStart(const VECTOR2I &aStart)
 
const VECTOR2I & GetStart() const
 
const VECTOR2I & GetEnd() const
 
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
 
virtual int GetWidth() const
 
Represent a set of closed polygons.
 
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
 
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
 
int NewOutline()
Creates a new empty polygon in the set and returns its index.
 
static int GetWidth(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
 
bool computeTeardropPolygon(const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aCorners, PCB_TRACK *aTrack, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos) const
Compute all teardrop points of the polygon shape.
 
TEARDROP_MANAGER(BOARD *aBoard, TOOL_MANAGER *aToolManager)
 
void UpdateTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks, bool aForceFullUpdate=false)
Update teardrops on a list of items.
 
void createAndAddTeardropWithMask(BOARD_COMMIT &aCommit, TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack)
Creates and adds a teardrop with optional mask to the board.
 
void setTeardropPriorities()
Set priority of created teardrops.
 
void AddTeardropsOnTracks(BOARD_COMMIT &aCommit, const std::set< PCB_TRACK * > *aTracks, bool aForceFullUpdate=false)
Add teardrop on tracks of different sizes connected by their end.
 
bool tryCreateTrackTeardrop(BOARD_COMMIT &aCommit, const TEARDROP_PARAMETERS &aParams, TEARDROP_VARIANT aTeardropVariant, PCB_TRACK *aTrack, BOARD_ITEM *aCandidate, const VECTOR2I &aPos)
Attempts to create a track-to-track teardrop.
 
TRACK_BUFFER m_trackLookupList
 
TEARDROP_PARAMETERS_LIST * m_prmsList
 
std::vector< ZONE * > m_createdTdList
 
ZONE * createTeardrop(TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack) const
Creates a teardrop (a ZONE item) from its polygonal shape, track netcode and layer.
 
void DeleteTrackToTrackTeardrops(BOARD_COMMIT &aCommit)
 
bool areItemsInSameZone(BOARD_ITEM *aPadOrVia, PCB_TRACK *aTrack) const
 
ZONE * createTeardropMask(TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack) const
 
friend class TEARDROP_PARAMETERS
 
void RemoveTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks)
Remove teardrops connected to any dirty pads, vias or tracks.
 
TOOL_MANAGER * m_toolManager
 
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
 
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
 
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
 
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
 
bool m_Enabled
Flag to enable teardrops.
 
static void GetNetcodeAndLayerFromIndex(int aIdx, int *aLayer, int *aNetcode)
 
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
 
static const ZONE_SETTINGS & GetDefaultSettings()
 
Handle a list of polygons defining a copper zone.
 
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
 
void SetLocalClearance(std::optional< int > aClearance)
 
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
 
void SetMinThickness(int aMinThickness)
 
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
 
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
 
SHAPE_POLY_SET * Outline()
 
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
 
int GetMinThickness() const
 
void SetIsFilled(bool isFilled)
 
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
 
void SetPadConnection(ZONE_CONNECTION aPadConnection)
 
void SetTeardropAreaType(TEARDROP_TYPE aType)
Set the type of teardrop if the zone is a teardrop area for non teardrop area, the type must be TEARD...
 
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
 
PCB_LAYER_ID GetFirstLayer() const
 
This file is part of the common library.
 
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
 
#define STRUCT_DELETED
flag indication structures to be erased
 
std::uint32_t EDA_ITEM_FLAGS
 
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
 
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
 
#define MAGIC_TEARDROP_ZONE_ID
 
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
 
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
 
VECTOR2< int32_t > VECTOR2I
 
@ FULL
pads are covered by copper