KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 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, 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 <map>
32#include <board_item.h>
34#include <layer_ids.h>
35#include <lset.h>
37#include <zone_settings.h>
39
40
41class LINE_READER;
42class PCB_EDIT_FRAME;
43class BOARD;
44class ZONE;
45class MSG_PANEL_ITEM;
46
47
60{
61 std::vector<int> m_IsolatedOutlines;
63};
64
65
73{
74public:
75 ZONE( BOARD_ITEM_CONTAINER* parent );
76
77 ZONE( const ZONE& aZone );
78 ZONE& operator=( const ZONE &aOther );
79
80 ~ZONE();
81
82 void CopyFrom( const BOARD_ITEM* aOther ) override;
83
84 static inline bool ClassOf( const EDA_ITEM* aItem )
85 {
86 return aItem && aItem->Type() == PCB_ZONE_T;
87 }
88
89 void Serialize( google::protobuf::Any &aContainer ) const override;
90 bool Deserialize( const google::protobuf::Any &aContainer ) override;
91
95 bool IsConnected() const override
96 {
97 return !GetIsRuleArea();
98 }
99
103 void InitDataFromSrcInCopyCtor( const ZONE& aZone, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
104
109 bool IsConflicting() const;
110
114 VECTOR2I GetPosition() const override;
115 void SetPosition( const VECTOR2I& aPos ) override {}
116
120 void SetAssignedPriority( unsigned aPriority ) { m_priority = aPriority; }
121
125 unsigned GetAssignedPriority() const { return m_priority; }
126
127 bool HigherPriority( const ZONE* aOther ) const;
128
129 bool SameNet( const ZONE* aOther ) const;
130
131 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
132 wxString GetFriendlyName() const override;
133
134 void SetLayerSet( const LSET& aLayerSet ) override;
135
136 virtual LSET GetLayerSet() const override
137 {
138 std::lock_guard<std::mutex> lock( m_layerSetMutex );
139 return m_layerSet;
140 }
141
147 void SetLayerSetAndRemoveUnusedFills( const LSET& aLayerSet );
148
150 {
151 return m_layerProperties[aLayer];
152 }
153
154 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& LayerProperties() { return m_layerProperties; }
155
156 const std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& LayerProperties() const
157 {
158 return m_layerProperties;
159 }
160
161 void SetLayerProperties( const std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& aOther );
162
163 const wxString& GetZoneName() const { return m_zoneName; }
164 void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
165
166 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
167 {
168 return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
169 }
170
174 const BOX2I GetBoundingBox() const override;
175
180 void CacheBoundingBox();
181
185 std::optional<int> GetLocalClearance() const override;
186 void SetLocalClearance( std::optional<int> aClearance ) { m_ZoneClearance = aClearance.value_or( 0 ); };
187
194 std::optional<int> GetLocalClearance( wxString* aSource ) const override
195 {
196 if( m_isRuleArea )
197 return std::optional<int>();
198
199 if( aSource )
200 *aSource = _( "zone" );
201
202 return GetLocalClearance();
203 }
204
208 bool IsOnCopperLayer() const override;
209
210 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
211
212 virtual PCB_LAYER_ID GetLayer() const override;
213
214 // Return the first layer in GUI sequence.
216
217 virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
218
219 virtual std::vector<int> ViewGetLayers() const override;
220
221 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
222
223 void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
225
226 void SetThermalReliefGap( int aThermalReliefGap )
227 {
228 if( m_thermalReliefGap != aThermalReliefGap )
229 SetNeedRefill( true );
230
231 m_thermalReliefGap = aThermalReliefGap;
232 }
233
235 int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
236
237 void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
238 {
239 if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
240 SetNeedRefill( true );
241
242 m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
243 }
244
246
252 double CalculateFilledArea();
253
258 double CalculateOutlineArea();
259
266 {
267 return m_area;
268 }
269
276 {
277 return m_outlinearea;
278 }
279
280 std::mutex& GetLock()
281 {
282 return m_lock;
283 }
284
286 {
287 std::lock_guard<std::mutex> lock( m_fillFlagsMutex );
288 return m_fillFlags.test( aLayer );
289 }
290
291 void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag )
292 {
293 std::lock_guard<std::mutex> lock( m_fillFlagsMutex );
294 m_fillFlags.set( aLayer, aFlag );
295 }
296
297 bool IsFilled() const { return m_isFilled; }
298 void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
299
300 bool NeedRefill() const { return m_needRefill; }
301 void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
302
304 void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
305
306 int GetMinThickness() const { return m_ZoneMinThickness; }
307 void SetMinThickness( int aMinThickness )
308 {
309 m_ZoneMinThickness = aMinThickness;
310 m_hatchThickness = std::max( m_hatchThickness, aMinThickness );
311 m_hatchGap = std::max( m_hatchGap, aMinThickness );
312 SetNeedRefill( true );
313 }
314
315 int GetHatchThickness() const { return m_hatchThickness; }
316 void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
317
318 int GetHatchGap() const { return m_hatchGap; }
319 void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
320
322 void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; }
323
325 void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
326
328 void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
329
330 double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
331 void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
332
334 void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
335
337 int GetLocalFlags() const { return m_localFlgs; }
338 void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
339
341 const SHAPE_POLY_SET* Outline() const { return m_Poly; }
342
343 void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
344
345 // @copydoc BOARD_ITEM::GetEffectiveShape
346 virtual std::shared_ptr<SHAPE>
348 FLASHING aFlash = FLASHING::DEFAULT ) const override;
349
356 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
357
366 bool HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy = 0 ) const;
367
376 bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
377 int* aHoleIdx = nullptr ) const;
378
384 void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
385 std::vector<ZONE*>* aOtherNetIntersectingZones ) const;
386
398
410 void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
411 int aError, ERROR_LOC aErrorLoc,
412 SHAPE_POLY_SET* aBoardOutline ) const;
413
427 int aClearance, int aError, ERROR_LOC aErrorLoc,
428 bool ignoreLineWidth = false ) const override;
429
440 bool HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
441 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
442
452 bool HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
453 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
454
458 bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
459
463 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
464
470 bool UnFill();
471
472 /* Geometric transformations: */
473
479 void Move( const VECTOR2I& offset ) override;
480
487 void MoveEdge( const VECTOR2I& offset, int aEdge );
488
494 void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
495
503 virtual void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
504
511 void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection ) override;
512
516 wxString GetClass() const override
517 {
518 return wxT( "ZONE" );
519 }
520
524 int GetNumCorners( void ) const
525 {
526 return m_Poly->TotalVertices();
527 }
528
535 {
536 return m_Poly->Iterate();
537 }
538
545 {
546 return m_Poly->IterateWithHoles();
547 }
548
555 {
556 return m_Poly->CIterateWithHoles();
557 }
558
559 void RemoveAllContours( void )
560 {
561 m_Poly->RemoveAllContours();
562 }
563
564 const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
565 {
567
568 // Convert global to relative indices
569 if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
570 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
571
572 return m_Poly->CVertex( index );
573 }
574
578 void NewHole()
579 {
580 m_Poly->NewHole();
581 }
582
592 bool AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication = false );
593
596
598 {
599 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
600 return m_FilledPolysList.count( aLayer ) > 0;
601 }
602
606 std::shared_ptr<SHAPE_POLY_SET> GetFilledPolysList( PCB_LAYER_ID aLayer ) const
607 {
608 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
609 wxASSERT( m_FilledPolysList.count( aLayer ) );
610 return m_FilledPolysList.at( aLayer );
611 }
612
614 {
615 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
616
617 auto it = m_FilledPolysList.find( aLayer );
618
619 if( it == m_FilledPolysList.end() )
620 return nullptr;
621
622 return it->second.get();
623 }
624
630
634 void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
635 {
636 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
637 m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
638 }
639
647 bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
648
649 void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
650 {
651 m_insulatedIslands[aLayer].insert( aPolyIdx );
652 }
653
654 bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
655 SHAPE_POLY_SET* aBoardOutline,
656 SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
657
658 void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
659
661
662 void SetCornerRadius( unsigned int aRadius );
663
664 unsigned int GetCornerRadius() const { return m_cornerRadius; }
665
672 void RemoveCutout( int aOutlineIdx, int aHoleIdx );
673
680 void AddPolygon( std::vector<VECTOR2I>& aPolygon );
681
682 void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
683
684 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
685
686 BITMAPS GetMenuImage() const override;
687
688 EDA_ITEM* Clone() const override;
689 ZONE* Clone( PCB_LAYER_ID aLayer ) const;
690
695
701
706
715
719 bool GetIsRuleArea() const { return m_isRuleArea; }
720 void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
722 void SetPlacementAreaEnabled( bool aEnabled ) { m_placementAreaEnabled = aEnabled; }
723
725 void SetPlacementAreaSource( const wxString& aSource ) { m_placementAreaSource = aSource; }
728
730 bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
732 bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
734
735 void SetDoNotAllowZoneFills( bool aEnable ) { m_doNotAllowZoneFills = aEnable; }
736 void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
737 void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
738 void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
739 void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
740
743
744 long long int GetMinIslandArea() const { return m_minIslandArea; }
745 void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
746
750
755 void SetBorderHatchPitch( int aPitch ) { m_borderHatchPitch = aPitch; }
756
760 static int GetDefaultHatchPitch();
761
771 void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
772 bool aRebuilBorderdHatch );
773
777 void UnHatchBorder();
778
783 void HatchBorder();
784
785 const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
786
791 void BuildHashValue( PCB_LAYER_ID aLayer );
792
797
798 double Similarity( const BOARD_ITEM& aOther ) const override;
799
800 bool operator==( const ZONE& aOther ) const;
801 bool operator==( const BOARD_ITEM& aOther ) const override;
802
803#if defined(DEBUG)
804 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
805
806 void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly )
807 {
808 {
809 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
810 m_FilledPolysList[ aLayer ] = std::make_shared<SHAPE_POLY_SET>( *aPoly );
811 }
812
813 SetFillFlag( aLayer, true );
814 }
815
816#endif
817
818private:
824 bool unFillLocked();
825
826protected:
827 virtual void swapData( BOARD_ITEM* aImage ) override;
828
829protected:
832 unsigned int m_cornerRadius;
833
835 wxString m_zoneName;
836
837 mutable std::mutex m_layerSetMutex;
839
840 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> m_layerProperties;
841
842 /* Priority: when a zone outline is inside and other zone, if its priority is higher
843 * the other zone priority, it will be created inside.
844 * if priorities are equal, a DRC error is set
845 */
846 unsigned m_priority;
847
848 /* A zone outline can be a keepout zone.
849 * It will be never filled, and DRC should test for pads, tracks and vias
850 */
852
859
860 /* A zone outline can be a teardrop zone with different rules for priority
861 * (always bigger priority than copper zones) and never removed from a
862 * copper zone having the same netcode
863 */
865
866 /* For keepout zones only:
867 * what is not allowed inside the keepout ( pads, tracks and vias )
868 */
874
876 int m_ZoneClearance; // Clearance value in internal units.
877 int m_ZoneMinThickness; // Minimum thickness value in filled areas.
878 int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
879 // differences.
881
886 long long int m_minIslandArea;
887
890
897
898 int m_thermalReliefGap; // Width of the gap in thermal reliefs.
899 int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
900
901 ZONE_FILL_MODE m_fillMode; // fill with POLYGONS vs HATCH_PATTERN
902 int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
903 int m_hatchGap; // gap between lines (0 -> solid shape
904 EDA_ANGLE m_hatchOrientation; // orientation of grid lines
905 int m_hatchSmoothingLevel; // 0 = no smoothing
906 // 1 = fillet
907 // 2 = arc low def
908 // 3 = arc high def
909 double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
910 double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
911 int m_hatchBorderAlgorithm; // 0 = use min zone thickness
912 // 1 = use hatch thickness
913 int m_localFlgs; // Variable used in polygon calculations.
914
915 /* set of filled polygons used to draw a zone as a filled area.
916 * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
917 * (they are all in one piece) In very simple cases m_FilledPolysList is same
918 * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
919 * a polygon equivalent to m_Poly, without holes but with extra outline segment
920 * connecting "holes" with external main outline. In complex cases an outline
921 * described by m_Poly can have many filled areas
922 */
923 mutable std::mutex m_filledPolysListMutex;
924 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
925
927 mutable std::mutex m_fillFlagsMutex;
929
931 std::map<PCB_LAYER_ID, HASH_128> m_filledPolysHash;
932
933 ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
934 int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
935 std::vector<SEG> m_borderHatchLines; // hatch lines
936
938 std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
939
940 double m_area; // The filled zone area
941 double m_outlinearea; // The outline zone area
942
944 std::mutex m_lock;
945};
946
947
948#ifndef SWIG
953#endif
954
955#endif // ZONE_H
int index
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
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:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
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:99
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:111
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:407
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:67
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:66
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:54
Definition pad.h:55
The main frame for Pcbnew.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
ITERATOR_TEMPLATE< VECTOR2I > ITERATOR
ITERATOR_TEMPLATE< const VECTOR2I > CONST_ITERATOR
Handle a list of polygons defining a copper zone.
Definition zone.h:73
void SetHatchThickness(int aThickness)
Definition zone.h:316
void SetNeedRefill(bool aNeedRefill)
Definition zone.h:301
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
Definition zone.h:275
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:735
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition zone.cpp:1203
void SetHatchBorderAlgorithm(int aAlgo)
Definition zone.h:334
int m_borderHatchPitch
Definition zone.h:934
wxString m_placementAreaSource
Definition zone.h:858
const SHAPE_POLY_SET * Outline() const
Definition zone.h:341
bool m_isRuleArea
Definition zone.h:851
void SetDoNotAllowPads(bool aEnable)
Definition zone.h:738
void SetLayerProperties(const std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aOther)
Definition zone.cpp:592
int GetHatchBorderAlgorithm() const
Definition zone.h:333
ZONE & operator=(const ZONE &aOther)
Definition zone.cpp:105
int m_cornerSmoothingType
Definition zone.h:831
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:719
PLACEMENT_SOURCE_T m_placementAreaSourceType
Definition zone.h:857
std::optional< int > GetLocalClearance() const override
Definition zone.cpp:846
void SetLocalClearance(std::optional< int > aClearance)
Definition zone.h:186
bool m_doNotAllowVias
Definition zone.h:870
bool UnFill()
Removes the zone filling.
Definition zone.cpp:456
bool NeedRefill() const
Definition zone.h:300
bool GetDoNotAllowVias() const
Definition zone.h:730
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:1670
void SetCornerRadius(unsigned int aRadius)
Definition zone.cpp:703
ZONE_FILL_MODE m_fillMode
Definition zone.h:901
const std::vector< SEG > & GetHatchLines() const
Definition zone.h:785
void SetPosition(const VECTOR2I &aPos) override
Definition zone.h:115
bool m_doNotAllowFootprints
Definition zone.h:873
bool unFillLocked()
Internal implementation of UnFill() that assumes the caller already holds m_filledPolysListMutex.
Definition zone.cpp:464
int m_ZoneMinThickness
Definition zone.h:877
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition zone.cpp:1166
ZONE_LAYER_PROPERTIES & LayerProperties(PCB_LAYER_ID aLayer)
Definition zone.h:149
double m_hatchSmoothingValue
Definition zone.h:909
void SetLocalFlags(int aFlags)
Definition zone.h:338
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:1597
void SetCornerSmoothingType(int aType)
Definition zone.h:658
int m_thermalReliefSpokeWidth
Definition zone.h:899
wxString GetPlacementAreaSource() const
Definition zone.h:724
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:874
EDA_ANGLE m_hatchOrientation
Definition zone.h:904
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:1353
void Mirror(const VECTOR2I &aMirrorRef, FLIP_DIRECTION aFlipDirection) override
Mirror the outlines relative to a given horizontal axis the layer is not changed.
Definition zone.cpp:1126
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:938
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition zone.h:835
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition zone.cpp:1293
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_POLY_SET > > m_FilledPolysList
Definition zone.h:924
std::optional< int > GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition zone.h:194
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition zone.cpp:1274
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:606
bool GetDoNotAllowPads() const
Definition zone.h:732
const BOX2I GetBoundingBox() const override
Definition zone.cpp:651
void SetMinThickness(int aMinThickness)
Definition zone.h:307
void SetPlacementAreaSource(const wxString &aSource)
Definition zone.h:725
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition zone.cpp:619
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
Definition zone.h:265
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
Definition zone.h:726
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition zone.h:166
double m_outlinearea
Definition zone.h:941
std::mutex m_filledPolysListMutex
Definition zone.h:923
wxString GetFriendlyName() const override
Definition zone.cpp:1055
bool GetDoNotAllowTracks() const
Definition zone.h:731
std::mutex m_fillFlagsMutex
Temp variables used while filling.
Definition zone.h:927
int GetLocalFlags() const
Definition zone.h:337
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition zone.cpp:218
void SetHatchOrientation(const EDA_ANGLE &aStep)
Definition zone.h:322
wxString GetClass() const override
Definition zone.h:516
void SetHatchSmoothingValue(double aValue)
Definition zone.h:328
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition zone.h:896
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition zone.h:544
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_layerProperties
Definition zone.h:840
bool IsFilled() const
Definition zone.h:297
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:745
void SetHatchSmoothingLevel(int aLevel)
Definition zone.h:325
bool m_doNotAllowTracks
Definition zone.h:871
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition zone.h:95
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition zone.h:237
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition zone.cpp:501
void SetPlacementAreaSourceType(PLACEMENT_SOURCE_T aType)
Definition zone.h:727
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition zone.cpp:550
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition zone.h:741
LSET m_fillFlags
Definition zone.h:928
SHAPE_POLY_SET * Outline()
Definition zone.h:340
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition zone.h:595
bool m_doNotAllowPads
Definition zone.h:872
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition zone.h:578
ZONE(BOARD_ITEM_CONTAINER *parent)
Definition zone.cpp:56
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition zone.h:291
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition zone.cpp:232
void Move(const VECTOR2I &offset) override
Move the outlines.
Definition zone.cpp:1028
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition zone.cpp:1372
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition zone.h:830
TEARDROP_TYPE m_teardropType
Definition zone.h:864
std::map< PCB_LAYER_ID, HASH_128 > m_filledPolysHash
A hash value used in zone filling calculations to see if the filled areas are up to date.
Definition zone.h:931
~ZONE()
Definition zone.cpp:122
long long int GetMinIslandArea() const
Definition zone.h:744
int m_hatchSmoothingLevel
Definition zone.h:905
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition zone.cpp:1783
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
Definition zone.h:613
LSET m_layerSet
Definition zone.h:838
void SetIsRuleArea(bool aEnable)
Definition zone.h:720
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > & LayerProperties()
Definition zone.h:154
int m_ZoneClearance
Definition zone.h:876
void CopyFrom(const BOARD_ITEM *aOther) override
Definition zone.cpp:115
void SetDoNotAllowTracks(bool aEnable)
Definition zone.h:737
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition zone.h:634
bool m_placementAreaEnabled
Placement rule area data.
Definition zone.h:856
const wxString & GetZoneName() const
Definition zone.h:163
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:680
int GetMinThickness() const
Definition zone.h:306
virtual void swapData(BOARD_ITEM *aImage) override
Definition zone.cpp:1345
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:752
static bool ClassOf(const EDA_ITEM *aItem)
Definition zone.h:84
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition zone.cpp:1137
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
Definition zone.cpp:1083
bool HigherPriority(const ZONE *aOther) const
Definition zone.cpp:436
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:852
void SetIsFilled(bool isFilled)
Definition zone.h:298
std::mutex m_layerSetMutex
Definition zone.h:837
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition zone.h:223
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition zone.h:285
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition zone.cpp:1339
int m_hatchGap
Definition zone.h:903
ZONE_CONNECTION GetPadConnection() const
Definition zone.h:303
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition zone.h:597
int GetHatchThickness() const
Definition zone.h:315
double GetHatchHoleMinArea() const
Definition zone.h:330
void SetLayerSet(const LSET &aLayerSet) override
Definition zone.cpp:556
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:899
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition zone.cpp:644
int m_hatchBorderAlgorithm
Definition zone.h:911
bool GetPlacementAreaEnabled() const
Definition zone.h:721
void SetDoNotAllowVias(bool aEnable)
Definition zone.h:736
bool IsTeardropArea() const
Definition zone.h:694
std::vector< SEG > m_borderHatchLines
Definition zone.h:935
VECTOR2I GetPosition() const override
Definition zone.cpp:492
int GetThermalReliefSpokeWidth() const
Definition zone.h:245
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition zone.h:754
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition zone.cpp:1094
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition zone.h:594
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition zone.cpp:724
void SetThermalReliefGap(int aThermalReliefGap)
Definition zone.h:226
EDA_ANGLE GetHatchOrientation() const
Definition zone.h:321
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition zone.cpp:1419
int m_fillVersion
Definition zone.h:878
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition zone.h:564
bool GetDoNotAllowFootprints() const
Definition zone.h:733
ZONE_FILL_MODE GetFillMode() const
Definition zone.h:224
double m_hatchHoleMinArea
Definition zone.h:910
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:554
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition zone.h:534
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:136
void SetDoNotAllowFootprints(bool aEnable)
Definition zone.h:739
bool HasKeepoutParametersSet() const
Accessor to determine if any keepout parameters are set.
Definition zone.h:710
void SetBorderHatchPitch(int aPitch)
Definition zone.h:755
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:1384
void SetLayerSetAndRemoveUnusedFills(const LSET &aLayerSet)
Set the zone to be on the aLayerSet layers and only remove the fill polygons from the unused layers,...
Definition zone.cpp:1679
int GetHatchGap() const
Definition zone.h:318
double CalculateOutlineArea()
Compute the area of the zone outline (not the filled area).
Definition zone.cpp:1590
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition zone.h:944
void SetHatchHoleMinArea(double aPct)
Definition zone.h:331
unsigned m_priority
Definition zone.h:846
TEARDROP_TYPE GetTeardropAreaType() const
Definition zone.h:705
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition zone.cpp:334
bool IsConflicting() const
For rule areas which exclude footprints (and therefore participate in courtyard conflicts during move...
Definition zone.cpp:486
bool m_doNotAllowZoneFills
Definition zone.h:869
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition zone.h:880
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition zone.h:889
double GetHatchSmoothingValue() const
Definition zone.h:327
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:1183
bool GetDoNotAllowZoneFills() const
Definition zone.h:729
void MoveEdge(const VECTOR2I &offset, int aEdge)
Move the outline Edge.
Definition zone.cpp:1068
int GetHatchSmoothingLevel() const
Definition zone.h:324
unsigned int GetCornerRadius() const
Definition zone.h:664
int GetCornerSmoothingType() const
Definition zone.h:660
int m_thermalReliefGap
Definition zone.h:898
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition zone.h:649
int m_localFlgs
Definition zone.h:913
bool IsOnCopperLayer() const override
Definition zone.cpp:543
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition zone.cpp:1579
void SetDoNotAllowZoneFills(bool aEnable)
Definition zone.h:735
int m_hatchThickness
Definition zone.h:902
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:1633
void SetAssignedPriority(unsigned aPriority)
Definition zone.h:120
double m_area
Definition zone.h:940
unsigned int m_cornerRadius
Definition zone.h:832
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition zone.h:304
std::mutex & GetLock()
Definition zone.h:280
void SetZoneName(const wxString &aName)
Definition zone.h:164
bool operator==(const ZONE &aOther) const
Definition zone.cpp:1715
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:700
void UnHatchBorder()
Clear the zone's hatch.
Definition zone.cpp:1287
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition zone.h:742
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition zone.h:343
PCB_LAYER_ID GetFirstLayer() const
Definition zone.cpp:523
void SetMinIslandArea(long long int aArea)
Definition zone.h:745
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition zone.cpp:598
HASH_128 GetHashValue(PCB_LAYER_ID aLayer)
Definition zone.cpp:715
ZONE_CONNECTION m_PadConnection
Definition zone.h:875
void InitDataFromSrcInCopyCtor(const ZONE &aZone, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Copy aZone data to me.
Definition zone.cpp:131
const std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > & LayerProperties() const
Definition zone.h:156
int GetThermalReliefGap() const
Definition zone.h:234
void RemoveAllContours(void)
Definition zone.h:559
void SetHatchGap(int aStep)
Definition zone.h:319
static int GetDefaultHatchPitch()
Definition zone.cpp:1333
void SetPlacementAreaEnabled(bool aEnabled)
Definition zone.h:722
unsigned GetAssignedPriority() const
Definition zone.h:125
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition zone.h:524
bool SameNet(const ZONE *aOther) const
Definition zone.cpp:450
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:1622
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition zone.h:933
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition zone.h:886
#define _(s)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:184
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:185
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ UNDEFINED_LAYER
Definition layer_ids.h:61
FLIP_DIRECTION
Definition mirror.h:27
#define DECLARE_ENUM_TO_WXANY(type)
Definition property.h:787
A storage class for 128-bit hash value.
Definition hash_128.h:36
A struct recording the isolated and single-pad islands within a zone.
Definition zone.h:60
std::vector< int > m_SingleConnectionOutlines
Definition zone.h:62
std::vector< int > m_IsolatedOutlines
Definition zone.h:61
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:108
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
ZONE_FILL_MODE
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
PLACEMENT_SOURCE_T
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:47