Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkBoundingShapeInteractor.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "../DataManagement/mitkBoundingShapeUtil.h"
15 #include <mitkDisplayInteractor.h>
16 #include <mitkInteractionConst.h>
20 #include <mitkMouseWheelEvent.h>
21 
22 #include <vtkCamera.h>
23 #include <vtkInteractorObserver.h>
24 #include <vtkInteractorStyle.h>
25 #include <vtkPointData.h>
26 #include <vtkRenderWindowInteractor.h>
27 #include <vtkSmartPointer.h>
28 
29 #include "usGetModuleContext.h"
30 #include "usModuleRegistry.h"
31 
32 // Properties to allow the user to interact with the base data
33 const char *selectedColorPropertyName = "Bounding Shape.Selected Color";
34 const char *deselectedColorPropertyName = "Bounding Shape.Deselected Color";
35 const char *activeHandleIdPropertyName = "Bounding Shape.Active Handle ID";
36 const char *boundingShapePropertyName = "Bounding Shape";
37 
38 namespace mitk
39 {
40  class BoundingShapeInteractor::Impl
41  {
42  public:
43  Impl() : ScrollEnabled(false), RotationEnabled(false)
44  {
45  Point3D initialPoint;
46  initialPoint.Fill(0.0);
47 
48  for (int i = 0; i < 6; ++i)
49  Handles.push_back(Handle(initialPoint, i, GetHandleIndices(i)));
50  }
51 
52  ~Impl() {}
53  bool ScrollEnabled;
54  Point3D InitialPickedWorldPoint;
55  Point3D LastPickedWorldPoint;
56  Point2D InitialPickedDisplayPoint;
57  std::vector<Handle> Handles;
58  Handle ActiveHandle;
59  Geometry3D::Pointer OriginalGeometry;
60  bool RotationEnabled;
61  std::map<us::ServiceReferenceU, mitk::EventConfig> DisplayInteractorConfigs;
62  };
63 }
64 
66 {
67 }
68 
70 {
71  this->RestoreNodeProperties();
72  delete m_Impl;
73 }
74 
76 {
77  // **Conditions** that can be used in the state machine, to ensure that certain conditions are met, before actually
78  // executing an action
79  CONNECT_CONDITION("isHoveringOverObject", CheckOverObject);
80  CONNECT_CONDITION("isHoveringOverHandles", CheckOverHandles);
81 
82  // **Function** in the statemachine patterns also referred to as **Actions**
83  CONNECT_FUNCTION("selectObject", SelectObject);
84  CONNECT_FUNCTION("deselectObject", DeselectObject);
85  CONNECT_FUNCTION("deselectHandles", DeselectHandles);
86  CONNECT_FUNCTION("initInteraction", InitInteraction);
87  CONNECT_FUNCTION("translateObject", TranslateObject);
88  CONNECT_FUNCTION("selectHandle", SelectHandle);
89  CONNECT_FUNCTION("scaleObject", ScaleObject);
90  // CONNECT_FUNCTION("rotateObject",RotateObject);
91 }
92 
93 // RotateObject(StateMachineAction*, InteractionEvent* interactionEvent)
94 // void mitk::BoundingShapeInteractor::RotateGeometry(mitk::ScalarType angle, int rotationaxis, mitk::BaseGeometry*
95 // geometry)
96 //{
97 // mitk::Vector3D rotationAxis = geometry->GetAxisVector(rotationaxis);
98 // float pointX = 0.0f;
99 // float pointY = 0.0f;
100 // float pointZ = 0.0f;
101 // mitk::Point3D pointOfRotation;
102 // pointOfRotation.Fill(0.0);
103 // this->GetDataNode()->GetFloatProperty(anchorPointX, pointX);
104 // this->GetDataNode()->GetFloatProperty(anchorPointY, pointY);
105 // this->GetDataNode()->GetFloatProperty(anchorPointZ, pointZ);
106 // pointOfRotation[0] = pointX;
107 // pointOfRotation[1] = pointY;
108 // pointOfRotation[2] = pointZ;
109 //
110 // mitk::RotationOperation* doOp = new mitk::RotationOperation(OpROTATE, pointOfRotation, rotationAxis, angle);
111 //
112 // geometry->ExecuteOperation(doOp);
113 // delete doOp;
114 //}
115 
117 {
118  m_Impl->RotationEnabled = rotationEnabled;
119 }
120 
122 {
123  mitk::DataNode::Pointer newInputNode = this->GetDataNode();
124 
125  if (newInputNode == nullptr)
126  return;
127 
128  // add color properties
130  dynamic_cast<mitk::ColorProperty *>(newInputNode->GetProperty(selectedColorPropertyName));
131  mitk::ColorProperty::Pointer deselectedColor =
132  dynamic_cast<mitk::ColorProperty *>(newInputNode->GetProperty(deselectedColorPropertyName));
133 
134  if (selectedColor.IsNull())
135  newInputNode->AddProperty(selectedColorPropertyName, mitk::ColorProperty::New(0.0, 1.0, 0.0));
136 
137  if (deselectedColor.IsNull())
138  newInputNode->AddProperty(deselectedColorPropertyName, mitk::ColorProperty::New(1.0, 1.0, 1.0));
139 
140  newInputNode->SetProperty(boundingShapePropertyName, mitk::BoolProperty::New(true));
141  newInputNode->AddProperty(activeHandleIdPropertyName, mitk::IntProperty::New(-1));
142  newInputNode->SetProperty("layer", mitk::IntProperty::New(101));
143  newInputNode->SetBoolProperty("fixedLayer", mitk::BoolProperty::New(true));
144  newInputNode->SetBoolProperty("pickable", true);
145 
146  mitk::ColorProperty::Pointer initialColor =
147  dynamic_cast<mitk::ColorProperty *>(newInputNode->GetProperty(deselectedColorPropertyName));
148  if (initialColor.IsNotNull())
149  {
150  newInputNode->SetColor(initialColor->GetColor());
151  }
152 
154 }
155 
157 {
158  GeometryData::Pointer geometryData = dynamic_cast<GeometryData *>(this->GetDataNode()->GetData());
159  int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
160  mitk::BaseGeometry::Pointer geometry = geometryData->GetGeometry(timeStep);
161 
162  std::vector<Point3D> cornerPoints = GetCornerPoints(geometry, true);
163  if (m_Impl->Handles.size() == 6)
164  {
165  // set handle positions
166  Point3D pointLeft = CalcAvgPoint(cornerPoints[5], cornerPoints[6]);
167  Point3D pointRight = CalcAvgPoint(cornerPoints[1], cornerPoints[2]);
168  Point3D pointTop = CalcAvgPoint(cornerPoints[0], cornerPoints[6]);
169  Point3D pointBottom = CalcAvgPoint(cornerPoints[7], cornerPoints[1]);
170  Point3D pointFront = CalcAvgPoint(cornerPoints[2], cornerPoints[7]);
171  Point3D pointBack = CalcAvgPoint(cornerPoints[4], cornerPoints[1]);
172 
173  m_Impl->Handles[0].SetPosition(pointLeft);
174  m_Impl->Handles[1].SetPosition(pointRight);
175  m_Impl->Handles[2].SetPosition(pointTop);
176  m_Impl->Handles[3].SetPosition(pointBottom);
177  m_Impl->Handles[4].SetPosition(pointFront);
178  m_Impl->Handles[5].SetPosition(pointBack);
179 
180  // calculate center based on half way of the distance between two opposing cornerpoints
181  center = CalcAvgPoint(cornerPoints[7], cornerPoints[0]);
182  }
183 }
184 
186 {
187  this->RestoreNodeProperties(); // if there is another node set, restore it's color
188 
189  if (node == nullptr)
190  return;
191  DataInteractor::SetDataNode(node); // calls DataNodeChanged internally
192  this->DataNodeChanged();
193 }
194 
196 {
197  const auto *positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent);
198  if (positionEvent == nullptr)
199  return false;
200 
201  GeometryData::Pointer geometryData = dynamic_cast<GeometryData *>(this->GetDataNode()->GetData());
202  int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
203  BaseGeometry::Pointer geometry = geometryData->GetGeometry(timeStep);
204 
205  // calculates translation based on offset+extent not on the transformation matrix (because the cube is located in the
206  // center not in the origin)
207  vtkSmartPointer<vtkMatrix4x4> imageTransform = geometry->GetVtkTransform()->GetMatrix();
208  Point3D center = geometry->GetCenter();
209  auto translation = vtkSmartPointer<vtkTransform>::New();
210  auto transform = vtkSmartPointer<vtkTransform>::New();
211  translation->Translate(center[0] - imageTransform->GetElement(0, 3),
212  center[1] - imageTransform->GetElement(1, 3),
213  center[2] - imageTransform->GetElement(2, 3));
214  transform->SetMatrix(imageTransform);
215  transform->PostMultiply();
216  transform->Concatenate(translation);
217  transform->Update();
218 
219  mitk::Vector3D extent;
220  for (unsigned int i = 0; i < 3; ++i)
221  extent[i] = (geometry->GetExtent(i));
222 
223  Point3D currentWorldPosition;
224  Point2D currentDisplayPosition = positionEvent->GetPointerPositionOnScreen();
225  interactionEvent->GetSender()->DisplayToWorld(currentDisplayPosition, currentWorldPosition);
226 
227  ScalarType transformedPosition[4];
228  transformedPosition[0] = currentWorldPosition[0];
229  transformedPosition[1] = currentWorldPosition[1];
230  transformedPosition[2] = currentWorldPosition[2];
231  transformedPosition[3] = 1;
232  // transform point from world to object coordinates
233  transform->GetInverse()->TransformPoint(transformedPosition, transformedPosition);
234  // check if the world point is within bounds
235  bool isInside = (transformedPosition[0] >= (-extent[0] / 2.0)) && (transformedPosition[0] <= (extent[0] / 2.0)) &&
236  (transformedPosition[1] >= (-extent[1] / 2.0)) && (transformedPosition[1] <= (extent[1] / 2.0)) &&
237  (transformedPosition[2] >= (-extent[2] / 2.0)) && (transformedPosition[2] <= (extent[2] / 2.0));
238 
239  return isInside;
240 }
241 
243 {
244  Point3D boundingBoxCenter;
245  HandlePositionChanged(interactionEvent, boundingBoxCenter);
246  const auto *positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent);
247  if (positionEvent == nullptr)
248  return false;
249 
250  Point2D displayCenterPoint;
251  // to do: change to actual time step (currently not necessary because geometry remains the same for each timestep
252  int timeStep = 0;
253 
254  GeometryData::Pointer geometryData = dynamic_cast<GeometryData *>(this->GetDataNode()->GetData());
255  BaseGeometry::Pointer geometry = geometryData->GetUpdatedTimeGeometry()->GetGeometryForTimeStep(timeStep);
256  std::vector<Point3D> cornerPoints = GetCornerPoints(geometry, true);
257  interactionEvent->GetSender()->WorldToDisplay(boundingBoxCenter, displayCenterPoint);
258  double scale = interactionEvent->GetSender()->GetScaleFactorMMPerDisplayUnit(); // GetDisplaySizeInMM
259  mitk::DoubleProperty::Pointer handleSizeProperty =
260  dynamic_cast<mitk::DoubleProperty *>(this->GetDataNode()->GetProperty("Bounding Shape.Handle Size Factor"));
261 
262  ScalarType initialHandleSize;
263  if (handleSizeProperty != nullptr)
264  initialHandleSize = handleSizeProperty->GetValue();
265  else
266  initialHandleSize = 1.0 / 40.0;
267 
268  mitk::Point2D displaysize = interactionEvent->GetSender()->GetDisplaySizeInMM();
269  ScalarType handlesize = ((displaysize[0] + displaysize[1]) / 2.0) * initialHandleSize;
270  unsigned int handleNum = 0;
271 
272  for (auto &handle : m_Impl->Handles)
273  {
274  Point2D centerpoint;
275  interactionEvent->GetSender()->WorldToDisplay(handle.GetPosition(), centerpoint);
276  Point2D currentDisplayPosition = positionEvent->GetPointerPositionOnScreen();
277 
278  if ((currentDisplayPosition.EuclideanDistanceTo(centerpoint) < (handlesize / scale)) &&
279  (currentDisplayPosition.EuclideanDistanceTo(displayCenterPoint) >
280  (handlesize / scale))) // check if mouse is hovering over center point
281  {
282  handle.SetActive(true);
283  m_Impl->ActiveHandle = handle;
285  mitk::IntProperty::New(handleNum++));
286  this->GetDataNode()->GetData()->Modified();
288  return true;
289  }
290  else
291  {
292  handleNum++;
293  handle.SetActive(false);
294  }
296  }
297 
298  return false;
299 }
300 
302 {
303  this->DisableCrosshairNavigation();
304  DataNode::Pointer node = this->GetDataNode();
305 
306  if (node.IsNull())
307  return;
308 
310  dynamic_cast<mitk::ColorProperty *>(node->GetProperty(deselectedColorPropertyName));
311  if (selectedColor.IsNotNull())
312  {
313  this->GetDataNode()->GetPropertyList()->SetProperty("color", selectedColor);
314  }
315  this->GetDataNode()->GetData()->UpdateOutputInformation(); // Geometry is up-to-date
316  this->GetDataNode()->GetData()->Modified();
318  return;
319 }
320 
322 {
323  this->DisableCrosshairNavigation();
324  DataNode::Pointer node = this->GetDataNode();
325 
326  if (node.IsNull())
327  return;
328 
330  this->GetDataNode()->GetData()->UpdateOutputInformation(); // Geometry is up-to-date
331  this->GetDataNode()->GetData()->Modified();
333 
334  return;
335 }
336 
338 {
339  this->DisableCrosshairNavigation(); // disable crosshair interaction and scolling if user is hovering over the object
340  DataNode::Pointer node = this->GetDataNode();
341 
342  if (node.IsNull())
343  return;
344 
346  dynamic_cast<mitk::ColorProperty *>(node->GetProperty(selectedColorPropertyName));
347  if (selectedColor.IsNotNull())
348  {
349  node->GetPropertyList()->SetProperty("color", selectedColor);
350  }
351  this->GetDataNode()->GetData()->UpdateOutputInformation(); // Geometry is up-to-date
352  this->GetDataNode()->GetData()->Modified();
354  return;
355 }
356 
358 {
359  this->EnableCrosshairNavigation(); // enable crosshair interaction and scolling if user is hovering over the object
360 
361  DataNode::Pointer node = this->GetDataNode();
362 
363  if (node.IsNull())
364  return;
365 
366  mitk::ColorProperty::Pointer deselectedColor =
367  dynamic_cast<mitk::ColorProperty *>(node->GetProperty(deselectedColorPropertyName));
368  if (deselectedColor.IsNotNull())
369  {
370  node->GetPropertyList()->SetProperty("color", deselectedColor);
371  }
372 
373  this->GetDataNode()->GetData()->UpdateOutputInformation(); // Geometry is up-to-date
374  this->GetDataNode()->GetData()->Modified();
376  return;
377 }
378 
380 {
381  InitMembers(interactionEvent);
382 }
383 
385 {
386  auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
387  if (positionEvent == nullptr)
388  return false;
389 
390  // get initial position coordinates
391  m_Impl->InitialPickedDisplayPoint = positionEvent->GetPointerPositionOnScreen();
392  m_Impl->InitialPickedWorldPoint = positionEvent->GetPositionInWorld();
393  m_Impl->LastPickedWorldPoint = positionEvent->GetPositionInWorld();
394 
395  return true;
396 }
397 
399 {
400  auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
401  if (positionEvent == nullptr)
402  return;
403 
404  int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
405  mitk::BaseGeometry::Pointer geometry =
407  Vector3D spacing = geometry->GetSpacing();
408  Point3D currentPickedPoint;
409  interactionEvent->GetSender()->DisplayToWorld(positionEvent->GetPointerPositionOnScreen(), currentPickedPoint);
410  Vector3D interactionMove;
411 
412  // pixel aligned shifting of the bounding box
413  interactionMove[0] = std::round((currentPickedPoint[0] - m_Impl->LastPickedWorldPoint[0]) / spacing[0]) * spacing[0];
414  interactionMove[1] = std::round((currentPickedPoint[1] - m_Impl->LastPickedWorldPoint[1]) / spacing[1]) * spacing[1];
415  interactionMove[2] = std::round((currentPickedPoint[2] - m_Impl->LastPickedWorldPoint[2]) / spacing[2]) * spacing[2];
416 
417  if ((interactionMove[0] + interactionMove[1] + interactionMove[2]) !=
418  0.0) // only update current position if a movement occured
419  {
420  m_Impl->LastPickedWorldPoint = currentPickedPoint;
421 
422  geometry->SetOrigin(geometry->GetOrigin() + interactionMove);
423 
424  this->GetDataNode()->GetData()->UpdateOutputInformation(); // Geometry is up-to-date
425  this->GetDataNode()->GetData()->Modified();
427  }
428  return;
429 }
430 
432 {
433  auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
434  if (positionEvent == nullptr)
435  return;
436 
437  GeometryData::Pointer geometryData = dynamic_cast<GeometryData *>(this->GetDataNode()->GetData());
438  Point3D handlePickedPoint = m_Impl->ActiveHandle.GetPosition();
439  Point3D currentPickedPoint;
440  interactionEvent->GetSender()->DisplayToWorld(positionEvent->GetPointerPositionOnScreen(), currentPickedPoint);
441  int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
442  mitk::BaseGeometry::Pointer geometry = geometryData->GetGeometry(timeStep);
443  Vector3D spacing = geometry->GetSpacing();
444 
445  // pixel aligned bounding box
446  Vector3D interactionMove;
447  interactionMove[0] = (currentPickedPoint[0] - m_Impl->LastPickedWorldPoint[0]);
448  interactionMove[1] = (currentPickedPoint[1] - m_Impl->LastPickedWorldPoint[1]);
449  interactionMove[2] = (currentPickedPoint[2] - m_Impl->LastPickedWorldPoint[2]);
450 
451  std::vector<int> faces = m_Impl->ActiveHandle.GetFaceIndices();
452  auto pointscontainer = mitk::BoundingBox::PointsContainer::New();
453 
454  // calculate cornerpoints from geometry plus visualization offset
455  std::vector<Point3D> cornerPoints = GetCornerPoints(geometry, true);
456  unsigned int num = 0;
457  for (auto point : cornerPoints)
458  {
459  pointscontainer->InsertElement(num++, point);
460  }
461 
462  // calculate center based on half way of the distance between two opposing cornerpoints
463  mitk::Point3D center = CalcAvgPoint(cornerPoints[7], cornerPoints[0]);
464 
465  Vector3D faceNormal;
466  faceNormal[0] = handlePickedPoint[0] - center[0];
467  faceNormal[1] = handlePickedPoint[1] - center[1];
468  faceNormal[2] = handlePickedPoint[2] - center[2];
469  Vector3D faceShift = ((faceNormal * interactionMove) / (faceNormal.GetNorm() * faceNormal.GetNorm())) * faceNormal;
470 
471  // calculate cornerpoints from geometry without visualization offset to update actual geometry
472  cornerPoints = GetCornerPoints(geometry, false);
473  num = 0;
474  for (auto point : cornerPoints)
475  {
476  pointscontainer->InsertElement(num++, point);
477  }
478 
479  bool positionChangeThreshold = true;
480  for (int numFaces = 0; numFaces < 8; numFaces++) // estimate the corresponding face and shift its assigned points
481  {
482  if ((numFaces != faces[0]) && (numFaces != faces[1]) && (numFaces != faces[2]) && (numFaces != faces[3]))
483  {
484  Point3D point = pointscontainer->GetElement(numFaces);
485  if (m_Impl->RotationEnabled) // apply if geometry is rotated at a pixel aligned shift is not possible
486  {
487  point[0] += faceShift[0];
488  point[1] += faceShift[1];
489  point[2] += faceShift[2];
490  }
491  else // shift pixelwise
492  {
493  point[0] += std::round(faceShift[0] / spacing[0]) * spacing[0];
494  point[1] += std::round(faceShift[1] / spacing[1]) * spacing[1];
495  point[2] += std::round(faceShift[2] / spacing[2]) * spacing[2];
496  }
497 
498  if (point == pointscontainer->GetElement(numFaces))
499  positionChangeThreshold = false;
500  else
501  m_Impl->LastPickedWorldPoint = point;
502 
503  pointscontainer->InsertElement(numFaces, point);
504  }
505  }
506 
507  if (positionChangeThreshold) // update only if bounding box is shifted at least by one pixel
508  {
509  auto inverse = mitk::AffineTransform3D::New();
510  geometry->GetIndexToWorldTransform()->GetInverse(inverse);
511  for (unsigned int pointid = 0; pointid < 8; pointid++)
512  {
513  pointscontainer->InsertElement(pointid, inverse->TransformPoint(pointscontainer->GetElement(pointid)));
514  }
515 
516  auto bbox = mitk::BoundingBox::New();
517  bbox->SetPoints(pointscontainer);
518  bbox->ComputeBoundingBox();
519  mitk::Point3D BBmin = bbox->GetMinimum();
520  mitk::Point3D BBmax = bbox->GetMaximum();
521  if (std::abs(BBmin[0] - BBmax[0]) > 0.01 && std::abs(BBmin[1] - BBmax[1]) > 0.01 &&
522  std::abs(BBmin[2] - BBmax[2]) > 0.01) // TODO: check if the extent is greater than zero
523  {
524  geometry->SetBounds(bbox->GetBounds());
525  geometry->Modified();
526  this->GetDataNode()->GetData()->UpdateOutputInformation(); // Geometry is up-to-date
527  this->GetDataNode()->GetData()->Modified();
529  }
530  }
531  return;
532 }
533 
535 {
536  mitk::DataNode::Pointer inputNode = this->GetDataNode();
537  if (inputNode.IsNull())
538  return;
539 
541  if (color.IsNotNull())
542  {
543  inputNode->GetPropertyList()->SetProperty("color", color);
544  }
545  inputNode->SetProperty("layer", mitk::IntProperty::New(99));
546  inputNode->SetProperty(boundingShapePropertyName, mitk::BoolProperty::New(false));
547  inputNode->GetPropertyList()->DeleteProperty(activeHandleIdPropertyName);
548 
549  EnableCrosshairNavigation();
550  // update rendering
552 }
553 
554 void mitk::BoundingShapeInteractor::EnableCrosshairNavigation()
555 {
556  // enable the crosshair navigation
557  // Re-enabling InteractionEventObservers that have been previously disabled for legacy handling of Tools
558  // in new interaction framework
559  for (auto it = m_Impl->DisplayInteractorConfigs.begin();
560  it != m_Impl->DisplayInteractorConfigs.end();
561  ++it)
562  {
563  if (it->first)
564  {
565  mitk::DisplayInteractor *displayInteractor = static_cast<mitk::DisplayInteractor *>(
567  if (displayInteractor != nullptr)
568  {
569  // here the regular configuration is loaded again
570  displayInteractor->SetEventConfig(it->second);
571  // MITK_INFO << "restore config";
572  }
573  }
574  }
575  m_Impl->DisplayInteractorConfigs.clear();
576  m_Impl->ScrollEnabled = true;
577 }
578 
579 void mitk::BoundingShapeInteractor::DisableCrosshairNavigation()
580 {
581  // dont deactivate twice, else we will clutter the config list ...
582  if (m_Impl->ScrollEnabled == false)
583  return;
584 
585  // As a legacy solution the display interaction of the new interaction framework is disabled here to avoid conflicts
586  // with tools
587  // Note: this only affects InteractionEventObservers (formerly known as Listeners) all DataNode specific interaction
588  // will still be enabled
589  m_Impl->DisplayInteractorConfigs.clear();
590  std::vector<us::ServiceReference<mitk::InteractionEventObserver>> listEventObserver =
592  for (auto it = listEventObserver.begin();
593  it != listEventObserver.end();
594  ++it)
595  {
596  auto *displayInteractor =
598  if (displayInteractor != nullptr)
599  {
600  // remember the original configuration
601  m_Impl->DisplayInteractorConfigs.insert(std::make_pair(*it, displayInteractor->GetEventConfig()));
602  // here the alternative configuration is loaded
603  displayInteractor->SetEventConfig("DisplayConfigMITKNoCrosshair.xml");
604  // MITK_INFO << "change config";
605  }
606  }
607 
608  m_Impl->ScrollEnabled = false;
609 }
virtual void SelectObject(StateMachineAction *, InteractionEvent *)
Called if the mouse pointer is over the object indicated by a color change.
void DisplayToWorld(const Point2D &displayPoint, Point3D &worldIndex) const
This method converts a display point to the 3D world index using the geometry of the renderWindow...
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr, bool fallBackOnDataProperties=true) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
virtual void DeselectHandles(StateMachineAction *, InteractionEvent *interactionEvent)
Deselects all Handles at the end of interaction.
Point< ScalarType, 2 > Point2D
Definition: mitkPoint.h:94
const char * boundingShapePropertyName
Super class for all position events.
virtual bool CheckOverObject(const InteractionEvent *)
Checks if the mouse pointer is over the object.
Base class to implement InteractionEventObservers.
Observer that manages the interaction with the display.
double ScalarType
Point2D GetDisplaySizeInMM() const
static Pointer New()
double GetScaleFactorMMPerDisplayUnit() const
const char * activeHandleIdPropertyName
DataCollection - Class to facilitate loading/accessing structured data.
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.
void HandlePositionChanged(const InteractionEvent *interactionEvent, Point3D &center)
std::vector< mitk::Point3D > GetCornerPoints(mitk::BaseGeometry::Pointer geometry, bool visualizationOffset)
helper function for calculating corner points of the bounding object from a given geometry ...
void WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
This method converts a 3D world index to the display point using the geometry of the renderWindow...
DataNode * GetDataNode() const
virtual void ScaleObject(StateMachineAction *, InteractionEvent *)
Performs a object shape change by influencing the scaling of the initial bounding box...
void * GetService(const ServiceReferenceBase &reference)
std::vector< int > GetHandleIndices(int index)
BaseRenderer * GetSender() const
static Pointer New()
The ColorProperty class RGB color property.
itk::SmartPointer< Self > Pointer
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
const char * selectedColorPropertyName
virtual bool CheckOverHandles(const InteractionEvent *interactionEvent)
Checks if the mouse pointer is over one of the assigned handles.
bool InitMembers(InteractionEvent *interactionEvent)
Initializes member variables.
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
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...
virtual unsigned int GetTimeStep() const
Data class only having a BaseGeometry but not containing any specific data.
Point< ScalarType, 3 > Point3D
Definition: mitkPoint.h:95
void UpdateOutputInformation() override
Update the information for this BaseData (the geometry in particular) so that it can be used as an ou...
std::vector< ServiceReferenceU > GetServiceReferences(const std::string &clazz, const std::string &filter=std::string())
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
virtual void SetDataNode(DataNode *dataNode)
#define CONNECT_CONDITION(a, f)
static Pointer New()
const mitk::TimeGeometry * GetUpdatedTimeGeometry()
Return the TimeGeometry of the data.
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
virtual void SelectHandle(StateMachineAction *, InteractionEvent *)
Called if the mouse pointer is over one of the handles indicated by a color change.
const float selectedColor[]
void SetRotationEnabled(bool rotationEnabled)
virtual void InitInteraction(StateMachineAction *, InteractionEvent *interactionEvent)
Initializes the movement, stores starting position.
#define CONNECT_FUNCTION(a, f)
const char * deselectedColorPropertyName
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void SetDataNode(DataNode *dataNode) override
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
mitk::Point3D CalcAvgPoint(mitk::Point3D a, mitk::Point3D b)
helper function for calculating the average of two points
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
void DataNodeChanged() override
Called when a DataNode has been set/changed.
bool SetEventConfig(const std::string &filename, const us::Module *module=nullptr)
Loads a configuration from an XML resource.
virtual void RestoreNodeProperties()
Restore default properties of bounding box and handles.