KiCad PCB EDA Suite
Loading...
Searching...
No Matches
teardrop.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include "teardrop/teardrop.h"
22
23#include <confirm.h>
24
26#include <pcb_track.h>
27#include <pad.h>
28#include <zone_filler.h>
29#include <board_commit.h>
30
32#include <drc/drc_rtree.h>
35#include <bezier_curves.h>
36
37#include <wx/log.h>
38
39// The first priority level of a teardrop area (arbitrary value)
40#define MAGIC_TEARDROP_ZONE_ID 30000
41
42
44 m_board( aBoard ),
45 m_toolManager( aToolManager )
46{
47 m_prmsList = m_board->GetDesignSettings().GetTeadropParamsList();
48 m_tolerance = 0;
49}
50
51
53 std::vector<VECTOR2I>& aPoints, PCB_TRACK* aTrack,
54 BOARD_ITEM* aCandidate ) const
55{
56 ZONE* teardrop = new ZONE( m_board );
57
58 // Create a deterministic UUID from the track and candidate UUIDs so that teardrops
59 // maintain stable ordering in the output file across save/load cycles.
60 teardrop->SetUuidDirect( KIID::Combine( aTrack->m_Uuid, aCandidate->m_Uuid ) );
61
62 // teardrop settings are the last zone settings used by a zone dialog.
63 // override them by default.
65
66 // Add zone properties (priority will be fixed later)
67 teardrop->SetTeardropAreaType( aTeardropVariant == TD_TYPE_PADVIA ? TEARDROP_TYPE::TD_VIAPAD
69 teardrop->SetLayer( aTrack->GetLayer() );
70 teardrop->SetNetCode( aTrack->GetNetCode(), /* aNoAssert */ true );
71 teardrop->SetLocalClearance( 0 );
72 teardrop->SetMinThickness( pcbIUScale.mmToIU( 0.0254 ) ); // The minimum zone thickness
74 teardrop->SetIsFilled( false );
77
78 SHAPE_POLY_SET* outline = teardrop->Outline();
79 outline->NewOutline();
80
81 for( const VECTOR2I& pt: aPoints )
82 outline->Append( pt.x, pt.y );
83
84 // Until we know better (ie: pay for a potentially very expensive zone refill), the teardrop
85 // fill is the same as its outline.
86 teardrop->SetFilledPolysList( aTrack->GetLayer(), *teardrop->Outline() );
87 teardrop->SetIsFilled( true );
88
89 // Used in priority calculations:
90 teardrop->CalculateFilledArea();
91
92 return teardrop;
93}
94
95
97 std::vector<VECTOR2I>& aPoints, PCB_TRACK* aTrack,
98 BOARD_ITEM* aCandidate ) const
99{
100 ZONE* teardrop = new ZONE( m_board );
101
102 // Create a deterministic UUID from the track and candidate UUIDs, then increment it
103 // to differentiate from the copper teardrop zone.
104 KIID maskUuid = KIID::Combine( aTrack->m_Uuid, aCandidate->m_Uuid );
105 maskUuid.Increment();
106 teardrop->SetUuidDirect( maskUuid );
107
108 teardrop->SetTeardropAreaType( aTeardropVariant == TD_TYPE_PADVIA ? TEARDROP_TYPE::TD_VIAPAD
110 teardrop->SetLayer( aTrack->GetLayer() == F_Cu ? F_Mask : B_Mask );
111 teardrop->SetMinThickness( pcbIUScale.mmToIU( 0.0254 ) ); // The minimum zone thickness
112 teardrop->SetIsFilled( false );
115
116 SHAPE_POLY_SET* outline = teardrop->Outline();
117 outline->NewOutline();
118
119 for( const VECTOR2I& pt: aPoints )
120 outline->Append( pt.x, pt.y );
121
122 if( int expansion = aTrack->GetSolderMaskExpansion() )
123 {
124 // The zone-min-thickness deflate/reinflate is going to round corners, so it's more
125 // efficient to allow acute corners on the solder mask expansion here, and delegate the
126 // rounding to the deflate/reinflate.
127 teardrop->SetMinThickness( std::max( teardrop->GetMinThickness(), expansion ) );
128
130 m_board->GetDesignSettings().m_MaxError );
131 }
132
133 // Until we know better (ie: pay for a potentially very expensive zone refill), the teardrop
134 // fill is the same as its outline.
135 teardrop->SetFilledPolysList( teardrop->GetLayer(), *teardrop->Outline() );
136 teardrop->SetIsFilled( true );
137
138 return teardrop;
139}
140
141
143 TEARDROP_VARIANT aTeardropVariant,
144 std::vector<VECTOR2I>& aPoints,
145 PCB_TRACK* aTrack, BOARD_ITEM* aCandidate )
146{
147 ZONE* new_teardrop = createTeardrop( aTeardropVariant, aPoints, aTrack, aCandidate );
148 m_board->Add( new_teardrop, ADD_MODE::BULK_INSERT );
149 m_createdTdList.push_back( new_teardrop );
150
151 aCommit.Added( new_teardrop );
152
153 if( aTrack->HasSolderMask() && IsExternalCopperLayer( aTrack->GetLayer() ) )
154 {
155 ZONE* new_teardrop_mask = createTeardropMask( aTeardropVariant, aPoints, aTrack, aCandidate );
156 m_board->Add( new_teardrop_mask, ADD_MODE::BULK_INSERT );
157 aCommit.Added( new_teardrop_mask );
158 }
159}
160
161
163 const TEARDROP_PARAMETERS& aParams,
164 TEARDROP_MANAGER::TEARDROP_VARIANT aTeardropVariant,
165 PCB_TRACK* aTrack, BOARD_ITEM* aCandidate,
166 const VECTOR2I& aPos )
167{
168 std::vector<VECTOR2I> points;
169
170 if( computeTeardropPolygon( aParams, points, aTrack, aCandidate, aPos ) )
171 {
172 createAndAddTeardropWithMask( aCommit, aTeardropVariant, points, aTrack, aCandidate );
173 return true;
174 }
175
176 return false;
177}
178
179
181 const std::vector<BOARD_ITEM*>* dirtyPadsAndVias,
182 const std::set<PCB_TRACK*>* dirtyTracks )
183{
184 std::shared_ptr<CONNECTIVITY_DATA> connectivity = m_board->GetConnectivity();
185
186 auto isStale =
187 [&]( ZONE* zone )
188 {
189 std::vector<PAD*> connectedPads;
190 std::vector<PCB_VIA*> connectedVias;
191
192 connectivity->GetConnectedPadsAndVias( zone, &connectedPads, &connectedVias );
193
194 for( PAD* pad : connectedPads )
195 {
196 if( alg::contains( *dirtyPadsAndVias, pad ) )
197 return true;
198 }
199
200 for( PCB_VIA* via : connectedVias )
201 {
202 if( alg::contains( *dirtyPadsAndVias, via ) )
203 return true;
204 }
205
206 for( PCB_TRACK* track : connectivity->GetConnectedTracks( zone ) )
207 {
208 if( alg::contains( *dirtyTracks, track ) )
209 return true;
210 }
211
212 return false;
213 };
214
215 for( ZONE* zone : m_board->Zones() )
216 {
217 if( zone->IsTeardropArea() && isStale( zone ) )
218 zone->SetFlags( STRUCT_DELETED );
219 }
220
221 m_board->BulkRemoveStaleTeardrops( aCommit );
222}
223
224
226 const std::vector<BOARD_ITEM*>* dirtyPadsAndVias,
227 const std::set<PCB_TRACK*>* dirtyTracks,
228 bool aForceFullUpdate )
229{
230 if( m_board->LegacyTeardrops() )
231 return;
232
233 // Init parameters:
234 m_tolerance = pcbIUScale.mmToIU( 0.01 );
235
237
238 // Old teardrops must be removed, to ensure a clean teardrop rebuild
239 if( aForceFullUpdate )
240 {
241 for( ZONE* zone : m_board->Zones() )
242 {
243 if( zone->IsTeardropArea() )
244 zone->SetFlags( STRUCT_DELETED );
245 }
246
247 m_board->BulkRemoveStaleTeardrops( aCommit );
248 }
249
250 std::shared_ptr<CONNECTIVITY_DATA> connectivity = m_board->GetConnectivity();
251
252 for( PCB_TRACK* track : m_board->Tracks() )
253 {
254 if( ! ( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T ) )
255 continue;
256
257 std::vector<PAD*> connectedPads;
258 std::vector<PCB_VIA*> connectedVias;
259
260 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
261
262 bool forceUpdate = aForceFullUpdate || dirtyTracks->contains( track );
263
264 for( PAD* pad : connectedPads )
265 {
266 if( !forceUpdate && !alg::contains( *dirtyPadsAndVias, pad ) )
267 continue;
268
269 TEARDROP_PARAMETERS& tdParams = pad->GetTeardropParams();
270 VECTOR2I padSize = pad->GetSize( track->GetLayer() );
271 int annularWidth = std::min( padSize.x, padSize.y );
272
273 if( !tdParams.m_Enabled )
274 continue;
275
276 // Ensure a teardrop shape can be built: track width must be < teardrop width and
277 // filter width
278 if( track->GetWidth() >= tdParams.m_TdMaxWidth
279 || track->GetWidth() >= annularWidth * tdParams.m_BestWidthRatio
280 || track->GetWidth() >= annularWidth * tdParams.m_WidthtoSizeFilterRatio )
281 {
282 continue;
283 }
284
285 bool startHitsPad = pad->HitTest( track->GetStart(), 0, track->GetLayer() );
286 bool endHitsPad = pad->HitTest( track->GetEnd(), 0, track->GetLayer() );
287
288 // The track is entirely inside the pad; cannot create a teardrop
289 if( startHitsPad && endHitsPad )
290 continue;
291
292 // Only count segments that substantively emerge from the pad copper. A track
293 // whose centerline grazes the pad edge exits by less than its own width; such a
294 // segment is effectively covered and using it mis-orients the teardrop axis
295 // along the tangent instead of the track's real entry direction.
296 if( startHitsPad != endHitsPad
297 && computeEmergingTrackLength( track, pad, track->GetLayer() ) < track->GetWidth() )
298 {
299 continue;
300 }
301
302 // Skip case where pad and the track are within a copper zone with the same net
303 // (and the pad can be connected to the zone)
304 if( !tdParams.m_TdOnPadsInZones && areItemsInSameZone( pad, track ) )
305 continue;
306
307 tryCreateTrackTeardrop( aCommit, tdParams, TEARDROP_MANAGER::TD_TYPE_PADVIA, track, pad, pad->GetPosition() );
308
309 // A track can be connected to pad when just crossing it. So we can create 2 teardrops,
310 // one from pad to track start point and the other to track end point.
311 // However this is acceptable only if the pad position is inside the track.
312 // Otherwise the 2 teardrop shapes can be strange (and of course incorrect
313 if( !startHitsPad && !endHitsPad && track->HitTest( pad->GetPosition() ) )
314 {
315 PCB_TRACK reversed( *track );
316 reversed.SetStart( track->GetEnd() );
317 reversed.SetEnd( pad->GetPosition() );
318 tryCreateTrackTeardrop( aCommit, tdParams, TEARDROP_MANAGER::TD_TYPE_PADVIA, &reversed, pad, pad->GetPosition() );
319 reversed.SetStart( track->GetStart() );
320 tryCreateTrackTeardrop( aCommit, tdParams, TEARDROP_MANAGER::TD_TYPE_PADVIA, &reversed, pad, pad->GetPosition() );
321 }
322 }
323
324 for( PCB_VIA* via : connectedVias )
325 {
326 if( !forceUpdate && !alg::contains( *dirtyPadsAndVias, via ) )
327 continue;
328
329 TEARDROP_PARAMETERS tdParams = via->GetTeardropParams();
330 int annularWidth = via->GetWidth( track->GetLayer() );
331
332 if( !tdParams.m_Enabled )
333 continue;
334
335 // Ensure a teardrop shape can be built: track width must be < teardrop width and
336 // filter width
337 if( track->GetWidth() >= tdParams.m_TdMaxWidth
338 || track->GetWidth() >= annularWidth * tdParams.m_BestWidthRatio
339 || track->GetWidth() >= annularWidth * tdParams.m_WidthtoSizeFilterRatio )
340 {
341 continue;
342 }
343
344 bool startHitsVia = via->HitTest( track->GetStart() );
345 bool endHitsVia = via->HitTest( track->GetEnd() );
346
347 // The track is entirely inside the via; cannot create a teardrop
348 if( startHitsVia && endHitsVia )
349 continue;
350
351 // Only count segments that substantively emerge from the via copper. A track
352 // that grazes the via edge tangentially emerges by less than its own width and
353 // should not anchor a teardrop: its direction misrepresents the real track entry.
354 if( startHitsVia != endHitsVia
355 && computeEmergingTrackLength( track, via, track->GetLayer() ) < track->GetWidth() )
356 {
357 continue;
358 }
359
361 via->GetPosition() );
362
363 // A track can be connected to via when just crossing it. So we can create 2 teardrops,
364 // one from via to track start point and the other to track end point.
365 // However this is acceptable only if the via position is inside the track.
366 // Otherwise the 2 teardrop shapes can be strange (and of course incorrect
367 if( !startHitsVia && !endHitsVia && track->HitTest( via->GetPosition() ) )
368 {
369 PCB_TRACK reversed( *track );
370 reversed.SetStart( track->GetEnd() );
371 reversed.SetEnd( via->GetPosition() );
372 tryCreateTrackTeardrop( aCommit, tdParams, TEARDROP_MANAGER::TD_TYPE_PADVIA, &reversed, via, via->GetPosition() );
373 reversed.SetStart( track->GetStart() );
374 tryCreateTrackTeardrop( aCommit, tdParams, TEARDROP_MANAGER::TD_TYPE_PADVIA, &reversed, via, via->GetPosition() );
375 }
376 }
377 }
378
379 if( ( aForceFullUpdate || !dirtyTracks->empty() )
380 && m_prmsList->GetParameters( TARGET_TRACK )->m_Enabled )
381 {
382 AddTeardropsOnTracks( aCommit, dirtyTracks, aForceFullUpdate );
383 }
384
385 // Now set priority of teardrops now all teardrops are added
387}
388
389
391{
392 for( ZONE* zone : m_board->Zones() )
393 {
394 if( zone->IsTeardropArea() && zone->GetTeardropAreaType() == TEARDROP_TYPE::TD_TRACKEND )
395 zone->SetFlags( STRUCT_DELETED );
396 }
397
398 m_board->BulkRemoveStaleTeardrops( aCommit );
399}
400
401
403{
404 // Note: a teardrop area is on only one layer, so using GetFirstLayer() is OK
405 // to know the zone layer of a teardrop
406
407 int priority_base = MAGIC_TEARDROP_ZONE_ID;
408
409 // The sort function to sort by increasing copper layers. Group by layers.
410 // For same layers sort by decreasing areas
411 struct
412 {
413 bool operator()(ZONE* a, ZONE* b) const
414 {
415 if( a->GetFirstLayer() == b->GetFirstLayer() )
416 {
417 if( a->GetOutlineArea() != b->GetOutlineArea() )
418 return a->GetOutlineArea() > b->GetOutlineArea();
419 return a->m_Uuid < b->m_Uuid; // stable tiebreak
420 }
421 return a->GetFirstLayer() < b->GetFirstLayer();
422
423 }
424 } compareLess;
425
426 for( ZONE* td: m_createdTdList )
427 td->CalculateOutlineArea();
428
429 std::sort( m_createdTdList.begin(), m_createdTdList.end(), compareLess );
430
431 int curr_layer = -1;
432
433 for( ZONE* td: m_createdTdList )
434 {
435 if( td->GetFirstLayer() != curr_layer )
436 {
437 curr_layer = td->GetFirstLayer();
438 priority_base = MAGIC_TEARDROP_ZONE_ID;
439 }
440
441 td->SetAssignedPriority( priority_base++ );
442 }
443}
444
445
447 const std::set<PCB_TRACK*>* aTracks,
448 bool aForceFullUpdate )
449{
450 std::shared_ptr<CONNECTIVITY_DATA> connectivity = m_board->GetConnectivity();
451 TEARDROP_PARAMETERS params = *m_prmsList->GetParameters( TARGET_TRACK );
452
453 // Explore groups (a group is a set of tracks on the same layer and the same net):
454 for( auto& grp : m_trackLookupList.GetBuffer() )
455 {
456 int layer, netcode;
457 TRACK_BUFFER::GetNetcodeAndLayerFromIndex( grp.first, &layer, &netcode );
458
459 std::vector<PCB_TRACK*>* sublist = grp.second;
460
461 if( sublist->size() <= 1 ) // We need at least 2 track segments
462 continue;
463
464 // The sort function to sort by increasing track widths
465 struct
466 {
467 bool operator()(PCB_TRACK* a, PCB_TRACK* b) const
468 { return a->GetWidth() < b->GetWidth(); }
469 } compareLess;
470
471 std::sort( sublist->begin(), sublist->end(), compareLess );
472 int min_width = sublist->front()->GetWidth();
473 int max_width = sublist->back()->GetWidth();
474
475 // Skip groups having the same track thickness
476 if( max_width == min_width )
477 continue;
478
479 for( unsigned ii = 0; ii < sublist->size()-1; ii++ )
480 {
481 PCB_TRACK* track = (*sublist)[ii];
482 int track_len = (int) track->GetLength();
483 bool track_needs_update = aForceFullUpdate || alg::contains( *aTracks, track );
484 min_width = track->GetWidth();
485
486 // to avoid creating a teardrop between 2 tracks having similar widths give a threshold
487 params.m_WidthtoSizeFilterRatio = std::max( params.m_WidthtoSizeFilterRatio, 0.1 );
488 const double th = 1.0 / params.m_WidthtoSizeFilterRatio;
489 min_width = KiROUND( min_width * th );
490
491 for( unsigned jj = ii+1; jj < sublist->size(); jj++ )
492 {
493 // Search candidates with thickness > curr thickness
494 PCB_TRACK* candidate = (*sublist)[jj];
495
496 if( min_width >= candidate->GetWidth() )
497 continue;
498
499 // Cannot build a teardrop on a too short track segment.
500 // The min len is > candidate radius
501 if( track_len <= candidate->GetWidth() /2 )
502 continue;
503
504 // Now test end to end connection:
505 EDA_ITEM_FLAGS match_points; // to return the end point EDA_ITEM_FLAGS:
506 // 0, STARTPOINT, ENDPOINT
507
508 VECTOR2I pos = candidate->GetStart();
509 match_points = track->IsPointOnEnds( pos, m_tolerance );
510
511 if( !match_points )
512 {
513 pos = candidate->GetEnd();
514 match_points = track->IsPointOnEnds( pos, m_tolerance );
515 }
516
517 if( !match_points )
518 continue;
519
520 if( !track_needs_update && alg::contains( *aTracks, candidate ) )
521 continue;
522
523 // Pads/vias have priority for teardrops; ensure there isn't one at our position
524 bool existingPadOrVia = false;
525 std::vector<PAD*> connectedPads;
526 std::vector<PCB_VIA*> connectedVias;
527
528 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
529
530 for( PAD* pad : connectedPads )
531 {
532 if( pad->HitTest( pos ) )
533 existingPadOrVia = true;
534 }
535
536 for( PCB_VIA* via : connectedVias )
537 {
538 if( via->HitTest( pos ) )
539 existingPadOrVia = true;
540 }
541
542 if( existingPadOrVia )
543 continue;
544
545 tryCreateTrackTeardrop( aCommit, params, TEARDROP_MANAGER::TD_TYPE_TRACKEND, track, candidate, pos );
546 }
547 }
548 }
549}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition commit.h:80
const KIID m_Uuid
Definition eda_item.h:531
Definition kiid.h:44
static KIID Combine(const KIID &aFirst, const KIID &aSecond)
Creates a deterministic KIID from two input KIIDs by XORing their underlying UUIDs.
Definition kiid.cpp:284
void Increment()
Generates a deterministic replacement for a given ID.
Definition kiid.cpp:269
Definition pad.h:61
int GetSolderMaskExpansion() const
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
void SetEnd(const VECTOR2I &aEnd)
Definition pcb_track.h:89
bool HasSolderMask() const
Definition pcb_track.h:117
void SetStart(const VECTOR2I &aStart)
Definition pcb_track.h:92
const VECTOR2I & GetStart() const
Definition pcb_track.h:93
const VECTOR2I & GetEnd() const
Definition pcb_track.h:90
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
Definition pcb_track.h:87
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.
BOARD * m_board
Definition teardrop.h:275
ZONE * createTeardropMask(TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack, BOARD_ITEM *aCandidate) const
Definition teardrop.cpp:96
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)
Definition teardrop.cpp:43
void createAndAddTeardropWithMask(BOARD_COMMIT &aCommit, TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack, BOARD_ITEM *aCandidate)
Creates and adds a teardrop with optional mask to the board.
Definition teardrop.cpp:142
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.
Definition teardrop.cpp:225
void setTeardropPriorities()
Set priority of created teardrops.
Definition teardrop.cpp:402
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.
Definition teardrop.cpp:446
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.
Definition teardrop.cpp:162
TRACK_BUFFER m_trackLookupList
Definition teardrop.h:280
TEARDROP_PARAMETERS_LIST * m_prmsList
Definition teardrop.h:277
std::vector< ZONE * > m_createdTdList
Definition teardrop.h:281
void DeleteTrackToTrackTeardrops(BOARD_COMMIT &aCommit)
Definition teardrop.cpp:390
bool areItemsInSameZone(BOARD_ITEM *aPadOrVia, PCB_TRACK *aTrack) const
friend class TEARDROP_PARAMETERS
Definition teardrop.h:91
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.
Definition teardrop.cpp:180
TOOL_MANAGER * m_toolManager
Definition teardrop.h:276
int computeEmergingTrackLength(PCB_TRACK *aTrack, BOARD_ITEM *aOther, PCB_LAYER_ID aLayer) const
Return the length of the portion of aTrack that lies outside aOther's copper shape on aLayer.
ZONE * createTeardrop(TEARDROP_VARIANT aTeardropVariant, std::vector< VECTOR2I > &aPoints, PCB_TRACK *aTrack, BOARD_ITEM *aCandidate) const
Creates a teardrop (a ZONE item) from its polygonal shape, track netcode and layer.
Definition teardrop.cpp:52
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.
Master controller class:
static void GetNetcodeAndLayerFromIndex(int aIdx, int *aLayer, int *aNetcode)
Definition teardrop.h:57
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.
Definition zone.h:70
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
Definition zone.h:289
void SetLocalClearance(std::optional< int > aClearance)
Definition zone.h:183
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition zone.cpp:1458
void SetMinThickness(int aMinThickness)
Definition zone.h:316
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition zone.cpp:532
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition zone.cpp:599
SHAPE_POLY_SET * Outline()
Definition zone.h:418
bool SetNetCode(int aNetCode, bool aNoAssert) override
Override that clamps the netcode to 0 when this zone is in copper-thieving fill mode.
Definition zone.cpp:581
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition zone.h:726
int GetMinThickness() const
Definition zone.h:315
void SetIsFilled(bool isFilled)
Definition zone.h:307
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition zone.cpp:1798
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition zone.h:313
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...
Definition zone.h:792
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition zone.h:834
PCB_LAYER_ID GetFirstLayer() const
Definition zone.cpp:554
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.
Definition layer_ids.h:686
@ B_Mask
Definition layer_ids.h:94
@ F_Mask
Definition layer_ids.h:93
@ F_Cu
Definition layer_ids.h:60
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
#define MAGIC_TEARDROP_ZONE_ID
Definition teardrop.cpp:40
@ TARGET_TRACK
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:91
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
@ FULL
pads are covered by copper
Definition zones.h:47