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>
328  FLASHING aFlash = FLASHING::DEFAULT ) const override;
329 
336  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
337 
346  bool HitTestFilledArea( PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy = 0 ) const;
347 
356  bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
357  int* aHoleIdx = nullptr ) const;
358 
359  bool HitTestCutout( const wxPoint& aRefPos, int* aOutlineIdx = nullptr,
360  int* aHoleIdx = nullptr ) const
361  {
362  return HitTestCutout( VECTOR2I( aRefPos.x, aRefPos.y ), aOutlineIdx, aHoleIdx );
363  }
364 
370  void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aZones ) const;
371 
383  int aError = ARC_HIGH_DEF ) const;
384 
396  void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearance,
397  int aError, ERROR_LOC aErrorLoc,
398  SHAPE_POLY_SET* aBoardOutline ) const;
399 
413  PCB_LAYER_ID aLayer, int aClearanceValue,
414  int aError, ERROR_LOC aErrorLoc,
415  bool ignoreLineWidth = false ) const override;
416 
427  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy,
428  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
429 
437  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy ) const;
438 
448  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy,
449  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
450 
458  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy ) const;
459 
464  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
465 
471  bool UnFill();
472 
473  /* Geometric transformations: */
474 
480  void Move( const wxPoint& offset ) override;
481 
488  void MoveEdge( const wxPoint& offset, int aEdge );
489 
496  void Rotate( const wxPoint& aCentre, double aAngle ) override;
497 
504  virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
505 
512  void Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight );
513 
517  wxString GetClass() const override
518  {
519  return wxT( "ZONE" );
520  }
521 
525  int GetNumCorners( void ) const
526  {
527  return m_Poly->TotalVertices();
528  }
529 
536  {
537  return m_Poly->Iterate();
538  }
539 
546  {
547  return m_Poly->IterateWithHoles();
548  }
549 
556  {
557  return m_Poly->CIterateWithHoles();
558  }
559 
560  void RemoveAllContours( void )
561  {
563  }
564 
565  const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
566  {
568 
569  // Convert global to relative indices
570  if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
571  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
572 
573  return m_Poly->CVertex( index );
574  }
575 
576  void SetCornerPosition( int aCornerIndex, const wxPoint& new_pos )
577  {
578  SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
579 
580  // Convert global to relative indices
581  if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
582  {
583  if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
584  || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
585  {
586  SetNeedRefill( true );
587  m_Poly->SetVertex( relativeIndices, new_pos );
588  }
589  }
590  else
591  {
592  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
593  }
594  }
595 
599  void NewHole()
600  {
601  m_Poly->NewHole();
602  }
603 
613  bool AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication = false );
614 
617 
627  bool IsSame( const ZONE &aZoneToCompare );
628 
630  {
631  return m_FilledPolysList.count( aLayer ) > 0;
632  }
633 
638  {
639  wxASSERT( m_FilledPolysList.count( aLayer ) );
640  return m_FilledPolysList.at( aLayer );
641  }
642 
648 
652  void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
653  {
654  m_FilledPolysList[aLayer] = aPolysList;
655  }
656 
660  void SetRawPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
661  {
662  m_RawPolysList[aLayer] = aPolysList;
663  }
664 
672  bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
673 
674  void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
675  {
676  m_insulatedIslands[aLayer].insert( aPolyIdx );
677  }
678 
679  bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
680  SHAPE_POLY_SET* aBoardOutline,
681  SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
682 
683  void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
684 
686 
687  void SetCornerRadius( unsigned int aRadius );
688 
689  unsigned int GetCornerRadius() const { return m_cornerRadius; }
690 
691  bool GetFilledPolysUseThickness() const { return m_fillVersion == 5; }
692  bool GetFilledPolysUseThickness( PCB_LAYER_ID aLayer ) const;
693 
694  int GetFillVersion() const { return m_fillVersion; }
695  void SetFillVersion( int aVersion ) { m_fillVersion = aVersion; }
696 
703  void RemoveCutout( int aOutlineIdx, int aHoleIdx );
704 
711  void AddPolygon( std::vector< wxPoint >& aPolygon );
712 
713  void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
714 
715  void SetFillSegments( PCB_LAYER_ID aLayer, const std::vector<SEG>& aSegments )
716  {
717  m_FillSegmList[aLayer] = aSegments;
718  }
719 
721  {
722  wxASSERT( m_RawPolysList.count( aLayer ) );
723  return m_RawPolysList.at( aLayer );
724  }
725 
726  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
727 
728  BITMAPS GetMenuImage() const override;
729 
730  EDA_ITEM* Clone() const override;
731 
735  bool GetIsRuleArea() const { return m_isRuleArea; }
737  bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
738  bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
739  bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
741  bool IsKeepout() const;
742  bool KeepoutAll() const;
743 
744  void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
745  void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
746  void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
747  void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
748  void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
749  void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
750 
753 
754  long long int GetMinIslandArea() const { return m_minIslandArea; }
755  void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
756 
764  int GetBorderHatchPitch() const;
765 
769  static int GetDefaultHatchPitch();
770 
780  void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch,
781  bool aRebuildHatch );
782 
788  void SetHatchPitch( int aPitch );
789 
793  void UnHatchBorder();
794 
799  void HatchBorder();
800 
801  const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
802 
803  bool GetHV45() const { return m_hv45; }
804  void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
805 
810  void BuildHashValue( PCB_LAYER_ID aLayer );
811 
816 
817 #if defined(DEBUG)
818  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
819 #endif
820 
821  virtual void SwapData( BOARD_ITEM* aImage ) override;
822 
823 protected:
826  unsigned int m_cornerRadius;
827 
829  wxString m_zoneName;
830 
832 
833  /* Priority: when a zone outline is inside and other zone, if its priority is higher
834  * the other zone priority, it will be created inside.
835  * if priorities are equal, a DRC error is set
836  */
837  unsigned m_priority;
838 
839  /* A zone outline can be a keepout zone.
840  * It will be never filled, and DRC should test for pads, tracks and vias
841  */
843 
844  /* For keepout zones only:
845  * what is not allowed inside the keepout ( pads, tracks and vias )
846  */
852 
854  int m_ZoneClearance; // Clearance value in internal units.
855  int m_ZoneMinThickness; // Minimum thickness value in filled areas.
856  int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
857  // differences.
859 
864  long long int m_minIslandArea;
865 
868 
875 
876  int m_thermalReliefGap; // Width of the gap in thermal reliefs.
877  int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
878 
879 
887  int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
888  int m_hatchGap; // gap between lines (0 -> solid shape
889  double m_hatchOrientation; // orientation in degrees of grid lines
890  int m_hatchSmoothingLevel; // 0 = no smoothing
891  // 1 = fillet
892  // 2 = arc low def
893  // 3 = arc high def
894  double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
895  double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
896  int m_hatchBorderAlgorithm; // 0 = use min zone thickness
897  // 1 = use hatch thickness
898 
901 
902  int m_localFlgs; // Variable used in polygon calculations.
903 
908  std::map<PCB_LAYER_ID, std::vector<SEG> > m_FillSegmList;
909 
910  /* set of filled polygons used to draw a zone as a filled area.
911  * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
912  * (they are all in one piece) In very simple cases m_FilledPolysList is same
913  * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
914  * a polygon equivalent to m_Poly, without holes but with extra outline segment
915  * connecting "holes" with external main outline. In complex cases an outline
916  * described by m_Poly can have many filled areas
917  */
918  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_FilledPolysList;
919  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_RawPolysList;
920 
923  std::map<PCB_LAYER_ID, bool> m_fillFlags;
924 
926  std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
927 
928  ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
929  int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
930  std::vector<SEG> m_borderHatchLines; // hatch lines
931 
933  std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
934 
935  bool m_hv45; // constrain edges to horiz, vert or 45º
936 
937  double m_area; // The filled zone area
938 
940  std::mutex m_lock;
941 };
942 
943 
947 class FP_ZONE : public ZONE
948 {
949 public:
950  FP_ZONE( BOARD_ITEM_CONTAINER* aParent );
951  FP_ZONE( const FP_ZONE& aZone );
952  FP_ZONE& operator=( const FP_ZONE &aOther );
953 
954  EDA_ITEM* Clone() const override;
955 
956  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
957 };
958 
959 #endif // ZONE_H
bool NeedRefill() const
Definition: zone.h:237
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition: zone.h:928
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:525
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: zone.cpp:1044
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:752
bool m_doNotAllowFootprints
Definition: zone.h:851
void SetCornerRadius(unsigned int aRadius)
Definition: zone.cpp:359
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:1058
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:364
unsigned int m_cornerRadius
Definition: zone.h:826
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:545
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition: zone.h:629
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:769
void SetZoneName(const wxString &aName)
Definition: zone.h:130
bool GetDoNotAllowFootprints() const
Definition: zone.h:740
void SetFillSegments(PCB_LAYER_ID aLayer, const std::vector< SEG > &aSegments)
Definition: zone.h:715
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:747
void UnHatchBorder()
Clear the zone's hatch.
Definition: zone.cpp:892
ZONE_FILL_MODE m_fillMode
How to fill areas:
Definition: zone.h:886
int GetHatchThickness() const
Definition: zone.h:253
int m_ZoneClearance
Definition: zone.h:854
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:735
SHAPE_POLY_SET::CONST_ITERATOR CIterateWithHoles() const
Return an iterator to visit all points of the zone's main outline with holes.
Definition: zone.h:555
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
int m_cornerSmoothingType
Definition: zone.h:825
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:616
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:875
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: zone.h:824
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:869
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: zone.h:829
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:890
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:250
ZONE_CONNECTION m_PadConnection
Definition: zone.h:853
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
SHAPE_POLY_SET * Outline()
Definition: zone.h:320
bool GetDoNotAllowVias() const
Definition: zone.h:737
double m_area
Definition: zone.h:937
bool m_doNotAllowTracks
Definition: zone.h:849
~ZONE()
Definition: zone.cpp:104
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition: zone.h:864
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:889
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:289
double GetHatchSmoothingValue() const
Definition: zone.h:265
bool HitTestCutout(const wxPoint &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Definition: zone.h:359
bool CommonLayerExists(const LSET aLayerSet) const
Test if this zone shares a common layer with the given layer set.
Definition: zone.cpp:234
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:933
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Definition: zone.cpp:1117
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:314
bool IsSame(const ZONE &aZoneToCompare)
Test if 2 zones are equivalent.
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
SHAPE_POLY_SET::ITERATOR Iterate()
Return an iterator to visit all points of the zone's main outline without holes.
Definition: zone.h:535
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:804
The base class for create windows for drawing purpose.
MD5_HASH GetHashValue(PCB_LAYER_ID aLayer)
Definition: zone.cpp:380
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:544
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
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:887
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:504
int GetFillVersion() const
Definition: zone.h:694
LSET m_layerSet
Definition: zone.h:831
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: zone.cpp:1050
void SetCornerPosition(int aCornerIndex, const wxPoint &new_pos)
Definition: zone.h:576
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:423
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: zone.cpp:715
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:1336
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:848
void SetIsRuleArea(bool aEnable)
Definition: zone.h:744
EDA_RECT m_bboxCache
Temp variables used while filling.
Definition: zone.h:922
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:689
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:1087
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:519
std::map< PCB_LAYER_ID, bool > m_fillFlags
Definition: zone.h:923
double GetHatchHoleMinArea() const
Definition: zone.h:268
int m_localFlgs
Definition: zone.h:902
void SetHatchSmoothingValue(double aValue)
Definition: zone.h:266
bool GetDoNotAllowPads() const
Definition: zone.h:739
void MoveEdge(const wxPoint &offset, int aEdge)
Move the outline Edge.
Definition: zone.cpp:674
bool GetDoNotAllowCopperPour() const
Definition: zone.h:736
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:295
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:599
int GetLocalClearance() const
Definition: zone.h:157
int GetMinThickness() const
Definition: zone.h:244
const EDA_RECT GetBoundingBox() const override
Definition: zone.cpp:320
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:801
void SetHatchGap(int aStep)
Definition: zone.h:257
int GetHatchSmoothingLevel() const
Definition: zone.h:262
static int GetDefaultHatchPitch()
Definition: zone.cpp:1038
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:748
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:906
ITERATOR IterateWithHoles(int aOutline)
std::vector< SEG > & FillSegments(PCB_LAYER_ID aLayer)
Definition: zone.h:308
Represent a set of closed polygons.
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:398
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:222
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:683
int GetLocalFlags() const
Definition: zone.h:305
bool GetDoNotAllowTracks() const
Definition: zone.h:738
int m_thermalReliefGap
Definition: zone.h:876
bool m_hv45
Definition: zone.h:935
void InitDataFromSrcInCopyCtor(const ZONE &aZone)
Copy aZone data to me.
Definition: zone.cpp:111
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
Definition: zone.h:900
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:858
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:746
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:615
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...
Definition: zone.cpp:1377
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:926
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:803
int m_ZoneMinThickness
Definition: zone.h:855
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: zone.h:940
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:153
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:652
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_RawPolysList
Definition: zone.h:919
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition: zone.cpp:389
bool m_isRuleArea
Definition: zone.h:842
void Move(const wxPoint &offset) override
Move the outlines.
Definition: zone.cpp:653
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:908
int m_borderHatchPitch
Definition: zone.h:929
EDA_UNITS
Definition: eda_units.h:38
bool IsKeepout() const
Definition: zone.cpp:1269
double GetHatchOrientation() const
Definition: zone.h:259
void SetHatchSmoothingLevel(int aLevel)
Definition: zone.h:263
unsigned int GetCornerRadius() const
Definition: zone.h:689
std::vector< SEG > m_borderHatchLines
Definition: zone.h:930
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:674
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:751
void RemoveAllContours(void)
Definition: zone.h:560
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:815
void SetMinIslandArea(long long int aArea)
Definition: zone.h:755
int m_hatchBorderAlgorithm
Definition: zone.h:896
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:437
wxPoint GetPosition() const override
Definition: zone.cpp:216
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition: zone.h:867
FP_ZONE & operator=(const FP_ZONE &aOther)
Definition: zone.cpp:1299
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:191
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:745
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1075
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
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:886
int m_hatchGap
Definition: zone.h:888
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: zone.h:565
Handle the component boundary box.
Definition: eda_rect.h:42
FP_ZONE(BOARD_ITEM_CONTAINER *aParent)
Definition: zone.cpp:1283
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:724
bool IsOnCopperLayer() const override
Definition: zone.cpp:228
void SetHatchOrientation(double aStep)
Definition: zone.h:260
bool m_doNotAllowCopperPour
Definition: zone.h:847
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition: zone.h:232
SHAPE_POLY_SET & RawPolysList(PCB_LAYER_ID aLayer)
Definition: zone.h:720
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:186
static bool ClassOf(const EDA_ITEM *aItem)
Definition: zone.h:74
int m_fillVersion
Definition: zone.h:856
void SetFillVersion(int aVersion)
Definition: zone.h:695
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
void TransformSmoothedOutlineToPolygon(SHAPE_POLY_SET &aCornerBuffer, 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:1238
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:242
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition: zone.h:82
long long int GetMinIslandArea() const
Definition: zone.h:754
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:238
double m_hatchHoleMinArea
Definition: zone.h:895
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition: zone.cpp:1215
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:874
void AddPolygon(std::vector< wxPoint > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:798
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:94
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:835
void SetRawPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
Definition: zone.h:660
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: zone.cpp:1353
Definition: pad.h:57
bool UnFill()
Removes the zone filling.
Definition: zone.cpp:192
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:1312
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: zone.h:918
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:306
unsigned m_priority
Definition: zone.h:837
double m_hatchSmoothingValue
Definition: zone.h:894
ZONE_FILL_MODE
Definition: zone_settings.h:38
wxString GetClass() const override
Definition: zone.h:517
int GetCornerSmoothingType() const
Definition: zone.h:685
A specialization of ZONE for use in footprints.
Definition: zone.h:947
int m_thermalReliefSpokeWidth
Definition: zone.h:877
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:749
bool GetFilledPolysUseThickness() const
Definition: zone.h:691
bool KeepoutAll() const
Definition: zone.cpp:1276
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:194
bool m_doNotAllowPads
Definition: zone.h:850
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:1306