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 ) )
417 aOut.insert(
static_cast<FOOTPRINT*
>( item ) );
431 else if( item->IsBOARD_ITEM() )
432 aOut.insert(
static_cast<BOARD_ITEM*
>( item ) );
439 std::set<FOOTPRINT*> rv;
443 if(
group->GetName() == aGroupName )
453 std::set<BOARD_ITEM*> rv;
457 if(
group->GetName() != aGroupName )
462 if( item->IsBOARD_ITEM() )
463 rv.insert(
static_cast<BOARD_ITEM*
>( item ) );
473 std::vector<VECTOR2I> bbCorners;
474 bbCorners.reserve( aFootprints.size() * 4 );
478 const BOX2I bb = fp->GetBoundingBox(
false ).GetInflated( aMargin );
482 std::vector<VECTOR2I> hullVertices;
493 std::vector<VECTOR2I> bbCorners;
494 bbCorners.reserve( aItems.size() * 4 );
498 BOX2I bb = item->GetBoundingBox();
501 bb =
static_cast<FOOTPRINT*
>( item )->GetBoundingBox(
false );
506 std::vector<VECTOR2I> hullVertices;
520 std::vector<wxString> segments;
523 for( wxUniChar ch : aSheetName )
528 segments.push_back( cur );
539 segments.push_back( cur );
541 std::vector<wxString> rv;
542 wxString prefix = wxT(
"/" );
544 for(
size_t i = 0; i + 1 < segments.size(); ++i )
546 prefix += segments[i] + wxT(
"/" );
547 rv.push_back( prefix );
558 std::map<wxString, wxString> uniqueSheets;
559 std::set<wxString> uniqueComponentClasses;
560 std::set<wxString> uniqueGroups;
566 uniqueSheets[fp->GetSheetname()] = fp->GetSheetfile();
570 uniqueSheets.emplace( parent, wxString() );
575 uniqueComponentClasses.insert( singleClass->GetName() );
581 if( !grp->GetName().IsEmpty() )
582 uniqueGroups.insert( grp->GetName() );
586 for(
const auto& [sheetPath, sheetFile] : uniqueSheets )
595 m_areas.m_areas.push_back( ent );
600 (
int)
m_areas.m_areas.size() );
603 for(
const wxString& compClass : uniqueComponentClasses )
611 m_areas.m_areas.push_back( ent );
615 static_cast<int>(
m_areas.m_areas.size() ) );
618 for(
const wxString& groupName : uniqueGroups )
626 m_areas.m_areas.push_back( ent );
630 static_cast<int>(
m_areas.m_areas.size() ) );
641 if( !zone->GetIsRuleArea() )
644 if( !zone->GetPlacementAreaEnabled() )
652 area.
m_center = zone->Outline()->COutline( 0 ).Centre();
656 m_areas.m_areas.push_back( area );
686 std::vector<ZONE*> refRAs;
688 auto isSelectedItemAnRA =
694 ZONE* zone =
static_cast<ZONE*
>( aItem );
707 if(
ZONE* zone = isSelectedItemAnRA( item ) )
709 refRAs.push_back( zone );
717 if(
ZONE* grpZone = isSelectedItemAnRA( grpItem ) )
718 refRAs.push_back( grpZone );
723 if( refRAs.size() != 1 )
728 _(
"Select a reference Rule Area to copy from..." ),
731 return isSelectedItemAnRA( aItem ) !=
nullptr;
745 if(
m_areas.m_areas.size() <= 1 )
747 frame()->ShowInfoBarError(
_(
"No Rule Areas to repeat layout to have been found." ),
true );
767 if( ra.
m_zone == aRefZone )
779 std::vector<RULE_AREA*> targets;
786 targets.push_back( &ra );
790 if( targets.empty() )
793 int total =
static_cast<int>( targets.size() );
794 std::atomic<int> completed( 0 );
795 std::atomic<bool> cancelled(
false );
796 std::atomic<int> matchedComponents( 0 );
797 std::atomic<int> totalComponents( 0 );
812 auto future =
tp.submit_task(
813 [
this, refRA, &targets, &completed, &cancelled, &matchedComponents, &isoParams]()
817 if( cancelled.load( std::memory_order_relaxed ) )
820 matchedComponents.store( 0, std::memory_order_relaxed );
824 completed.fetch_add( 1, std::memory_order_relaxed );
830 std::unique_ptr<WX_PROGRESS_REPORTER>
reporter;
831 auto startTime = std::chrono::steady_clock::now();
832 double highWaterMark = 0.0;
834 while( future.wait_for( std::chrono::milliseconds( 100 ) ) != std::future_status::ready )
838 auto elapsed = std::chrono::steady_clock::now() - startTime;
840 if( elapsed > std::chrono::seconds( 1 ) )
842 reporter = std::make_unique<WX_PROGRESS_REPORTER>(
848 wxLog::FlushActive();
854 int done = completed.load( std::memory_order_relaxed );
855 int matched = matchedComponents.load( std::memory_order_relaxed );
856 int compTotal = totalComponents.load( std::memory_order_relaxed );
858 double fraction = ( compTotal > 0 )
859 ?
static_cast<double>( matched ) / compTotal
861 double progress =
static_cast<double>( done + fraction ) / total;
863 if( progress > highWaterMark )
864 highWaterMark = progress;
866 reporter->SetCurrentProgress( highWaterMark );
868 _(
"Resolving topology %d of %d (%d/%d components)" ),
869 done + 1, total, matched, compTotal ) );
872 cancelled.store(
true, std::memory_order_relaxed );
881 if( cancelled.load( std::memory_order_relaxed ) )
893 wxString* aErrorOut )
895 wxCHECK_MSG( aRefArea.
m_zone, -1, wxT(
"Reference Rule Area has no zone." ) );
896 wxCHECK_MSG( aTargetArea.
m_zone, -1, wxT(
"Target Rule Area has no zone." ) );
898 const bool silent = aErrorOut !=
nullptr;
900 auto reportError = [&](
const wxString& aMsg )
904 else if(
Pgm().IsGUI() )
905 frame()->ShowInfoBarError( aMsg,
true );
916 else if(
Pgm().IsGUI() )
918 wxString summary = wxString::Format(
_(
"Rule Area topologies do not match: %s" ), compat.
m_errorMsg );
925 std::optional<BOARD_COMMIT> localCommit;
927 if( !aExternalCommit )
928 localCommit.emplace(
GetManager(),
true,
false );
930 BOARD_COMMIT& commit = aExternalCommit ? *aExternalCommit : *localCommit;
943 auto errMsg = wxString::Format(
_(
"Copy Rule Area contents failed between rule areas '%s' and '%s'." ),
946 if( !aExternalCommit )
949 reportError( errMsg );
963 if( !aExternalCommit )
966 reportError(
_(
"Target group does not have a group." ) );
976 group->AddItem( item );
980 if( !aExternalCommit )
981 commit.
Push(
_(
"Repeat layout" ) );
993 for(
auto& [targetArea, compatData] :
m_areas.m_compatMap )
995 if( !compatData.m_doCopy )
998 targetArea->m_ruleName );
1002 if( !compatData.m_isOk )
1007 auto errMsg = wxString::Format(
_(
"Copy Rule Area contents failed between rule areas '%s' and '%s'." ),
1008 m_areas.m_refRA->m_zone->GetZoneName(),
1009 targetArea->m_zone->GetZoneName() );
1014 frame()->ShowInfoBarError( errMsg,
true );
1023 if(
m_areas.m_options.m_groupItems )
1025 for(
const auto& [targetArea, compatData] :
m_areas.m_compatMap )
1027 if( compatData.m_groupableItems.size() < 2 )
1036 for(
BOARD_ITEM* item : compatData.m_groupableItems )
1039 group->AddItem( item );
1044 commit.
Push(
_(
"Repeat layout" ) );
1047 frame()->ShowInfoBarMsg( wxString::Format(
_(
"Copied to %d Rule Areas." ), totalCopied ),
true );
1059 for(
auto k : aRef )
1067 if( ( c >=
'a' && c <=
'z' ) || ( c >=
'A' && c <=
'Z' ) || ( c ==
'_' ) )
1078 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
1081 if( !aRuleArea || !aRuleArea->
m_zone )
1110 if(
EDA_GROUP* parent = bci->GetParentGroup() )
1116 if( bci->IsConnected() )
1117 aOutput.insert( bci );
1121 return (
int) aOutput.size();
1128 bool zoneOnBoard =
false;
1132 if( zone == aRuleArea->
m_zone )
1146 if( aOutput.contains( aItem ) )
1150 if(
EDA_GROUP* parent = aItem->GetParentGroup() )
1160 aItem->TransformShapeToPolygon( itemShape, aItem->GetLayer(), 0, maxError,
ERROR_OUTSIDE );
1169 aOutput.insert( aItem );
1175 enclosedByZone( track );
1179 if( drawing->IsConnected() )
1192 [&](
const wxString& aMessage,
int aOffset )
1203 wxString ruleText = wxString::Format( wxT(
"A.enclosedByArea('%s')" ),
1209 if( aOutput.contains( aItem ) )
1213 if(
EDA_GROUP* parent = aItem->GetParentGroup() )
1224 aOutput.insert( aItem );
1229 if( compiler.
Compile( ruleText, &ucode, &preflightCtx ) )
1232 testAndAdd( track );
1236 if( drawing->IsConnected() )
1262 targetAnchorFp = targetFP;
1270 if( targetAnchorFp )
1277 disp = newpos - oldpos;
1290 newTargetOutline.
Move( disp );
1305 std::vector<std::pair<BOARD_ITEM*, BOARD_ITEM*>> groupFixupPairs;
1306 std::set<BOARD_ITEM*> reproducedSourceItems;
1308 auto fixupParentGroup =
1313 destItem->SetParentGroup(
nullptr );
1315 if( !preserveGroups )
1319 groupFixupPairs.emplace_back( sourceItem, destItem );
1321 reproducedSourceItems.insert( sourceItem );
1327 bool targetZoneOnBoard =
false;
1329 if( aTargetArea->
m_zone )
1333 if( z == aTargetArea->
m_zone )
1335 targetZoneOnBoard =
true;
1341 if( targetZoneOnBoard )
1349 if( preserveGroups )
1352 groupFixupPairs.emplace_back( aRefArea->
m_zone, aTargetArea->
m_zone );
1354 reproducedSourceItems.insert( aRefArea->
m_zone );
1360 std::set<BOARD_CONNECTED_ITEM*> refRouting;
1361 std::set<BOARD_CONNECTED_ITEM*> targetRouting;
1367 std::set<int> targc;
1371 for(
PAD*
pad : refFP->Pads() )
1372 refc.insert(
pad->GetNetCode() );
1374 for(
PAD*
pad : targetFP->Pads() )
1375 targc.insert(
pad->GetNetCode() );
1382 std::set<int> targetGroupNets;
1391 targetGroupNets.insert(
pad->GetNetCode() );
1395 targetGroupNets.insert( bci->GetNetCode() );
1414 if( item->GetParentGroup() )
1417 if( item->IsLocked() )
1420 if( item->GetNetCode() <= 0 || !targetGroupNets.contains( item->GetNetCode() ) )
1464 fixupParentGroup( item,
copied );
1474 std::vector<PCB_GENERATOR*> refGenerators;
1475 std::vector<PCB_GENERATOR*> targetGenerators;
1482 refGenerators.push_back(
static_cast<PCB_GENERATOR*
>( item ) );
1487 if( !targetGroup && !aTargetArea->
m_components.empty() )
1488 targetGroup = ( *aTargetArea->
m_components.begin() )->GetParentGroup();
1495 targetGenerators.push_back(
static_cast<PCB_GENERATOR*
>( member ) );
1506 if( gen->GetGeneratorType() != wxT(
"tuning_pattern" ) )
1509 if( gen->HitTest( refOut,
false ) )
1510 refGenerators.push_back( gen );
1511 else if( gen->HitTest( targetOut,
false ) )
1512 targetGenerators.push_back( gen );
1522 aCommit->
Remove( child );
1534 clone->
Move( disp );
1535 aCommit->
Add( clone );
1545 aCommit->
Add( child );
1555 std::set<BOARD_ITEM*> sourceItems;
1556 std::set<BOARD_ITEM*> targetItems;
1574 if( item->GetParent() && item->GetParent()->Type() ==
PCB_FOOTPRINT_T )
1591 ZONE* zone =
static_cast<ZONE*
>( item );
1614 if( item->GetParent() && item->GetParent()->Type() ==
PCB_FOOTPRINT_T )
1624 ZONE* zone =
static_cast<ZONE*
>( item );
1626 if( !skipLayerFilter )
1628 LSET allowedLayers =
1636 ZONE* targetZone =
static_cast<ZONE*
>( item->Duplicate(
false ) );
1643 if( !skipLayerFilter )
1657 fixupParentGroup( item,
copied );
1675 refFP->GetReference() );
1681 refFP->GetReference() );
1688 && !refFP->GetEffectiveShape( refFP->GetLayer() )->Collide( &refPoly, 0 ) )
1696 aCommit->
Modify( targetFP );
1698 targetFP->SetLayerAndFlip( refFP->GetLayer() );
1699 targetFP->SetOrientation( refFP->GetOrientation() );
1700 targetFP->SetPosition( refFP->GetPosition() );
1701 targetFP->Rotate(
VECTOR2( 0, 0 ), rot );
1702 targetFP->Move( disp );
1704 for(
PCB_FIELD* refField : refFP->GetFields() )
1706 wxCHECK2( refField,
continue );
1708 PCB_FIELD* targetField = targetFP->GetField( refField->GetName() );
1713 targetField->
SetLayerSet( refField->GetLayerSet() );
1714 targetField->
SetVisible( refField->IsVisible() );
1716 targetField->
SetPosition( refField->GetPosition() );
1719 targetField->
Move( disp );
1726 std::set<PCB_TEXT*> consumedTargets;
1728 for(
BOARD_ITEM* refItem : refFP->GraphicalItems() )
1736 for(
BOARD_ITEM* targetItem : targetFP->GraphicalItems() )
1743 if( consumedTargets.contains( candidate ) || candidate->
GetText() != refText->
GetText() )
1748 targetText = candidate;
1757 consumedTargets.insert( targetText );
1765 targetText->
Move( disp );
1770 targetFP->Models() = refFP->Models();
1777 if( preserveGroups && refFP->GetParentGroup() )
1778 groupFixupPairs.emplace_back( refFP, targetFP );
1780 if( preserveGroups )
1781 reproducedSourceItems.insert( refFP );
1788 if( preserveGroups && !groupFixupPairs.empty() )
1790 std::map<EDA_GROUP*, EDA_GROUP*> groupMap;
1791 std::map<EDA_GROUP*, bool> fullyReproducedCache;
1793 auto groupFullyReproduced =
1796 if(
auto it = fullyReproducedCache.find( aGroup ); it != fullyReproducedCache.end() )
1799 bool reproduced =
true;
1801 for(
EDA_ITEM* member : aGroup->GetItems() )
1805 if( !member->IsBOARD_ITEM()
1806 || !reproducedSourceItems.contains(
static_cast<BOARD_ITEM*
>( member ) ) )
1813 fullyReproducedCache[aGroup] = reproduced;
1817 for(
const auto& [sourceItem, destItem] : groupFixupPairs )
1821 if( !parentGroup || !groupFullyReproduced( parentGroup ) )
1824 if( !groupMap.contains( parentGroup ) )
1834 newGroup->
Move( disp );
1837 groupMap[parentGroup] = newGroup;
1838 aCommit->
Add( newGroup );
1843 if(
EDA_GROUP* oldGroup = destItem->GetParentGroup() )
1845 if( oldGroup != groupMap[parentGroup] )
1846 aCommit->
Modify( oldGroup->AsEdaItem() );
1849 groupMap[parentGroup]->AddItem( destItem );
1869 if( aComponentMatches.empty() )
1876 const std::vector<BOARD_CONNECTED_ITEM*> refConnectedPads = connectivity->
GetNetItems( aRef->
GetNetCode(),
1884 const PAD* refPad =
static_cast<const PAD*
>( refConItem );
1887 if( aComponentMatches.contains( sourceFootprint ) )
1889 const FOOTPRINT* targetFootprint = aComponentMatches[sourceFootprint];
1890 std::vector<const PAD*> targetFpPads = targetFootprint->
GetPads( refPad->
GetNumber() );
1892 if( !targetFpPads.empty() )
1894 int targetNetCode = targetFpPads[0]->GetNet()->GetNetCode();
1905 const std::set<FOOTPRINT*>& aFootprints,
1906 const std::unordered_set<EDA_ITEM*>& aItems )
1908 std::vector<NETINFO_ITEM*> created;
1909 std::map<int, NETINFO_ITEM*> remap;
1915 auto isAutoName = [](
const wxString& aName )
1917 return aName.StartsWith( wxT(
"Net-(" ) ) || aName.StartsWith( wxT(
"unconnected-" ) );
1922 int code = aItem->GetNetCode();
1929 if( !oldNet || !isAutoName( oldNet->
GetNetname() ) )
1932 auto it = remap.find( code );
1934 if( it == remap.end() )
1940 name = wxString::Format( wxT(
"__dbapply_%d_%d" ), code, counter++ );
1944 aBoard->
Add( newNet );
1945 created.push_back( newNet );
1946 it = remap.emplace( code, newNet ).first;
1949 aItem->SetNet( it->second );
1954 for(
PAD*
pad : fp->Pads() )
1975 if( aRef.empty() || aRef.size() != aTarget.size() )
1984 std::map<KIID, FOOTPRINT*> targetByUuid;
1988 KIID uuid = symbolUuid( fp );
1991 if( uuid ==
niluuid || !targetByUuid.emplace( uuid, fp ).second )
1996 std::set<FOOTPRINT*> used;
2000 KIID uuid = symbolUuid( refFp );
2005 auto it = targetByUuid.find( uuid );
2007 if( it == targetByUuid.end() )
2013 if( refFp->GetFPID() != targetFp->
GetFPID() || refFp->Pads().size() != targetFp->
Pads().size() )
2016 if( !used.insert( targetFp ).second )
2019 result[refFp] = targetFp;
2022 aResult = std::move(
result );
2049 std::set<FOOTPRINT*> shared;
2052 std::inserter( shared, shared.begin() ) );
2054 if( !shared.empty() )
2058 aMatches.
m_errorMsg =
_(
"Target Rule Area shares components with the reference area" );
2061 _(
"This target Rule Area selects the same components as the reference area. "
2062 "Repeat layout cannot copy a Rule Area onto itself. Give each placement Rule "
2063 "Area a distinct sheet, component class or group." ) );
2064 aMatches.
m_mismatchReasons.push_back( wxString::Format(
_(
"Shared components:\n%s" ),
2072 std::unordered_map<int, std::vector<const RULE_AREA*>> netInternalAreas;
2076 std::unordered_map<int, int> areaNetPadCounts;
2082 if(
pad->GetNetCode() > 0 )
2083 areaNetPadCounts[
pad->GetNetCode()]++;
2087 for(
const auto& [netCode, padCount] : areaNetPadCounts )
2090 netInternalAreas[netCode].push_back( &area );
2101 if( aB->m_components.count( fp ) )
2108 std::unordered_set<int> globalNets;
2110 for(
const auto& [netCode, areas] : netInternalAreas )
2112 for(
size_t i = 0; i < areas.size() && !globalNets.count( netCode ); i++ )
2114 for(
size_t j = i + 1; j < areas.size(); j++ )
2116 if( disjoint( areas[i], areas[j] ) )
2118 globalNets.insert( netCode );
2139 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> mismatchReasons;
2143 mismatchReasons, aParams );
2155 if( !status && !cancelled
2162 aMatches.
m_isOk = status;
2173 for(
const auto& reason : mismatchReasons )
2175 if( reason.m_reason.IsEmpty() )
2178 if( !reason.m_reference.IsEmpty() && !reason.m_candidate.IsEmpty() )
2183 reason.m_reason ) );
2185 else if( !reason.m_reference.IsEmpty() )
2189 reason.m_reason ) );
2202 wxString::Format(
_(
"Reference area total components: %d" ), (
int) aRefArea->
m_components.size() ) );
2203 aMatches.
m_mismatchReasons.push_back( wxString::Format(
_(
"Reference area components:\n%s" ),
2206 wxString::Format(
_(
"Target area total components: %d" ), (
int) aTargetArea->
m_components.size() ) );
2207 aMatches.
m_mismatchReasons.push_back( wxString::Format(
_(
"Target area components:\n%s" ),
2218 const std::unordered_set<BOARD_ITEM*>& aItemsToRemove )
2224 std::vector<EDA_ITEM*> pruneList;
2230 if( refItem->m_Uuid == testItem->m_Uuid )
2231 pruneList.push_back( refItem );
2235 if( !pruneList.empty() )
2240 group->RemoveItem( item );
2242 if(
group->GetItems().size() < 2 )
2257 if(
m_areas.m_areas.size() <= 1 )
2259 frame()->ShowInfoBarError(
_(
"Cannot auto-generate any placement areas because the "
2260 "schematic has only one or no hierarchical sheets, "
2261 "groups, or component classes." ),
2269 if( ret != wxID_OK )
2275 if( !zone->GetIsRuleArea() )
2278 if( !zone->GetPlacementAreaEnabled() )
2281 std::set<FOOTPRINT*> components;
2284 zoneRA.
m_sourceType = zone->GetPlacementAreaSourceType();
2287 if( components.empty() )
2297 wxT(
"Placement rule area for sheet '%s' already exists as '%s'\n" ),
2303 wxT(
"Placement rule area for component class '%s' already exists as '%s'\n" ),
2309 wxT(
"Placement rule area for group '%s' already exists as '%s'\n" ),
2343 if( groupItems.empty() )
2346 wxT(
"Skipping placement rule area generation for source group '%s': group has no board items." ),
2358 std::set<BOARD_ITEM*> outlineItems;
2359 std::set<EDA_GROUP*> groups;
2360 std::set<int> channelNets;
2364 outlineItems.insert( fp );
2367 channelNets.insert(
pad->GetNetCode() );
2378 std::set<int> foreignNets;
2386 foreignNets.insert(
pad->GetNetCode() );
2391 int net = track->GetNetCode();
2393 if( net > 0 && channelNets.count( net ) && !foreignNets.count( net ) )
2394 outlineItems.insert( track );
2400 std::unique_ptr<ZONE> newZone(
new ZONE(
board() ) );
2403 newZone->SetZoneName( wxString::Format( wxT(
"auto-placement-area-%s" ), ra.
m_sheetPath ) );
2405 newZone->SetZoneName( wxString::Format( wxT(
"auto-placement-area-%s" ), ra.
m_componentClass ) );
2407 newZone->SetZoneName( wxString::Format( wxT(
"auto-placement-area-%s" ), ra.
m_groupName ) );
2410 newZone->GetZoneName(),
2413 newZone->SetIsRuleArea(
true );
2415 newZone->SetPlacementAreaEnabled(
true );
2416 newZone->SetDoNotAllowZoneFills(
false );
2417 newZone->SetDoNotAllowVias(
false );
2418 newZone->SetDoNotAllowTracks(
false );
2419 newZone->SetDoNotAllowPads(
false );
2420 newZone->SetDoNotAllowFootprints(
false );
2425 newZone->SetPlacementAreaSource( ra.
m_sheetPath );
2435 newZone->SetPlacementAreaSource( ra.
m_groupName );
2438 newZone->AddPolygon( raOutline );
2446 ra.
m_zone = newZone.release();
2453 if(
m_areas.m_options.m_groupItems )
2467 std::unordered_set<BOARD_ITEM*> toPrune;
2472 toPrune.insert( ra.
m_zone );
2486 group->AddItem( fp );
2491 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.
PCB_GENERATOR * DeepClone() const
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.
EDA_ANGLE GetTextAngle() const override
virtual VECTOR2I GetPosition() const override
virtual void SetPosition(const VECTOR2I &aPos) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetTextAngle(const EDA_ANGLE &aAngle) override
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.
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={}, const std::unordered_set< int > &aGlobalNets={})
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