truncate angle values in Segment properties
This commit is contained in:
parent
6429051750
commit
8d7255aae3
|
@ -309,6 +309,14 @@ public:
|
|||
|
||||
EDA_ANGLE KeepUpright() const;
|
||||
|
||||
EDA_ANGLE& Truncate( int digits ) const
|
||||
{
|
||||
EDA_ANGLE angle( *this );
|
||||
double truncated = KiROUND( angle.AsDegrees() * pow( 10.0, digits ) ) / pow( 10.0, digits );
|
||||
angle = EDA_ANGLE( truncated , DEGREES_T );
|
||||
return angle;
|
||||
}
|
||||
|
||||
EDA_ANGLE& operator+=( const EDA_ANGLE& aAngle )
|
||||
{
|
||||
*this = EDA_ANGLE( AsDegrees() + aAngle.AsDegrees(), DEGREES_T );
|
||||
|
|
|
@ -126,6 +126,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_BASE_EDIT_FR
|
|||
|
||||
m_segmentLength.SetUnits( EDA_UNITS::MILLIMETRES );
|
||||
m_segmentAngle.SetUnits( EDA_UNITS::DEGREES );
|
||||
m_segmentAngle.SetPrecision( 4 );
|
||||
|
||||
m_rectangleHeight.SetUnits( EDA_UNITS::MILLIMETRES );
|
||||
m_rectangleWidth.SetUnits( EDA_UNITS::MILLIMETRES );
|
||||
|
@ -402,7 +403,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
|
|||
if( m_item->GetShape() == SHAPE_T::SEGMENT )
|
||||
{
|
||||
segment_length = m_item->GetLength();
|
||||
segment_angle = m_item->GetSegmentAngle();
|
||||
segment_angle = m_item->GetSegmentAngle().Truncate( 3 );
|
||||
}
|
||||
|
||||
if( m_item->GetShape() == SHAPE_T::RECT )
|
||||
|
@ -448,12 +449,12 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
|
|||
difference = -difference;
|
||||
|
||||
bool change_angle =
|
||||
( difference > EDA_ANGLE( 0.00001, TENTHS_OF_A_DEGREE_T ) );
|
||||
( difference > EDA_ANGLE( 0.0005, DEGREES_T ) );
|
||||
|
||||
if( !( change_begin && change_end ) )
|
||||
{
|
||||
segment_length = m_segmentLength.GetValue();
|
||||
segment_angle = m_segmentAngle.GetAngleValue();
|
||||
segment_angle = m_segmentAngle.GetAngleValue().Truncate( 3 );
|
||||
|
||||
if( change_length || change_angle )
|
||||
{
|
||||
|
@ -480,9 +481,9 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
|
|||
m_item->SetLength( m_item->GetLength() );
|
||||
|
||||
if( change_angle )
|
||||
m_item->SetAngle( m_segmentAngle.GetAngleValue() );
|
||||
m_item->SetAngle( m_segmentAngle.GetAngleValue().Truncate( 3 ) );
|
||||
else
|
||||
m_item->SetAngle( m_item->GetSegmentAngle() );
|
||||
m_item->SetAngle( m_item->GetSegmentAngle().Truncate( 3 ) );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,14 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind
|
|||
gbSizer2->Add( m_segmentAngleLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_segmentAngleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
#ifdef __WXGTK__
|
||||
if ( !m_segmentAngleCtrl->HasFlag( wxTE_MULTILINE ) )
|
||||
{
|
||||
m_segmentAngleCtrl->SetMaxLength( 7 );
|
||||
}
|
||||
#else
|
||||
m_segmentAngleCtrl->SetMaxLength( 7 );
|
||||
#endif
|
||||
gbSizer2->Add( m_segmentAngleCtrl, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxTOP, 5 );
|
||||
|
||||
m_segmentAngleUnits = new wxStaticText( this, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
|
|
@ -2720,7 +2720,7 @@
|
|||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength">0</property>
|
||||
<property name="maxlength">7</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
|
|
Loading…
Reference in New Issue