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-2020 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 
118  void SetPriority( unsigned aPriority ) { m_priority = aPriority; }
119 
124  unsigned GetPriority() const { return m_priority; }
125 
126  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
127 
128  void SetLayerSet( LSET aLayerSet ) override;
129  virtual LSET GetLayerSet() const override;
130 
131  wxString GetZoneName() const { return m_zoneName; }
132  void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
133 
134  bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
135  {
136  return BOARD_ITEM::Matches( GetZoneName(), aSearchData );
137  }
138 
143  const EDA_RECT GetBoundingBox() const override;
144 
148  const EDA_RECT GetCachedBoundingBox() const { return m_bboxCache; }
150 
158  int GetLocalClearance( wxString* aSource ) const override;
159 
160  int GetLocalClearance() const { return GetLocalClearance( nullptr ); }
161  void SetLocalClearance( int aClearance ) { m_ZoneClearance = aClearance; }
162 
167  bool IsOnCopperLayer() const override;
168 
173  bool CommonLayerExists( const LSET aLayerSet ) const;
174 
175  virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
176 
177  virtual PCB_LAYER_ID GetLayer() const override;
178 
179  virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
180 
181  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
182 
183  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
184 
185  void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
187 
188  void SetThermalReliefGap( int aThermalReliefGap )
189  {
190  if( m_thermalReliefGap != aThermalReliefGap )
191  SetNeedRefill( true );
192 
193  m_thermalReliefGap = aThermalReliefGap;
194  }
195  int GetThermalReliefGap() const { return m_thermalReliefGap; }
196  int GetThermalReliefGap( PAD* aPad, wxString* aSource = nullptr ) const;
197 
198  void SetThermalReliefSpokeWidth( int aThermalReliefSpokeWidth )
199  {
200  if( m_thermalReliefSpokeWidth != aThermalReliefSpokeWidth )
201  SetNeedRefill( true );
202 
203  m_thermalReliefSpokeWidth = aThermalReliefSpokeWidth;
204  }
206  int GetThermalReliefSpokeWidth( PAD* aPad, wxString* aSource = nullptr ) const;
207 
213  double CalculateFilledArea();
214 
221  double GetFilledArea()
222  {
223  return m_area;
224  }
225 
226  std::mutex& GetLock()
227  {
228  return m_lock;
229  }
230 
231  int GetFillFlag( PCB_LAYER_ID aLayer )
232  {
233  return m_fillFlags.count( aLayer ) ? m_fillFlags[ aLayer ] : false;
234  }
235  void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags[ aLayer ] = aFlag; }
236 
237  bool IsFilled() const { return m_isFilled; }
238  void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; }
239 
240  bool NeedRefill() const { return m_needRefill; }
241  void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
242 
243  ZONE_CONNECTION GetPadConnection( PAD* aPad, wxString* aSource = nullptr ) const;
245  void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_PadConnection = aPadConnection; }
246 
247  int GetMinThickness() const { return m_ZoneMinThickness; }
248  void SetMinThickness( int aMinThickness )
249  {
250  if( m_ZoneMinThickness != aMinThickness )
251  SetNeedRefill( true );
252 
253  m_ZoneMinThickness = aMinThickness;
254  }
255 
256  int GetHatchThickness() const { return m_hatchThickness; }
257  void SetHatchThickness( int aThickness ) { m_hatchThickness = aThickness; }
258 
259  int GetHatchGap() const { return m_hatchGap; }
260  void SetHatchGap( int aStep ) { m_hatchGap = aStep; }
261 
262  double GetHatchOrientation() const { return m_hatchOrientation; }
263  void SetHatchOrientation( double aStep ) { m_hatchOrientation = aStep; }
264 
266  void SetHatchSmoothingLevel( int aLevel ) { m_hatchSmoothingLevel = aLevel; }
267 
269  void SetHatchSmoothingValue( double aValue ) { m_hatchSmoothingValue = aValue; }
270 
271  double GetHatchHoleMinArea() const { return m_hatchHoleMinArea; }
272  void SetHatchHoleMinArea( double aPct ) { m_hatchHoleMinArea = aPct; }
273 
275  void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
276 
277  int GetSelectedCorner() const
278  {
279  // Transform relative indices to global index
280  int globalIndex = -1;
281 
282  if( m_CornerSelection )
283  m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
284 
285  return globalIndex;
286  }
287 
288  void SetSelectedCorner( int aCorner )
289  {
290  SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
291 
292  // If the global index of the corner is correct, assign it to m_CornerSelection
293  if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
294  {
295  if( m_CornerSelection == nullptr )
297 
298  *m_CornerSelection = selectedCorner;
299  }
300  else
301  throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
302  }
303 
305  // Like HitTest but selects the current corner to be operated on
306  void SetSelectedCorner( const wxPoint& aPosition, int aAccuracy );
307 
308  int GetLocalFlags() const { return m_localFlgs; }
309  void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
310 
312  {
313  wxASSERT( m_FillSegmList.count( aLayer ) );
314  return m_FillSegmList.at( aLayer );
315  }
316 
318  {
319  wxASSERT( m_FillSegmList.count( aLayer ) );
320  return m_FillSegmList.at( aLayer );
321  }
322 
324  const SHAPE_POLY_SET* Outline() const { return m_Poly; }
325 
326  void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
327 
328  // @copydoc BOARD_ITEM::GetEffectiveShape
329  virtual std::shared_ptr<SHAPE>
330  GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
331 
338  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
339 
348  bool HitTestFilledArea( PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy = 0 ) const;
349 
358  bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
359  int* aHoleIdx = nullptr ) const;
360 
361  bool HitTestCutout( const wxPoint& aRefPos, int* aOutlineIdx = nullptr,
362  int* aHoleIdx = nullptr ) const
363  {
364  return HitTestCutout( VECTOR2I( aRefPos.x, aRefPos.y ), aOutlineIdx, aHoleIdx );
365  }
366 
372  void GetInteractingZones( PCB_LAYER_ID aLayer, std::vector<ZONE*>* aZones ) const;
373 
385  int aError = ARC_HIGH_DEF ) const;
386 
398  void TransformSmoothedOutlineToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearance,
399  SHAPE_POLY_SET* aBoardOutline ) const;
400 
414  PCB_LAYER_ID aLayer, int aClearanceValue,
415  int aError, ERROR_LOC aErrorLoc,
416  bool ignoreLineWidth = false ) const override;
417 
428  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy,
429  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
430 
439  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy ) const;
440 
450  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy,
451  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
452 
460  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy ) const;
461 
465  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
466 
467 
474  bool UnFill();
475 
476  /* Geometric transformations: */
477 
483  void Move( const wxPoint& offset ) override;
484 
491  void MoveEdge( const wxPoint& offset, int aEdge );
492 
499  void Rotate( const wxPoint& aCentre, double aAngle ) override;
500 
507  virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
508 
516  void Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight );
517 
523  wxString GetClass() const override
524  {
525  return wxT( "ZONE" );
526  }
527 
530  int GetNumCorners( void ) const
531  {
532  return m_Poly->TotalVertices();
533  }
534 
541  {
542  return m_Poly->Iterate();
543  }
544 
551  {
552  return m_Poly->IterateWithHoles();
553  }
554 
561  {
562  return m_Poly->CIterateWithHoles();
563  }
564 
565  void RemoveAllContours( void )
566  {
568  }
569 
570  const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
571  {
573 
574  // Convert global to relative indices
575  if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
576  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
577 
578  return m_Poly->CVertex( index );
579  }
580 
581  void SetCornerPosition( int aCornerIndex, wxPoint new_pos )
582  {
583  SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
584 
585  // Convert global to relative indices
586  if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
587  {
588  if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
589  || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
590  {
591  SetNeedRefill( true );
592  m_Poly->SetVertex( relativeIndices, new_pos );
593  }
594  }
595  else
596  {
597  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
598  }
599  }
600 
605  void NewHole()
606  {
607  m_Poly->NewHole();
608  }
609 
618  bool AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication = false );
619 
622 
630  bool IsSame( const ZONE &aZoneToCompare );
631 
637  {
638  for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
639  {
640  m_insulatedIslands[pair.first].clear();
641  pair.second.RemoveAllContours();
642  }
643  }
644 
646  {
647  return m_FilledPolysList.count( aLayer ) > 0;
648  }
649 
656  {
657  wxASSERT( m_FilledPolysList.count( aLayer ) );
658  return m_FilledPolysList.at( aLayer );
659  }
660 
665 
670  void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
671  {
672  m_FilledPolysList[aLayer] = aPolysList;
673  }
674 
679  void SetRawPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
680  {
681  m_RawPolysList[aLayer] = aPolysList;
682  }
683 
690  bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx ) const;
691 
692  void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
693  {
694  m_insulatedIslands[aLayer].insert( aPolyIdx );
695  }
696 
700  bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer,
701  SHAPE_POLY_SET* aBoardOutline,
702  SHAPE_POLY_SET* aSmoothedPolyWithApron = nullptr ) const;
703 
704  void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
705 
707 
708  void SetCornerRadius( unsigned int aRadius );
709 
710  unsigned int GetCornerRadius() const { return m_cornerRadius; }
711 
712  bool GetFilledPolysUseThickness() const { return m_fillVersion == 5; }
713  bool GetFilledPolysUseThickness( PCB_LAYER_ID aLayer ) const;
714 
715  int GetFillVersion() const { return m_fillVersion; }
716  void SetFillVersion( int aVersion ) { m_fillVersion = aVersion; }
717 
724  void RemoveCutout( int aOutlineIdx, int aHoleIdx );
725 
731  void AddPolygon( std::vector< wxPoint >& aPolygon );
732 
733  void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
734 
735  void SetFillSegments( PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL& aSegments )
736  {
737  m_FillSegmList[aLayer] = aSegments;
738  }
739 
741  {
742  wxASSERT( m_RawPolysList.count( aLayer ) );
743  return m_RawPolysList.at( aLayer );
744  }
745 
746  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
747 
748  BITMAP_DEF GetMenuImage() const override;
749 
750  EDA_ITEM* Clone() const override;
751 
755  bool GetIsRuleArea() const { return m_isRuleArea; }
757  bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
758  bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
759  bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
761 
762  void SetIsRuleArea( bool aEnable ) {m_isRuleArea = aEnable; }
763  void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
764  void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
765  void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
766  void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
767  void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
768 
771  m_islandRemovalMode = aRemove; }
772 
773  long long int GetMinIslandArea() const { return m_minIslandArea; }
774  void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
775 
784  int GetBorderHatchPitch() const;
785 
790  static int GetDefaultHatchPitch();
791 
801  void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch );
802 
808  void SetHatchPitch( int aPitch );
809 
814  void UnHatchBorder();
815 
821  void HatchBorder();
822 
823  const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
824 
825  bool GetHV45() const { return m_hv45; }
826  void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
827 
832  void BuildHashValue( PCB_LAYER_ID aLayer );
833 
838 
839 #if defined(DEBUG)
840  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
841 #endif
842 
843  virtual void SwapData( BOARD_ITEM* aImage ) override;
844 
845 protected:
848  unsigned int m_cornerRadius;
849 
851  wxString m_zoneName;
852 
854 
855  /* Priority: when a zone outline is inside and other zone, if its priority is higher
856  * the other zone priority, it will be created inside.
857  * if priorities are equal, a DRC error is set
858  */
859  unsigned m_priority;
860 
861  /* A zone outline can be a keepout zone.
862  * It will be never filled, and DRC should test for pads, tracks and vias
863  */
865 
866  /* For keepout zones only:
867  * what is not allowed inside the keepout ( pads, tracks and vias )
868  */
874 
876  int m_ZoneClearance; // Clearance value in internal units.
877  int m_ZoneMinThickness; // Minimum thickness value in filled areas.
878  int m_fillVersion; // See BOARD_DESIGN_SETTINGS for version
879  // differences.
881 
886  long long int m_minIslandArea;
887 
890 
896 
897  int m_thermalReliefGap; // Width of the gap in thermal reliefs.
898  int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
899 
900 
906  int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
907  int m_hatchGap; // gap between lines (0 -> solid shape
908  double m_hatchOrientation; // orientation in degrees of grid lines
909  int m_hatchSmoothingLevel; // 0 = no smoothing
910  // 1 = fillet
911  // 2 = arc low def
912  // 3 = arc high def
913  double m_hatchSmoothingValue; // hole chamfer/fillet size (ratio of hole size)
914  double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
915  int m_hatchBorderAlgorithm; // 0 = use min zone thickness
916  // 1 = use hatch thickness
917 
920 
921  int m_localFlgs; // Variable used in polygon calculations.
922 
926  std::map<PCB_LAYER_ID, ZONE_SEGMENT_FILL> m_FillSegmList;
927 
928  /* set of filled polygons used to draw a zone as a filled area.
929  * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
930  * (they are all in one piece) In very simple cases m_FilledPolysList is same
931  * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
932  * a polygon equivalent to m_Poly, without holes but with extra outline segment
933  * connecting "holes" with external main outline. In complex cases an outline
934  * described by m_Poly can have many filled areas
935  */
936  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_FilledPolysList;
937  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_RawPolysList;
938 
941  std::map<PCB_LAYER_ID, bool> m_fillFlags;
942 
944  std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
945 
946  ZONE_BORDER_DISPLAY_STYLE m_borderStyle; // border display style, see enum above
947  int m_borderHatchPitch; // for DIAGONAL_EDGE, distance between 2 lines
948  std::vector<SEG> m_borderHatchLines; // hatch lines
949 
951  std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
952 
953  bool m_hv45; // constrain edges to horiz, vert or 45º
954 
955  double m_area; // The filled zone area
956 
958  std::mutex m_lock;
959 };
960 
961 
965 class FP_ZONE : public ZONE
966 {
967 public:
968  FP_ZONE( BOARD_ITEM_CONTAINER* aParent );
969  FP_ZONE( const FP_ZONE& aZone );
970  FP_ZONE& operator=( const FP_ZONE &aOther );
971 
972  EDA_ITEM* Clone() const override;
973 
974  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
975 };
976 
977 #endif // ZONE_H
bool NeedRefill() const
Definition: zone.h:240
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
Definition: zone.h:946
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:530
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:244
wxString GetNetClassName() const override
Returns the netclass of the zone.
Definition: zone.h:96
int GetHatchGap() const
Definition: zone.h:259
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition: zone.h:770
bool m_doNotAllowFootprints
Definition: zone.h:873
void SetCornerRadius(unsigned int aRadius)
Definition: zone.cpp:358
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)
(re)create a list of triangles that "fill" the solid areas.
Definition: zone.cpp:1104
void SetHatchThickness(int aThickness)
Definition: zone.h:257
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:414
unsigned int m_cornerRadius
Definition: zone.h:848
void TransformSmoothedOutlineToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearance, SHAPE_POLY_SET *aBoardOutline) const
Function TransformSmoothedOutlineToPolygon Convert the outlines shape to a polygon with no holes infl...
Definition: zone.cpp:1290
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Function IterateWithHoles returns an iterator to visit all points of the zone's main outline with hol...
Definition: zone.h:550
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Definition: zone.h:645
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: zone.cpp:786
void SetZoneName(const wxString &aName)
Definition: zone.h:132
bool GetDoNotAllowFootprints() const
Definition: zone.h:760
PNG memory record (file in memory).
Definition: bitmap_def.h:29
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:765
void UnHatchBorder()
Function UnHatchBorder clears the zone's hatch.
Definition: zone.cpp:909
ZONE_FILL_MODE m_fillMode
How to fill areas: ZONE_FILL_MODE::POLYGONS => use solid polygons ZONE_FILL_MODE::HATCH_PATTERN => us...
Definition: zone.h:905
int GetHatchThickness() const
Definition: zone.h:256
int m_ZoneClearance
Definition: zone.h:876
unsigned GetPriority() const
Function GetPriority.
Definition: zone.h:124
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:755
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: zone.cpp:1090
SHAPE_POLY_SET::CONST_ITERATOR CIterateWithHoles() const
Function CIterateWithHoles returns an iterator to visit all points of the zone's main outline with ho...
Definition: zone.h:560
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
int m_cornerSmoothingType
Definition: zone.h:847
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:621
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetBorderDisplayStyle sets all hatch parameters for the zone.
Definition: zone.cpp:892
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: zone.h:846
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:886
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: zone.h:851
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:909
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:243
ZONE_CONNECTION m_PadConnection
Definition: zone.h:875
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
SHAPE_POLY_SET * Outline()
Definition: zone.h:323
bool GetDoNotAllowVias() const
Definition: zone.h:757
double m_area
Definition: zone.h:955
bool m_doNotAllowTracks
Definition: zone.h:871
~ZONE()
Definition: zone.cpp:98
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition: zone.h:886
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: zone.h:134
const SHAPE_POLY_SET * Outline() const
Definition: zone.h:324
double m_hatchOrientation
Definition: zone.h:908
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:288
double GetHatchSmoothingValue() const
Definition: zone.h:268
bool HitTestCutout(const wxPoint &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Definition: zone.h:361
bool CommonLayerExists(const LSET aLayerSet) const
Function CommonLayerExist Test if this zone shares a common layer with the given layer set.
Definition: zone.cpp:227
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:951
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
Function GetSmoothedPoly.
Definition: zone.cpp:1161
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:313
bool IsSame(const ZONE &aZoneToCompare)
Function IsSame tests if 2 zones are equivalent: 2 zones are equivalent if they have same parameters ...
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: zone.h:655
SHAPE_POLY_SET::ITERATOR Iterate()
Function Iterate returns an iterator to visit all points of the zone's main outline without holes.
Definition: zone.h:540
bool IsFilled() const
Definition: zone.h:237
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:826
The base class for create windows for drawing purpose.
MD5_HASH GetHashValue(PCB_LAYER_ID aLayer)
Definition: zone.cpp:379
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:543
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: zone.h:118
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 comaptible with FP_ZONE requirement.
Definition: zone.cpp:42
int m_hatchThickness
Definition: zone.h:906
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:185
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy=0) const
Function HitTestFilledArea tests if the given wxPoint is within the bounds of a filled area of this z...
Definition: zone.cpp:503
int GetFillVersion() const
Definition: zone.h:715
LSET m_layerSet
Definition: zone.h:853
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: zone.cpp:1096
virtual wxString GetNetClassName() const
Returns the netclass of the zone.
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:186
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
Function HitTestForCorner tests if the given wxPoint is near a corner.
Definition: zone.cpp:422
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
Definition: zone.cpp:729
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:870
void SetIsRuleArea(bool aEnable)
Definition: zone.h:762
EDA_RECT m_bboxCache
Temp variables used while filling.
Definition: zone.h:940
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:926
int GetThermalReliefGap() const
Definition: zone.h:195
void SetFillSegments(PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL &aSegments)
Definition: zone.h:735
int GetFillFlag(PCB_LAYER_ID aLayer)
Definition: zone.h:231
void Rotate(const wxPoint &aCentre, double aAngle) override
Function Rotate Move the outlines.
Definition: zone.cpp:703
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:1131
bool HitTestCutout(const VECTOR2I &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Tests if the given point is contained within a cutout of the zone.
Definition: zone.cpp:518
std::map< PCB_LAYER_ID, bool > m_fillFlags
Definition: zone.h:941
double GetHatchHoleMinArea() const
Definition: zone.h:271
int m_localFlgs
Definition: zone.h:921
void SetHatchSmoothingValue(double aValue)
Definition: zone.h:269
bool GetDoNotAllowPads() const
Definition: zone.h:759
void MoveEdge(const wxPoint &offset, int aEdge)
Function MoveEdge Move the outline Edge.
Definition: zone.cpp:688
PCB_LAYER_ID
A quick note on layer IDs:
bool GetDoNotAllowCopperPour() const
Definition: zone.h:756
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:294
LSET is a set of PCB_LAYER_IDs.
void NewHole()
Function NewHole creates a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:605
int GetLocalClearance() const
Definition: zone.h:160
int GetMinThickness() const
Definition: zone.h:247
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox (virtual)
Definition: zone.cpp:319
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:823
void SetHatchGap(int aStep)
Definition: zone.h:260
int GetHatchSmoothingLevel() const
Definition: zone.h:265
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
Definition: zone.cpp:1084
const EDA_RECT GetCachedBoundingBox() const
ONLY TO BE USED BY CLIENTS WHICH SET UP THE CACHE!
Definition: zone.h:148
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:766
void SetCornerPosition(int aCornerIndex, wxPoint new_pos)
Definition: zone.h:581
void HatchBorder()
Function HatchBorder computes the hatch lines depending on the hatch parameters and stores it in the ...
Definition: zone.cpp:923
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:1372
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if a point is near an outline edge or a corner of this zone.
Definition: zone.cpp:397
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:215
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition: zone.h:326
void SetSelectedCorner(int aCorner)
Definition: zone.h:288
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:704
int GetLocalFlags() const
Definition: zone.h:308
bool GetDoNotAllowTracks() const
Definition: zone.h:758
int m_thermalReliefGap
Definition: zone.h:897
bool m_hv45
Definition: zone.h:953
void InitDataFromSrcInCopyCtor(const ZONE &aZone)
Copy aZone data to me.
Definition: zone.cpp:105
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
Definition: zone.h:919
double GetFilledArea()
Get the area currently occupied by the zone fill.
Definition: zone.h:221
const ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer) const
Definition: zone.h:317
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition: zone.h:880
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:764
ZONE handles 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:248
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:620
void SetIsFilled(bool isFilled)
Definition: zone.h:238
void TransformSolidAreasShapesToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Function TransformSolidAreasShapesToPolygon Convert solid areas full shapes to polygon set (the full ...
void SetHatchHoleMinArea(double aPct)
Definition: zone.h:272
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:944
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:825
int m_ZoneMinThickness
Definition: zone.h:877
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: zone.h:958
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: zone.h:636
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
Definition: zone.h:670
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_RawPolysList
Definition: zone.h:937
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition: zone.cpp:388
bool m_isRuleArea
Definition: zone.h:864
bool GetGlobalIndex(VERTEX_INDEX aRelativeIndices, int &aGlobalIdx)
Compute the global index of a vertex from the relative indices of polygon, contour and vertex.
void Move(const wxPoint &offset) override
Function Move Move the outlines.
Definition: zone.cpp:667
int m_borderHatchPitch
Definition: zone.h:947
EDA_UNITS
Definition: eda_units.h:38
double GetHatchOrientation() const
Definition: zone.h:262
void SetHatchSmoothingLevel(int aLevel)
Definition: zone.h:266
unsigned int GetCornerRadius() const
Definition: zone.h:710
std::vector< SEG > m_borderHatchLines
Definition: zone.h:948
void SetLocalFlags(int aFlags)
Definition: zone.h:309
int GetHatchBorderAlgorithm() const
Definition: zone.h:274
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition: zone.h:692
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:769
void RemoveAllContours(void)
Definition: zone.h:565
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: zone.h:245
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:832
void SetMinIslandArea(long long int aArea)
Definition: zone.h:774
int m_hatchBorderAlgorithm
Definition: zone.h:915
void SetPosition(const wxPoint &aPos) override
Definition: zone.h:112
bool HitTestForEdge(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Function HitTestForEdge tests if the given wxPoint is near a segment defined by 2 corners.
Definition: zone.cpp:436
wxPoint GetPosition() const override
Definition: zone.cpp:209
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
Definition: zone.h:889
FP_ZONE & operator=(const FP_ZONE &aOther)
Definition: zone.cpp:1335
std::vector< SEG > ZONE_SEGMENT_FILL
Definition: zone.h:44
Board layer functions and definitions.
void SetHatchBorderAlgorithm(int aAlgo)
Definition: zone.h:275
void CacheBoundingBox()
Definition: zone.h:149
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:763
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Checks if a given filled polygon is an insulated island.
Definition: zone.cpp:1119
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)
Function SetHatchPitch sets the hatch pitch parameter for the zone.
Definition: zone.cpp:903
int m_hatchGap
Definition: zone.h:907
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: zone.h:570
Handle the component boundary box.
Definition: eda_rect.h:42
FP_ZONE(BOARD_ITEM_CONTAINER *aParent)
Definition: zone.cpp:1319
The main frame for Pcbnew.
void Mirror(const wxPoint &aMirrorRef, bool aMirrorLeftRight)
Function Mirror Mirror the outlines , relative to a given horizontal axis the layer is not changed.
Definition: zone.cpp:741
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: zone.cpp:221
void SetHatchOrientation(double aStep)
Definition: zone.h:263
bool m_doNotAllowCopperPour
Definition: zone.h:869
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
void SetFillFlag(PCB_LAYER_ID aLayer, bool aFlag)
Definition: zone.h:235
SHAPE_POLY_SET & RawPolysList(PCB_LAYER_ID aLayer)
Definition: zone.h:740
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:180
static bool ClassOf(const EDA_ITEM *aItem)
Definition: zone.h:75
int m_fillVersion
Definition: zone.h:878
void SetFillVersion(int aVersion)
Definition: zone.h:716
std::mutex & GetLock()
Definition: zone.h:226
int GetSelectedCorner() const
Definition: zone.h:277
void SetThermalReliefGap(int aThermalReliefGap)
Definition: zone.h:188
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:235
bool IsConnected() const override
Not all ZONEs are really BOARD_CONNECTED_ITEMs....
Definition: zone.h:83
long long int GetMinIslandArea() const
Definition: zone.h:773
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:241
double m_hatchHoleMinArea
Definition: zone.h:914
ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer)
Definition: zone.h:311
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
Definition: zone.cpp:1262
void SetLocalClearance(int aClearance)
Definition: zone.h:161
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition: zone.h:895
void AddPolygon(std::vector< wxPoint > &aPolygon)
add a polygon to the zone outline if the zone outline is empty, this is the main outline else it is a...
Definition: zone.cpp:815
int GetThermalReliefSpokeWidth() const
Definition: zone.h:205
Abstract interface for BOARD_ITEMs capable of storing other items inside.
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
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:88
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:852
void SetRawPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
Definition: zone.h:679
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the zone shape to a closed polygon Used in fill...
Definition: pad.h:60
bool UnFill()
Function UnFill Removes the zone filling.
Definition: zone.cpp:186
wxString GetZoneName() const
Definition: zone.h:131
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:1348
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: zone.h:936
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: zone.cpp:305
unsigned m_priority
Definition: zone.h:859
double m_hatchSmoothingValue
Definition: zone.h:913
ZONE_FILL_MODE
Definition: zone_settings.h:38
wxString GetClass() const override
Function GetClass returns the class name.
Definition: zone.h:523
int GetCornerSmoothingType() const
Definition: zone.h:706
FP_ZONE is a specialization of ZONE for use in footprints.
Definition: zone.h:965
int m_thermalReliefSpokeWidth
Definition: zone.h:898
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:767
bool GetFilledPolysUseThickness() const
Definition: zone.h:712
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:198
bool m_doNotAllowPads
Definition: zone.h:872
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: zone.cpp:1342