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 <atomic>
30#include <mutex>
31#include <vector>
32#include <map>
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
282 {
283 std::lock_guard<std::mutex> lock( m_fillFlagsMutex );
284 return m_fillFlags.test( aLayer );
285 }
286
287 void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag )
288 {
289 std::lock_guard<std::mutex> lock( m_fillFlagsMutex );
290 m_fillFlags.set( aLayer, aFlag );
291 }
292
293 bool IsFilled() const { return m_isFilled; }
294 void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
295
296 bool NeedRefill() const { return m_needRefill; }
297 void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
298
300 void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
301
302 int GetMinThickness() const { return m_ZoneMinThickness; }
303 void SetMinThickness( int aMinThickness )
304 {
305 m_ZoneMinThickness = aMinThickness;
306 m_hatchThickness = std::max( m_hatchThickness, aMinThickness );
307 m_hatchGap = std::max( m_hatchGap, aMinThickness );
308 SetNeedRefill( true );
309 }
310
311 int GetHatchThickness() const { return m_hatchThickness; }
312 void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
313
314 int GetHatchGap() const { return m_hatchGap; }
315 void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
316
318 void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; }
319
321 void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
322
324 void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
325
326 double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
327 void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
328
330 void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
331
333 int GetLocalFlags() const { return m_localFlgs; }
334 void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
335
337 const SHAPE_POLY_SET* Outline() const { return m_Poly; }
338
339 void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
340
341 // @copydoc BOARD_ITEM::GetEffectiveShape
342 virtual std::shared_ptr<SHAPE>
344 FLASHING aFlash = FLASHING::DEFAULT ) const override;
345
352 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
353
362 bool HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy = 0 ) const;
363
372 bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
373 int* aHoleIdx = nullptr ) const;
374
380 void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
381 std::vector<ZONE*>* aOtherNetIntersectingZones ) const;
382
394
406 void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
407 int aError, ERROR_LOC aErrorLoc,
408 SHAPE_POLY_SET* aBoardOutline ) const;
409
423 int aClearance, int aError, ERROR_LOC aErrorLoc,
424 bool ignoreLineWidth = false ) const override;
425
436 bool HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
437 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
438
448 bool HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
449 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
450
454 bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
455
459 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
460
466 bool UnFill();
467
468 /* Geometric transformations: */
469
475 void Move( const VECTOR2I& offset ) override;
476
483 void MoveEdge( const VECTOR2I& offset, int aEdge );
484
490 void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
491
499 virtual void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
500
507 void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection ) override;
508
512 wxString GetClass() const override
513 {
514 return wxT( "ZONE" );
515 }
516
520 int GetNumCorners( void ) const
521 {
522 return m_Poly->TotalVertices();
523 }
524
531 {
532 return m_Poly->Iterate();
533 }
534
541 {
542 return m_Poly->IterateWithHoles();
543 }
544
551 {
552 return m_Poly->CIterateWithHoles();
553 }
554
555 void RemoveAllContours( void )
556 {
557 m_Poly->RemoveAllContours();
558 }
559
560 const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
561 {
563
564 // Convert global to relative indices
565 if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
566 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
567
568 return m_Poly->CVertex( index );
569 }
570
574 void NewHole()
575 {
576 m_Poly->NewHole();
577 }
578
588 bool AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication = false );
589
592
594 {
595 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
596 return m_FilledPolysList.count( aLayer ) > 0;
597 }
598
602 std::shared_ptr<SHAPE_POLY_SET> GetFilledPolysList( PCB_LAYER_ID aLayer ) const
603 {
604 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
605 wxASSERT( m_FilledPolysList.count( aLayer ) );
606 return m_FilledPolysList.at( aLayer );
607 }
608
610 {
611 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
612
613 auto it = m_FilledPolysList.find( aLayer );
614
615 if( it == m_FilledPolysList.end() )
616 return nullptr;
617
618 return it->second.get();
619 }
620
626 const SHAPE_POLY_SET::TASK_SUBMITTER& aSubmitter = {} );
627
631 void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
632 {
633 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
634 m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
635 }
636
644 bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
645
646 void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
647 {
648 m_insulatedIslands[aLayer].insert( aPolyIdx );
649 }
650
651 bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
652 SHAPE_POLY_SET* aBoardOutline,
653 SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
654
655 void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
656
658
659 void SetCornerRadius( unsigned int aRadius );
660
661 unsigned int GetCornerRadius() const { return m_cornerRadius; }
662
669 void RemoveCutout( int aOutlineIdx, int aHoleIdx );
670
677 void AddPolygon( std::vector<VECTOR2I>& aPolygon );
678
679 void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
680
681 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
682
683 BITMAPS GetMenuImage() const override;
684
685 EDA_ITEM* Clone() const override;
686 ZONE* Clone( PCB_LAYER_ID aLayer ) const;
687
692
698
703
712
716 bool GetIsRuleArea() const { return m_isRuleArea; }
717 void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
719 void SetPlacementAreaEnabled( bool aEnabled ) { m_placementAreaEnabled = aEnabled; }
720
722 void SetPlacementAreaSource( const wxString& aSource ) { m_placementAreaSource = aSource; }
725
727 bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
729 bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
731
732 void SetDoNotAllowZoneFills( bool aEnable ) { m_doNotAllowZoneFills = aEnable; }
733 void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
734 void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
735 void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
736 void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
737
740
741 long long int GetMinIslandArea() const { return m_minIslandArea; }
742 void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
743
747
752 void SetBorderHatchPitch( int aPitch ) { m_borderHatchPitch = aPitch; }
753
757 static int GetDefaultHatchPitch();
758
768 void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
769 bool aRebuilBorderdHatch );
770
774 void UnHatchBorder();
775
780 void HatchBorder();
781
782 const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
783
788 void BuildHashValue( PCB_LAYER_ID aLayer );
789
794
795 double Similarity( const BOARD_ITEM& aOther ) const override;
796
797 bool operator==( const ZONE& aOther ) const;
798 bool operator==( const BOARD_ITEM& aOther ) const override;
799
800#if defined(DEBUG)
801 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
802
803 void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly )
804 {
805 {
806 std::lock_guard<std::mutex> lock( m_filledPolysListMutex );
807 m_FilledPolysList[ aLayer ] = std::make_shared<SHAPE_POLY_SET>( *aPoly );
808 }
809
810 SetFillFlag( aLayer, true );
811 }
812
813#endif
814
815private:
821 bool unFillLocked();
822
823protected:
824 virtual void swapData( BOARD_ITEM* aImage ) override;
825
826protected:
829 unsigned int m_cornerRadius;
830
832 wxString m_zoneName;
833
834 mutable std::mutex m_layerSetMutex;
836
837 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> m_layerProperties;
838
839 /* Priority: when a zone outline is inside and other zone, if its priority is higher
840 * the other zone priority, it will be created inside.
841 * if priorities are equal, a DRC error is set
842 */
843 unsigned m_priority;
844
845 /* A zone outline can be a keepout zone.
846 * It will be never filled, and DRC should test for pads, tracks and vias
847 */
849
856
857 /* A zone outline can be a teardrop zone with different rules for priority
858 * (always bigger priority than copper zones) and never removed from a
859 * copper zone having the same netcode
860 */
862
863 /* For keepout zones only:
864 * what is not allowed inside the keepout ( pads, tracks and vias )
865 */
871
873 int m_ZoneClearance; // Clearance value in internal units.
874 int m_ZoneMinThickness; // Minimum thickness value in filled areas.
875 int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
876 // differences.
878
883 long long int m_minIslandArea;
884
887
893 std::atomic<bool> m_needRefill;
894
895 int m_thermalReliefGap; // Width of the gap in thermal reliefs.
896 int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
897
898 ZONE_FILL_MODE m_fillMode; // fill with POLYGONS vs HATCH_PATTERN
899 int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
900 int m_hatchGap; // gap between lines (0 -> solid shape
901 EDA_ANGLE m_hatchOrientation; // orientation of grid lines
902 int m_hatchSmoothingLevel; // 0 = no smoothing
903 // 1 = fillet
904 // 2 = arc low def
905 // 3 = arc high def
906 double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
907 double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
908 int m_hatchBorderAlgorithm; // 0 = use min zone thickness
909 // 1 = use hatch thickness
910 int m_localFlgs; // Variable used in polygon calculations.
911
912 /* set of filled polygons used to draw a zone as a filled area.
913 * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
914 * (they are all in one piece) In very simple cases m_FilledPolysList is same
915 * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
916 * a polygon equivalent to m_Poly, without holes but with extra outline segment
917 * connecting "holes" with external main outline. In complex cases an outline
918 * described by m_Poly can have many filled areas
919 */
920 mutable std::mutex m_filledPolysListMutex;
921 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
922
924 mutable std::mutex m_fillFlagsMutex;
926
928 std::map<PCB_LAYER_ID, HASH_128> m_filledPolysHash;
929
930 ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
931 int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
932 std::vector<SEG> m_borderHatchLines; // hatch lines
933
935 std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
936
937 double m_area; // The filled zone area
938 double m_outlinearea; // The outline zone area
939
940};
941
942
947
948#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:323
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:100
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:413
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
std::function< void(std::function< void()>)> TASK_SUBMITTER
Callback that submits a unit of work for asynchronous execution.
Handle a list of polygons defining a copper zone.
Definition zone.h:74
void SetHatchThickness(int aThickness)
Definition zone.h:312
void CacheTriangulation(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, const SHAPE_POLY_SET::TASK_SUBMITTER &aSubmitter={})
Create a list of triangles that "fill" the solid areas used for instance to draw these solid areas on...
Definition zone.cpp:1360
void SetNeedRefill(bool aNeedRefill)
Definition zone.h:297
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:735
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition zone.cpp:1210
void SetHatchBorderAlgorithm(int aAlgo)
Definition zone.h:330
int m_borderHatchPitch
Definition zone.h:931
wxString m_placementAreaSource
Definition zone.h:855
const SHAPE_POLY_SET * Outline() const
Definition zone.h:337
bool m_isRuleArea
Definition zone.h:848
void SetDoNotAllowPads(bool aEnable)
Definition zone.h:735
void SetLayerProperties(const std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aOther)
Definition zone.cpp:592
int GetHatchBorderAlgorithm() const
Definition zone.h:329
ZONE & operator=(const ZONE &aOther)
Definition zone.cpp:105
int m_cornerSmoothingType
Definition zone.h:828
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:716
PLACEMENT_SOURCE_T m_placementAreaSourceType
Definition zone.h:854
std::optional< int > GetLocalClearance() const override
Definition zone.cpp:846
void SetLocalClearance(std::optional< int > aClearance)
Definition zone.h:187
bool m_doNotAllowVias
Definition zone.h:867
bool UnFill()
Removes the zone filling.
Definition zone.cpp:456
bool NeedRefill() const
Definition zone.h:296
bool GetDoNotAllowVias() const
Definition zone.h:727
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:1691
void SetCornerRadius(unsigned int aRadius)
Definition zone.cpp:703
ZONE_FILL_MODE m_fillMode
Definition zone.h:898
const std::vector< SEG > & GetHatchLines() const
Definition zone.h:782
void SetPosition(const VECTOR2I &aPos) override
Definition zone.h:116
bool m_doNotAllowFootprints
Definition zone.h:870
bool unFillLocked()
Internal implementation of UnFill() that assumes the caller already holds m_filledPolysListMutex.
Definition zone.cpp:464
int m_ZoneMinThickness
Definition zone.h:874
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition zone.cpp:1173
ZONE_LAYER_PROPERTIES & LayerProperties(PCB_LAYER_ID aLayer)
Definition zone.h:150
double m_hatchSmoothingValue
Definition zone.h:906
void SetLocalFlags(int aFlags)
Definition zone.h:334
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:1618
void SetCornerSmoothingType(int aType)
Definition zone.h:655
int m_thermalReliefSpokeWidth
Definition zone.h:896
wxString GetPlacementAreaSource() const
Definition zone.h:721
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:901
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:1133
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:935
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition zone.h:832
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition zone.cpp:1300
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_POLY_SET > > m_FilledPolysList
Definition zone.h:921
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:1281
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:602
bool GetDoNotAllowPads() const
Definition zone.h:729
const BOX2I GetBoundingBox() const override
Definition zone.cpp:651
void SetMinThickness(int aMinThickness)
Definition zone.h:303
void SetPlacementAreaSource(const wxString &aSource)
Definition zone.h:722
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:266
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
Definition zone.h:723
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:938
std::mutex m_filledPolysListMutex
Definition zone.h:920
wxString GetFriendlyName() const override
Definition zone.cpp:1062
bool GetDoNotAllowTracks() const
Definition zone.h:728
std::mutex m_fillFlagsMutex
Temp variables used while filling.
Definition zone.h:924
int GetLocalFlags() const
Definition zone.h:333
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:318
wxString GetClass() const override
Definition zone.h:512
void SetHatchSmoothingValue(double aValue)
Definition zone.h:324
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition zone.h:540
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_layerProperties
Definition zone.h:837
bool IsFilled() const
Definition zone.h:293
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:321
bool m_doNotAllowTracks
Definition zone.h:868
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:501
void SetPlacementAreaSourceType(PLACEMENT_SOURCE_T aType)
Definition zone.h:724
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:738
LSET m_fillFlags
Definition zone.h:925
SHAPE_POLY_SET * Outline()
Definition zone.h:336
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition zone.h:591
bool m_doNotAllowPads
Definition zone.h:869
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition zone.h:574
ZONE(BOARD_ITEM_CONTAINER *parent)
Definition zone.cpp:56
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition zone.h:287
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:1393
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition zone.h:827
TEARDROP_TYPE m_teardropType
Definition zone.h:861
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:928
~ZONE()
Definition zone.cpp:122
long long int GetMinIslandArea() const
Definition zone.h:741
int m_hatchSmoothingLevel
Definition zone.h:902
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:1804
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
Definition zone.h:609
LSET m_layerSet
Definition zone.h:835
void SetIsRuleArea(bool aEnable)
Definition zone.h:717
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > & LayerProperties()
Definition zone.h:155
int m_ZoneClearance
Definition zone.h:873
void CopyFrom(const BOARD_ITEM *aOther) override
Definition zone.cpp:115
void SetDoNotAllowTracks(bool aEnable)
Definition zone.h:734
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition zone.h:631
bool m_placementAreaEnabled
Placement rule area data.
Definition zone.h:853
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:680
int GetMinThickness() const
Definition zone.h:302
virtual void swapData(BOARD_ITEM *aImage) override
Definition zone.cpp:1352
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:85
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition zone.cpp:1144
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
Definition zone.cpp:1090
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:294
std::mutex m_layerSetMutex
Definition zone.h:834
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition zone.h:224
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition zone.h:281
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition zone.cpp:1346
int m_hatchGap
Definition zone.h:900
ZONE_CONNECTION GetPadConnection() const
Definition zone.h:299
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition zone.h:593
int GetHatchThickness() const
Definition zone.h:311
double GetHatchHoleMinArea() const
Definition zone.h:326
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:908
bool GetPlacementAreaEnabled() const
Definition zone.h:718
void SetDoNotAllowVias(bool aEnable)
Definition zone.h:733
bool IsTeardropArea() const
Definition zone.h:691
std::vector< SEG > m_borderHatchLines
Definition zone.h:932
VECTOR2I GetPosition() const override
Definition zone.cpp:492
int GetThermalReliefSpokeWidth() const
Definition zone.h:246
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition zone.h:751
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition zone.cpp:1101
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition zone.h:590
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:227
EDA_ANGLE GetHatchOrientation() const
Definition zone.h:317
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition zone.cpp:1440
int m_fillVersion
Definition zone.h:875
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition zone.h:560
bool GetDoNotAllowFootprints() const
Definition zone.h:730
ZONE_FILL_MODE GetFillMode() const
Definition zone.h:225
double m_hatchHoleMinArea
Definition zone.h:907
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:550
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition zone.h:530
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:736
bool HasKeepoutParametersSet() const
Accessor to determine if any keepout parameters are set.
Definition zone.h:707
void SetBorderHatchPitch(int aPitch)
Definition zone.h:752
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:1405
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:1700
int GetHatchGap() const
Definition zone.h:314
double CalculateOutlineArea()
Compute the area of the zone outline (not the filled area).
Definition zone.cpp:1611
void SetHatchHoleMinArea(double aPct)
Definition zone.h:327
unsigned m_priority
Definition zone.h:843
TEARDROP_TYPE GetTeardropAreaType() const
Definition zone.h:702
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:866
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition zone.h:877
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition zone.h:886
double GetHatchSmoothingValue() const
Definition zone.h:323
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:1190
std::atomic< bool > m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition zone.h:893
bool GetDoNotAllowZoneFills() const
Definition zone.h:726
void MoveEdge(const VECTOR2I &offset, int aEdge)
Move the outline Edge.
Definition zone.cpp:1075
int GetHatchSmoothingLevel() const
Definition zone.h:320
unsigned int GetCornerRadius() const
Definition zone.h:661
int GetCornerSmoothingType() const
Definition zone.h:657
int m_thermalReliefGap
Definition zone.h:895
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition zone.h:646
int m_localFlgs
Definition zone.h:910
bool IsOnCopperLayer() const override
Definition zone.cpp:543
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition zone.cpp:1600
void SetDoNotAllowZoneFills(bool aEnable)
Definition zone.h:732
int m_hatchThickness
Definition zone.h:899
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:1654
void SetAssignedPriority(unsigned aPriority)
Definition zone.h:121
double m_area
Definition zone.h:937
unsigned int m_cornerRadius
Definition zone.h:829
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition zone.h:300
void SetZoneName(const wxString &aName)
Definition zone.h:165
bool operator==(const ZONE &aOther) const
Definition zone.cpp:1736
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:697
void UnHatchBorder()
Clear the zone's hatch.
Definition zone.cpp:1294
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition zone.h:739
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition zone.h:339
PCB_LAYER_ID GetFirstLayer() const
Definition zone.cpp:523
void SetMinIslandArea(long long int aArea)
Definition zone.h:742
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:872
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:157
int GetThermalReliefGap() const
Definition zone.h:235
void RemoveAllContours(void)
Definition zone.h:555
void SetHatchGap(int aStep)
Definition zone.h:315
static int GetDefaultHatchPitch()
Definition zone.cpp:1340
void SetPlacementAreaEnabled(bool aEnabled)
Definition zone.h:719
unsigned GetAssignedPriority() const
Definition zone.h:126
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition zone.h:520
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:1643
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition zone.h:930
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition zone.h:883
#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:105
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
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