56#include <wx/richmsgdlg.h>
60#define MULTICHANNEL_EXTRA_DEBUG
67 std::vector<wxString> refs;
74 refs.push_back( fp->GetReferenceAsString() );
77 std::sort( refs.begin(), refs.end(),
78 [](
const wxString& aLhs,
const wxString& aRhs )
80 return aLhs.CmpNoCase( aRhs ) < 0;
88 size_t componentsOnLine = 0;
90 for(
const wxString& ref : refs )
92 if( componentsOnLine == 10 )
106 if( !line.IsEmpty() )
119 const std::vector<wxString>& aReasons )
121 if( !aParent || aReasons.empty() )
126 for(
size_t idx = 0; idx < aReasons.size(); ++idx )
129 reasonText += wxT(
"\n" );
131 reasonText += aReasons[idx];
134 wxRichMessageDialog dlg( aParent, aSummary,
_(
"Topology mismatch" ), wxICON_ERROR | wxOK );
135 dlg.ShowDetailedText( reasonText );
151 const std::vector<wxString>& aReasons )
const
153 wxWindow* parent = aParent ? aParent :
frame();
166 std::set<FOOTPRINT*>& aComponents )
168 if( !aRuleArea || !aRuleArea->
m_zone )
179 aComponents.insert(
static_cast<FOOTPRINT*
>( item ) );
182 return (
int) aComponents.size();
191 [&](
const wxString& aMessage,
int aOffset )
221 auto ok = compiler.
Compile( ruleText, &ucode, &preflightCtx );
235 fp->GetSheetname() );
237 aComponents.insert( fp );
247 if( !aRuleArea || !aRuleArea->
m_zone )
272 if( !boardItem->IsConnected() || boardItem->Type() ==
PCB_ZONE_T )
273 aItems.insert( boardItem );
277 return aItems.size() > 0;
285 bool zoneOnBoard =
false;
289 if( zone == aRuleArea->
m_zone )
313 if( !boardItem->IsConnected() || boardItem->Type() ==
PCB_ZONE_T )
314 aItems.insert( boardItem );
319 return aItems.size() > 0;
328 [&](
const wxString& aMessage,
int aOffset )
339 wxString ruleText = wxString::Format( wxT(
"A.enclosedByArea('%s')" ),
342 if( !compiler.
Compile( ruleText, &ucode, &preflightCtx ) )
349 auto val = ucode.
Run( &ctx );
351 if( val->AsDouble() != 0.0 )
352 aItems.insert( aItem );
357 if( zone == aRuleArea->
m_zone )
365 if( !drawing->IsConnected() )
366 testAndAdd( drawing );
375 std::set<FOOTPRINT*> rv;
377 if( aSheetName.EndsWith( wxT(
"/" ) ) )
378 aSheetName.RemoveLast();
380 wxString childPrefix = aSheetName + wxT(
"/" );
384 auto sn = fp->GetSheetname();
386 if( sn.EndsWith( wxT(
"/" ) ) )
389 if( sn == aSheetName || sn.StartsWith( childPrefix ) )
400 std::set<FOOTPRINT*> rv;
404 if( fp->GetComponentClass()->ContainsClassName( aComponentClassName ) )
414 std::set<FOOTPRINT*> rv;
418 if(
group->GetName() == aGroupName )
423 rv.insert(
static_cast<FOOTPRINT*
>( item ) );
434 std::set<BOARD_ITEM*> rv;
438 if(
group->GetName() != aGroupName )
443 if( item->IsBOARD_ITEM() )
444 rv.insert(
static_cast<BOARD_ITEM*
>( item ) );
454 std::vector<VECTOR2I> bbCorners;
455 bbCorners.reserve( aFootprints.size() * 4 );
459 const BOX2I bb = fp->GetBoundingBox(
false ).GetInflated( aMargin );
463 std::vector<VECTOR2I> hullVertices;
474 std::vector<VECTOR2I> bbCorners;
475 bbCorners.reserve( aItems.size() * 4 );
479 BOX2I bb = item->GetBoundingBox();
482 bb =
static_cast<FOOTPRINT*
>( item )->GetBoundingBox(
false );
487 std::vector<VECTOR2I> hullVertices;
499 using PathAndName = std::pair<wxString, wxString>;
500 std::set<PathAndName> uniqueSheets;
501 std::set<wxString> uniqueComponentClasses;
502 std::set<wxString> uniqueGroups;
508 uniqueSheets.insert( PathAndName( fp->GetSheetname(), fp->GetSheetfile() ) );
513 uniqueComponentClasses.insert( singleClass->GetName() );
515 if( fp->GetParentGroup() && !fp->GetParentGroup()->GetName().IsEmpty() )
516 uniqueGroups.insert( fp->GetParentGroup()->GetName() );
519 for(
const PathAndName& sheet : uniqueSheets )
528 m_areas.m_areas.push_back( ent );
533 (
int)
m_areas.m_areas.size() );
536 for(
const wxString& compClass : uniqueComponentClasses )
544 m_areas.m_areas.push_back( ent );
548 static_cast<int>(
m_areas.m_areas.size() ) );
551 for(
const wxString& groupName : uniqueGroups )
559 m_areas.m_areas.push_back( ent );
563 static_cast<int>(
m_areas.m_areas.size() ) );
574 if( !zone->GetIsRuleArea() )
577 if( !zone->GetPlacementAreaEnabled() )
585 area.
m_center = zone->Outline()->COutline( 0 ).Centre();
589 m_areas.m_areas.push_back( area );
619 std::vector<ZONE*> refRAs;
621 auto isSelectedItemAnRA =
627 ZONE* zone =
static_cast<ZONE*
>( aItem );
640 if(
ZONE* zone = isSelectedItemAnRA( item ) )
642 refRAs.push_back( zone );
650 if(
ZONE* grpZone = isSelectedItemAnRA( grpItem ) )
651 refRAs.push_back( grpZone );
656 if( refRAs.size() != 1 )
661 _(
"Select a reference Rule Area to copy from..." ),
664 return isSelectedItemAnRA( aItem ) !=
nullptr;
678 if(
m_areas.m_areas.size() <= 1 )
680 frame()->ShowInfoBarError(
_(
"No Rule Areas to repeat layout to have been found." ),
true );
700 if( ra.
m_zone == aRefZone )
712 std::vector<RULE_AREA*> targets;
719 targets.push_back( &ra );
723 if( targets.empty() )
726 int total =
static_cast<int>( targets.size() );
727 std::atomic<int> completed( 0 );
728 std::atomic<bool> cancelled(
false );
729 std::atomic<int> matchedComponents( 0 );
730 std::atomic<int> totalComponents( 0 );
745 auto future =
tp.submit_task(
746 [
this, refRA, &targets, &completed, &cancelled, &matchedComponents, &isoParams]()
750 if( cancelled.load( std::memory_order_relaxed ) )
753 matchedComponents.store( 0, std::memory_order_relaxed );
757 completed.fetch_add( 1, std::memory_order_relaxed );
763 std::unique_ptr<WX_PROGRESS_REPORTER>
reporter;
764 auto startTime = std::chrono::steady_clock::now();
765 double highWaterMark = 0.0;
767 while( future.wait_for( std::chrono::milliseconds( 100 ) ) != std::future_status::ready )
771 auto elapsed = std::chrono::steady_clock::now() - startTime;
773 if( elapsed > std::chrono::seconds( 1 ) )
775 reporter = std::make_unique<WX_PROGRESS_REPORTER>(
781 wxLog::FlushActive();
787 int done = completed.load( std::memory_order_relaxed );
788 int matched = matchedComponents.load( std::memory_order_relaxed );
789 int compTotal = totalComponents.load( std::memory_order_relaxed );
791 double fraction = ( compTotal > 0 )
792 ?
static_cast<double>( matched ) / compTotal
794 double progress =
static_cast<double>( done + fraction ) / total;
796 if( progress > highWaterMark )
797 highWaterMark = progress;
799 reporter->SetCurrentProgress( highWaterMark );
801 _(
"Resolving topology %d of %d (%d/%d components)" ),
802 done + 1, total, matched, compTotal ) );
805 cancelled.store(
true, std::memory_order_relaxed );
814 if( cancelled.load( std::memory_order_relaxed ) )
826 wxString* aErrorOut )
828 wxCHECK_MSG( aRefArea.
m_zone, -1, wxT(
"Reference Rule Area has no zone." ) );
829 wxCHECK_MSG( aTargetArea.
m_zone, -1, wxT(
"Target Rule Area has no zone." ) );
831 const bool silent = aErrorOut !=
nullptr;
833 auto reportError = [&](
const wxString& aMsg )
837 else if(
Pgm().IsGUI() )
838 frame()->ShowInfoBarError( aMsg,
true );
849 else if(
Pgm().IsGUI() )
851 wxString summary = wxString::Format(
_(
"Rule Area topologies do not match: %s" ), compat.
m_errorMsg );
858 std::optional<BOARD_COMMIT> localCommit;
860 if( !aExternalCommit )
861 localCommit.emplace(
GetManager(),
true,
false );
863 BOARD_COMMIT& commit = aExternalCommit ? *aExternalCommit : *localCommit;
876 auto errMsg = wxString::Format(
_(
"Copy Rule Area contents failed between rule areas '%s' and '%s'." ),
879 if( !aExternalCommit )
882 reportError( errMsg );
896 if( !aExternalCommit )
899 reportError(
_(
"Target group does not have a group." ) );
909 group->AddItem( item );
913 if( !aExternalCommit )
914 commit.
Push(
_(
"Repeat layout" ) );
926 for(
auto& [targetArea, compatData] :
m_areas.m_compatMap )
928 if( !compatData.m_doCopy )
931 targetArea->m_ruleName );
935 if( !compatData.m_isOk )
940 auto errMsg = wxString::Format(
_(
"Copy Rule Area contents failed between rule areas '%s' and '%s'." ),
941 m_areas.m_refRA->m_zone->GetZoneName(),
942 targetArea->m_zone->GetZoneName() );
947 frame()->ShowInfoBarError( errMsg,
true );
956 if(
m_areas.m_options.m_groupItems )
958 for(
const auto& [targetArea, compatData] :
m_areas.m_compatMap )
960 if( compatData.m_groupableItems.size() < 2 )
969 for(
BOARD_ITEM* item : compatData.m_groupableItems )
972 group->AddItem( item );
977 commit.
Push(
_(
"Repeat layout" ) );
980 frame()->ShowInfoBarMsg( wxString::Format(
_(
"Copied to %d Rule Areas." ), totalCopied ),
true );
1000 if( ( c >=
'a' && c <=
'z' ) || ( c >=
'A' && c <=
'Z' ) || ( c ==
'_' ) )
1011 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
1014 if( !aRuleArea || !aRuleArea->
m_zone )
1043 if(
EDA_GROUP* parent = bci->GetParentGroup() )
1049 if( bci->IsConnected() )
1050 aOutput.insert( bci );
1054 return (
int) aOutput.size();
1061 bool zoneOnBoard =
false;
1065 if( zone == aRuleArea->
m_zone )
1079 if( aOutput.contains( aItem ) )
1083 if(
EDA_GROUP* parent = aItem->GetParentGroup() )
1093 aItem->TransformShapeToPolygon( itemShape, aItem->GetLayer(), 0, maxError,
ERROR_OUTSIDE );
1102 aOutput.insert( aItem );
1108 enclosedByZone( track );
1112 if( drawing->IsConnected() )
1125 [&](
const wxString& aMessage,
int aOffset )
1136 wxString ruleText = wxString::Format( wxT(
"A.enclosedByArea('%s')" ),
1142 if( aOutput.contains( aItem ) )
1150 aOutput.insert( aItem );
1155 if( compiler.
Compile( ruleText, &ucode, &preflightCtx ) )
1158 testAndAdd( track );
1162 if( drawing->IsConnected() )
1168 if( generator->GetGeneratorType() != wxT(
"tuning_pattern" ) )
1171 if( !generator->HitTest( aRAPoly.
Outline( 0 ),
false ) )
1174 for(
EDA_ITEM* member : generator->GetItems() )
1178 if( !aOutput.contains( bci ) )
1180 aOutput.insert( bci );
1209 targetAnchorFp = targetFP;
1217 if( targetAnchorFp )
1224 disp = newpos - oldpos;
1237 newTargetOutline.
Move( disp );
1252 std::vector<std::pair<BOARD_ITEM*, BOARD_ITEM*>> groupFixupPairs;
1253 std::set<BOARD_ITEM*> reproducedSourceItems;
1255 auto fixupParentGroup =
1260 destItem->SetParentGroup(
nullptr );
1262 if( !preserveGroups )
1266 groupFixupPairs.emplace_back( sourceItem, destItem );
1268 reproducedSourceItems.insert( sourceItem );
1274 bool targetZoneOnBoard =
false;
1276 if( aTargetArea->
m_zone )
1280 if( z == aTargetArea->
m_zone )
1282 targetZoneOnBoard =
true;
1288 if( targetZoneOnBoard )
1296 if( preserveGroups )
1299 groupFixupPairs.emplace_back( aRefArea->
m_zone, aTargetArea->
m_zone );
1301 reproducedSourceItems.insert( aRefArea->
m_zone );
1307 std::set<BOARD_CONNECTED_ITEM*> refRouting;
1308 std::set<BOARD_CONNECTED_ITEM*> targetRouting;
1314 std::set<int> targc;
1318 for(
PAD*
pad : refFP->Pads() )
1319 refc.insert(
pad->GetNetCode() );
1321 for(
PAD*
pad : targetFP->Pads() )
1322 targc.insert(
pad->GetNetCode() );
1384 fixupParentGroup( item,
copied );
1398 if( !targetGroup && !aTargetArea->
m_components.empty() )
1399 targetGroup = ( *aTargetArea->
m_components.begin() )->GetParentGroup();
1403 std::vector<PCB_GENERATOR*> targetGenerators;
1408 targetGenerators.push_back(
static_cast<PCB_GENERATOR*
>( member ) );
1416 aCommit->
Remove( child );
1432 clone->
Move( disp );
1433 aCommit->
Add( clone );
1443 aCommit->
Add( child );
1454 std::set<BOARD_ITEM*> sourceItems;
1455 std::set<BOARD_ITEM*> targetItems;
1473 if( item->GetParent() && item->GetParent()->Type() ==
PCB_FOOTPRINT_T )
1490 ZONE* zone =
static_cast<ZONE*
>( item );
1513 if( item->GetParent() && item->GetParent()->Type() ==
PCB_FOOTPRINT_T )
1523 ZONE* zone =
static_cast<ZONE*
>( item );
1525 if( !skipLayerFilter )
1527 LSET allowedLayers =
1535 ZONE* targetZone =
static_cast<ZONE*
>( item->Duplicate(
false ) );
1542 if( !skipLayerFilter )
1556 fixupParentGroup( item,
copied );
1574 refFP->GetReference() );
1580 refFP->GetReference() );
1587 && !refFP->GetEffectiveShape( refFP->GetLayer() )->Collide( &refPoly, 0 ) )
1595 aCommit->
Modify( targetFP );
1597 targetFP->SetLayerAndFlip( refFP->GetLayer() );
1598 targetFP->SetOrientation( refFP->GetOrientation() );
1599 targetFP->SetPosition( refFP->GetPosition() );
1600 targetFP->Rotate(
VECTOR2( 0, 0 ), rot );
1601 targetFP->Move( disp );
1603 for(
PCB_FIELD* refField : refFP->GetFields() )
1605 wxCHECK2( refField,
continue );
1607 PCB_FIELD* targetField = targetFP->GetField( refField->GetName() );
1612 targetField->
SetLayerSet( refField->GetLayerSet() );
1613 targetField->
SetVisible( refField->IsVisible() );
1615 targetField->
SetPosition( refField->GetPosition() );
1617 targetField->
Move( disp );
1624 std::set<PCB_TEXT*> consumedTargets;
1626 for(
BOARD_ITEM* refItem : refFP->GraphicalItems() )
1634 for(
BOARD_ITEM* targetItem : targetFP->GraphicalItems() )
1641 if( consumedTargets.contains( candidate ) || candidate->
GetText() != refText->
GetText() )
1646 targetText = candidate;
1655 consumedTargets.insert( targetText );
1662 targetText->
Move( disp );
1667 targetFP->Models() = refFP->Models();
1674 if( preserveGroups && refFP->GetParentGroup() )
1675 groupFixupPairs.emplace_back( refFP, targetFP );
1677 if( preserveGroups )
1678 reproducedSourceItems.insert( refFP );
1685 if( preserveGroups && !groupFixupPairs.empty() )
1687 std::map<EDA_GROUP*, EDA_GROUP*> groupMap;
1688 std::map<EDA_GROUP*, bool> fullyReproducedCache;
1690 auto groupFullyReproduced =
1693 if(
auto it = fullyReproducedCache.find( aGroup ); it != fullyReproducedCache.end() )
1696 bool reproduced =
true;
1698 for(
EDA_ITEM* member : aGroup->GetItems() )
1702 if( !member->IsBOARD_ITEM()
1703 || !reproducedSourceItems.contains(
static_cast<BOARD_ITEM*
>( member ) ) )
1710 fullyReproducedCache[aGroup] = reproduced;
1714 for(
const auto& [sourceItem, destItem] : groupFixupPairs )
1718 if( !parentGroup || !groupFullyReproduced( parentGroup ) )
1721 if( !groupMap.contains( parentGroup ) )
1731 newGroup->
Move( disp );
1734 groupMap[parentGroup] = newGroup;
1735 aCommit->
Add( newGroup );
1740 if(
EDA_GROUP* oldGroup = destItem->GetParentGroup() )
1742 if( oldGroup != groupMap[parentGroup] )
1743 aCommit->
Modify( oldGroup->AsEdaItem() );
1746 groupMap[parentGroup]->AddItem( destItem );
1766 if( aComponentMatches.empty() )
1773 const std::vector<BOARD_CONNECTED_ITEM*> refConnectedPads = connectivity->
GetNetItems( aRef->
GetNetCode(),
1781 const PAD* refPad =
static_cast<const PAD*
>( refConItem );
1784 if( aComponentMatches.contains( sourceFootprint ) )
1786 const FOOTPRINT* targetFootprint = aComponentMatches[sourceFootprint];
1787 std::vector<const PAD*> targetFpPads = targetFootprint->
GetPads( refPad->
GetNumber() );
1789 if( !targetFpPads.empty() )
1791 int targetNetCode = targetFpPads[0]->GetNet()->GetNetCode();
1802 const std::set<FOOTPRINT*>& aFootprints,
1803 const std::unordered_set<EDA_ITEM*>& aItems )
1805 std::vector<NETINFO_ITEM*> created;
1806 std::map<int, NETINFO_ITEM*> remap;
1812 auto isAutoName = [](
const wxString& aName )
1814 return aName.StartsWith( wxT(
"Net-(" ) ) || aName.StartsWith( wxT(
"unconnected-" ) );
1819 int code = aItem->GetNetCode();
1826 if( !oldNet || !isAutoName( oldNet->
GetNetname() ) )
1829 auto it = remap.find( code );
1831 if( it == remap.end() )
1837 name = wxString::Format( wxT(
"__dbapply_%d_%d" ), code, counter++ );
1841 aBoard->
Add( newNet );
1842 created.push_back( newNet );
1843 it = remap.emplace( code, newNet ).first;
1846 aItem->SetNet( it->second );
1851 for(
PAD*
pad : fp->Pads() )
1872 if( aRef.empty() || aRef.size() != aTarget.size() )
1881 std::map<KIID, FOOTPRINT*> targetByUuid;
1885 KIID uuid = symbolUuid( fp );
1888 if( uuid ==
niluuid || !targetByUuid.emplace( uuid, fp ).second )
1893 std::set<FOOTPRINT*> used;
1897 KIID uuid = symbolUuid( refFp );
1902 auto it = targetByUuid.find( uuid );
1904 if( it == targetByUuid.end() )
1910 if( refFp->GetFPID() != targetFp->
GetFPID() || refFp->Pads().size() != targetFp->
Pads().size() )
1913 if( !used.insert( targetFp ).second )
1916 result[refFp] = targetFp;
1919 aResult = std::move(
result );
1946 std::set<FOOTPRINT*> shared;
1949 std::inserter( shared, shared.begin() ) );
1951 if( !shared.empty() )
1955 aMatches.
m_errorMsg =
_(
"Target Rule Area shares components with the reference area" );
1958 _(
"This target Rule Area selects the same components as the reference area. "
1959 "Repeat layout cannot copy a Rule Area onto itself. Give each placement Rule "
1960 "Area a distinct sheet, component class or group." ) );
1961 aMatches.
m_mismatchReasons.push_back( wxString::Format(
_(
"Shared components:\n%s" ),
1979 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> mismatchReasons;
1983 mismatchReasons, aParams );
1995 if( !status && !cancelled
2002 aMatches.
m_isOk = status;
2013 for(
const auto& reason : mismatchReasons )
2015 if( reason.m_reason.IsEmpty() )
2018 if( !reason.m_reference.IsEmpty() && !reason.m_candidate.IsEmpty() )
2023 reason.m_reason ) );
2025 else if( !reason.m_reference.IsEmpty() )
2029 reason.m_reason ) );
2042 wxString::Format(
_(
"Reference area total components: %d" ), (
int) aRefArea->
m_components.size() ) );
2043 aMatches.
m_mismatchReasons.push_back( wxString::Format(
_(
"Reference area components:\n%s" ),
2046 wxString::Format(
_(
"Target area total components: %d" ), (
int) aTargetArea->
m_components.size() ) );
2047 aMatches.
m_mismatchReasons.push_back( wxString::Format(
_(
"Target area components:\n%s" ),
2058 const std::unordered_set<BOARD_ITEM*>& aItemsToRemove )
2064 std::vector<EDA_ITEM*> pruneList;
2070 if( refItem->m_Uuid == testItem->m_Uuid )
2071 pruneList.push_back( refItem );
2075 if( !pruneList.empty() )
2080 group->RemoveItem( item );
2082 if(
group->GetItems().size() < 2 )
2097 if(
m_areas.m_areas.size() <= 1 )
2099 frame()->ShowInfoBarError(
_(
"Cannot auto-generate any placement areas because the "
2100 "schematic has only one or no hierarchical sheets, "
2101 "groups, or component classes." ),
2109 if( ret != wxID_OK )
2115 if( !zone->GetIsRuleArea() )
2118 if( !zone->GetPlacementAreaEnabled() )
2121 std::set<FOOTPRINT*> components;
2124 zoneRA.
m_sourceType = zone->GetPlacementAreaSourceType();
2127 if( components.empty() )
2137 wxT(
"Placement rule area for sheet '%s' already exists as '%s'\n" ),
2143 wxT(
"Placement rule area for component class '%s' already exists as '%s'\n" ),
2149 wxT(
"Placement rule area for group '%s' already exists as '%s'\n" ),
2183 if( groupItems.empty() )
2186 wxT(
"Skipping placement rule area generation for source group '%s': group has no board items." ),
2198 std::unique_ptr<ZONE> newZone(
new ZONE(
board() ) );
2201 newZone->SetZoneName( wxString::Format( wxT(
"auto-placement-area-%s" ), ra.
m_sheetPath ) );
2203 newZone->SetZoneName( wxString::Format( wxT(
"auto-placement-area-%s" ), ra.
m_componentClass ) );
2205 newZone->SetZoneName( wxString::Format( wxT(
"auto-placement-area-%s" ), ra.
m_groupName ) );
2208 newZone->GetZoneName(),
2211 newZone->SetIsRuleArea(
true );
2213 newZone->SetPlacementAreaEnabled(
true );
2214 newZone->SetDoNotAllowZoneFills(
false );
2215 newZone->SetDoNotAllowVias(
false );
2216 newZone->SetDoNotAllowTracks(
false );
2217 newZone->SetDoNotAllowPads(
false );
2218 newZone->SetDoNotAllowFootprints(
false );
2223 newZone->SetPlacementAreaSource( ra.
m_sheetPath );
2233 newZone->SetPlacementAreaSource( ra.
m_groupName );
2236 newZone->AddPolygon( raOutline );
2244 ra.
m_zone = newZone.release();
2251 if(
m_areas.m_options.m_groupItems )
2265 std::unordered_set<BOARD_ITEM*> toPrune;
2270 toPrune.insert( ra.
m_zone );
2284 group->AddItem( fp );
2289 commit.
Push(
_(
"Auto-generate placement rule areas" ) );
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayerSet(const LSET &aLayers)
virtual bool IsKnockout() const
virtual void SetIsKnockout(bool aKnockout)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
FOOTPRINT * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr BOX2< Vec > GetInflated(coord_type aDx, coord_type aDy) const
Get a new rectangle that is this one, inflated by aDx and aDy.
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
A lightweight representation of a component class.
const std::vector< COMPONENT_CLASS * > & GetConstituentClasses() const
Fetches a vector of the constituent classes for this (effective) class.
const std::vector< BOARD_CONNECTED_ITEM * > GetNetItems(int aNetCode, const std::vector< KICAD_T > &aTypes) const
Function GetNetItems() Returns the list of items that belong to a certain net.
A set of EDA_ITEMs (i.e., without duplicates).
std::unordered_set< EDA_ITEM * > & GetItems()
virtual EDA_ITEM * AsEdaItem()=0
A base class for most all the KiCad significant classes used in schematics and boards.
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParentGroup(EDA_GROUP *aGroup)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
virtual void SetVisible(bool aVisible)
const TEXT_ATTRIBUTES & GetAttributes() const
wxString AsString() const
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
VALUE * Run(CONTEXT *ctx)
virtual double AsDouble() const
LSET is a set of PCB_LAYER_IDs.
bool ContainsAll(const LSET &aLayers) const
See if this layer set contains all layers in another set.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Handle the data for a net.
const wxString & GetNetname() const
const wxString & GetNumber() const
void SetItems(BOARD_ITEM *a, BOARD_ITEM *b=nullptr)
static TOOL_ACTION repeatLayout
static TOOL_ACTION generatePlacementRuleAreas
static TOOL_ACTION selectItemInteractively
Selection of reference points/items.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
A set of BOARD_ITEMs (i.e., without duplicates).
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
virtual VECTOR2I GetPosition() const override
virtual void SetPosition(const VECTOR2I &aPos) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Move(const VECTOR2I &aVector) override
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
virtual void CacheTriangulation(bool aSimplify=false, const TASK_SUBMITTER &aSubmitter={})
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static std::unique_ptr< CONNECTION_GRAPH > BuildFromFootprintSet(const std::set< FOOTPRINT * > &aFps, const std::set< FOOTPRINT * > &aOtherChannelFps={})
Define a general 2D-vector/point.
Handle a list of polygons defining a copper zone.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
wxString GetPlacementAreaSource() const
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
SHAPE_POLY_SET * Outline()
const wxString & GetZoneName() const
bool GetPlacementAreaEnabled() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void UnHatchBorder()
Clear the zone's hatch.
void RemoveAllContours(void)
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
SHAPE_LINE_CHAIN RectifyPolygon(const SHAPE_LINE_CHAIN &aPoly)
void CollectBoxCorners(const BOX2I &aBox, std::vector< VECTOR2I > &aCorners)
Add the 4 corners of a BOX2I to a vector.
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Class to handle a set of BOARD_ITEMs.
PGM_BASE & Pgm()
The global program "get" accessor.
Utility functions for working with shapes.
void AccumulateDescription(wxString &aDesc, const wxString &aItem)
Utility to build comma separated lists in messages.
bool m_connectedRoutingOnly
bool m_includeLockedItems
std::vector< wxString > m_mismatchReasons
std::unordered_set< BOARD_ITEM * > m_affectedItems
Filled in by copyRuleAreaContents with items that were affected by the copy operation.
TMATCH::COMPONENT_MATCHES m_matchingComponents
std::unordered_set< BOARD_ITEM * > m_groupableItems
Filled in by copyRuleAreaContents with affected items that can be grouped together.
std::unordered_set< EDA_ITEM * > m_designBlockItems
PLACEMENT_SOURCE_T m_sourceType
wxString m_componentClass
std::set< FOOTPRINT * > m_components
std::atomic< bool > * m_cancelled
std::atomic< int > * m_matchedComponents
std::atomic< int > * m_totalComponents
IbisParser parser & reporter
wxString result
Test unit parsing edge cases and error handling.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< int32_t > VECTOR2I