39#include <math_for_graphics.h>
47#include <google/protobuf/any.pb.h>
51#include <api/board/board_types.pb.h>
59 m_isRuleArea( false ),
60 m_ruleAreaPlacementEnabled( false ),
65 m_ZoneMinThickness( 0 ),
68 m_thermalReliefGap( 0 ),
69 m_thermalReliefSpokeWidth( 0 ),
71 m_hatchThickness( 0 ),
74 m_hatchSmoothingLevel( 0 ),
75 m_hatchHoleMinArea( 0 ),
76 m_CornerSelection( nullptr ),
99 m_CornerSelection( nullptr )
121 board->IncrementTimeStamp();
209 return new ZONE( *
this );
219 PackLayerSet( *zone.mutable_layers(),
GetLayerSet() );
222 zone.set_type( types::ZT_RULE_AREA );
224 zone.set_type( types::ZT_TEARDROP );
226 zone.set_type( types::ZT_COPPER );
228 zone.set_type( types::ZT_GRAPHICAL );
238 types::RuleAreaSettings* ra = zone.mutable_rule_area_settings();
247 ra->set_placement_source_type(
248 ToProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE, types::PlacementRuleSourceType>(
253 types::CopperZoneSettings* cu = zone.mutable_copper_settings();
254 cu->mutable_connection()->set_zone_connection(
255 ToProtoEnum<ZONE_CONNECTION, types::ZoneConnectionStyle>(
m_PadConnection ) );
257 types::ThermalSpokeSettings* thermals = cu->mutable_connection()->mutable_thermal_spokes();
267 cu->set_fill_mode( ToProtoEnum<ZONE_FILL_MODE, types::ZoneFillMode>(
m_fillMode ) );
269 types::HatchFillSettings* hatch = cu->mutable_hatch_settings();
271 hatch->mutable_gap()->set_value_nm(
m_hatchGap );
279 case 0: hatch->set_border_mode( types::ZHFBM_USE_MIN_ZONE_THICKNESS );
break;
280 case 1: hatch->set_border_mode( types::ZHFBM_USE_HATCH_THICKNESS );
break;
283 cu->mutable_net()->mutable_code()->set_value(
GetNetCode() );
285 cu->mutable_teardrop()->set_type(
286 ToProtoEnum<TEARDROP_TYPE, types::TeardropType>(
m_teardropType ) );
291 types::ZoneFilledPolygons* filledLayer = zone.add_filled_polygons();
292 filledLayer->set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
296 zone.mutable_border()->set_style(
297 ToProtoEnum<ZONE_BORDER_DISPLAY_STYLE, types::ZoneBorderStyle>(
m_borderStyle ) );
300 aContainer.PackFrom( zone );
309 if( !aContainer.UnpackTo( &zone ) )
317 if( zone.type() == types::ZoneType::ZT_RULE_AREA )
330 const types::RuleAreaSettings& ra = zone.rule_area_settings();
340 FromProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE>( ra.placement_source_type() );
344 const types::CopperZoneSettings& cu = zone.copper_settings();
345 m_PadConnection = FromProtoEnum<ZONE_CONNECTION>( cu.connection().zone_connection() );
352 m_fillMode = FromProtoEnum<ZONE_FILL_MODE>( cu.fill_mode() );
355 m_hatchGap = cu.hatch_settings().gap().value_nm();
361 switch( cu.hatch_settings().border_mode() )
369 m_teardropType = FromProtoEnum<TEARDROP_TYPE>( cu.teardrop().type() );
372 m_borderStyle = FromProtoEnum<ZONE_BORDER_DISPLAY_STYLE>( zone.border().style() );
381 for(
const types::ZoneFilledPolygons& fillLayer : zone.filled_polygons() )
383 PCB_LAYER_ID layer = FromProtoEnum<PCB_LAYER_ID>( fillLayer.layer() );
424 change |= !pair.second->IsEmpty();
426 pair.second->RemoveAllContours();
469 if( uiLayers.size() )
494 if( aLayerSet.count() == 0 )
522 std::vector<int> layers;
528 layers.push_back( layer );
549 bool flipped = parentFP->GetLayer() ==
B_Cu;
574 std::unordered_map<const ZONE*, BOX2I>& cache = board->m_ZoneBBoxCache;
577 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
579 auto cacheIter = cache.find(
this );
581 if( cacheIter != cache.end() )
582 return cacheIter->second;
588 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
589 cache[ this ] = bbox;
612 *aSource =
_(
"zone" );
698 for(
int ii = 0; ii < count; ii++ )
769 msg << wxT(
" " ) <<
_(
"Cutout" );
771 aList.emplace_back(
_(
"Type" ), msg );
793 aList.emplace_back(
_(
"Restrictions" ), msg );
797 aList.emplace_back(
_(
"Placement source" ),
807 aList.emplace_back(
_(
"Resolved Netclass" ),
812 aList.emplace_back(
_(
"Priority" ),
819 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
825 if( layers.size() == 1 )
829 else if (layers.size() == 2 )
831 layerDesc.Printf(
_(
"%s and %s" ),
835 else if (layers.size() == 3 )
837 layerDesc.Printf(
_(
"%s, %s and %s" ),
842 else if( layers.size() > 3 )
844 layerDesc.Printf(
_(
"%s, %s and %d more" ),
847 static_cast<int>( layers.size() - 2 ) );
850 aList.emplace_back(
_(
"Layer" ), layerDesc );
857 case ZONE_FILL_MODE::POLYGONS: msg =
_(
"Solid" );
break;
858 case ZONE_FILL_MODE::HATCH_PATTERN: msg =
_(
"Hatched" );
break;
859 default: msg =
_(
"Unknown" );
break;
862 aList.emplace_back(
_(
"Fill Mode" ), msg );
864 aList.emplace_back(
_(
"Filled Area" ),
870 if( !source.IsEmpty() )
872 aList.emplace_back( wxString::Format(
_(
"Min Clearance: %s" ),
874 wxString::Format(
_(
"(from %s)" ),
883 count += ii.second->TotalVertices();
885 aList.emplace_back(
_(
"Corner Count" ), wxString::Format( wxT(
"%d" ), count ) );
899 pair.second->Move( offset );
911 if( it !=
GetBoard()->m_ZoneBBoxCache.end() )
912 it->second.Move( offset );
920 return _(
"Rule Area" );
922 return _(
"Teardrop Area" );
924 return _(
"Copper Zone" );
926 return _(
"Non-copper Zone" );
952 pair.second->Rotate( aAngle, aCentre );
958 Mirror( aCentre, aFlipDirection );
960 std::map<PCB_LAYER_ID, SHAPE_POLY_SET> fillsCopy;
964 fillsCopy[oldLayer] = *shapePtr;
969 for(
auto& [oldLayer, shape] : fillsCopy )
984 pair.second->Mirror( aMirrorRef, aFlipDirection );
1019 if( aPolygon.empty() )
1025 for(
const VECTOR2I& pt : aPolygon )
1046 m_Poly->
Append( aPosition.
x, aPosition.
y, -1, aHoleIdx, aAllowDuplication );
1059 if( layers.size() == 1 )
1063 else if (layers.size() == 2 )
1065 layerDesc.Printf(
_(
"on %s and %s" ),
1069 else if (layers.size() == 3 )
1071 layerDesc.Printf(
_(
"on %s, %s and %s" ),
1076 else if( layers.size() > 3 )
1078 layerDesc.Printf(
_(
"on %s, %s and %zu more" ),
1081 layers.size() - 2 );
1088 return wxString::Format(
_(
"Rule Area Cutout %s" ), layerDesc );
1090 return wxString::Format(
_(
"Zone Cutout %s" ), layerDesc );
1095 return wxString::Format(
_(
"Rule Area %s" ), layerDesc );
1097 return wxString::Format(
_(
"Teardrop %s %s" ),
GetNetnameMsg(), layerDesc );
1099 return wxString::Format(
_(
"Zone %s %s" ),
GetNetnameMsg(), layerDesc );
1111 int aBorderHatchPitch,
bool aRebuildBorderHatch )
1113 aBorderHatchPitch = std::max( aBorderHatchPitch,
1115 aBorderHatchPitch = std::min( aBorderHatchPitch,
1120 if( aRebuildBorderHatch )
1141 return tst.
x < ref.
x;
1164 if( iterator->x < min_x )
1165 min_x = iterator->x;
1167 if( iterator->x > max_x )
1168 max_x = iterator->x;
1170 if( iterator->y < min_y )
1171 min_y = iterator->y;
1173 if( iterator->y > max_y )
1174 max_y = iterator->y;
1180 if(
m_borderStyle == ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE )
1190 std::vector<int> slope_flags;
1193 slope_flags = { 1, -1 };
1194 else if( layer & 1 )
1195 slope_flags = { 1 };
1197 slope_flags = { -1 };
1199 for(
int slope_flag : slope_flags )
1201 double slope = 0.707106 * slope_flag;
1202 int64_t max_a, min_a;
1204 if( slope_flag == 1 )
1206 max_a = KiROUND<double, int64_t>( max_y - slope * min_x );
1207 min_a = KiROUND<double, int64_t>( min_y - slope * max_x );
1211 max_a = KiROUND<double, int64_t>( max_y - slope * max_x );
1212 min_a = KiROUND<double, int64_t>( min_y - slope * min_x );
1215 min_a = (min_a / spacing) * spacing;
1219 int offset = (layer * 7) / 8;
1223 std::vector<VECTOR2I> pointbuffer;
1224 pointbuffer.reserve( 256 );
1226 for( int64_t a = min_a; a < max_a; a += spacing )
1228 pointbuffer.clear();
1233 const SEG seg = *iterator;
1236 if( FindLineSegmentIntersection( a, slope, seg.
A.
x, seg.
A.
y, seg.
B.
x, seg.
B.
y, x, y ) )
1243 if( pointbuffer.size() > 2 )
1247 for(
size_t ip = 0; ip + 1 < pointbuffer.size(); ip += 2 )
1249 int dx = pointbuffer[ip + 1].x - pointbuffer[ip].x;
1254 if(
m_borderStyle == ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL
1255 ||
std::abs( dx ) < 2 * hatch_line_len )
1261 double dy = pointbuffer[ip + 1].y - pointbuffer[ip].y;
1265 dx = hatch_line_len;
1267 dx = -hatch_line_len;
1269 int x1 =
KiROUND( pointbuffer[ip].x + dx );
1270 int x2 =
KiROUND( pointbuffer[ip + 1].x - dx );
1271 int y1 =
KiROUND( pointbuffer[ip].y + dx * slope );
1272 int y2 =
KiROUND( pointbuffer[ip + 1].y - dx * slope );
1294 return BITMAPS::add_zone;
1302 std::swap( *
static_cast<ZONE*
>(
this ), *
static_cast<ZONE*
>( aImage) );
1311 poly->CacheTriangulation();
1336 std::vector<ZONE*>* aOtherNetIntersectingZones )
const
1345 if( candidate ==
this )
1348 if( !candidate->GetLayerSet().test( aLayer ) )
1351 if( candidate->GetIsRuleArea() || candidate->IsTeardropArea() )
1354 if( !candidate->GetBoundingBox().Intersects( bbox ) )
1357 if( candidate->GetNetCode() ==
GetNetCode() )
1360 aSameNetCollidingZones->push_back( candidate );
1364 aOtherNetIntersectingZones->push_back( candidate );
1385 aSmoothedPoly = flattened;
1391 bool keepExternalFillets =
false;
1398 smooth_requested =
false;
1412 if( !smooth_requested )
1433 aSmoothedPoly = flattened;
1438 if( keepExternalFillets && smooth_requested )
1440 withFillets = flattened;
1441 smooth( withFillets );
1443 maxExtents = &withFillets;
1451 std::vector<ZONE*> sameNetCollidingZones;
1452 std::vector<ZONE*> diffNetIntersectingZones;
1455 for(
ZONE* sameNetZone : sameNetCollidingZones )
1457 BOX2I sameNetBoundingBox = sameNetZone->GetBoundingBox();
1469 for(
ZONE* diffNetZone : diffNetIntersectingZones )
1471 if( diffNetZone->HigherPriority( sameNetZone )
1472 && diffNetZone->GetBoundingBox().Intersects( sameNetBoundingBox ) )
1474 diffNetPoly.
BooleanAdd( *diffNetZone->Outline() );
1481 bool isolated =
false;
1503 smooth( aSmoothedPoly );
1505 if( aSmoothedPolyWithApron )
1515 if( !keepExternalFillets )
1518 *aSmoothedPolyWithApron = aSmoothedPoly;
1536 std::shared_ptr<SHAPE_POLY_SET>& poly = pair.second;
1538 for(
int i = 0; i < poly->OutlineCount(); i++ )
1540 m_area += poly->Outline( i ).Area();
1542 for(
int j = 0; j < poly->HoleCount( i ); j++ )
1543 m_area -= poly->Hole( i, j ).Area();
1579 aClearance += maxError;
1581 polybuffer.
Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
1585 aBuffer.
Append( polybuffer );
1592 return std::make_shared<SHAPE_NULL>();
1599 int aError,
ERROR_LOC aErrorLoc,
bool aIgnoreLineWidth )
const
1601 wxASSERT_MSG( !aIgnoreLineWidth, wxT(
"IgnoreLineWidth has no meaning for zones." ) );
1618 aClearance += aError;
1623 aBuffer.
Append( temp_buf );
1636 if( aLayerSet.count() == 0 )
1647 m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>();
1648 m_filledPolysHash[layer] = {};
1654 m_layerSet = aLayerSet;
1663 const ZONE& other =
static_cast<const ZONE&
>( aOther );
1664 return *
this == other;
1674 const ZONE& other =
static_cast<const ZONE&
>( aOther );
1741 const ZONE& other =
static_cast<const ZONE&
>( aOther );
1746 double similarity = 1.0;
1785 std::vector<VECTOR2I> corners;
1786 std::vector<VECTOR2I> otherCorners;
1816 if( layerEnum.
Choices().GetCount() == 0 )
1826 if( zcMap.
Choices().GetCount() == 0 )
1828 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
1829 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
1830 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
1831 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
1832 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
1833 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
1838 if( zfmMap.
Choices().GetCount() == 0 )
1840 zfmMap.
Undefined( ZONE_FILL_MODE::POLYGONS );
1841 zfmMap.
Map( ZONE_FILL_MODE::POLYGONS,
_HKI(
"Solid fill" ) )
1842 .
Map( ZONE_FILL_MODE::HATCH_PATTERN,
_HKI(
"Hatch pattern" ) );
1847 if( irmMap.
Choices().GetCount() == 0 )
1849 irmMap.
Undefined( ISLAND_REMOVAL_MODE::ALWAYS );
1850 irmMap.
Map( ISLAND_REMOVAL_MODE::ALWAYS,
_HKI(
"Always" ) )
1851 .
Map( ISLAND_REMOVAL_MODE::NEVER,
_HKI(
"Never" ) )
1852 .
Map( ISLAND_REMOVAL_MODE::AREA,
_HKI(
"Below area limit" ) );
1858 if( rapstMap.
Choices().GetCount() == 0 )
1860 rapstMap.
Undefined( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME );
1861 rapstMap.
Map( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME,
_HKI(
"Sheet Name" ) )
1862 .
Map( RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS,
1863 _HKI(
"Component Class" ) );
1873 PROPERTY_DISPLAY::PT_COORD,
1875 posX->SetIsHiddenFromPropertiesManager();
1879 PROPERTY_DISPLAY::PT_COORD,
1881 posY->SetIsHiddenFromPropertiesManager();
1889 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1890 return !zone->GetIsRuleArea() &&
IsCopperLayer( zone->GetFirstLayer() );
1898 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1899 return zone->GetIsRuleArea();
1904 auto isHatchedFill =
1907 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1908 return zone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN;
1913 auto isAreaBasedIslandRemoval =
1916 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
1917 return zone->GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA;
1928 .SetIsHiddenFromPropertiesManager();
1931 _HKI(
"Net" ), isCopperZone );
1933 _HKI(
"Net Class" ), isCopperZone );
1937 .SetAvailableFunc( isCopperZone );
1942 const wxString groupKeepout =
_HKI(
"Keepout" );
1975 const wxString groupPlacement =
_HKI(
"Placement" );
1996 const wxString groupFill =
_HKI(
"Fill Style" );
2005 PROPERTY_DISPLAY::PT_DEGREE ),
2011 auto atLeastMinWidthValidator =
2014 int val = aValue.As<
int>();
2015 ZONE* zone =
dynamic_cast<ZONE*
>( aZone );
2016 wxCHECK( zone, std::nullopt );
2018 if( val < zone->GetMinThickness() )
2020 return std::make_unique<VALIDATION_ERROR_MSG>(
2021 _(
"Cannot be less than zone minimum width" ) );
2024 return std::nullopt;
2072 const wxString groupElectrical =
_HKI(
"Electrical" );
2076 PROPERTY_DISPLAY::PT_SIZE );
2079 clearanceOverride->SetValidator( PROPERTY_VALIDATORS::RangeIntValidator<0, maxClearance> );
2083 PROPERTY_DISPLAY::PT_SIZE );
2084 minWidth->SetAvailableFunc( isCopperZone );
2091 padConnections->SetAvailableFunc( isCopperZone );
2095 PROPERTY_DISPLAY::PT_SIZE );
2096 thermalGap->SetAvailableFunc( isCopperZone );
2101 PROPERTY_DISPLAY::PT_SIZE );
2102 thermalSpokeWidth->SetAvailableFunc( isCopperZone );
2103 thermalSpokeWidth->SetValidator( atLeastMinWidthValidator );
2105 propMgr.
AddProperty( clearanceOverride, groupElectrical );
2107 propMgr.
AddProperty( padConnections, groupElectrical );
2108 propMgr.
AddProperty( thermalGap, groupElectrical );
2109 propMgr.
AddProperty( thermalSpokeWidth, groupElectrical );
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
BASE_SET & reset(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.
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
wxString GetNetname() 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.
TEARDROP_PARAMETERS & GetTeardropParams()
Container for design settings for a BOARD object.
ZONE_SETTINGS & GetDefaultZoneSettings()
bool m_ZoneKeepExternalFillets
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...
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual bool IsLocked() 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
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.
std::string AsStdString() const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
static LSET AllLayersMask()
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=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
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)
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.
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 Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX *aClosestVertex=nullptr, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
ITERATOR IterateWithHoles(int aOutline)
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
virtual void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
double Area()
Return the area of this poly set.
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
int TotalVertices() const
Return total number of vertices stored in the set.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
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)
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
bool GetNeighbourIndexes(int aGlobalIndex, int *aPrevious, int *aNext) const
Return the global indexes of the previous and the next corner of the aGlobalIndex-th corner of a cont...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the reference to aHole-th hole in the aIndex-th outline.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
bool CollideVertex(const VECTOR2I &aPoint, VERTEX_INDEX *aClosestVertex=nullptr, int aClearance=0) const
Check whether aPoint collides with any vertex of any of the contours of the polygon.
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both)
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
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.
void Move(const VECTOR2I &aVector) override
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
SHAPE_POLY_SET CloneDropTriangulation() const
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
SEGMENT_ITERATOR IterateSegmentsWithHoles()
Returns an iterator object, for all outlines in the set (with holes)
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
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)
SHAPE_POLY_SET::VERTEX_INDEX * m_CornerSelection
The index of the corner being moved or nullptr if no corner is selected.
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.
void SetDoNotAllowPads(bool aEnable)
ZONE & operator=(const ZONE &aOther)
int m_cornerSmoothingType
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
std::optional< int > GetLocalClearance() const override
void SetRuleAreaPlacementEnabled(bool aEnabled)
void SetLocalClearance(std::optional< int > aClearance)
bool UnFill()
Removes the zone filling.
wxString GetRuleAreaPlacementSource() const
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
How to fill areas:
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
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)
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
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)
bool m_doNotAllowCopperPour
bool GetRuleAreaPlacementEnabled() const
void SetHatchSmoothingValue(double aValue)
bool m_needRefill
False when a zone was refilled, true after changes in zone params.
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)
RULE_AREA_PLACEMENT_SOURCE_TYPE m_ruleAreaPlacementSourceType
void SetDoNotAllowCopperPour(bool aEnable)
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
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 SetRuleAreaPlacementSourceType(RULE_AREA_PLACEMENT_SOURCE_TYPE aType)
void SetIsRuleArea(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
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
void InitDataFromSrcInCopyCtor(const ZONE &aZone)
Copy aZone data to me.
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
void SetDoNotAllowVias(bool aEnable)
bool IsTeardropArea() const
std::vector< SEG > m_borderHatchLines
wxString m_ruleAreaPlacementSource
VECTOR2I GetPosition() const override
int GetThermalReliefSpokeWidth() const
int GetBorderHatchPitch() const
HatchBorder related methods.
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)
bool GetDoNotAllowCopperPour() const
void SetBorderHatchPitch(int aPitch)
Set the hatch pitch parameter for the zone.
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...
bool m_ruleAreaPlacementEnabled
Placement rule area data.
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).
RULE_AREA_PLACEMENT_SOURCE_TYPE GetRuleAreaPlacementSourceType() const
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...
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)
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 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 SetRuleAreaPlacementSource(const wxString &aSource)
int GetThermalReliefGap() const
void SetHatchGap(int aStep)
static int GetDefaultHatchPitch()
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.
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.
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.
KICOMMON_API SHAPE_POLY_SET UnpackPolySet(const types::PolySet &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)
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
@ NONE
No connection to this item.
wxString UnescapeString(const wxString &aSource)
void AccumulateDescription(wxString &aDesc, const wxString &aItem)
Utility to build comma separated lists in messages.
constexpr int mmToIU(double mm) const
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...
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
bool sortEndsByDescendingX(const VECTOR2I &ref, const VECTOR2I &tst)
static struct ZONE_DESC _ZONE_DESC
RULE_AREA_PLACEMENT_SOURCE_TYPE
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.
#define ZONE_BORDER_HATCH_DIST_MM
#define ZONE_BORDER_HATCH_MINDIST_MM
#define ZONE_THICKNESS_MIN_VALUE_MM
#define ZONE_BORDER_HATCH_MAXDIST_MM