From 5ac25422fa7e9899ae6fddc402efd91f6f41b8b0 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 27 Feb 2018 00:36:38 -0500 Subject: [PATCH] Change dimension style to improve display and be more standard --- pcbnew/class_dimension.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 132824fc9..c4f0f1643 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -221,7 +221,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) m_Text.SetLayer( GetLayer() ); // calculate the size of the dimension (text + line above the text) - ii = m_Text.GetTextHeight() + m_Text.GetThickness() + (m_Width * 3); + ii = m_Text.GetTextHeight() + m_Text.GetThickness() + ( m_Width ); deltax = m_featureLineDO.x - m_featureLineGO.x; deltay = m_featureLineDO.y - m_featureLineGO.y; @@ -282,16 +282,27 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) m_arrowD2F.x = m_crossBarF.x - arrow_up_X; m_arrowD2F.y = m_crossBarF.y - arrow_up_Y; - m_featureLineGF.x = m_crossBarO.x + hx; - m_featureLineGF.y = m_crossBarO.y + hy; + // Length of feature lines + double radius = ( m_Height + + ( std::copysign( 1.0, m_Height ) * + arrowz * sin( DEG2RAD( 27.5 ) ) ) ); - m_featureLineDF.x = m_crossBarF.x + hx; - m_featureLineDF.y = m_crossBarF.y + hy; + m_featureLineGF.x = m_featureLineGO.x - wxRound( radius * sin( angle ) ); + m_featureLineGF.y = m_featureLineGO.y + wxRound( radius * cos( angle ) ); + + m_featureLineDF.x = m_featureLineDO.x - wxRound( radius * sin( angle ) ); + m_featureLineDF.y = m_featureLineDO.y + wxRound( radius * cos( angle ) ); // Calculate the better text position and orientation: + radius = ( std::copysign( 1.0, m_Height ) * ii ); + wxPoint textPos; - textPos.x = (m_crossBarF.x + m_featureLineGF.x) / 2; - textPos.y = (m_crossBarF.y + m_featureLineGF.y) / 2; + textPos.x = ( m_crossBarF.x + m_crossBarO.x ) / 2; + textPos.y = ( m_crossBarF.y + m_crossBarO.y ) / 2; + + textPos.x -= KiROUND( radius * sin( angle ) ); + textPos.y += KiROUND( radius * cos( angle ) ); + m_Text.SetTextPos( textPos ); double newAngle = -RAD2DECIDEG( angle ); -- 2.14.1