123 m_report.requiresConnectivityRebuild =
m_plan.requiresConnectivityRebuild;
125 auto result = std::make_unique<BOARD>();
128 std::map<KIID_PATH, const ITEM_RESOLUTION*> actionsById;
131 actionsById[r.
id] = &r;
137 auto readProjectSiblingFile = [](
const BOARD* aBoard,
const wxString& aName,
138 bool aIsFullName ) -> wxString
141 return wxEmptyString;
145 if( boardPath.IsEmpty() )
146 return wxEmptyString;
148 wxFileName fn( boardPath );
151 fn.SetFullName( aName );
155 if( !fn.FileExists() )
156 return wxEmptyString;
158 wxFile file( fn.GetFullPath() );
160 if( !file.IsOpened() )
161 return wxEmptyString;
164 file.ReadAll( &contents );
168 auto readSiblingRules = [&](
const BOARD* aBoard ) -> wxString
170 return readProjectSiblingFile( aBoard,
174 auto readFpLibTable = [&](
const BOARD* aBoard ) -> wxString
176 return readProjectSiblingFile( aBoard,
180 auto readSymLibTable = [&](
const BOARD* aBoard ) -> wxString
182 return readProjectSiblingFile( aBoard,
194 auto docIt = actionsById.find( docPath );
196 if( docIt != actionsById.end() )
197 docRes = docIt->second;
203 switch( docRes->
kind )
217 auto detachNetSettingsFor = [](
BOARD* aBoard )
223 std::make_shared<NET_SETTINGS>(
nullptr,
"" );
230 auto adoptNetSettings = [&](
const BOARD* aSource )
232 if( !aSource || !aSource->GetDesignSettings().m_NetSettings
233 || !
result->GetDesignSettings().m_NetSettings )
238 result->GetDesignSettings().m_NetSettings->CopyFrom(
239 *aSource->GetDesignSettings().m_NetSettings );
246 detachNetSettingsFor(
result.get() );
247 adoptNetSettings( settingsSrc );
260 static const std::map<int, SEVERITY> s_emptySeverities;
261 const std::map<int, SEVERITY>& ancDrc =
264 const bool oursDrcChanged =
265 m_ours &&
m_ours->GetDesignSettings().m_DRCSeverities != ancDrc;
266 const bool theirsDrcChanged =
272 auto netSettingsEqual = [](
const BOARD* aLhs,
const BOARD* aRhs )
278 const auto& rhs = aRhs->GetDesignSettings().m_NetSettings;
296 const wxString ancRules = readSiblingRules(
m_ancestor );
297 const wxString oursRules = readSiblingRules(
m_ours );
298 const wxString theirsRules = readSiblingRules(
m_theirs );
300 const bool oursRulesChanged =
m_ours && oursRules != ancRules;
301 const bool theirsRulesChanged =
m_theirs && theirsRules != ancRules;
307 if( oursRulesChanged || theirsRulesChanged )
309 if( settingsSrc ==
m_ours )
310 m_report.customDrcRules = oursRules;
312 m_report.customDrcRules = theirsRules;
323 const wxString ancFp = readFpLibTable(
m_ancestor );
324 const wxString oursFp = readFpLibTable(
m_ours );
325 const wxString theirsFp = readFpLibTable(
m_theirs );
327 const bool oursFpChanged =
m_ours && oursFp != ancFp;
328 const bool theirsFpChanged =
m_theirs && theirsFp != ancFp;
330 if( oursFpChanged || theirsFpChanged )
332 if( settingsSrc ==
m_ours )
342 const wxString ancSym = readSymLibTable(
m_ancestor );
343 const wxString oursSym = readSymLibTable(
m_ours );
344 const wxString theirsSym = readSymLibTable(
m_theirs );
346 const bool oursSymChanged =
m_ours && oursSym != ancSym;
347 const bool theirsSymChanged =
m_theirs && theirsSym != ancSym;
349 if( oursSymChanged || theirsSymChanged )
351 if( settingsSrc ==
m_ours )
363 auto drawingSheet = [](
const BOARD* aBoard ) -> wxString
366 return wxEmptyString;
371 const wxString ancSheet = drawingSheet(
m_ancestor );
372 const bool sheetDiverged =
384 if( sheetDiverged && settingsSrc && settingsSrc->
GetProject() )
388 m_report.drawingSheetFileSet =
true;
391 if( oursDrcChanged || theirsDrcChanged )
393 m_report.drcSeveritiesTouched =
true;
397 if( oursNetChanged || theirsNetChanged )
403 if( sheetDiverged || oursRulesChanged || theirsRulesChanged
404 || oursFpChanged || theirsFpChanged || oursSymChanged || theirsSymChanged )
424 bool pageTouched =
false;
428 const BOARD* src = pickBoard( prop.
kind );
445 result->GetDesignSettings().SetBoardThickness(
452 result->GetDesignSettings().GetStackupDescriptor() =
463 result->GetDesignSettings().m_DRCSeverities =
465 m_report.drcSeveritiesTouched =
true;
470 m_report.fpLibTable = readFpLibTable( src );
476 m_report.symLibTable = readSymLibTable( src );
489 m_report.customDrcRules = readSiblingRules( src );
504 &&
result->GetDesignSettings().m_NetSettings )
506 result->GetDesignSettings().m_NetSettings->CopyFrom(
526 m_report.drawingSheetFileSet =
true;
533 result->SetPageSettings( merged );
540 std::set<KIID> allIds;
548 path.push_back( aUuid );
550 auto it = actionsById.find(
path );
552 if( it == actionsById.end() )
560 std::set<KIID_PATH> consumedActions;
562 for(
const KIID& uuid : allIds )
565 topPath.push_back( uuid );
567 if( actionsById.count( topPath ) )
568 consumedActions.insert( topPath );
659 const BOARD_ITEM* base = ours ? ours : ( ancestor ? ancestor : theirs );
686 std::map<KIID, FOOTPRINT*> footprintsByUuid;
691 footprintsByUuid[fp->m_Uuid] = fp;
694 for(
const auto& [actionPath, action] : actionsById )
696 if( consumedActions.count( actionPath ) )
699 if( actionPath.size() < 2 )
702 const KIID& parentUuid = actionPath.at( 0 );
703 const KIID& childUuid = actionPath.at( 1 );
706 auto fpIt = footprintsByUuid.find( parentUuid );
707 FOOTPRINT* parentFp = fpIt != footprintsByUuid.end() ? fpIt->second :
nullptr;
716 if(
pad->m_Uuid == childUuid )
727 if( g && g->m_Uuid == childUuid )
739 if( z && z->m_Uuid == childUuid )
751 if( f && f->m_Uuid == childUuid )
762 auto adoptChildFrom = [&](
const BOARD* aSide )
766 parentFp->
Remove( targetChild );
768 targetChild =
nullptr;
776 std::unique_ptr<EDA_ITEM> cloned( src->
Clone() );
778 if(
auto* childClone =
dynamic_cast<BOARD_ITEM*
>( cloned.get() ) )
787 switch( action->kind )
801 oursChild, theirsChild, ancestorChild );
829 parentFp->
Remove( targetChild );
855 entry.
refdes = fp->GetReference();
857 entry.
id.push_back( fp->m_Uuid );
866 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.