22 #include <vtkCamera.h> 23 #include <vtkInteractorObserver.h> 24 #include <vtkInteractorStyle.h> 25 #include <vtkPointData.h> 26 #include <vtkPolyData.h> 27 #include <vtkRenderWindowInteractor.h> 36 const char *
anchorPointX =
"AffineBaseDataInteractor3D.Anchor Point X";
37 const char *
anchorPointY =
"AffineBaseDataInteractor3D.Anchor Point Y";
38 const char *
anchorPointZ =
"AffineBaseDataInteractor3D.Anchor Point Z";
85 float stepSize = 1.0f;
88 movementVector.Fill(0.0);
89 movementVector.SetElement(2, stepSize);
96 float stepSize = 1.0f;
99 movementVector.Fill(0.0);
100 movementVector.SetElement(2, -stepSize);
107 float stepSize = 1.0f;
110 movementVector.Fill(0.0);
111 movementVector.SetElement(0, -stepSize);
118 float stepSize = 1.0f;
121 movementVector.Fill(0.0);
122 movementVector.SetElement(0, stepSize);
129 float stepSize = 1.0f;
132 movementVector.Fill(0.0);
133 movementVector.SetElement(1, stepSize);
140 float stepSize = 1.0f;
143 movementVector.Fill(0.0);
144 movementVector.SetElement(1, -stepSize);
150 float stepSize = 1.0f;
158 float stepSize = 1.0f;
167 float stepSize = 1.0f;
175 float stepSize = 1.0f;
183 float stepSize = 1.0f;
191 float stepSize = 1.0f;
198 float stepSize = 0.1f;
201 newScale.Fill(stepSize);
208 float stepSize = 0.1f;
211 newScale.Fill(-stepSize);
221 anchorPoint.Fill(0.0);
225 anchorPoint[0] = pointX;
226 anchorPoint[1] = pointY;
227 anchorPoint[2] = pointZ;
244 pointOfRotation.Fill(0.0);
248 pointOfRotation[0] = pointX;
249 pointOfRotation[1] = pointY;
250 pointOfRotation[2] = pointZ;
271 if (geometry ==
nullptr)
272 MITK_ERROR <<
"Geometry is nullptr. Cannot modify it.";
279 if (newInputNode.IsNotNull())
290 if (priorColor.IsNotNull())
293 tmpCopyOfPriorColor->SetColor(priorColor->GetColor());
296 newInputNode->SetColor(0.0, 0.0, 1.0);
310 if (positionEvent ==
nullptr)
314 if (interactionEvent->
GetSender()->
PickObject(positionEvent->GetPointerPositionOnScreen(), currentWorldPoint) ==
330 if (selectedColor.IsNotNull())
332 node->GetPropertyList()->SetProperty(
"color", selectedColor);
348 if (selectedColor.IsNotNull())
350 node->GetPropertyList()->SetProperty(
"color", selectedColor);
371 if (positionEvent ==
nullptr)
374 m_InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
375 m_InitialPickedWorldPoint = positionEvent->GetPositionInWorld();
379 if ((interactionEvent->
GetSender()) !=
nullptr)
392 if (positionEvent ==
nullptr)
395 Point3D currentPickedPoint = positionEvent->GetPositionInWorld();
398 interactionMove[0] = currentPickedPoint[0] - m_InitialPickedWorldPoint[0];
399 interactionMove[1] = currentPickedPoint[1] - m_InitialPickedWorldPoint[1];
400 interactionMove[2] = currentPickedPoint[2] - m_InitialPickedWorldPoint[2];
406 geometry->SetOrigin(m_OriginalGeometry->GetOrigin());
416 if (positionEvent ==
nullptr)
419 Point2D currentPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
420 Point3D currentWorldPoint = positionEvent->GetPositionInWorld();
422 vtkCamera *camera =
nullptr;
423 vtkRenderer *currentVtkRenderer =
nullptr;
425 if ((interactionEvent->
GetSender()) !=
nullptr)
430 if (camera && currentVtkRenderer)
433 camera->GetViewPlaneNormal(vpn);
436 viewPlaneNormal[0] = vpn[0];
437 viewPlaneNormal[1] = vpn[1];
438 viewPlaneNormal[2] = vpn[2];
441 interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
442 interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
443 interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
445 if (interactionMove[0] == 0 && interactionMove[1] == 0 && interactionMove[2] == 0)
448 Vector3D rotationAxis = itk::CrossProduct(viewPlaneNormal, interactionMove);
449 rotationAxis.Normalize();
451 int *size = currentVtkRenderer->GetSize();
452 double l2 = (currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) *
453 (currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) +
454 (currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]) *
455 (currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]);
457 double rotationAngle = 360.0 * sqrt(l2 / (size[0] * size[0] + size[1] * size[1]));
460 Point3D rotationCenter = m_OriginalGeometry->GetCenter();
463 if ((interactionEvent->
GetSender()) !=
nullptr)
470 newGeometry->ExecuteOperation(&op);
472 if (timeGeometry.IsNotNull())
473 timeGeometry->SetTimeStepGeometry(newGeometry, timeStep);
487 if (inputNode.IsNull())
490 if (color.IsNotNull())
492 inputNode->GetPropertyList()->SetProperty(
"color", color);
virtual void ScaleDownKey(mitk::StateMachineAction *, mitk::InteractionEvent *interactionEvent)
void DataNodeChanged() override
~AffineBaseDataInteractor3D() override
Super class for all position events.
Standard implementation of BaseGeometry.
void ScaleGeometry(mitk::Point3D newScale, mitk::BaseGeometry *geometry)
const char * priorPropertyName
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
vtkRenderer * GetVtkRenderer() const
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
void TranslateGeometry(mitk::Vector3D translate, mitk::BaseGeometry *geometry)
const char * selectedColorPropertyName
void RotateGeometry(mitk::ScalarType angle, int rotationaxis, mitk::BaseGeometry *geometry)
const char * rotationStepSizePropertyName
Constants for most interaction classes, due to the generic StateMachines.
virtual void TranslateDownModifierKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual void RotateRightKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual void RotateUpKey(StateMachineAction *, InteractionEvent *interactionEvent)
const char * scaleStepSizePropertyName
void Translate(const Vector3D &vector)
Translate the origin by a vector.
DataNode * GetDataNode() const
void ConnectActionsAndFunctions() override
const char * anchorPointX
const char * anchorPointZ
BaseRenderer * GetSender() const
virtual void RotateObject(StateMachineAction *, InteractionEvent *)
virtual void TranslateLeftKey(StateMachineAction *, InteractionEvent *interactionEvent)
The ColorProperty class RGB color property.
virtual void RestoreNodeProperties()
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
virtual void RotateLeftKey(StateMachineAction *, InteractionEvent *interactionEvent)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
virtual unsigned int GetTimeStep() const
AffineBaseDataInteractor3D()
virtual void DeselectObject(StateMachineAction *, InteractionEvent *)
virtual void InitRotate(StateMachineAction *, InteractionEvent *)
virtual void TranslateRightKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual bool CheckOverObject(const InteractionEvent *)
const char * translationStepSizePropertyName
const char * anchorPointY
virtual void TranslateObject(StateMachineAction *, InteractionEvent *)
void UpdateOutputInformation() override
Update the information for this BaseData (the geometry in particular) so that it can be used as an ou...
virtual void TranslateUpKey(StateMachineAction *, InteractionEvent *interactionEvent)
mitk::BaseGeometry * GetUpdatedTimeGeometry(mitk::InteractionEvent *interactionEvent)
virtual DataNode * PickObject(const Point2D &, Point3D &) const
Determines the object (mitk::DataNode) closest to the current position by means of picking...
virtual void InitTranslate(StateMachineAction *, InteractionEvent *)
bool InitMembers(InteractionEvent *interactionEvent)
InitMembers convinience method to avoid code duplication between InitRotate() and InitTranslate()...
virtual void TranslateUpModifierKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual void RotateDownModifierKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual void SetDataNode(DataNode *dataNode)
#define CONNECT_CONDITION(a, f)
virtual void ScaleObject(StateMachineAction *, InteractionEvent *)
const mitk::TimeGeometry * GetUpdatedTimeGeometry()
Return the TimeGeometry of the data.
The ScaleOperation is an operation to scale any mitk::BaseGeometry.
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
const float selectedColor[]
const char * deselectedColorPropertyName
#define CONNECT_FUNCTION(a, f)
virtual void ScaleUpKey(mitk::StateMachineAction *, mitk::InteractionEvent *interactionEvent)
Operation, that holds everything necessary for an rotation operation on mitk::BaseData.
void SetDataNode(DataNode *node) override
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
virtual void TranslateDownKey(StateMachineAction *, InteractionEvent *interactionEvent)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
void ExecuteOperation(Operation *operation) override
executes affine operations (translate, rotate, scale)
Class for nodes of the DataTree.
virtual void RotateDownKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual void RotateUpModifierKey(StateMachineAction *, InteractionEvent *interactionEvent)