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

View File

@ -281,11 +281,14 @@ public:
* symbols. * symbols.
* @see SCH_REFERENCE_LIST::UpdateAnnotation * @see SCH_REFERENCE_LIST::UpdateAnnotation
*/ */
void RemoveAnnotation() void RemoveAnnotation( bool aIncludePowerSymbols )
{ {
for( unsigned ii = 0; ii < GetCount(); ii++ ) for( unsigned ii = 0; ii < GetCount(); ii++ )
{
if( !flatList[ii].m_libPart->IsPower() || aIncludePowerSymbols )
flatList[ii].m_isNew = true; flatList[ii].m_isNew = true;
} }
}
/** /**
* Update the symbol references for the schematic project (or the current sheet). * Update the symbol references for the schematic project (or the current sheet).

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 ) for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
{ {
SCH_MULTI_UNIT_REFERENCE_MAP tempMap; SCH_MULTI_UNIT_REFERENCE_MAP tempMap;
( *it ).GetMultiUnitSymbols( tempMap ); ( *it ).GetMultiUnitSymbols( tempMap, aIncludePowerSymbols );
for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap ) for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
{ {

View File

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

View File

@ -159,7 +159,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
}; };
auto cleanup = auto cleanup =
[&] () [&]()
{ {
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_frame->RollbackSchematicFromUndo(); m_frame->RollbackSchematicFromUndo();
@ -167,20 +167,25 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
}; };
auto annotate = auto annotate =
[&] () [&]()
{ {
EESCHEMA_SETTINGS::PANEL_ANNOTATE& annotate_panel = m_frame->eeconfig()->m_AnnotatePanel; EESCHEMA_SETTINGS* cfg = m_frame->eeconfig();
SCHEMATIC_SETTINGS& projSettings = m_frame->Schematic().Settings();
int annotateStartNum = projSettings.m_AnnotateStartNum;
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; NULL_REPORTER reporter;
m_frame->AnnotateSymbols( ANNOTATE_SELECTION, m_frame->AnnotateSymbols( ANNOTATE_SELECTION,
(ANNOTATE_ORDER_T) annotate_panel.sort_order, (ANNOTATE_ORDER_T) cfg->m_AnnotatePanel.sort_order,
(ANNOTATE_ALGO_T) annotate_panel.method, (ANNOTATE_ALGO_T) cfg->m_AnnotatePanel.method,
annotate_panel.recursive, cfg->m_AnnotatePanel.recursive,
annotateStartNum, false, false, reporter, true ); 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 ); loadTestCase( c.m_SchematicRelativePath, c.m_ExpectedReannotations );
m_refsToReannotate.RemoveAnnotation(); m_refsToReannotate.RemoveAnnotation( true );
m_refsToReannotate.SplitReferences(); m_refsToReannotate.SplitReferences();
m_refsToReannotate.Annotate( false, 0, c.m_StartNumber, m_lockedRefs, getAdditionalRefs() ); m_refsToReannotate.Annotate( false, 0, c.m_StartNumber, m_lockedRefs, getAdditionalRefs() );
m_refsToReannotate.UpdateAnnotation(); m_refsToReannotate.UpdateAnnotation();