Fix numerous bugs in schematic item rotation.
(This will probably introduce some new ones too, but it was so broken it's hard to know where to start.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/17921
This commit is contained in:
parent
e73d2a32dc
commit
20cde51b43
|
@ -455,7 +455,7 @@ void BITMAP_BASE::Rotate( bool aRotateCCW )
|
|||
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONX, resX);
|
||||
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONY, resY);
|
||||
|
||||
m_rotation += ( aRotateCCW ? -ANGLE_90 : ANGLE_90 );
|
||||
m_rotation += ( aRotateCCW ? ANGLE_90 : -ANGLE_90 );
|
||||
rebuildBitmap( false );
|
||||
UpdateImageDataBuffer();
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ void SCH_BITMAP::MirrorHorizontally( int aCenter )
|
|||
|
||||
void SCH_BITMAP::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||
{
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
m_bitmapBase->Rotate( aRotateCCW );
|
||||
}
|
||||
|
||||
|
|
|
@ -308,8 +308,8 @@ void SCH_BUS_ENTRY_BASE::MirrorHorizontally( int aCenter )
|
|||
|
||||
void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||
{
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -996,7 +996,7 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
|
|||
void SCH_FIELD::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||
{
|
||||
VECTOR2I pt = GetPosition();
|
||||
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
SetPosition( pt );
|
||||
|
||||
SetTextAngle( GetTextAngle() != ANGLE_HORIZONTAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
|
||||
|
|
|
@ -142,7 +142,7 @@ void SCH_JUNCTION::MirrorHorizontally( int aCenter )
|
|||
|
||||
void SCH_JUNCTION::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||
{
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -428,10 +428,10 @@ void SCH_LABEL_BASE::Move( const VECTOR2I& aMoveVector )
|
|||
void SCH_LABEL_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||
{
|
||||
VECTOR2I pt = GetTextPos();
|
||||
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
VECTOR2I offset = pt - GetTextPos();
|
||||
|
||||
Rotate90( aRotateCCW );
|
||||
Rotate90( !aRotateCCW );
|
||||
|
||||
SetTextPos( GetTextPos() + offset );
|
||||
|
||||
|
|
|
@ -416,10 +416,10 @@ void SCH_LINE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
|||
// else if should become a plain if to allow
|
||||
// rotation around the center of the line
|
||||
if( m_flags & STARTPOINT )
|
||||
RotatePoint( m_start, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_start, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
|
||||
else if( m_flags & ENDPOINT )
|
||||
RotatePoint( m_end, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_end, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ void SCH_NO_CONNECT::MirrorHorizontally( int aCenter )
|
|||
|
||||
void SCH_NO_CONNECT::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||
{
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -846,8 +846,8 @@ void SCH_SHEET::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
|||
{
|
||||
VECTOR2I prev = m_pos;
|
||||
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
|
||||
if( m_size.x < 0 )
|
||||
{
|
||||
|
|
|
@ -258,7 +258,7 @@ void SCH_SHEET_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
|||
VECTOR2I pt = GetTextPos();
|
||||
VECTOR2I delta = pt - aCenter;
|
||||
|
||||
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
|
||||
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
|
||||
|
||||
SHEET_SIDE oldSide = GetSide();
|
||||
ConstrainOnEdge( pt, true );
|
||||
|
|
|
@ -837,12 +837,12 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
if( !moving )
|
||||
commit->Modify( item, m_frame->GetScreen() );
|
||||
|
||||
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
|
||||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
|
||||
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
|
||||
{
|
||||
// If we are rotating more than one item, we do not have start/end
|
||||
// points separately selected
|
||||
if( item->HasFlag( STARTPOINT ) )
|
||||
|
@ -851,47 +851,47 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
if( item->HasFlag( ENDPOINT ) )
|
||||
line->RotateEnd( rotPoint );
|
||||
}
|
||||
else if( item->Type() == SCH_SHEET_PIN_T )
|
||||
}
|
||||
else if( item->Type() == SCH_SHEET_PIN_T )
|
||||
{
|
||||
if( item->GetParent()->IsSelected() )
|
||||
{
|
||||
if( item->GetParent()->IsSelected() )
|
||||
{
|
||||
// parent will rotate us
|
||||
}
|
||||
else
|
||||
{
|
||||
// rotate within parent
|
||||
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
|
||||
SCH_SHEET* sheet = pin->GetParent();
|
||||
|
||||
pin->Rotate( sheet->GetBodyBoundingBox().GetCenter(), false );
|
||||
}
|
||||
}
|
||||
else if( item->Type() == SCH_FIELD_T )
|
||||
{
|
||||
if( item->GetParent()->IsSelected() )
|
||||
{
|
||||
// parent will rotate us
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
||||
|
||||
field->Rotate( rotPoint, true );
|
||||
|
||||
if( field->GetTextAngle().IsHorizontal() )
|
||||
field->SetTextAngle( ANGLE_VERTICAL );
|
||||
else
|
||||
field->SetTextAngle( ANGLE_HORIZONTAL );
|
||||
|
||||
// Now that we're moving a field, they're no longer autoplaced.
|
||||
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
|
||||
}
|
||||
// parent will rotate us
|
||||
}
|
||||
else
|
||||
{
|
||||
item->Rotate( rotPoint, true );
|
||||
// rotate within parent
|
||||
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
|
||||
SCH_SHEET* sheet = pin->GetParent();
|
||||
|
||||
pin->Rotate( sheet->GetBodyBoundingBox().GetCenter(), !clockwise );
|
||||
}
|
||||
}
|
||||
else if( item->Type() == SCH_FIELD_T )
|
||||
{
|
||||
if( item->GetParent()->IsSelected() )
|
||||
{
|
||||
// parent will rotate us
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
||||
|
||||
field->Rotate( rotPoint, !clockwise );
|
||||
|
||||
if( field->GetTextAngle().IsHorizontal() )
|
||||
field->SetTextAngle( ANGLE_VERTICAL );
|
||||
else
|
||||
field->SetTextAngle( ANGLE_HORIZONTAL );
|
||||
|
||||
// Now that we're moving a field, they're no longer autoplaced.
|
||||
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item->Rotate( rotPoint, !clockwise );
|
||||
}
|
||||
|
||||
m_frame->UpdateItem( item, false, true );
|
||||
updateItem( item, true );
|
||||
|
|
Loading…
Reference in New Issue