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 <gr_basic.h>
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 static inline bool ClassOf( const EDA_ITEM* aItem )
83 {
84 return aItem && aItem->Type() == PCB_ZONE_T;
85 }
86
87 void Serialize( google::protobuf::Any &aContainer ) const override;
88 bool Deserialize( const google::protobuf::Any &aContainer ) override;
89
93 bool IsConnected() const override
94 {
95 return !GetIsRuleArea();
96 }
97
101 void InitDataFromSrcInCopyCtor( const ZONE& aZone );
102
107 bool IsConflicting() const;
108
112 VECTOR2I GetPosition() const override;
113 void SetPosition( const VECTOR2I& aPos ) override {}
114
118 void SetAssignedPriority( unsigned aPriority ) { m_priority = aPriority; }
119
123 unsigned GetAssignedPriority() const { return m_priority; }
124
125 bool HigherPriority( const ZONE* aOther ) const;
126
127 bool SameNet( const ZONE* aOther ) const;
128
129 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
130 wxString GetFriendlyName() const override;
131
132 void SetLayerSet( const LSET& aLayerSet ) override;
133 virtual LSET GetLayerSet() const override { return m_layerSet; }
134
140 void SetLayerSetAndRemoveUnusedFills( const LSET& aLayerSet );
141
142 const wxString& GetZoneName() const { return m_zoneName; }
143 void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
144
145 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
146 {
147 return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
148 }
149
153 const BOX2I GetBoundingBox() const override;
154
159 void CacheBoundingBox();
160
164 std::optional<int> GetLocalClearance() const override;
165 void SetLocalClearance( std::optional<int> aClearance ) { m_ZoneClearance = aClearance.value(); }
166
173 std::optional<int> GetLocalClearance( wxString* aSource ) const override
174 {
175 if( m_isRuleArea )
176 return std::optional<int>();
177
178 if( aSource )
179 *aSource = _( "zone" );
180
181 return GetLocalClearance();
182 }
183
187 bool IsOnCopperLayer() const override;
188
189 virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
190
191 virtual PCB_LAYER_ID GetLayer() const override;
192
193 // Return the first layer in GUI sequence.
195
196 virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
197
198 virtual std::vector<int> ViewGetLayers() const override;
199
200 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
201
202 void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
204
205 void SetThermalReliefGap( int aThermalReliefGap )
206 {
207 if( m_thermalReliefGap != aThermalReliefGap )
208 SetNeedRefill( true );
209
210 m_thermalReliefGap = aThermalReliefGap;
211 }
212
214 int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
215
216 void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
217 {
218 if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
219 SetNeedRefill( true );
220
221 m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
222 }
223
225
231 double CalculateFilledArea();
232
237 double CalculateOutlineArea();
238
245 {
246 return m_area;
247 }
248
255 {
256 return m_outlinearea;
257 }
258
259 std::mutex& GetLock()
260 {
261 return m_lock;
262 }
263
265 {
266 return m_fillFlags.test( aLayer );
267 }
268
269 void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags.set( aLayer, aFlag ); }
270
271 bool IsFilled() const { return m_isFilled; }
272 void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
273
274 bool NeedRefill() const { return m_needRefill; }
275 void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
276
278 void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
279
280 int GetMinThickness() const { return m_ZoneMinThickness; }
281 void SetMinThickness( int aMinThickness )
282 {
283 if( m_ZoneMinThickness != aMinThickness
284 || ( m_fillMode == ZONE_FILL_MODE::HATCH_PATTERN
285 && ( m_hatchThickness < aMinThickness || m_hatchGap < aMinThickness ) ) )
286 {
287 SetNeedRefill( true );
288 }
289
290 m_ZoneMinThickness = aMinThickness;
291 m_hatchThickness = std::max( m_hatchThickness, aMinThickness );
292 m_hatchGap = std::max( m_hatchGap, aMinThickness );
293 }
294
295 int GetHatchThickness() const { return m_hatchThickness; }
296 void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
297
298 int GetHatchGap() const { return m_hatchGap; }
299 void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
300
302 void SetHatchOrientation( const EDA_ANGLE& aStep ) { m_hatchOrientation = aStep; }
303
305 void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
306
308 void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
309
310 double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
311 void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
312
314 void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
315
317 {
318 // Transform relative indices to global index
319 int globalIndex = -1;
320
322 m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
323
324 return globalIndex;
325 }
326
327 void SetSelectedCorner( int aCorner )
328 {
329 SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
330
331 // If the global index of the corner is correct, assign it to m_CornerSelection
332 if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
333 {
334 if( m_CornerSelection == nullptr )
336
337 *m_CornerSelection = selectedCorner;
338 }
339 else
340 throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
341 }
342
344 int GetLocalFlags() const { return m_localFlgs; }
345 void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
346
348 const SHAPE_POLY_SET* Outline() const { return m_Poly; }
349
350 void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
351
352 // @copydoc BOARD_ITEM::GetEffectiveShape
353 virtual std::shared_ptr<SHAPE>
355 FLASHING aFlash = FLASHING::DEFAULT ) const override;
356
363 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
364
373 bool HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int aAccuracy = 0 ) const;
374
383 bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
384 int* aHoleIdx = nullptr ) const;
385
391 void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aSameNetCollidingZones,
392 std::vector<ZONE*>* aOtherNetIntersectingZones ) const;
393
405
417 void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance,
418 int aError, ERROR_LOC aErrorLoc,
419 SHAPE_POLY_SET* aBoardOutline ) const;
420
434 int aClearance, int aError, ERROR_LOC aErrorLoc,
435 bool ignoreLineWidth = false ) const override;
436
447 bool HitTestForCorner( const VECTOR2I& refPos, int aAccuracy,
448 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
449
459 bool HitTestForEdge( const VECTOR2I& refPos, int aAccuracy,
460 SHAPE_POLY_SET::VERTEX_INDEX* aCornerHit = nullptr ) const;
461
465 bool HitTest( const BOX2I& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
466
472 bool UnFill();
473
474 /* Geometric transformations: */
475
481 void Move( const VECTOR2I& offset ) override;
482
489 void MoveEdge( const VECTOR2I& offset, int aEdge );
490
496 void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
497
505 virtual void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
506
513 void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection ) override;
514
518 wxString GetClass() const override
519 {
520 return wxT( "ZONE" );
521 }
522
526 int GetNumCorners( void ) const
527 {
528 return m_Poly->TotalVertices();
529 }
530
537 {
538 return m_Poly->Iterate();
539 }
540
547 {
548 return m_Poly->IterateWithHoles();
549 }
550
557 {
558 return m_Poly->CIterateWithHoles();
559 }
560
561 void RemoveAllContours( void )
562 {
564 }
565
566 const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
567 {
569
570 // Convert global to relative indices
571 if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
572 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
573
574 return m_Poly->CVertex( index );
575 }
576
577 void SetCornerPosition( int aCornerIndex, const VECTOR2I& new_pos )
578 {
579 SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
580
581 // Convert global to relative indices
582 if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
583 {
584 if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
585 || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
586 {
587 SetNeedRefill( true );
588 m_Poly->SetVertex( relativeIndices, new_pos );
589 }
590 }
591 else
592 {
593 throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
594 }
595 }
596
600 void NewHole()
601 {
602 m_Poly->NewHole();
603 }
604
614 bool AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication = false );
615
618
620 {
621 return m_FilledPolysList.count( aLayer ) > 0;
622 }
623
627 const std::shared_ptr<SHAPE_POLY_SET>& GetFilledPolysList( PCB_LAYER_ID aLayer ) const
628 {
629 wxASSERT( m_FilledPolysList.count( aLayer ) );
630 return m_FilledPolysList.at( aLayer );
631 }
632
634 {
635 wxASSERT( m_FilledPolysList.count( aLayer ) );
636 return m_FilledPolysList.at( aLayer ).get();
637 }
638
644
648 void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
649 {
650 m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
651 }
652
660 bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
661
662 void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
663 {
664 m_insulatedIslands[aLayer].insert( aPolyIdx );
665 }
666
667 bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
668 SHAPE_POLY_SET* aBoardOutline,
669 SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
670
671 void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
672
674
675 void SetCornerRadius( unsigned int aRadius );
676
677 unsigned int GetCornerRadius() const { return m_cornerRadius; }
678
685 void RemoveCutout( int aOutlineIdx, int aHoleIdx );
686
693 void AddPolygon( std::vector<VECTOR2I>& aPolygon );
694
695 void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
696
697 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
698
699 BITMAPS GetMenuImage() const override;
700
701 EDA_ITEM* Clone() const override;
702
706 bool IsTeardropArea() const { return m_teardropType != TEARDROP_TYPE::TD_NONE; }
707
713
718
723 {
726 }
727
731 bool GetIsRuleArea() const { return m_isRuleArea; }
734 {
736 }
739 bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
741 bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
743
744 void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
745 void SetRuleAreaPlacementEnabled( bool aEnabled ) { m_ruleAreaPlacementEnabled = aEnabled; }
747 {
749 }
750 void SetRuleAreaPlacementSource( const wxString& aSource )
751 {
753 }
754 void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
755 void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
756 void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
757 void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
758 void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
759
762
763 long long int GetMinIslandArea() const { return m_minIslandArea; }
764 void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
765
773 int GetBorderHatchPitch() const;
774
778 static int GetDefaultHatchPitch();
779
789 void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
790 bool aRebuilBorderdHatch );
791
797 void SetBorderHatchPitch( int aPitch );
798
802 void UnHatchBorder();
803
808 void HatchBorder();
809
810 const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
811
816 void BuildHashValue( PCB_LAYER_ID aLayer );
817
822
823 double Similarity( const BOARD_ITEM& aOther ) const override;
824
825 bool operator==( const ZONE& aOther ) const;
826 bool operator==( const BOARD_ITEM& aOther ) const override;
827
828#if defined(DEBUG)
829 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
830
831 void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly )
832 {
833 m_FilledPolysList[ aLayer ] = std::make_shared<SHAPE_POLY_SET>( *aPoly );
834 SetFillFlag( aLayer, true );
835 }
836
837#endif
838
839protected:
840 virtual void swapData( BOARD_ITEM* aImage ) override;
841
842protected:
845 unsigned int m_cornerRadius;
846
848 wxString m_zoneName;
849
851
852 /* Priority: when a zone outline is inside and other zone, if its priority is higher
853 * the other zone priority, it will be created inside.
854 * if priorities are equal, a DRC error is set
855 */
856 unsigned m_priority;
857
858 /* A zone outline can be a keepout zone.
859 * It will be never filled, and DRC should test for pads, tracks and vias
860 */
862
869
870 /* A zone outline can be a teardrop zone with different rules for priority
871 * (always bigger priority than copper zones) and never removed from a
872 * copper zone having the same netcode
873 */
875
876 /* For keepout zones only:
877 * what is not allowed inside the keepout ( pads, tracks and vias )
878 */
884
886 int m_ZoneClearance; // Clearance value in internal units.
887 int m_ZoneMinThickness; // Minimum thickness value in filled areas.
888 int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
889 // differences.
891
896 long long int m_minIslandArea;
897
900
907
908 int m_thermalReliefGap; // Width of the gap in thermal reliefs.
909 int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
910
911
919 int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
920 int m_hatchGap; // gap between lines (0 -> solid shape
921 EDA_ANGLE m_hatchOrientation; // orientation of grid lines
922 int m_hatchSmoothingLevel; // 0 = no smoothing
923 // 1 = fillet
924 // 2 = arc low def
925 // 3 = arc high def
926 double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
927 double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
928 int m_hatchBorderAlgorithm; // 0 = use min zone thickness
929 // 1 = use hatch thickness
930
933
934 int m_localFlgs; // Variable used in polygon calculations.
935
936 /* set of filled polygons used to draw a zone as a filled area.
937 * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
938 * (they are all in one piece) In very simple cases m_FilledPolysList is same
939 * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
940 * a polygon equivalent to m_Poly, without holes but with extra outline segment
941 * connecting "holes" with external main outline. In complex cases an outline
942 * described by m_Poly can have many filled areas
943 */
944 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
945
948
950 std::map<PCB_LAYER_ID, HASH_128> m_filledPolysHash;
951
952 ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
953 int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
954 std::vector<SEG> m_borderHatchLines; // hatch lines
955
957 std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
958
959 double m_area; // The filled zone area
960 double m_outlinearea; // The outline zone area
961
963 std::mutex m_lock;
964};
965
966
967#ifndef SWIG
972#endif
973
974#endif // ZONE_H
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
BASE_SET & set(size_t pos)
Definition: base_set.h:116
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:295
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:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:376
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:93
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:54
The main frame for Pcbnew.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
ITERATOR IterateWithHoles(int aOutline)
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int TotalVertices() const
Return total number of vertices stored in the set.
bool GetRelativeIndices(int aGlobalIdx, VERTEX_INDEX *aRelativeIndices) const
Convert a global vertex index —i.e., a number that globally identifies a vertex in a concatenated lis...
bool GetGlobalIndex(VERTEX_INDEX aRelativeIndices, int &aGlobalIdx) const
Compute the global index of a vertex from the relative indices of polygon, contour and vertex.
int NewHole(int aOutline=-1)
Creates a new hole in a given outline.
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Return an object to iterate through the points of the polygons between aFirst and aLast.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
CONST_ITERATOR CIterateWithHoles(int aOutline) const
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
void SetHatchThickness(int aThickness)
Definition: zone.h:296
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
Definition: zone.h:932
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:275
double GetOutlineArea()
This area is cached from the most recent call to CalculateOutlineArea().
Definition: zone.h:254
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:652
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: zone.cpp:1054
void SetHatchBorderAlgorithm(int aAlgo)
Definition: zone.h:314
int m_borderHatchPitch
Definition: zone.h:953
const SHAPE_POLY_SET * Outline() const
Definition: zone.h:348
bool m_isRuleArea
Definition: zone.h:861
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:757
int GetHatchBorderAlgorithm() const
Definition: zone.h:313
ZONE & operator=(const ZONE &aOther)
Definition: zone.cpp:105
int m_cornerSmoothingType
Definition: zone.h:844
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:731
std::optional< int > GetLocalClearance() const override
Definition: zone.cpp:717
void SetRuleAreaPlacementEnabled(bool aEnabled)
Definition: zone.h:745
void SetLocalClearance(std::optional< int > aClearance)
Definition: zone.h:165
bool m_doNotAllowVias
Definition: zone.h:880
bool UnFill()
Removes the zone filling.
Definition: zone.cpp:418
wxString GetRuleAreaPlacementSource() const
Definition: zone.h:737
bool NeedRefill() const
Definition: zone.h:274
bool GetDoNotAllowVias() const
Definition: zone.h:739
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:1627
void SetCornerRadius(unsigned int aRadius)
Definition: zone.cpp:622
ZONE_FILL_MODE m_fillMode
How to fill areas:
Definition: zone.h:918
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:810
void SetPosition(const VECTOR2I &aPos) override
Definition: zone.h:113
bool m_doNotAllowFootprints
Definition: zone.h:883
int m_ZoneMinThickness
Definition: zone.h:887
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:1017
double m_hatchSmoothingValue
Definition: zone.h:926
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:627
void SetLocalFlags(int aFlags)
Definition: zone.h:345
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:1558
void SetCornerSmoothingType(int aType)
Definition: zone.h:671
int m_thermalReliefSpokeWidth
Definition: zone.h:909
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:737
EDA_ANGLE m_hatchOrientation
Definition: zone.h:921
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:1306
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:977
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:957
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: zone.h:848
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:1145
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_POLY_SET > > m_FilledPolysList
Definition: zone.h:944
std::optional< int > GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.h:173
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:1110
bool GetDoNotAllowPads() const
Definition: zone.h:741
const BOX2I GetBoundingBox() const override
Definition: zone.cpp:570
void SetMinThickness(int aMinThickness)
Definition: zone.h:281
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:539
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
Definition: zone.h:244
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: zone.h:145
double m_outlinearea
Definition: zone.h:960
wxString GetFriendlyName() const override
Definition: zone.cpp:917
bool GetDoNotAllowTracks() const
Definition: zone.h:740
int GetLocalFlags() const
Definition: zone.h:344
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:207
void SetHatchOrientation(const EDA_ANGLE &aStep)
Definition: zone.h:302
wxString GetClass() const override
Definition: zone.h:518
bool m_doNotAllowCopperPour
Definition: zone.h:879
bool GetRuleAreaPlacementEnabled() const
Definition: zone.h:732
void SetHatchSmoothingValue(double aValue)
Definition: zone.h:308
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition: zone.h:906
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:546
bool IsFilled() const
Definition: zone.h:271
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:662
void SetHatchSmoothingLevel(int aLevel)
Definition: zone.h:305
bool m_doNotAllowTracks
Definition: zone.h:881
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition: zone.h:93
RULE_AREA_PLACEMENT_SOURCE_TYPE m_ruleAreaPlacementSourceType
Definition: zone.h:867
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:754
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:216
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:448
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:486
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:760
LSET m_fillFlags
Temp variables used while filling.
Definition: zone.h:947
void SetSelectedCorner(int aCorner)
Definition: zone.h:327
int GetSelectedCorner() const
Definition: zone.h:316
SHAPE_POLY_SET * Outline()
Definition: zone.h:347
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:617
bool m_doNotAllowPads
Definition: zone.h:882
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:600
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition: zone.h:269
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: zone.cpp:213
void SetCornerPosition(int aCornerIndex, const VECTOR2I &new_pos)
Definition: zone.h:577
void Move(const VECTOR2I &offset) override
Move the outlines.
Definition: zone.cpp:890
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1323
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: zone.h:843
TEARDROP_TYPE m_teardropType
Definition: zone.h:874
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:950
~ZONE()
Definition: zone.cpp:115
long long int GetMinIslandArea() const
Definition: zone.h:763
int m_hatchSmoothingLevel
Definition: zone.h:922
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:1736
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
Definition: zone.h:633
LSET m_layerSet
Definition: zone.h:850
void SetRuleAreaPlacementSourceType(RULE_AREA_PLACEMENT_SOURCE_TYPE aType)
Definition: zone.h:746
void SetIsRuleArea(bool aEnable)
Definition: zone.h:744
int m_ZoneClearance
Definition: zone.h:886
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:756
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:648
const wxString & GetZoneName() const
Definition: zone.h:142
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:599
int GetMinThickness() const
Definition: zone.h:280
virtual void swapData(BOARD_ITEM *aImage) override
Definition: zone.cpp:1298
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:669
static bool ClassOf(const EDA_ITEM *aItem)
Definition: zone.h:82
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:988
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
Definition: zone.cpp:945
bool HigherPriority(const ZONE *aOther) const
Definition: zone.cpp:395
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:723
void SetIsFilled(bool isFilled)
Definition: zone.h:272
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:202
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition: zone.h:264
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: zone.cpp:1292
int m_hatchGap
Definition: zone.h:920
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:277
void InitDataFromSrcInCopyCtor(const ZONE &aZone)
Copy aZone data to me.
Definition: zone.cpp:125
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition: zone.h:619
int GetHatchThickness() const
Definition: zone.h:295
double GetHatchHoleMinArea() const
Definition: zone.h:310
void SetLayerSet(const LSET &aLayerSet) override
Definition: zone.cpp:492
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:762
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:564
int m_hatchBorderAlgorithm
Definition: zone.h:928
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:755
bool IsTeardropArea() const
Definition: zone.h:706
std::vector< SEG > m_borderHatchLines
Definition: zone.h:954
wxString m_ruleAreaPlacementSource
Definition: zone.h:868
VECTOR2I GetPosition() const override
Definition: zone.cpp:442
int GetThermalReliefSpokeWidth() const
Definition: zone.h:224
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:1104
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: zone.cpp:956
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:616
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition: zone.cpp:643
void SetThermalReliefGap(int aThermalReliefGap)
Definition: zone.h:205
EDA_ANGLE GetHatchOrientation() const
Definition: zone.h:301
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition: zone.cpp:1370
int m_fillVersion
Definition: zone.h:888
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: zone.h:566
bool GetDoNotAllowFootprints() const
Definition: zone.h:742
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:203
double m_hatchHoleMinArea
Definition: zone.h:927
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:556
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition: zone.h:536
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:133
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:758
bool GetDoNotAllowCopperPour() const
Definition: zone.h:738
bool HasKeepoutParametersSet() const
Accessor to determine if any keepout parameters are set.
Definition: zone.h:722
void SetBorderHatchPitch(int aPitch)
Set the hatch pitch parameter for the zone.
Definition: zone.cpp:1125
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:1335
bool m_ruleAreaPlacementEnabled
Placement rule area data.
Definition: zone.h:866
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:1634
int GetHatchGap() const
Definition: zone.h:298
double CalculateOutlineArea()
Compute the area of the zone outline (not the filled area).
Definition: zone.cpp:1551
RULE_AREA_PLACEMENT_SOURCE_TYPE GetRuleAreaPlacementSourceType() const
Definition: zone.h:733
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: zone.h:963
void SetHatchHoleMinArea(double aPct)
Definition: zone.h:311
unsigned m_priority
Definition: zone.h:856
TEARDROP_TYPE GetTeardropAreaType() const
Definition: zone.h:717
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: zone.cpp:304
bool IsConflicting() const
For rule areas which exclude footprints (and therefore participate in courtyard conflicts during move...
Definition: zone.cpp:436
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition: zone.h:890
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition: zone.h:899
double GetHatchSmoothingValue() const
Definition: zone.h:307
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:1034
void MoveEdge(const VECTOR2I &offset, int aEdge)
Move the outline Edge.
Definition: zone.cpp:930
int GetHatchSmoothingLevel() const
Definition: zone.h:304
unsigned int GetCornerRadius() const
Definition: zone.h:677
int GetCornerSmoothingType() const
Definition: zone.h:673
int m_thermalReliefGap
Definition: zone.h:908
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition: zone.h:662
int m_localFlgs
Definition: zone.h:934
bool IsOnCopperLayer() const override
Definition: zone.cpp:480
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition: zone.cpp:1528
int m_hatchThickness
Definition: zone.h:919
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:1598
void SetAssignedPriority(unsigned aPriority)
Definition: zone.h:118
double m_area
Definition: zone.h:959
unsigned int m_cornerRadius
Definition: zone.h:845
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: zone.h:278
std::mutex & GetLock()
Definition: zone.h:259
void SetZoneName(const wxString &aName)
Definition: zone.h:143
bool operator==(const ZONE &aOther) const
Definition: zone.cpp:1668
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:712
void UnHatchBorder()
Clear the zone's hatch.
Definition: zone.cpp:1131
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition: zone.h:761
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition: zone.h:350
PCB_LAYER_ID GetFirstLayer() const
Definition: zone.cpp:458
void SetMinIslandArea(long long int aArea)
Definition: zone.h:764
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition: zone.cpp:520
HASH_128 GetHashValue(PCB_LAYER_ID aLayer)
Definition: zone.cpp:634
ZONE_CONNECTION m_PadConnection
Definition: zone.h:885
void SetRuleAreaPlacementSource(const wxString &aSource)
Definition: zone.h:750
int GetThermalReliefGap() const
Definition: zone.h:213
void RemoveAllContours(void)
Definition: zone.h:561
void SetHatchGap(int aStep)
Definition: zone.h:299
static int GetDefaultHatchPitch()
Definition: zone.cpp:1286
unsigned GetAssignedPriority() const
Definition: zone.h:123
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: zone.h:526
bool SameNet(const ZONE *aOther) const
Definition: zone.cpp:412
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:1589
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition: zone.h:952
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition: zone.h:896
#define _(s)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:184
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:746
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:107
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
RULE_AREA_PLACEMENT_SOURCE_TYPE
Definition: zone_settings.h:66
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:59
ZONE_FILL_MODE
Definition: zone_settings.h:42
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:50
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:47