KiCad PCB EDA Suite
class_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-2019 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 
29 #ifndef CLASS_ZONE_H_
30 #define CLASS_ZONE_H_
31 
32 
33 #include <mutex>
34 #include <vector>
35 #include <gr_basic.h>
36 #include <class_board_item.h>
37 #include <board_connected_item.h>
40 #include <zone_settings.h>
41 
42 
43 class EDA_RECT;
44 class LINE_READER;
45 class PCB_EDIT_FRAME;
46 class BOARD;
47 class ZONE_CONTAINER;
49 
50 typedef std::vector<SEG> ZONE_SEGMENT_FILL;
51 
62 {
63 public:
64 
73  ZONE_CONTAINER( BOARD_ITEM_CONTAINER* parent, bool aInModule = false );
74 
75  ZONE_CONTAINER( const ZONE_CONTAINER& aZone );
76  ZONE_CONTAINER& operator=( const ZONE_CONTAINER &aOther );
77 
79 
80  static inline bool ClassOf( const EDA_ITEM* aItem )
81  {
82  return aItem && aItem->Type() == PCB_ZONE_AREA_T;
83  }
84 
88  const wxPoint GetPosition() const override;
89  void SetPosition( const wxPoint& aPos ) override {}
90 
95  void SetPriority( unsigned aPriority ) { m_priority = aPriority; }
96 
101  unsigned GetPriority() const { return m_priority; }
102 
103  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
104 
105  void SetLayerSet( LSET aLayerSet );
106 
107  virtual LSET GetLayerSet() const override;
108 
109  wxString GetZoneName() const { return m_zoneName; }
110 
111  void SetZoneName( const wxString& aName ) { m_zoneName = aName; }
112 
116  const EDA_RECT GetBoundingBox() const override;
117 
125  int GetLocalClearance( wxString* aSource = nullptr ) const override;
126 
131  bool IsOnCopperLayer() const override;
132 
137  bool CommonLayerExists( const LSET aLayerSet ) const;
138 
139  virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
140 
141  virtual PCB_LAYER_ID GetLayer() const override;
142 
143  virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
144 
145  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
146 
147  void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_FillMode = aFillMode; }
149 
150  void SetThermalReliefGap( int aThermalReliefGap ) { m_ThermalReliefGap = aThermalReliefGap; }
151  int GetThermalReliefGap( D_PAD* aPad = NULL ) const;
152 
153  void SetThermalReliefCopperBridge( int aThermalReliefCopperBridge )
154  {
155  if( m_ThermalReliefCopperBridge != aThermalReliefCopperBridge )
156  SetNeedRefill( true );
157 
158  m_ThermalReliefCopperBridge = aThermalReliefCopperBridge;
159  }
160  int GetThermalReliefCopperBridge( D_PAD* aPad = NULL ) const;
161 
167  double CalculateFilledArea();
168 
175  double GetFilledArea()
176  {
177  return m_area;
178  }
179 
180  std::mutex& GetLock()
181  {
182  return m_lock;
183  }
184 
185  bool IsFilled() const { return m_IsFilled; }
186  void SetIsFilled( bool isFilled ) { m_IsFilled = isFilled; }
187 
188  bool NeedRefill() const { return m_needRefill; }
189  void SetNeedRefill( bool aNeedRefill ) { m_needRefill = aNeedRefill; }
190 
191  int GetZoneClearance() const { return m_ZoneClearance; }
192  void SetZoneClearance( int aZoneClearance ) { m_ZoneClearance = aZoneClearance; }
193 
194  ZONE_CONNECTION GetPadConnection( D_PAD* aPad = NULL ) const;
195 
196  void SetPadConnection( ZONE_CONNECTION aPadConnection )
197  {
198  m_PadConnection = aPadConnection;
199  }
200 
201  int GetMinThickness() const { return m_ZoneMinThickness; }
202  void SetMinThickness( int aMinThickness )
203  {
204  if( m_ZoneMinThickness != aMinThickness )
205  SetNeedRefill( true );
206 
207  m_ZoneMinThickness = aMinThickness;
208  }
209 
211  void SetHatchFillTypeThickness( int aThickness ) { m_HatchFillTypeThickness = aThickness; }
212 
213  int GetHatchFillTypeGap() const { return m_HatchFillTypeGap; }
214  void SetHatchFillTypeGap( int aStep ) { m_HatchFillTypeGap = aStep; }
215 
217  void SetHatchFillTypeOrientation( double aStep ) { m_HatchFillTypeOrientation = aStep; }
218 
221 
224 
225  int GetSelectedCorner() const
226  {
227  // Transform relative indices to global index
228  int globalIndex = -1;
229 
230  if( m_CornerSelection )
231  m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
232 
233  return globalIndex;
234  }
235 
236  void SetSelectedCorner( int aCorner )
237  {
238  SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
239 
240  // If the global index of the corner is correct, assign it to m_CornerSelection
241  if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
242  {
243  if( m_CornerSelection == nullptr )
245 
246  *m_CornerSelection = selectedCorner;
247  }
248  else
249  throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
250  }
251 
253  // Like HitTest but selects the current corner to be operated on
254  void SetSelectedCorner( const wxPoint& aPosition, int aAccuracy );
255 
256  int GetLocalFlags() const { return m_localFlgs; }
257  void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
258 
260  {
261  wxASSERT( m_FillSegmList.count( aLayer ) );
262  return m_FillSegmList.at( aLayer );
263  }
264 
266  {
267  wxASSERT( m_FillSegmList.count( aLayer ) );
268  return m_FillSegmList.at( aLayer );
269  }
270 
272  const SHAPE_POLY_SET* Outline() const { return const_cast< SHAPE_POLY_SET* >( m_Poly ); }
273 
274  void SetOutline( SHAPE_POLY_SET* aOutline ) { m_Poly = aOutline; }
275 
282  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
283 
291  bool HitTestFilledArea( PCB_LAYER_ID aLayer, const wxPoint& aRefPos ) const;
292 
301  bool HitTestCutout( const VECTOR2I& aRefPos, int* aOutlineIdx = nullptr,
302  int* aHoleIdx = nullptr ) const;
303 
304  bool HitTestCutout( const wxPoint& aRefPos, int* aOutlineIdx = nullptr,
305  int* aHoleIdx = nullptr ) const
306  {
307  return HitTestCutout( VECTOR2I( aRefPos.x, aRefPos.y ), aOutlineIdx, aHoleIdx );
308  }
309 
310 
316  void GetColinearCorners( BOARD* aBoard, std::set<VECTOR2I>& colinearCorners );
317 
329  SHAPE_POLY_SET& aCornerBuffer, int aError = ARC_HIGH_DEF ) const;
330 
347  int aMinClearanceValue, std::set<VECTOR2I>* aPreserveCorners = nullptr ) const;
348 
362  int aClearanceValue, int aError = ARC_HIGH_DEF,
363  bool ignoreLineWidth = false ) const override;
364 
375  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy,
376  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
377 
386  bool HitTestForCorner( const wxPoint& refPos, int aAccuracy ) const;
387 
397  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy,
398  SHAPE_POLY_SET::VERTEX_INDEX& aCornerHit ) const;
399 
407  bool HitTestForEdge( const wxPoint& refPos, int aAccuracy ) const;
408 
412  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
413 
414 
421  bool UnFill();
422 
423  /* Geometric transformations: */
424 
430  void Move( const wxPoint& offset ) override;
431 
438  void MoveEdge( const wxPoint& offset, int aEdge );
439 
446  void Rotate( const wxPoint& centre, double angle ) override;
447 
454  virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
455 
463  void Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight );
464 
470  wxString GetClass() const override
471  {
472  return wxT( "ZONE_CONTAINER" );
473  }
474 
477  int GetNumCorners( void ) const
478  {
479  return m_Poly->TotalVertices();
480  }
481 
488  {
489  return m_Poly->Iterate();
490  }
491 
498  {
499  return m_Poly->IterateWithHoles();
500  }
501 
508  {
509  return m_Poly->CIterateWithHoles();
510  }
511 
512  void RemoveAllContours( void )
513  {
515  }
516 
517  const VECTOR2I& GetCornerPosition( int aCornerIndex ) const
518  {
520 
521  // Convert global to relative indices
522  if( !m_Poly->GetRelativeIndices( aCornerIndex, &index ) )
523  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
524 
525  return m_Poly->CVertex( index );
526  }
527 
528  void SetCornerPosition( int aCornerIndex, wxPoint new_pos )
529  {
530  SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
531 
532  // Convert global to relative indices
533  if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
534  {
535  if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
536  || m_Poly->CVertex( relativeIndices ).y != new_pos.y )
537  {
538  SetNeedRefill( true );
539  m_Poly->SetVertex( relativeIndices, new_pos );
540  }
541  }
542  else
543  throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
544  }
545 
550  void NewHole()
551  {
552  m_Poly->NewHole();
553  }
554 
563  bool AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowDuplication = false );
564 
566  {
567  return m_hatchStyle;
568  }
569 
571  {
572  m_hatchStyle = aStyle;
573  }
574 
582  bool IsSame( const ZONE_CONTAINER &aZoneToCompare );
583 
589  {
590  for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
591  {
592  m_insulatedIslands[pair.first].clear();
593  pair.second.RemoveAllContours();
594  }
595  }
596 
603  {
604  wxASSERT( m_FilledPolysList.count( aLayer ) );
605  return m_FilledPolysList.at( aLayer );
606  }
607 
611  void CacheTriangulation();
612 
617  void SetFilledPolysList( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aPolysList )
618  {
619  m_FilledPolysList[aLayer] = aPolysList;
620  }
621 
626  void SetRawPolysList( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aPolysList )
627  {
628  m_RawPolysList[aLayer] = aPolysList;
629  }
630 
637  bool IsIsland( PCB_LAYER_ID aLayer, int aPolyIdx );
638 
639  void SetIsIsland( PCB_LAYER_ID aLayer, int aPolyIdx )
640  {
641  m_insulatedIslands[aLayer].insert( aPolyIdx );
642  }
643 
650  bool BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly,
651  std::set<VECTOR2I>* aPreserveCorners ) const;
652 
653  void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
654 
656 
657  void SetCornerRadius( unsigned int aRadius );
658 
659  unsigned int GetCornerRadius() const { return m_cornerRadius; }
660 
662  void SetFilledPolysUseThickness( bool aOption ) { m_FilledPolysUseThickness = aOption; }
663 
664 
671  void RemoveCutout( int aOutlineIdx, int aHoleIdx );
672 
678  void AddPolygon( std::vector< wxPoint >& aPolygon );
679 
680  void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
681 
682  void SetFillSegments( PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL& aSegments )
683  {
684  m_FillSegmList[aLayer] = aSegments;
685  }
686 
688  {
689  wxASSERT( m_RawPolysList.count( aLayer ) );
690  return m_RawPolysList.at( aLayer );
691  }
692 
693  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
694 
695  BITMAP_DEF GetMenuImage() const override;
696 
697  EDA_ITEM* Clone() const override;
698 
702  bool GetIsKeepout() const { return m_isKeepout; }
704  bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
705  bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
706  bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
708 
716  int GetKeepouts( std::map<int, wxString>* aSources = nullptr ) const;
717 
718  void SetIsKeepout( bool aEnable ) { m_isKeepout = aEnable; }
719  void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
720  void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
721  void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
722  void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
723  void SetDoNotAllowFootprints( bool aEnable ) { m_doNotAllowFootprints = aEnable; }
724 
727  m_islandRemovalMode = aRemove; }
728 
729  long long int GetMinIslandArea() const { return m_minIslandArea; }
730  void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
731 
740  int GetHatchPitch() const;
741 
746  static int GetDefaultHatchPitch();
747 
757  void SetHatch( ZONE_HATCH_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch );
758 
764  void SetHatchPitch( int aPitch );
765 
770  void UnHatch();
771 
777  void Hatch();
778 
779  const std::vector<SEG>& GetHatchLines() const { return m_HatchLines; }
780 
781  bool GetHV45() const { return m_hv45; }
782  void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
783 
788  {
789  if( !m_filledPolysHash.count( aLayer ) )
790  return MD5_HASH();
791 
792  return m_filledPolysHash.at( aLayer );
793  }
794 
800  {
801  if( !m_FilledPolysList.count( aLayer ) )
802  return;
803 
804  m_filledPolysHash[aLayer] = m_FilledPolysList.at( aLayer ).GetHash();
805  }
806 
807 
808 
809 #if defined(DEBUG)
810  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
811 #endif
812 
813  virtual void SwapData( BOARD_ITEM* aImage ) override;
814 
815 protected:
820  void initDataFromSrcInCopyCtor( const ZONE_CONTAINER& aZone );
821 
824  unsigned int m_cornerRadius;
825 
827  wxString m_zoneName;
828 
830 
831  /* Priority: when a zone outline is inside and other zone, if its priority is higher
832  * the other zone priority, it will be created inside.
833  * if priorities are equal, a DRC error is set
834  */
835  unsigned m_priority;
836 
837  /* A zone outline can be a keepout zone.
838  * It will be never filled, and DRC should test for pads, tracks and vias
839  */
841 
842  /* For keepout zones only:
843  * what is not allowed inside the keepout ( pads, tracks and vias )
844  */
850 
855 
857 
862  long long int m_minIslandArea;
863 
866 
872 
875 
878 
879 
885 
888 
891 
894 
898 
902 
905 
908 
912  std::map<PCB_LAYER_ID, ZONE_SEGMENT_FILL> m_FillSegmList;
913 
914  /* set of filled polygons used to draw a zone as a filled area.
915  * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
916  * (they are all in one piece) In very simple cases m_FilledPolysList is same
917  * as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
918  * a polygon equivalent to m_Poly, without holes but with extra outline segment
919  * connecting "holes" with external main outline. In complex cases an outline
920  * described by m_Poly can have many filled areas
921  */
922  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_FilledPolysList;
923  std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_RawPolysList;
924 
926  std::map<PCB_LAYER_ID, MD5_HASH> m_filledPolysHash;
927 
928  ZONE_HATCH_STYLE m_hatchStyle; // hatch style, see enum above
929  int m_hatchPitch; // for DIAGONAL_EDGE, distance between 2 hatch lines
930  std::vector<SEG> m_HatchLines; // hatch lines
931 
933  std::map<PCB_LAYER_ID, std::set<int>> m_insulatedIslands;
934 
935  bool m_hv45; // constrain edges to horizontal, vertical or 45ยบ
936 
937  double m_area; // The filled zone area
938 
940  std::mutex m_lock;
941 };
942 
943 
953 {
954 public:
958 
959  EDA_ITEM* Clone() const override;
960 
961  unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
962 };
963 
964 #endif // CLASS_ZONE_H_
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:721
int TotalVertices() const
Returns total number of vertices stored in the set.
void MoveEdge(const wxPoint &offset, int aEdge)
Function MoveEdge Move the outline Edge.
Definition: class_zone.cpp:755
EDA_UNITS
Definition: common.h:198
int NewHole(int aOutline=-1)
Creates a new hole in a given outline
void SetCornerSmoothingType(int aType)
Definition: class_zone.h:653
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
void SetHatchPitch(int aPitch)
Function SetHatchPitch sets the hatch pitch parameter for the zone.
Definition: class_zone.cpp:961
bool GetDoNotAllowPads() const
Definition: class_zone.h:706
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
void SetHatch(ZONE_HATCH_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
Definition: class_zone.cpp:951
bool IsFilled() const
Definition: class_zone.h:185
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
std::vector< SEG > ZONE_SEGMENT_FILL
Definition: class_zone.h:48
LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to re...
Definition: richio.h:81
int m_ZoneClearance
Clearance value in internal units.
Definition: class_zone.h:852
void Mirror(const wxPoint &aMirrorRef, bool aMirrorLeftRight)
Function Mirror Mirror the outlines , relative to a given horizontal axis the layer is not changed.
Definition: class_zone.cpp:810
void SetHatchFillTypeSmoothingLevel(int aLevel)
Definition: class_zone.h:220
void SetHatchFillTypeSmoothingValue(double aValue)
Definition: class_zone.h:223
ISLAND_REMOVAL_MODE m_islandRemovalMode
Definition: class_zone.h:856
PNG memory record (file in memory).
Definition: bitmap_def.h:29
bool m_doNotAllowPads
Definition: class_zone.h:848
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: class_zone.h:196
bool CommonLayerExists(const LSET aLayerSet) const
Function CommonLayerExist Test if this zone shares a common layer with the given layer set.
Definition: class_zone.cpp:248
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const wxPoint &aRefPos) const
Function HitTestFilledArea tests if the given wxPoint is within the bounds of a filled area of this z...
Definition: class_zone.cpp:559
int GetThermalReliefCopperBridge(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:354
void SetFilledPolysUseThickness(bool aOption)
Definition: class_zone.h:662
void SetRawPolysList(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
Definition: class_zone.h:626
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_zone.cpp:202
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
bool m_doNotAllowTracks
Definition: class_zone.h:847
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox (virtual)
Definition: class_zone.cpp:335
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
Definition: class_zone.h:726
void SetCornerRadius(unsigned int aRadius)
Definition: class_zone.cpp:439
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
int GetHatchFillTypeThickness() const
Definition: class_zone.h:210
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
Definition: class_zone.h:904
int GetSelectedCorner() const
Definition: class_zone.h:225
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
void SetIsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Definition: class_zone.h:639
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:329
void SetDoNotAllowFootprints(bool aEnable)
Definition: class_zone.h:723
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: class_zone.cpp:473
void SetMinIslandArea(long long int aArea)
Definition: class_zone.h:730
std::mutex m_lock
Lock used for multi-threaded filling on multi-layer zones.
Definition: class_zone.h:940
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
ZONE_CONTAINER(BOARD_ITEM_CONTAINER *parent, bool aInModule=false)
The ctor to build ZONE_CONTAINER, but comaptible with MODULE_ZONE_CONTAINER requirement.
Definition: class_zone.cpp:39
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:236
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:271
CONST_ITERATOR CIterateWithHoles(int aOutline) const
SHAPE_POLY_SET & RawPolysList(PCB_LAYER_ID aLayer)
Definition: class_zone.h:687
void SetZoneName(const wxString &aName)
Definition: class_zone.h:111
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:661
double GetHatchFillTypeOrientation() const
Definition: class_zone.h:216
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:602
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
Definition: class_zone.h:862
Struct VERTEX_INDEX.
void SetHatchStyle(ZONE_HATCH_STYLE aStyle)
Definition: class_zone.h:570
double GetHatchFillTypeSmoothingValue() const
Definition: class_zone.h:222
MODULE_ZONE_CONTAINER(BOARD_ITEM_CONTAINER *aParent)
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
Definition: class_zone.cpp:848
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
std::map< PCB_LAYER_ID, std::set< int > > m_insulatedIslands
For each layer, a set of insulated islands that were not removed.
Definition: class_zone.h:933
int GetThermalReliefGap(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:345
The base class for create windows for drawing purpose.
std::mutex & GetLock()
Definition: class_zone.h:180
int m_localFlgs
Variable used in polygon calculations.
Definition: class_zone.h:907
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
static bool ClassOf(const EDA_ITEM *aItem)
Definition: class_zone.h:80
void SetIsFilled(bool isFilled)
Definition: class_zone.h:186
MD5_HASH GetHashValue(PCB_LAYER_ID aLayer)
Definition: class_zone.h:787
const wxPoint GetPosition() const override
Definition: class_zone.cpp:230
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition: class_zone.h:274
void TransformSolidAreasShapesToPolygonSet(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Function TransformSolidAreasShapesToPolygonSet Convert solid areas full shapes to polygon set (the fu...
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
struct SHAPE_POLY_SET::VERTEX_INDEX VERTEX_INDEX
Struct VERTEX_INDEX.
bool m_doNotAllowFootprints
Definition: class_zone.h:849
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:720
bool GetDoNotAllowVias() const
Definition: class_zone.h:704
long long int GetMinIslandArea() const
Definition: class_zone.h:729
ZONE_CONNECTION m_PadConnection
Definition: class_zone.h:851
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:95
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:312
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Function SetVertex Accessor function to set the position of a specific point.
void SetLayerSet(LSET aLayerSet)
Definition: class_zone.cpp:264
bool HitTestCutout(const wxPoint &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Definition: class_zone.h:304
wxString GetZoneName() const
Definition: class_zone.h:109
void GetColinearCorners(BOARD *aBoard, std::set< VECTOR2I > &colinearCorners)
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
SHAPE_POLY_SET::ITERATOR Iterate()
Function Iterate returns an iterator to visit all points of the zone's main outline without holes.
Definition: class_zone.h:487
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: class_zone.h:507
int m_HatchFillTypeSmoothingLevel
Grid pattern smoothing type, similar to corner smoothing type 0 = no smoothing, 1 = fillet,...
Definition: class_zone.h:897
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
Definition: class_zone.h:827
PCB_LAYER_ID
A quick note on layer IDs:
void SetHatchFillTypeGap(int aStep)
Definition: class_zone.h:214
LSET is a set of PCB_LAYER_IDs.
int m_ThermalReliefCopperBridge
Definition: class_zone.h:877
unsigned int GetCornerRadius() const
Definition: class_zone.h:659
std::vector< SEG > m_HatchLines
Definition: class_zone.h:930
#define NULL
ZONE_CONTAINER & operator=(const ZONE_CONTAINER &aOther)
Definition: class_zone.cpp:81
unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
bool IsSame(const ZONE_CONTAINER &aZoneToCompare)
Function IsSame tests if 2 zones are equivalent: 2 zones are equivalent if they have same parameters ...
ITERATOR IterateWithHoles(int aOutline)
Function IterateWithHoles.
SHAPE_POLY_SET.
void NewHole()
Function NewHole creates a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: class_zone.h:550
double m_HatchFillTypeOrientation
Grid style shape: orientation in degrees of the grid lines.
Definition: class_zone.h:893
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, std::set< VECTOR2I > *aPreserveCorners) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly.
ZONE_FILL_MODE GetFillMode() const
Definition: class_zone.h:148
bool m_IsFilled
True when a zone was filled, false after deleting the filled areas.
Definition: class_zone.h:865
ZONE_HATCH_STYLE m_hatchStyle
Definition: class_zone.h:928
SHAPE_POLY_SET * m_Poly
Outline of the zone.
Definition: class_zone.h:822
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: class_zone.cpp:448
bool GetDoNotAllowCopperPour() const
Definition: class_zone.h:703
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: class_zone.h:725
unsigned m_priority
Definition: class_zone.h:835
void Rotate(const wxPoint &centre, double angle) override
Function Rotate Move the outlines.
Definition: class_zone.cpp:770
bool m_doNotAllowVias
Definition: class_zone.h:846
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:256
bool UnFill()
Function UnFill Removes the zone filling.
Definition: class_zone.cpp:208
int m_cornerSmoothingType
Definition: class_zone.h:823
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_RawPolysList
Definition: class_zone.h:923
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: class_zone.h:477
void CacheTriangulation()
(re)create a list of triangles that "fill" the solid areas.
void TransformOutlinesShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aMinClearanceValue, std::set< VECTOR2I > *aPreserveCorners=nullptr) const
Function TransformOutlinesShapeWithClearanceToPolygon Convert the outlines shape to a polygon with no...
double m_HatchFillTypeSmoothingValue
Grid pattern smoothing value for smoothing shape size calculations this is the ratio between the gap ...
Definition: class_zone.h:901
int GetLocalClearance(wxString *aSource=nullptr) const override
Function GetLocalClearance returns any local clearances set in the "classic" (ie: pre-rule) system.
Definition: class_zone.cpp:547
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
Definition: class_zone.h:799
void SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:192
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: class_zone.cpp:318
ZONE_CONNECTION GetPadConnection(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:839
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: class_zone.h:926
void SetDoNotAllowPads(bool aEnable)
Definition: class_zone.h:722
bool GetRelativeIndices(int aGlobalIdx, VERTEX_INDEX *aRelativeIndices) const
Function GetRelativeIndices.
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:779
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
ZONE_HATCH_STYLE GetHatchStyle() const
Definition: class_zone.h:565
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: class_zone.cpp:877
int GetCornerSmoothingType() const
Definition: class_zone.h:655
void SetSelectedCorner(int aCorner)
Definition: class_zone.h:236
void SetFillSegments(PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL &aSegments)
Definition: class_zone.h:682
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:702
unsigned int m_cornerRadius
Definition: class_zone.h:824
bool GetHV45() const
Definition: class_zone.h:781
void SetThermalReliefCopperBridge(int aThermalReliefCopperBridge)
Definition: class_zone.h:153
bool NeedRefill() const
Definition: class_zone.h:188
void Move(const wxPoint &offset) override
Function Move Move the outlines.
Definition: class_zone.cpp:734
bool GetGlobalIndex(VERTEX_INDEX aRelativeIndices, int &aGlobalIdx)
Function GetGlobalIndex computes the global index of a vertex from the relative indices of polygon,...
int GetKeepouts(std::map< int, wxString > *aSources=nullptr) const
Return a bitset of flags for keepouts.
Definition: class_zone.cpp:363
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_zone.cpp:914
void SetFilledPolysList(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
Definition: class_zone.h:617
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:719
bool m_doNotAllowCopperPour
Definition: class_zone.h:845
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: class_zone.h:912
wxString GetClass() const override
Function GetClass returns the class name.
Definition: class_zone.h:470
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
int m_ThermalReliefGap
Width of the copper bridge in thermal reliefs.
Definition: class_zone.h:874
int m_ZoneMinThickness
Minimum thickness value in filled areas.
Definition: class_zone.h:853
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: class_zone.h:147
ZONE_FILL_MODE m_FillMode
How to fill areas: ZONE_FILL_MODE::POLYGONS => use solid polygons ZONE_FILL_MODE::HATCH_PATTERN => us...
Definition: class_zone.h:884
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:101
void SetCornerPosition(int aCornerIndex, wxPoint new_pos)
Definition: class_zone.h:528
Board layer functions and definitions.
MODULE_ZONE_CONTAINER & operator=(const MODULE_ZONE_CONTAINER &aOther)
void UnHatch()
Function UnHatch clears the zone's hatch.
Definition: class_zone.cpp:967
ZONE_HATCH_STYLE
Zone hatch styles.
Definition: zone_settings.h:46
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
SHAPE_LINE_CHAIN.
int m_HatchFillTypeThickness
Grid style shape: thickness of lines (if 0 -> solid shape)
Definition: class_zone.h:887
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:54
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Function IterateWithHoles returns an iterator to visit all points of the zone's main outline with hol...
Definition: class_zone.h:497
void initDataFromSrcInCopyCtor(const ZONE_CONTAINER &aZone)
Copy aZone data to me members are expected non initialize in this.
Definition: class_zone.cpp:132
void SetHatchFillTypeOrientation(double aStep)
Definition: class_zone.h:217
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: class_zone.cpp:573
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
void SetHV45(bool aConstrain)
Definition: class_zone.h:782
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
PCB_EDIT_FRAME is the main frame for Pcbnew.
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone's...
Definition: class_zone.cpp:981
int GetHatchPitch() const
Hatch related methods.
Definition: class_zone.cpp:945
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void SetLocalFlags(int aFlags)
Definition: class_zone.h:257
MODULE_ZONE_CONTAINER is the same item as ZONE_CONTAINER, but with a specific type id ZONE_CONTAINER ...
Definition: class_zone.h:952
int GetMinThickness() const
Definition: class_zone.h:201
bool GetDoNotAllowTracks() const
Definition: class_zone.h:705
const ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer) const
Definition: class_zone.h:265
void SetHatchFillTypeThickness(int aThickness)
Definition: class_zone.h:211
bool GetDoNotAllowFootprints() const
Definition: class_zone.h:707
void SetPosition(const wxPoint &aPos) override
Definition: class_zone.h:89
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: class_zone.cpp:894
int GetHatchFillTypeSmoothingLevel() const
Definition: class_zone.h:219
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: class_zone.cpp:487
double GetFilledArea()
Get the area currently occupied by the zone fill.
Definition: class_zone.h:175
ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer)
Definition: class_zone.h:259
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
Definition: class_zone.h:871
const SHAPE_POLY_SET * Outline() const
Definition: class_zone.h:272
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: class_zone.cpp:598
Abstract interface for BOARD_ITEMs capable of storing other items inside.
int GetZoneClearance() const
Definition: class_zone.h:191
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
int m_HatchFillTypeGap
Grid style shape: dist between center of lines (grid size) (0 -> solid shape)
Definition: class_zone.h:890
VIEW.
Definition: view.h:61
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:718
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
void SetMinThickness(int aMinThickness)
Definition: class_zone.h:202
int GetHatchFillTypeGap() const
Definition: class_zone.h:213
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: class_zone.h:517
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
Definition: class_zone.cpp:798
ZONE_FILL_MODE
Definition: zone_settings.h:38
void SetThermalReliefGap(int aThermalReliefGap)
Definition: class_zone.h:150
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Checks if a given filled polygon is an insulated island.
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: class_zone.cpp:242
int GetLocalFlags() const
Definition: class_zone.h:256
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the zone shape to a closed polygon Used in fill...
bool m_FilledPolysUseThickness
outline of filled polygons have thickness.
Definition: class_zone.h:854
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:588
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
void RemoveAllContours(void)
Definition: class_zone.h:512
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: class_zone.h:922
void SetNeedRefill(bool aNeedRefill)
Definition: class_zone.h:189