122 m_report.requiresConnectivityRebuild =
m_plan.requiresConnectivityRebuild;
124 auto result = std::make_unique<BOARD>();
127 std::map<KIID_PATH, const ITEM_RESOLUTION*> actionsById;
130 actionsById[r.
id] = &r;
136 auto readProjectSiblingFile = [](
const BOARD* aBoard,
const wxString& aName,
137 bool aIsFullName ) -> wxString
140 return wxEmptyString;
144 if( boardPath.IsEmpty() )
145 return wxEmptyString;
147 wxFileName fn( boardPath );
150 fn.SetFullName( aName );
154 if( !fn.FileExists() )
155 return wxEmptyString;
157 wxFile file( fn.GetFullPath() );
159 if( !file.IsOpened() )
160 return wxEmptyString;
163 file.ReadAll( &contents );
167 auto readSiblingRules = [&](
const BOARD* aBoard ) -> wxString
169 return readProjectSiblingFile( aBoard,
173 auto readFpLibTable = [&](
const BOARD* aBoard ) -> wxString
175 return readProjectSiblingFile( aBoard,
179 auto readSymLibTable = [&](
const BOARD* aBoard ) -> wxString
181 return readProjectSiblingFile( aBoard,
193 auto docIt = actionsById.find( docPath );
195 if( docIt != actionsById.end() )
196 docRes = docIt->second;
202 switch( docRes->
kind )
216 auto detachNetSettingsFor = [](
BOARD* aBoard )
222 std::make_shared<NET_SETTINGS>(
nullptr,
"" );
229 auto adoptNetSettings = [&](
const BOARD* aSource )
231 if( !aSource || !aSource->GetDesignSettings().m_NetSettings
232 || !
result->GetDesignSettings().m_NetSettings )
237 result->GetDesignSettings().m_NetSettings->CopyFrom(
238 *aSource->GetDesignSettings().m_NetSettings );
245 detachNetSettingsFor(
result.get() );
246 adoptNetSettings( settingsSrc );
259 static const std::map<int, SEVERITY> s_emptySeverities;
260 const std::map<int, SEVERITY>& ancDrc =
263 const bool oursDrcChanged =
264 m_ours &&
m_ours->GetDesignSettings().m_DRCSeverities != ancDrc;
265 const bool theirsDrcChanged =
271 auto netSettingsEqual = [](
const BOARD* aLhs,
const BOARD* aRhs )
277 const auto& rhs = aRhs->GetDesignSettings().m_NetSettings;
295 const wxString ancRules = readSiblingRules(
m_ancestor );
296 const wxString oursRules = readSiblingRules(
m_ours );
297 const wxString theirsRules = readSiblingRules(
m_theirs );
299 const bool oursRulesChanged =
m_ours && oursRules != ancRules;
300 const bool theirsRulesChanged =
m_theirs && theirsRules != ancRules;
306 if( oursRulesChanged || theirsRulesChanged )
308 if( settingsSrc ==
m_ours )
309 m_report.customDrcRules = oursRules;
311 m_report.customDrcRules = theirsRules;
322 const wxString ancFp = readFpLibTable(
m_ancestor );
323 const wxString oursFp = readFpLibTable(
m_ours );
324 const wxString theirsFp = readFpLibTable(
m_theirs );
326 const bool oursFpChanged =
m_ours && oursFp != ancFp;
327 const bool theirsFpChanged =
m_theirs && theirsFp != ancFp;
329 if( oursFpChanged || theirsFpChanged )
331 if( settingsSrc ==
m_ours )
341 const wxString ancSym = readSymLibTable(
m_ancestor );
342 const wxString oursSym = readSymLibTable(
m_ours );
343 const wxString theirsSym = readSymLibTable(
m_theirs );
345 const bool oursSymChanged =
m_ours && oursSym != ancSym;
346 const bool theirsSymChanged =
m_theirs && theirsSym != ancSym;
348 if( oursSymChanged || theirsSymChanged )
350 if( settingsSrc ==
m_ours )
362 auto drawingSheet = [](
const BOARD* aBoard ) -> wxString
365 return wxEmptyString;
370 const wxString ancSheet = drawingSheet(
m_ancestor );
371 const bool sheetDiverged =
383 if( sheetDiverged && settingsSrc && settingsSrc->
GetProject() )
387 m_report.drawingSheetFileSet =
true;
390 if( oursDrcChanged || theirsDrcChanged )
392 m_report.drcSeveritiesTouched =
true;
396 if( oursNetChanged || theirsNetChanged )
402 if( sheetDiverged || oursRulesChanged || theirsRulesChanged
403 || oursFpChanged || theirsFpChanged || oursSymChanged || theirsSymChanged )
423 bool pageTouched =
false;
427 const BOARD* src = pickBoard( prop.
kind );
444 result->GetDesignSettings().SetBoardThickness(
451 result->GetDesignSettings().GetStackupDescriptor() =
462 result->GetDesignSettings().m_DRCSeverities =
464 m_report.drcSeveritiesTouched =
true;
469 m_report.fpLibTable = readFpLibTable( src );
475 m_report.symLibTable = readSymLibTable( src );
488 m_report.customDrcRules = readSiblingRules( src );
503 &&
result->GetDesignSettings().m_NetSettings )
505 result->GetDesignSettings().m_NetSettings->CopyFrom(
525 m_report.drawingSheetFileSet =
true;
532 result->SetPageSettings( merged );
539 std::set<KIID> allIds;
547 path.push_back( aUuid );
549 auto it = actionsById.find(
path );
551 if( it == actionsById.end() )
559 std::set<KIID_PATH> consumedActions;
561 for(
const KIID& uuid : allIds )
564 topPath.push_back( uuid );
566 if( actionsById.count( topPath ) )
567 consumedActions.insert( topPath );
658 const BOARD_ITEM* base = ours ? ours : ( ancestor ? ancestor : theirs );
685 std::map<KIID, FOOTPRINT*> footprintsByUuid;
690 footprintsByUuid[fp->m_Uuid] = fp;
693 for(
const auto& [actionPath, action] : actionsById )
695 if( consumedActions.count( actionPath ) )
698 if( actionPath.size() < 2 )
701 const KIID& parentUuid = actionPath.at( 0 );
702 const KIID& childUuid = actionPath.at( 1 );
705 auto fpIt = footprintsByUuid.find( parentUuid );
706 FOOTPRINT* parentFp = fpIt != footprintsByUuid.end() ? fpIt->second :
nullptr;
715 if(
pad->m_Uuid == childUuid )
726 if( g && g->m_Uuid == childUuid )
738 if( z && z->m_Uuid == childUuid )
750 if( f && f->m_Uuid == childUuid )
761 auto adoptChildFrom = [&](
const BOARD* aSide )
765 parentFp->
Remove( targetChild );
767 targetChild =
nullptr;
775 std::unique_ptr<EDA_ITEM> cloned( src->
Clone() );
777 if(
auto* childClone =
dynamic_cast<BOARD_ITEM*
>( cloned.get() ) )
784 switch( action->kind )
798 oursChild, theirsChild, ancestorChild );
826 parentFp->
Remove( targetChild );
852 entry.
refdes = fp->GetReference();
854 entry.
id.push_back( fp->m_Uuid );
863 m_report.connectivityRebuildPerformed =
m_plan.requiresConnectivityRebuild;
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
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.
Reference-designator uniqueness over a flat list of (refdes, id) pairs.
wxString result
Test unit parsing edge cases and error handling.