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>
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;
45 
46 typedef std::vector<SEG> ZONE_SEGMENT_FILL;
47 
57 class ZONE : public BOARD_CONNECTED_ITEM
58 {
59 public:
60 
68  ZONE( BOARD_ITEM_CONTAINER* parent, bool aInFP = false );
69 
70  ZONE( const ZONE& aZone );
71  ZONE& operator=( const ZONE &aOther );
72 
73  ~ZONE();
74 
75  static inline bool ClassOf( const EDA_ITEM* aItem )
76  {
77  return aItem && aItem->Type() == PCB_ZONE_T;
78  }
79 
83  bool IsConnected() const override
84  {
85  return !GetIsRuleArea();
86  }
87 
88  NETCLASS* GetNetClass() const override
89  {
90  if( GetIsRuleArea() )
91  return nullptr;
92 
94  }
95 
96  wxString GetNetClassName() const override
97  {
98  if( GetIsRuleArea() )
99  return "UNDEFINED";
100 
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  int GetThermalReliefGap() const { return m_thermalReliefGap; }
191  int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
192 
193  void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
194  {
195  if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
196  SetNeedRefill( true );
197 
198  m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
199  }
201  int GetThermalReliefSpokeWidth( PAD* aPad, wxString* aSource = nullptr ) const;
202 
208  double CalculateFilledArea();
209 
215  double GetFilledArea()
216  {
217  return m_area;
218  }
219 
220  std::mutex& GetLock()
221  {
222  return m_lock;
223  }
224 
225  int GetFillFlag( PCB_LAYER_ID aLayer )
226  {
227  return m_fillFlags.count( aLayer ) ? m_fillFlags[ aLayer ] : false;
228  }
229  void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags[ aLayer ] = aFlag; }
230 
231  bool IsFilled() const { return m_isFilled; }
232  void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
233 
234  bool NeedRefill() const { return m_needRefill; }
235  void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
236 
237  ZONE_CONNECTION GetPadConnection( PAD* aPad, wxString* aSource = nullptr ) const;
239  void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
240 
241  int GetMinThickness() const { return m_ZoneMinThickness; }
242  void SetMinThickness( int aMinThickness )
243  {
244  if( m_ZoneMinThickness != aMinThickness )
245  SetNeedRefill( true );
246 
247  m_ZoneMinThickness = aMinThickness;
248  }
249 
250  int GetHatchThickness() const { return m_hatchThickness; }
251  void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
252 
253  int GetHatchGap() const { return m_hatchGap; }
254  void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
255 
256  double GetHatchOrientation() const { return m_hatchOrientation; }
257  void SetHatchOrientation( double aStep ) { m_hatchOrientation = aStep; }
258 
260  void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
261 
263  void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
264 
265  double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
266  void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
267 
269  void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
270 
271  int GetSelectedCorner() const
272  {
273  // Transform relative indices to global index
274  int globalIndex = -1;
275 
276  if( m_CornerSelection )
277  m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
278 
279  return globalIndex;
280  }
281 
282  void SetSelectedCorner( int aCorner )
283  {
284  SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
285 
286  // If the global index of the corner is correct, assign it to m_CornerSelection
287  if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
288  {
289  if( m_CornerSelection == nullptr )
291 
292  *m_CornerSelection = selectedCorner;
293  }
294  else
295  throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
296  }
297 
299  // Like HitTest but selects the current corner to be operated on
300  void SetSelectedCorner( const wxPoint& aPosition, int aAccuracy );
301 
302  int GetLocalFlags() const { return m_localFlgs; }
303  void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
304 
306  {
307  wxASSERT( m_FillSegmList.count( aLayer ) );
308  return m_FillSegmList.at( aLayer );
309  }
310 
312  {
313  wxASSERT( m_FillSegmList.count( aLayer ) );
314  return m_FillSegmList.at( aLayer );
315  }
316 
318  const SHAPE_POLY_SET* Outline() const { return m_Poly; }
319 
320  void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
321 
322  // @copydoc BOARD_ITEM::GetEffectiveShape
323  virtual std::shared_ptr<SHAPE>
324  GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
325 
332  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
333 
342  bool HitTestFilledArea( PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy = 0 ) const;
343 
352  bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
353  int* aHoleIdx = nullptr ) const;
354 
355  bool HitTestCutout( const wxPoint& aRefPos, int* aOutlineIdx = nullptr,
356  int* aHoleIdx = nullptr ) const
357  {
358  return HitTestCutout( VECTOR2I( aRefPos.x, aRefPos.y ), aOutlineIdx, aHoleIdx );
359  }
360 
366  void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aZones ) const;
367 
379  int aError = ARC_HIGH_DEF ) const;
380 
392  void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearance,
393  SHAPE_POLY_SET* aBoardOutline ) const;
394 
408  PCB_LAYER_ID aLayer, int aClearanceValue,
409  int aError, ERROR_LOC aErrorLoc,
410  bool ignoreLineWidth = false ) const override;
411 
422  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy,
423  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
424 
432  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy ) const;
433 
443  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy,
444  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
445 
453  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy ) const;
454 
459  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
460 
466  bool UnFill();
467 
468  /* Geometric transformations: */
469 
475  void Move( const wxPoint& offset ) override;
476 
483  void MoveEdge( const wxPoint& offset, int aEdge );
484 
491  void Rotate( const wxPoint& aCentre, double aAngle ) override;
492 
499  virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
500 
507  void Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight );
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  {
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 
571  void SetCornerPosition( int aCornerIndex, wxPoint new_pos )
572  {
573  SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
574 
575  // Convert global to relative indices
576  if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
577  {
578  if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
579  || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
580  {
581  SetNeedRefill( true );
582  m_Poly->SetVertex( relativeIndices, new_pos );
583  }
584  }
585  else
586  {
587  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
588  }
589  }
590 
594  void NewHole()
595  {
596  m_Poly->NewHole();
597  }
598 
608  bool AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication = false );
609 
612 
622  bool IsSame( const ZONE &aZoneToCompare );
623 
625  {
626  return m_FilledPolysList.count( aLayer ) > 0;
627  }
628 
633  {
634  wxASSERT( m_FilledPolysList.count( aLayer ) );
635  return m_FilledPolysList.at( aLayer );
636  }
637 
643 
647  void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
648  {
649  m_FilledPolysList[aLayer] = aPolysList;
650  }
651 
655  void SetRawPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
656  {
657  m_RawPolysList[aLayer] = aPolysList;
658  }
659 
667  bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
668 
669  void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
670  {
671  m_insulatedIslands[aLayer].insert( aPolyIdx );
672  }
673 
674  bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
675  SHAPE_POLY_SET* aBoardOutline,
676  SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
677 
678  void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
679 
681 
682  void SetCornerRadius( unsigned int aRadius );
683 
684  unsigned int GetCornerRadius() const { return m_cornerRadius; }
685 
686  bool GetFilledPolysUseThickness() const { return m_fillVersion == 5; }
687  bool GetFilledPolysUseThickness( PCB_LAYER_ID aLayer ) const;
688 
689  int GetFillVersion() const { return m_fillVersion; }
690  void SetFillVersion( int aVersion ) { m_fillVersion = aVersion; }
691 
698  void RemoveCutout( int aOutlineIdx, int aHoleIdx );
699 
706  void AddPolygon( std::vector< wxPoint >& aPolygon );
707 
708  void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
709 
710  void SetFillSegments( PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL& aSegments )
711  {
712  m_FillSegmList[aLayer] = aSegments;
713  }
714 
716  {
717  wxASSERT( m_RawPolysList.count( aLayer ) );
718  return m_RawPolysList.at( aLayer );
719  }
720 
721  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
722 
723  BITMAPS GetMenuImage() const override;
724 
725  EDA_ITEM* Clone() const override;
726 
730  bool GetIsRuleArea() const { return m_isRuleArea; }
732  bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
733  bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
734  bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
736  bool IsKeepout() const;
737  bool KeepoutAll() const;
738 
739  void SetIsRuleArea( bool aEnable ) {m_isRuleArea = aEnable; }
740  void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
741  void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
742  void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
743  void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
744  void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
745 
748  m_islandRemovalMode = aRemove; }
749 
750  long long int GetMinIslandArea() const { return m_minIslandArea; }
751  void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
752 
760  int GetBorderHatchPitch() const;
761 
765  static int GetDefaultHatchPitch();
766 
776  void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch,
777  bool aRebuildHatch );
778 
784  void SetHatchPitch( int aPitch );
785 
789  void UnHatchBorder();
790 
795  void HatchBorder();
796 
797  const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
798 
799  bool GetHV45() const { return m_hv45; }
800  void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
801 
806  void BuildHashValue( PCB_LAYER_ID aLayer );
807 
812 
813 #if defined(DEBUG)
814  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
815 #endif
816 
817  virtual void SwapData( BOARD_ITEM* aImage ) override;
818 
819 protected:
822  unsigned int m_cornerRadius;
823 
825  wxString m_zoneName;
826 
828 
829  /* Priority: when a zone outline is inside and other zone, if its priority is higher
830  * the other zone priority, it will be created inside.
831  * if priorities are equal, a DRC error is set
832  */
833  unsigned m_priority;
834 
835  /* A zone outline can be a keepout zone.
836  * It will be never filled, and DRC should test for pads, tracks and vias
837  */
839 
840  /* For keepout zones only:
841  * what is not allowed inside the keepout ( pads, tracks and vias )
842  */
848 
850  int m_ZoneClearance; // Clearance value in internal units.
851  int m_ZoneMinThickness; // Minimum thickness value in filled areas.
852  int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
853  // differences.
855 
860  long long int m_minIslandArea;
861 
864 
871 
872  int m_thermalReliefGap; // Width of the gap in thermal reliefs.
873  int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
874 
875 
883  int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
884  int m_hatchGap; // gap between lines (0 -> solid shape
885  double m_hatchOrientation; // orientation in degrees of grid lines
886  int m_hatchSmoothingLevel; // 0 = no smoothing
887  // 1 = fillet
888  // 2 = arc low def
889  // 3 = arc high def
890  double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
891  double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
892  int m_hatchBorderAlgorithm; // 0 = use min zone thickness
893  // 1 = use hatch thickness
894 
897 
898  int m_localFlgs; // Variable used in polygon calculations.
899 
904  std::map<PCB_LAYER_ID, ZONE_SEGMENT_FILL> m_FillSegmList;
905 
906  /* set of filled polygons used to draw a zone as a filled area.
907  * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
908  * (they are all in one piece) In very simple cases m_FilledPolysList is same
909  * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
910  * a polygon equivalent to m_Poly, without holes but with extra outline segment
911  * connecting "holes" with external main outline. In complex cases an outline
912  * described by m_Poly can have many filled areas
913  */
914  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_FilledPolysList;
915  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_RawPolysList;
916 
919  std::map<PCB_LAYER_ID, bool> m_fillFlags;
920 
922  std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
923 
924  ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
925  int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
926  std::vector<SEG> m_borderHatchLines; // hatch lines
927 
929  std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
930 
931  bool m_hv45; // constrain edges to horiz, vert or 45º
932 
933  double m_area; // The filled zone area
934 
936  std::mutex m_lock;
937 };
938 
939 
943 class FP_ZONE : public ZONE
944 {
945 public:
946  FP_ZONE( BOARD_ITEM_CONTAINER* aParent );
947  FP_ZONE( const FP_ZONE& aZone );
948  FP_ZONE& operator=( const FP_ZONE &aOther );
949 
950  EDA_ITEM* Clone() const override;
951 
952  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
953 };
954 
955 #endif // ZONE_H
bool NeedRefill() const
Definition: zone.h:234
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition: zone.h:924
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:520
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: zone.cpp:1098
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:238
wxString GetNetClassName() const override
Returns the netclass of the zone.
Definition: zone.h:96
int GetHatchGap() const
Definition: zone.h:253
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition: zone.h:747
bool m_doNotAllowFootprints
Definition: zone.h:847
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:1112
void SetHatchThickness(int aThickness)
Definition: zone.h:251
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:822
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:1281
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:540
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition: zone.h:624
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:792
void SetZoneName(const wxString &aName)
Definition: zone.h:130
bool GetDoNotAllowFootprints() const
Definition: zone.h:735
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:742
void UnHatchBorder()
Clear the zone's hatch.
Definition: zone.cpp:915
ZONE_FILL_MODE m_fillMode
How to fill areas:
Definition: zone.h:882
int GetHatchThickness() const
Definition: zone.h:250
int m_ZoneClearance
Definition: zone.h:850
unsigned GetPriority() const
Definition: zone.h:122
NETCLASS * GetNetClass() const override
Return the NETCLASS for this item.
Definition: zone.h:88
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:730
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
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:821
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:611
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:898
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: zone.h:820
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:892
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: zone.h:825
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:886
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:246
ZONE_CONNECTION m_PadConnection
Definition: zone.h:849
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
SHAPE_POLY_SET * Outline()
Definition: zone.h:317
bool GetDoNotAllowVias() const
Definition: zone.h:732
double m_area
Definition: zone.h:933
bool m_doNotAllowTracks
Definition: zone.h:845
~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:860
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:318
double m_hatchOrientation
Definition: zone.h:885
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:262
bool HitTestCutout(const wxPoint &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Definition: zone.h:355
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:929
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition: zone.cpp:1169
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:632
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition: zone.h:530
bool IsFilled() const
Definition: zone.h:231
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:800
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:883
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:689
LSET m_layerSet
Definition: zone.h:827
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: zone.cpp:1104
virtual wxString GetNetClassName() const
Returns the netclass of the zone.
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:181
struct SHAPE_POLY_SET::VERTEX_INDEX VERTEX_INDEX
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
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:735
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:844
void SetIsRuleArea(bool aEnable)
Definition: zone.h:739
EDA_RECT m_bboxCache
Temp variables used while filling.
Definition: zone.h:918
std::map< PCB_LAYER_ID, ZONE_SEGMENT_FILL > m_FillSegmList
Segments used to fill the zone (#m_FillMode ==1 ), when fill zone by segment is used.
Definition: zone.h:904
int GetThermalReliefGap() const
Definition: zone.h:190
void SetFillSegments(PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL &aSegments)
Definition: zone.h:710
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition: zone.h:225
void Rotate(const wxPoint &aCentre, double aAngle) override
Move the outlines.
Definition: zone.cpp:709
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:1139
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:919
double GetHatchHoleMinArea() const
Definition: zone.h:265
int m_localFlgs
Definition: zone.h:898
void SetHatchSmoothingValue(double aValue)
Definition: zone.h:263
bool GetDoNotAllowPads() const
Definition: zone.h:734
void MoveEdge(const wxPoint &offset, int aEdge)
Move the outline Edge.
Definition: zone.cpp:694
PCB_LAYER_ID
A quick note on layer IDs:
bool GetDoNotAllowCopperPour() const
Definition: zone.h:731
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.
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:594
int GetLocalClearance() const
Definition: zone.h:157
int GetMinThickness() const
Definition: zone.h:241
const EDA_RECT GetBoundingBox() const override
Definition: zone.cpp:322
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:797
void SetHatchGap(int aStep)
Definition: zone.h:254
int GetHatchSmoothingLevel() const
Definition: zone.h:259
static int GetDefaultHatchPitch()
Definition: zone.cpp:1092
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:743
void SetCornerPosition(int aCornerIndex, wxPoint new_pos)
Definition: zone.h:571
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:929
ITERATOR IterateWithHoles(int aOutline)
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:1377
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:320
void SetSelectedCorner(int aCorner)
Definition: zone.h:282
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:678
int GetLocalFlags() const
Definition: zone.h:302
bool GetDoNotAllowTracks() const
Definition: zone.h:733
int m_thermalReliefGap
Definition: zone.h:872
bool m_hv45
Definition: zone.h:931
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:896
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
Definition: zone.h:215
const ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer) const
Definition: zone.h:311
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition: zone.h:854
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:741
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:105
void SetMinThickness(int aMinThickness)
Definition: zone.h:242
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:610
void SetIsFilled(bool isFilled)
Definition: zone.h:232
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:266
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:922
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:799
int m_ZoneMinThickness
Definition: zone.h:851
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: zone.h:936
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:647
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_RawPolysList
Definition: zone.h:915
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:838
void Move(const wxPoint &offset) override
Move the outlines.
Definition: zone.cpp:673
int m_borderHatchPitch
Definition: zone.h:925
EDA_UNITS
Definition: eda_units.h:38
bool IsKeepout() const
Definition: zone.cpp:1307
double GetHatchOrientation() const
Definition: zone.h:256
void SetHatchSmoothingLevel(int aLevel)
Definition: zone.h:260
unsigned int GetCornerRadius() const
Definition: zone.h:684
std::vector< SEG > m_borderHatchLines
Definition: zone.h:926
void SetLocalFlags(int aFlags)
Definition: zone.h:303
int GetHatchBorderAlgorithm() const
Definition: zone.h:268
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition: zone.h:669
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:746
void RemoveAllContours(void)
Definition: zone.h:555
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: zone.h:239
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:838
void SetMinIslandArea(long long int aArea)
Definition: zone.h:751
int m_hatchBorderAlgorithm
Definition: zone.h:892
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:863
FP_ZONE & operator=(const FP_ZONE &aOther)
Definition: zone.cpp:1340
std::vector< SEG > ZONE_SEGMENT_FILL
Definition: zone.h:44
Board layer functions and definitions.
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:269
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:740
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1127
SHAPE_LINE_CHAIN.
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:909
int m_hatchGap
Definition: zone.h:884
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: zone.h:560
Handle the component boundary box.
Definition: eda_rect.h:42
FP_ZONE(BOARD_ITEM_CONTAINER *aParent)
Definition: zone.cpp:1324
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:747
bool IsOnCopperLayer() const override
Definition: zone.cpp:224
void SetHatchOrientation(double aStep)
Definition: zone.h:257
bool m_doNotAllowCopperPour
Definition: zone.h:843
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:229
SHAPE_POLY_SET & RawPolysList(PCB_LAYER_ID aLayer)
Definition: zone.h:715
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:75
int m_fillVersion
Definition: zone.h:852
void SetFillVersion(int aVersion)
Definition: zone.h:690
std::mutex & GetLock()
Definition: zone.h:220
int GetSelectedCorner() const
Definition: zone.h:271
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:83
long long int GetMinIslandArea() const
Definition: zone.h:750
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:235
double m_hatchHoleMinArea
Definition: zone.h:891
ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer)
Definition: zone.h:305
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition: zone.cpp:1258
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:870
void AddPolygon(std::vector< wxPoint > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:821
int GetThermalReliefSpokeWidth() const
Definition: zone.h:200
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:67
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:858
void SetRawPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:655
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:1353
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: zone.h:914
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:833
double m_hatchSmoothingValue
Definition: zone.h:890
ZONE_FILL_MODE
Definition: zone_settings.h:38
wxString GetClass() const override
Definition: zone.h:512
int GetCornerSmoothingType() const
Definition: zone.h:680
A specialization of ZONE for use in footprints.
Definition: zone.h:943
int m_thermalReliefSpokeWidth
Definition: zone.h:873
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:744
bool GetFilledPolysUseThickness() const
Definition: zone.h:686
bool KeepoutAll() const
Definition: zone.cpp:1314
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:193
bool m_doNotAllowPads
Definition: zone.h:846
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:1347