From 17b01170741f3e2b93117c228fa5b4b78740e5b6 Mon Sep 17 00:00:00 2001 From: Zoltan Gyarmati Date: Wed, 3 Feb 2021 20:54:09 +0100 Subject: [PATCH] eeschema: fixing intersheet ref mirroring for global labels Implementing Mirror{X,Y} overrides in SCH_GLOBALLABEL in order to properly handle Intersheet Ref field mirroring. Fixes: https://gitlab.com/kicad/code/kicad/issues/7225 --- eeschema/sch_text.cpp | 30 ++++++++++++++++++++++++++++++ eeschema/sch_text.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 8d36137cb6..b44b6405a7 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -1057,6 +1057,36 @@ void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight ) } +void SCH_GLOBALLABEL::MirrorY( int aYaxis_position ) +{ + wxPoint old_pos = GetPosition(); + SCH_TEXT::MirrorY( aYaxis_position ); + + if( m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + else + m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + wxPoint pos = m_intersheetRefsField.GetTextPos(); + wxPoint delta = old_pos - pos; + pos.x = GetPosition().x + delta.x; + + m_intersheetRefsField.SetPosition( pos ); +} + + +void SCH_GLOBALLABEL::MirrorX( int aXaxis_position ) +{ + wxPoint old_pos = GetPosition(); + SCH_TEXT::MirrorX( aXaxis_position ); + wxPoint pos = m_intersheetRefsField.GetTextPos(); + wxPoint delta = old_pos - pos; + pos.y = GetPosition().y + delta.y; + + m_intersheetRefsField.SetPosition( pos ); +} + + void SCH_GLOBALLABEL::UpdateIntersheetRefProps() { m_intersheetRefsField.SetTextSize( GetTextSize() ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index d0053006fe..98461032cf 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -406,6 +406,9 @@ public: void Rotate90( bool aClockwise ) override; void MirrorSpinStyle( bool aLeftRight ) override; + void MirrorY( int aYaxis_position ) override; + void MirrorX( int aXaxis_position ) override; + void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) override; wxPoint GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;