KiCad PCB EDA Suite
zone.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2021 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>
33 #include <board_connected_item.h>
34 #include <layer_ids.h>
36 #include <zone_settings.h>
37 
38 
39 class EDA_RECT;
40 class LINE_READER;
41 class PCB_EDIT_FRAME;
42 class BOARD;
43 class ZONE;
44 class MSG_PANEL_ITEM;
45 
46 
56 class ZONE : public BOARD_CONNECTED_ITEM
57 {
58 public:
59 
67  ZONE( BOARD_ITEM_CONTAINER* parent, bool aInFP = false );
68 
69  ZONE( const ZONE& aZone );
70  ZONE& operator=( const ZONE &aOther );
71 
72  ~ZONE();
73 
74  static inline bool ClassOf( const EDA_ITEM* aItem )
75  {
76  return aItem && aItem->Type() == PCB_ZONE_T;
77  }
78 
82  bool IsConnected() const override
83  {
84  return !GetIsRuleArea();
85  }
86 
87  NETCLASS* GetNetClass() const override
88  {
89  if( GetIsRuleArea() )
90  return nullptr;
91 
93  }
94 
95  wxString GetNetClassName() const override
96  {
97  if( GetIsRuleArea() )
98  return "UNDEFINED";
99 
101  }
102 
106  void InitDataFromSrcInCopyCtor( const ZONE& aZone );
107 
111  wxPoint GetPosition() const override;
112  void SetPosition( const wxPoint& aPos ) override {}
113 
117  void SetPriority( unsigned aPriority ) { m_priority = aPriority; }
118 
122  unsigned GetPriority() const { return m_priority; }
123 
124  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
125 
126  void SetLayerSet( LSET aLayerSet ) override;
127  virtual LSET GetLayerSet() const override;
128 
129  wxString GetZoneName() const { return m_zoneName; }
130  void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
131 
132  bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
133  {
134  return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
135  }
136 
140  const EDA_RECT GetBoundingBox() const override;
141 
145  const EDA_RECT GetCachedBoundingBox() const { return m_bboxCache; }
147 
155  int GetLocalClearance( wxString* aSource ) const override;
156 
157  int GetLocalClearance() const { return GetLocalClearance( nullptr ); }
158  void SetLocalClearance( int aClearance ) { m_ZoneClearance = aClearance; }
159 
163  bool IsOnCopperLayer() const override;
164 
168  bool CommonLayerExists( const LSET aLayerSet ) const;
169 
170  virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
171 
172  virtual PCB_LAYER_ID GetLayer() const override;
173 
174  virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
175 
176  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
177 
178  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
179 
180  void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
182 
183  void SetThermalReliefGap( int aThermalReliefGap )
184  {
185  if( m_thermalReliefGap != aThermalReliefGap )
186  SetNeedRefill( true );
187 
188  m_thermalReliefGap = aThermalReliefGap;
189  }
190 
191  int GetThermalReliefGap() const { return m_thermalReliefGap; }
192  int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
193 
194  void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
195  {
196  if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
197  SetNeedRefill( true );
198 
199  m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
200  }
201 
203  int GetThermalReliefSpokeWidth( PAD* aPad, wxString* aSource = nullptr ) const;
204 
210  double CalculateFilledArea();
211 
217  double GetFilledArea()
218  {
219  return m_area;
220  }
221 
222  std::mutex& GetLock()
223  {
224  return m_lock;
225  }
226 
227  int GetFillFlag( PCB_LAYER_ID aLayer )
228  {
229  return m_fillFlags.count( aLayer ) ? m_fillFlags[ aLayer ] : false;
230  }
231 
232  void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags[ aLayer ] = aFlag; }
233 
234  bool IsFilled() const { return m_isFilled; }
235  void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
236 
237  bool NeedRefill() const { return m_needRefill; }
238  void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
239 
240  ZONE_CONNECTION GetPadConnection( PAD* aPad, wxString* aSource = nullptr ) const;
242  void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
243 
244  int GetMinThickness() const { return m_ZoneMinThickness; }
245  void SetMinThickness( int aMinThickness )
246  {
247  if( m_ZoneMinThickness != aMinThickness )
248  SetNeedRefill( true );
249 
250  m_ZoneMinThickness = aMinThickness;
251  }
252 
253  int GetHatchThickness() const { return m_hatchThickness; }
254  void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
255 
256  int GetHatchGap() const { return m_hatchGap; }
257  void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
258 
259  double GetHatchOrientation() const { return m_hatchOrientation; }
260  void SetHatchOrientation( double aStep ) { m_hatchOrientation = aStep; }
261 
263  void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
264 
266  void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
267 
268  double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
269  void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
270 
272  void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
273 
274  int GetSelectedCorner() const
275  {
276  // Transform relative indices to global index
277  int globalIndex = -1;
278 
279  if( m_CornerSelection )
280  m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
281 
282  return globalIndex;
283  }
284 
285  void SetSelectedCorner( int aCorner )
286  {
287  SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
288 
289  // If the global index of the corner is correct, assign it to m_CornerSelection
290  if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
291  {
292  if( m_CornerSelection == nullptr )
294 
295  *m_CornerSelection = selectedCorner;
296  }
297  else
298  throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
299  }
300 
302  // Like HitTest but selects the current corner to be operated on
303  void SetSelectedCorner( const wxPoint& aPosition, int aAccuracy );
304 
305  int GetLocalFlags() const { return m_localFlgs; }
306  void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
307 
308  std::vector<SEG>& FillSegments( PCB_LAYER_ID aLayer )
309  {
310  wxASSERT( m_FillSegmList.count( aLayer ) );
311  return m_FillSegmList.at( aLayer );
312  }
313 
314  const std::vector<SEG>& FillSegments( PCB_LAYER_ID aLayer ) const
315  {
316  wxASSERT( m_FillSegmList.count( aLayer ) );
317  return m_FillSegmList.at( aLayer );
318  }
319 
321  const SHAPE_POLY_SET* Outline() const { return m_Poly; }
322 
323  void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
324 
325  // @copydoc BOARD_ITEM::GetEffectiveShape
326  virtual std::shared_ptr<SHAPE>
327  GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
328 
335  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
336 
345  bool HitTestFilledArea( PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy = 0 ) const;
346 
355  bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
356  int* aHoleIdx = nullptr ) const;
357 
358  bool HitTestCutout( const wxPoint& aRefPos, int* aOutlineIdx = nullptr,
359  int* aHoleIdx = nullptr ) const
360  {
361  return HitTestCutout( VECTOR2I( aRefPos.x, aRefPos.y ), aOutlineIdx, aHoleIdx );
362  }
363 
369  void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aZones ) const;
370 
382  int aError = ARC_HIGH_DEF ) const;
383 
395  void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearance,
396  SHAPE_POLY_SET* aBoardOutline ) const;
397 
411  PCB_LAYER_ID aLayer, int aClearanceValue,
412  int aError, ERROR_LOC aErrorLoc,
413  bool ignoreLineWidth = false ) const override;
414 
425  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy,
426  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
427 
435  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy ) const;
436 
446  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy,
447  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
448 
456  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy ) const;
457 
462  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
463 
469  bool UnFill();
470 
471  /* Geometric transformations: */
472 
478  void Move( const wxPoint& offset ) override;
479 
486  void MoveEdge( const wxPoint& offset, int aEdge );
487 
494  void Rotate( const wxPoint& aCentre, double aAngle ) override;
495 
502  virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
503 
510  void Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight );
511 
515  wxString GetClass() const override
516  {
517  return wxT( "ZONE" );
518  }
519 
523  int GetNumCorners( void ) const
524  {
525  return m_Poly->TotalVertices();
526  }
527 
534  {
535  return m_Poly->Iterate();
536  }
537 
544  {
545  return m_Poly->IterateWithHoles();
546  }
547 
554  {
555  return m_Poly->CIterateWithHoles();
556  }
557 
558  void RemoveAllContours( void )
559  {
561  }
562 
563  const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
564  {
566 
567  // Convert global to relative indices
568  if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
569  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
570 
571  return m_Poly->CVertex( index );
572  }
573 
574  void SetCornerPosition( int aCornerIndex, const wxPoint& new_pos )
575  {
576  SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
577 
578  // Convert global to relative indices
579  if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
580  {
581  if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
582  || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
583  {
584  SetNeedRefill( true );
585  m_Poly->SetVertex( relativeIndices, new_pos );
586  }
587  }
588  else
589  {
590  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
591  }
592  }
593 
597  void NewHole()
598  {
599  m_Poly->NewHole();
600  }
601 
611  bool AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication = false );
612 
615 
625  bool IsSame( const ZONE &aZoneToCompare );
626 
628  {
629  return m_FilledPolysList.count( aLayer ) > 0;
630  }
631 
636  {
637  wxASSERT( m_FilledPolysList.count( aLayer ) );
638  return m_FilledPolysList.at( aLayer );
639  }
640 
646 
650  void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
651  {
652  m_FilledPolysList[aLayer] = aPolysList;
653  }
654 
658  void SetRawPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
659  {
660  m_RawPolysList[aLayer] = aPolysList;
661  }
662 
670  bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
671 
672  void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
673  {
674  m_insulatedIslands[aLayer].insert( aPolyIdx );
675  }
676 
677  bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
678  SHAPE_POLY_SET* aBoardOutline,
679  SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
680 
681  void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
682 
684 
685  void SetCornerRadius( unsigned int aRadius );
686 
687  unsigned int GetCornerRadius() const { return m_cornerRadius; }
688 
689  bool GetFilledPolysUseThickness() const { return m_fillVersion == 5; }
690  bool GetFilledPolysUseThickness( PCB_LAYER_ID aLayer ) const;
691 
692  int GetFillVersion() const { return m_fillVersion; }
693  void SetFillVersion( int aVersion ) { m_fillVersion = aVersion; }
694 
701  void RemoveCutout( int aOutlineIdx, int aHoleIdx );
702 
709  void AddPolygon( std::vector< wxPoint >& aPolygon );
710 
711  void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
712 
713  void SetFillSegments( PCB_LAYER_ID aLayer, const std::vector<SEG>& aSegments )
714  {
715  m_FillSegmList[aLayer] = aSegments;
716  }
717 
719  {
720  wxASSERT( m_RawPolysList.count( aLayer ) );
721  return m_RawPolysList.at( aLayer );
722  }
723 
724  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
725 
726  BITMAPS GetMenuImage() const override;
727 
728  EDA_ITEM* Clone() const override;
729 
733  bool GetIsRuleArea() const { return m_isRuleArea; }
735  bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
736  bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
737  bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
739  bool IsKeepout() const;
740  bool KeepoutAll() const;
741 
742  void SetIsRuleArea( bool aEnable ) {m_isRuleArea = aEnable; }
743  void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
744  void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
745  void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
746  void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
747  void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
748 
751  m_islandRemovalMode = aRemove; }
752 
753  long long int GetMinIslandArea() const { return m_minIslandArea; }
754  void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
755 
763  int GetBorderHatchPitch() const;
764 
768  static int GetDefaultHatchPitch();
769 
779  void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch,
780  bool aRebuildHatch );
781 
787  void SetHatchPitch( int aPitch );
788 
792  void UnHatchBorder();
793 
798  void HatchBorder();
799 
800  const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
801 
802  bool GetHV45() const { return m_hv45; }
803  void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
804 
809  void BuildHashValue( PCB_LAYER_ID aLayer );
810 
815 
816 #if defined(DEBUG)
817  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
818 #endif
819 
820  virtual void SwapData( BOARD_ITEM* aImage ) override;
821 
822 protected:
825  unsigned int m_cornerRadius;
826 
828  wxString m_zoneName;
829 
831 
832  /* Priority: when a zone outline is inside and other zone, if its priority is higher
833  * the other zone priority, it will be created inside.
834  * if priorities are equal, a DRC error is set
835  */
836  unsigned m_priority;
837 
838  /* A zone outline can be a keepout zone.
839  * It will be never filled, and DRC should test for pads, tracks and vias
840  */
842 
843  /* For keepout zones only:
844  * what is not allowed inside the keepout ( pads, tracks and vias )
845  */
851 
853  int m_ZoneClearance; // Clearance value in internal units.
854  int m_ZoneMinThickness; // Minimum thickness value in filled areas.
855  int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
856  // differences.
858 
863  long long int m_minIslandArea;
864 
867 
874 
875  int m_thermalReliefGap; // Width of the gap in thermal reliefs.
876  int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
877 
878 
886  int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
887  int m_hatchGap; // gap between lines (0 -> solid shape
888  double m_hatchOrientation; // orientation in degrees of grid lines
889  int m_hatchSmoothingLevel; // 0 = no smoothing
890  // 1 = fillet
891  // 2 = arc low def
892  // 3 = arc high def
893  double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
894  double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
895  int m_hatchBorderAlgorithm; // 0 = use min zone thickness
896  // 1 = use hatch thickness
897 
900 
901  int m_localFlgs; // Variable used in polygon calculations.
902 
907  std::map<PCB_LAYER_ID, std::vector<SEG> > m_FillSegmList;
908 
909  /* set of filled polygons used to draw a zone as a filled area.
910  * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
911  * (they are all in one piece) In very simple cases m_FilledPolysList is same
912  * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
913  * a polygon equivalent to m_Poly, without holes but with extra outline segment
914  * connecting "holes" with external main outline. In complex cases an outline
915  * described by m_Poly can have many filled areas
916  */
917  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_FilledPolysList;
918  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_RawPolysList;
919 
922  std::map<PCB_LAYER_ID, bool> m_fillFlags;
923 
925  std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
926 
927  ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
928  int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
929  std::vector<SEG> m_borderHatchLines; // hatch lines
930 
932  std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
933 
934  bool m_hv45; // constrain edges to horiz, vert or 45º
935 
936  double m_area; // The filled zone area
937 
939  std::mutex m_lock;
940 };
941 
942 
946 class FP_ZONE : public ZONE
947 {
948 public:
949  FP_ZONE( BOARD_ITEM_CONTAINER* aParent );
950  FP_ZONE( const FP_ZONE& aZone );
951  FP_ZONE& operator=( const FP_ZONE &aOther );
952 
953  EDA_ITEM* Clone() const override;
954 
955  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
956 };
957 
958 #endif // ZONE_H
bool NeedRefill() const
Definition: zone.h:237
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition: zone.h:927
int TotalVertices() const
Delete aIdx-th polygon from the set.
int NewHole(int aOutline=-1)
Adds a new outline to the set and returns its index.
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: zone.h:523
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: zone.cpp:1094
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:241
wxString GetNetClassName() const override
Returns the netclass of the zone.
Definition: zone.h:95
int GetHatchGap() const
Definition: zone.h:256
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition: zone.h:750
bool m_doNotAllowFootprints
Definition: zone.h:850
void SetCornerRadius(unsigned int aRadius)
Definition: zone.cpp:361
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
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:1108
void SetHatchThickness(int aThickness)
Definition: zone.h:254
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:365
unsigned int m_cornerRadius
Definition: zone.h:825
void TransformSmoothedOutlineToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearance, SHAPE_POLY_SET *aBoardOutline) const
Convert the outlines shape to a polygon with no holes inflated (optional) by max( aClearanceValue,...
Definition: zone.cpp:1286
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:543
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition: zone.h:627
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:790
void SetZoneName(const wxString &aName)
Definition: zone.h:130
bool GetDoNotAllowFootprints() const
Definition: zone.h:738
void SetFillSegments(PCB_LAYER_ID aLayer, const std::vector< SEG > &aSegments)
Definition: zone.h:713
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:745
void UnHatchBorder()
Clear the zone's hatch.
Definition: zone.cpp:913
ZONE_FILL_MODE m_fillMode
How to fill areas:
Definition: zone.h:885
int GetHatchThickness() const
Definition: zone.h:253
int m_ZoneClearance
Definition: zone.h:853
unsigned GetPriority() const
Definition: zone.h:122
NETCLASS * GetNetClass() const override
Return the NETCLASS for this item.
Definition: zone.h:87
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:733
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:553
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
int m_cornerSmoothingType
Definition: zone.h:824
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:614
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:896
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: zone.h:823
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:890
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: zone.h:828
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
int m_hatchSmoothingLevel
Definition: zone.h:889
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:246
ZONE_CONNECTION m_PadConnection
Definition: zone.h:852
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
SHAPE_POLY_SET * Outline()
Definition: zone.h:320
bool GetDoNotAllowVias() const
Definition: zone.h:735
double m_area
Definition: zone.h:936
bool m_doNotAllowTracks
Definition: zone.h:848
~ZONE()
Definition: zone.cpp:100
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition: zone.h:863
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: zone.h:132
const SHAPE_POLY_SET * Outline() const
Definition: zone.h:321
double m_hatchOrientation
Definition: zone.h:888
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:291
double GetHatchSmoothingValue() const
Definition: zone.h:265
bool HitTestCutout(const wxPoint &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Definition: zone.h:358
bool CommonLayerExists(const LSET aLayerSet) const
Test if this zone shares a common layer with the given layer set.
Definition: zone.cpp:230
CONST_ITERATOR CIterateWithHoles(int aOutline) const
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
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:932
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition: zone.cpp:1165
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:316
bool IsSame(const ZONE &aZoneToCompare)
Test if 2 zones are equivalent.
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:635
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition: zone.h:533
bool IsFilled() const
Definition: zone.h:234
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Return an object to iterate through the points of the polygons between aFirst and aLast.
void SetHV45(bool aConstrain)
Definition: zone.h:803
The base class for create windows for drawing purpose.
MD5_HASH GetHashValue(PCB_LAYER_ID aLayer)
Definition: zone.cpp:382
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:546
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void SetPriority(unsigned aPriority)
Definition: zone.h:117
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
ZONE(BOARD_ITEM_CONTAINER *parent, bool aInFP=false)
The ctor to build ZONE, but compatible with FP_ZONE requirement.
Definition: zone.cpp:44
int m_hatchThickness
Definition: zone.h:886
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:180
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy=0) const
Test if the given wxPoint is within the bounds of a filled area of this zone.
Definition: zone.cpp:506
int GetFillVersion() const
Definition: zone.h:692
LSET m_layerSet
Definition: zone.h:830
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: zone.cpp:1100
void SetCornerPosition(int aCornerIndex, const wxPoint &new_pos)
Definition: zone.h:574
virtual wxString GetNetClassName() const
Returns the netclass of the zone.
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:181
bool HitTestForCorner(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a corner.
Definition: zone.cpp:425
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: zone.cpp:733
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
bool m_doNotAllowVias
Definition: zone.h:847
void SetIsRuleArea(bool aEnable)
Definition: zone.h:742
EDA_RECT m_bboxCache
Temp variables used while filling.
Definition: zone.h:921
int GetThermalReliefGap() const
Definition: zone.h:191
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition: zone.h:227
void Rotate(const wxPoint &aCentre, double aAngle) override
Move the outlines.
Definition: zone.cpp:707
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
void GetInteractingZones(PCB_LAYER_ID aLayer, std::vector< ZONE * > *aZones) const
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
Definition: zone.cpp:1135
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:521
std::map< PCB_LAYER_ID, bool > m_fillFlags
Definition: zone.h:922
double GetHatchHoleMinArea() const
Definition: zone.h:268
int m_localFlgs
Definition: zone.h:901
void SetHatchSmoothingValue(double aValue)
Definition: zone.h:266
bool GetDoNotAllowPads() const
Definition: zone.h:737
void MoveEdge(const wxPoint &offset, int aEdge)
Move the outline Edge.
Definition: zone.cpp:692
bool GetDoNotAllowCopperPour() const
Definition: zone.h:734
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: zone.cpp:297
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:597
int GetLocalClearance() const
Definition: zone.h:157
int GetMinThickness() const
Definition: zone.h:244
const EDA_RECT GetBoundingBox() const override
Definition: zone.cpp:322
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:800
void SetHatchGap(int aStep)
Definition: zone.h:257
int GetHatchSmoothingLevel() const
Definition: zone.h:262
static int GetDefaultHatchPitch()
Definition: zone.cpp:1088
const EDA_RECT GetCachedBoundingBox() const
ONLY TO BE USED BY CLIENTS WHICH SET UP THE CACHE!
Definition: zone.h:145
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:746
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:927
ITERATOR IterateWithHoles(int aOutline)
std::vector< SEG > & FillSegments(PCB_LAYER_ID aLayer)
Definition: zone.h:308
Represent a set of closed polygons.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: zone.cpp:1379
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if a point is near an outline edge or a corner of this zone.
Definition: zone.cpp:400
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:218
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition: zone.h:323
void SetSelectedCorner(int aCorner)
Definition: zone.h:285
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
void SetCornerSmoothingType(int aType)
Definition: zone.h:681
int GetLocalFlags() const
Definition: zone.h:305
bool GetDoNotAllowTracks() const
Definition: zone.h:736
int m_thermalReliefGap
Definition: zone.h:875
bool m_hv45
Definition: zone.h:934
void InitDataFromSrcInCopyCtor(const ZONE &aZone)
Copy aZone data to me.
Definition: zone.cpp:107
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
Definition: zone.h:899
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
Definition: zone.h:217
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition: zone.h:857
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:744
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
void SetMinThickness(int aMinThickness)
Definition: zone.h:245
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:613
void SetIsFilled(bool isFilled)
Definition: zone.h:235
void TransformSolidAreasShapesToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Convert solid areas full shapes to polygon set (the full shape is the polygon area with a thick outli...
void SetHatchHoleMinArea(double aPct)
Definition: zone.h:269
std::map< PCB_LAYER_ID, MD5_HASH > m_filledPolysHash
A hash value used in zone filling calculations to see if the filled areas are up to date.
Definition: zone.h:925
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 GetHV45() const
Definition: zone.h:802
int m_ZoneMinThickness
Definition: zone.h:854
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: zone.h:939
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:650
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_RawPolysList
Definition: zone.h:918
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition: zone.cpp:391
bool m_isRuleArea
Definition: zone.h:841
void Move(const wxPoint &offset) override
Move the outlines.
Definition: zone.cpp:671
std::map< PCB_LAYER_ID, std::vector< SEG > > m_FillSegmList
Segments used to fill the zone (#m_FillMode ==1 ), when fill zone by segment is used.
Definition: zone.h:907
int m_borderHatchPitch
Definition: zone.h:928
EDA_UNITS
Definition: eda_units.h:38
bool IsKeepout() const
Definition: zone.cpp:1312
double GetHatchOrientation() const
Definition: zone.h:259
void SetHatchSmoothingLevel(int aLevel)
Definition: zone.h:263
unsigned int GetCornerRadius() const
Definition: zone.h:687
std::vector< SEG > m_borderHatchLines
Definition: zone.h:929
void SetLocalFlags(int aFlags)
Definition: zone.h:306
int GetHatchBorderAlgorithm() const
Definition: zone.h:271
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition: zone.h:672
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:749
void RemoveAllContours(void)
Definition: zone.h:558
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: zone.h:242
const std::vector< SEG > & FillSegments(PCB_LAYER_ID aLayer) const
Definition: zone.h:314
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: zone.cpp:836
void SetMinIslandArea(long long int aArea)
Definition: zone.h:754
int m_hatchBorderAlgorithm
Definition: zone.h:895
void SetPosition(const wxPoint &aPos) override
Definition: zone.h:112
bool HitTestForEdge(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a segment defined by 2 corners.
Definition: zone.cpp:439
wxPoint GetPosition() const override
Definition: zone.cpp:212
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition: zone.h:866
FP_ZONE & operator=(const FP_ZONE &aOther)
Definition: zone.cpp:1342
bool GetGlobalIndex(VERTEX_INDEX aRelativeIndices, int &aGlobalIdx) const
Compute the global index of a vertex from the relative indices of polygon, contour and vertex.
void SetHatchBorderAlgorithm(int aAlgo)
Definition: zone.h:272
void CacheBoundingBox()
Definition: zone.h:146
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:743
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1123
Represent a polyline (an zero-thickness chain of connected line segments).
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:54
void SetHatchPitch(int aPitch)
Set the hatch pitch parameter for the zone.
Definition: zone.cpp:907
int m_hatchGap
Definition: zone.h:887
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: zone.h:563
Handle the component boundary box.
Definition: eda_rect.h:42
FP_ZONE(BOARD_ITEM_CONTAINER *aParent)
Definition: zone.cpp:1326
The main frame for Pcbnew.
void Mirror(const wxPoint &aMirrorRef, bool aMirrorLeftRight)
Mirror the outlines relative to a given horizontal axis the layer is not changed.
Definition: zone.cpp:745
bool IsOnCopperLayer() const override
Definition: zone.cpp:224
void SetHatchOrientation(double aStep)
Definition: zone.h:260
bool m_doNotAllowCopperPour
Definition: zone.h:846
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition: zone.h:232
SHAPE_POLY_SET & RawPolysList(PCB_LAYER_ID aLayer)
Definition: zone.h:718
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:182
static bool ClassOf(const EDA_ITEM *aItem)
Definition: zone.h:74
int m_fillVersion
Definition: zone.h:855
void SetFillVersion(int aVersion)
Definition: zone.h:693
std::mutex & GetLock()
Definition: zone.h:222
int GetSelectedCorner() const
Definition: zone.h:274
void SetThermalReliefGap(int aThermalReliefGap)
Definition: zone.h:183
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:46
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:238
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition: zone.h:82
long long int GetMinIslandArea() const
Definition: zone.h:753
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:238
double m_hatchHoleMinArea
Definition: zone.h:894
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition: zone.cpp:1263
void SetLocalClearance(int aClearance)
Definition: zone.h:158
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition: zone.h:873
void AddPolygon(std::vector< wxPoint > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:819
int GetThermalReliefSpokeWidth() const
Definition: zone.h:202
Abstract interface for BOARD_ITEMs capable of storing other items inside.
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
ZONE & operator=(const ZONE &aOther)
Definition: zone.cpp:90
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: zone.cpp:856
void SetRawPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:658
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, 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: pad.h:57
bool UnFill()
Removes the zone filling.
Definition: zone.cpp:188
wxString GetZoneName() const
Definition: zone.h:129
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:1355
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: zone.h:917
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:308
unsigned m_priority
Definition: zone.h:836
double m_hatchSmoothingValue
Definition: zone.h:893
ZONE_FILL_MODE
Definition: zone_settings.h:38
wxString GetClass() const override
Definition: zone.h:515
int GetCornerSmoothingType() const
Definition: zone.h:683
A specialization of ZONE for use in footprints.
Definition: zone.h:946
int m_thermalReliefSpokeWidth
Definition: zone.h:876
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:747
bool GetFilledPolysUseThickness() const
Definition: zone.h:689
bool KeepoutAll() const
Definition: zone.cpp:1319
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:194
bool m_doNotAllowPads
Definition: zone.h:849
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:1349