From fe6cb7dbb445c5701d3f99dd276c312d3feb1ec8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 28 Oct 2021 21:44:58 +0100 Subject: [PATCH] Mirror sheet fields when mirroring sheet. Fixes https://gitlab.com/kicad/code/kicad/issues/9479 --- eeschema/sch_sheet.cpp | 20 ++++++++++++++++++++ eeschema/sch_symbol.cpp | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 281ac69222..5a13ffb5fc 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -781,21 +781,41 @@ void SCH_SHEET::Rotate( const wxPoint& aCenter ) void SCH_SHEET::MirrorVertically( int aCenter ) { + int dy = m_pos.y; + MIRROR( m_pos.y, aCenter ); m_pos.y -= m_size.y; + dy -= m_pos.y; // 0,dy is the move vector for this transform for( SCH_SHEET_PIN* sheetPin : m_pins ) sheetPin->MirrorVertically( aCenter ); + + for( SCH_FIELD& field : m_fields ) + { + wxPoint pos = field.GetTextPos(); + pos.y -= dy; + field.SetTextPos( pos ); + } } void SCH_SHEET::MirrorHorizontally( int aCenter ) { + int dx = m_pos.x; + MIRROR( m_pos.x, aCenter ); m_pos.x -= m_size.x; + dx -= m_pos.x; // dx,0 is the move vector for this transform for( SCH_SHEET_PIN* sheetPin : m_pins ) sheetPin->MirrorHorizontally( aCenter ); + + for( SCH_FIELD& field : m_fields ) + { + wxPoint pos = field.GetTextPos(); + pos.x -= dx; + field.SetTextPos( pos ); + } } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 799c4105c7..a8899a6fb8 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1467,7 +1467,7 @@ void SCH_SYMBOL::MirrorVertically( int aCenter ) SetOrientation( SYM_MIRROR_X ); MIRROR( m_pos.y, aCenter ); - dy -= m_pos.y; // dy,0 is the move vector for this transform + dy -= m_pos.y; // 0,dy is the move vector for this transform for( SCH_FIELD& field : m_fields ) {