116 m_report.requiresConnectivityRebuild =
m_plan.requiresConnectivityRebuild;
118 auto result = std::make_unique<BOARD>();
121 std::map<KIID_PATH, const ITEM_RESOLUTION*> actionsById;
124 actionsById[r.
id] = &r;
130 auto readProjectSiblingFile = [](
const BOARD* aBoard,
const wxString& aName,
131 bool aIsFullName ) -> wxString
134 return wxEmptyString;
138 if( boardPath.IsEmpty() )
139 return wxEmptyString;
141 wxFileName fn( boardPath );
144 fn.SetFullName( aName );
148 if( !fn.FileExists() )
149 return wxEmptyString;
151 wxFile file( fn.GetFullPath() );
153 if( !file.IsOpened() )
154 return wxEmptyString;
157 file.ReadAll( &contents );
161 auto readSiblingRules = [&](
const BOARD* aBoard ) -> wxString
163 return readProjectSiblingFile( aBoard,
167 auto readFpLibTable = [&](
const BOARD* aBoard ) -> wxString
169 return readProjectSiblingFile( aBoard,
173 auto readSymLibTable = [&](
const BOARD* aBoard ) -> wxString
175 return readProjectSiblingFile( aBoard,
187 auto docIt = actionsById.find( docPath );
189 if( docIt != actionsById.end() )
190 docRes = docIt->second;
196 switch( docRes->
kind )
210 auto detachNetSettingsFor = [](
BOARD* aBoard )
216 std::make_shared<NET_SETTINGS>(
nullptr,
"" );
223 auto adoptNetSettings = [&](
const BOARD* aSource )
225 if( !aSource || !aSource->GetDesignSettings().m_NetSettings
226 || !
result->GetDesignSettings().m_NetSettings )
231 result->GetDesignSettings().m_NetSettings->CopyFrom(
232 *aSource->GetDesignSettings().m_NetSettings );
239 detachNetSettingsFor(
result.get() );
240 adoptNetSettings( settingsSrc );
253 static const std::map<int, SEVERITY> s_emptySeverities;
254 const std::map<int, SEVERITY>& ancDrc =
257 const bool oursDrcChanged =
258 m_ours &&
m_ours->GetDesignSettings().m_DRCSeverities != ancDrc;
259 const bool theirsDrcChanged =
265 auto netSettingsEqual = [](
const BOARD* aLhs,
const BOARD* aRhs )
271 const auto& rhs = aRhs->GetDesignSettings().m_NetSettings;
289 const wxString ancRules = readSiblingRules(
m_ancestor );
290 const wxString oursRules = readSiblingRules(
m_ours );
291 const wxString theirsRules = readSiblingRules(
m_theirs );
293 const bool oursRulesChanged =
m_ours && oursRules != ancRules;
294 const bool theirsRulesChanged =
m_theirs && theirsRules != ancRules;
300 if( oursRulesChanged || theirsRulesChanged )
302 if( settingsSrc ==
m_ours )
303 m_report.customDrcRules = oursRules;
305 m_report.customDrcRules = theirsRules;
316 const wxString ancFp = readFpLibTable(
m_ancestor );
317 const wxString oursFp = readFpLibTable(
m_ours );
318 const wxString theirsFp = readFpLibTable(
m_theirs );
320 const bool oursFpChanged =
m_ours && oursFp != ancFp;
321 const bool theirsFpChanged =
m_theirs && theirsFp != ancFp;
323 if( oursFpChanged || theirsFpChanged )
325 if( settingsSrc ==
m_ours )
335 const wxString ancSym = readSymLibTable(
m_ancestor );
336 const wxString oursSym = readSymLibTable(
m_ours );
337 const wxString theirsSym = readSymLibTable(
m_theirs );
339 const bool oursSymChanged =
m_ours && oursSym != ancSym;
340 const bool theirsSymChanged =
m_theirs && theirsSym != ancSym;
342 if( oursSymChanged || theirsSymChanged )
344 if( settingsSrc ==
m_ours )
356 auto drawingSheet = [](
const BOARD* aBoard ) -> wxString
359 return wxEmptyString;
364 const wxString ancSheet = drawingSheet(
m_ancestor );
365 const bool sheetDiverged =
377 if( sheetDiverged && settingsSrc && settingsSrc->
GetProject() )
381 m_report.drawingSheetFileSet =
true;
384 if( oursDrcChanged || theirsDrcChanged )
386 m_report.drcSeveritiesTouched =
true;
390 if( oursNetChanged || theirsNetChanged )
396 if( sheetDiverged || oursRulesChanged || theirsRulesChanged
397 || oursFpChanged || theirsFpChanged || oursSymChanged || theirsSymChanged )
417 bool pageTouched =
false;
421 const BOARD* src = pickBoard( prop.
kind );
438 result->GetDesignSettings().SetBoardThickness(
445 result->GetDesignSettings().GetStackupDescriptor() =
456 result->GetDesignSettings().m_DRCSeverities =
458 m_report.drcSeveritiesTouched =
true;
463 m_report.fpLibTable = readFpLibTable( src );
469 m_report.symLibTable = readSymLibTable( src );
482 m_report.customDrcRules = readSiblingRules( src );
497 &&
result->GetDesignSettings().m_NetSettings )
499 result->GetDesignSettings().m_NetSettings->CopyFrom(
519 m_report.drawingSheetFileSet =
true;
526 result->SetPageSettings( merged );
533 std::set<KIID> allIds;
541 path.push_back( aUuid );
543 auto it = actionsById.find(
path );
545 if( it == actionsById.end() )
553 std::set<KIID_PATH> consumedActions;
555 for(
const KIID& uuid : allIds )
558 topPath.push_back( uuid );
560 if( actionsById.count( topPath ) )
561 consumedActions.insert( topPath );
652 const BOARD_ITEM* base = ours ? ours : ( ancestor ? ancestor : theirs );
679 std::map<KIID, FOOTPRINT*> footprintsByUuid;
684 footprintsByUuid[fp->m_Uuid] = fp;
687 for(
const auto& [actionPath, action] : actionsById )
689 if( consumedActions.count( actionPath ) )
692 if( actionPath.size() < 2 )
695 const KIID& parentUuid = actionPath.at( 0 );
696 const KIID& childUuid = actionPath.at( 1 );
699 auto fpIt = footprintsByUuid.find( parentUuid );
700 FOOTPRINT* parentFp = fpIt != footprintsByUuid.end() ? fpIt->second :
nullptr;
709 if(
pad->m_Uuid == childUuid )
720 if( g && g->m_Uuid == childUuid )
732 if( z && z->m_Uuid == childUuid )
744 if( f && ( f->m_Uuid == childUuid ||
PcbDiffItemId( *f ) == childUuid ) )
754 auto adoptChildFrom = [&](
const BOARD* aSide )
774 parentFp->
Remove( targetChild );
776 targetChild =
nullptr;
782 std::unique_ptr<EDA_ITEM> cloned( src->
Clone() );
784 if(
auto* childClone =
dynamic_cast<BOARD_ITEM*
>( cloned.get() ) )
793 switch( action->kind )
806 oursChild, theirsChild, ancestorChild );
834 parentFp->
Remove( targetChild );
860 entry.
refdes = fp->GetReference();
862 entry.
id.push_back( fp->m_Uuid );
871 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.