Allow taking hidden fields into account for symbol unit bounding box

Even the GUI export of svg wasn't taking fields into account which rendered the fields regardless of status
This commit is contained in:
Marek Roszko 2022-12-12 22:47:56 -05:00
parent f1f5fff072
commit 6eedbe4a14
4 changed files with 8 additions and 6 deletions

View File

@ -362,7 +362,7 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
}
// Get the symbol bounding box to fit the plot page to it
BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, convert );
BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, convert, false );
PAGE_INFO pageInfo( PAGE_INFO::Custom );
pageInfo.SetHeightMils( schIUScale.IUToMils( symbolBB.GetHeight() * 1.2 ) );
pageInfo.SetWidthMils( schIUScale.IUToMils( symbolBB.GetWidth() * 1.2 ) );

View File

@ -971,7 +971,8 @@ bool LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums,
}
const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert ) const
const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert,
bool aIgnoreHiddenFields ) const
{
BOX2I bBox; // Start with a fresh BOX2I so the Merge algorithm works
@ -988,7 +989,8 @@ const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert ) const
if( item.m_convert > 0 && aConvert > 0 && aConvert != item.m_convert )
continue;
if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
if( aIgnoreHiddenFields && ( item.Type() == LIB_FIELD_T )
&& !( (LIB_FIELD&) item ).IsVisible() )
continue;
bBox.Merge( item.GetBoundingBox() );

View File

@ -214,9 +214,9 @@ public:
* @param aConvert = 0, 1 or 2
* If aUnit == 0, unit is not used
* if aConvert == 0 Convert is non used
* Invisible fields are not taken in account
* @param aIgnoreHiddenFields default true, ignores any hidden fields
**/
const BOX2I GetUnitBoundingBox( int aUnit, int aConvert ) const;
const BOX2I GetUnitBoundingBox( int aUnit, int aConvert, bool aIgnoreHiddenFields = true ) const;
/**
* Get the symbol bounding box excluding fields.

View File

@ -583,7 +583,7 @@ int SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent )
PAGE_INFO pageTemp = pageSave;
VECTOR2I symbolSize = symbol->GetUnitBoundingBox( editFrame->GetUnit(),
editFrame->GetConvert() ).GetSize();
editFrame->GetConvert(), false ).GetSize();
// Add a small margin to the plot bounding box
pageTemp.SetWidthMils( schIUScale.IUToMils( symbolSize.x * 1.2 ) );