diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 7c858150b1..9ec5d9ed3f 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -42,7 +42,9 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, m_label( aLabel ), m_value( aValue ), m_unitLabel( aUnitLabel ), - m_eval( aParent->GetUserUnits(), aUseMils ) + m_eval( aParent->GetUserUnits(), aUseMils ), + m_originTransforms( aParent->GetOriginTransforms() ), + m_coordType( ORIGIN_TRANSFORMS::NOT_A_COORD ) { m_units = aParent->GetUserUnits(); m_useMils = aUseMils; @@ -223,13 +225,16 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits, bool aUs void UNIT_BINDER::SetValue( int aValue ) { - SetValue( StringFromValue( m_units, aValue, false, m_useMils, m_dataType ) ); + double value = aValue; + double displayValue = m_originTransforms.ToDisplay( value, m_coordType ); + SetValue( StringFromValue( m_units, displayValue, false, m_useMils, m_dataType ) ); } void UNIT_BINDER::SetDoubleValue( double aValue ) { - SetValue( StringFromValue( m_units, aValue, false, m_useMils, m_dataType ) ); + double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType ); + SetValue( StringFromValue( m_units, displayValue, false, m_useMils, m_dataType ) ); } @@ -252,7 +257,9 @@ void UNIT_BINDER::SetValue( wxString aValue ) void UNIT_BINDER::ChangeValue( int aValue ) { - ChangeValue( StringFromValue( m_units, aValue, false, m_useMils ) ); + double value = aValue; + double displayValue = m_originTransforms.ToDisplay( value, m_coordType ); + ChangeValue( StringFromValue( m_units, displayValue, false, m_useMils ) ); } @@ -291,7 +298,8 @@ long long int UNIT_BINDER::GetValue() else return 0; - return ValueFromString( m_units, value, m_useMils, m_dataType ); + long long int displayValue = ValueFromString( m_units, value, m_useMils, m_dataType ); + return m_originTransforms.FromDisplay( displayValue, m_coordType ); } @@ -313,7 +321,8 @@ double UNIT_BINDER::GetDoubleValue() else return 0.0; - return DoubleValueFromString( m_units, value, m_useMils, m_dataType ); + double displayValue = DoubleValueFromString( m_units, value, m_useMils, m_dataType ); + return m_originTransforms.FromDisplay( displayValue, m_coordType ); } diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index b875288612..e2b05c7726 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "hotkeys_basic.h" @@ -72,6 +73,9 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER ///< GAL display options - this is the frame's interface to setting GAL display options KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; + /// Default display origin transforms object + ORIGIN_TRANSFORMS m_OriginTransforms; + protected: wxSocketServer* m_socketServer; std::vector m_sockets; ///< interprocess communication @@ -199,6 +203,13 @@ public: */ wxPoint GetNearestGridPosition( const wxPoint& aPosition ) const; + /** + * Return a reference to the default ORIGIN_TRANSFORMS object + */ + virtual ORIGIN_TRANSFORMS& GetOriginTransforms() + { return m_OriginTransforms; } + + virtual const TITLE_BLOCK& GetTitleBlock() const = 0; virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0; diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index 42e53ac415..61e202bd8d 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -153,6 +154,25 @@ public: */ void Show( bool aShow, bool aResize = false ); + /** + * Get the origin transforms coordinate type + * + * @returns the origin transforms coordinate type + */ + ORIGIN_TRANSFORMS::COORD_TYPES_T GetCoordType() const + { + return m_coordType; + } + + /** + * Function SetOriginTransform + * Sets the current origin transform mode + */ + void SetCoordType( ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType ) + { + m_coordType = aCoordType; + } + protected: void onSetFocus( wxFocusEvent& aEvent ); @@ -184,6 +204,12 @@ protected: ///> Selection start and end of the original text long m_selStart; long m_selEnd; + + /// A reference to an ORIGIN_TRANSFORMS object + ORIGIN_TRANSFORMS& m_originTransforms; + + /// Type of coordinate for display origin transforms + ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType; }; #endif /* __UNIT_BINDER_H_ */