KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TEARDROP_MANAGER Class Reference

TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) having: 2 points on the track connected to a pad or via 2 points on the outline of this pad or via 1 point near the pad/via position (calculated in order to have this pad/via position inside the area The 2 sides joining a point on the track to the corresponding point on the pad/via outline can be a straight line or a curved shape (defined from a Bezier curve) This curved shape is built by segments (3 to 10) from this Bezier curve Because one cannot build a suitable shape for a custom pad, custom pads are ignored. More...

#include <teardrop.h>

Public Types

enum  TEARDROP_VARIANT { TD_TYPE_PADVIA , TD_TYPE_TRACKEND }
 

Public Member Functions

 TEARDROP_MANAGER (BOARD *aBoard, TOOL_MANAGER *aToolManager)
 
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.
 
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 AddTeardropsOnTracks (BOARD_COMMIT &aCommit, const std::set< PCB_TRACK * > *aTracks, bool aForceFullUpdate=false)
 Add teardrop on tracks of different sizes connected by their end.
 
void DeleteTrackToTrackTeardrops (BOARD_COMMIT &aCommit)
 
void BuildTrackCaches ()
 

Static Public Member Functions

static int GetWidth (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
 
static bool IsRound (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
 

Private Member Functions

bool areItemsInSameZone (BOARD_ITEM *aPadOrVia, PCB_TRACK *aTrack) const
 
void computeCurvedForRoundShape (const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aPoly, PCB_LAYER_ID aLayer, int aTrackHalfWidth, const VECTOR2D &aTrackDir, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos, std::vector< VECTOR2I > &aPts) const
 Compute the curve part points for teardrops connected to a round shape The Bezier curve control points are optimized for a round pad/via shape, and do not give a good curve shape for other pad shapes use m_m_heightRatio.
 
void computeCurvedForRectShape (const TEARDROP_PARAMETERS &aParams, std::vector< VECTOR2I > &aPoly, int aTdWidth, int aTrackHalfWidth, std::vector< VECTOR2I > &aPts, const VECTOR2I &aIntersection) const
 Compute the curve part points for teardrops connected to a rectangular/polygonal shape The Bezier curve control points are not optimized for a special shape, so use computeCurvedForRoundShape() for round shapes for better result.
 
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.
 
bool computeAnchorPoints (const TEARDROP_PARAMETERS &aParams, PCB_LAYER_ID aLayer, BOARD_ITEM *aItem, const VECTOR2I &aPos, std::vector< VECTOR2I > &aPts) const
 Compute the 2 points on pad/via of the teardrop shape.
 
PCB_TRACKfindTouchingTrack (EDA_ITEM_FLAGS &aMatchType, PCB_TRACK *aTrackRef, const VECTOR2I &aEndPoint) const
 Find a track connected to the end of another track.
 
ZONEcreateTeardrop (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.
 
ZONEcreateTeardropMask (TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack) const
 
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.
 
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.
 
void setTeardropPriorities ()
 Set priority of created teardrops.
 
bool findAnchorPointsOnTrack (const TEARDROP_PARAMETERS &aParams, VECTOR2I &aStartPoint, VECTOR2I &aEndPoint, VECTOR2I &aIntersection, PCB_TRACK *&aTrack, BOARD_ITEM *aOther, const VECTOR2I &aOtherPos, int *aEffectiveTeardropLen) const
 

Private Attributes

int m_tolerance
 
BOARDm_board
 
TOOL_MANAGERm_toolManager
 
TEARDROP_PARAMETERS_LISTm_prmsList
 
DRC_RTREE m_tracksRTree
 
TRACK_BUFFER m_trackLookupList
 
std::vector< ZONE * > m_createdTdList
 

Friends

class TEARDROP_PARAMETERS
 

Detailed Description

TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) having: 2 points on the track connected to a pad or via 2 points on the outline of this pad or via 1 point near the pad/via position (calculated in order to have this pad/via position inside the area The 2 sides joining a point on the track to the corresponding point on the pad/via outline can be a straight line or a curved shape (defined from a Bezier curve) This curved shape is built by segments (3 to 10) from this Bezier curve Because one cannot build a suitable shape for a custom pad, custom pads are ignored.

Size of area (height and length) are defined from the pad/via size or for pads having a size X and a size Y, the smallest of X,Y size.

Definition at line 94 of file teardrop.h.

Member Enumeration Documentation

◆ TEARDROP_VARIANT

Enumerator
TD_TYPE_PADVIA 
TD_TYPE_TRACKEND 

Definition at line 99 of file teardrop.h.

Constructor & Destructor Documentation

◆ TEARDROP_MANAGER()

TEARDROP_MANAGER::TEARDROP_MANAGER ( BOARD * aBoard,
TOOL_MANAGER * aToolManager )

Definition at line 48 of file teardrop.cpp.

References m_board, m_prmsList, m_tolerance, and m_toolManager.

Member Function Documentation

◆ AddTeardropsOnTracks()

◆ areItemsInSameZone()

bool TEARDROP_MANAGER::areItemsInSameZone ( BOARD_ITEM * aPadOrVia,
PCB_TRACK * aTrack ) const
private
Returns
true if the given aViaPad + aTrack is located inside a zone of the same netname

Definition at line 116 of file teardrop_utils.cpp.

References BOARD_ITEM::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), EDA_ITEM::GetPosition(), m_board, NONE, pad, PCB_PAD_T, and EDA_ITEM::Type().

Referenced by UpdateTeardrops().

◆ BuildTrackCaches()

void TEARDROP_MANAGER::BuildTrackCaches ( )

◆ computeAnchorPoints()

bool TEARDROP_MANAGER::computeAnchorPoints ( const TEARDROP_PARAMETERS & aParams,
PCB_LAYER_ID aLayer,
BOARD_ITEM * aItem,
const VECTOR2I & aPos,
std::vector< VECTOR2I > & aPts ) const
private

Compute the 2 points on pad/via of the teardrop shape.

Returns
false if these 2 points are not found
Parameters
aLayeris the layer for the teardrop
aItemis the via/pad/track used to build the teardrop
aPosis the via/pad position, or track start or end teardrop height = aViaPad size * aHeightRatio
aPtsis the buffer that contains initial and final teardrop polygonal shape in aPts: A and B ( aPts[0] and aPts[1] ) are points on the track C and E ( aPts[2] and aPts[4] ) are points on the aViaPad D ( aPts[3] ) is midpoint behind the aViaPad centre m_heightRatio is the factor to calculate the aViaPad teardrop size

Definition at line 322 of file teardrop_utils.cpp.

References SHAPE_POLY_SET::Append(), SHAPE_LINE_CHAIN::Area(), SHAPE_POLY_SET::BooleanIntersection(), BuildConvexHull(), SHAPE_LINE_CHAIN::CPoints(), ERROR_INSIDE, VECTOR2< T >::EuclideanNorm(), GetWidth(), IsRound(), KiROUND(), TEARDROP_PARAMETERS::m_BestWidthRatio, m_board, TEARDROP_PARAMETERS::m_TdMaxWidth, SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::NewOutline(), next(), SHAPE_POLY_SET::Outline(), pad, PCB_PAD_T, SHAPE_POLY_SET::Rotate(), TEARDROP_PARAMETERS, TransformCircleToPolygon(), and EDA_ITEM::Type().

Referenced by computeTeardropPolygon().

◆ computeCurvedForRectShape()

void TEARDROP_MANAGER::computeCurvedForRectShape ( const TEARDROP_PARAMETERS & aParams,
std::vector< VECTOR2I > & aPoly,
int aTdWidth,
int aTrackHalfWidth,
std::vector< VECTOR2I > & aPts,
const VECTOR2I & aIntersection ) const
private

Compute the curve part points for teardrops connected to a rectangular/polygonal shape The Bezier curve control points are not optimized for a special shape, so use computeCurvedForRoundShape() for round shapes for better result.

Definition at line 276 of file teardrop_utils.cpp.

References VECTOR2< T >::EuclideanNorm(), BEZIER_POLY::GetPoly(), m_board, VECTOR2< T >::Resize(), and TEARDROP_PARAMETERS.

Referenced by computeTeardropPolygon().

◆ computeCurvedForRoundShape()

void TEARDROP_MANAGER::computeCurvedForRoundShape ( const TEARDROP_PARAMETERS & aParams,
std::vector< VECTOR2I > & aPoly,
PCB_LAYER_ID aLayer,
int aTrackHalfWidth,
const VECTOR2D & aTrackDir,
BOARD_ITEM * aOther,
const VECTOR2I & aOtherPos,
std::vector< VECTOR2I > & aPts ) const
private

Compute the curve part points for teardrops connected to a round shape The Bezier curve control points are optimized for a round pad/via shape, and do not give a good curve shape for other pad shapes use m_m_heightRatio.

Definition at line 213 of file teardrop_utils.cpp.

References BEZIER_POLY::GetPoly(), GetWidth(), KiROUND(), SEG::Length(), TEARDROP_PARAMETERS::m_BestWidthRatio, m_board, TEARDROP_PARAMETERS::m_TdMaxWidth, radius, TEARDROP_PARAMETERS, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by computeTeardropPolygon().

◆ computeTeardropPolygon()

bool TEARDROP_MANAGER::computeTeardropPolygon ( const TEARDROP_PARAMETERS & aParams,
std::vector< VECTOR2I > & aCorners,
PCB_TRACK * aTrack,
BOARD_ITEM * aOther,
const VECTOR2I & aOtherPos ) const
private

◆ createAndAddTeardropWithMask()

void TEARDROP_MANAGER::createAndAddTeardropWithMask ( BOARD_COMMIT & aCommit,
TEARDROP_VARIANT aTeardropVariant,
std::vector< VECTOR2I > & aPoints,
PCB_TRACK * aTrack )
private

Creates and adds a teardrop with optional mask to the board.

Parameters
aCommitthe board commit to add the teardrop to
aTeardropVariant= variant of the teardrop( attached to a pad, or a track end )
aPointsis the polygonal shape
aTrackis the track connected to the starting points of the teardrop

Definition at line 135 of file teardrop.cpp.

References COMMIT::Added(), BULK_INSERT, createTeardrop(), createTeardropMask(), BOARD_ITEM::GetLayer(), PCB_TRACK::HasSolderMask(), IsExternalCopperLayer(), m_board, and m_createdTdList.

Referenced by tryCreateTrackTeardrop().

◆ createTeardrop()

ZONE * TEARDROP_MANAGER::createTeardrop ( TEARDROP_VARIANT aTeardropVariant,
std::vector< VECTOR2I > & aPoints,
PCB_TRACK * aTrack ) const
private

Creates a teardrop (a ZONE item) from its polygonal shape, track netcode and layer.

Parameters
aTeardropVariant= variant of the teardrop( attached to a pad, or a track end )
aPointsis the polygonal shape
aTrackis the track connected to the starting points of the teardrop (mainly for net info)

Definition at line 57 of file teardrop.cpp.

References SHAPE_POLY_SET::Append(), ZONE::CalculateFilledArea(), ZONE_SETTINGS::ExportSetting(), FULL, ZONE_SETTINGS::GetDefaultSettings(), BOARD_ITEM::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), INVISIBLE_BORDER, m_board, NEVER, SHAPE_POLY_SET::NewOutline(), ZONE::Outline(), pcbIUScale, ZONE::SetBorderDisplayStyle(), ZONE::SetFilledPolysList(), ZONE::SetIsFilled(), ZONE::SetIslandRemovalMode(), ZONE::SetLayer(), ZONE::SetLocalClearance(), ZONE::SetMinThickness(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE::SetPadConnection(), ZONE::SetTeardropAreaType(), TD_TRACKEND, TD_TYPE_PADVIA, and TD_VIAPAD.

Referenced by createAndAddTeardropWithMask().

◆ createTeardropMask()

◆ DeleteTrackToTrackTeardrops()

void TEARDROP_MANAGER::DeleteTrackToTrackTeardrops ( BOARD_COMMIT & aCommit)

Definition at line 365 of file teardrop.cpp.

References m_board, STRUCT_DELETED, and TD_TRACKEND.

Referenced by DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow().

◆ findAnchorPointsOnTrack()

bool TEARDROP_MANAGER::findAnchorPointsOnTrack ( const TEARDROP_PARAMETERS & aParams,
VECTOR2I & aStartPoint,
VECTOR2I & aEndPoint,
VECTOR2I & aIntersection,
PCB_TRACK *& aTrack,
BOARD_ITEM * aOther,
const VECTOR2I & aOtherPos,
int * aEffectiveTeardropLen ) const
private
Returns
true if a point on a track can be found as anchor point of a teardrop
Parameters
aStartPointis the start point of the track found (always inside the teardrop)
aEndPointis the start point of the track found (always outside the teardrop)
aIntersectionis the point where the track's centerline meets the pad/via edge
aTrackis the track connected to the pad/via used to search a anchor point this reference can be modified if a connected track to the initial track is selected
aOtheris the via/pad/track used to build the teardrop
aOtherPosis the via/pad position, or track start or end
aEffectiveTeardropLenis the actual teardrop length, that can be smaller than expected if the connected track length is too small
aFollowTracks= true to use a connected track to aTrack if aTrack is too small
aTrackLookupListis the list of tracks to explore if aFollowTracks = true m_lengthRatio is the length of teardrop (ratio pad/via size/teardrop len)

Definition at line 505 of file teardrop_utils.cpp.

References SHAPE_ARC::ConvertToPolyline(), SHAPE_LINE_CHAIN::CPoint(), end, ERROR_INSIDE, findTouchingTrack(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_TRACK::GetLength(), PCB_ARC::GetMid(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), GetWidth(), EDA_ITEM::HitTest(), SHAPE_LINE_CHAIN::Intersect(), IsRound(), KiROUND(), TEARDROP_PARAMETERS::m_AllowUseTwoTracks, TEARDROP_PARAMETERS::m_BestLengthRatio, m_board, TEARDROP_PARAMETERS::m_TdMaxLen, SHAPE_POLY_SET::Outline(), PCB_ARC_T, PCB_PAD_T, SHAPE_LINE_CHAIN::PointCount(), radius, SHAPE_ARC::Reverse(), SHAPE_LINE_CHAIN::SetClosed(), STARTPOINT, TEARDROP_PARAMETERS, TransformCircleToPolygon(), and EDA_ITEM::Type().

Referenced by computeTeardropPolygon().

◆ findTouchingTrack()

PCB_TRACK * TEARDROP_MANAGER::findTouchingTrack ( EDA_ITEM_FLAGS & aMatchType,
PCB_TRACK * aTrackRef,
const VECTOR2I & aEndPoint ) const
private

Find a track connected to the end of another track.

Returns
a reference to the touching track (or nullptr)
Parameters
aMatchTypereturns the end point id 0, STARTPOINT, ENDPOINT
aTrackRefis the reference track
aEndpointis the coordinate to test
tracksRTreeis an RTree containing the available tracks

Definition at line 153 of file teardrop_utils.cpp.

References BOARD_ITEM::GetLayer(), and m_tracksRTree.

Referenced by findAnchorPointsOnTrack().

◆ GetWidth()

◆ IsRound()

◆ RemoveTeardrops()

void TEARDROP_MANAGER::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.

They need to be removed before being rebuilt.

NB: this must be called BEFORE the connectivity is updated for the change in question.

Definition at line 173 of file teardrop.cpp.

References alg::contains(), m_board, pad, STRUCT_DELETED, and via.

Referenced by BOARD_COMMIT::Push().

◆ setTeardropPriorities()

void TEARDROP_MANAGER::setTeardropPriorities ( )
private

Set priority of created teardrops.

smaller have bigger priority

Definition at line 377 of file teardrop.cpp.

References ZONE::GetFirstLayer(), ZONE::GetOutlineArea(), m_createdTdList, and MAGIC_TEARDROP_ZONE_ID.

Referenced by UpdateTeardrops().

◆ tryCreateTrackTeardrop()

bool TEARDROP_MANAGER::tryCreateTrackTeardrop ( BOARD_COMMIT & aCommit,
const TEARDROP_PARAMETERS & aParams,
TEARDROP_MANAGER::TEARDROP_VARIANT aTeardropVariant,
PCB_TRACK * aTrack,
BOARD_ITEM * aCandidate,
const VECTOR2I & aPos )
private

Attempts to create a track-to-track teardrop.

Parameters
aCommitthe board commit to add the teardrop to
aParamsthe teardrop parameters
aTeardropVariant= variant of the teardrop( attached to a pad, or a track end )
aTrackthe source track
aCandidatethe target item
aPosthe connection position
Returns
true if teardrop was created successfully

Definition at line 155 of file teardrop.cpp.

References computeTeardropPolygon(), createAndAddTeardropWithMask(), and TEARDROP_PARAMETERS.

Referenced by AddTeardropsOnTracks(), and UpdateTeardrops().

◆ UpdateTeardrops()

Friends And Related Symbol Documentation

◆ TEARDROP_PARAMETERS

Member Data Documentation

◆ m_board

◆ m_createdTdList

std::vector<ZONE*> TEARDROP_MANAGER::m_createdTdList
private

Definition at line 271 of file teardrop.h.

Referenced by createAndAddTeardropWithMask(), and setTeardropPriorities().

◆ m_prmsList

TEARDROP_PARAMETERS_LIST* TEARDROP_MANAGER::m_prmsList
private

Definition at line 267 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), TEARDROP_MANAGER(), and UpdateTeardrops().

◆ m_tolerance

int TEARDROP_MANAGER::m_tolerance
private

Definition at line 263 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), TEARDROP_MANAGER(), and UpdateTeardrops().

◆ m_toolManager

TOOL_MANAGER* TEARDROP_MANAGER::m_toolManager
private

Definition at line 266 of file teardrop.h.

Referenced by TEARDROP_MANAGER().

◆ m_trackLookupList

TRACK_BUFFER TEARDROP_MANAGER::m_trackLookupList
private

Definition at line 270 of file teardrop.h.

Referenced by AddTeardropsOnTracks(), and BuildTrackCaches().

◆ m_tracksRTree

DRC_RTREE TEARDROP_MANAGER::m_tracksRTree
private

Definition at line 269 of file teardrop.h.

Referenced by BuildTrackCaches(), and findTouchingTrack().


The documentation for this class was generated from the following files: