When reannotating keep existing prefix in most cases.
(Execption is reannotating entire schematic, in which case we reset all of them.) Fixes https://gitlab.com/kicad/code/kicad/issues/11379
This commit is contained in:
parent
604a148f40
commit
034b57d9c0
|
@ -63,20 +63,20 @@ void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& aMap )
|
||||||
void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aAppendUndo )
|
void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aAppendUndo )
|
||||||
{
|
{
|
||||||
auto clearSymbolAnnotation =
|
auto clearSymbolAnnotation =
|
||||||
[&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet )
|
[&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
|
||||||
{
|
{
|
||||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
|
||||||
|
|
||||||
SaveCopyInUndoList( aScreen, symbol, UNDO_REDO::CHANGED, *aAppendUndo );
|
SaveCopyInUndoList( aScreen, symbol, UNDO_REDO::CHANGED, *aAppendUndo );
|
||||||
*aAppendUndo = true;
|
*aAppendUndo = true;
|
||||||
symbol->ClearAnnotation( aSheet );
|
symbol->ClearAnnotation( aSheet, aResetPrefixes );
|
||||||
};
|
};
|
||||||
|
|
||||||
auto clearSheetAnnotation =
|
auto clearSheetAnnotation =
|
||||||
[&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet )
|
[&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
|
||||||
{
|
{
|
||||||
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
|
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
|
||||||
clearSymbolAnnotation( item, aScreen, aSheet );
|
clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
|
||||||
};
|
};
|
||||||
|
|
||||||
SCH_SCREEN* screen = GetScreen();
|
SCH_SCREEN* screen = GetScreen();
|
||||||
|
@ -87,13 +87,15 @@ void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aA
|
||||||
case ANNOTATE_ALL:
|
case ANNOTATE_ALL:
|
||||||
{
|
{
|
||||||
for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
|
for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
|
||||||
clearSheetAnnotation( sheet.LastScreen(), nullptr );
|
clearSheetAnnotation( sheet.LastScreen(), nullptr, true );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ANNOTATE_CURRENT_SHEET:
|
case ANNOTATE_CURRENT_SHEET:
|
||||||
{
|
{
|
||||||
clearSheetAnnotation( screen, ¤tSheet );
|
// One could make an argument that this should clear prefixes. I have no idea what
|
||||||
|
// the right answer is.
|
||||||
|
clearSheetAnnotation( screen, ¤tSheet, false );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +107,11 @@ void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aA
|
||||||
for( EDA_ITEM* item : selection.Items() )
|
for( EDA_ITEM* item : selection.Items() )
|
||||||
{
|
{
|
||||||
if( item->Type() == SCH_SYMBOL_T )
|
if( item->Type() == SCH_SYMBOL_T )
|
||||||
clearSymbolAnnotation( item, screen, ¤tSheet );
|
{
|
||||||
|
// One could make an argument that this should clear prefixes. I have no idea
|
||||||
|
// what the right answer is.
|
||||||
|
clearSymbolAnnotation( item, screen, ¤tSheet, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -988,14 +988,14 @@ size_t SCH_SCREEN::CountConnectedItems( const VECTOR2I& aPos, bool aTestJunction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath, bool aResetPrefix )
|
||||||
{
|
{
|
||||||
|
|
||||||
for( SCH_ITEM* item : Items().OfType( SCH_SYMBOL_T ) )
|
for( SCH_ITEM* item : Items().OfType( SCH_SYMBOL_T ) )
|
||||||
{
|
{
|
||||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
||||||
|
|
||||||
symbol->ClearAnnotation( aSheetPath );
|
symbol->ClearAnnotation( aSheetPath, aResetPrefix );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1301,7 +1301,7 @@ void SCH_SCREENS::ClearAnnotationOfNewSheetPaths( SCH_SHEET_LIST& aInitialSheetP
|
||||||
// Otherwise ClearAnnotation do nothing, because the F1 field is used as
|
// Otherwise ClearAnnotation do nothing, because the F1 field is used as
|
||||||
// reference default value and takes the latest displayed value
|
// reference default value and takes the latest displayed value
|
||||||
curr_screen->EnsureAlternateReferencesExist();
|
curr_screen->EnsureAlternateReferencesExist();
|
||||||
curr_screen->ClearAnnotation( &sheetpath );
|
curr_screen->ClearAnnotation( &sheetpath, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,8 +379,10 @@ public:
|
||||||
*
|
*
|
||||||
* @param[in] aSheetPath The sheet path of the symbol annotation to clear. If NULL then
|
* @param[in] aSheetPath The sheet path of the symbol annotation to clear. If NULL then
|
||||||
* the entire hierarchy is cleared.
|
* the entire hierarchy is cleared.
|
||||||
|
* @param[in] aResetPrefix The annotation prefix ('R', 'U', etc.) should be reset to the
|
||||||
|
* symbol library prefix.
|
||||||
*/
|
*/
|
||||||
void ClearAnnotation( SCH_SHEET_PATH* aSheetPath );
|
void ClearAnnotation( SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For screens shared by many sheetpaths (complex hierarchies):
|
* For screens shared by many sheetpaths (complex hierarchies):
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_SYMBOL::ClearAnnotation( const SCH_SHEET_PATH* aSheetPath )
|
void SCH_SYMBOL::ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix )
|
||||||
{
|
{
|
||||||
// Build a reference with no annotation, i.e. a reference ending with a single '?'
|
// Build a reference with no annotation, i.e. a reference ending with a single '?'
|
||||||
wxString defRef = UTIL::GetRefDesUnannotated( m_prefix );
|
wxString defRef = UTIL::GetRefDesUnannotated( m_prefix );
|
||||||
|
@ -1079,13 +1079,23 @@ void SCH_SYMBOL::ClearAnnotation( const SCH_SHEET_PATH* aSheetPath )
|
||||||
for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
|
for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
|
||||||
{
|
{
|
||||||
if( instance.m_Path == path )
|
if( instance.m_Path == path )
|
||||||
instance.m_Reference = defRef;
|
{
|
||||||
|
if( instance.m_Reference.IsEmpty() || aResetPrefix )
|
||||||
|
instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
|
||||||
|
else
|
||||||
|
instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
|
for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
|
||||||
instance.m_Reference = defRef;
|
{
|
||||||
|
if( instance.m_Reference.IsEmpty() || aResetPrefix)
|
||||||
|
instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
|
||||||
|
else
|
||||||
|
instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( std::unique_ptr<SCH_PIN>& pin : m_pins )
|
for( std::unique_ptr<SCH_PIN>& pin : m_pins )
|
||||||
|
@ -1095,7 +1105,12 @@ void SCH_SYMBOL::ClearAnnotation( const SCH_SHEET_PATH* aSheetPath )
|
||||||
// When a clear annotation is made, the calling function must call a
|
// When a clear annotation is made, the calling function must call a
|
||||||
// UpdateAllScreenReferences for the active sheet.
|
// UpdateAllScreenReferences for the active sheet.
|
||||||
// But this call cannot made here.
|
// But this call cannot made here.
|
||||||
m_fields[REFERENCE_FIELD].SetText( defRef ); //for drawing.
|
wxString currentReference = m_fields[REFERENCE_FIELD].GetText();
|
||||||
|
|
||||||
|
if( currentReference.IsEmpty() || aResetPrefix )
|
||||||
|
m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( m_prefix ) );
|
||||||
|
else
|
||||||
|
m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( currentReference ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -296,8 +296,10 @@ public:
|
||||||
*
|
*
|
||||||
* @param aSheetPath is the hierarchical path of the symbol to clear or remove all
|
* @param aSheetPath is the hierarchical path of the symbol to clear or remove all
|
||||||
* annotations for this symbol if NULL.
|
* annotations for this symbol if NULL.
|
||||||
|
* @param[in] aResetPrefix The annotation prefix ('R', 'U', etc.) should be reset to the
|
||||||
|
* symbol library prefix.
|
||||||
*/
|
*/
|
||||||
void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath );
|
void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an instance to the alternate references list (m_instanceReferences), if this entry
|
* Add an instance to the alternate references list (m_instanceReferences), if this entry
|
||||||
|
|
|
@ -1493,7 +1493,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
||||||
// Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
|
// Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
|
||||||
// path, but symbols managed by its sheet path must have their annotation cleared
|
// path, but symbols managed by its sheet path must have their annotation cleared
|
||||||
// because they are new:
|
// because they are new:
|
||||||
sheet->GetScreen()->ClearAnnotation( &m_frame->GetCurrentSheet() );
|
sheet->GetScreen()->ClearAnnotation( &m_frame->GetCurrentSheet(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( doRefresh )
|
if( doRefresh )
|
||||||
|
|
|
@ -1493,7 +1493,7 @@ void SCH_EDITOR_CONTROL::updatePastedSymbol( SCH_SYMBOL* aSymbol, SCH_SCREEN* aP
|
||||||
if( aForceKeepAnnotations && !reference.IsEmpty() )
|
if( aForceKeepAnnotations && !reference.IsEmpty() )
|
||||||
aSymbol->SetRef( &aPastePath, reference );
|
aSymbol->SetRef( &aPastePath, reference );
|
||||||
else
|
else
|
||||||
aSymbol->ClearAnnotation( &aPastePath );
|
aSymbol->ClearAnnotation( &aPastePath, false );
|
||||||
|
|
||||||
// We might clear annotations but always leave the original unit number, value and footprint
|
// We might clear annotations but always leave the original unit number, value and footprint
|
||||||
// from the paste
|
// from the paste
|
||||||
|
|
Loading…
Reference in New Issue