diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index f64b6b2323..a7a30761cd 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -168,8 +168,11 @@ public: if( m_align_to_grid ) { - pos.x = round_n( pos.x, Mils2iu( 50 ), field_side.x >= 0 ); - pos.y = round_n( pos.y, Mils2iu( 50 ), field_side.y >= 0 ); + if( abs( field_side.x ) > 0 ) + pos.x = round_n( pos.x, Mils2iu( 50 ), field_side.x >= 0 ); + + if( abs( field_side.y ) > 0 ) + pos.y = round_n( pos.y, Mils2iu( 50 ), field_side.y >= 0 ); } field->SetPosition( pos ); @@ -188,19 +191,21 @@ protected: for( SCH_FIELD* field : m_fields ) { - int field_width; - int field_height; - if( m_symbol->GetTransform().y1 ) field->SetTextAngle( TEXT_ANGLE_VERT ); else field->SetTextAngle( TEXT_ANGLE_HORIZ ); - field_width = field->GetBoundingBox().GetWidth(); - field_height = field->GetBoundingBox().GetHeight(); + EDA_RECT bbox = field->GetBoundingBox(); + int field_width = bbox.GetWidth(); + int field_height = bbox.GetHeight(); max_field_width = std::max( max_field_width, field_width ); + // Remove interline spacing from field_height for last line. + if( field == m_fields[ m_fields.size() - 1 ] ) + field_height *= 0.62; + if( !aDynamic ) total_height += WIRE_V_SPACING; else if( m_align_to_grid ) diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index d4fe0e25e3..8e442e119e 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -852,13 +852,8 @@ const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const for( const LIB_ITEM& item : m_drawings ) { - if( item.m_unit > 0 - && m_unitCount > 1 - && aUnit > 0 - && aUnit != item.m_unit ) - { + if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit ) continue; - } if( item.m_convert > 0 && aConvert > 0 && aConvert != item.m_convert ) continue; @@ -866,7 +861,10 @@ const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const if( item.Type() == LIB_FIELD_T ) continue; - bbox.Merge( item.GetBoundingBox() ); + if( item.Type() == LIB_PIN_T ) + bbox.Merge( static_cast( item ).GetBoundingBox( false, true ) ); + else + bbox.Merge( item.GetBoundingBox() ); } return bbox; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 7518045c41..d6a6913b9e 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -220,9 +220,6 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) component->SetParent( m_frame->GetCurrentSheet().LastScreen() ); component->SetFlags( IS_NEW | IS_MOVED ); - if( m_frame->eeconfig()->m_AutoplaceFields.enable ) - component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); - m_frame->SaveCopyForRepeatItem( component ); m_view->ClearPreview(); @@ -237,6 +234,10 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) SCH_COMPONENT* next_comp = nullptr; m_view->ClearPreview(); + + if( m_frame->eeconfig()->m_AutoplaceFields.enable ) + component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); + m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), component, false ); EE_SELECTION new_sel; @@ -273,9 +274,6 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) next_comp->SetUnit( new_unit ); next_comp->SetUnitSelection( new_unit ); - if( m_frame->eeconfig()->m_AutoplaceFields.enable ) - component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); - m_frame->SaveCopyForRepeatItem( next_comp ); m_view->AddToPreview( next_comp->Clone() ); m_selectionTool->AddItemToSel( next_comp );