Excise deci-degrees from UNIT_BINDER.

Fixes https://gitlab.com/kicad/code/kicad/issues/10495
This commit is contained in:
Jeff Young 2022-01-18 23:20:48 +00:00
parent 57afdf153d
commit 0091c76a6f
17 changed files with 148 additions and 154 deletions

View File

@ -220,7 +220,7 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
*/ */
static double rotationFromString( const wxString& aValue ) 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 ) if( rotation > MAX_ROTATION )
{ {
@ -376,7 +376,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS
else if( spinCtrl == m_spinZrot ) else if( spinCtrl == m_spinZrot )
textCtrl = zrot; 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 += ( ROTATION_INCREMENT * aSign );
curr_value = std::max( -MAX_ROTATION, curr_value ); curr_value = std::max( -MAX_ROTATION, curr_value );
@ -447,7 +447,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
if( event.GetWheelRotation() >= 0 ) if( event.GetWheelRotation() >= 0 )
step = -step; 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 += step;
curr_value = std::max( -MAX_ROTATION, curr_value ); curr_value = std::max( -MAX_ROTATION, curr_value );

View File

@ -78,7 +78,7 @@ double To_User_Unit( EDA_UNITS aUnit, double aValue )
return IU_TO_IN( aValue ); return IU_TO_IN( aValue );
case EDA_UNITS::DEGREES: case EDA_UNITS::DEGREES:
return aValue / 10.0f; return aValue;
default: default:
return aValue; return aValue;
@ -260,11 +260,8 @@ double From_User_Unit( EDA_UNITS aUnits, double aValue )
case EDA_UNITS::INCHES: case EDA_UNITS::INCHES:
return IN_TO_IU( aValue ); return IN_TO_IU( aValue );
case EDA_UNITS::DEGREES:
// Convert to "decidegrees"
return aValue * 10;
default: default:
case EDA_UNITS::DEGREES:
case EDA_UNITS::UNSCALED: case EDA_UNITS::UNSCALED:
case EDA_UNITS::PERCENT: case EDA_UNITS::PERCENT:
return aValue; return aValue;
@ -329,10 +326,8 @@ double DoubleValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, EDA_
else if( aUnits == EDA_UNITS::DEGREES ) else if( aUnits == EDA_UNITS::DEGREES )
{ {
if( unit == wxT( "ra" ) ) // Radians if( unit == wxT( "ra" ) ) // Radians
{
dtmp *= 180.0f / M_PI; dtmp *= 180.0f / M_PI;
} }
}
switch( aType ) switch( aType )
{ {

View File

@ -109,10 +109,11 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// draw the radius guide circle // draw the radius guide circle
preview_ctx.DrawCircle( origin, m_constructMan.GetRadius(), true ); 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( "r", m_constructMan.GetRadius(), m_units ) );
cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), angle.AsDegrees(),
EDA_UNITS::DEGREES ) ); EDA_UNITS::DEGREES ) );
} }
else else
@ -121,15 +122,15 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
double start = m_constructMan.GetStartAngle(); double start = m_constructMan.GetStartAngle();
double subtended = m_constructMan.GetSubtended(); double subtended = m_constructMan.GetSubtended();
double subtendedDeg = getNormDeciDegFromRad( subtended ); EDA_ANGLE incAngle( subtended, RADIANS_T );
double endAngleDeg = getNormDeciDegFromRad( start + subtended ); EDA_ANGLE endAngle( start + subtended, RADIANS_T );
// draw dimmed extender line to cursor // draw dimmed extender line to cursor
preview_ctx.DrawLineWithAngleHighlight( origin, m_constructMan.GetLastPoint(), true ); 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 ) ); EDA_UNITS::DEGREES ) );
cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), endAngleDeg, cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), endAngle.AsDegrees(),
EDA_UNITS::DEGREES ) ); EDA_UNITS::DEGREES ) );
} }

View File

@ -72,8 +72,8 @@ static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor,
cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), aUnits ) ); cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), aUnits ) );
double degs = RAD2DECIDEG( -aRulerVec.Angle() ); EDA_ANGLE angle( -aRulerVec.Angle(), RADIANS_T );
cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), angle.AsDegrees(),
EDA_UNITS::DEGREES ) ); EDA_UNITS::DEGREES ) );
temp = aRulerVec; temp = aRulerVec;

View File

@ -276,9 +276,6 @@ void UNIT_BINDER::SetDoubleValue( double aValue )
void UNIT_BINDER::SetAngleValue( const EDA_ANGLE& 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,9 +324,6 @@ void UNIT_BINDER::ChangeDoubleValue( double aValue )
void UNIT_BINDER::ChangeAngleValue( const EDA_ANGLE& 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,9 +420,6 @@ double UNIT_BINDER::GetDoubleValue()
EDA_ANGLE UNIT_BINDER::GetAngleValue() 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 );
} }

View File

@ -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 ) void WIDGET_SAVE_RESTORE::Add( wxChoice& ctrl, long& dest )
{ {
m_ctrls.emplace_back( WIDGET_CTRL_TYPE_T::CHOICE, ctrl, 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(); *ctrl.m_dest.m_long = ctrl.m_control.m_unit_binder->GetValue();
break; 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: case WIDGET_CTRL_TYPE_T::CHOICE:
*ctrl.m_dest.m_long = ctrl.m_control.m_choice->GetSelection(); *ctrl.m_dest.m_long = ctrl.m_control.m_choice->GetSelection();
break; break;
@ -168,6 +177,10 @@ void WIDGET_SAVE_RESTORE::RestoreConfigToControls()
ctrl.m_control.m_unit_binder->SetValue( *ctrl.m_dest.m_long ); ctrl.m_control.m_unit_binder->SetValue( *ctrl.m_dest.m_long );
break; 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: case WIDGET_CTRL_TYPE_T::CHOICE:
ctrl.m_control.m_choice->SetSelection( *ctrl.m_dest.m_long ); ctrl.m_control.m_choice->SetSelection( *ctrl.m_dest.m_long );
break; break;

View File

@ -886,14 +886,13 @@ void GERBVIEW_FRAME::UpdateStatusBar()
if( GetShowPolarCoords() ) // display relative polar coordinates if( GetShowPolarCoords() ) // display relative polar coordinates
{ {
double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x; VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin;
double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y; EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) );
double theta = RAD2DEG( atan2( -dy, dx ) ); double ro = hypot( v.x, v.y );
double ro = hypot( dx, dy );
line.Printf( wxT( "r %s theta %s" ), line.Printf( wxT( "r %s theta %s" ),
MessageTextFromValue( GetUserUnits(), ro, false ), MessageTextFromValue( GetUserUnits(), ro, false ),
MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) ); MessageTextFromValue( EDA_UNITS::DEGREES, theta.AsDegrees(), false ) );
SetStatusText( line, 3 ); SetStatusText( line, 3 );
} }

View File

@ -35,6 +35,7 @@ class wxString;
class wxTextCtrl; class wxTextCtrl;
class UNIT_BINDER; class UNIT_BINDER;
class EDA_ANGLE;
class WIDGET_SAVE_RESTORE class WIDGET_SAVE_RESTORE
{ {
@ -82,6 +83,11 @@ public:
*/ */
void Add( UNIT_BINDER& ctrl, long& dest ); 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 * Bind a choice control into a choice (agnostic to the actual
* meaning of the choice) * meaning of the choice)
@ -116,6 +122,7 @@ private:
TEXT_INTEGER, TEXT_INTEGER,
TEXT_DOUBLE, TEXT_DOUBLE,
UNIT_BINDER, UNIT_BINDER,
UNIT_BINDER_ANGLE,
CHECKBOX, CHECKBOX,
RADIOBUTTON, RADIOBUTTON,
RADIOBOX, RADIOBOX,
@ -189,10 +196,16 @@ private:
{ {
} }
DATA( EDA_ANGLE* aDest ) :
m_angle( aDest )
{
}
long* m_long; long* m_long;
bool* m_bool; bool* m_bool;
wxString* m_str; wxString* m_str;
double* m_double; double* m_double;
EDA_ANGLE* m_angle;
}; };
/** /**

View File

@ -270,7 +270,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow()
} }
m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES ); 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 // 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) // parameters for grid pattern thickness and gap (if the value is 0)
@ -419,7 +419,7 @@ bool DIALOG_COPPER_ZONE::TransferDataFromWindow()
if( !AcceptOptions() ) if( !AcceptOptions() )
return false; 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_HatchThickness = m_gridStyleThickness.GetValue();
m_settings.m_HatchGap = m_gridStyleGap.GetValue(); m_settings.m_HatchGap = m_gridStyleGap.GetValue();
m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue(); m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue();

View File

@ -63,7 +63,6 @@ struct CREATE_ARRAY_DIALOG_ENTRIES
m_GridSecondaryAxisStep( 1 ), m_GridSecondaryAxisStep( 1 ),
m_CircCentreX( 0 ), m_CircCentreX( 0 ),
m_CircCentreY( 0 ), m_CircCentreY( 0 ),
m_CircAngle( 0.0 ),
m_CircCount( 4 ), m_CircCount( 4 ),
m_CircNumStartSet( 1 ), // use specified start m_CircNumStartSet( 1 ), // use specified start
m_GridCircNumScheme( 0 ), m_GridCircNumScheme( 0 ),
@ -100,7 +99,7 @@ struct CREATE_ARRAY_DIALOG_ENTRIES
long m_CircCentreX; long m_CircCentreX;
long m_CircCentreY; long m_CircCentreY;
long m_CircAngle; EDA_ANGLE m_CircAngle;
long m_CircCount; long m_CircCount;
long m_CircNumStartSet; long m_CircNumStartSet;
long m_GridCircNumScheme; long m_GridCircNumScheme;

View File

@ -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_rotate( aParent, m_rotLabel, m_rotEntry, m_rotUnit ),
m_stateX( 0.0 ), m_stateX( 0.0 ),
m_stateY( 0.0 ), m_stateY( 0.0 ),
m_stateRadius( 0.0 ), m_stateRadius( 0.0 )
m_stateTheta( 0.0 )
{ {
// We can't set the tab order through wxWidgets due to shortcomings in their mnemonics // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics
// implementation on MSW // 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 // convert to polar coordinates
r = hypot( x, y ); r = hypot( x, y );
q = ( r != 0) ? RAD2DEG( atan2( y, x ) ) : 0; q = ( r != 0) ? EDA_ANGLE( VECTOR2D( x, y ) ) : ANGLE_0;
} }
@ -129,10 +128,10 @@ bool DIALOG_MOVE_EXACT::GetTranslationInIU( wxRealPoint& val, bool polar )
if( polar ) if( polar )
{ {
const double r = m_moveX.GetDoubleValue(); const double r = m_moveX.GetDoubleValue();
const double q = m_moveY.GetDoubleValue(); const EDA_ANGLE q = m_moveY.GetAngleValue();
val.x = r * cos( DEG2RAD( q / 10.0 ) ); val.x = r * q.Cos();
val.y = r * sin( DEG2RAD( q / 10.0 ) ); val.y = r * q.Sin();
} }
else else
{ {
@ -160,27 +159,26 @@ void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event )
m_stateX = moveX; m_stateX = moveX;
m_stateY = moveY; m_stateY = moveY;
ToPolarDeg( m_stateX, m_stateY, m_stateRadius, m_stateTheta ); ToPolarDeg( m_stateX, m_stateY, m_stateRadius, m_stateTheta );
m_stateTheta *= 10.0;
m_moveX.SetDoubleValue( m_stateRadius ); m_moveX.SetDoubleValue( m_stateRadius );
m_stateRadius = m_moveX.GetDoubleValue(); m_stateRadius = m_moveX.GetDoubleValue();
m_moveY.SetDoubleValue( m_stateTheta ); m_moveY.SetAngleValue( m_stateTheta );
m_stateTheta = m_moveY.GetDoubleValue(); m_stateTheta = m_moveY.GetAngleValue();
} }
else else
{ {
m_moveX.SetDoubleValue( m_stateRadius ); m_moveX.SetDoubleValue( m_stateRadius );
m_moveY.SetDoubleValue( m_stateTheta ); m_moveY.SetAngleValue( m_stateTheta );
} }
} }
else else
{ {
if( moveX != m_stateRadius || moveY != m_stateTheta ) if( moveX != m_stateRadius || moveY != m_stateTheta.AsDegrees() )
{ {
m_stateRadius = moveX; m_stateRadius = moveX;
m_stateTheta = moveY; m_stateTheta = EDA_ANGLE( moveY, DEGREES_T );
m_stateX = m_stateRadius * cos( DEG2RAD( m_stateTheta / 10.0 ) ); m_stateX = m_stateRadius * m_stateTheta.Cos();
m_stateY = m_stateRadius * sin( DEG2RAD( m_stateTheta / 10.0 ) ); m_stateY = m_stateRadius * m_stateTheta.Sin();
m_moveX.SetDoubleValue( m_stateX ); m_moveX.SetDoubleValue( m_stateX );
m_stateX = m_moveX.GetDoubleValue(); m_stateX = m_moveX.GetDoubleValue();
@ -229,7 +227,7 @@ void DIALOG_MOVE_EXACT::OnClear( wxCommandEvent& event )
} }
else if( obj == m_clearRot ) 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 // Keep m_stdButtonsOK focused to allow enter key actiavte the OK button

View File

@ -67,10 +67,9 @@ private:
/** /**
* Convert a given Cartesian point into a polar representation. * Convert a given Cartesian point into a polar representation.
* *
* Linear units are not considered, the answer is in the same units as given * Linear units are not considered, the answer is in the same units as given.
* Angle is returned in degrees
*/ */
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. * Get the (Cartesian) translation described by the text entries.
@ -125,7 +124,7 @@ private:
double m_stateX; double m_stateX;
double m_stateY; double m_stateY;
double m_stateRadius; double m_stateRadius;
double m_stateTheta; EDA_ANGLE m_stateTheta;
}; };
#endif // __DIALOG_MOVE_EXACT__ #endif // __DIALOG_MOVE_EXACT__

View File

@ -130,7 +130,7 @@ bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow()
} }
m_hatchRotation.SetUnits( EDA_UNITS::DEGREES ); 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 // 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) // 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 m_settings.SetCornerRadius( m_settings.GetCornerSmoothingType() == ZONE_SETTINGS::SMOOTHING_NONE
? 0 : m_cornerRadius.GetValue() ); ? 0 : m_cornerRadius.GetValue() );
if( !m_hatchRotation.Validate( -1800, 1800 ) )
return false;
m_settings.m_ZoneMinThickness = m_minWidth.GetValue(); m_settings.m_ZoneMinThickness = m_minWidth.GetValue();
switch( m_OutlineDisplayCtrl->GetSelection() ) 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_HatchThickness = m_hatchWidth.GetValue();
m_settings.m_HatchGap = m_hatchGap.GetValue(); m_settings.m_HatchGap = m_hatchGap.GetValue();
m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue(); m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue();

View File

@ -196,6 +196,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_pad_orientation.SetPrecision( 3 ); m_pad_orientation.SetPrecision( 3 );
m_spokeAngle.SetUnits( EDA_UNITS::DEGREES ); m_spokeAngle.SetUnits( EDA_UNITS::DEGREES );
m_spokeAngle.SetPrecision( 3 );
m_pasteMargin.SetNegativeZero(); m_pasteMargin.SetNegativeZero();
@ -858,13 +859,13 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
// what the last shape was. // what the last shape was.
if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CIRCLE ) if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CIRCLE )
{ {
if( m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetDoubleValue() == 900.0 ) if( m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetAngleValue() == ANGLE_90 )
m_spokeAngle.SetDoubleValue( 450.0 ); m_spokeAngle.SetAngleValue( ANGLE_45 );
} }
else else
{ {
if( !m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetDoubleValue() == 450.0 ) if( !m_sizeYCtrl->IsEnabled() && m_spokeAngle.GetAngleValue() == ANGLE_45 )
m_spokeAngle.SetDoubleValue( 900.0 ); m_spokeAngle.SetAngleValue( ANGLE_90 );
} }
// Readjust props book size // Readjust props book size

View File

@ -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_yOffset( aParent, m_yLabel, m_yEntry, m_yUnit ),
m_stateX( 0.0 ), m_stateX( 0.0 ),
m_stateY( 0.0 ), m_stateY( 0.0 ),
m_stateRadius( 0.0 ), m_stateRadius( 0.0 )
m_stateTheta( 0.0 )
{ {
// We can't set the tab order through wxWidgets due to shortcomings in their mnemonics // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics
// implementation on MSW // 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 // convert to polar coordinates
r = hypot( x, y ); r = hypot( x, y );
q = ( r != 0) ? RAD2DEG( atan2( y, x ) ) : 0; q = ( r != 0) ? EDA_ANGLE( VECTOR2D( x, y ) ) : ANGLE_0;
} }
@ -88,10 +87,10 @@ bool DIALOG_POSITION_RELATIVE::GetTranslationInIU( wxRealPoint& val, bool polar
if( polar ) if( polar )
{ {
const double r = m_xOffset.GetDoubleValue(); const double r = m_xOffset.GetDoubleValue();
const double q = m_yOffset.GetDoubleValue(); const EDA_ANGLE q = m_yOffset.GetAngleValue();
val.x = r * cos( DEG2RAD( q / 10.0 ) ); val.x = r * q.Cos();
val.y = r * sin( DEG2RAD( q / 10.0 ) ); val.y = r * q.Sin();
} }
else else
{ {
@ -119,27 +118,26 @@ void DIALOG_POSITION_RELATIVE::OnPolarChanged( wxCommandEvent& event )
m_stateX = xOffset; m_stateX = xOffset;
m_stateY = yOffset; m_stateY = yOffset;
ToPolarDeg( m_stateX, m_stateY, m_stateRadius, m_stateTheta ); ToPolarDeg( m_stateX, m_stateY, m_stateRadius, m_stateTheta );
m_stateTheta *= 10.0;
m_xOffset.SetDoubleValue( m_stateRadius ); m_xOffset.SetDoubleValue( m_stateRadius );
m_stateRadius = m_xOffset.GetDoubleValue(); m_stateRadius = m_xOffset.GetDoubleValue();
m_yOffset.SetDoubleValue( m_stateTheta ); m_yOffset.SetAngleValue( m_stateTheta );
m_stateTheta = m_yOffset.GetDoubleValue(); m_stateTheta = m_yOffset.GetAngleValue();
} }
else else
{ {
m_xOffset.SetDoubleValue( m_stateRadius ); m_xOffset.SetDoubleValue( m_stateRadius );
m_yOffset.SetDoubleValue( m_stateTheta ); m_yOffset.SetAngleValue( m_stateTheta );
} }
} }
else else
{ {
if( xOffset != m_stateRadius || yOffset != m_stateTheta ) if( xOffset != m_stateRadius || yOffset != m_stateTheta.AsDegrees() )
{ {
m_stateRadius = xOffset; m_stateRadius = xOffset;
m_stateTheta = yOffset; m_stateTheta = EDA_ANGLE( yOffset, DEGREES_T );
m_stateX = m_stateRadius * cos( DEG2RAD( m_stateTheta / 10.0 ) ); m_stateX = m_stateRadius * m_stateTheta.Cos();
m_stateY = m_stateRadius * sin( DEG2RAD( m_stateTheta / 10.0 ) ); m_stateY = m_stateRadius * m_stateTheta.Sin();
m_xOffset.SetDoubleValue( m_stateX ); m_xOffset.SetDoubleValue( m_stateX );
m_stateX = m_xOffset.GetDoubleValue(); m_stateX = m_xOffset.GetDoubleValue();
@ -183,7 +181,8 @@ void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event )
wxASSERT( posrelTool ); wxASSERT( posrelTool );
VECTOR2I offset = posrelTool->GetSelectionAnchorPosition() - m_anchor_position; VECTOR2I offset = posrelTool->GetSelectionAnchorPosition() - m_anchor_position;
double r, q; double r;
EDA_ANGLE q;
ToPolarDeg( offset.x, offset.y, r, q ); ToPolarDeg( offset.x, offset.y, r, q );
@ -194,30 +193,22 @@ void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event )
m_stateRadius = m_xOffset.GetDoubleValue(); m_stateRadius = m_xOffset.GetDoubleValue();
if( m_polarCoords->IsChecked() ) if( m_polarCoords->IsChecked() )
{
m_xOffset.SetDoubleValue( m_stateRadius ); m_xOffset.SetDoubleValue( m_stateRadius );
}
else else
{
m_xOffset.SetValue( m_stateX ); m_xOffset.SetValue( m_stateX );
} }
}
else if( obj == m_clearY ) else if( obj == m_clearY )
{ {
m_stateY = offset.y; m_stateY = offset.y;
m_yOffset.SetDoubleValue( q * 10 ); m_yOffset.SetAngleValue( q );
m_stateTheta = m_yOffset.GetDoubleValue(); m_stateTheta = m_yOffset.GetAngleValue();
if( m_polarCoords->IsChecked() ) if( m_polarCoords->IsChecked() )
{ m_yOffset.SetAngleValue( m_stateTheta );
m_yOffset.SetDoubleValue( m_stateTheta );
}
else else
{
m_yOffset.SetValue( m_stateY ); m_yOffset.SetValue( m_stateY );
} }
} }
}
void DIALOG_POSITION_RELATIVE::OnSelectItemClick( wxCommandEvent& event ) void DIALOG_POSITION_RELATIVE::OnSelectItemClick( wxCommandEvent& event )

