2016-09-29 04:43:24 -05:00
|
|
|
|
|
|
|
#include "cafDisplayCoordTransform.h"
|
|
|
|
#include "cvfMatrix4.h"
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::DisplayCoordTransform::DisplayCoordTransform()
|
|
|
|
: m_scale(1.0, 1.0, 1.0),
|
|
|
|
m_translation(cvf::Vec3d::ZERO)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void caf::DisplayCoordTransform::setScale(const cvf::Vec3d& scale)
|
|
|
|
{
|
|
|
|
m_scale = scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void caf::DisplayCoordTransform::setTranslation(const cvf::Vec3d& translation)
|
|
|
|
{
|
|
|
|
m_translation = translation;
|
|
|
|
}
|
|
|
|
|
2017-01-09 00:43:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d caf::DisplayCoordTransform::translateToDisplayCoord(const cvf::Vec3d& domainCoord) const
|
|
|
|
{
|
|
|
|
return domainCoord - m_translation;
|
|
|
|
}
|
|
|
|
|
2016-09-29 04:43:24 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d caf::DisplayCoordTransform::transformToDisplayCoord(const cvf::Vec3d& domainCoord) const
|
|
|
|
{
|
2017-01-09 00:43:17 -06:00
|
|
|
cvf::Vec3d coord = translateToDisplayCoord(domainCoord);
|
|
|
|
|
2016-09-29 04:43:24 -05:00
|
|
|
coord.x() *= m_scale.x();
|
|
|
|
coord.y() *= m_scale.y();
|
|
|
|
coord.z() *= m_scale.z();
|
|
|
|
|
|
|
|
return coord;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d caf::DisplayCoordTransform::scaleToDisplaySize(const cvf::Vec3d& domainSize) const
|
|
|
|
{
|
|
|
|
cvf::Vec3d coord = domainSize;
|
|
|
|
coord.x() *= m_scale.x();
|
|
|
|
coord.y() *= m_scale.y();
|
|
|
|
coord.z() *= m_scale.z();
|
|
|
|
|
|
|
|
return coord;
|
|
|
|
}
|
2016-09-29 04:43:47 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-09 00:43:17 -06:00
|
|
|
cvf::Vec3d caf::DisplayCoordTransform::translateToDomainCoord(const cvf::Vec3d& displayCoord) const
|
2016-09-29 04:43:47 -05:00
|
|
|
{
|
2017-01-09 00:43:17 -06:00
|
|
|
return displayCoord + m_translation;
|
|
|
|
}
|
2016-09-29 04:43:47 -05:00
|
|
|
|
2017-01-09 00:43:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d caf::DisplayCoordTransform::transformToDomainCoord(const cvf::Vec3d& displayCoord) const
|
|
|
|
{
|
|
|
|
cvf::Vec3d unScaledDisplayCoord = displayCoord;
|
|
|
|
unScaledDisplayCoord.x() /= m_scale.x();
|
|
|
|
unScaledDisplayCoord.y() /= m_scale.y();
|
|
|
|
unScaledDisplayCoord.z() /= m_scale.z();
|
2016-09-29 04:43:47 -05:00
|
|
|
|
2017-01-09 00:43:17 -06:00
|
|
|
return translateToDomainCoord(unScaledDisplayCoord);
|
2016-09-29 04:43:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d caf::DisplayCoordTransform::scaleToDomainSize(const cvf::Vec3d& displaySize) const
|
|
|
|
{
|
|
|
|
cvf::Vec3d coord = displaySize;
|
|
|
|
coord.x() /= m_scale.x();
|
|
|
|
coord.y() /= m_scale.y();
|
|
|
|
coord.z() /= m_scale.z();
|
|
|
|
|
|
|
|
return coord;
|
|
|
|
}
|