KiCad PCB EDA Suite
zone.h
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) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2022 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef ZONE_H
26#define ZONE_H
27
28
29#include <mutex>
30#include <vector>
31#include <gr_basic.h>
32#include <board_item.h>
34#include <layer_ids.h>
36#include <zone_settings.h>
38
39
40class LINE_READER;
41class PCB_EDIT_FRAME;
42class BOARD;
43class ZONE;
44class MSG_PANEL_ITEM;
45
46
57{
58public:
59
67 ZONE( BOARD_ITEM_CONTAINER* parent, bool aInFP = false );
68
69 ZONE( const ZONE& aZone );
70 ZONE& operator=( const ZONE &aOther );
71
72 ~ZONE();
73
74 static inline bool ClassOf( const EDA_ITEM* aItem )
75 {
76 return aItem && aItem->Type() == PCB_ZONE_T;
77 }
78
82 bool IsConnected() const override
83 {
84 return !GetIsRuleArea();
85 }
86
90 void InitDataFromSrcInCopyCtor( const ZONE& aZone );
91
96 bool IsConflicting() const;
97
101 VECTOR2I GetPosition() const override;
102 void SetPosition( const VECTOR2I& aPos ) override {}
103
107 void SetAssignedPriority( unsigned aPriority ) { m_priority = aPriority; }
108
112 unsigned GetAssignedPriority() const { return m_priority; }
113
114 bool HigherPriority( const ZONE* aOther ) const;
115
116 bool SameNet( const ZONE* aOther ) const;
117
118 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
119 wxString GetFriendlyName() const override;
120
121 void SetLayerSet( LSET aLayerSet ) override;
122 virtual LSET GetLayerSet() const override { return m_layerSet; }
123
124 wxString GetZoneName() const { return m_zoneName; }
125 void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
126
127 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
128 {
129 return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
130 }
131
135 const BOX2I GetBoundingBox() const override;
136
141 void CacheBoundingBox();
142
150 int GetLocalClearance( wxString* aSource ) const override;
151
152 int GetLocalClearance() const { return GetLocalClearance( nullptr ); }
153 void SetLocalClearance( int aClearance ) { m_ZoneClearance = aClearance; }
154
158 bool IsOnCopperLayer() const override;
159
160 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
161
162 virtual PCB_LAYER_ID GetLayer() const override;
163
164 // Return the first layer in GUI sequence.
166
167 virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
168
169 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
170
171 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
172
173 void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
175
176 void SetThermalReliefGap( int aThermalReliefGap )
177 {
178 if( m_thermalReliefGap != aThermalReliefGap )
179 SetNeedRefill( true );
180
181 m_thermalReliefGap = aThermalReliefGap;
182 }
183
185 int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
186
187 void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
188 {
189 if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
190 SetNeedRefill( true );
191
192 m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
193 }
194
196
202 double CalculateFilledArea();
203
208 double CalculateOutlineArea();
209
216 {
217 return m_area;
218 }
219
226 {
227 return m_outlinearea;
228 }
229
230 std::mutex& GetLock()
231 {
232 return m_lock;
233 }
234
236 {
237 return m_fillFlags.test( aLayer );
238 }
239
240 void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags.set( aLayer, aFlag ); }
241
242 bool IsFilled() const { return m_isFilled; }
243 void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
244
245 bool NeedRefill() const { return m_needRefill; }
246 void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
247
249 void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
250
251 int GetMinThickness() const { return m_ZoneMinThickness; }
252 void SetMinThickness( int aMinThickness )
253 {
254 if( m_ZoneMinThickness != aMinThickness )
255 SetNeedRefill( true );
256
257 m_ZoneMinThickness = aMinThickness;
258 }
259
260 int GetHatchThickness() const { return m_hatchThickness; }
261 void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
262
263 int GetHatchGap() const { return m_hatchGap; }
264 void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
265
267 void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; }
268
270 void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
271
273 void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
274
275 double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
276 void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
277
279 void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
280
282 {
283 // Transform relative indices to global index
284 int globalIndex = -1;
285
287 m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
288
289 return globalIndex;
290 }
291
292 void SetSelectedCorner( int aCorner )
293 {
294 SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
295
296 // If the global index of the corner is correct, assign it to m_CornerSelection
297 if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
298 {
299 if( m_CornerSelection == nullptr )
301
302 *m_CornerSelection = selectedCorner;
303 }
304 else
305 throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
306 }
307
309 int GetLocalFlags() const { return m_localFlgs; }
310 void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
311
313 const SHAPE_POLY_SET* Outline() const { return m_Poly; }
314
315 void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
316
317 // @copydoc BOARD_ITEM::GetEffectiveShape
318 virtual std::shared_ptr<SHAPE>
320 FLASHING aFlash = FLASHING::DEFAULT ) const override;
321
328 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
329
338 bool HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy = 0 ) const;
339
348 bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
349 int* aHoleIdx = nullptr ) const;
350
356 void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
357 std::vector<ZONE*>* aOtherNetIntersectingZones ) const;
358
370
382 void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
383 int aError, ERROR_LOC aErrorLoc,
384 SHAPE_POLY_SET* aBoardOutline ) const;
385
399 int aClearance, int aError, ERROR_LOC aErrorLoc,
400 bool ignoreLineWidth = false ) const override;
401
412 bool HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
413 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
414
424 bool HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
425 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
426
430 bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
431
437 bool UnFill();
438
439 /* Geometric transformations: */
440
446 void Move( const VECTOR2I& offset ) override;
447
454 void MoveEdge( const VECTOR2I& offset, int aEdge );
455
461 void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
462
469 virtual void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
470
477 void Mirror( const VECTOR2I& aMirrorRef, bool aMirrorLeftRight );
478
482 wxString GetClass() const override
483 {
484 return wxT( "ZONE" );
485 }
486
490 int GetNumCorners( void ) const
491 {
492 return m_Poly->TotalVertices();
493 }
494
501 {
502 return m_Poly->Iterate();
503 }
504
511 {
512 return m_Poly->IterateWithHoles();
513 }
514
521 {
522 return m_Poly->CIterateWithHoles();
523 }
524
525 void RemoveAllContours( void )
526 {
528 }
529
530 const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
531 {
533
534 // Convert global to relative indices
535 if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
536 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
537
538 return m_Poly->CVertex( index );
539 }
540
541 void SetCornerPosition( int aCornerIndex, const VECTOR2I& new_pos )
542 {
543 SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
544
545 // Convert global to relative indices
546 if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
547 {
548 if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
549 || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
550 {
551 SetNeedRefill( true );
552 m_Poly->SetVertex( relativeIndices, new_pos );
553 }
554 }
555 else
556 {
557 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
558 }
559 }
560
564 void NewHole()
565 {
566 m_Poly->NewHole();
567 }
568
578 bool AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication = false );
579
582
592 bool IsSame( const ZONE &aZoneToCompare );
593
595 {
596 return m_FilledPolysList.count( aLayer ) > 0;
597 }
598
602 const std::shared_ptr<SHAPE_POLY_SET>& GetFilledPolysList( PCB_LAYER_ID aLayer ) const
603 {
604 wxASSERT( m_FilledPolysList.count( aLayer ) );
605 return m_FilledPolysList.at( aLayer );
606 }
607
609 {
610 wxASSERT( m_FilledPolysList.count( aLayer ) );
611 return m_FilledPolysList.at( aLayer ).get();
612 }
613
619
623 void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
624 {
625 m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
626 }
627
635 bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
636
637 void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
638 {
639 m_insulatedIslands[aLayer].insert( aPolyIdx );
640 }
641
642 bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
643 SHAPE_POLY_SET* aBoardOutline,
644 SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
645
646 void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
647
649
650 void SetCornerRadius( unsigned int aRadius );
651
652 unsigned int GetCornerRadius() const { return m_cornerRadius; }
653
660 void RemoveCutout( int aOutlineIdx, int aHoleIdx );
661
668 void AddPolygon( std::vector<VECTOR2I>& aPolygon );
669
670 void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
671
672 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
673
674 BITMAPS GetMenuImage() const override;
675
676 EDA_ITEM* Clone() const override;
677
682
688
693
697 bool GetIsRuleArea() const { return m_isRuleArea; }
699 bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
701 bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
703
704 void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
705 void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
706 void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
707 void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
708 void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
709 void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
710
713
714 long long int GetMinIslandArea() const { return m_minIslandArea; }
715 void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
716
724 int GetBorderHatchPitch() const;
725
729 static int GetDefaultHatchPitch();
730
740 void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
741 bool aRebuilBorderdHatch );
742
748 void SetBorderHatchPitch( int aPitch );
749
753 void UnHatchBorder();
754
759 void HatchBorder();
760
761 const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
762
767 void BuildHashValue( PCB_LAYER_ID aLayer );
768
773
774#if defined(DEBUG)
775 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
776
777 void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly )
778 {
779 m_FilledPolysList[ aLayer ] = std::make_shared<SHAPE_POLY_SET>( *aPoly );
780 SetFillFlag( aLayer, true );
781 }
782
783#endif
784
785protected:
786 virtual void swapData( BOARD_ITEM* aImage ) override;
787
788protected:
791 unsigned int m_cornerRadius;
792
794 wxString m_zoneName;
795
797
798 /* Priority: when a zone outline is inside and other zone, if its priority is higher
799 * the other zone priority, it will be created inside.
800 * if priorities are equal, a DRC error is set
801 */
802 unsigned m_priority;
803
804 /* A zone outline can be a keepout zone.
805 * It will be never filled, and DRC should test for pads, tracks and vias
806 */
808
809 /* A zone outline can be a teardrop zone with different rules for priority
810 * (always bigger priority than copper zones) and never removed from a
811 * copper zone having the same netcode
812 */
814
815 /* For keepout zones only:
816 * what is not allowed inside the keepout ( pads, tracks and vias )
817 */
823
825 int m_ZoneClearance; // Clearance value in internal units.
826 int m_ZoneMinThickness; // Minimum thickness value in filled areas.
827 int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
828 // differences.
830
835 long long int m_minIslandArea;
836
839
846
847 int m_thermalReliefGap; // Width of the gap in thermal reliefs.
848 int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
849
850
858 int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
859 int m_hatchGap; // gap between lines (0 -> solid shape
860 EDA_ANGLE m_hatchOrientation; // orientation of grid lines
861 int m_hatchSmoothingLevel; // 0 = no smoothing
862 // 1 = fillet
863 // 2 = arc low def
864 // 3 = arc high def
865 double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
866 double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
867 int m_hatchBorderAlgorithm; // 0 = use min zone thickness
868 // 1 = use hatch thickness
869
872
873 int m_localFlgs; // Variable used in polygon calculations.
874
875 /* set of filled polygons used to draw a zone as a filled area.
876 * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
877 * (they are all in one piece) In very simple cases m_FilledPolysList is same
878 * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
879 * a polygon equivalent to m_Poly, without holes but with extra outline segment
880 * connecting "holes" with external main outline. In complex cases an outline
881 * described by m_Poly can have many filled areas
882 */
883 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
884
887
889 std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
890
891 ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
892 int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
893 std::vector<SEG> m_borderHatchLines; // hatch lines
894
896 std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
897
898 double m_area; // The filled zone area
899 double m_outlinearea; // The outline zone area
900
902 std::mutex m_lock;
903};
904
905
909class FP_ZONE : public ZONE
910{
911public:
912 FP_ZONE( BOARD_ITEM_CONTAINER* aParent );
913 FP_ZONE( const FP_ZONE& aZone );
914 FP_ZONE& operator=( const FP_ZONE &aOther );
915
916 EDA_ITEM* Clone() const override;
917
918 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
919};
920
921#ifndef SWIG
924#endif
925
926#endif // ZONE_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
DECLARE_ENUM_TO_WXANY(PCB_LAYER_ID)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:382
A specialization of ZONE for use in footprints.
Definition: zone.h:910
FP_ZONE(BOARD_ITEM_CONTAINER *aParent)
Definition: zone.cpp:1258
FP_ZONE & operator=(const FP_ZONE &aOther)
Definition: zone.cpp:1274
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:1287
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:1281
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:81
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Definition: pad.h:59
The main frame for Pcbnew.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
Represent a set of closed polygons.
ITERATOR IterateWithHoles(int aOutline)
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int TotalVertices() const
Delete aIdx-th polygon from the set.
bool GetRelativeIndices(int aGlobalIdx, VERTEX_INDEX *aRelativeIndices) const
Convert a global vertex index —i.e., a number that globally identifies a vertex in a concatenated lis...
bool GetGlobalIndex(VERTEX_INDEX aRelativeIndices, int &aGlobalIdx) const
Compute the global index of a vertex from the relative indices of polygon, contour and vertex.
int NewHole(int aOutline=-1)
Adds a new outline to the set and returns its index.
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Return an object to iterate through the points of the polygons between aFirst and aLast.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
CONST_ITERATOR CIterateWithHoles(int aOutline) const
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void SetHatchThickness(int aThickness)
Definition: zone.h:261
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
Definition: zone.h:871
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:246
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
Definition: zone.h:225
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if a point is near an outline edge or a corner of this zone.
Definition: zone.cpp:405
void SetHatchBorderAlgorithm(int aAlgo)
Definition: zone.h:279
int m_borderHatchPitch
Definition: zone.h:892
const SHAPE_POLY_SET * Outline() const
Definition: zone.h:313
bool m_isRuleArea
Definition: zone.h:807
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:708
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: zone.cpp:780
int GetHatchBorderAlgorithm() const
Definition: zone.h:278
ZONE & operator=(const ZONE &aOther)
Definition: zone.cpp:82
int m_cornerSmoothingType
Definition: zone.h:790
void Mirror(const VECTOR2I &aMirrorRef, bool aMirrorLeftRight)
Mirror the outlines relative to a given horizontal axis the layer is not changed.
Definition: zone.cpp:703
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:697
bool m_doNotAllowVias
Definition: zone.h:819
bool UnFill()
Removes the zone filling.
Definition: zone.cpp:209
bool NeedRefill() const
Definition: zone.h:245
bool GetDoNotAllowVias() const
Definition: zone.h:699
void TransformSolidAreasShapesToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aBuffer) const
Convert solid areas full shapes to polygon set (the full shape is the polygon area with a thick outli...
Definition: zone.cpp:1348
void SetCornerRadius(unsigned int aRadius)
Definition: zone.cpp:375
ZONE_FILL_MODE m_fillMode
How to fill areas:
Definition: zone.h:857
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:761
void SetPosition(const VECTOR2I &aPos) override
Definition: zone.h:102
bool m_doNotAllowFootprints
Definition: zone.h:822
int m_ZoneMinThickness
Definition: zone.h:826
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: zone.cpp:293
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:743
double m_hatchSmoothingValue
Definition: zone.h:865
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:602
void SetLocalFlags(int aFlags)
Definition: zone.h:310
void TransformSmoothedOutlineToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, SHAPE_POLY_SET *aBoardOutline) const
Convert the outlines shape to a polygon with no holes inflated (optional) by max( aClearanceValue,...
Definition: zone.cpp:1225
void SetCornerSmoothingType(int aType)
Definition: zone.h:646
int m_thermalReliefSpokeWidth
Definition: zone.h:848
bool HitTestCutout(const VECTOR2I &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Test if the given point is contained within a cutout of the zone.
Definition: zone.cpp:496
EDA_ANGLE m_hatchOrientation
Definition: zone.h:860
void CacheTriangulation(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Create a list of triangles that "fill" the solid areas used for instance to draw these solid areas on...
Definition: zone.cpp:1005
std::map< PCB_LAYER_ID, std::set< int > > m_insulatedIslands
For each layer, a set of insulated islands that were not removed.
Definition: zone.h:896
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: zone.h:794
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:855
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_POLY_SET > > m_FilledPolysList
Definition: zone.h:883
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:711
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:820
MD5_HASH GetHashValue(PCB_LAYER_ID aLayer)
Definition: zone.cpp:387
bool GetDoNotAllowPads() const
Definition: zone.h:701
const BOX2I GetBoundingBox() const override
Definition: zone.cpp:323
void SetMinThickness(int aMinThickness)
Definition: zone.h:252
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
Definition: zone.h:215
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: zone.h:127
double m_outlinearea
Definition: zone.h:899
wxString GetFriendlyName() const override
Definition: zone.cpp:656
bool GetDoNotAllowTracks() const
Definition: zone.h:700
int GetLocalFlags() const
Definition: zone.h:309
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:180
void SetHatchOrientation(const EDA_ANGLE &aStep)
Definition: zone.h:267
wxString GetClass() const override
Definition: zone.h:482
bool m_doNotAllowCopperPour
Definition: zone.h:818
void SetHatchSmoothingValue(double aValue)
Definition: zone.h:273
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition: zone.h:845
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:510
virtual void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: zone.cpp:695
bool IsSame(const ZONE &aZoneToCompare)
Test if 2 zones are equivalent.
bool IsFilled() const
Definition: zone.h:242
bool HitTestForCorner(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a corner.
Definition: zone.cpp:415
void SetHatchSmoothingLevel(int aLevel)
Definition: zone.h:270
bool m_doNotAllowTracks
Definition: zone.h:820
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition: zone.h:82
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:705
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:187
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:239
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:260
LSET m_fillFlags
Temp variables used while filling.
Definition: zone.h:886
void SetSelectedCorner(int aCorner)
Definition: zone.h:292
int GetSelectedCorner() const
Definition: zone.h:281
SHAPE_POLY_SET * Outline()
Definition: zone.h:312
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:581
bool m_doNotAllowPads
Definition: zone.h:821
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:564
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition: zone.h:240
void SetCornerPosition(int aCornerIndex, const VECTOR2I &new_pos)
Definition: zone.h:541
void Move(const VECTOR2I &offset) override
Move the outlines.
Definition: zone.cpp:629
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1022
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: zone.h:789
TEARDROP_TYPE m_teardropType
Definition: zone.h:813
~ZONE()
Definition: zone.cpp:92
long long int GetMinIslandArea() const
Definition: zone.h:714
int m_hatchSmoothingLevel
Definition: zone.h:861
int GetLocalClearance() const
Definition: zone.h:152
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
Definition: zone.h:608
LSET m_layerSet
Definition: zone.h:796
void SetIsRuleArea(bool aEnable)
Definition: zone.h:704
int m_ZoneClearance
Definition: zone.h:825
wxString GetZoneName() const
Definition: zone.h:124
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:707
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:623
void CacheBoundingBox()
Used to preload the zone bounding box cache so we don't have to worry about mutex-locking it each tim...
Definition: zone.cpp:345
int GetMinThickness() const
Definition: zone.h:251
virtual void swapData(BOARD_ITEM *aImage) override
Definition: zone.cpp:997
bool HitTestForEdge(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a segment defined by 2 corners.
Definition: zone.cpp:422
static bool ClassOf(const EDA_ITEM *aItem)
Definition: zone.h:74
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:714
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
Definition: zone.cpp:684
bool HigherPriority(const ZONE *aOther) const
Definition: zone.cpp:186
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const VECTOR2I &aRefPos, int aAccuracy=0) const
Test if the given VECTOR2I is within the bounds of a filled area of this zone.
Definition: zone.cpp:482
void SetIsFilled(bool isFilled)
Definition: zone.h:243
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:173
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition: zone.h:235
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: zone.cpp:991
int m_hatchGap
Definition: zone.h:859
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:248
void InitDataFromSrcInCopyCtor(const ZONE &aZone)
Copy aZone data to me.
Definition: zone.cpp:102
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition: zone.h:594
int GetHatchThickness() const
Definition: zone.h:260
double GetHatchHoleMinArea() const
Definition: zone.h:275
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: zone.cpp:521
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:317
int m_hatchBorderAlgorithm
Definition: zone.h:867
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:706
bool IsTeardropArea() const
Definition: zone.h:681
std::vector< SEG > m_borderHatchLines
Definition: zone.h:893
VECTOR2I GetPosition() const override
Definition: zone.cpp:233
int GetThermalReliefSpokeWidth() const
Definition: zone.h:195
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:814
void SetLocalClearance(int aClearance)
Definition: zone.h:153
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:580
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition: zone.cpp:396
void SetThermalReliefGap(int aThermalReliefGap)
Definition: zone.h:176
EDA_ANGLE GetHatchOrientation() const
Definition: zone.h:266
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:266
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition: zone.cpp:1069
int m_fillVersion
Definition: zone.h:827
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: zone.h:530
bool GetDoNotAllowFootprints() const
Definition: zone.h:702
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:174
double m_hatchHoleMinArea
Definition: zone.h:866
SHAPE_POLY_SET::CONST_ITERATOR CIterateWithHoles() const
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:520
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition: zone.h:500
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:122
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:709
bool GetDoNotAllowCopperPour() const
Definition: zone.h:698
void SetBorderHatchPitch(int aPitch)
Set the hatch pitch parameter for the zone.
Definition: zone.cpp:835
void GetInteractingZones(PCB_LAYER_ID aLayer, std::vector< ZONE * > *aSameNetCollidingZones, std::vector< ZONE * > *aOtherNetIntersectingZones) const
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
Definition: zone.cpp:1034
int GetHatchGap() const
Definition: zone.h:263
double CalculateOutlineArea()
Compute the area of the zone outline (not the filled area).
Definition: zone.cpp:1218
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: zone.h:902
void SetHatchHoleMinArea(double aPct)
Definition: zone.h:276
unsigned m_priority
Definition: zone.h:802
TEARDROP_TYPE GetTeardropAreaType() const
Definition: zone.h:692
bool IsConflicting() const
For rule areas which exclude footprints (and therefore participate in courtyard conflicts during move...
Definition: zone.cpp:227
std::map< PCB_LAYER_ID, MD5_HASH > m_filledPolysHash
A hash value used in zone filling calculations to see if the filled areas are up to date.
Definition: zone.h:889
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition: zone.h:829
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition: zone.h:838
double GetHatchSmoothingValue() const
Definition: zone.h:272
ZONE(BOARD_ITEM_CONTAINER *parent, bool aInFP=false)
The ctor to build ZONE, but compatible with FP_ZONE requirement.
Definition: zone.cpp:43
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: zone.cpp:760
void MoveEdge(const VECTOR2I &offset, int aEdge)
Move the outline Edge.
Definition: zone.cpp:669
int GetHatchSmoothingLevel() const
Definition: zone.h:269
unsigned int GetCornerRadius() const
Definition: zone.h:652
int GetCornerSmoothingType() const
Definition: zone.h:648
int m_thermalReliefGap
Definition: zone.h:847
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:309
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition: zone.h:637
int m_localFlgs
Definition: zone.h:873
bool IsOnCopperLayer() const override
Definition: zone.cpp:254
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition: zone.cpp:1195
int m_hatchThickness
Definition: zone.h:858
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the zone shape to a closed polygon Used in filling zones calculations Circles and arcs are ap...
Definition: zone.cpp:1320
void SetAssignedPriority(unsigned aPriority)
Definition: zone.h:107
double m_area
Definition: zone.h:898
unsigned int m_cornerRadius
Definition: zone.h:791
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: zone.h:249
std::mutex & GetLock()
Definition: zone.h:230
void SetZoneName(const wxString &aName)
Definition: zone.h:125
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:687
void UnHatchBorder()
Clear the zone's hatch.
Definition: zone.cpp:841
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition: zone.h:712
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition: zone.h:315
PCB_LAYER_ID GetFirstLayer() const
Definition: zone.cpp:245
void SetMinIslandArea(long long int aArea)
Definition: zone.h:715
ZONE_CONNECTION m_PadConnection
Definition: zone.h:824
int GetThermalReliefGap() const
Definition: zone.h:184
void RemoveAllContours(void)
Definition: zone.h:525
void SetHatchGap(int aStep)
Definition: zone.h:264
static int GetDefaultHatchPitch()
Definition: zone.cpp:985
unsigned GetAssignedPriority() const
Definition: zone.h:112
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: zone.h:490
bool SameNet(const ZONE *aOther) const
Definition: zone.cpp:203
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: zone.cpp:1311
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition: zone.h:891
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition: zone.h:835
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
TEARDROP_TYPE
define the type of a teardrop: on a via or pad, or a track end
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:57
ZONE_FILL_MODE
Definition: zone_settings.h:41
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:49
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:50