26 #include <vtkCamera.h>
27 #include <vtkInteractorObserver.h>
28 #include <vtkInteractorStyle.h>
29 #include <vtkPointData.h>
30 #include <vtkPolyData.h>
31 #include <vtkRenderWindowInteractor.h>
40 const char *
anchorPointX =
"AffineBaseDataInteractor3D.Anchor Point X";
41 const char *
anchorPointY =
"AffineBaseDataInteractor3D.Anchor Point Y";
42 const char *
anchorPointZ =
"AffineBaseDataInteractor3D.Anchor Point Z";
89 float stepSize = 1.0f;
92 movementVector.Fill(0.0);
93 movementVector.SetElement(2, stepSize);
94 this->TranslateGeometry(movementVector, this->GetUpdatedTimeGeometry(interactionEvent));
100 float stepSize = 1.0f;
103 movementVector.Fill(0.0);
104 movementVector.SetElement(2, -stepSize);
105 this->TranslateGeometry(movementVector, this->GetUpdatedTimeGeometry(interactionEvent));
111 float stepSize = 1.0f;
114 movementVector.Fill(0.0);
115 movementVector.SetElement(0, -stepSize);
116 this->TranslateGeometry(movementVector, this->GetUpdatedTimeGeometry(interactionEvent));
122 float stepSize = 1.0f;
125 movementVector.Fill(0.0);
126 movementVector.SetElement(0, stepSize);
127 this->TranslateGeometry(movementVector, this->GetUpdatedTimeGeometry(interactionEvent));
133 float stepSize = 1.0f;
136 movementVector.Fill(0.0);
137 movementVector.SetElement(1, stepSize);
138 this->TranslateGeometry(movementVector, this->GetUpdatedTimeGeometry(interactionEvent));
144 float stepSize = 1.0f;
147 movementVector.Fill(0.0);
148 movementVector.SetElement(1, -stepSize);
149 this->TranslateGeometry(movementVector, this->GetUpdatedTimeGeometry(interactionEvent));
154 float stepSize = 1.0f;
156 this->RotateGeometry(-stepSize, 0, this->GetUpdatedTimeGeometry(interactionEvent));
162 float stepSize = 1.0f;
164 this->RotateGeometry(stepSize, 0, this->GetUpdatedTimeGeometry(interactionEvent));
171 float stepSize = 1.0f;
173 this->RotateGeometry(-stepSize, 2, this->GetUpdatedTimeGeometry(interactionEvent));
179 float stepSize = 1.0f;
181 this->RotateGeometry(stepSize, 2, this->GetUpdatedTimeGeometry(interactionEvent));
187 float stepSize = 1.0f;
189 this->RotateGeometry(stepSize, 1, this->GetUpdatedTimeGeometry(interactionEvent));
195 float stepSize = 1.0f;
197 this->RotateGeometry(-stepSize, 1, this->GetUpdatedTimeGeometry(interactionEvent));
202 float stepSize = 0.1f;
205 newScale.Fill(stepSize);
206 this->ScaleGeometry(newScale, this->GetUpdatedTimeGeometry(interactionEvent));
212 float stepSize = 0.1f;
215 newScale.Fill(-stepSize);
216 this->ScaleGeometry(newScale, this->GetUpdatedTimeGeometry(interactionEvent));
225 anchorPoint.Fill(0.0);
226 this->GetDataNode()->GetFloatProperty(
anchorPointX, pointX);
227 this->GetDataNode()->GetFloatProperty(
anchorPointY, pointY);
228 this->GetDataNode()->GetFloatProperty(
anchorPointZ, pointZ);
229 anchorPoint[0] = pointX;
230 anchorPoint[1] = pointY;
231 anchorPoint[2] = pointZ;
248 pointOfRotation.Fill(0.0);
249 this->GetDataNode()->GetFloatProperty(
anchorPointX, pointX);
250 this->GetDataNode()->GetFloatProperty(
anchorPointY, pointY);
251 this->GetDataNode()->GetFloatProperty(
anchorPointZ, pointZ);
252 pointOfRotation[0] = pointX;
253 pointOfRotation[1] = pointY;
254 pointOfRotation[2] = pointZ;
266 this->GetDataNode()->Modified();
274 BaseGeometry *geometry = this->GetDataNode()->GetData()->GetUpdatedTimeGeometry()->GetGeometryForTimeStep(timeStep);
275 if (geometry == NULL)
276 MITK_ERROR <<
"Geometry is NULL. Cannot modify it.";
283 if (newInputNode.IsNotNull())
294 if (priorColor.IsNotNull())
297 tmpCopyOfPriorColor->SetColor(priorColor->GetColor());
300 newInputNode->SetColor(0.0, 0.0, 1.0);
314 if (positionEvent == NULL)
334 if (selectedColor.IsNotNull())
336 node->GetPropertyList()->SetProperty(
"color", selectedColor);
352 if (selectedColor.IsNotNull())
354 node->GetPropertyList()->SetProperty(
"color", selectedColor);
375 if (positionEvent == NULL)
383 if ((interactionEvent->
GetSender()) != NULL)
387 this->GetDataNode()->GetData()->UpdateOutputInformation();
389 static_cast<Geometry3D *
>(this->GetDataNode()->GetData()->GetGeometry(timeStep)->Clone().GetPointer());
396 if (positionEvent == NULL)
402 interactionMove[0] = currentPickedPoint[0] - m_InitialPickedWorldPoint[0];
403 interactionMove[1] = currentPickedPoint[1] - m_InitialPickedWorldPoint[1];
404 interactionMove[2] = currentPickedPoint[2] - m_InitialPickedWorldPoint[2];
409 this->GetDataNode()->GetData()->GetUpdatedTimeGeometry()->GetGeometryForTimeStep(timeStep);
410 geometry->SetOrigin(m_OriginalGeometry->GetOrigin());
412 this->TranslateGeometry(interactionMove, this->GetUpdatedTimeGeometry(interactionEvent));
420 if (positionEvent == NULL)
426 vtkCamera *camera = NULL;
427 vtkRenderer *currentVtkRenderer = NULL;
429 if ((interactionEvent->
GetSender()) != NULL)
434 if (camera && currentVtkRenderer)
437 camera->GetViewPlaneNormal(vpn);
440 viewPlaneNormal[0] = vpn[0];
441 viewPlaneNormal[1] = vpn[1];
442 viewPlaneNormal[2] = vpn[2];
445 interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
446 interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
447 interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
449 if (interactionMove[0] == 0 && interactionMove[1] == 0 && interactionMove[2] == 0)
452 Vector3D rotationAxis = itk::CrossProduct(viewPlaneNormal, interactionMove);
453 rotationAxis.Normalize();
455 int *size = currentVtkRenderer->GetSize();
456 double l2 = (currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) *
457 (currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) +
458 (currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]) *
459 (currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]);
461 double rotationAngle = 360.0 * sqrt(l2 / (size[0] * size[0] + size[1] * size[1]));
464 Point3D rotationCenter = m_OriginalGeometry->GetCenter();
467 if ((interactionEvent->
GetSender()) != NULL)
474 newGeometry->ExecuteOperation(&op);
476 if (timeGeometry.IsNotNull())
477 timeGeometry->SetTimeStepGeometry(newGeometry, timeStep);
491 if (inputNode.IsNull())
494 if (color.IsNotNull())
496 inputNode->GetPropertyList()->SetProperty(
"color", color);
virtual void ScaleDownKey(mitk::StateMachineAction *, mitk::InteractionEvent *interactionEvent)
virtual void DataNodeChanged() override
bool InitMembers(InteractionEvent *interactionEvent)
Initializes member variables.
Super class for all position events.
Standard implementation of BaseGeometry.
virtual bool CheckOverObject(const InteractionEvent *)
Checks if the mouse pointer is over the object.
void ScaleGeometry(mitk::Point3D newScale, mitk::BaseGeometry *geometry)
const char * priorPropertyName
BaseRenderer * GetSender() const
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
Point3D GetPositionInWorld() const
virtual DataNode * PickObject(const Point2D &, Point3D &) const
Determines the object (mitk::DataNode) closest to the current position by means of picking...
virtual void SetDataNode(DataNode *node)
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.
virtual void DeselectObject(StateMachineAction *, InteractionEvent *)
Called if the mouse pointer leaves the area of the object.
virtual void ConnectActionsAndFunctions() override
Point2D GetPointerPositionOnScreen() const
const char * anchorPointX
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
Called if the mouse pointer is over the object indicated by a color change.
const char * anchorPointZ
T::Pointer GetData(const std::string &name)
virtual void RotateObject(StateMachineAction *, InteractionEvent *)
virtual void TranslateLeftKey(StateMachineAction *, InteractionEvent *interactionEvent)
The ColorProperty class RGB color property.
virtual void RestoreNodeProperties()
virtual void RestoreNodeProperties()
Restore default properties of bounding box and handles.
virtual void RotateLeftKey(StateMachineAction *, InteractionEvent *interactionEvent)
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
virtual mitk::RenderingManager * GetRenderingManager() const
Setter for the RenderingManager that handles this instance of BaseRenderer.
virtual void TranslateObject(StateMachineAction *, InteractionEvent *)
Performs a translation of the object relative to the mouse movement.
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
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 *)
virtual void TranslateUpKey(StateMachineAction *, InteractionEvent *interactionEvent)
mitk::BaseGeometry * GetUpdatedTimeGeometry(mitk::InteractionEvent *interactionEvent)
virtual void InitTranslate(StateMachineAction *, InteractionEvent *)
virtual unsigned int GetTimeStep() const
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 *)
The ScaleOperation is an operation to scale any mitk::BaseGeometry.
const float selectedColor[]
const char * deselectedColorPropertyName
#define CONNECT_FUNCTION(a, f)
virtual void ScaleUpKey(mitk::StateMachineAction *, mitk::InteractionEvent *interactionEvent)
vtkRenderer * GetVtkRenderer() const
virtual void ScaleObject(StateMachineAction *, InteractionEvent *)
Performs a object shape change by influencing the scaling of the initial bounding box...
Operation, that holds everything necessary for an rotation operation on mitk::BaseData.
virtual void TranslateDownKey(StateMachineAction *, InteractionEvent *interactionEvent)
virtual ~AffineBaseDataInteractor3D()
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
virtual 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)