From 597a74af9a9948264fc7f2326458336807a280e3 Mon Sep 17 00:00:00 2001 From: Jeff Glass Date: Tue, 13 Oct 2020 10:47:57 -0500 Subject: [PATCH] Corrects text of orthogonal dimensions The 'outisde' position is now 'outside' in all orientations Fixes https://gitlab.com/kicad/code/kicad/-/issues/5821 --- pcbnew/dimension.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 5ab1cfd5a2..848d1e8073 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -750,6 +750,9 @@ void ORTHOGONAL_DIMENSION::updateGeometry() addShape( SHAPE_SEGMENT( extStart, extStart + extension.Resize( extensionHeight ) ) ); + //## + //UpdateHeight(m_crossBarStart, m_crossBarEnd); + // Update text after calculating crossbar position but before adding crossbar lines updateText(); @@ -814,11 +817,20 @@ void ORTHOGONAL_DIMENSION::updateText() { int textOffsetDistance = m_text.GetEffectiveTextPenWidth() + m_text.GetTextHeight(); + VECTOR2D height( m_crossBarStart - GetStart() ); + VECTOR2D crossBar( m_crossBarEnd - m_crossBarStart ); + + if( height.Cross( crossBar ) > 0 ) + m_height = height.EuclideanNorm(); + else + m_height = -height.EuclideanNorm(); + double rotation = sign( m_height ) * DEG2RAD( -90 ); VECTOR2I textOffset = crossbarCenter.Rotate( rotation ).Resize( textOffsetDistance ); textOffset += crossbarCenter; m_text.SetTextPos( m_crossBarStart + wxPoint( textOffset ) ); + m_text.SetTextAngle(rotation); } else if( m_textPosition == DIM_TEXT_POSITION::INLINE ) {