From 6b1c2da867d3620c349a798af89e946134627dd2 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 24 May 2023 08:54:16 -0700 Subject: [PATCH] Revert "Eeschema: fix block mirroring of fields attached to labels (all types)" This reverts commit b968bac3181f74d15738600a1f9ac42fdcb1bf77. --- eeschema/sch_label.cpp | 179 +++++++++++++++++------------------------ eeschema/sch_label.h | 11 ++- 2 files changed, 79 insertions(+), 111 deletions(-) diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 6d14f09154..7455b4d5ed 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -403,52 +402,6 @@ void SCH_LABEL_BASE::MirrorSpinStyle( bool aLeftRight ) } -void SCH_LABEL_BASE::MirrorHorizontally( int aCenter ) -{ - VECTOR2I old_pos = GetPosition(); - SCH_TEXT::MirrorHorizontally( aCenter ); - - for( SCH_FIELD& field : m_fields ) - { - switch( field.GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: - field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - break; - - case GR_TEXT_H_ALIGN_CENTER: - break; - - case GR_TEXT_H_ALIGN_RIGHT: - field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - break; - } - - VECTOR2I pos = field.GetTextPos(); - VECTOR2I delta = old_pos - pos; - pos.x = GetPosition().x + delta.x; - - field.SetPosition( pos ); - } -} - - -void SCH_LABEL_BASE::MirrorVertically( int aCenter ) -{ - VECTOR2I old_pos = GetPosition(); - SCH_TEXT::MirrorVertically( aCenter ); - - for( SCH_FIELD& field : m_fields ) - { - VECTOR2I pos = field.GetTextPos(); - VECTOR2I delta = old_pos - pos; - pos.y = GetPosition().y + delta.y; - - field.SetPosition( pos ); - } -} - - bool SCH_LABEL_BASE::IncrementLabel( int aIncrement ) { wxString text = GetText(); @@ -1230,64 +1183,6 @@ void SCH_DIRECTIVE_LABEL::MirrorSpinStyle( bool aLeftRight ) } -void SCH_DIRECTIVE_LABEL::MirrorHorizontally( int aCenter ) -{ - VECTOR2I old_pos = GetPosition(); - // The "text" is in fact a graphic shape. For a horizontal "text", it looks like a - // vertical shape (like a text reduced to only "I" letter). - // So the mirroring is not exactly similar to a SCH_TEXT item - // Text is NOT really mirrored; it is moved to a suitable horizontal position - SetTextSpinStyle( GetTextSpinStyle().MirrorX() ); - - SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) ); - - for( SCH_FIELD& field : m_fields ) - { - switch( field.GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: - field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - break; - - case GR_TEXT_H_ALIGN_CENTER: - break; - - case GR_TEXT_H_ALIGN_RIGHT: - field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - break; - } - - VECTOR2I pos = field.GetTextPos(); - VECTOR2I delta = old_pos - pos; - pos.x = GetPosition().x + delta.x; - - field.SetPosition( pos ); - } -} - - -void SCH_DIRECTIVE_LABEL::MirrorVertically( int aCenter ) -{ - VECTOR2I old_pos = GetPosition(); - // The "text" is in fact a graphic shape. For a horizontal "text", it looks like a - // vertical shape (like a text reduced to only "I" letter). - // So the mirroring is not exactly similar to a SCH_TEXT item - // Text is NOT really mirrored; it is moved to a suitable vertical position - SetTextSpinStyle( GetTextSpinStyle().MirrorY() ); - - SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) ); - - for( SCH_FIELD& field : m_fields ) - { - VECTOR2I pos = field.GetTextPos(); - VECTOR2I delta = old_pos - pos; - pos.y = GetPosition().y + delta.y; - - field.SetPosition( pos ); - } -} - - void SCH_DIRECTIVE_LABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, std::vector& aPoints, const VECTOR2I& aPos ) const @@ -1484,6 +1379,80 @@ void SCH_GLOBALLABEL::SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle ) } +void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight ) +{ + SCH_TEXT::MirrorSpinStyle( aLeftRight ); + + for( SCH_FIELD& field : m_fields ) + { + if( ( aLeftRight && field.GetTextAngle().IsHorizontal() ) + || ( !aLeftRight && field.GetTextAngle().IsVertical() ) ) + { + if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + + VECTOR2I pos = field.GetTextPos(); + VECTOR2I delta = (VECTOR2I)GetPosition() - pos; + + if( aLeftRight ) + pos.x = GetPosition().x + delta.x; + else + pos.y = GetPosition().y + delta.y; + + field.SetTextPos( pos ); + } +} + + +void SCH_GLOBALLABEL::MirrorHorizontally( int aCenter ) +{ + VECTOR2I old_pos = GetPosition(); + SCH_TEXT::MirrorHorizontally( aCenter ); + + for( SCH_FIELD& field : m_fields ) + { + switch( field.GetHorizJustify() ) + { + case GR_TEXT_H_ALIGN_LEFT: + field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + break; + + case GR_TEXT_H_ALIGN_CENTER: + break; + + case GR_TEXT_H_ALIGN_RIGHT: + field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + break; + } + + VECTOR2I pos = field.GetTextPos(); + VECTOR2I delta = old_pos - pos; + pos.x = GetPosition().x + delta.x; + + field.SetPosition( pos ); + } +} + + +void SCH_GLOBALLABEL::MirrorVertically( int aCenter ) +{ + VECTOR2I old_pos = GetPosition(); + SCH_TEXT::MirrorVertically( aCenter ); + + for( SCH_FIELD& field : m_fields ) + { + VECTOR2I pos = field.GetTextPos(); + VECTOR2I delta = old_pos - pos; + pos.y = GetPosition().y + delta.y; + + field.SetPosition( pos ); + } +} + + bool SCH_GLOBALLABEL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const { diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h index 7c39c30542..9c54cd4185 100644 --- a/eeschema/sch_label.h +++ b/eeschema/sch_label.h @@ -118,9 +118,6 @@ public: void MirrorSpinStyle( bool aLeftRight ) override; - void MirrorHorizontally( int aCenter ) override; - void MirrorVertically( int aCenter ) override; - void SetPosition( const VECTOR2I& aPosition ) override; void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override; @@ -327,9 +324,6 @@ public: void MirrorSpinStyle( bool aLeftRight ) override; - void MirrorHorizontally( int aCenter ) override; - void MirrorVertically( int aCenter ) override; - private: int m_pinLength; int m_symbolSize; @@ -362,6 +356,11 @@ public: int GetMandatoryFieldCount() override { return 1; } + void MirrorSpinStyle( bool aLeftRight ) override; + + void MirrorHorizontally( int aCenter ) override; + void MirrorVertically( int aCenter ) override; + void SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle ) override; VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;