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 <gr_basic.h>
33#include <board_item.h>
35#include <layer_ids.h>
36#include <lset.h>
38#include <zone_settings.h>
40
41
42class LINE_READER;
43class PCB_EDIT_FRAME;
44class BOARD;
45class ZONE;
46class MSG_PANEL_ITEM;
47
48
61{
62 std::vector<int> m_IsolatedOutlines;
64};
65
66
74{
75public:
76 ZONE( BOARD_ITEM_CONTAINER* parent );
77
78 ZONE( const ZONE& aZone );
79 ZONE& operator=( const ZONE &aOther );
80
81 ~ZONE();
82
83 void CopyFrom( const BOARD_ITEM* aOther ) override;
84
85 static inline bool ClassOf( const EDA_ITEM* aItem )
86 {
87 return aItem && aItem->Type() == PCB_ZONE_T;
88 }
89
90 void Serialize( google::protobuf::Any &aContainer ) const override;
91 bool Deserialize( const google::protobuf::Any &aContainer ) override;
92
96 bool IsConnected() const override
97 {
98 return !GetIsRuleArea();
99 }
100
104 void InitDataFromSrcInCopyCtor( const ZONE& aZone, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
105
110 bool IsConflicting() const;
111
115 VECTOR2I GetPosition() const override;
116 void SetPosition( const VECTOR2I& aPos ) override {}
117
121 void SetAssignedPriority( unsigned aPriority ) { m_priority = aPriority; }
122
126 unsigned GetAssignedPriority() const { return m_priority; }
127
128 bool HigherPriority( const ZONE* aOther ) const;
129
130 bool SameNet( const ZONE* aOther ) const;
131
132 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
133 wxString GetFriendlyName() const override;
134
135 void SetLayerSet( const LSET& aLayerSet ) override;
136
137 virtual LSET GetLayerSet() const override
138 {
139 std::lock_guard<std::mutex> lock( m_layerSetMutex );
140 return m_layerSet;
141 }
142
148 void SetLayerSetAndRemoveUnusedFills( const LSET& aLayerSet );
149
151 {
152 return m_layerProperties[aLayer];
153 }
154
155 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& LayerProperties() { return m_layerProperties; }
156
157 const std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& LayerProperties() const
158 {
159 return m_layerProperties;
160 }
161
162 void SetLayerProperties( const std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& aOther );
163
164 const wxString& GetZoneName() const { return m_zoneName; }
165 void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
166
167 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
168 {
169 return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
170 }
171
175 const BOX2I GetBoundingBox() const override;
176
181 void CacheBoundingBox();
182
186 std::optional<int> GetLocalClearance() const override;
187 void SetLocalClearance( std::optional<int> aClearance ) { m_ZoneClearance = aClearance.value_or( 0 ); };
188
195 std::optional<int> GetLocalClearance( wxString* aSource ) const override
196 {
197 if( m_isRuleArea )
198 return std::optional<int>();
199
200 if( aSource )
201 *aSource = _( "zone" );
202
203 return GetLocalClearance();
204 }
205
209 bool IsOnCopperLayer() const override;
210
211 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
212
213 virtual PCB_LAYER_ID GetLayer() const override;
214
215 // Return the first layer in GUI sequence.
217
218 virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
219
220 virtual std::vector<int> ViewGetLayers() const override;
221
222 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
223
224 void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
226
227 void SetThermalReliefGap( int aThermalReliefGap )
228 {
229 if( m_thermalReliefGap != aThermalReliefGap )
230 SetNeedRefill( true );
231
232 m_thermalReliefGap = aThermalReliefGap;
233 }
234
236 int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
237
238 void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
239 {
240 if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
241 SetNeedRefill( true );
242
243 m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
244 }
245
247
253 double CalculateFilledArea();
254
259 double CalculateOutlineArea();
260
267 {
268 return m_area;
269 }
270
277 {
278 return m_outlinearea;
279 }
280
281 std::mutex& GetLock()
282 {
283 return m_lock;
284 }
285
287 {
288 std::lock_guard<std::mutex> lock( m_fillFlagsMutex );
289 return m_fillFlags.test( aLayer );
290 }
291
292 void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag )
293 {
294 std::lock_guard<std::mutex> lock( m_fillFlagsMutex );
295 m_fillFlags.set( aLayer, aFlag );
296 }
297
298 bool IsFilled() const { return m_isFilled; }
299 void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
300
301 bool NeedRefill() const { return m_needRefill; }
302 void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
303
305 void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
306
307 int GetMinThickness() const { return m_ZoneMinThickness; }
308 void SetMinThickness( int aMinThickness )
309 {
310 m_ZoneMinThickness = aMinThickness;
311 m_hatchThickness = std::max( m_hatchThickness, aMinThickness );
312 m_hatchGap = std::max( m_hatchGap, aMinThickness );
313 SetNeedRefill( true );
314 }
315
316 int GetHatchThickness() const { return m_hatchThickness; }
317 void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
318
319 int GetHatchGap() const { return m_hatchGap; }
320 void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
321
323 void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; }
324
326 void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
327
329 void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
330
331 double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
332 void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
333
335 void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
336
338 int GetLocalFlags() const { return m_localFlgs; }
339 void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
340
342 const SHAPE_POLY_SET* Outline() const { return m_Poly; }
343
344 void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
345
346 // @copydoc BOARD_ITEM::GetEffectiveShape
347 virtual std::shared_ptr<SHAPE>
349 FLASHING aFlash = FLASHING::DEFAULT ) const override;
350
357 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
358
367 bool HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy = 0 ) const;
368
377 bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
378 int* aHoleIdx = nullptr ) const;
379
385 void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
386 std::vector<ZONE*>* aOtherNetIntersectingZones ) const;
387
399
411 void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
412 int aError, ERROR_LOC aErrorLoc,
413 SHAPE_POLY_SET* aBoardOutline ) const;
414
428 int aClearance, int aError, ERROR_LOC aErrorLoc,
429 bool ignoreLineWidth = false ) const override;
430
441 bool HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
442 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
443
453 bool HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
454 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
455
459 bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
460
464 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
465
471 bool UnFill();
472
473 /* Geometric transformations: */
474
480 void Move( const VECTOR2I& offset ) override;
481
488 void MoveEdge( const VECTOR2I& offset, int aEdge );
489
495 void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
496
504 virtual void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
505
512 void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection ) override;
513
517 wxString GetClass() const override
518 {
519 return wxT( "ZONE" );
520 }
521
525 int GetNumCorners( void ) const
526 {
527 return m_Poly->TotalVertices();
528 }
529
536 {
537 return m_Poly->Iterate();
538 }
539
546 {
547 return m_Poly->IterateWithHoles();
548 }
549
556 {
557 return m_Poly->CIterateWithHoles();
558 }
559
560 void RemoveAllContours( void )
561 {
562 m_Poly->RemoveAllContours();
563 }
564
565 const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
566 {
568
569 // Convert global to relative indices
570 if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
571 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
572
573 return m_Poly->CVertex( index );
574 }
575
579 void NewHole()
580 {
581 m_Poly->NewHole();
582 }
583
593 bool AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication = false );
594
597
599 {
600 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
601 return m_FilledPolysList.count( aLayer ) > 0;
602 }
603
607 std::shared_ptr<SHAPE_POLY_SET> GetFilledPolysList( PCB_LAYER_ID aLayer ) const
608 {
609 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
610 wxASSERT( m_FilledPolysList.count( aLayer ) );
611 return m_FilledPolysList.at( aLayer );
612 }
613
615 {
616 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
617 wxASSERT( m_FilledPolysList.count( aLayer ) );
618 return m_FilledPolysList.at( aLayer ).get();
619 }
620
626
630 void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
631 {
632 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
633 m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
634 }
635
643 bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
644
645 void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
646 {
647 m_insulatedIslands[aLayer].insert( aPolyIdx );
648 }
649
650 bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
651 SHAPE_POLY_SET* aBoardOutline,
652 SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
653
654 void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
655
657
658 void SetCornerRadius( unsigned int aRadius );
659
660 unsigned int GetCornerRadius() const { return m_cornerRadius; }
661
668 void RemoveCutout( int aOutlineIdx, int aHoleIdx );
669
676 void AddPolygon( std::vector<VECTOR2I>& aPolygon );
677
678 void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
679
680 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
681
682 BITMAPS GetMenuImage() const override;
683
684 EDA_ITEM* Clone() const override;
685 ZONE* Clone( PCB_LAYER_ID aLayer ) const;
686
691
697
702
711
715 bool GetIsRuleArea() const { return m_isRuleArea; }
716 void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
718 void SetPlacementAreaEnabled( bool aEnabled ) { m_placementAreaEnabled = aEnabled; }
719
721 void SetPlacementAreaSource( const wxString& aSource ) { m_placementAreaSource = aSource; }
724
726 bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
728 bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
730
731 void SetDoNotAllowZoneFills( bool aEnable ) { m_doNotAllowZoneFills = aEnable; }
732 void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
733 void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
734 void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
735 void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
736
739
740 long long int GetMinIslandArea() const { return m_minIslandArea; }
741 void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
742
746
751 void SetBorderHatchPitch( int aPitch ) { m_borderHatchPitch = aPitch; }
752
756 static int GetDefaultHatchPitch();
757
767 void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
768 bool aRebuilBorderdHatch );
769
773 void UnHatchBorder();
774
779 void HatchBorder();
780
781 const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
782
787 void BuildHashValue( PCB_LAYER_ID aLayer );
788
793
794 double Similarity( const BOARD_ITEM& aOther ) const override;
795
796 bool operator==( const ZONE& aOther ) const;
797 bool operator==( const BOARD_ITEM& aOther ) const override;
798
799#if defined(DEBUG)
800 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
801
802 void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly )
803 {
804 {
805 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
806 m_FilledPolysList[ aLayer ] = std::make_shared<SHAPE_POLY_SET>( *aPoly );
807 }
808
809 SetFillFlag( aLayer, true );
810 }
811
812#endif
813
814private:
820 bool unFillLocked();
821
822protected:
823 virtual void swapData( BOARD_ITEM* aImage ) override;
824
825protected:
828 unsigned int m_cornerRadius;
829
831 wxString m_zoneName;
832
833 mutable std::mutex m_layerSetMutex;
835
836 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> m_layerProperties;
837
838 /* Priority: when a zone outline is inside and other zone, if its priority is higher
839 * the other zone priority, it will be created inside.
840 * if priorities are equal, a DRC error is set
841 */
842 unsigned m_priority;
843
844 /* A zone outline can be a keepout zone.
845 * It will be never filled, and DRC should test for pads, tracks and vias
846 */
848
855
856 /* A zone outline can be a teardrop zone with different rules for priority
857 * (always bigger priority than copper zones) and never removed from a
858 * copper zone having the same netcode
859 */
861
862 /* For keepout zones only:
863 * what is not allowed inside the keepout ( pads, tracks and vias )
864 */
870
872 int m_ZoneClearance; // Clearance value in internal units.
873 int m_ZoneMinThickness; // Minimum thickness value in filled areas.
874 int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
875 // differences.
877
882 long long int m_minIslandArea;
883
886
893
894 int m_thermalReliefGap; // Width of the gap in thermal reliefs.
895 int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
896
897 ZONE_FILL_MODE m_fillMode; // fill with POLYGONS vs HATCH_PATTERN
898 int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
899 int m_hatchGap; // gap between lines (0 -> solid shape
900 EDA_ANGLE m_hatchOrientation; // orientation of grid lines
901 int m_hatchSmoothingLevel; // 0 = no smoothing
902 // 1 = fillet
903 // 2 = arc low def
904 // 3 = arc high def
905 double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
906 double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
907 int m_hatchBorderAlgorithm; // 0 = use min zone thickness
908 // 1 = use hatch thickness
909 int m_localFlgs; // Variable used in polygon calculations.
910
911 /* set of filled polygons used to draw a zone as a filled area.
912 * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
913 * (they are all in one piece) In very simple cases m_FilledPolysList is same
914 * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
915 * a polygon equivalent to m_Poly, without holes but with extra outline segment
916 * connecting "holes" with external main outline. In complex cases an outline
917 * described by m_Poly can have many filled areas
918 */
919 mutable std::mutex m_filledPolysListMutex;
920 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
921
923 mutable std::mutex m_fillFlagsMutex;
925
927 std::map<PCB_LAYER_ID, HASH_128> m_filledPolysHash;
928
929 ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
930 int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
931 std::vector<SEG> m_borderHatchLines; // hatch lines
932
934 std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
935
936 double m_area; // The filled zone area
937 double m_outlinearea; // The outline zone area
938
940 std::mutex m_lock;
941};
942
943
944#ifndef SWIG
949#endif
950
951#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:83
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:85
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:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:406
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:39
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
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:74
void SetHatchThickness(int aThickness)
Definition zone.h:317
void SetNeedRefill(bool aNeedRefill)
Definition zone.h:302
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
Definition zone.h:276
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:730
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition zone.cpp:1198
void SetHatchBorderAlgorithm(int aAlgo)
Definition zone.h:335
int m_borderHatchPitch
Definition zone.h:930
wxString m_placementAreaSource
Definition zone.h:854
const SHAPE_POLY_SET * Outline() const
Definition zone.h:342
bool m_isRuleArea
Definition zone.h:847
void SetDoNotAllowPads(bool aEnable)
Definition zone.h:734
void SetLayerProperties(const std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aOther)
Definition zone.cpp:587
int GetHatchBorderAlgorithm() const
Definition zone.h:334
ZONE & operator=(const ZONE &aOther)
Definition zone.cpp:103
int m_cornerSmoothingType
Definition zone.h:827
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:715
PLACEMENT_SOURCE_T m_placementAreaSourceType
Definition zone.h:853
std::optional< int > GetLocalClearance() const override
Definition zone.cpp:841
void SetLocalClearance(std::optional< int > aClearance)
Definition zone.h:187
bool m_doNotAllowVias
Definition zone.h:866
bool UnFill()
Removes the zone filling.
Definition zone.cpp:454
bool NeedRefill() const
Definition zone.h:301
bool GetDoNotAllowVias() const
Definition zone.h:726
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:1665
void SetCornerRadius(unsigned int aRadius)
Definition zone.cpp:698
ZONE_FILL_MODE m_fillMode
Definition zone.h:897
const std::vector< SEG > & GetHatchLines() const
Definition zone.h:781
void SetPosition(const VECTOR2I &aPos) override
Definition zone.h:116
bool m_doNotAllowFootprints
Definition zone.h:869
bool unFillLocked()
Internal implementation of UnFill() that assumes the caller already holds m_filledPolysListMutex.
Definition zone.cpp:462
int m_ZoneMinThickness
Definition zone.h:873
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition zone.cpp:1161
ZONE_LAYER_PROPERTIES & LayerProperties(PCB_LAYER_ID aLayer)
Definition zone.h:150
double m_hatchSmoothingValue
Definition zone.h:905
void SetLocalFlags(int aFlags)
Definition zone.h:339
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:1592
void SetCornerSmoothingType(int aType)
Definition zone.h:654
int m_thermalReliefSpokeWidth
Definition zone.h:895
wxString GetPlacementAreaSource() const
Definition zone.h:720
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:869
EDA_ANGLE m_hatchOrientation
Definition zone.h:900
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:1348
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:1121
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:934
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition zone.h:831
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition zone.cpp:1288
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_POLY_SET > > m_FilledPolysList
Definition zone.h:920
std::optional< int > GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition zone.h:195
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition zone.cpp:1269
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:607
bool GetDoNotAllowPads() const
Definition zone.h:728
const BOX2I GetBoundingBox() const override
Definition zone.cpp:646
void SetMinThickness(int aMinThickness)
Definition zone.h:308
void SetPlacementAreaSource(const wxString &aSource)
Definition zone.h:721
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition zone.cpp:614
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
Definition zone.h:266
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
Definition zone.h:722
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition zone.h:167
double m_outlinearea
Definition zone.h:937
std::mutex m_filledPolysListMutex
Definition zone.h:919
wxString GetFriendlyName() const override
Definition zone.cpp:1050
bool GetDoNotAllowTracks() const
Definition zone.h:727
std::mutex m_fillFlagsMutex
Temp variables used while filling.
Definition zone.h:923
int GetLocalFlags() const
Definition zone.h:338
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition zone.cpp:216
void SetHatchOrientation(const EDA_ANGLE &aStep)
Definition zone.h:323
wxString GetClass() const override
Definition zone.h:517
void SetHatchSmoothingValue(double aValue)
Definition zone.h:329
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition zone.h:892
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition zone.h:545
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_layerProperties
Definition zone.h:836
bool IsFilled() const
Definition zone.h:298
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:740
void SetHatchSmoothingLevel(int aLevel)
Definition zone.h:326
bool m_doNotAllowTracks
Definition zone.h:867
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition zone.h:96
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition zone.h:238
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition zone.cpp:496
void SetPlacementAreaSourceType(PLACEMENT_SOURCE_T aType)
Definition zone.h:723
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition zone.cpp:545
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition zone.h:737
LSET m_fillFlags
Definition zone.h:924
SHAPE_POLY_SET * Outline()
Definition zone.h:341
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition zone.h:596
bool m_doNotAllowPads
Definition zone.h:868
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition zone.h:579
ZONE(BOARD_ITEM_CONTAINER *parent)
Definition zone.cpp:54
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition zone.h:292
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition zone.cpp:230
void Move(const VECTOR2I &offset) override
Move the outlines.
Definition zone.cpp:1023
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition zone.cpp:1367
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition zone.h:826
TEARDROP_TYPE m_teardropType
Definition zone.h:860
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:927
~ZONE()
Definition zone.cpp:120
long long int GetMinIslandArea() const
Definition zone.h:740
int m_hatchSmoothingLevel
Definition zone.h:901
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:1778
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
Definition zone.h:614
LSET m_layerSet
Definition zone.h:834
void SetIsRuleArea(bool aEnable)
Definition zone.h:716
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > & LayerProperties()
Definition zone.h:155
int m_ZoneClearance
Definition zone.h:872
void CopyFrom(const BOARD_ITEM *aOther) override
Definition zone.cpp:113
void SetDoNotAllowTracks(bool aEnable)
Definition zone.h:733
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition zone.h:630
bool m_placementAreaEnabled
Placement rule area data.
Definition zone.h:852
const wxString & GetZoneName() const
Definition zone.h:164
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:675
int GetMinThickness() const
Definition zone.h:307
virtual void swapData(BOARD_ITEM *aImage) override
Definition zone.cpp:1340
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:747
static bool ClassOf(const EDA_ITEM *aItem)
Definition zone.h:85
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition zone.cpp:1132
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
Definition zone.cpp:1078
bool HigherPriority(const ZONE *aOther) const
Definition zone.cpp:434
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:847
void SetIsFilled(bool isFilled)
Definition zone.h:299
std::mutex m_layerSetMutex
Definition zone.h:833
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition zone.h:224
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition zone.h:286
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition zone.cpp:1334
int m_hatchGap
Definition zone.h:899
ZONE_CONNECTION GetPadConnection() const
Definition zone.h:304
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition zone.h:598
int GetHatchThickness() const
Definition zone.h:316
double GetHatchHoleMinArea() const
Definition zone.h:331
void SetLayerSet(const LSET &aLayerSet) override
Definition zone.cpp:551
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:894
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition zone.cpp:639
int m_hatchBorderAlgorithm
Definition zone.h:907
bool GetPlacementAreaEnabled() const
Definition zone.h:717
void SetDoNotAllowVias(bool aEnable)
Definition zone.h:732
bool IsTeardropArea() const
Definition zone.h:690
std::vector< SEG > m_borderHatchLines
Definition zone.h:931
VECTOR2I GetPosition() const override
Definition zone.cpp:490
int GetThermalReliefSpokeWidth() const
Definition zone.h:246
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition zone.h:750
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition zone.cpp:1089
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition zone.h:595
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition zone.cpp:719
void SetThermalReliefGap(int aThermalReliefGap)
Definition zone.h:227
EDA_ANGLE GetHatchOrientation() const
Definition zone.h:322
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition zone.cpp:1414
int m_fillVersion
Definition zone.h:874
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition zone.h:565
bool GetDoNotAllowFootprints() const
Definition zone.h:729
ZONE_FILL_MODE GetFillMode() const
Definition zone.h:225
double m_hatchHoleMinArea
Definition zone.h:906
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:555
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition zone.h:535
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:137
void SetDoNotAllowFootprints(bool aEnable)
Definition zone.h:735
bool HasKeepoutParametersSet() const
Accessor to determine if any keepout parameters are set.
Definition zone.h:706
void SetBorderHatchPitch(int aPitch)
Definition zone.h:751
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:1379
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:1674
int GetHatchGap() const
Definition zone.h:319
double CalculateOutlineArea()
Compute the area of the zone outline (not the filled area).
Definition zone.cpp:1585
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition zone.h:940
void SetHatchHoleMinArea(double aPct)
Definition zone.h:332
unsigned m_priority
Definition zone.h:842
TEARDROP_TYPE GetTeardropAreaType() const
Definition zone.h:701
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition zone.cpp:332
bool IsConflicting() const
For rule areas which exclude footprints (and therefore participate in courtyard conflicts during move...
Definition zone.cpp:484
bool m_doNotAllowZoneFills
Definition zone.h:865
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition zone.h:876
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition zone.h:885
double GetHatchSmoothingValue() const
Definition zone.h:328
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:1178
bool GetDoNotAllowZoneFills() const
Definition zone.h:725
void MoveEdge(const VECTOR2I &offset, int aEdge)
Move the outline Edge.
Definition zone.cpp:1063
int GetHatchSmoothingLevel() const
Definition zone.h:325
unsigned int GetCornerRadius() const
Definition zone.h:660
int GetCornerSmoothingType() const
Definition zone.h:656
int m_thermalReliefGap
Definition zone.h:894
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition zone.h:645
int m_localFlgs
Definition zone.h:909
bool IsOnCopperLayer() const override
Definition zone.cpp:538
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition zone.cpp:1574
void SetDoNotAllowZoneFills(bool aEnable)
Definition zone.h:731
int m_hatchThickness
Definition zone.h:898
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:1628
void SetAssignedPriority(unsigned aPriority)
Definition zone.h:121
double m_area
Definition zone.h:936
unsigned int m_cornerRadius
Definition zone.h:828
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition zone.h:305
std::mutex & GetLock()
Definition zone.h:281
void SetZoneName(const wxString &aName)
Definition zone.h:165
bool operator==(const ZONE &aOther) const
Definition zone.cpp:1710
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:696
void UnHatchBorder()
Clear the zone's hatch.
Definition zone.cpp:1282
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition zone.h:738
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition zone.h:344
PCB_LAYER_ID GetFirstLayer() const
Definition zone.cpp:518
void SetMinIslandArea(long long int aArea)
Definition zone.h:741
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition zone.cpp:593
HASH_128 GetHashValue(PCB_LAYER_ID aLayer)
Definition zone.cpp:710
ZONE_CONNECTION m_PadConnection
Definition zone.h:871
void InitDataFromSrcInCopyCtor(const ZONE &aZone, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Copy aZone data to me.
Definition zone.cpp:129
const std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > & LayerProperties() const
Definition zone.h:157
int GetThermalReliefGap() const
Definition zone.h:235
void RemoveAllContours(void)
Definition zone.h:560
void SetHatchGap(int aStep)
Definition zone.h:320
static int GetDefaultHatchPitch()
Definition zone.cpp:1328
void SetPlacementAreaEnabled(bool aEnabled)
Definition zone.h:718
unsigned GetAssignedPriority() const
Definition zone.h:126
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition zone.h:525
bool SameNet(const ZONE *aOther) const
Definition zone.cpp:448
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:1617
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition zone.h:929
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition zone.h:882
#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:61
std::vector< int > m_SingleConnectionOutlines
Definition zone.h:63
std::vector< int > m_IsolatedOutlines
Definition zone.h:62
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