23 #include <vtkCamera.h> 24 #include <vtkInteractorStyle.h> 25 #include <vtkMatrix4x4.h> 26 #include <vtkPointData.h> 27 #include <vtkPolyData.h> 28 #include <vtkRenderWindowInteractor.h> 70 Point3D currentPickedPoint = positionEvent->GetPositionInWorld();
73 return object &&
object->GetGeometry()->GetBoundingBox()->IsInside(currentPickedPoint);
88 void mitk::AffineImageCropperInteractor::Deselect()
106 const auto *wheelEvent =
dynamic_cast<const MouseWheelEvent *
>(interactionEvent);
107 if (wheelEvent ==
nullptr)
110 if (m_SelectedNode.IsNull())
113 double scale = (double)(wheelEvent->GetWheelDelta()) / 64.0;
115 newScale[0] = newScale[1] = newScale[2] = scale;
117 mitk::Point3D anchorPoint = wheelEvent->GetPositionInWorld();
119 m_SelectedNode->GetData()->GetGeometry()->ExecuteOperation(doOp);
126 if (m_SelectedNode.IsNull())
129 if (positionEvent ==
nullptr)
132 m_InitialPickedPoint = positionEvent->GetPositionInWorld();
133 m_InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
137 m_InitialOrigin = surGeo->GetOrigin();
143 if (positionEvent ==
nullptr)
146 m_InitialPickedPoint = positionEvent->GetPositionInWorld();
147 m_InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
157 if (positionEvent ==
nullptr)
160 m_InitialPickedPoint = positionEvent->GetPositionInWorld();
161 m_InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
171 if (positionEvent ==
nullptr)
174 Point3D currentPickedPoint = positionEvent->GetPositionInWorld();
177 interactionMove[0] = currentPickedPoint[0] - m_InitialPickedPoint[0];
178 interactionMove[1] = currentPickedPoint[1] - m_InitialPickedPoint[1];
179 interactionMove[2] = currentPickedPoint[2] - m_InitialPickedPoint[2];
183 surGeo->SetOrigin(m_InitialOrigin);
184 surGeo->Translate(interactionMove);
192 if (positionEvent ==
nullptr)
195 Point3D currentPickedPoint = positionEvent->GetPositionInWorld();
196 Vector3D interactionMove = currentPickedPoint - m_InitialPickedPoint;
199 surface->SetGeometry(m_OriginalGeometry);
202 surGeo->WorldToIndex(interactionMove, interactionMove);
204 for (
int i = 0; i < 3; ++i)
206 scale[i] = (interactionMove[i] * surGeo->GetMatrixColumn(i).magnitude()) - 1;
212 surGeo->ExecuteOperation(doOp);
220 if (positionEvent ==
nullptr)
223 Point2D currentPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
224 if (currentPickedDisplayPoint.EuclideanDistanceTo(m_InitialPickedDisplayPoint) < 1)
229 if (currentVtkRenderer && currentVtkRenderer->GetActiveCamera())
232 currentVtkRenderer->GetActiveCamera()->GetViewPlaneNormal(vpn);
235 rotationAxis[0] = vpn[0];
236 rotationAxis[1] = vpn[1];
237 rotationAxis[2] = vpn[2];
238 rotationAxis.Normalize();
240 Vector2D move = currentPickedDisplayPoint - m_InitialPickedDisplayPoint;
242 double rotationAngle = -57.3 * atan(move[0] / move[1]);
244 rotationAngle += 180;
247 Point3D rotationCenter = m_OriginalGeometry->GetCenter();
249 rotationCenter = m_InitialPickedPoint;
255 newGeometry->ExecuteOperation(&op);
256 m_SelectedNode->GetData()->SetGeometry(newGeometry);
Class for storing surfaces (vtkPolyData).
Super class for all position events.
Standard implementation of BaseGeometry.
virtual void InitTranslate(StateMachineAction *, InteractionEvent *)
virtual void DeformObject(StateMachineAction *, InteractionEvent *)
vtkRenderer * GetVtkRenderer() const
virtual void InitRotate(StateMachineAction *, InteractionEvent *)
Constants for most interaction classes, due to the generic StateMachines.
virtual void ScaleRadius(StateMachineAction *, InteractionEvent *interactionEvent)
void ConnectActionsAndFunctions() override
DataNode * GetDataNode() const
BaseRenderer * GetSender() const
superclass of all bounding objects (cylinder, cuboid,...)
void DataNodeChanged() override
AffineImageCropperInteractor()
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
virtual void DeselectObject(StateMachineAction *, InteractionEvent *)
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
virtual bool CheckOverObject(const InteractionEvent *interactionEvent)
virtual void RotateObject(StateMachineAction *, InteractionEvent *interactionEvent)
#define CONNECT_CONDITION(a, f)
virtual void InitDeformation(StateMachineAction *, InteractionEvent *)
The ScaleOperation is an operation to scale any mitk::BaseGeometry.
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
#define CONNECT_FUNCTION(a, f)
~AffineImageCropperInteractor() override
Operation, that holds everything necessary for an rotation operation on mitk::BaseData.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
virtual void TranslateObject(StateMachineAction *, InteractionEvent *interactionEvent)