45#include <magic_enum.hpp>
47#include <google/protobuf/any.pb.h>
51#include <api/board/board_types.pb.h>
116 *
this = *
static_cast<const ZONE*
>( aOther );
125 board->IncrementTimeStamp();
218 return new ZONE( *
this );
236 zone.mutable_id()->set_value(
m_Uuid.AsStdString() );
240 zone.set_type( types::ZT_RULE_AREA );
242 zone.set_type( types::ZT_TEARDROP );
244 zone.set_type( types::ZT_COPPER );
246 zone.set_type( types::ZT_GRAPHICAL );
256 types::RuleAreaSettings* ra = zone.mutable_rule_area_settings();
270 types::CopperZoneSettings* cu = zone.mutable_copper_settings();
271 cu->mutable_connection()->set_zone_connection(
274 types::ThermalSpokeSettings* thermals = cu->mutable_connection()->mutable_thermal_spokes();
286 types::HatchFillSettings* hatch = cu->mutable_hatch_settings();
288 hatch->mutable_gap()->set_value_nm(
m_hatchGap );
296 case 0: hatch->set_border_mode( types::ZHFBM_USE_MIN_ZONE_THICKNESS );
break;
297 case 1: hatch->set_border_mode( types::ZHFBM_USE_HATCH_THICKNESS );
break;
301 cu->mutable_teardrop()->set_type(
307 types::ZoneFilledPolygons* filledLayer = zone.add_filled_polygons();
314 types::ZoneLayerProperties* layerProperties = zone.add_layer_properties();
317 if( properties.hatching_offset.has_value() )
319 PackVector2( *layerProperties->mutable_hatching_offset(),
320 properties.hatching_offset.value() );
324 zone.mutable_border()->set_style(
328 aContainer.PackFrom( zone );
338 if( !aContainer.UnpackTo( &zone ) )
346 if( zone.type() == types::ZoneType::ZT_RULE_AREA )
354 if(
m_Poly->OutlineCount() == 0 )
359 const types::RuleAreaSettings& ra = zone.rule_area_settings();
372 const types::CopperZoneSettings& cu = zone.copper_settings();
383 m_hatchGap = cu.hatch_settings().gap().value_nm();
388 switch( cu.hatch_settings().border_mode() )
398 for(
const auto& properties : zone.layer_properties() )
404 if( properties.has_hatching_offset() )
405 layerProperties.
hatching_offset = UnpackVector2( properties.hatching_offset() );
420 for(
const types::ZoneFilledPolygons& fillLayer : zone.filled_polygons() )
460 change |= !pair.second->IsEmpty();
462 pair.second->RemoveAllContours();
502 if( uiLayers.size() )
525 if( aLayerSet.count() == 0 )
547 [&](
const auto& item )
549 return !aLayerSet.
Contains( item.first );
565 std::vector<int> layers;
571 layers.push_back( layer );
592 bool flipped = parentFP->GetLayer() ==
B_Cu;
617 std::unordered_map<const ZONE*, BOX2I>& cache =
board->m_ZoneBBoxCache;
620 std::shared_lock<std::shared_mutex> readLock(
board->m_CachesMutex );
622 auto cacheIter = cache.find(
this );
624 if( cacheIter != cache.end() )
625 return cacheIter->second;
631 std::unique_lock<std::shared_mutex> writeLock(
board->m_CachesMutex );
632 cache[ this ] = bbox;
655 *aSource =
_(
"zone" );
708 return m_Poly->CollideVertex(
VECTOR2I( refPos ), aCornerHit, aAccuracy );
715 return m_Poly->CollideEdge(
VECTOR2I( refPos ), aCornerHit, aAccuracy );
739 int count =
m_Poly->TotalVertices();
741 for(
int ii = 0; ii < count; ii++ )
764 auto outlineIntersectingSelection =
767 for(
auto segment =
m_Poly->IterateSegments(); segment; segment++ )
778 auto vertexInsideSelection =
784 return vertexInsideSelection() && !outlineIntersectingSelection();
790 for(
auto segment =
m_Poly->IterateSegmentsWithHoles(); segment; segment++ )
817 return m_Poly->Contains( aRefPos, -1, aAccuracy );
830 for(
int i = 0; i <
m_Poly->OutlineCount(); i++ )
832 for(
int j = 0; j <
m_Poly->HoleCount( i ); j++ )
834 if(
m_Poly->Hole( i, j ).PointInside( aRefPos ) )
855 aList.emplace_back(
_(
"Type" ), msg );
877 aList.emplace_back(
_(
"Restrictions" ), msg );
888 aList.emplace_back(
_(
"Resolved Netclass" ),
899 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
905 if( layers.size() == 1 )
909 else if (layers.size() == 2 )
911 layerDesc.Printf(
_(
"%s and %s" ),
915 else if (layers.size() == 3 )
917 layerDesc.Printf(
_(
"%s, %s and %s" ),
922 else if( layers.size() > 3 )
924 layerDesc.Printf(
_(
"%s, %s and %d more" ),
927 static_cast<int>( layers.size() - 2 ) );
930 aList.emplace_back(
_(
"Layer" ), layerDesc );
939 default: msg =
_(
"Unknown" );
break;
942 aList.emplace_back(
_(
"Fill Mode" ), msg );
944 aList.emplace_back(
_(
"Filled Area" ),
950 if( !source.IsEmpty() )
953 wxString::Format(
_(
"(from %s)" ), source ) );
961 count += ii.second->TotalVertices();
963 aList.emplace_back(
_(
"Corner Count" ), wxString::Format( wxT(
"%d" ), count ) );
977 pair.second->Move( offset );
989 if( it !=
GetBoard()->m_ZoneBBoxCache.end() )
990 it->second.Move( offset );
998 return _(
"Rule Area" );
1000 return _(
"Teardrop Area" );
1002 return _(
"Copper Zone" );
1004 return _(
"Non-copper Zone" );
1012 if(
m_Poly->GetNeighbourIndexes( aEdge,
nullptr, &next_corner ) )
1025 m_Poly->Rotate( aAngle, aCentre );
1030 pair.second->Rotate( aAngle, aCentre );
1036 Mirror( aCentre, aFlipDirection );
1038 std::map<PCB_LAYER_ID, SHAPE_POLY_SET> fillsCopy;
1041 fillsCopy[oldLayer] = *shapePtr;
1043 std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> layerPropertiesCopy =
m_layerProperties;
1052 for(
auto& [oldLayer, properties] : layerPropertiesCopy )
1058 for(
auto& [oldLayer, shape] : fillsCopy )
1068 m_Poly->Mirror( aMirrorRef, aFlipDirection );
1073 pair.second->Mirror( aMirrorRef, aFlipDirection );
1080 if(
m_Poly->OutlineCount() < aOutlineIdx ||
m_Poly->HoleCount( aOutlineIdx ) < aHoleIdx )
1086 m_Poly->BooleanAdd( cutPoly );
1097 if(
m_Poly->OutlineCount() == 0 )
1098 m_Poly->AddOutline( aPolygon );
1100 m_Poly->AddHole( aPolygon );
1108 if( aPolygon.empty() )
1114 for(
const VECTOR2I& pt : aPolygon )
1126 if(
m_Poly->OutlineCount() == 0 )
1132 if( aHoleIdx >=
m_Poly->HoleCount( 0 ) )
1135 m_Poly->Append( aPosition.
x, aPosition.
y, -1, aHoleIdx, aAllowDuplication );
1148 if( layers.size() == 1 )
1152 else if (layers.size() == 2 )
1154 layerDesc.Printf(
_(
"on %s and %s" ),
1158 else if (layers.size() == 3 )
1160 layerDesc.Printf(
_(
"on %s, %s and %s" ),
1165 else if( layers.size() > 3 )
1167 layerDesc.Printf(
_(
"on %s, %s and %zu more" ),
1170 layers.size() - 2 );
1177 return wxString::Format(
_(
"Rule Area %s" ),
1182 return wxString::Format(
_(
"Rule area '%s' %s" ),
1189 return wxString::Format(
_(
"Teardrop %s %s" ),
1197 return wxString::Format(
_(
"Zone %s %s, priority %d" ),
1204 return wxString::Format(
_(
"Zone '%s' %s %s, priority %d" ),
1215 int aBorderHatchPitch,
bool aRebuildBorderHatch )
1222 if( aRebuildBorderHatch )
1257 std::vector<double> slopes;
1260 slopes = { 0.7, -0.7 };
1261 else if( layer & 1 )
1286 std::swap( *
static_cast<ZONE*
>(
this ), *
static_cast<ZONE*
>( aImage) );
1295 poly->CacheTriangulation();
1297 m_Poly->CacheTriangulation(
false );
1320 std::vector<ZONE*>* aOtherNetIntersectingZones )
const
1329 if( candidate ==
this )
1332 if( !candidate->GetLayerSet().test( aLayer ) )
1335 if( candidate->GetIsRuleArea() || candidate->IsTeardropArea() )
1338 if( !candidate->GetBoundingBox().Intersects( bbox ) )
1341 if( candidate->GetNetCode() ==
GetNetCode() )
1343 if(
m_Poly->Collide( candidate->m_Poly ) )
1344 aSameNetCollidingZones->push_back( candidate );
1348 aOtherNetIntersectingZones->push_back( candidate );
1369 aSmoothedPoly = std::move( flattened );
1374 bool keepExternalFillets =
false;
1381 smooth_requested =
false;
1385 keepExternalFillets =
board->GetDesignSettings().m_ZoneKeepExternalFillets;
1390 if( !smooth_requested )
1411 aSmoothedPoly = flattened;
1416 if( keepExternalFillets && smooth_requested )
1418 withFillets = flattened;
1419 smooth( withFillets );
1421 maxExtents = &withFillets;
1429 std::vector<ZONE*> sameNetCollidingZones;
1430 std::vector<ZONE*> diffNetIntersectingZones;
1433 for(
ZONE* sameNetZone : sameNetCollidingZones )
1435 BOX2I sameNetBoundingBox = sameNetZone->GetBoundingBox();
1449 for(
ZONE* diffNetZone : diffNetIntersectingZones )
1451 if( diffNetZone->HigherPriority( sameNetZone )
1452 && diffNetZone->GetBoundingBox().Intersects( sameNetBoundingBox ) )
1464 bool isolated =
false;
1489 smooth( aSmoothedPoly );
1491 if( aSmoothedPolyWithApron )
1501 if( !keepExternalFillets )
1504 *aSmoothedPolyWithApron = aSmoothedPoly;
1553 aBuffer.
Append( polybuffer );
1560 return std::make_shared<SHAPE_NULL>();
1567 int aError,
ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth )
const
1569 wxASSERT_MSG( !aIgnoreLineWidth, wxT(
"IgnoreLineWidth has no meaning for zones." ) );
1586 aClearance += aError;
1591 aBuffer.
Append( temp_buf );
1604 if( aLayerSet.count() == 0 )
1631 const ZONE& other =
static_cast<const ZONE&
>( aOther );
1632 return *
this == other;
1642 const ZONE& other =
static_cast<const ZONE&
>( aOther );
1709 const ZONE& other =
static_cast<const ZONE&
>( aOther );
1714 double similarity = 1.0;
1753 std::vector<VECTOR2I> corners;
1754 std::vector<VECTOR2I> otherCorners;
1784 if( layerEnum.
Choices().GetCount() == 0 )
1794 if( zcMap.
Choices().GetCount() == 0 )
1806 if( zfmMap.
Choices().GetCount() == 0 )
1815 if( irmMap.
Choices().GetCount() == 0 )
1825 if( rapstMap.
Choices().GetCount() == 0 )
1842 posX->SetIsHiddenFromPropertiesManager();
1848 posY->SetIsHiddenFromPropertiesManager();
1856 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1857 return !zone->GetIsRuleArea() &&
IsCopperLayer( zone->GetFirstLayer() );
1865 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1866 return zone->GetIsRuleArea();
1871 auto isHatchedFill =
1874 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1880 auto isAreaBasedIslandRemoval =
1883 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1898 _HKI(
"Net" ), isCopperZone );
1900 _HKI(
"Net Class" ), isCopperZone );
1909 const wxString groupKeepout =
_HKI(
"Keepout" );
1942 const wxString groupPlacement =
_HKI(
"Placement" );
1963 const wxString groupFill =
_HKI(
"Fill Style" );
1977 auto atLeastMinWidthValidator =
1980 int val = aValue.As<
int>();
1981 ZONE* zone =
dynamic_cast<ZONE*
>( aZone );
1982 wxCHECK( zone, std::nullopt );
1984 if( val < zone->GetMinThickness() )
1985 return std::make_unique<VALIDATION_ERROR_MSG>(
_(
"Cannot be less than zone minimum width" ) );
1987 return std::nullopt;
2035 const wxString groupElectrical =
_HKI(
"Electrical" );
2040 clearance->SetAvailableFunc( isCopperZone );
2047 minWidth->SetAvailableFunc( isCopperZone );
2053 padConnections->SetAvailableFunc( isCopperZone );
2058 thermalGap->SetAvailableFunc( isCopperZone );
2064 thermalSpokeWidth->SetAvailableFunc( isCopperZone );
2065 thermalSpokeWidth->SetValidator( atLeastMinWidthValidator );
2069 propMgr.
AddProperty( padConnections, groupElectrical );
2070 propMgr.
AddProperty( thermalGap, groupElectrical );
2071 propMgr.
AddProperty( thermalSpokeWidth, groupElectrical );
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr EDA_IU_SCALE pcbIUScale
BITMAPS
A list of all bitmap identifiers.
BASE_SET & set(size_t pos)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
wxString GetNetname() const
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
void PackNet(kiapi::board::types::Net *aProto) const
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
void UnpackNet(const kiapi::board::types::Net &aProto)
Assigns a net to this item from an API message.
TEARDROP_PARAMETERS & GetTeardropParams()
ZONE_SETTINGS & GetDefaultZoneSettings()
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
bool IsLocked() const override
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
BOARD_ITEM_CONTAINER * GetParent() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
std::unordered_map< const ZONE *, BOX2I > m_ZoneBBoxCache
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr bool Contains(const Vec &aPoint) const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
KICAD_T Type() const
Returns the type of object.
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
Class that other classes need to inherit from, in order to be inspectable.
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
int GetLocalThermalGapOverride(wxString *aSource) const
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
PROPERTY_BASE & SetWriteableFunc(std::function< bool(INSPECTABLE *)> aFunc)
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
PROPERTY_BASE & SetIsHiddenFromPropertiesManager(bool aHide=true)
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
static VALIDATOR_RESULT PositiveRatioValidator(const wxAny &&aValue, EDA_ITEM *aItem)
static VALIDATOR_RESULT PositiveIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
static VALIDATOR_RESULT RangeIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
Check if point aP lies inside a closed shape.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
bool Intersects(const SEG &aSeg) const
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Represent a set of closed polygons.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
void Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
int OutlineCount() const
Return the number of outlines in the set.
void InflateWithLinkedHoles(int aFactor, CORNER_STRATEGY aCornerStrategy, int aMaxError)
Perform outline inflation/deflation, using round corners.
SHAPE_POLY_SET CloneDropTriangulation() const
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
ZONE_SETTINGS handles zones parameters.
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
Handle a list of polygons defining a copper zone.
void SetHatchThickness(int aThickness)
void SetNeedRefill(bool aNeedRefill)
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if a point is near an outline edge or a corner of this zone.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
wxString m_placementAreaSource
void SetDoNotAllowPads(bool aEnable)
void SetLayerProperties(const std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aOther)
ZONE & operator=(const ZONE &aOther)
int m_cornerSmoothingType
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
PLACEMENT_SOURCE_T m_placementAreaSourceType
std::optional< int > GetLocalClearance() const override
void SetLocalClearance(std::optional< int > aClearance)
bool UnFill()
Removes the zone filling.
bool GetDoNotAllowVias() const
void TransformSolidAreasShapesToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aBuffer) const
Convert solid areas full shapes to polygon set (the full shape is the polygon area with a thick outli...
void SetCornerRadius(unsigned int aRadius)
ZONE_FILL_MODE m_fillMode
bool m_doNotAllowFootprints
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
double m_hatchSmoothingValue
void SetLocalFlags(int aFlags)
void TransformSmoothedOutlineToPolygon(SHAPE_POLY_SET &aBuffer, 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,...
int m_thermalReliefSpokeWidth
wxString GetPlacementAreaSource() const
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.
EDA_ANGLE m_hatchOrientation
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...
void Mirror(const VECTOR2I &aMirrorRef, FLIP_DIRECTION aFlipDirection) override
Mirror the outlines relative to a given horizontal axis the layer is not changed.
std::map< PCB_LAYER_ID, std::set< int > > m_insulatedIslands
For each layer, a set of insulated islands that were not removed.
wxString m_zoneName
An optional unique name for this zone, used for identifying it in DRC checking.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
std::map< PCB_LAYER_ID, std::shared_ptr< SHAPE_POLY_SET > > m_FilledPolysList
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
bool GetDoNotAllowPads() const
const BOX2I GetBoundingBox() const override
void SetMinThickness(int aMinThickness)
void SetPlacementAreaSource(const wxString &aSource)
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
wxString GetFriendlyName() const override
bool GetDoNotAllowTracks() const
int GetLocalFlags() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetHatchOrientation(const EDA_ANGLE &aStep)
void SetHatchSmoothingValue(double aValue)
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > m_layerProperties
bool HitTestForCorner(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a corner.
void SetHatchSmoothingLevel(int aLevel)
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
void SetPlacementAreaSourceType(PLACEMENT_SOURCE_T aType)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
LSET m_fillFlags
Temp variables used while filling.
SHAPE_POLY_SET * Outline()
ZONE(BOARD_ITEM_CONTAINER *parent)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void Move(const VECTOR2I &offset) override
Move the outlines.
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
SHAPE_POLY_SET * m_Poly
Outline of the zone.
TEARDROP_TYPE m_teardropType
std::map< PCB_LAYER_ID, HASH_128 > m_filledPolysHash
A hash value used in zone filling calculations to see if the filled areas are up to date.
long long int GetMinIslandArea() const
int m_hatchSmoothingLevel
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetIsRuleArea(bool aEnable)
void CopyFrom(const BOARD_ITEM *aOther) override
void SetDoNotAllowTracks(bool aEnable)
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
bool m_placementAreaEnabled
Placement rule area data.
const wxString & GetZoneName() const
void CacheBoundingBox()
Used to preload the zone bounding box cache so we don't have to worry about mutex-locking it each tim...
int GetMinThickness() const
virtual void swapData(BOARD_ITEM *aImage) override
bool HitTestForEdge(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a segment defined by 2 corners.
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
bool HigherPriority(const ZONE *aOther) const
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const VECTOR2I &aRefPos, int aAccuracy=0) const
Test if the given VECTOR2I is within the bounds of a filled area of this zone.
void SetIsFilled(bool isFilled)
void SetFillMode(ZONE_FILL_MODE aFillMode)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
ZONE_CONNECTION GetPadConnection() const
int GetHatchThickness() const
double GetHatchHoleMinArea() const
void SetLayerSet(const LSET &aLayerSet) override
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.
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
int m_hatchBorderAlgorithm
bool GetPlacementAreaEnabled() const
void SetDoNotAllowVias(bool aEnable)
bool IsTeardropArea() const
std::vector< SEG > m_borderHatchLines
VECTOR2I GetPosition() const override
int GetThermalReliefSpokeWidth() const
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void BuildHashValue(PCB_LAYER_ID aLayer)
Build the hash value of m_FilledPolysList, and store it internally in m_filledPolysHash.
void SetThermalReliefGap(int aThermalReliefGap)
EDA_ANGLE GetHatchOrientation() const
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aBoardOutline, SHAPE_POLY_SET *aSmoothedPolyWithApron=nullptr) const
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
bool GetDoNotAllowFootprints() const
ZONE_FILL_MODE GetFillMode() const
double m_hatchHoleMinArea
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetDoNotAllowFootprints(bool aEnable)
void SetBorderHatchPitch(int aPitch)
void GetInteractingZones(PCB_LAYER_ID aLayer, std::vector< ZONE * > *aSameNetCollidingZones, std::vector< ZONE * > *aOtherNetIntersectingZones) const
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
void SetLayerSetAndRemoveUnusedFills(const LSET &aLayerSet)
Set the zone to be on the aLayerSet layers and only remove the fill polygons from the unused layers,...
double CalculateOutlineArea()
Compute the area of the zone outline (not the filled area).
void SetHatchHoleMinArea(double aPct)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool IsConflicting() const
For rule areas which exclude footprints (and therefore participate in courtyard conflicts during move...
bool m_doNotAllowZoneFills
ISLAND_REMOVAL_MODE m_islandRemovalMode
bool m_isFilled
True when a zone was filled, false after deleting the filled areas.
double GetHatchSmoothingValue() const
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
bool GetDoNotAllowZoneFills() const
void MoveEdge(const VECTOR2I &offset, int aEdge)
Move the outline Edge.
int GetHatchSmoothingLevel() const
unsigned int GetCornerRadius() const
int GetCornerSmoothingType() const
bool IsOnCopperLayer() const override
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
void SetDoNotAllowZoneFills(bool aEnable)
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, 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...
void SetAssignedPriority(unsigned aPriority)
unsigned int m_cornerRadius
void SetPadConnection(ZONE_CONNECTION aPadConnection)
void SetZoneName(const wxString &aName)
bool operator==(const ZONE &aOther) const
void UnHatchBorder()
Clear the zone's hatch.
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void SetOutline(SHAPE_POLY_SET *aOutline)
PCB_LAYER_ID GetFirstLayer() const
void SetMinIslandArea(long long int aArea)
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
HASH_128 GetHashValue(PCB_LAYER_ID aLayer)
ZONE_CONNECTION m_PadConnection
void InitDataFromSrcInCopyCtor(const ZONE &aZone, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Copy aZone data to me.
int GetThermalReliefGap() const
void SetHatchGap(int aStep)
static int GetDefaultHatchPitch()
void SetPlacementAreaEnabled(bool aEnabled)
unsigned GetAssignedPriority() const
int GetNumCorners(void) const
Access to m_Poly parameters.
bool SameNet(const ZONE *aOther) const
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.
ZONE_BORDER_DISPLAY_STYLE m_borderStyle
long long int m_minIslandArea
When island removal mode is set to AREA, islands below this area will be removed.
@ ROUND_ALL_CORNERS
All angles are rounded.
static constexpr EDA_ANGLE ANGLE_0
#define PCB_EDIT_FRAME_NAME
#define COURTYARD_CONFLICT
temporary set when moving footprints having courtyard overlapping
a few functions useful in geometry calculations.
Some functions to handle hotkeys in KiCad.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored).
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
PCB_LAYER_ID
A quick note on layer IDs:
size_t longest_common_subset(const _Container &__c1, const _Container &__c2)
Returns the length of the longest common subset of values between two containers.
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
LSET UnpackLayerSet(const google::protobuf::RepeatedField< int > &aProtoLayerSet)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput)
KICOMMON_API SHAPE_POLY_SET UnpackPolySet(const types::PolySet &aInput)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput)
KICOMMON_API void PackPolySet(types::PolySet &aOutput, const SHAPE_POLY_SET &aInput)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define IMPLEMENT_ENUM_TO_WXANY(type)
#define NO_SETTER(owner, type)
@ PT_DEGREE
Angle expressed in degrees.
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
@ PT_AREA
Area expressed in distance units-squared (mm/inch)
@ PT_SIZE
Size expressed in distance units (mm/inch)
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
wxString UnescapeString(const wxString &aSource)
void AccumulateDescription(wxString &aDesc, const wxString &aItem)
Utility to build comma separated lists in messages.
A storage class for 128-bit hash value.
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
std::optional< VECTOR2I > hatching_offset
TEARDROP_TYPE
define the type of a teardrop: on a via or pad, or a track end
@ PCB_ZONE_T
class ZONE, a copper pour area
VECTOR2< int32_t > VECTOR2I
static SHAPE_POLY_SET g_nullPoly
static struct ZONE_DESC _ZONE_DESC
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
#define ZONE_CLEARANCE_MAX_VALUE_MM
ZONE_CONNECTION
How pads are covered by copper in zone.
@ THERMAL
Use thermal relief for pads.
@ THT_THERMAL
Thermal relief only for THT pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper
#define ZONE_BORDER_HATCH_DIST_MM
#define ZONE_BORDER_HATCH_MINDIST_MM
#define ZONE_THICKNESS_MIN_VALUE_MM
#define ZONE_BORDER_HATCH_MAXDIST_MM