Commit 802a59dc authored by jean-pierre charras's avatar jean-pierre charras

eeschema: fix the very minor bug #1298094. But it was due to a bad bounding...

eeschema: fix the very minor bug  #1298094. But it was due to a bad bounding box calculation, which is now fixed.
parent 948f22de
...@@ -32,14 +32,6 @@ ...@@ -32,14 +32,6 @@
#include <trigo.h> // RotatePoint #include <trigo.h> // RotatePoint
#include <class_drawpanel.h> // EDA_DRAW_PANEL #include <class_drawpanel.h> // 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. // Conversion to application internal units defined at build time.
#if defined( PCBNEW ) #if defined( PCBNEW )
#include <class_board_item.h> #include <class_board_item.h>
...@@ -205,7 +197,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const ...@@ -205,7 +197,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
if( linecount > 1 ) if( linecount > 1 )
{ {
#ifdef FIX_MULTILINE_VERT_JUSTIF
int yoffset; int yoffset;
linecount -= 1; linecount -= 1;
...@@ -224,7 +215,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const ...@@ -224,7 +215,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
rect.SetY( rect.GetY() - yoffset ); rect.SetY( rect.GetY() - yoffset );
break; break;
} }
#endif
} }
rect.Inflate( thickness / 2 ); rect.Inflate( thickness / 2 );
...@@ -305,7 +295,6 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText( ...@@ -305,7 +295,6 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
offset.y = GetInterline(); offset.y = GetInterline();
#ifdef FIX_MULTILINE_VERT_JUSTIF
if( aLineCount > 1 ) if( aLineCount > 1 )
{ {
switch( m_VJustify ) switch( m_VJustify )
...@@ -326,7 +315,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText( ...@@ -326,7 +315,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
// Rotate the position of the first line // Rotate the position of the first line
// around the center of the multiline text block // around the center of the multiline text block
RotatePoint( &pos, m_Pos, m_Orient ); RotatePoint( &pos, m_Pos, m_Orient );
#endif
// Rotate the offset lines to increase happened in the right direction // Rotate the offset lines to increase happened in the right direction
RotatePoint( &offset, m_Orient ); RotatePoint( &offset, m_Orient );
......
...@@ -35,19 +35,6 @@ ...@@ -35,19 +35,6 @@
* They can be renamed and can appear in reports * 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 <fctsys.h> #include <fctsys.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <base_struct.h> #include <base_struct.h>
...@@ -206,7 +193,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, ...@@ -206,7 +193,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
textpos = m_Pos - origin; textpos = m_Pos - origin;
textpos = parentComponent->GetScreenCoord( textpos ); textpos = parentComponent->GetScreenCoord( textpos );
textpos += parentComponent->GetPosition(); 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 /* Enable this to draw the bounding box around the text field to validate
...@@ -281,26 +268,14 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const ...@@ -281,26 +268,14 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const
// Calculate the text bounding box: // Calculate the text bounding box:
EDA_RECT rect; EDA_RECT rect;
// set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use if( m_id == REFERENCE ) // multi units have one letter or more added to reference
// 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 )
{ {
// For vertical texts, exchange the horizontal and the vertical justification SCH_FIELD text( *this ); // Make a local copy to change text
// 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
// because GetBoundingBox() is const // because GetBoundingBox() is const
int tmp = (int)text.m_VJustify; text.SetText( GetFullyQualifiedText() );
NEGATE( tmp );
text.m_VJustify = (EDA_TEXT_VJUSTIFY_T)text.m_HJustify;
text.m_HJustify = (EDA_TEXT_HJUSTIFY_T)tmp;
rect = text.GetTextBox( -1, linewidth ); rect = text.GetTextBox( -1, linewidth );
} }
else else
#endif
rect = GetTextBox( -1, linewidth ); rect = GetTextBox( -1, linewidth );
// Calculate the bounding box position relative to the component: // Calculate the bounding box position relative to the component:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment