From 0091c76a6fadf7f35a16bebb396732cea098dd04 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 18 Jan 2022 23:20:48 +0000 Subject: [PATCH] Excise deci-degrees from UNIT_BINDER. Fixes https://gitlab.com/kicad/code/kicad/issues/10495 --- 3d-viewer/dialogs/panel_preview_3d_model.cpp | 6 +- common/base_units.cpp | 9 +-- common/preview_items/arc_assistant.cpp | 17 ++--- common/preview_items/ruler_item.cpp | 4 +- common/widgets/unit_binder.cpp | 15 +---- common/widgets/widget_save_restore.cpp | 13 ++++ gerbview/gerbview_frame.cpp | 9 ++- include/widgets/widget_save_restore.h | 21 +++++-- pcbnew/dialogs/dialog_copper_zones.cpp | 4 +- pcbnew/dialogs/dialog_create_array.cpp | 63 +++++++++---------- pcbnew/dialogs/dialog_move_exact.cpp | 32 +++++----- pcbnew/dialogs/dialog_move_exact.h | 27 ++++---- .../dialog_non_copper_zones_properties.cpp | 7 +-- pcbnew/dialogs/dialog_pad_properties.cpp | 9 +-- pcbnew/dialogs/dialog_position_relative.cpp | 49 ++++++--------- pcbnew/dialogs/dialog_position_relative.h | 13 ++-- pcbnew/fp_text_grid_table.cpp | 4 +- 17 files changed, 148 insertions(+), 154 deletions(-) diff --git a/3d-viewer/dialogs/panel_preview_3d_model.cpp b/3d-viewer/dialogs/panel_preview_3d_model.cpp index efb8b1ca4a..8ea9819db4 100644 --- a/3d-viewer/dialogs/panel_preview_3d_model.cpp +++ b/3d-viewer/dialogs/panel_preview_3d_model.cpp @@ -220,7 +220,7 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings() */ static double rotationFromString( const wxString& aValue ) { - double rotation = DoubleValueFromString( EDA_UNITS::DEGREES, aValue ) / 10.0; + double rotation = DoubleValueFromString( EDA_UNITS::DEGREES, aValue ); if( rotation > MAX_ROTATION ) { @@ -376,7 +376,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS else if( spinCtrl == m_spinZrot ) textCtrl = zrot; - double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ) / 10.0; + double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ); curr_value += ( ROTATION_INCREMENT * aSign ); curr_value = std::max( -MAX_ROTATION, curr_value ); @@ -447,7 +447,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event ) if( event.GetWheelRotation() >= 0 ) step = -step; - double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ) / 10.0; + double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ); curr_value += step; curr_value = std::max( -MAX_ROTATION, curr_value ); diff --git a/common/base_units.cpp b/common/base_units.cpp index f169ad3787..681564c9d1 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -78,7 +78,7 @@ double To_User_Unit( EDA_UNITS aUnit, double aValue ) return IU_TO_IN( aValue ); case EDA_UNITS::DEGREES: - return aValue / 10.0f; + return aValue; default: return aValue; @@ -260,11 +260,8 @@ double From_User_Unit( EDA_UNITS aUnits, double aValue ) case EDA_UNITS::INCHES: return IN_TO_IU( aValue ); - case EDA_UNITS::DEGREES: - // Convert to "decidegrees" - return aValue * 10; - default: + case EDA_UNITS::DEGREES: case EDA_UNITS::UNSCALED: case EDA_UNITS::PERCENT: return aValue; @@ -329,9 +326,7 @@ double DoubleValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, EDA_ else if( aUnits == EDA_UNITS::DEGREES ) { if( unit == wxT( "ra" ) ) // Radians - { dtmp *= 180.0f / M_PI; - } } switch( aType ) diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp index bed900dad8..187b94df12 100644 --- a/common/preview_items/arc_assistant.cpp +++ b/common/preview_items/arc_assistant.cpp @@ -109,27 +109,28 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const // draw the radius guide circle preview_ctx.DrawCircle( origin, m_constructMan.GetRadius(), true ); - double degs = getNormDeciDegFromRad( initAngle ); + EDA_ANGLE angle( initAngle, RADIANS_T ); + angle.Normalize(); cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), m_units ) ); - cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, + cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), angle.AsDegrees(), EDA_UNITS::DEGREES ) ); } else { preview_ctx.DrawLineWithAngleHighlight( origin, m_constructMan.GetEndRadiusEnd(), false ); - double start = m_constructMan.GetStartAngle(); - double subtended = m_constructMan.GetSubtended(); - double subtendedDeg = getNormDeciDegFromRad( subtended ); - double endAngleDeg = getNormDeciDegFromRad( start + subtended ); + double start = m_constructMan.GetStartAngle(); + double subtended = m_constructMan.GetSubtended(); + EDA_ANGLE incAngle( subtended, RADIANS_T ); + EDA_ANGLE endAngle( start + subtended, RADIANS_T ); // draw dimmed extender line to cursor preview_ctx.DrawLineWithAngleHighlight( origin, m_constructMan.GetLastPoint(), true ); - cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "Δθ" ), subtendedDeg, + cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "Δθ" ), incAngle.AsDegrees(), EDA_UNITS::DEGREES ) ); - cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), endAngleDeg, + cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), endAngle.AsDegrees(), EDA_UNITS::DEGREES ) ); } diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index 1c35b7db13..29307fd13e 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -72,8 +72,8 @@ static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor, cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), aUnits ) ); - double degs = RAD2DECIDEG( -aRulerVec.Angle() ); - cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, + EDA_ANGLE angle( -aRulerVec.Angle(), RADIANS_T ); + cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), angle.AsDegrees(), EDA_UNITS::DEGREES ) ); temp = aRulerVec; diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 6632e8073b..3cc3f779c9 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -276,10 +276,7 @@ void UNIT_BINDER::SetDoubleValue( double aValue ) void UNIT_BINDER::SetAngleValue( const EDA_ANGLE& aValue ) { - if( m_units == EDA_UNITS::DEGREES ) - SetDoubleValue( aValue.AsTenthsOfADegree() ); // Historical reasons. - else - SetDoubleValue( aValue.AsDegrees() ); + SetDoubleValue( aValue.AsDegrees() ); } @@ -327,10 +324,7 @@ void UNIT_BINDER::ChangeDoubleValue( double aValue ) void UNIT_BINDER::ChangeAngleValue( const EDA_ANGLE& aValue ) { - if( m_units == EDA_UNITS::DEGREES ) - ChangeDoubleValue( aValue.AsTenthsOfADegree() ); // Historical reasons. - else - ChangeDoubleValue( aValue.AsDegrees() ); + ChangeDoubleValue( aValue.AsDegrees() ); } @@ -426,10 +420,7 @@ double UNIT_BINDER::GetDoubleValue() EDA_ANGLE UNIT_BINDER::GetAngleValue() { - if( m_units == EDA_UNITS::DEGREES ) - return EDA_ANGLE( GetDoubleValue(), TENTHS_OF_A_DEGREE_T ); // historical reasons - else - return EDA_ANGLE( GetDoubleValue(), DEGREES_T ); + return EDA_ANGLE( GetDoubleValue(), DEGREES_T ); } diff --git a/common/widgets/widget_save_restore.cpp b/common/widgets/widget_save_restore.cpp index 2bbcfecadc..f2ae6b0911 100644 --- a/common/widgets/widget_save_restore.cpp +++ b/common/widgets/widget_save_restore.cpp @@ -75,6 +75,11 @@ void WIDGET_SAVE_RESTORE::Add( UNIT_BINDER& ctrl, long& dest ) } +void WIDGET_SAVE_RESTORE::Add( UNIT_BINDER& ctrl, EDA_ANGLE& dest ) +{ + m_ctrls.emplace_back( WIDGET_CTRL_TYPE_T::UNIT_BINDER_ANGLE, ctrl, dest ); +} + void WIDGET_SAVE_RESTORE::Add( wxChoice& ctrl, long& dest ) { m_ctrls.emplace_back( WIDGET_CTRL_TYPE_T::CHOICE, ctrl, dest ); @@ -117,6 +122,10 @@ void WIDGET_SAVE_RESTORE::ReadConfigFromControls() *ctrl.m_dest.m_long = ctrl.m_control.m_unit_binder->GetValue(); break; + case WIDGET_CTRL_TYPE_T::UNIT_BINDER_ANGLE: + *ctrl.m_dest.m_angle = ctrl.m_control.m_unit_binder->GetAngleValue(); + break; + case WIDGET_CTRL_TYPE_T::CHOICE: *ctrl.m_dest.m_long = ctrl.m_control.m_choice->GetSelection(); break; @@ -168,6 +177,10 @@ void WIDGET_SAVE_RESTORE::RestoreConfigToControls() ctrl.m_control.m_unit_binder->SetValue( *ctrl.m_dest.m_long ); break; + case WIDGET_CTRL_TYPE_T::UNIT_BINDER_ANGLE: + ctrl.m_control.m_unit_binder->SetAngleValue( *ctrl.m_dest.m_angle ); + break; + case WIDGET_CTRL_TYPE_T::CHOICE: ctrl.m_control.m_choice->SetSelection( *ctrl.m_dest.m_long ); break; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index e1c8b87bdb..e19e1a1b7f 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -886,14 +886,13 @@ void GERBVIEW_FRAME::UpdateStatusBar() if( GetShowPolarCoords() ) // display relative polar coordinates { - double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x; - double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y; - double theta = RAD2DEG( atan2( -dy, dx ) ); - double ro = hypot( dx, dy ); + VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin; + EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) ); + double ro = hypot( v.x, v.y ); line.Printf( wxT( "r %s theta %s" ), MessageTextFromValue( GetUserUnits(), ro, false ), - MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) ); + MessageTextFromValue( EDA_UNITS::DEGREES, theta.AsDegrees(), false ) ); SetStatusText( line, 3 ); } diff --git a/include/widgets/widget_save_restore.h b/include/widgets/widget_save_restore.h index 2ce5d68e3c..7854cc2487 100644 --- a/include/widgets/widget_save_restore.h +++ b/include/widgets/widget_save_restore.h @@ -35,6 +35,7 @@ class wxString; class wxTextCtrl; class UNIT_BINDER; +class EDA_ANGLE; class WIDGET_SAVE_RESTORE { @@ -82,6 +83,11 @@ public: */ void Add( UNIT_BINDER& ctrl, long& dest ); + /** + * Bind a control managed by a #UNIT_BINDER into an angle + */ + void Add( UNIT_BINDER& ctrl, EDA_ANGLE& dest ); + /** * Bind a choice control into a choice (agnostic to the actual * meaning of the choice) @@ -116,6 +122,7 @@ private: TEXT_INTEGER, TEXT_DOUBLE, UNIT_BINDER, + UNIT_BINDER_ANGLE, CHECKBOX, RADIOBUTTON, RADIOBOX, @@ -189,10 +196,16 @@ private: { } - long* m_long; - bool* m_bool; - wxString* m_str; - double* m_double; + DATA( EDA_ANGLE* aDest ) : + m_angle( aDest ) + { + } + + long* m_long; + bool* m_bool; + wxString* m_str; + double* m_double; + EDA_ANGLE* m_angle; }; /** diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index d324ffb85b..dcac44e8e1 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -270,7 +270,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow() } m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES ); - m_gridStyleRotation.SetValue( m_settings.m_HatchOrientation * 10 ); // IU is decidegree + m_gridStyleRotation.SetAngleValue( EDA_ANGLE( m_settings.m_HatchOrientation, DEGREES_T ) ); // Gives a reasonable value to grid style parameters, if currently there are no defined // parameters for grid pattern thickness and gap (if the value is 0) @@ -419,7 +419,7 @@ bool DIALOG_COPPER_ZONE::TransferDataFromWindow() if( !AcceptOptions() ) return false; - m_settings.m_HatchOrientation = m_gridStyleRotation.GetValue() / 10.0; // value is returned in deci-degree + m_settings.m_HatchOrientation = m_gridStyleRotation.GetAngleValue().AsDegrees(); m_settings.m_HatchThickness = m_gridStyleThickness.GetValue(); m_settings.m_HatchGap = m_gridStyleGap.GetValue(); m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue(); diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp index 7025c37b20..6663c4f4ea 100644 --- a/pcbnew/dialogs/dialog_create_array.cpp +++ b/pcbnew/dialogs/dialog_create_array.cpp @@ -63,7 +63,6 @@ struct CREATE_ARRAY_DIALOG_ENTRIES m_GridSecondaryAxisStep( 1 ), m_CircCentreX( 0 ), m_CircCentreY( 0 ), - m_CircAngle( 0.0 ), m_CircCount( 4 ), m_CircNumStartSet( 1 ), // use specified start m_GridCircNumScheme( 0 ), @@ -76,40 +75,40 @@ struct CREATE_ARRAY_DIALOG_ENTRIES { } - bool m_OptionsSet; + bool m_OptionsSet; - long m_GridNx; - long m_GridNy; - long m_GridDx; - long m_GridDy; - long m_GridOffsetX; - long m_GridOffsetY; - long m_GridStagger; + long m_GridNx; + long m_GridNy; + long m_GridDx; + long m_GridDy; + long m_GridOffsetX; + long m_GridOffsetY; + long m_GridStagger; - long m_GridStaggerType; - long m_GridNumberingAxis; - bool m_GridNumReverseAlt; - long m_GridNumStartSet; - long m_Grid2dArrayNumbering; - long m_GridPrimaryAxisScheme; - long m_GridSecondaryAxisScheme; - wxString m_GridPrimaryNumOffset; - wxString m_GridSecondaryNumOffset; - long m_GridPrimaryAxisStep; - long m_GridSecondaryAxisStep; + long m_GridStaggerType; + long m_GridNumberingAxis; + bool m_GridNumReverseAlt; + long m_GridNumStartSet; + long m_Grid2dArrayNumbering; + long m_GridPrimaryAxisScheme; + long m_GridSecondaryAxisScheme; + wxString m_GridPrimaryNumOffset; + wxString m_GridSecondaryNumOffset; + long m_GridPrimaryAxisStep; + long m_GridSecondaryAxisStep; - long m_CircCentreX; - long m_CircCentreY; - long m_CircAngle; - long m_CircCount; - long m_CircNumStartSet; - long m_GridCircNumScheme; - wxString m_CircNumberingOffset; - long m_CircNumberingStep; - bool m_CircRotatationStep; - long m_ArrayTypeTab; - bool m_FootprintKeepAnnotations; - bool m_FootprintReannotate; + long m_CircCentreX; + long m_CircCentreY; + EDA_ANGLE m_CircAngle; + long m_CircCount; + long m_CircNumStartSet; + long m_GridCircNumScheme; + wxString m_CircNumberingOffset; + long m_CircNumberingStep; + bool m_CircRotatationStep; + long m_ArrayTypeTab; + bool m_FootprintKeepAnnotations; + bool m_FootprintReannotate; }; // Persistent options settings diff --git a/pcbnew/dialogs/dialog_move_exact.cpp b/pcbnew/dialogs/dialog_move_exact.cpp index 22f7d215ce..9ab8795530 100644 --- a/pcbnew/dialogs/dialog_move_exact.cpp +++ b/pcbnew/dialogs/dialog_move_exact.cpp @@ -45,8 +45,7 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, VECTOR2I& aTransl m_rotate( aParent, m_rotLabel, m_rotEntry, m_rotUnit ), m_stateX( 0.0 ), m_stateY( 0.0 ), - m_stateRadius( 0.0 ), - m_stateTheta( 0.0 ) + m_stateRadius( 0.0 ) { // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics // implementation on MSW @@ -115,12 +114,12 @@ void DIALOG_MOVE_EXACT::buildRotationAnchorMenu() } -void DIALOG_MOVE_EXACT::ToPolarDeg( double x, double y, double& r, double& q ) +void DIALOG_MOVE_EXACT::ToPolarDeg( double x, double y, double& r, EDA_ANGLE& q ) { // convert to polar coordinates r = hypot( x, y ); - q = ( r != 0) ? RAD2DEG( atan2( y, x ) ) : 0; + q = ( r != 0) ? EDA_ANGLE( VECTOR2D( x, y ) ) : ANGLE_0; } @@ -128,11 +127,11 @@ bool DIALOG_MOVE_EXACT::GetTranslationInIU( wxRealPoint& val, bool polar ) { if( polar ) { - const double r = m_moveX.GetDoubleValue(); - const double q = m_moveY.GetDoubleValue(); + const double r = m_moveX.GetDoubleValue(); + const EDA_ANGLE q = m_moveY.GetAngleValue(); - val.x = r * cos( DEG2RAD( q / 10.0 ) ); - val.y = r * sin( DEG2RAD( q / 10.0 ) ); + val.x = r * q.Cos(); + val.y = r * q.Sin(); } else { @@ -160,27 +159,26 @@ void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event ) m_stateX = moveX; m_stateY = moveY; ToPolarDeg( m_stateX, m_stateY, m_stateRadius, m_stateTheta ); - m_stateTheta *= 10.0; m_moveX.SetDoubleValue( m_stateRadius ); m_stateRadius = m_moveX.GetDoubleValue(); - m_moveY.SetDoubleValue( m_stateTheta ); - m_stateTheta = m_moveY.GetDoubleValue(); + m_moveY.SetAngleValue( m_stateTheta ); + m_stateTheta = m_moveY.GetAngleValue(); } else { m_moveX.SetDoubleValue( m_stateRadius ); - m_moveY.SetDoubleValue( m_stateTheta ); + m_moveY.SetAngleValue( m_stateTheta ); } } else { - if( moveX != m_stateRadius || moveY != m_stateTheta ) + if( moveX != m_stateRadius || moveY != m_stateTheta.AsDegrees() ) { m_stateRadius = moveX; - m_stateTheta = moveY; - m_stateX = m_stateRadius * cos( DEG2RAD( m_stateTheta / 10.0 ) ); - m_stateY = m_stateRadius * sin( DEG2RAD( m_stateTheta / 10.0 ) ); + m_stateTheta = EDA_ANGLE( moveY, DEGREES_T ); + m_stateX = m_stateRadius * m_stateTheta.Cos(); + m_stateY = m_stateRadius * m_stateTheta.Sin(); m_moveX.SetDoubleValue( m_stateX ); m_stateX = m_moveX.GetDoubleValue(); @@ -229,7 +227,7 @@ void DIALOG_MOVE_EXACT::OnClear( wxCommandEvent& event ) } else if( obj == m_clearRot ) { - m_rotate.SetValue( 0 ); + m_rotate.SetAngleValue( ANGLE_0 ); } // Keep m_stdButtonsOK focused to allow enter key actiavte the OK button diff --git a/pcbnew/dialogs/dialog_move_exact.h b/pcbnew/dialogs/dialog_move_exact.h index d1e23d0f1c..9b37dbb97c 100644 --- a/pcbnew/dialogs/dialog_move_exact.h +++ b/pcbnew/dialogs/dialog_move_exact.h @@ -67,10 +67,9 @@ private: /** * Convert a given Cartesian point into a polar representation. * - * Linear units are not considered, the answer is in the same units as given - * Angle is returned in degrees + * Linear units are not considered, the answer is in the same units as given. */ - void ToPolarDeg( double x, double y, double& r, double& q ); + void ToPolarDeg( double x, double y, double& r, EDA_ANGLE& q ); /** * Get the (Cartesian) translation described by the text entries. @@ -111,21 +110,21 @@ private: static MOVE_EXACT_OPTIONS m_options; private: - VECTOR2I& m_translation; - EDA_ANGLE& m_rotation; - ROTATION_ANCHOR& m_rotationAnchor; - const EDA_RECT& m_bbox; + VECTOR2I& m_translation; + EDA_ANGLE& m_rotation; + ROTATION_ANCHOR& m_rotationAnchor; + const EDA_RECT& m_bbox; - UNIT_BINDER m_moveX; - UNIT_BINDER m_moveY; - UNIT_BINDER m_rotate; + UNIT_BINDER m_moveX; + UNIT_BINDER m_moveY; + UNIT_BINDER m_rotate; std::vector m_menuIDs; - double m_stateX; - double m_stateY; - double m_stateRadius; - double m_stateTheta; + double m_stateX; + double m_stateY; + double m_stateRadius; + EDA_ANGLE m_stateTheta; }; #endif // __DIALOG_MOVE_EXACT__ diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index e4964e01c6..6bdb3065c6 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -130,7 +130,7 @@ bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow() } m_hatchRotation.SetUnits( EDA_UNITS::DEGREES ); - m_hatchRotation.SetValue( m_settings.m_HatchOrientation * 10 ); // IU is decidegree + m_hatchRotation.SetAngleValue( EDA_ANGLE( m_settings.m_HatchOrientation, DEGREES_T ) ); // Gives a reasonable value to grid style parameters, if currently there are no defined // parameters for grid pattern thickness and gap (if the value is 0) @@ -197,9 +197,6 @@ bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow() m_settings.SetCornerRadius( m_settings.GetCornerSmoothingType() == ZONE_SETTINGS::SMOOTHING_NONE ? 0 : m_cornerRadius.GetValue() ); - if( !m_hatchRotation.Validate( -1800, 1800 ) ) - return false; - m_settings.m_ZoneMinThickness = m_minWidth.GetValue(); switch( m_OutlineDisplayCtrl->GetSelection() ) @@ -227,7 +224,7 @@ bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow() } - m_settings.m_HatchOrientation = m_hatchRotation.GetValue() / 10.0; // value is returned in deci-degree + m_settings.m_HatchOrientation = m_hatchRotation.GetAngleValue().AsDegrees(); m_settings.m_HatchThickness = m_hatchWidth.GetValue(); m_settings.m_HatchGap = m_hatchGap.GetValue(); m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue(); diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index a561923422..d3d0b7130b 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -196,6 +196,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad m_pad_orientation.SetPrecision( 3 ); m_spokeAngle.SetUnits( EDA_UNITS::DEGREES ); + m_spokeAngle.SetPrecision( 3 ); m_pasteMargin.SetNegativeZero(); @@ -858,13 +859,13 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event ) // what the last shape was. if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CIRCLE ) { - if( m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetDoubleValue() == 900.0 ) - m_spokeAngle.SetDoubleValue( 450.0 ); + if( m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetAngleValue() == ANGLE_90 ) + m_spokeAngle.SetAngleValue( ANGLE_45 ); } else { - if( !m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetDoubleValue() == 450.0 ) - m_spokeAngle.SetDoubleValue( 900.0 ); + if( !m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetAngleValue() == ANGLE_45 ) + m_spokeAngle.SetAngleValue( ANGLE_90 ); } // Readjust props book size diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index 0640bdde4f..87e97ea86e 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -43,8 +43,7 @@ DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, VEC m_yOffset( aParent, m_yLabel, m_yEntry, m_yUnit ), m_stateX( 0.0 ), m_stateY( 0.0 ), - m_stateRadius( 0.0 ), - m_stateTheta( 0.0 ) + m_stateRadius( 0.0 ) { // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics // implementation on MSW @@ -74,12 +73,12 @@ DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, VEC } -void DIALOG_POSITION_RELATIVE::ToPolarDeg( double x, double y, double& r, double& q ) +void DIALOG_POSITION_RELATIVE::ToPolarDeg( double x, double y, double& r, EDA_ANGLE& q ) { // convert to polar coordinates r = hypot( x, y ); - q = ( r != 0) ? RAD2DEG( atan2( y, x ) ) : 0; + q = ( r != 0) ? EDA_ANGLE( VECTOR2D( x, y ) ) : ANGLE_0; } @@ -87,11 +86,11 @@ bool DIALOG_POSITION_RELATIVE::GetTranslationInIU( wxRealPoint& val, bool polar { if( polar ) { - const double r = m_xOffset.GetDoubleValue(); - const double q = m_yOffset.GetDoubleValue(); + const double r = m_xOffset.GetDoubleValue(); + const EDA_ANGLE q = m_yOffset.GetAngleValue(); - val.x = r * cos( DEG2RAD( q / 10.0 ) ); - val.y = r * sin( DEG2RAD( q / 10.0 ) ); + val.x = r * q.Cos(); + val.y = r * q.Sin(); } else { @@ -119,27 +118,26 @@ void DIALOG_POSITION_RELATIVE::OnPolarChanged( wxCommandEvent& event ) m_stateX = xOffset; m_stateY = yOffset; ToPolarDeg( m_stateX, m_stateY, m_stateRadius, m_stateTheta ); - m_stateTheta *= 10.0; m_xOffset.SetDoubleValue( m_stateRadius ); m_stateRadius = m_xOffset.GetDoubleValue(); - m_yOffset.SetDoubleValue( m_stateTheta ); - m_stateTheta = m_yOffset.GetDoubleValue(); + m_yOffset.SetAngleValue( m_stateTheta ); + m_stateTheta = m_yOffset.GetAngleValue(); } else { m_xOffset.SetDoubleValue( m_stateRadius ); - m_yOffset.SetDoubleValue( m_stateTheta ); + m_yOffset.SetAngleValue( m_stateTheta ); } } else { - if( xOffset != m_stateRadius || yOffset != m_stateTheta ) + if( xOffset != m_stateRadius || yOffset != m_stateTheta.AsDegrees() ) { m_stateRadius = xOffset; - m_stateTheta = yOffset; - m_stateX = m_stateRadius * cos( DEG2RAD( m_stateTheta / 10.0 ) ); - m_stateY = m_stateRadius * sin( DEG2RAD( m_stateTheta / 10.0 ) ); + m_stateTheta = EDA_ANGLE( yOffset, DEGREES_T ); + m_stateX = m_stateRadius * m_stateTheta.Cos(); + m_stateY = m_stateRadius * m_stateTheta.Sin(); m_xOffset.SetDoubleValue( m_stateX ); m_stateX = m_xOffset.GetDoubleValue(); @@ -182,8 +180,9 @@ void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event ) POSITION_RELATIVE_TOOL* posrelTool = m_toolMgr->GetTool(); wxASSERT( posrelTool ); - VECTOR2I offset = posrelTool->GetSelectionAnchorPosition() - m_anchor_position; - double r, q; + VECTOR2I offset = posrelTool->GetSelectionAnchorPosition() - m_anchor_position; + double r; + EDA_ANGLE q; ToPolarDeg( offset.x, offset.y, r, q ); @@ -194,28 +193,20 @@ void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event ) m_stateRadius = m_xOffset.GetDoubleValue(); if( m_polarCoords->IsChecked() ) - { m_xOffset.SetDoubleValue( m_stateRadius ); - } else - { m_xOffset.SetValue( m_stateX ); - } } else if( obj == m_clearY ) { m_stateY = offset.y; - m_yOffset.SetDoubleValue( q * 10 ); - m_stateTheta = m_yOffset.GetDoubleValue(); + m_yOffset.SetAngleValue( q ); + m_stateTheta = m_yOffset.GetAngleValue(); if( m_polarCoords->IsChecked() ) - { - m_yOffset.SetDoubleValue( m_stateTheta ); - } + m_yOffset.SetAngleValue( m_stateTheta ); else - { m_yOffset.SetValue( m_stateY ); - } } } diff --git a/pcbnew/dialogs/dialog_position_relative.h b/pcbnew/dialogs/dialog_position_relative.h index 773ada614f..a154e5df49 100644 --- a/pcbnew/dialogs/dialog_position_relative.h +++ b/pcbnew/dialogs/dialog_position_relative.h @@ -58,10 +58,9 @@ private: /** * Convert a given Cartesian point into a polar representation. * - * Linear units are not considered, the answer is in the same units as given - * Angle is returned in degrees + * Linear units are not considered, the answer is in the same units as given. */ - void ToPolarDeg( double x, double y, double& r, double& q ); + void ToPolarDeg( double x, double y, double& r, EDA_ANGLE& q ); /** * Get the (Cartesian) translation described by the text entries. @@ -102,10 +101,10 @@ private: UNIT_BINDER m_xOffset; UNIT_BINDER m_yOffset; - double m_stateX; - double m_stateY; - double m_stateRadius; - double m_stateTheta; + double m_stateX; + double m_stateY; + double m_stateRadius; + EDA_ANGLE m_stateTheta; }; #endif // __DIALOG_POSITION_RELATIVE__ diff --git a/pcbnew/fp_text_grid_table.cpp b/pcbnew/fp_text_grid_table.cpp index 25229de653..61e174eb2c 100644 --- a/pcbnew/fp_text_grid_table.cpp +++ b/pcbnew/fp_text_grid_table.cpp @@ -211,9 +211,7 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol ) return text.GetLayerName(); case FPT_ORIENTATION: - return StringFromValue( EDA_UNITS::DEGREES, - NormalizeAnglePos( text.GetTextAngle().AsTenthsOfADegree() ), - true ); + return StringFromValue( EDA_UNITS::DEGREES, text.GetTextAngle().AsDegrees(), true ); case FPT_XOFFSET: return StringFromValue( m_frame->GetUserUnits(), text.GetPos0().x, true );