View File

@ -58,10 +58,9 @@ private:
/** /**
* Convert a given Cartesian point into a polar representation. * Convert a given Cartesian point into a polar representation.
* *
* Linear units are not considered, the answer is in the same units as given * Linear units are not considered, the answer is in the same units as given.
* Angle is returned in degrees
*/ */
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. * Get the (Cartesian) translation described by the text entries.
@ -105,7 +104,7 @@ private:
double m_stateX; double m_stateX;
double m_stateY; double m_stateY;
double m_stateRadius; double m_stateRadius;
double m_stateTheta; EDA_ANGLE m_stateTheta;
}; };
#endif // __DIALOG_POSITION_RELATIVE__ #endif // __DIALOG_POSITION_RELATIVE__

View File

@ -211,9 +211,7 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol )
return text.GetLayerName(); return text.GetLayerName();
case FPT_ORIENTATION: case FPT_ORIENTATION:
return StringFromValue( EDA_UNITS::DEGREES, return StringFromValue( EDA_UNITS::DEGREES, text.GetTextAngle().AsDegrees(), true );
NormalizeAnglePos( text.GetTextAngle().AsTenthsOfADegree() ),
true );
case FPT_XOFFSET: case FPT_XOFFSET:
return StringFromValue( m_frame->GetUserUnits(), text.GetPos0().x, true ); return StringFromValue( m_frame->GetUserUnits(), text.GetPos0().x, true );