56#include <google/protobuf/any.pb.h>
60#include <api/board/board_types.pb.h>
82 *
this = *
static_cast<const PCB_TRACK*
>( aOther );
100 std::unique_ptr<PCB_TRACK> track = std::make_unique<PCB_TRACK>( aParent );
102 track->SetStart( aStart );
103 track->SetEnd( aEnd );
107 std::unique_ptr<PCB_ARC> arc = std::make_unique<PCB_ARC>( aParent );
109 arc->SetStart( aStart );
125 *
this = *
static_cast<const PCB_ARC*
>( aOther );
163 std::memory_order_relaxed );
186 *
this = *
static_cast<const PCB_VIA*
>( aOther );
205 default: formatStr =
_(
"Via %s on %s" );
break;
225 return *
this == other;
247 double similarity = 1.0;
278 return *
this == other;
289 return *
this == other;
312 double similarity = 1.0;
346 return *
this == other;
357 return *
this == other;
394 double similarity = 1.0;
421 wxFAIL_MSG( wxT(
"Warning: PCB_VIA::SetWidth() called without a layer argument" ) );
429 wxT(
"Warning: PCB_VIA::GetWidth() called without a layer argument" ) );
435 m_padStack.SetSize( { aWidth, aWidth }, aLayer );
447 kiapi::board::types::Track track;
449 track.mutable_id()->set_value(
m_Uuid.AsStdString() );
450 track.mutable_start()->set_x_nm(
GetStart().x );
451 track.mutable_start()->set_y_nm(
GetStart().y );
452 track.mutable_end()->set_x_nm(
GetEnd().x );
453 track.mutable_end()->set_y_nm(
GetEnd().y );
454 track.mutable_width()->set_value_nm(
GetWidth() );
456 track.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
457 : kiapi::common::types::LockedState::LS_UNLOCKED );
458 PackNet( track.mutable_net() );
461 track.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
465 kiapi::board::types::SolderMaskOverrides* sm = track.mutable_solder_mask();
466 sm->set_expose_copper(
true );
473 aContainer.PackFrom( track );
479 kiapi::board::types::Track track;
481 if( !aContainer.UnpackTo( &track ) )
487 SetWidth( track.width().value_nm() );
490 SetLocked( track.locked() == kiapi::common::types::LockedState::LS_LOCKED );
493 if( track.has_solder_mask() )
497 if( track.solder_mask().has_solder_mask_margin() )
514 kiapi::board::types::Arc arc;
516 arc.mutable_id()->set_value(
m_Uuid.AsStdString() );
517 arc.mutable_start()->set_x_nm(
GetStart().x );
518 arc.mutable_start()->set_y_nm(
GetStart().y );
519 arc.mutable_mid()->set_x_nm(
GetMid().x );
520 arc.mutable_mid()->set_y_nm(
GetMid().y );
521 arc.mutable_end()->set_x_nm(
GetEnd().x );
522 arc.mutable_end()->set_y_nm(
GetEnd().y );
523 arc.mutable_width()->set_value_nm(
GetWidth() );
525 arc.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
526 : kiapi::common::types::LockedState::LS_UNLOCKED );
530 arc.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
534 kiapi::board::types::SolderMaskOverrides* sm = arc.mutable_solder_mask();
535 sm->set_expose_copper(
true );
542 aContainer.PackFrom( arc );
548 kiapi::board::types::Arc arc;
550 if( !aContainer.UnpackTo( &arc ) )
554 const VECTOR2I start( arc.start().x_nm(), arc.start().y_nm() );
555 const VECTOR2I mid( arc.mid().x_nm(), arc.mid().y_nm() );
556 const VECTOR2I end( arc.end().x_nm(), arc.end().y_nm() );
568 SetLocked( arc.locked() == kiapi::common::types::LockedState::LS_LOCKED );
571 if( arc.has_solder_mask() )
575 if( arc.solder_mask().has_solder_mask_margin() )
592 kiapi::board::types::Via
via;
594 aContainer.PackFrom(
via );
600 aVia.mutable_id()->set_value(
m_Uuid.AsStdString() );
601 aVia.mutable_position()->set_x_nm(
GetPosition().x );
602 aVia.mutable_position()->set_y_nm(
GetPosition().y );
606 padstack.
Serialize( *aVia.mutable_pad_stack() );
609 aVia.mutable_pad_stack()->clear_layers();
613 aVia.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
614 : kiapi::common::types::LockedState::LS_UNLOCKED );
618 aVia.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
626 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> overrides;
640 kiapi::board::types::Via
via;
642 if( !aContainer.UnpackTo( &
via ) )
655 google::protobuf::Any padStackWrapper;
656 padStackWrapper.PackFrom( aVia.pad_stack() );
658 if( !
m_padStack.Deserialize( padStackWrapper ) )
666 SetLocked( aVia.locked() == kiapi::common::types::LockedState::LS_LOCKED );
669 if( aVia.has_teardrop() )
679 std::map<PCB_LAYER_ID, ZONE_LAYER_OVERRIDE> overrides;
682 for(
const auto& [layer, value] : overrides )
709 *aSource = constraint.
GetName();
711 return constraint.
Value();
726 *aSource = constraint.
GetName();
728 return constraint.
Value();
744 *aSource = constraint.
GetName();
746 return constraint.
Value();
777 *aSource =
_(
"removed annular ring" );
793 *aSource = constraint.
GetName();
866 std::map<int, int> ordinals;
870 ordinals[layer] = n++;
872 std::vector<PCB_VIA*> microvias;
885 if(
via->TopLayer() ==
via->BottomLayer() )
888 if( ordinals.count(
via->TopLayer() ) && ordinals.count(
via->BottomLayer() ) )
889 microvias.push_back(
via );
892 auto upper = [&](
PCB_VIA* aVia )
894 return std::min( ordinals[aVia->TopLayer()], ordinals[aVia->BottomLayer()] );
897 auto lower = [&](
PCB_VIA* aVia )
899 return std::max( ordinals[aVia->TopLayer()], ordinals[aVia->BottomLayer()] );
905 double reach = ( aFirst->
GetDrillValue() + aSecond->GetDrillValue() ) / 2.0;
907 return ( aFirst->
GetPosition() - aSecond->GetPosition() ).EuclideanNorm() <= reach;
915 cellSize = std::max( cellSize,
via->GetDrillValue() );
917 auto cellOf = [&](
int aCoord )
919 return (
int) std::floor( (
double) aCoord / cellSize );
922 std::map<std::tuple<int, int, int>, std::vector<PCB_VIA*>> byCell;
927 byCell[{ upper(
via ), cellOf( pos.
x ), cellOf( pos.
y ) }].push_back(
via );
935 for(
int dx = -1; dx <= 1; ++dx )
937 for(
int dy = -1; dy <= 1; ++dy )
939 auto it = byCell.find( { lower( aVia ), cellOf( pos.
x ) + dx, cellOf( pos.
y ) + dy } );
941 if( it == byCell.end() )
944 for(
PCB_VIA* other : it->second )
946 if( other != aVia && overlaps( aVia, other ) )
955 std::set<PCB_VIA*> carried;
960 carried.insert( under );
963 std::vector<std::vector<PCB_VIA*>> columns;
964 std::set<PCB_VIA*> taken;
969 if( carried.count(
via ) )
972 std::vector<PCB_VIA*> column;
973 bool landsOnAnother =
false;
975 for(
PCB_VIA* step =
via; step; step = below( step ) )
977 if( !taken.insert( step ).second )
979 landsOnAnother =
true;
983 column.push_back( step );
985 if( column.size() > ordinals.size() )
989 if( column.size() > 1 || landsOnAnother )
990 columns.push_back( std::move( column ) );
1026 if( aDrill.has_value() && *aDrill > 0 )
1038 return std::nullopt;
1074 if( aDrill.has_value() && *aDrill > 0 )
1086 return std::nullopt;
1121 if( secondaryDrill.
size.
x > 0
1134 if( tertiaryDrill.
size.
x > 0
1165 if( frontPM.
mode.has_value()
1168 && frontPM.
size > 0 )
1170 int pmDepth = frontPM.
depth;
1175 && frontPM.
angle > 0 )
1177 double halfAngleRad = ( frontPM.
angle / 10.0 ) *
M_PI / 180.0 / 2.0;
1178 pmDepth =
static_cast<int>( ( frontPM.
size / 2.0 ) / tan( halfAngleRad ) );
1186 if( layerDist < pmDepth )
1191 double halfAngleRad = ( frontPM.
angle / 10.0 ) *
M_PI / 180.0 / 2.0;
1192 int diameterAtLayer = frontPM.
size -
static_cast<int>( 2.0 * layerDist * tan( halfAngleRad ) );
1193 return std::max( 0, diameterAtLayer );
1198 return frontPM.
size;
1207 if( backPM.
mode.has_value()
1210 && backPM.
size > 0 )
1212 int pmDepth = backPM.
depth;
1217 && backPM.
angle > 0 )
1219 double halfAngleRad = ( backPM.
angle / 10.0 ) *
M_PI / 180.0 / 2.0;
1220 pmDepth =
static_cast<int>( ( backPM.
size / 2.0 ) / tan( halfAngleRad ) );
1228 if( layerDist < pmDepth )
1233 double halfAngleRad = ( backPM.
angle / 10.0 ) *
M_PI / 180.0 / 2.0;
1234 int diameterAtLayer = backPM.
size -
static_cast<int>( 2.0 * layerDist * tan( halfAngleRad ) );
1235 return std::max( 0, diameterAtLayer );
1262 if(
m_End == point )
1267 double dist =
m_Start.Distance( point );
1269 if( min_dist >= dist )
1272 dist =
m_End.Distance( point );
1274 if( min_dist >= dist )
1286 int ymax, xmax, ymin, xmin;
1291 BOX2I bbox = arc->BBox();
1315 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
1329 diameter = std::max( diameter,
GetWidth( aLayer ) );
1332 diameter = std::max( diameter,
Padstack().GetMaxHoleSize() );
1335 int radius = ( diameter + 1 ) / 2;
1345 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
1354 diameter = std::max( diameter,
Padstack().GetMaxHoleSize() );
1357 int radius = ( diameter + 1 ) / 2;
1367 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
1387 .MergeTracks =
false,
1388 .OptimiseTracesInPads =
false,
1389 .InferViaInPad =
false
1468 return start_end.
Cross( start_mid ) < 0;
1499 for(
KICAD_T scanType : aScanTypes )
1501 if( scanType ==
Type() )
1524 holeSize = std::max( holeSize,
Padstack().GetMaxHoleSize() );
1544 if(
m_padStack.FrontOuterLayers().has_solder_mask.has_value() )
1567 if(
m_padStack.BackOuterLayers().has_solder_mask.has_value() )
1590 if(
m_padStack.FrontOuterLayers().has_covering.has_value() )
1613 if(
m_padStack.BackOuterLayers().has_covering.has_value() )
1636 if(
m_padStack.FrontOuterLayers().has_plugging.has_value() )
1659 if(
m_padStack.BackOuterLayers().has_plugging.has_value() )
1682 if(
m_padStack.Drill().is_capped.has_value() )
1705 if(
m_padStack.Drill().is_filled.has_value() )
1721 if( front &&
m_padStack.FrontOuterLayers().has_solder_mask.has_value() )
1722 return *
m_padStack.FrontOuterLayers().has_solder_mask;
1724 if( !front &&
m_padStack.BackOuterLayers().has_solder_mask.has_value() )
1725 return *
m_padStack.BackOuterLayers().has_solder_mask;
1729 return front ? board->GetDesignSettings().m_TentViasFront
1730 : board->GetDesignSettings().m_TentViasBack;
1740 return board->GetDesignSettings().m_SolderMaskExpansion;
1767 margin = board->GetDesignSettings().m_SolderMaskExpansion;
1772 margin = std::max( margin, -
m_width / 2 );
1807 else if( aLayer ==
B_Mask )
1825 int layer_id = aCopperLayerCount*2;
1829 if(
Padstack().Drill().start > layer_id )
1873 if( layermask.test(
F_Cu ) )
1875 else if( layermask.test(
B_Cu ) )
1902 layermask.
set(
id );
1933 bool top_found =
false;
1934 bool bottom_found =
false;
1944 if( !top_found && layer !=
B_Cu )
1955 bottom_found =
true;
1970 board->InvalidateClearanceCache(
m_Uuid );
1987 board->InvalidateClearanceCache(
m_Uuid );
1995 if( aLayer ==
Padstack().Drill().start )
2004 board->InvalidateClearanceCache(
m_Uuid );
2020 std::swap( b_layer, t_layer );
2024 *top_layer = t_layer;
2027 *bottom_layer = b_layer;
2056 auto sanitizeBackdrill =
2065 if( copperCount > 0 )
2078 aDrill.size = { 0, 0 };
2081 sanitizeBackdrill(
Padstack().SecondaryDrill() );
2082 sanitizeBackdrill(
Padstack().TertiaryDrill() );
2086std::optional<PCB_VIA::VIA_PARAMETER_ERROR>
2088 std::optional<int> aPrimaryDrill,
2089 std::optional<PCB_LAYER_ID> aPrimaryStartLayer,
2090 std::optional<PCB_LAYER_ID> aPrimaryEndLayer,
2091 std::optional<int> aSecondaryDrill,
2092 std::optional<PCB_LAYER_ID> aSecondaryStartLayer,
2093 std::optional<PCB_LAYER_ID> aSecondaryEndLayer,
2094 std::optional<int> aTertiaryDrill,
2095 std::optional<PCB_LAYER_ID> aTertiaryStartLayer,
2096 std::optional<PCB_LAYER_ID> aTertiaryEndLayer,
2097 int aCopperLayerCount )
2103 error.
m_Message =
_(
"Via diameter is too small." );
2104 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::DIAMETER;
2110 error.
m_Message =
_(
"Via drill is too small." );
2111 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::DRILL;
2115 if( aDiameter.has_value() && !aPrimaryDrill.has_value() )
2117 error.
m_Message =
_(
"No via hole size defined." );
2118 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::DRILL;
2122 if( aPrimaryDrill.has_value() && !aDiameter.has_value() )
2124 error.
m_Message =
_(
"No via diameter defined." );
2125 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::DIAMETER;
2129 if( aDiameter.has_value() && aPrimaryDrill.has_value()
2130 && aDiameter.value() <= aPrimaryDrill.value() )
2132 error.
m_Message =
_(
"Via hole size must be smaller than via diameter" );
2133 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::DRILL;
2137 std::optional<LSET> copperMask;
2139 auto validateLayer = [&]( std::optional<PCB_LAYER_ID> aLayer,
2142 if( !aLayer.has_value() )
2152 error.
m_Message =
_(
"Via layer must be a copper layer." );
2157 if( aCopperLayerCount > 0 )
2159 if( !copperMask.has_value() )
2162 if( !copperMask->Contains( layer ) )
2164 error.
m_Message =
_(
"Via layer is outside the board stack." );
2173 if( !validateLayer( aPrimaryStartLayer, VIA_PARAMETER_ERROR::FIELD::START_LAYER ) )
2176 if( !validateLayer( aPrimaryEndLayer, VIA_PARAMETER_ERROR::FIELD::END_LAYER ) )
2179 if( aPrimaryStartLayer.has_value() && aPrimaryEndLayer.has_value()
2180 && aPrimaryStartLayer.value() == aPrimaryEndLayer.value() )
2182 error.
m_Message =
_(
"Via start layer and end layer cannot be the same" );
2183 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::START_LAYER;
2187 if( aSecondaryDrill.has_value() )
2191 error.
m_Message =
_(
"Backdrill diameter is too small." );
2192 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::SECONDARY_DRILL;
2196 if( !validateLayer( aSecondaryStartLayer, VIA_PARAMETER_ERROR::FIELD::SECONDARY_START_LAYER ) )
2199 if( !validateLayer( aSecondaryEndLayer, VIA_PARAMETER_ERROR::FIELD::SECONDARY_END_LAYER ) )
2203 if( aTertiaryDrill.has_value() )
2207 error.
m_Message =
_(
"Tertiary backdrill diameter is too small." );
2208 error.
m_Field = VIA_PARAMETER_ERROR::FIELD::TERTIARY_DRILL;
2212 if( !validateLayer( aTertiaryStartLayer, VIA_PARAMETER_ERROR::FIELD::TERTIARY_START_LAYER ) )
2215 if( !validateLayer( aTertiaryEndLayer, VIA_PARAMETER_ERROR::FIELD::TERTIARY_END_LAYER ) )
2219 return std::nullopt;
2238 return startOuter ^ endOuter;
2285 wxFAIL_MSG( wxT(
"Unsupported layer for FRONT_INNER_BACK" ) );
2323 switch(
Padstack().UnconnectedLayerMode() )
2369 entry.store(
ZLO_NONE, std::memory_order_relaxed );
2402 bool connected =
false;
2409 &&
GetBoard()->GetConnectivity()->IsConnectedOnLayer(
this, layer, nonZoneTypes ) )
2430 std::vector<int> layers{
2436 layers.reserve( 6 );
2441 layers.push_back(
F_Mask );
2443 layers.push_back(
B_Mask );
2496 if(
VECTOR2I(
end - start ).SquaredEuclideanNorm() == 0 )
2529 bbox.
Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
2533 bbox = board->ExpandBoundingBoxForDrillSymbols( bbox );
2556 for(
PCB_LAYER_ID mapLayer : drillBoard->DrillSymbolLayers().Seq() )
2566 bool isBlindBuried =
2574 cuMask &= board->GetEnabledLayers();
2591 ret_layers.push_back(
F_Mask );
2594 ret_layers.push_back(
B_Mask );
2624 highContrastLayer =
F_Cu;
2626 highContrastLayer =
B_Cu;
2671 if( !visible.any() )
2679 if( !visible.any() )
2737 default:
return _(
"Track" );
2760 aList.emplace_back(
_(
"Angle" ), wxString::Format(
"%.2fdeg",
2761 static_cast<PCB_ARC*
>(
this)->GetAngle().AsDegrees() ) );
2767 if( segmentDelay == 0.0 )
2773 aList.emplace_back(
_(
"Segment Delay" ),
2781 double trackLen = 0.0;
2782 double lenPadToDie = 0.0;
2783 double trackDelay = 0.0;
2784 double delayPadToDie = 0.0;
2786 std::tie( count, trackLen, lenPadToDie, trackDelay, delayPadToDie ) = board->
GetTrackLength( *
this );
2788 if( trackDelay == 0.0 )
2792 if( lenPadToDie != 0 )
2795 aList.emplace_back(
_(
"Pad To Die Length" ), msg );
2798 aList.emplace_back(
_(
"Full Length" ), msg );
2803 aList.emplace_back(
_(
"Routed Delay" ),
2806 if( delayPadToDie != 0.0 )
2809 aList.emplace_back(
_(
"Pad To Die Delay" ), msg );
2812 aList.emplace_back(
_(
"Full Delay" ), msg );
2819 aList.emplace_back(
_(
"Copper Area" ),
2825 aList.emplace_back( wxString::Format(
_(
"Min Clearance: %s" ),
2827 wxString::Format(
_(
"(from %s)" ),
source ) );
2832 if( !msg.IsEmpty() )
2834 aList.emplace_back( wxString::Format(
_(
"Width Constraints: %s" ), msg ),
2835 wxString::Format(
_(
"(from %s)" ),
source ) );
2850 default: msg =
_(
"Via" );
break;
2853 aList.emplace_back(
_(
"Type" ), msg );
2859 std::set<int> widths;
2866 widths.insert(
GetWidth( aLayer ) );
2869 if( widths.size() == 1 )
2872 aList.emplace_back(
_(
"Diameter" ),
_(
"(mixed)" ) );
2880 wxString::Format(
_(
"(from %s)" ),
source ) );
2884 aList.emplace_back( wxString::Format(
_(
"Min Annular Width: %s" ), aFrame->
MessageTextFromValue( minAnnulus ) ),
2885 wxString::Format(
_(
"(from %s)" ),
source ) );
2895 const wxString& chainName = netInfo->GetNetChain();
2897 if( !chainName.IsEmpty() )
2901 aList.emplace_back(
_(
"Resolved Netclass" ),
2906 aList.emplace_back(
_(
"NetCode" ), fmt::format(
"{}",
GetNetCode() ) );
2908 aList.emplace_back( wxT(
"Flags" ), fmt::format(
"#08X",
m_flags ) );
2910 aList.emplace_back( wxT(
"Start pos" ), fmt::format(
"{} {}",
m_Start.x,
m_Start.y ) );
2911 aList.emplace_back( wxT(
"End pos" ), fmt::format(
"{} {}",
m_End.x,
m_End.y ) );
2915 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
2934 return width * width;
2946 double max_dist = aAccuracy + (
GetWidth() / 2.0 );
2949 if(
GetStart().Distance( aPosition ) <= max_dist ||
GetEnd().Distance( aPosition ) <= max_dist )
2967 arc_hittest -= arc_angle_start;
2973 return arc_hittest >=
ANGLE_360 + arc_angle;
2975 return arc_hittest <= arc_angle;
2999 int max_dist = aAccuracy + (
GetWidth( aLayer ) / 2 );
3003 double dist = rel_pos.x * rel_pos.x + rel_pos.y * rel_pos.y;
3005 if( dist <=
static_cast<double>( max_dist ) * max_dist )
3015 BOX2I arect = aRect;
3027 BOX2I arect = aRect;
3045 BOX2I arect = aRect;
3080 return wxString::Format(
Type() ==
PCB_ARC_T ?
_(
"Track (arc) %s on %s, length %s" )
3081 :
_(
"Track %s on %s, length %s" ),
3106 std::swap( *
this, *
static_cast<PCB_ARC*
>( aImage ) );
3128 return std::min(
center.Distance(
m_Start ), (
double) INT_MAX / 2.0 );
3163 if(
GetRadius() >= (
double)INT_MAX/2.0 )
3172 && (
GetMid() -
GetEnd() ).EuclideanNorm() < aThreshold;
3201 return std::make_shared<SHAPE_SEGMENT>(
m_Start,
m_End, width );
3220 diameter = std::max( diameter,
GetWidth( layer ) );
3241 diameter = std::max( diameter,
Padstack().GetMaxHoleSize() );
3244 return std::make_shared<SHAPE_CIRCLE>(
m_Start, diameter / 2 );
3258 return std::make_shared<SHAPE_SEGMENT>(
GetStart(),
GetEnd(), width );
3260 return std::make_shared<SHAPE_ARC>( arc );
3265 int aError,
ERROR_LOC aErrorLoc,
bool ignoreLineWidth )
const
3267 wxASSERT_MSG( !ignoreLineWidth, wxT(
"IgnoreLineWidth has no meaning for tracks." ) );
3281 int width =
m_width + ( 2 * aClearance );
3292 int width =
m_width + ( 2 * aClearance );
3352 if( pmMap.
Choices().GetCount() == 0 )
3362 if( bdMap.
Choices().GetCount() == 0 )
3373 if( layerEnum.
Choices().GetCount() == 0 )
3381 auto viaDiameterPropertyValidator =
3384 if( !aItem || aItem->Type() !=
PCB_VIA_T )
3385 return std::nullopt;
3387 if( !aValue.CheckType<
int>() )
3388 return std::nullopt;
3392 std::optional<int> diameter = aValue.As<
int>();
3393 std::optional<int> drill =
via->GetDrillValue();
3395 std::optional<PCB_LAYER_ID> startLayer;
3398 startLayer =
via->Padstack().Drill().start;
3400 std::optional<PCB_LAYER_ID> endLayer;
3403 endLayer =
via->Padstack().Drill().end;
3405 int copperLayerCount =
via->BoardCopperLayerCount();
3407 if( std::optional<PCB_VIA::VIA_PARAMETER_ERROR> error =
3409 std::nullopt, std::nullopt, std::nullopt,
3410 std::nullopt, std::nullopt, std::nullopt,
3411 copperLayerCount ) )
3413 return std::make_unique<VALIDATION_ERROR_MSG>( error->m_Message );
3416 return std::nullopt;
3419 auto viaDrillPropertyValidator =
3422 if( !aItem || aItem->Type() !=
PCB_VIA_T )
3423 return std::nullopt;
3425 if( !aValue.CheckType<
int>() )
3426 return std::nullopt;
3430 std::optional<int> diameter =
via->GetFrontWidth();
3431 std::optional<int> drill = aValue.As<
int>();
3433 std::optional<PCB_LAYER_ID> startLayer;
3436 startLayer =
via->Padstack().Drill().start;
3438 std::optional<PCB_LAYER_ID> endLayer;
3441 endLayer =
via->Padstack().Drill().end;
3443 std::optional<int> secondaryDrill =
via->GetSecondaryDrillSize();
3445 std::optional<PCB_LAYER_ID> secondaryStart;
3448 secondaryStart =
via->GetSecondaryDrillStartLayer();
3450 std::optional<PCB_LAYER_ID> secondaryEnd;
3453 secondaryEnd =
via->GetSecondaryDrillEndLayer();
3455 std::optional<int> tertiaryDrill =
via->GetTertiaryDrillSize();
3457 std::optional<PCB_LAYER_ID> tertiaryStart;
3460 tertiaryStart =
via->GetTertiaryDrillStartLayer();
3462 std::optional<PCB_LAYER_ID> tertiaryEnd;
3465 tertiaryEnd =
via->GetTertiaryDrillEndLayer();
3467 int copperLayerCount =
via->BoardCopperLayerCount();
3469 if( std::optional<PCB_VIA::VIA_PARAMETER_ERROR> error =
3471 secondaryDrill, secondaryStart, secondaryEnd,
3472 tertiaryDrill, tertiaryStart, tertiaryEnd,
3473 copperLayerCount ) )
3475 return std::make_unique<VALIDATION_ERROR_MSG>( error->m_Message );
3478 return std::nullopt;
3481 auto viaStartLayerPropertyValidator =
3484 if( !aItem || aItem->Type() !=
PCB_VIA_T )
3485 return std::nullopt;
3491 else if( aValue.CheckType<
int>() )
3494 return std::nullopt;
3498 std::optional<int> diameter =
via->GetFrontWidth();
3499 std::optional<int> drill =
via->GetDrillValue();
3501 std::optional<PCB_LAYER_ID> endLayer;
3504 endLayer =
via->BottomLayer();
3506 std::optional<int> secondaryDrill =
via->GetSecondaryDrillSize();
3508 std::optional<PCB_LAYER_ID> secondaryStart;
3511 secondaryStart =
via->GetSecondaryDrillStartLayer();
3513 std::optional<PCB_LAYER_ID> secondaryEnd;
3516 secondaryEnd =
via->GetSecondaryDrillEndLayer();
3518 int copperLayerCount =
via->BoardCopperLayerCount();
3520 if( std::optional<PCB_VIA::VIA_PARAMETER_ERROR> error =
3522 secondaryDrill, secondaryStart, secondaryEnd,
3523 std::nullopt, std::nullopt, std::nullopt,
3524 copperLayerCount ) )
3526 return std::make_unique<VALIDATION_ERROR_MSG>( error->m_Message );
3529 return std::nullopt;
3532 auto viaEndLayerPropertyValidator =
3535 if( !aItem || aItem->Type() !=
PCB_VIA_T )
3536 return std::nullopt;
3542 else if( aValue.CheckType<
int>() )
3545 return std::nullopt;
3549 std::optional<int> diameter =
via->GetFrontWidth();
3550 std::optional<int> drill =
via->GetDrillValue();
3552 std::optional<PCB_LAYER_ID> startLayer;
3555 startLayer =
via->TopLayer();
3557 std::optional<int> secondaryDrill =
via->GetSecondaryDrillSize();
3559 std::optional<PCB_LAYER_ID> secondaryStart;
3562 secondaryStart =
via->GetSecondaryDrillStartLayer();
3564 std::optional<PCB_LAYER_ID> secondaryEnd;
3567 secondaryEnd =
via->GetSecondaryDrillEndLayer();
3569 int copperLayerCount =
via->BoardCopperLayerCount();
3571 if( std::optional<PCB_VIA::VIA_PARAMETER_ERROR> error =
3573 secondaryDrill, secondaryStart, secondaryEnd,
3574 std::nullopt, std::nullopt, std::nullopt,
3575 copperLayerCount ) )
3577 return std::make_unique<VALIDATION_ERROR_MSG>( error->m_Message );
3580 return std::nullopt;
3606 const wxString groupTechLayers =
_HKI(
"Technical Layers" );
3608 auto isExternalLayerTrack =
3634 const wxString groupVia =
_HKI(
"Via Properties" );
3635 const wxString groupBackdrill =
_HKI(
"Backdrill" );
3636 const wxString groupPostMachining =
_HKI(
"Post-machining" );
3765 groupPostMachining );
3770 groupPostMachining )
3776 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode =
via->GetFrontPostMachining();
3778 if( mode.has_value() )
3791 groupPostMachining )
3797 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode =
via->GetFrontPostMachining();
3799 if( mode.has_value() )
3809 groupPostMachining )
3815 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode =
via->GetFrontPostMachining();
3817 if( mode.has_value() )
3829 groupPostMachining )
3835 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode =
via->GetBackPostMachining();
3837 if( mode.has_value() )
3849 groupPostMachining )
3855 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode =
via->GetBackPostMachining();
3857 if( mode.has_value() )
3866 groupPostMachining )
3872 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode =
via->GetBackPostMachining();
3874 if( mode.has_value() )
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API 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
constexpr int ARC_LOW_DEF
BITMAPS
A list of all bitmap identifiers.
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
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
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
void PackNet(kiapi::board::types::Net *aProto) const
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
const wxString & GetDisplayNetname() const
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()
void SetTeardropsEnabled(bool aEnable)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
BOARD_STACKUP & GetStackupDescriptor()
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)
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
bool IsLocked() const override
virtual double GetCoverageArea(int aTextMargin) const
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const
Convert the item shape to a polyset.
virtual wxString LayerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
BOARD_ITEM & operator=(const BOARD_ITEM &aOther)
BOARD_ITEM_CONTAINER * GetParent() const
virtual int BoardCopperLayerCount() const
Return the total number of copper layers for the board that this item resides on.
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
virtual bool HasHole() const
Manage layers needed to make a physical board.
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
Information pertinent to a Pcbnew printed circuit board.
LENGTH_DELAY_CALCULATION * GetLengthCalculation() const
Returns the track length calculator.
std::tuple< int, double, double, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
int GetCopperLayerCount() const
const TRACKS & Tracks() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
bool IntersectsCircle(const Vec &aCenter, const int aRadius) const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
bool IsConnectedOnLayer(const BOARD_CONNECTED_ITEM *aItem, int aLayer, const std::initializer_list< KICAD_T > &aTypes={}) const
MINOPTMAX< int > & Value()
Design Rule Checker object that performs all the DRC tests.
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
EDA_ITEM_FLAGS GetFlags() 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.
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
static double lodScaleForThreshold(const KIGFX::VIEW *aView, int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
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...
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
bool IsLayerVisibleCached(int aLayer) const
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
static bool Contains(int aStart_layer, int aEnd_layer, int aTest_layer)
Class which calculates lengths (and associated routing statistics) in a BOARD context.
int64_t CalculateDelay(std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr) const
Calculates the electrical propagation delay of the given items.
LENGTH_DELAY_CALCULATION_ITEM GetLengthCalculationItem(const BOARD_CONNECTED_ITEM *aBoardItem) const
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
static const LSET & BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
static const LSET & AllLayersMask()
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
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.
static const LSET & FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
A collection of nets and the parameters used to route or test these nets.
Handle the data for a net.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
@ NORMAL
Shape is the same on all layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static constexpr PCB_LAYER_ID INNER_LAYERS
! The layer identifier to use for "inner layers" on top/inner/bottom padstacks
VECTOR2I GetPosition() const override
static std::unique_ptr< PCB_TRACK > CreateFromThreePoints(BOARD_ITEM *aParent, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Create a PCB_ARC through the three points, or a PCB_TRACK segment when they are straight.
bool IsDegenerated(int aThreshold=5) const
virtual void swapData(BOARD_ITEM *aImage) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
EDA_ANGLE GetArcAngleStart() const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
EDA_ANGLE GetArcAngleEnd() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetMid(const VECTOR2I &aMid)
EDA_ANGLE GetAngle() const
const VECTOR2I & GetMid() const
PCB_ARC(BOARD_ITEM *aParent)
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
VECTOR2I m_Mid
Arc mid point, halfway between start and end.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
bool operator==(const PCB_ARC &aOther) const
void CopyFrom(const BOARD_ITEM *aOther) override
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
virtual void SetLayerSet(const LSET &aLayers) override
int GetSolderMaskExpansion() const
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetHasSolderMask(bool aVal)
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void swapData(BOARD_ITEM *aImage) override
void SetEnd(const VECTOR2I &aEnd)
bool HasSolderMask() const
void SetStart(const VECTOR2I &aStart)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool ApproxCollinear(const PCB_TRACK &aTrack)
VECTOR2I m_End
Line end point.
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
std::optional< int > m_solderMaskMargin
void CopyFrom(const BOARD_ITEM *aOther) override
std::optional< int > GetLocalSolderMaskMargin() const
virtual double GetDelay() const
Get the time delay of the track.
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.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the track shape to a closed polygon.
const VECTOR2I & GetStart() const
bool operator==(const BOARD_ITEM &aOther) const override
VECTOR2I m_Start
Line start point.
wxString GetFriendlyName() const override
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
const VECTOR2I & GetEnd() const
PCB_TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
virtual MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
int m_width
Thickness of track (or arc) – no longer the width of a via.
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
bool GetIsFree() const
Check if the via is a free via (as opposed to one created on a track by the router).
int GetFrontPostMachiningSize() const
PCB_LAYER_ID BottomLayer() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
PLUGGING_MODE GetFrontPluggingMode() const
VECTOR2I GetPosition() const override
bool IsTented(PCB_LAYER_ID aLayer) const override
Checks if the given object is tented (its copper shape is covered by solder mask) on a given side of ...
void CopyFrom(const BOARD_ITEM *aOther) override
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
PCB_LAYER_ID GetTopBackdrillLayer() const
bool IsGhostLayer(PCB_LAYER_ID aLayer) const
void SetFrontPostMachiningDepth(int aDepth)
void SetCappingMode(CAPPING_MODE aMode)
void SetFrontCoveringMode(COVERING_MODE aMode)
wxString LayerMaskDescribe() const override
Return a string (to be shown to the user) describing a layer mask.
int GetBackPostMachiningDepth() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetBackPostMachiningAngle(int aAngle)
int GetBackPostMachiningAngle() const
COVERING_MODE GetBackCoveringMode() const
std::optional< int > GetTertiaryDrillSize() const
void SetTopBackdrillSize(std::optional< int > aSize)
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
ZONE_LAYER_OVERRIDE GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
std::optional< int > GetTopBackdrillSize() const
void SetBackdrillMode(BACKDRILL_MODE aMode)
void SetDrillDefault()
Set the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
void SetBottomBackdrillSize(std::optional< int > aSize)
void ClearZoneLayerOverrides()
CAPPING_MODE GetCappingMode() const
const PADSTACK & Padstack() const
void SetFrontTentingMode(TENTING_MODE aMode)
bool m_isFree
"Free" vias don't get their nets auto-updated
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetFrontPostMachiningDepth() const
static std::vector< std::vector< PCB_VIA * > > CollectMicroviaColumns(BOARD *aBoard)
Runs of microvias that land on one another, each ordered from its outermost hop down.
TENTING_MODE GetFrontTentingMode() const
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
void SetBottomLayer(PCB_LAYER_ID aLayer)
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Set the drill value for vias.
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
std::optional< int > GetSecondaryDrillSize() const
void SetPrimaryDrillCappedFlag(bool aCapped)
int GetSolderMaskExpansion() const
void SetSecondaryDrillStartLayer(PCB_LAYER_ID aLayer)
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
bool HasValidLayerPair(int aCopperLayerCount) const
void ClearSecondaryDrillSize()
void SetBackPostMachiningDepth(int aDepth)
void SetDrill(int aDrill)
PLUGGING_MODE GetBackPluggingMode() const
void SetBackPluggingMode(PLUGGING_MODE aMode)
MINOPTMAX< int > GetDrillConstraint(wxString *aSource=nullptr) const
void SetPadstackMode(PADSTACK::MODE aMode)
void SetBackTentingMode(TENTING_MODE aMode)
void SetIsFree(bool aFree=true)
void SetFrontPluggingMode(PLUGGING_MODE aMode)
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
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.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetFrontPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
bool operator==(const PCB_VIA &aOther) const
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
int GetFrontPostMachiningAngle() const
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
void SetFrontPostMachiningAngle(int aAngle)
void SetTopLayer(PCB_LAYER_ID aLayer)
FILLING_MODE GetFillingMode() const
int GetFrontWidth() const
void SetSizeFromRules(int aDiameter, int aDrill)
Give the via a uniform padstack sized from its diameter and hole rules.
std::array< std::atomic< ZONE_LAYER_OVERRIDE >, MAX_CU_LAYERS > m_zoneLayerOverrides
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
For a via m_layer contains the top layer, the other layer is in m_bottomLayer/.
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
bool IsOnCopperLayer() const override
void SetFrontPostMachiningSize(int aSize)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
PCB_LAYER_ID GetBottomBackdrillLayer() const
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
static std::optional< VIA_PARAMETER_ERROR > ValidateViaParameters(std::optional< int > aDiameter, std::optional< int > aPrimaryDrill, std::optional< PCB_LAYER_ID > aPrimaryStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aPrimaryEndLayer=std::nullopt, std::optional< int > aSecondaryDrill=std::nullopt, std::optional< PCB_LAYER_ID > aSecondaryStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aSecondaryEndLayer=std::nullopt, std::optional< int > aTertiaryDrill=std::nullopt, std::optional< PCB_LAYER_ID > aTertiaryStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aTertiaryEndLayer=std::nullopt, int aCopperLayerCount=0)
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
virtual void SetLayerSet(const LSET &aLayers) override
Note SetLayerSet() initialize the first and last copper layers connected by the via.
void GetOutermostConnectedLayers(PCB_LAYER_ID *aTopmost, PCB_LAYER_ID *aBottommost) const
Return the top-most and bottom-most connected layers.
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
void SanitizeLayers()
Check so that the layers are correct depending on the type of via, and so that the top actually is on...
int GetWidth() const override
void SetBackPostMachining(const std::optional< PAD_DRILL_POST_MACHINING_MODE > &aMode)
PCB_VIA & operator=(const PCB_VIA &aOther)
void swapData(BOARD_ITEM *aImage) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetFillingMode(FILLING_MODE aMode)
bool GetIsNotFree() const
PCB_VIA(BOARD_ITEM *aParent)
void SetPrimaryDrillFilledFlag(bool aFilled)
std::optional< int > GetBottomBackdrillSize() const
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void SetViaType(VIATYPE aViaType)
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
TENTING_MODE GetBackTentingMode() const
PCB_LAYER_ID TopLayer() const
void ClearTertiaryDrillSize()
VIATYPE m_viaType
through, blind/buried or micro
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
int GetBackPostMachiningSize() const
void SetTertiaryDrillSize(const VECTOR2I &aSize)
void SetIsNotFree(bool aNotFree)
void SetSecondaryDrillSize(const VECTOR2I &aSize)
COVERING_MODE GetFrontCoveringMode() const
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
bool sameZoneLayerOverrides(const PCB_VIA &aOther) const
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
void SetFrontWidth(int aWidth)
VIATYPE GetViaType() const
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const override
BACKDRILL_MODE GetBackdrillMode() const
void SetWidth(int aWidth) override
void SetBackCoveringMode(COVERING_MODE aMode)
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Return the 2 layers used by the via (the via actually uses all layers between these 2 layers)
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetBackPostMachiningSize(int aSize)
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
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 SEG::ecoord Square(int a)
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
const VECTOR2I & GetArcMid() const
const VECTOR2I & GetP1() const
bool IsEffectiveLine() const
const VECTOR2I & GetP0() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
double Area()
Return the area of this poly set.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString MessageTextFromMinOptMax(const MINOPTMAX< int > &aValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
@ ANNULAR_WIDTH_CONSTRAINT
@ VIA_DIAMETER_CONSTRAINT
@ SILK_CLEARANCE_CONSTRAINT
@ HOLE_CLEARANCE_CONSTRAINT
@ SOLDER_MASK_EXPANSION_CONSTRAINT
@ PHYSICAL_CLEARANCE_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
#define PCB_EDIT_FRAME_NAME
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define ROUTER_TRANSIENT
transient items that should NOT be cached
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#define STARTPOINT
When a line is selected, these flags indicate which.
a few functions useful in geometry calculations.
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
bool IsSolderMaskLayer(int aLayer)
bool IsDrillSymbolLayer(int aLayer)
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
constexpr PCB_LAYER_ID PCBNEW_LAYER_ID_START
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
@ DEFAULT
Flashing follows connectivity.
@ ALWAYS_FLASHED
Always flashed for connectivity.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
bool IsClearanceLayer(int aLayer)
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_DRILL_SYMBOL_START
Drill symbols, one channel per board layer.
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
size_t CopperLayerToOrdinal(PCB_LAYER_ID aLayer)
Converts KiCad copper layer enum to an ordinal between the front and back layers.
bool IsViaCopperLayer(int aLayer)
#define DRILL_SYMBOL_LAYER_FOR(boardLayer)
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
bool IsHoleLayer(int aLayer)
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
@ LEFT_RIGHT
Flip left to right (around the Y axis)
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
void PackZoneLayerOverrides(google::protobuf::RepeatedPtrField< types::ZoneLayerOverrideEntry > *aOutput, const std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > &aInput)
void UnpackTeardropSettings(TEARDROP_PARAMETERS &aOutput, const types::PadTeardropSettings &aProto)
void UnpackZoneLayerOverrides(std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > &aOutput, const google::protobuf::RepeatedPtrField< types::ZoneLayerOverrideEntry > &aInput)
void PackTeardropSettings(types::PadTeardropSettings &aOutput, const TEARDROP_PARAMETERS &aParams)
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
@ REMOVE_EXCEPT_START_AND_END
PCBNEW_SETTINGS * pcbconfig()
static bool hasLayerOrdinal(PCB_LAYER_ID aLayer)
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
#define GEOMETRY_MIN_SIZE
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define ENUM_TO_WXANY(type)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
@ PT_DECIDEGREE
Angle expressed in decidegrees.
@ PT_SIZE
Size expressed in distance units (mm/inch)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
wxString UnescapeString(const wxString &aSource)
The properties of a padstack drill.
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
std::optional< PAD_DRILL_POST_MACHINING_MODE > mode
Struct to control which optimisations the length calculation code runs on the given path objects.
bool operator()(const PCB_TRACK *aFirst, const PCB_TRACK *aSecond) const
wxString result
Test unit parsing edge cases and error handling.
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
bool IsStraightArc(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
VECTOR2< int64_t > VECTOR2L