43#define MAGIC_TEARDROP_ZONE_ID 30000
58 std::vector<VECTOR2I>& aPoints,
PCB_TRACK* aTrack)
const
84 outline->
Append(pt.x, pt.y);
105 std::vector< VIAPAD > viapad_list;
122 int netcode = track->GetNetCode();
123 int layer = track->GetLayer();
124 trackLookupList.
AddTrack( track, layer, netcode );
130 std::vector< ZONE*> teardrops;
140 for(
VIAPAD& viapad: viapad_list )
143 if( !viapad.IsOnLayer( track->GetLayer() ) )
146 bool start_in_pad = viapad.m_Parent->HitTest( track->GetStart() );
147 bool end_in_pad = viapad.m_Parent->HitTest( track->GetEnd() );
149 if( end_in_pad == start_in_pad )
156 if( viapad.m_IsRound )
164 || track->GetWidth() >= viapad.m_Width * currParams->
m_HeightRatio )
176 std::vector<VECTOR2I> points;
178 aFollowTracks, trackLookupList );
187 aCommitter->
Added( new_teardrop );
194 int track2trackCount = 0;
211 int half_min_width = zone->GetMinThickness() / 2;
215 filledPolys.
Deflate( half_min_width - epsilon, numSegs );
218 if( half_min_width - epsilon > epsilon )
219 filledPolys.
Inflate( half_min_width - epsilon, numSegs );
221 zone->SetFilledPolysList( zone->GetFirstLayer(), filledPolys );
225 if( count || removed_cnt || track2trackCount )
228 aCommitter->
Push(
_(
"Add teardrops" ) );
235 return count + track2trackCount;
250 bool operator()(
ZONE* a,
ZONE* b)
const
260 td->CalculateOutlineArea();
268 if( td->GetFirstLayer() != curr_layer )
270 curr_layer = td->GetFirstLayer();
274 td->SetAssignedPriority( priority_base++ );
289 int netcode = track->GetNetCode();
290 int layer = track->GetLayer();
291 trackLookupList.
AddTrack( track, layer, netcode );
297 std::vector< VIAPAD > viapad_list;
304 for(
auto grp : trackLookupList.
GetBuffer() )
309 std::vector<PCB_TRACK*>* sublist = grp.second;
311 if( sublist->size() <= 1 )
321 std::sort( sublist->begin(), sublist->end(), compareLess );
322 int min_width = sublist->front()->GetWidth();
323 int max_width = sublist->back()->GetWidth();
326 if( max_width == min_width )
329 for(
unsigned ii = 0; ii < sublist->size()-1; ii++ )
340 min_width = min_width * th;
342 for(
unsigned jj = ii+1; jj < sublist->size(); jj++ )
347 if( min_width >= candidate->
GetWidth() )
352 if( track_len <= candidate->GetWidth() /2 )
365 roundshape_pos = candidate->
GetEnd();
372 for(
VIAPAD& viapad : viapad_list )
374 if( viapad.IsOnLayer( track->
GetLayer() )
375 && viapad.m_Parent->HitTest( roundshape_pos, 0 ) )
384 VIAPAD viatrack( candidate, endPointCandidate );
385 std::vector<VECTOR2I> points;
387 points, track, viatrack,
388 false, trackLookupList );
397 aCommitter->
Added( new_teardrop );
413 std::vector< ZONE*> teardrops;
417 for(
ZONE* teardrop : teardrops )
422 aCommitter->
Removed( teardrop );
429 if( aCommitter && aCommitAfterRemove )
constexpr EDA_IU_SCALE pcbIUScale
#define SKIP_CONNECTIVITY
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
TEARDROP_PARAMETERS_LIST * GetTeadropParamsList()
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
COMMIT & Added(EDA_ITEM *aItem)
Remove a new item from the model.
COMMIT & Removed(EDA_ITEM *aItem)
Modify a given item in the model.
The main frame for Pcbnew.
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Represent a set of closed polygons.
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=CHAMFER_ALL_CORNERS)
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
SHAPE_LINE_CHAIN & Outline(int aIndex)
int NewOutline()
Creates a new hole in a given outline.
TEARDROP_MANAGER(BOARD *aBoard, PCB_EDIT_FRAME *aFrame)
void collectTeardrops(std::vector< ZONE * > &aList) const
Build a list of all teardrops on the current board.
void collectVias(std::vector< VIAPAD > &aList) const
Collect and build the list of all vias from the given board.
void collectPadsCandidate(std::vector< VIAPAD > &aList, bool aDrilledViaPad, bool aRoundShapesOnly, bool aIncludeNotDrilled) const
Build a list of pads candidate for teardrops from the given board Pads with no net are not candidate ...
bool isViaAndTrackInSameZone(VIAPAD &aVia, PCB_TRACK *aTrack) const
int SetTeardrops(BOARD_COMMIT *aCommitter, bool aFollowTracks=true)
Set teardrops on a teardrop free board.
void setTeardropPriorities()
Set priority of created teardrops.
int RemoveTeardrops(BOARD_COMMIT *aCommitter, bool aCommitAfterRemove)
Remove all teardrops.
bool computeTeardropPolygonPoints(TEARDROP_PARAMETERS *aCurrParams, std::vector< VECTOR2I > &aCorners, PCB_TRACK *aTrack, VIAPAD &aVia, bool aFollowTracks, TRACK_BUFFER &aTrackLookupList) const
Compute all teardrop points of the polygon shape.
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.
int addTeardropsOnTracks(BOARD_COMMIT *aCommitter)
Add teardrop on tracks of different sizes connected by their end.
bool m_TargetPadsWithNoHole
True to create teardrops for pads without holes (SMD and others.
bool m_TargetViasPads
True to create teardrops for vias and pads with holes.
bool m_UseRoundShapesOnly
True to create teardrops for round shapes only.
bool m_TargetTrack2Track
True to create teardrops at the end of a track connected to the end of another track having a differe...
bool m_TdOnPadsInZones
Pads inside a zone of the same net do not have teardrop added.
TEARDROP_PARAMETERS * GetParameters(TARGET_TD aTdType)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
double m_HeightRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxHeight
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....
void AddTrack(PCB_TRACK *aTrack, int aLayer, int aNetcode)
Add a track in buffer, in space grouping tracks having the same netcode and the same layer.
static void GetNetcodeAndLayerFromIndex(int aIdx, int *aLayer, int *aNetcode)
std::map< int, std::vector< PCB_TRACK * > * > & GetBuffer()
ZONE_SETTINGS handles zones parameters.
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
Handle a list of polygons defining a copper zone.
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
void SetMinThickness(int aMinThickness)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
void SetIsFilled(bool isFilled)
void SetLocalClearance(int aClearance)
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
void SetPadConnection(ZONE_CONNECTION aPadConnection)
void SetZoneName(const wxString &aName)
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.
static constexpr EDA_ANGLE & FULL_CIRCLE
std::uint32_t EDA_ITEM_FLAGS
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
constexpr int mmToIU(double mm) const
Stores info of a pad, via or track end to build a teardrop.
static ZONE_SETTINGS s_default_settings
#define MAGIC_TEARDROP_ZONE_ID
#define MAGIC_TEARDROP_TRACK_NAME
#define MAGIC_TEARDROP_PADVIA_NAME
@ 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)
@ FULL
pads are covered by copper