diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index 64774e3b39..e7840db698 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004-2018 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 2010-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2010-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -50,7 +50,7 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ), m_linesThickness( aParent, m_LineThicknessLabel, m_LineThicknessCtrl, m_LineThicknessUnits, true ), - m_OrientValidator( 1, &m_OrientValue ) + m_orientation( aParent, m_OrientLabel, m_OrientCtrl, nullptr, false ) { wxString title; @@ -114,17 +114,15 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO m_LayerSelectionCtrl->Resync(); m_OrientValue = 0.0; - m_OrientValidator.SetRange( -360.0, 360.0 ); - m_OrientCtrl->SetValidator( m_OrientValidator ); - m_OrientValidator.SetWindow( m_OrientCtrl ); + m_orientation.SetUnits( EDA_UNITS::DEGREES ); + m_orientation.SetPrecision( 3 ); - // Handle decimal separators in combo dropdown - for( size_t i = 0; i < m_OrientCtrl->GetCount(); ++i ) - { - wxString item = m_OrientCtrl->GetString( i ); - item.Replace( '.', localeconv()->decimal_point[0] ); - m_OrientCtrl->SetString( i, item ); - } + // Set predefined rotations in combo dropdown, according to the locale + // floating point separator notation + double rot_list[] = { 0.0, 90.0, -90.0, 180.0 }; + + for( size_t ii = 0; ii < m_OrientCtrl->GetCount() && ii < 4; ++ii ) + m_OrientCtrl->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) ); // Set font sizes wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); @@ -302,7 +300,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() m_Italic->SetValue( m_edaText->IsItalic() ); EDA_TEXT_HJUSTIFY_T hJustify = m_edaText->GetHorizJustify(); m_JustifyChoice->SetSelection( (int) hJustify + 1 ); - m_OrientValue = m_edaText->GetTextAngleDegrees(); + m_OrientValue = m_edaText->GetTextAngle(); + m_orientation.SetDoubleValue( m_OrientValue ); m_Mirrored->SetValue( m_edaText->IsMirrored() ); if( m_fpText ) @@ -379,7 +378,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_edaText->SetVisible( m_Visible->GetValue() ); m_edaText->SetItalic( m_Italic->GetValue() ); - m_edaText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) ); + m_OrientValue = m_orientation.GetDoubleValue(); + m_edaText->SetTextAngle( m_OrientValue ); m_edaText->SetMirrored( m_Mirrored->GetValue() ); if( m_fpText ) diff --git a/pcbnew/dialogs/dialog_text_properties.h b/pcbnew/dialogs/dialog_text_properties.h index 4ea37f7cde..feb3f85372 100644 --- a/pcbnew/dialogs/dialog_text_properties.h +++ b/pcbnew/dialogs/dialog_text_properties.h @@ -62,9 +62,8 @@ private: UNIT_BINDER m_thickness; UNIT_BINDER m_posX; UNIT_BINDER m_posY; - UNIT_BINDER m_linesThickness; // lines thikness for dimension graphic - - wxFloatingPointValidator m_OrientValidator; + UNIT_BINDER m_linesThickness; // lines thickness for dimension graphic + UNIT_BINDER m_orientation; // rotation in degrees double m_OrientValue; bool TransferDataToWindow() override; diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index e54266b92f..87cd3901e5 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -294,7 +294,7 @@ void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), GetTextThickness() ); diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 4ee86b1574..5a1e5a4975 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -854,9 +854,9 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& pad_orient_degrees = NormalizeAngleDegrees( pad_orient_degrees, -180.0, +180.0 ); if( fp_orient_degrees != 0.0 ) - msg.Printf( wxT( "%.4g(+ %.4g)" ), pad_orient_degrees, fp_orient_degrees ); + msg.Printf( wxT( "%g(+ %g)" ), pad_orient_degrees, fp_orient_degrees ); else - msg.Printf( wxT( "%.4g" ), GetOrientationDegrees() ); + msg.Printf( wxT( "%g" ), GetOrientationDegrees() ); aList.emplace_back( _( "Rotation" ), msg ); diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index f8c13ae002..c6923dba84 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -108,15 +108,13 @@ void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(); - wxCHECK_RET( m_parent != NULL, wxT( "PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) ); - aList.emplace_back( _( "PCB Text" ), GetShownText() ); aList.emplace_back( _( "Layer" ), GetLayerName() ); aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) ); - aList.emplace_back( _( "Angle" ), wxString::Format( "%.1f", GetTextAngle() / 10.0 ) ); + aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngleDegrees() ) ); aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) ); aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) );