Small Update for physical length lib. - wxPoint supported

This commit is contained in:
Vladimir Ur 2011-06-22 20:33:59 +04:00
parent 35ec6ff5a4
commit ea8f9c61ed
1 changed files with 40 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#define UNITS_H_INCLUDED 1 #define UNITS_H_INCLUDED 1
#include <math.h> #include <math.h>
#include <wx/gdicmn.h>
/**********************************************/ /**********************************************/
/*! I'm a physical length */ /*! I'm a physical length */
/**********************************************/ /**********************************************/
@ -388,7 +389,7 @@ public:
} }
/*! /*!
* A point ( or vector ) given x and y multiplies of some unit. * A point ( or vector ) given x and y multiplies of specified unit.
* Given just for a convenience, you can use ( x*unit, y*unit ) instead. * Given just for a convenience, you can use ( x*unit, y*unit ) instead.
* @param x coordinate factor * @param x coordinate factor
* @param y coordinate factor * @param y coordinate factor
@ -398,6 +399,24 @@ public:
{ {
} }
/*!
* A point ( or vector ) given wxPoint and unit
* @param x wxPoint
* @param unit the unit
*/
LENGTH_XY( wxPoint x, const LENGTH unit ) : m_X( unit * x.x ), m_Y( unit * x.y )
{
}
/*!
* A point ( or vector ) given wxRealPoint and unit
* @param x wxRealPoint
* @param unit the unit
*/
LENGTH_XY( wxRealPoint x, const LENGTH unit ) : m_X( unit * x.x ), m_Y( unit * x.y )
{
}
/*! /*!
* x coordinate * x coordinate
* @return x coordinate * @return x coordinate
@ -612,6 +631,26 @@ public:
return *this; return *this;
} }
/*!
* Outputs wxPoint in specified scale.
* @param y scale
* @return wxPoint
*/
const wxPoint toWxPoint ( LENGTH y ) const
{
return wxPoint( m_X.idiv( y ), m_Y.idiv( y ) );
}
/*!
* Outputs wxRealPoint in specified scale.
* @param y scale
* @return wxPoint
*/
const wxRealPoint toWxRealPoint ( LENGTH y ) const
{
return wxRealPoint( m_X / y, m_Y / y );
}
/*! /*!
* Rotates vector 90 degrees ( X axis towards Y ) * Rotates vector 90 degrees ( X axis towards Y )
* @return rotated * @return rotated