Hi all, While working on that field autoplace feature, I noticed that LIB_PART::GetBodyBoundingBox was returning incorrect bounding boxes when the parts contained a LIB_TEXT. Further investigation revealed that there was an extra negation of the vertical dimension somewhere in the mix. The trouble is, there appear to be multiple of these, because adding or removing negations would fix it in this place, but would cause other troubles (text rendering in the wrong spot in libedit, or clicks not being received). The only way I found that worked was to special-case LIB_TEXT inside LIB_PART::GetBodyBoundingBox, negating both the Y position and Y size. Ugly hack attached.
Anyone familiar enough to have a guess as to what the "real" problem is, without me spending hours digging into the entirety of the bounding box code? The ugly hack works, but... ew. -- Chris
commit c2a1607092013825312608a454f3861fd4b07547 Author: Chris Pavlina <[email protected]> Date: Tue Jun 16 17:59:28 2015 -0400 Preliminary fix for eeschema text bounding boxes diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 2ba8989..81429c8 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -1142,6 +1142,7 @@ bool LIB_PART::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMsg ) const EDA_RECT LIB_PART::GetBoundingBox( int aUnit, int aConvert ) const { EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); + bool first = true; for( unsigned ii = 0; ii < drawings.size(); ii++ ) { @@ -1157,7 +1158,21 @@ const EDA_RECT LIB_PART::GetBoundingBox( int aUnit, int aConvert ) const if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() ) continue; - bBox.Merge( item.GetBoundingBox() ); + EDA_RECT item_bb = item.GetBoundingBox(); + + if( item.Type() == LIB_TEXT_T || item.Type() == LIB_FIELD_T ) + { + item_bb.SetY( -item_bb.GetY() ); + item_bb.SetSize( item_bb.GetSize().x, -item_bb.GetSize().y ); + } + + if( first ) + { + bBox = item_bb; + first = false; + } + else + bBox.Merge( item_bb ); } return bBox; @@ -1167,6 +1182,7 @@ const EDA_RECT LIB_PART::GetBoundingBox( int aUnit, int aConvert ) const const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const { EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); + bool first = true; for( unsigned ii = 0; ii < drawings.size(); ii++ ) { @@ -1182,7 +1198,21 @@ const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const if ( item.Type() == LIB_FIELD_T ) continue; - bBox.Merge( item.GetBoundingBox() ); + EDA_RECT item_bb = item.GetBoundingBox(); + + if( item.Type() == LIB_TEXT_T ) + { + item_bb.SetY( -item_bb.GetY() ); + item_bb.SetSize( item_bb.GetSize().x, -item_bb.GetSize().y ); + } + + if( first ) + { + bBox = item_bb; + first = false; + } + else + bBox.Merge( item_bb ); } return bBox;
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

