Adjust justified text for rotation.
Fixes: lp:1823090 * https://bugs.launchpad.net/kicad/+bug/1823090
This commit is contained in:
parent
27e6f5b9e8
commit
a81512ca96
|
@ -1048,10 +1048,21 @@ void MODULE::Move( const wxPoint& aMoveVector )
|
||||||
|
|
||||||
void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||||
{
|
{
|
||||||
|
double orientation = GetOrientation();
|
||||||
|
double newOrientation = orientation + aAngle;
|
||||||
wxPoint newpos = m_Pos;
|
wxPoint newpos = m_Pos;
|
||||||
RotatePoint( &newpos, aRotCentre, aAngle );
|
RotatePoint( &newpos, aRotCentre, aAngle );
|
||||||
SetPosition( newpos );
|
SetPosition( newpos );
|
||||||
SetOrientation( GetOrientation() + aAngle );
|
SetOrientation( newOrientation );
|
||||||
|
|
||||||
|
m_Reference->KeepUpright( orientation, newOrientation );
|
||||||
|
m_Value->KeepUpright( orientation, newOrientation );
|
||||||
|
|
||||||
|
for( EDA_ITEM* item = m_Drawings; item; item = item->Next() )
|
||||||
|
{
|
||||||
|
if( item->Type() == PCB_MODULE_TEXT_T )
|
||||||
|
static_cast<TEXTE_MODULE*>( item )->KeepUpright( orientation, newOrientation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -119,6 +119,33 @@ bool TEXTE_MODULE::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TEXTE_MODULE::KeepUpright( double aOldOrientation, double aNewOrientation )
|
||||||
|
{
|
||||||
|
if( !IsKeepUpright() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
double currentAngle = GetTextAngle() + aOldOrientation;
|
||||||
|
double newAngle = GetTextAngle() + aNewOrientation;
|
||||||
|
|
||||||
|
NORMALIZE_ANGLE_POS( currentAngle );
|
||||||
|
NORMALIZE_ANGLE_POS( newAngle );
|
||||||
|
|
||||||
|
bool isFlipped = currentAngle >= 1800.0;
|
||||||
|
bool needsFlipped = newAngle >= 1800.0;
|
||||||
|
|
||||||
|
if( isFlipped != needsFlipped )
|
||||||
|
{
|
||||||
|
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
||||||
|
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||||
|
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
||||||
|
SetHorizJustify(GR_TEXT_HJUSTIFY_LEFT );
|
||||||
|
|
||||||
|
SetTextAngle( GetTextAngle() + 1800.0 );
|
||||||
|
SetDrawCoord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||||
{
|
{
|
||||||
// Used in footprint editing
|
// Used in footprint editing
|
||||||
|
@ -148,9 +175,10 @@ void TEXTE_MODULE::Flip( const wxPoint& aCentre )
|
||||||
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT || GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT || GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
||||||
{
|
{
|
||||||
if( ( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) == IsMirrored() )
|
if( ( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) == IsMirrored() )
|
||||||
m_Pos0.x -= GetTextBox().GetWidth();
|
SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-GetHorizJustify() );
|
||||||
else
|
else
|
||||||
m_Pos0.x += GetTextBox().GetWidth();
|
SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-GetHorizJustify() );
|
||||||
|
|
||||||
SetDrawCoord();
|
SetDrawCoord();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -87,6 +87,11 @@ public:
|
||||||
|
|
||||||
void SetTextAngle( double aAngle );
|
void SetTextAngle( double aAngle );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when rotating the parent footprint.
|
||||||
|
*/
|
||||||
|
void KeepUpright( double aOldOrientation, double aNewOrientation );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return force the text rotation to be always between -90 .. 90 deg. Otherwise the text is not easy to read
|
* @return force the text rotation to be always between -90 .. 90 deg. Otherwise the text is not easy to read
|
||||||
* if false, the text rotation is free.
|
* if false, the text rotation is free.
|
||||||
|
|
Loading…
Reference in New Issue