7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Implement AutoplaceFields() for LIB_SYMBOL.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19247
This commit is contained in:
Jeff Young 2025-01-02 10:59:50 +00:00
parent 1a0427a375
commit 76d4ef3971
3 changed files with 32 additions and 6 deletions

View File

@ -731,16 +731,34 @@ const AUTOPLACER::SIDE AUTOPLACER::SIDE_RIGHT( 1, 0 );
void SCH_SYMBOL::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo )
{
if( aAlgo == AUTOPLACE_MANUAL )
wxASSERT_MSG( aScreen, wxS( "A SCH_SCREEN pointer must be given for manual autoplacement" ) );
wxASSERT_MSG( aScreen, wxS( "A SCH_SCREEN ptr must be given for manual autoplacement" ) );
AUTOPLACER autoplacer( this, aScreen );
autoplacer.DoAutoplace( aAlgo );
switch( aAlgo )
{
case AUTOPLACE_AUTO: m_fieldsAutoplaced = AUTOPLACE_AUTO; break;
case AUTOPLACE_MANUAL: m_fieldsAutoplaced = AUTOPLACE_MANUAL; break;
case AUTOPLACE_AUTOADDED: /* leave m_fieldsAutoplaced as it is */ break;
default: wxFAIL_MSG( "Unknown autoplace algorithm" ); break;
case AUTOPLACE_AUTO: m_fieldsAutoplaced = AUTOPLACE_AUTO; break;
case AUTOPLACE_MANUAL: m_fieldsAutoplaced = AUTOPLACE_MANUAL; break;
case AUTOPLACE_AUTOADDED: /* leave m_fieldsAutoplaced as it is */ break;
default: wxFAIL_MSG( "Unknown autoplace algorithm" ); break;
}
}
void LIB_SYMBOL::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo )
{
if( aAlgo == AUTOPLACE_MANUAL )
wxFAIL_MSG( wxS( "Manual autoplacement not supported for LIB_SYMBOLs" ) );
AUTOPLACER autoplacer( this, aScreen );
autoplacer.DoAutoplace( aAlgo );
switch( aAlgo )
{
case AUTOPLACE_AUTO: m_fieldsAutoplaced = AUTOPLACE_AUTO; break;
case AUTOPLACE_MANUAL: m_fieldsAutoplaced = AUTOPLACE_MANUAL; break;
case AUTOPLACE_AUTOADDED: /* leave m_fieldsAutoplaced as it is */ break;
default: wxFAIL_MSG( "Unknown autoplace algorithm" ); break;
}
}

View File

@ -1943,4 +1943,4 @@ void LIB_SYMBOL::EmbedFonts()
auto file = GetEmbeddedFiles()->AddFile( font->GetFileName(), false );
file->type = EMBEDDED_FILES::EMBEDDED_FILE::FILE_TYPE::FONT;
}
}
}

View File

@ -350,6 +350,14 @@ public:
void EmbedFonts() override;
/**
* Automatically orient all the fields in the symbol.
*
* @param aScreen is the SCH_SCREEN associated with the current instance of the symbol.
* Required when \a aAlgo is AUTOPLACE_MANUAL; optional otherwise.
*/
void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
/**