数据类
BaseData->SlicedData->Image
void mitk::DisplayActionEventBroadcast::StartRotation(StateMachineAction* /*stateMachineAction*/, InteractionEvent* /*interactionEvent*/)
{
SetMouseCursor(rotate_cursor_xpm, 0, 0);
}
void mitk::DisplayActionEventBroadcast::EndRotation(StateMachineAction* /*stateMachineAction*/, InteractionEvent* /*interactionEvent*/)
{
ResetMouseCursor();
}
斜切部分核心代码
void mitk::DisplayActionEventBroadcast::Rotate(StateMachineAction* /*stateMachineAction*/, InteractionEvent* interactionEvent)
{
const auto* positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (nullptr == positionEvent)
{
return;
}
Point3D position = positionEvent->GetPositionInWorld();
Vector3D toProjected = m_LastCursorPosition - m_CenterOfRotation;
Vector3D toCursor = position - m_CenterOfRotation;
// cross product: | A x B | = |A| * |B| * sin(angle)
Vector3D axisOfRotation;
vnl_vector_fixed<ScalarType, 3> vnlDirection = vnl_cross_3d(toCursor.GetVnlVector(), toProjected.GetVnlVector());
axisOfRotation.SetVnlVector(vnlDirection);
// scalar product: A * B = |A| * |B| * cos(angle)
// tan = sin / cos
ScalarType angle = -atan2((double)(axisOfRotation.GetNorm()), (double)(toCursor * toProjected));
angle *= 180.0 / vnl_math::pi;
m_LastCursorPosition = position;
// create RotationOperation and apply to all SNCs that should be rotated
RotationOperation rotationOperation(OpROTATE, m_CenterOfRotation, axisOfRotation, angle);
// iterate the OTHER slice navigation controllers
for (auto iter = m_SNCsToBeRotated.begin(); iter != m_SNCsToBeRotated.end(); ++iter)
{
TimeGeometry* timeGeometry = (*iter)->GetCreatedWorldGeometry();
if (nullptr == timeGeometry)
{
continue;
}
timeGeometry->ExecuteOperation(&rotationOperation);
(*iter)->SendCreatedWorldGeometryUpdate();
}
RenderingManager::GetInstance()->RequestUpdateAll();
}