Ensure rectangles are normalized
Normalize on creation and fixup rectangles previously saved with inverted coordinates Fixes https://gitlab.com/kicad/code/kicad/issues/11965
This commit is contained in:
parent
a830261973
commit
0c47a09517
|
@ -132,6 +132,22 @@ void PCB_SHAPE::Scale( double aScale )
|
|||
}
|
||||
|
||||
|
||||
void PCB_SHAPE::NormalizeRect()
|
||||
{
|
||||
if( m_shape == SHAPE_T::RECT )
|
||||
{
|
||||
VECTOR2I start = GetStart();
|
||||
VECTOR2I end = GetEnd();
|
||||
|
||||
EDA_RECT rect( start, end - start );
|
||||
rect.Normalize();
|
||||
|
||||
SetStart( rect.GetPosition() );
|
||||
SetEnd( rect.GetEnd() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
rotate( aRotCentre, aAngle );
|
||||
|
|
|
@ -122,6 +122,8 @@ public:
|
|||
return hitTest( aRect, aContained, aAccuracy );
|
||||
}
|
||||
|
||||
void NormalizeRect();
|
||||
|
||||
virtual void Move( const VECTOR2I& aMoveVector ) override;
|
||||
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
|
|
@ -2635,6 +2635,7 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
|
|||
pt.x = parseBoardUnits( "X coordinate" );
|
||||
pt.y = parseBoardUnits( "Y coordinate" );
|
||||
shape->SetEnd( pt );
|
||||
shape->NormalizeRect();
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
|
|
@ -388,6 +388,7 @@ int DRAWING_TOOL::DrawRectangle( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
rect->NormalizeRect();
|
||||
commit.Add( rect );
|
||||
commit.Push( isTextBox ? _( "Draw a text box" ) : _( "Draw a rectangle" ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue