From 802a59dc521e6d34e3dfbc6b031307aec7add266 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 25 Apr 2014 18:49:32 +0200 Subject: [PATCH] eeschema: fix the very minor bug #1298094. But it was due to a bad bounding box calculation, which is now fixed. --- common/eda_text.cpp | 13 +------------ eeschema/sch_field.cpp | 33 ++++----------------------------- 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 97da020d55..1c253819ba 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -32,14 +32,6 @@ #include // RotatePoint #include // EDA_DRAW_PANEL -// until bzr rev 4476, Y position of vertical justification -// of multiline texts was incorrectly calculated for BOTTOM -// and CENTER vertical justification. (Only the first line was justified) -// If this line is left uncommented, the bug is fixed, but -// creates a (very minor) issue for existing texts, mainly in Pcbnew -// because the text position is sometimes critical. -#define FIX_MULTILINE_VERT_JUSTIF - // Conversion to application internal units defined at build time. #if defined( PCBNEW ) #include @@ -205,7 +197,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const if( linecount > 1 ) { -#ifdef FIX_MULTILINE_VERT_JUSTIF int yoffset; linecount -= 1; @@ -224,7 +215,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const rect.SetY( rect.GetY() - yoffset ); break; } -#endif } rect.Inflate( thickness / 2 ); @@ -305,7 +295,6 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText( offset.y = GetInterline(); -#ifdef FIX_MULTILINE_VERT_JUSTIF if( aLineCount > 1 ) { switch( m_VJustify ) @@ -326,7 +315,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText( // Rotate the position of the first line // around the center of the multiline text block RotatePoint( &pos, m_Pos, m_Orient ); -#endif + // Rotate the offset lines to increase happened in the right direction RotatePoint( &offset, m_Orient ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 942bf820e8..3eb8462e9f 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -35,19 +35,6 @@ * They can be renamed and can appear in reports */ -/* set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use - * a justification relative to the text itself - * i.e. justification relative to an horizontal text - * or to 1 to keep the initial Eeschema behavior - * The initial behavior is: - * For vertical texts, exchange the horizontal and the vertical justification - * The idea is to keep the justification always left or top for instance, - * no matter the text orientation - * This is a bit tricky when you want to change a text field justification - * when the fiels and the component are both rotated 90.0 degrees - */ -#define USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR 0 - #include #include #include @@ -206,7 +193,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, textpos = m_Pos - origin; textpos = parentComponent->GetScreenCoord( textpos ); textpos += parentComponent->GetPosition(); - GRLine( clipbox, DC, origin.x, origin.y, textpos.x, textpos.y, 2, DARKGRAY ); + GRLine( clipbox, DC, origin, textpos, 2, DARKGRAY ); } /* Enable this to draw the bounding box around the text field to validate @@ -281,26 +268,14 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const // Calculate the text bounding box: EDA_RECT rect; - // set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use - // a justification relative to the text itself - // i.e. justification relative to an horizontal text - // or to 1 to keep the initial behavior -#if (USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR == 1 ) - if( m_Orient == TEXT_ORIENT_VERT ) + if( m_id == REFERENCE ) // multi units have one letter or more added to reference { - // For vertical texts, exchange the horizontal and the vertical justification - // The idea is to keep the justification always left or top for instance, - // no matter the text orientation - SCH_FIELD text( *this ); // Make a local copy to swap justifications + SCH_FIELD text( *this ); // Make a local copy to change text // because GetBoundingBox() is const - int tmp = (int)text.m_VJustify; - NEGATE( tmp ); - text.m_VJustify = (EDA_TEXT_VJUSTIFY_T)text.m_HJustify; - text.m_HJustify = (EDA_TEXT_HJUSTIFY_T)tmp; + text.SetText( GetFullyQualifiedText() ); rect = text.GetTextBox( -1, linewidth ); } else -#endif rect = GetTextBox( -1, linewidth ); // Calculate the bounding box position relative to the component: