AppFwk : Added DisplayCoordTransform

This commit is contained in:
Magne Sjaastad 2016-09-29 11:43:24 +02:00
parent d4bdbcb7c8
commit de11836e03
3 changed files with 86 additions and 0 deletions

View File

@ -15,6 +15,8 @@ include_directories(
)
add_library( ${PROJECT_NAME}
cafDisplayCoordTransform.cpp
cafDisplayCoordTransform.h
cafBoxManipulatorPartManager.cpp
cafBoxManipulatorPartManager.h
cafBoxManipulatorGeometryGenerator.cpp

View File

@ -0,0 +1,54 @@
#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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d caf::DisplayCoordTransform::transformToDisplayCoord(const cvf::Vec3d& domainCoord) const
{
cvf::Vec3d coord = domainCoord - m_translation;
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;
}

View File

@ -0,0 +1,30 @@
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace caf {
//==================================================================================================
//
//
//==================================================================================================
class DisplayCoordTransform : public cvf::Object
{
public:
DisplayCoordTransform();
void setScale(const cvf::Vec3d& scale);
void setTranslation(const cvf::Vec3d& translation);
cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const;
cvf::Vec3d scaleToDisplaySize(const cvf::Vec3d& domainSize) const;
private:
cvf::Vec3d m_scale;
cvf::Vec3d m_translation;
};
}