135 m_report.requiresConnectivityRebuild =
m_plan.requiresConnectivityRebuild;
138 std::vector<std::unique_ptr<SCH_SHEET_PATH>> ancStorage;
139 std::vector<std::unique_ptr<SCH_SHEET_PATH>> oursStorage;
140 std::vector<std::unique_ptr<SCH_SHEET_PATH>> theirsStorage;
156 std::set<const SCH_ITEM*> freedAncestorItems;
157 std::set<std::pair<SCH_SCREEN*, KIID>> placedScreenItems;
158 std::map<KIID, SCH_ITEM*> placedByItemUuid;
162 if( !aSource || !aTargetScreen )
168 if( !placedScreenItems.insert( { aTargetScreen, aSource->m_Uuid } ).second )
172 auto* schClone =
dynamic_cast<SCH_ITEM*
>( cloned );
184 aTargetScreen->Append( schClone );
193 if( aFullPath.empty() )
197 sheetPathKey.pop_back();
199 for(
auto& storedPath : ancStorage )
201 if( storedPath->Path() == sheetPathKey )
202 return storedPath.get();
208 auto takeFrom = [&](
const std::map<KIID_PATH, PathedItem>& aIndex,
209 std::map<KIID_PATH, PathedItem>::const_iterator aIt,
211 std::map<KIID_PATH, PathedItem>::iterator aAncIt,
212 std::size_t& aCounter ) ->
bool
214 if( aIt == aIndex.end() )
221 wxT(
"applier: sheet-level resolution skipped for %s" ),
222 aRes.id.AsString() );
229 if( aAncIt != ancestorIndex.end() )
231 ancestorItem = aAncIt->second.item;
232 ancestorScreen = aAncIt->second.sheetPath->LastScreen();
240 wxT(
"applier: target sheet path missing for %s" ),
241 aRes.id.AsString() );
249 if( ancestorItem && ancestorScreen )
252 ancestorScreen->
Remove( ancestorItem );
259 if( ancestorItem && ancestorScreen )
260 ancestorScreen->
Append( ancestorItem );
265 if( !aRes.id.empty() )
266 placedByItemUuid[aRes.id.back()] = placed;
268 if( ancestorItem && ancestorScreen )
271 freedAncestorItems.insert( ancestorItem );
272 ancestorIndex.erase( aAncIt );
288 if( !dstSym || !srcSym )
301 auto applyInstanceResolution =
303 std::map<KIID_PATH, PathedItem>::iterator aOursIt,
304 std::map<KIID_PATH, PathedItem>::iterator aTheirsIt )
311 SCH_ITEM* ours = aOursIt != oursIndex.end() ? aOursIt->second.item :
nullptr;
312 SCH_ITEM* theirs = aTheirsIt != theirsIndex.end() ? aTheirsIt->second.item :
nullptr;
325 copyInstanceData( aPlaced, theirs, targetSheet->
Path() );
329 copyInstanceData( aPlaced, ours, targetSheet->
Path() );
354 auto markProjectFieldTouched = [&](
const wxString& aProp )
357 m_report.ercSeveritiesTouched =
true;
359 m_report.drawingSheetFileTouched =
true;
369 auto markDivergedProjectFields = [&](
const SCHEMATIC* aSide )
371 if( !aSide || !aSide->IsValid() || !
m_ancestor->IsValid() )
374 if( aSide->ErcSettings().m_ERCSeverities
375 !=
m_ancestor->ErcSettings().m_ERCSeverities )
380 if( aSide->Settings().m_SchDrawingSheetFileName
381 !=
m_ancestor->Settings().m_SchDrawingSheetFileName )
389 markDivergedProjectFields(
m_ours );
390 markDivergedProjectFields(
m_theirs );
393 auto applyWholeSide = [&](
const SCHEMATIC* aSrc )
398 if( aSrc->RootScreen() &&
m_ancestor->RootScreen() )
401 aSrc->RootScreen()->GetPageSettings() );
405 && aSrc->ErcSettings().m_ERCSeverities
406 !=
m_ancestor->ErcSettings().m_ERCSeverities )
409 aSrc->ErcSettings().m_ERCSeverities;
417 && aSrc->Settings().m_SchDrawingSheetFileName
418 !=
m_ancestor->Settings().m_SchDrawingSheetFileName )
420 m_ancestor->Settings().m_SchDrawingSheetFileName =
421 aSrc->Settings().m_SchDrawingSheetFileName;
438 bool pageTouched =
false;
465 !=
m_ancestor->ErcSettings().m_ERCSeverities )
477 !=
m_ancestor->Settings().m_SchDrawingSheetFileName )
479 m_ancestor->Settings().m_SchDrawingSheetFileName =
485 if( pageTouched && ancRoot )
501 sheetPath.pop_back();
504 [&](
const std::vector<std::unique_ptr<SCH_SHEET_PATH>>& aPaths )
507 for(
const auto& p : aPaths )
509 if( p->Path() == sheetPath )
510 return p->LastScreen();
516 SCH_SCREEN* ancScreen = resolveScreen( ancStorage );
523 if(
SCH_SCREEN* src = resolveScreen( oursStorage ) )
528 if(
SCH_SCREEN* src = resolveScreen( theirsStorage ) )
541 if( aKind ==
PROP_RES::OURS )
return resolveScreen( oursStorage );
567 auto ancIt = ancestorIndex.find(
res.id );
568 auto oursIt = oursIndex.find(
res.id );
569 auto theirsIt = theirsIndex.find(
res.id );
574 auto resolutionTargetsSheet = [&]() ->
bool
576 if( ancIt != ancestorIndex.end() &&
isSheetItem( ancIt->second.item ) )
return true;
577 if( oursIt != oursIndex.end() &&
isSheetItem( oursIt->second.item ) )
return true;
578 if( theirsIt != theirsIndex.end() &&
isSheetItem( theirsIt->second.item ) )
return true;
582 if( resolutionTargetsSheet() )
592 if( !
res.id.empty() )
594 auto placedIt = placedByItemUuid.find(
res.id.back() );
596 if( placedIt != placedByItemUuid.end() )
598 applyInstanceResolution( placedIt->second,
res, oursIt, theirsIt );
606 if( ancIt != ancestorIndex.end() && freedAncestorItems.count( ancIt->second.item ) )
612 takeFrom( oursIndex, oursIt,
res, ancIt,
m_report.itemsTakenOurs );
616 takeFrom( theirsIndex, theirsIt,
res, ancIt,
m_report.itemsTakenTheirs );
625 if( ancIt != ancestorIndex.end() )
627 SCH_ITEM* victim = ancIt->second.item;
628 ancIt->second.sheetPath->LastScreen()->DeleteItem( victim );
629 freedAncestorItems.insert( victim );
630 ancestorIndex.erase( ancIt );
647 if( oursIt == oursIndex.end() )
658 const SCH_ITEM* theirs = theirsIt != theirsIndex.end()
659 ? theirsIt->second.item :
nullptr;
663 if( ancIt != ancestorIndex.end() )
665 ancestorItem = ancIt->second.item;
666 ancestorScreen = ancIt->second.sheetPath->LastScreen();
673 if( ancestorItem && ancestorScreen )
676 ancestorScreen->
Remove( ancestorItem );
680 SCH_ITEM* placed = cloneIntoSheet( oursIt->second.item, targetScreen );
684 if( ancestorItem && ancestorScreen )
685 ancestorScreen->
Append( ancestorItem );
690 if( !
res.id.empty() )
691 placedByItemUuid[
res.id.back()] = placed;
701 oursIt->second.item, theirs, ancestorItem );
704 targetScreen->
Update( placed );
711 if( ancestorItem && ancestorScreen )
714 freedAncestorItems.insert( ancestorItem );
715 ancestorIndex.erase( ancIt );
745 entry.
id = sheetPath.Path();
Describe the page size and margins of a paper page on which to eventually print or plot.
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.