24 #include <vtkCamera.h>
25 #include <vtkInteractorObserver.h>
26 #include <vtkInteractorStyle.h>
27 #include <vtkPointData.h>
28 #include <vtkPolyData.h>
29 #include <vtkRenderWindowInteractor.h>
36 m_ObjectNormal[0] = 0.0;
37 m_ObjectNormal[1] = 0.0;
38 m_ObjectNormal[2] = 1.0;
67 if (positionEvent == NULL)
85 node->SetColor(1.0, 0.0, 0.0);
88 this->ColorizeSurface(interactionEvent->
GetSender(), 0.0);
100 node->SetColor(1.0, 1.0, 1.0);
103 this->ColorizeSurface(interactionEvent->
GetSender(), -1.0);
111 if (positionEvent == NULL)
117 m_InitialPickedDisplayPoint[0],
118 m_InitialPickedDisplayPoint[1],
120 m_InitialPickedWorldPoint);
124 if ((interactionEvent->
GetSender()) != NULL)
128 this->GetDataNode()->GetData()->UpdateOutputInformation();
130 static_cast<Geometry3D *
>(this->GetDataNode()->GetData()->GetGeometry(timeStep)->Clone().GetPointer());
136 if (positionEvent == NULL)
142 m_InitialPickedDisplayPoint[0],
143 m_InitialPickedDisplayPoint[1],
145 m_InitialPickedWorldPoint);
151 this->GetDataNode()->GetData()->UpdateOutputInformation();
153 static_cast<Geometry3D *
>(this->GetDataNode()->GetData()->GetGeometry(timeStep)->Clone().GetPointer());
159 if (positionEvent == NULL)
162 double currentWorldPoint[4];
165 currentDisplayPoint[0],
166 currentDisplayPoint[1],
171 interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
172 interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
173 interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
175 Point3D origin = m_OriginalGeometry->GetOrigin();
182 vtkPolyData *polyData = NULL;
183 if (surface.IsNotNull())
185 polyData = surface->GetVtkPolyData(timeStep);
188 vtkPointData *pointData = polyData->GetPointData();
189 if (pointData != NULL)
191 vtkDataArray *normal = polyData->GetPointData()->GetVectors(
"planeNormal");
194 m_ObjectNormal[0] = normal->GetComponent(0, 0);
195 m_ObjectNormal[1] = normal->GetComponent(0, 1);
196 m_ObjectNormal[2] = normal->GetComponent(0, 2);
202 this->GetDataNode()->GetData()->GetGeometry(timeStep)->IndexToWorld(m_ObjectNormal, transformedObjectNormal);
204 this->GetDataNode()->GetData()->GetGeometry(timeStep)->SetOrigin(
205 origin + transformedObjectNormal * (interactionMove * transformedObjectNormal));
213 if (positionEvent == NULL)
216 double currentWorldPoint[4];
219 currentPickedDisplayPoint[0],
220 currentPickedDisplayPoint[1],
224 vtkCamera *camera = NULL;
225 vtkRenderer *currentVtkRenderer = NULL;
227 if ((interactionEvent->
GetSender()) != NULL)
230 if (renderWindow != NULL)
232 vtkRenderWindowInteractor *renderWindowInteractor = renderWindow->GetInteractor();
233 if (renderWindowInteractor != NULL)
235 currentVtkRenderer = renderWindowInteractor->GetInteractorStyle()->GetCurrentRenderer();
236 if (currentVtkRenderer != NULL)
237 camera = currentVtkRenderer->GetActiveCamera();
244 camera->GetViewPlaneNormal(vpn);
247 viewPlaneNormal[0] = vpn[0];
248 viewPlaneNormal[1] = vpn[1];
249 viewPlaneNormal[2] = vpn[2];
252 interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
253 interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
254 interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
256 if (interactionMove[0] == 0 && interactionMove[1] == 0 && interactionMove[2] == 0)
259 Vector3D rotationAxis = itk::CrossProduct(viewPlaneNormal, interactionMove);
260 rotationAxis.Normalize();
262 int *size = currentVtkRenderer->GetSize();
263 double l2 = (currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) *
264 (currentPickedDisplayPoint[0] - m_InitialPickedDisplayPoint[0]) +
265 (currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]) *
266 (currentPickedDisplayPoint[1] - m_InitialPickedDisplayPoint[1]);
268 double rotationAngle = 360.0 * sqrt(l2 / (size[0] * size[0] + size[1] * size[1]));
271 Point3D rotationCenter = m_OriginalGeometry->GetCenter();
274 if ((interactionEvent->
GetSender()) != NULL)
281 newGeometry->ExecuteOperation(&op);
283 if (timeGeometry.IsNotNull())
284 timeGeometry->SetTimeStepGeometry(newGeometry, timeStep);
295 MITK_ERROR <<
"ClippingPlaneInteractor3D: No data object present!";
301 if (renderer.IsNotNull())
302 timeStep = renderer->GetTimeStep(data);
306 vtkPolyData *polyData = NULL;
307 if (surface.IsNotNull())
308 polyData = surface->GetVtkPolyData(timeStep);
310 if (polyData == NULL)
312 MITK_ERROR <<
"ClippingPlaneInteractor3D: No poly data present!";
316 vtkPointData *pointData = polyData->GetPointData();
317 if (pointData == NULL)
319 MITK_ERROR <<
"ClippingPlaneInteractor3D: No point data present!";
323 vtkDataArray *scalars = pointData->GetScalars();
326 MITK_ERROR <<
"ClippingPlaneInteractor3D: No scalars for point data present!";
330 for (vtkIdType i = 0; i < pointData->GetNumberOfTuples(); ++i)
332 scalars->SetComponent(i, 0, scalar);
335 polyData->Modified();
Class for storing surfaces (vtkPolyData).
Super class for all position events.
Standard implementation of BaseGeometry.
virtual bool CheckOverObject(const InteractionEvent *)
Checks if the mouse pointer is over the object.
ClippingPlaneInteractor3D()
BaseRenderer * GetSender() const
virtual DataNode * PickObject(const Point2D &, Point3D &) const
Determines the object (mitk::DataNode) closest to the current position by means of picking...
virtual void InitRotate(StateMachineAction *, InteractionEvent *)
itk::SmartPointer< Self > Pointer
Constants for most interaction classes, due to the generic StateMachines.
virtual void DeselectObject(StateMachineAction *, InteractionEvent *)
Called if the mouse pointer leaves the area of the object.
Point2D GetPointerPositionOnScreen() const
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
Called if the mouse pointer is over the object indicated by a color change.
T::Pointer GetData(const std::string &name)
virtual void RotateObject(StateMachineAction *, InteractionEvent *)
virtual void InitTranslate(StateMachineAction *, InteractionEvent *)
virtual ~ClippingPlaneInteractor3D()
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.
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
virtual bool CheckOverObject(const InteractionEvent *)
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
virtual unsigned int GetTimeStep() const
virtual void DeselectObject(StateMachineAction *, InteractionEvent *)
#define CONNECT_CONDITION(a, f)
virtual void ConnectActionsAndFunctions() override
virtual void TranslateObject(StateMachineAction *, InteractionEvent *)
virtual void DataNodeChanged() override
#define CONNECT_FUNCTION(a, f)
vtkRenderer * GetVtkRenderer() const
Operation, that holds everything necessary for an rotation operation on mitk::BaseData.
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)