Annotation: use full hierarchy for sheet based numbering on paste
This commit is contained in:
parent
63917c4ef9
commit
bf550afa8c
|
@ -380,7 +380,8 @@ void SCH_REFERENCE_LIST::ReannotateByOptions( ANNOTATE_ORDER_T aSort
|
|||
ANNOTATE_ALGO_T aAlgoOption,
|
||||
int aStartNumber,
|
||||
const SCH_REFERENCE_LIST& aAdditionalRefs,
|
||||
bool aStartAtCurrent )
|
||||
bool aStartAtCurrent,
|
||||
SCH_SHEET_LIST* aHierarchy )
|
||||
{
|
||||
SplitReferences();
|
||||
|
||||
|
@ -392,6 +393,17 @@ void SCH_REFERENCE_LIST::ReannotateByOptions( ANNOTATE_ORDER_T aSort
|
|||
SCH_REFERENCE& ref = flatList[i];
|
||||
wxString refstr = ref.GetSymbol()->GetRef( &ref.GetSheetPath() );
|
||||
|
||||
// Update sheet numbers based on the reference's sheet's position within the full
|
||||
// hierarchy; we do this now before we annotate so annotation by sheet number * X
|
||||
// works correctly.
|
||||
if( aHierarchy )
|
||||
{
|
||||
SCH_SHEET_PATH* path = aHierarchy->FindSheetForPath( &ref.GetSheetPath() );
|
||||
wxASSERT_MSG( path, wxT( "Attempting to annotate item on sheet not part of the hierarchy?" ) );
|
||||
|
||||
ref.SetSheetNumber( path->GetVirtualPageNumber() );
|
||||
}
|
||||
|
||||
// Never lock unassigned references
|
||||
if( refstr[refstr.Len() - 1] == '?' )
|
||||
continue;
|
||||
|
@ -408,7 +420,7 @@ void SCH_REFERENCE_LIST::ReannotateByOptions( ANNOTATE_ORDER_T aSort
|
|||
|
||||
void SCH_REFERENCE_LIST::ReannotateDuplicates( const SCH_REFERENCE_LIST& aAdditionalReferences )
|
||||
{
|
||||
ReannotateByOptions( UNSORTED, INCREMENTAL_BY_REF, 0, aAdditionalReferences, true );
|
||||
ReannotateByOptions( UNSORTED, INCREMENTAL_BY_REF, 0, aAdditionalReferences, true, nullptr );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -346,12 +346,16 @@ public:
|
|||
* @param aAdditionalReferences Additional references to check for duplicates
|
||||
* @param aStartAtCurrent Use m_numRef for each reference as the start number (overrides
|
||||
* aStartNumber)
|
||||
* @param aHierarchy Optional sheet path hierarchy for resetting the references'
|
||||
* sheet numbers based on their sheet's place in the hierarchy. Set
|
||||
* nullptr if not desired.
|
||||
*/
|
||||
void ReannotateByOptions( ANNOTATE_ORDER_T aSortOption,
|
||||
ANNOTATE_ALGO_T aAlgoOption,
|
||||
int aStartNumber,
|
||||
const SCH_REFERENCE_LIST& aAdditionalRefs,
|
||||
bool aStartAtCurrent );
|
||||
bool aStartAtCurrent,
|
||||
SCH_SHEET_LIST* aHierarchy );
|
||||
|
||||
/**
|
||||
* Convenience function for the Paste Unique functionality. Do not use as a general
|
||||
|
|
|
@ -921,6 +921,18 @@ bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
|
|||
}
|
||||
|
||||
|
||||
SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForPath( const SCH_SHEET_PATH* aPath )
|
||||
{
|
||||
for( SCH_SHEET_PATH& path : *this )
|
||||
{
|
||||
if( path.Path() == aPath->Path() )
|
||||
return &path;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForScreen( const SCH_SCREEN* aScreen )
|
||||
{
|
||||
for( SCH_SHEET_PATH& sheetpath : *this )
|
||||
|
|
|
@ -520,6 +520,12 @@ public:
|
|||
bool TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
|
||||
const wxString& aDestFileName );
|
||||
|
||||
/**
|
||||
* Return a pointer to the first #SCH_SHEET_PATH object (not necessarily the only one)
|
||||
* matching the provided path. Returns nullptr if not found.
|
||||
*/
|
||||
SCH_SHEET_PATH* FindSheetForPath( const SCH_SHEET_PATH* aPath );
|
||||
|
||||
/**
|
||||
* Return a pointer to the first #SCH_SHEET_PATH object (not necessarily the only one) using
|
||||
* a particular screen.
|
||||
|
|
|
@ -1934,6 +1934,10 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_frame->SetSheetNumberAndCount();
|
||||
m_frame->UpdateHierarchyNavigator();
|
||||
|
||||
// Get a version with correct sheet numbers since we've pasted sheets,
|
||||
// we'll need this when annotating next
|
||||
hierarchy = m_frame->Schematic().GetSheets();
|
||||
}
|
||||
|
||||
if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS || pasteMode == PASTE_MODE::RESPECT_OPTIONS )
|
||||
|
@ -1947,7 +1951,8 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
pastedSymbols[instance].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
|
||||
(ANNOTATE_ALGO_T) annotate.method,
|
||||
annotateStartNum, existingRefs, true );
|
||||
annotateStartNum, existingRefs, true,
|
||||
&hierarchy );
|
||||
|
||||
pastedSymbols[instance].UpdateAnnotation();
|
||||
|
||||
|
|
Loading…
Reference in New Issue