Fix rotation bugs in Eeschema.

Rotate text using the Rotate90() function which gets the orientation
right.

Also, when calculating the center point for rotation, don't include
labels if the selection contains other stuff.  It just makes the
rotation odd, and tends to cause walking when continuing to rotate
(due to keep-upright being non-symmetrical).

Fixes https://gitlab.com/kicad/code/kicad/issues/git
This commit is contained in:
Jeff Young 2020-11-24 18:16:03 +00:00
parent 696fc7e46e
commit 050d9e37ec
2 changed files with 27 additions and 22 deletions

View File

@ -203,29 +203,11 @@ void SCH_TEXT::Rotate( wxPoint aPosition )
{
wxPoint pt = GetTextPos();
RotatePoint( &pt, aPosition, 900 );
SetTextPos( pt );
wxPoint offset = pt - GetTextPos();
SetLabelSpinStyle( GetLabelSpinStyle().RotateCW() );
Rotate90( false );
if( this->Type() == SCH_TEXT_T )
{
int dy = 0;
switch( GetLabelSpinStyle() )
{
case LABEL_SPIN_STYLE::LEFT:
case LABEL_SPIN_STYLE::RIGHT:
dy = GetTextHeight();
break;
case LABEL_SPIN_STYLE::UP:
case LABEL_SPIN_STYLE::BOTTOM:
default:
dy = 0;
break;
}
SetTextY( GetTextPos().y + dy );
}
SetTextPos( GetTextPos() + offset );
}

View File

@ -136,7 +136,30 @@ public:
/// Returns the center point of the selection area bounding box.
virtual VECTOR2I GetCenter() const
{
return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
KICAD_T labelTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
bool includeLabels = true;
// If the selection contains at least one non-label then don't include labels when
// calculating the centerpoint.
for( EDA_ITEM* item : m_items )
{
if( !item->IsType( labelTypes ) )
{
includeLabels = false;
break;
}
}
EDA_RECT bbox;
for( EDA_ITEM* item : m_items )
{
if( !item->IsType( labelTypes ) || includeLabels )
bbox.Merge( item->GetBoundingBox() );
}
return static_cast<VECTOR2I>( bbox.Centre() );
}
virtual const BOX2I ViewBBox() const override