Add ORIGIN_TRANSFORMS to the UNIT_BINDER and EDA_DRAW_FRAME classes
This commit modifies the UNIT_BINDER class to invoke the ORIGIN_TRANSFORMS methods to support Display Origin Transforms. The EDA_DRAW_FRAME class is modified to instantiate an ORIGIN_TRANSFORMS object providing null transforms. A function is provided to allow the UNIT_BINDER to find the ORIGIN_TRANSFORMS object in an overrideable manner.
This commit is contained in:
parent
3fec2805ec
commit
6e25b7d455
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <gal/gal_display_options.h>
|
||||
#include <gal/color4d.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <origin_transforms.h>
|
||||
#include <wx/fdrepdlg.h>
|
||||
#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<wxSocketBase*> 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;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <common.h>
|
||||
#include <base_units.h>
|
||||
#include <base_struct.h>
|
||||
#include <origin_transforms.h>
|
||||
#include <libeval/numeric_evaluator.h>
|
||||
|
||||
|
||||
|
@ -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_ */
|
||||
|
|
Loading…
Reference in New Issue