Make an exception for SCH_TEXT in SELECTION::GetCenter()
And undo the previous changes in SCH_TEXT::Rotate(). We continue hitting this with a wrench until it gets fixed or becomes broken beyond any recognition.
This commit is contained in:
parent
8caf62803d
commit
10be483430
|
@ -70,25 +70,25 @@ bool SELECTION::Contains( EDA_ITEM* aItem ) const
|
||||||
/// Returns the center point of the selection area bounding box.
|
/// Returns the center point of the selection area bounding box.
|
||||||
VECTOR2I SELECTION::GetCenter() const
|
VECTOR2I SELECTION::GetCenter() const
|
||||||
{
|
{
|
||||||
KICAD_T labelTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
|
KICAD_T textTypes[] = { SCH_TEXT_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
|
||||||
bool hasOnlyLabels = true;
|
bool hasOnlyText = true;
|
||||||
|
|
||||||
// If the selection contains only labels calculate the center as the mean of all positions
|
// If the selection contains only texts calculate the center as the mean of all positions
|
||||||
// instead of using the center of the total bounding box. Otherwise rotating the selection will
|
// instead of using the center of the total bounding box. Otherwise rotating the selection will
|
||||||
// also translate it.
|
// also translate it.
|
||||||
|
|
||||||
for( EDA_ITEM* item : m_items )
|
for( EDA_ITEM* item : m_items )
|
||||||
{
|
{
|
||||||
if( !item->IsType( labelTypes ) )
|
if( !item->IsType( textTypes ) )
|
||||||
{
|
{
|
||||||
hasOnlyLabels = false;
|
hasOnlyText = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EDA_RECT bbox;
|
EDA_RECT bbox;
|
||||||
|
|
||||||
if( hasOnlyLabels )
|
if( hasOnlyText )
|
||||||
{
|
{
|
||||||
wxPoint center( 0, 0 );
|
wxPoint center( 0, 0 );
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ VECTOR2I SELECTION::GetCenter() const
|
||||||
|
|
||||||
for( EDA_ITEM* item : m_items )
|
for( EDA_ITEM* item : m_items )
|
||||||
{
|
{
|
||||||
if( !item->IsType( labelTypes ) )
|
if( !item->IsType( textTypes ) )
|
||||||
bbox.Merge( item->GetBoundingBox() );
|
bbox.Merge( item->GetBoundingBox() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,21 +299,13 @@ void SCH_TEXT::MirrorVertically( int aCenter )
|
||||||
|
|
||||||
void SCH_TEXT::Rotate( const wxPoint& aCenter )
|
void SCH_TEXT::Rotate( const wxPoint& aCenter )
|
||||||
{
|
{
|
||||||
wxPoint pt = GetBoundingBox().GetCenter();
|
wxPoint pt = GetTextPos();
|
||||||
|
RotatePoint( &pt, aCenter, 900 );
|
||||||
wxPoint offset = pt - GetTextPos();
|
wxPoint offset = pt - GetTextPos();
|
||||||
|
|
||||||
RotatePoint( &pt, aCenter, 900 );
|
|
||||||
|
|
||||||
// `offset` compensates for `GetTextPos()` not being the item center.
|
|
||||||
SetTextPos( pt - offset );
|
|
||||||
|
|
||||||
|
|
||||||
pt = GetBoundingBox().GetCenter();
|
|
||||||
Rotate90( false );
|
Rotate90( false );
|
||||||
|
|
||||||
// Compensate for `Rotate90()` shifting the item center.
|
SetTextPos( GetTextPos() + offset );
|
||||||
offset = GetBoundingBox().GetCenter() - pt;
|
|
||||||
SetTextPos( GetTextPos() - offset );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -927,18 +919,6 @@ const EDA_RECT SCH_LABEL::GetBoundingBox() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_LABEL::Rotate( const wxPoint& aCenter )
|
|
||||||
{
|
|
||||||
wxPoint pt = GetTextPos();
|
|
||||||
RotatePoint( &pt, aCenter, 900 );
|
|
||||||
wxPoint offset = pt - GetTextPos();
|
|
||||||
|
|
||||||
Rotate90( false );
|
|
||||||
|
|
||||||
SetTextPos( GetTextPos() + offset );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
|
wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||||
{
|
{
|
||||||
return wxString::Format( _( "Label '%s'" ), ShortenedShownText() );
|
return wxString::Format( _( "Label '%s'" ), ShortenedShownText() );
|
||||||
|
|
|
@ -300,8 +300,6 @@ public:
|
||||||
|
|
||||||
const EDA_RECT GetBoundingBox() const override;
|
const EDA_RECT GetBoundingBox() const override;
|
||||||
|
|
||||||
void Rotate( const wxPoint& aCenter ) override;
|
|
||||||
|
|
||||||
bool IsConnectable() const override { return true; }
|
bool IsConnectable() const override { return true; }
|
||||||
|
|
||||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||||
|
|
|
@ -801,21 +801,6 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||||
pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
|
pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( item->Type() == SCH_TEXT_T || item->Type() == SCH_LABEL_T )
|
|
||||||
{
|
|
||||||
/// Text and Labels are aligned to their bottom right corners and we don't flip the
|
|
||||||
/// alignment corner, so we need to offset this in the vertical direction
|
|
||||||
|
|
||||||
wxPoint textMirrorPoint = mirrorPoint;
|
|
||||||
|
|
||||||
textMirrorPoint.y += item->GetBoundingBox().GetHeight() / 2;
|
|
||||||
textMirrorPoint = m_frame->GetNearestHalfGridPosition( textMirrorPoint );
|
|
||||||
|
|
||||||
if( vertical )
|
|
||||||
item->MirrorVertically( textMirrorPoint.y );
|
|
||||||
else
|
|
||||||
item->MirrorHorizontally( textMirrorPoint.x );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( vertical )
|
if( vertical )
|
||||||
|
|
Loading…
Reference in New Issue