Auto-annotate (and then don't re-annotate) power symbols.

Fixes https://gitlab.com/kicad/code/kicad/issues/11942
This commit is contained in:
Jeff Young 2022-07-11 21:45:21 -06:00
parent 664bf1382d
commit d24e6c3408
6 changed files with 36 additions and 22 deletions

View File

@ -185,7 +185,9 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
// Store the selected sheets relative to the full hierarchy so we
// get the correct sheet numbers
SCH_SHEET_LIST selectedSheets;
for( EDA_ITEM* item : selection )
{
if( item->Type() == SCH_SHEET_T )
{
SCH_SHEET_PATH subSheetPath = currentSheet;
@ -193,6 +195,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
}
}
// Like above, store subsheets relative to full hierarchy for
@ -282,7 +285,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
// that these references must be reannotated, but keeps the original reference
// so that we can reannotate multi-unit symbols together.
if( aResetAnnotation )
references.RemoveAnnotation();
references.RemoveAnnotation( false );
// Build additional list of references to be used during reannotation
// to avoid duplicate designators (no additional references when annotating

View File

@ -281,10 +281,13 @@ public:
* symbols.
* @see SCH_REFERENCE_LIST::UpdateAnnotation
*/
void RemoveAnnotation()
void RemoveAnnotation( bool aIncludePowerSymbols )
{
for( unsigned ii = 0; ii < GetCount(); ii++ )
flatList[ii].m_isNew = true;
{
if( !flatList[ii].m_libPart->IsPower() || aIncludePowerSymbols )
flatList[ii].m_isNew = true;
}
}
/**

View File

@ -867,7 +867,7 @@ void SCH_SHEET_LIST::GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP &aRefList
for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
{
SCH_MULTI_UNIT_REFERENCE_MAP tempMap;
( *it ).GetMultiUnitSymbols( tempMap );
( *it ).GetMultiUnitSymbols( tempMap, aIncludePowerSymbols );
for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
{

View File

@ -1430,18 +1430,21 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
{
if( m_part.get() != dummy() )
{
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
msg = m_part->IsPower() ? _( "Power symbol" ) : _( "Value" );
aList.emplace_back( msg, GetValue( currentSheet, true ) );
if( m_part->IsPower() )
{
aList.emplace_back( _( "Power symbol" ), GetValue( currentSheet, true ) );
}
else
{
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
aList.emplace_back( _( "Value" ), GetValue( currentSheet, true ) );
aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
}
#if 0 // Display symbol flags, for debug only
aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) );
#endif
// Display symbol reference in library and library
aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
if( !m_part->IsRoot() )
{
msg = _( "Missing parent" );

View File

@ -159,7 +159,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
};
auto cleanup =
[&] ()
[&]()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_frame->RollbackSchematicFromUndo();
@ -167,20 +167,25 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
};
auto annotate =
[&] ()
[&]()
{
EESCHEMA_SETTINGS::PANEL_ANNOTATE& annotate_panel = m_frame->eeconfig()->m_AnnotatePanel;
SCHEMATIC_SETTINGS& projSettings = m_frame->Schematic().Settings();
int annotateStartNum = projSettings.m_AnnotateStartNum;
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig();
if( annotate_panel.automatic )
if( symbol->GetLibSymbolRef()->IsPower() )
{
NULL_REPORTER reporter;
m_frame->AnnotateSymbols( ANNOTATE_SELECTION, UNSORTED, INCREMENTAL_BY_REF,
false, 1, false, false, reporter, true );
}
else if( cfg->m_AnnotatePanel.automatic )
{
NULL_REPORTER reporter;
m_frame->AnnotateSymbols( ANNOTATE_SELECTION,
(ANNOTATE_ORDER_T) annotate_panel.sort_order,
(ANNOTATE_ALGO_T) annotate_panel.method,
annotate_panel.recursive,
annotateStartNum, false, false, reporter, true );
(ANNOTATE_ORDER_T) cfg->m_AnnotatePanel.sort_order,
(ANNOTATE_ALGO_T) cfg->m_AnnotatePanel.method,
cfg->m_AnnotatePanel.recursive,
m_frame->Schematic().Settings().m_AnnotateStartNum,
false, false, reporter, true );
}
};

View File

@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE( Reannotate )
loadTestCase( c.m_SchematicRelativePath, c.m_ExpectedReannotations );
m_refsToReannotate.RemoveAnnotation();
m_refsToReannotate.RemoveAnnotation( true );
m_refsToReannotate.SplitReferences();
m_refsToReannotate.Annotate( false, 0, c.m_StartNumber, m_lockedRefs, getAdditionalRefs() );
m_refsToReannotate.UpdateAnnotation();