Medical Imaging Interaction Toolkit  2018.4.99-bd7b41ba
Medical Imaging Interaction Toolkit
QmitkStdMultiWidget.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 #define SMW_INFO MITK_INFO("widget.stdmulti")
14 
15 #include "QmitkStdMultiWidget.h"
17 
18 // mitk core
19 #include <mitkCameraController.h>
20 #include <mitkImage.h>
22 #include <mitkInteractionConst.h>
23 #include <mitkLine.h>
24 #include <mitkNodePredicateBase.h>
26 #include <mitkNodePredicateNot.h>
28 #include <mitkPixelTypeMultiplex.h>
30 #include <mitkPointSet.h>
31 #include <mitkProperties.h>
32 #include <mitkStatusBar.h>
34 #include <mitkVtkLayerController.h>
35 
36 // qt
37 #include <QList>
38 #include <QMouseEvent>
39 #include <QTimer>
40 
41 // vtk
42 #include <vtkSmartPointer.h>
43 
44 // c++
45 #include <iomanip>
46 
48  Qt::WindowFlags f/* = 0*/,
49  const QString &name/* = "stdmulti"*/)
50  : QmitkAbstractMultiWidget(parent, f, name)
52  , m_PendingCrosshairPositionEvent(false)
53 {
54  m_TimeNavigationController = mitk::RenderingManager::GetInstance()->GetTimeNavigationController();
55 }
56 
58 {
59  m_TimeNavigationController->Disconnect(GetRenderWindow1()->GetSliceNavigationController());
60  m_TimeNavigationController->Disconnect(GetRenderWindow2()->GetSliceNavigationController());
61  m_TimeNavigationController->Disconnect(GetRenderWindow3()->GetSliceNavigationController());
62  m_TimeNavigationController->Disconnect(GetRenderWindow4()->GetSliceNavigationController());
63 }
64 
66 {
67  // yellow is default color for widget4
68  m_DecorationColorWidget4[0] = 1.0f;
69  m_DecorationColorWidget4[1] = 1.0f;
70  m_DecorationColorWidget4[2] = 0.0f;
71 
72  SetLayout(2, 2);
73 
74  // transfer colors in WorldGeometry-Nodes of the associated Renderer
76  // of widget 1
77  m_PlaneNode1 =
79  m_PlaneNode1->SetColor(GetDecorationColor(0));
80  layer = mitk::IntProperty::New(1000);
81  m_PlaneNode1->SetProperty("layer", layer);
82 
83  // of widget 2
84  m_PlaneNode2 =
86  m_PlaneNode2->SetColor(GetDecorationColor(1));
87  layer = mitk::IntProperty::New(1000);
88  m_PlaneNode2->SetProperty("layer", layer);
89 
90  // of widget 3
91  m_PlaneNode3 =
93  m_PlaneNode3->SetColor(GetDecorationColor(2));
94  layer = mitk::IntProperty::New(1000);
95  m_PlaneNode3->SetProperty("layer", layer);
96 
97  // the parent node
98  m_ParentNodeForGeometryPlanes =
100  layer = mitk::IntProperty::New(1000);
101  m_ParentNodeForGeometryPlanes->SetProperty("layer", layer);
102 
104 
105  SetDisplayActionEventHandler(std::make_unique<mitk::DisplayActionEventHandlerStd>());
106 
107  auto displayActionEventHandler = GetDisplayActionEventHandler();
108  if (nullptr != displayActionEventHandler)
109  {
110  displayActionEventHandler->InitActions();
111  }
112 }
113 
115 {
116  if ("axial" == widgetName)
117  {
118  return GetRenderWindow1();
119  }
120 
121  if ("sagittal" == widgetName)
122  {
123  return GetRenderWindow2();
124  }
125 
126  if ("coronal" == widgetName)
127  {
128  return GetRenderWindow3();
129  }
130 
131  if ("3d" == widgetName)
132  {
133  return GetRenderWindow4();
134  }
135 
136 
138 }
139 
141 {
142  return GetRenderWindow(static_cast<unsigned int>(viewDirection));
143 }
144 
145 void QmitkStdMultiWidget::SetSelectedPosition(const mitk::Point3D& newPosition, const QString& /*widgetName*/)
146 {
150 
152 }
153 
154 const mitk::Point3D QmitkStdMultiWidget::GetSelectedPosition(const QString& /*widgetName*/) const
155 {
159 
161  if ((plane1 != nullptr) && (plane2 != nullptr)
162  && (plane1->IntersectionLine(plane2, line)))
163  {
164  mitk::Point3D point;
165  if ((plane3 != nullptr) && (plane3->IntersectionPoint(line, point)))
166  {
167  return point;
168  }
169  }
170 
171  return mitk::Point3D();
172 }
173 
175 {
176  if (m_PlaneNode1.IsNotNull())
177  {
178  m_PlaneNode1->SetVisibility(visible);
179  }
180  if (m_PlaneNode2.IsNotNull())
181  {
182  m_PlaneNode2->SetVisibility(visible);
183  }
184  if (m_PlaneNode3.IsNotNull())
185  {
186  m_PlaneNode3->SetVisibility(visible);
187  }
188 
190 }
191 
193 {
194  bool crosshairVisibility = true;
195 
196  if (m_PlaneNode1.IsNotNull())
197  {
198  bool visibilityProperty = false;
199  m_PlaneNode1->GetVisibility(visibilityProperty, nullptr);
200  crosshairVisibility &= visibilityProperty;
201  }
202 
203  if (m_PlaneNode2.IsNotNull())
204  {
205  bool visibilityProperty = false;
206  crosshairVisibility &= m_PlaneNode2->GetVisibility(visibilityProperty, nullptr);
207  crosshairVisibility &= visibilityProperty;
208  }
209 
210  if (m_PlaneNode3.IsNotNull())
211  {
212  bool visibilityProperty = false;
213  crosshairVisibility &= m_PlaneNode3->GetVisibility(visibilityProperty, nullptr);
214  crosshairVisibility &= visibilityProperty;
215  }
216 
217  return crosshairVisibility;
218 }
219 
221 {
222  auto dataStorage = GetDataStorage();
223  if (nullptr == dataStorage)
224  {
225  return;
226  }
227 
229 
231 }
232 
234 {
235  MITK_DEBUG << "Changing crosshair mode to " << userMode;
236 
237  switch (userMode)
238  {
239  case 0:
241  break;
242  case 1:
244  break;
245  case 2:
247  break;
248  case 3:
250  break;
251  }
252 }
253 
255 {
256  return m_TimeNavigationController;
257 }
258 
260 {
261  auto dataStorage = GetDataStorage();
262  if (nullptr == dataStorage)
263  {
264  return;
265  }
266 
267  if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull()
268  && m_PlaneNode3.IsNotNull() && m_ParentNodeForGeometryPlanes.IsNotNull())
269  {
270  dataStorage->Add(m_ParentNodeForGeometryPlanes);
271  dataStorage->Add(m_PlaneNode1, m_ParentNodeForGeometryPlanes);
272  dataStorage->Add(m_PlaneNode2, m_ParentNodeForGeometryPlanes);
273  dataStorage->Add(m_PlaneNode3, m_ParentNodeForGeometryPlanes);
274  }
275 }
276 
278 {
279  auto dataStorage = GetDataStorage();
280  if (nullptr == dataStorage)
281  {
282  return;
283  }
284 
285  if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull()
286  && m_PlaneNode3.IsNotNull() && m_ParentNodeForGeometryPlanes.IsNotNull())
287  {
288  dataStorage->Remove(m_PlaneNode1);
289  dataStorage->Remove(m_PlaneNode2);
290  dataStorage->Remove(m_PlaneNode3);
291  dataStorage->Remove(m_ParentNodeForGeometryPlanes);
292  }
293 }
294 
296 {
297  if (!m_PendingCrosshairPositionEvent)
298  {
299  m_PendingCrosshairPositionEvent = true;
300  QTimer::singleShot(0, this, SLOT(HandleCrosshairPositionEventDelayed()));
301  }
302 }
303 
305 {
306  switch (number)
307  {
308  case 0:
309  return GetRenderWindow1();
310  case 1:
311  return GetRenderWindow2();
312  case 2:
313  return GetRenderWindow3();
314  case 3:
315  return GetRenderWindow4();
316  default:
317  MITK_ERROR << "Requested unknown render window";
318  break;
319  }
320 
321  return nullptr;
322 }
323 
325 {
327 }
328 
330 {
332 }
333 
335 {
337 }
338 
340 {
342 }
343 
345 {
346  return m_PlaneNode1;
347 }
348 
350 {
351  return m_PlaneNode2;
352 }
353 
355 {
356  return m_PlaneNode3;
357 }
358 
360 {
361  switch (number)
362  {
363  case 1:
364  return m_PlaneNode1;
365  case 2:
366  return m_PlaneNode2;
367  case 3:
368  return m_PlaneNode3;
369  default:
370  MITK_ERROR << "Requested unknown render window";
371  break;
372  }
373 
374  return nullptr;
375 }
376 
377 void QmitkStdMultiWidget::SetDecorationColor(unsigned int widgetNumber, mitk::Color color)
378 {
379  switch (widgetNumber)
380  {
381  case 0:
382  if (m_PlaneNode1.IsNotNull())
383  {
384  m_PlaneNode1->SetColor(color);
385  }
386  break;
387  case 1:
388  if (m_PlaneNode2.IsNotNull())
389  {
390  m_PlaneNode2->SetColor(color);
391  }
392  break;
393  case 2:
394  if (m_PlaneNode3.IsNotNull())
395  {
396  m_PlaneNode3->SetColor(color);
397  }
398  break;
399  case 3:
400  m_DecorationColorWidget4 = color;
401  break;
402  default:
403  MITK_ERROR << "Decoration color for unknown widget!";
404  break;
405  }
406 }
407 
409 {
410  // The implementation looks a bit messy here, but it avoids
411  // synchronization of the color of the geometry nodes and an
412  // internal member here.
413  // Default colors were chosen for decent visibility.
414  // Feel free to change your preferences in the workbench.
415  float tmp[3] = { 0.0f, 0.0f, 0.0f };
416  switch (widgetNumber)
417  {
418  case 0:
419  {
420  if (m_PlaneNode1.IsNotNull())
421  {
422  if (m_PlaneNode1->GetColor(tmp))
423  {
424  return dynamic_cast<mitk::ColorProperty *>(m_PlaneNode1->GetProperty("color"))->GetColor();
425  }
426  }
427  float red[3] = { 0.753f, 0.0f, 0.0f }; // This is #C00000 in hex
428  return mitk::Color(red);
429  }
430  case 1:
431  {
432  if (m_PlaneNode2.IsNotNull())
433  {
434  if (m_PlaneNode2->GetColor(tmp))
435  {
436  return dynamic_cast<mitk::ColorProperty *>(m_PlaneNode2->GetProperty("color"))->GetColor();
437  }
438  }
439  float green[3] = { 0.0f, 0.69f, 0.0f }; // This is #00B000 in hex
440  return mitk::Color(green);
441  }
442  case 2:
443  {
444  if (m_PlaneNode3.IsNotNull())
445  {
446  if (m_PlaneNode3->GetColor(tmp))
447  {
448  return dynamic_cast<mitk::ColorProperty *>(m_PlaneNode3->GetProperty("color"))->GetColor();
449  }
450  }
451  float blue[3] = { 0.0, 0.502f, 1.0f }; // This is #0080FF in hex
452  return mitk::Color(blue);
453  }
454  case 3:
455  {
456  return m_DecorationColorWidget4;
457  }
458  default:
459  MITK_ERROR << "Decoration color for unknown widget!";
460  float black[3] = { 0.0f, 0.0f, 0.0f };
461  return mitk::Color(black);
462  }
463 }
464 
466 {
467  if (QEvent::MouseButtonPress != e->type())
468  {
469  return;
470  }
471 
472  auto renderWindowWidget = dynamic_cast<QmitkRenderWindowWidget*>(this->sender());
473  if (nullptr == renderWindowWidget)
474  {
475  return;
476  }
477 
478  auto renderWindowWidgetPointer = GetRenderWindowWidget(renderWindowWidget->GetWidgetName());
479  SetActiveRenderWindowWidget(renderWindowWidgetPointer);
480 }
481 
483 {
484  QWidget::moveEvent(e);
485 
486  // it is necessary to readjust the position of the Annotation as the StdMultiWidget has moved
487  // unfortunately it's not done by QmitkRenderWindow::moveEvent -> must be done here
488  emit Moved();
489 }
490 
492 {
493  emit WheelMoved(e);
494 }
495 
497 {
498  auto dataStorage = GetDataStorage();
499  if (nullptr == dataStorage)
500  {
501  return;
502  }
503 
504  m_PendingCrosshairPositionEvent = false;
505 
506  // find image with highest layer
508  mitk::DataStorage::SetOfObjects::ConstPointer nodes = dataStorage->GetSubset(isImageData).GetPointer();
509  mitk::Point3D crosshairPos = GetSelectedPosition("");
511  auto globalCurrentTimePoint = baseRenderer->GetTime();
512  mitk::DataNode::Pointer node = mitk::FindTopmostVisibleNode(nodes, crosshairPos, globalCurrentTimePoint, baseRenderer);
513 
514  mitk::DataNode::Pointer topSourceNode;
516  bool isBinary = false;
517  int component = 0;
518 
519  if (node.IsNotNull())
520  {
521  node->GetBoolProperty("binary", isBinary);
522  if (isBinary)
523  {
524  mitk::DataStorage::SetOfObjects::ConstPointer sourcenodes = dataStorage->GetSources(node, nullptr, true);
525  if (!sourcenodes->empty())
526  {
527  topSourceNode = mitk::FindTopmostVisibleNode(sourcenodes, crosshairPos, globalCurrentTimePoint, baseRenderer);
528  }
529  if (topSourceNode.IsNotNull())
530  {
531  image = dynamic_cast<mitk::Image *>(topSourceNode->GetData());
532  topSourceNode->GetIntProperty("Image.Displayed Component", component);
533  }
534  else
535  {
536  image = dynamic_cast<mitk::Image *>(node->GetData());
537  node->GetIntProperty("Image.Displayed Component", component);
538  }
539  }
540  else
541  {
542  image = dynamic_cast<mitk::Image *>(node->GetData());
543  node->GetIntProperty("Image.Displayed Component", component);
544  }
545  }
546 
547  std::string statusText;
548  std::stringstream stream;
549  itk::Index<3> p;
550  unsigned int timestep = baseRenderer->GetTimeStep();
551 
552  if (image.IsNotNull() && (image->GetTimeSteps() > timestep))
553  {
554  image->GetGeometry()->WorldToIndex(crosshairPos, p);
555  stream.precision(2);
556  stream << "Position: <" << std::fixed << crosshairPos[0] << ", " << std::fixed << crosshairPos[1] << ", "
557  << std::fixed << crosshairPos[2] << "> mm";
558  stream << "; Index: <" << p[0] << ", " << p[1] << ", " << p[2] << "> ";
559 
560  mitk::ScalarType pixelValue;
561 
563  image->GetChannelDescriptor().GetPixelType(),
564  image,
565  image->GetVolumeData(image->GetTimeGeometry()->TimePointToTimeStep(globalCurrentTimePoint)),
566  p,
567  pixelValue,
568  component);
569 
570  if (fabs(pixelValue) > 1000000 || fabs(pixelValue) < 0.01)
571  {
572  stream << "; Time: " << globalCurrentTimePoint << " ms; Pixelvalue: " << std::scientific << pixelValue << " ";
573  }
574  else
575  {
576  stream << "; Time: " << globalCurrentTimePoint << " ms; Pixelvalue: " << pixelValue << " ";
577  }
578  }
579  else
580  {
581  stream << "No image information at this position!";
582  }
583 
584  statusText = stream.str();
585  mitk::StatusBar::GetInstance()->DisplayGreyValueText(statusText.c_str());
586 }
587 
589 {
590  vtkSmartPointer<vtkRenderer> vtkrenderer;
592  if (nullptr != vtkrenderer)
593  {
594  vtkrenderer->ResetCamera();
595  }
596 
598  if (nullptr != vtkrenderer)
599  {
600  vtkrenderer->ResetCamera();
601  }
602 
604  if (nullptr != vtkrenderer)
605  {
606  vtkrenderer->ResetCamera();
607  }
608 
610  if (nullptr != vtkrenderer)
611  {
612  vtkrenderer->ResetCamera();
613  }
614 
619 
620  int w = vtkObject::GetGlobalWarningDisplay();
621  vtkObject::GlobalWarningDisplayOff();
622 
623  vtkObject::SetGlobalWarningDisplay(w);
624 }
625 
627 {
628  // add the displayed planes of the multiwidget to a node to which the subtree
629  // @a planesSubTree points ...
630 
632 
633  // ... of widget 1
635  m_PlaneNode1 = renderer1->GetCurrentWorldPlaneGeometryNode();
636  m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true));
637  m_PlaneNode1->SetProperty("name", mitk::StringProperty::New(std::string(renderer1->GetName()) + ".plane"));
638  m_PlaneNode1->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
639  m_PlaneNode1->SetProperty("helper object", mitk::BoolProperty::New(true));
641  m_PlaneNode1->SetMapper(mitk::BaseRenderer::Standard2D, mapper);
642 
643  // ... of widget 2
645  m_PlaneNode2 = renderer2->GetCurrentWorldPlaneGeometryNode();
646  m_PlaneNode2->SetProperty("visible", mitk::BoolProperty::New(true));
647  m_PlaneNode2->SetProperty("name", mitk::StringProperty::New(std::string(renderer2->GetName()) + ".plane"));
648  m_PlaneNode2->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
649  m_PlaneNode2->SetProperty("helper object", mitk::BoolProperty::New(true));
651  m_PlaneNode2->SetMapper(mitk::BaseRenderer::Standard2D, mapper);
652 
653  // ... of widget 3
655  m_PlaneNode3 = renderer3->GetCurrentWorldPlaneGeometryNode();
656  m_PlaneNode3->SetProperty("visible", mitk::BoolProperty::New(true));
657  m_PlaneNode3->SetProperty("name", mitk::StringProperty::New(std::string(renderer3->GetName()) + ".plane"));
658  m_PlaneNode3->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
659  m_PlaneNode3->SetProperty("helper object", mitk::BoolProperty::New(true));
661  m_PlaneNode3->SetMapper(mitk::BaseRenderer::Standard2D, mapper);
662 
663  m_ParentNodeForGeometryPlanes = mitk::DataNode::New();
664  m_ParentNodeForGeometryPlanes->SetProperty("name", mitk::StringProperty::New("Widgets"));
665  m_ParentNodeForGeometryPlanes->SetProperty("helper object", mitk::BoolProperty::New(true));
666 }
667 
669 {
670  mitk::Point2D pointOnDisplay;
671  renderer->WorldToDisplay(p, pointOnDisplay);
672 
673  if (pointOnDisplay[0] < renderer->GetVtkRenderer()->GetOrigin()[0] ||
674  pointOnDisplay[1] < renderer->GetVtkRenderer()->GetOrigin()[1] ||
675  pointOnDisplay[0] > renderer->GetVtkRenderer()->GetOrigin()[0] + renderer->GetViewportSize()[0] ||
676  pointOnDisplay[1] > renderer->GetVtkRenderer()->GetOrigin()[1] + renderer->GetViewportSize()[1])
677  {
678  mitk::Point2D pointOnPlane;
679  renderer->GetCurrentWorldPlaneGeometry()->Map(p, pointOnPlane);
680  renderer->GetCameraController()->MoveCameraToPoint(pointOnPlane);
681  }
682 }
683 
684 void QmitkStdMultiWidget::SetWidgetPlaneVisibility(const char *widgetName, bool visible, mitk::BaseRenderer *renderer)
685 {
686  auto dataStorage = GetDataStorage();
687  if (nullptr != dataStorage)
688  {
689  mitk::DataNode* dataNode = dataStorage->GetNamedNode(widgetName);
690  if (dataNode != nullptr)
691  {
692  dataNode->SetVisibility(visible, renderer);
693  }
694  }
695 }
696 
698 {
699  if (m_PlaneNode1.IsNotNull())
700  {
701  m_PlaneNode1->SetVisibility(visible, renderer);
702  }
703  if (m_PlaneNode2.IsNotNull())
704  {
705  m_PlaneNode2->SetVisibility(visible, renderer);
706  }
707  if (m_PlaneNode3.IsNotNull())
708  {
709  m_PlaneNode3->SetVisibility(visible, renderer);
710  }
712 }
713 
715 // PRIVATE
717 void QmitkStdMultiWidget::SetLayoutImpl()
718 {
719  CreateRenderWindowWidgets();
721 
722  // Initialize views as axial, sagittal, coronal to all data objects in DataStorage
723  auto geo = GetDataStorage()->ComputeBoundingGeometry3D(GetDataStorage()->GetAll());
725 }
726 
727 void QmitkStdMultiWidget::CreateRenderWindowWidgets()
728 {
729  // create axial render window (widget)
730  QString renderWindowWidgetName = GetNameFromIndex(0, 0);
731  RenderWindowWidgetPointer renderWindowWidget1 = std::make_shared<QmitkRenderWindowWidget>(this, renderWindowWidgetName, GetDataStorage());
732  auto renderWindow1 = renderWindowWidget1->GetRenderWindow();
733  renderWindow1->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial);
734  renderWindowWidget1->SetDecorationColor(GetDecorationColor(0));
735  renderWindowWidget1->SetCornerAnnotationText("Axial");
736  renderWindowWidget1->GetRenderWindow()->SetLayoutIndex(ViewDirection::AXIAL);
737  AddRenderWindowWidget(renderWindowWidgetName, renderWindowWidget1);
738 
739  // create sagittal render window (widget)
740  renderWindowWidgetName = GetNameFromIndex(0, 1);
741  RenderWindowWidgetPointer renderWindowWidget2 = std::make_shared<QmitkRenderWindowWidget>(this, renderWindowWidgetName, GetDataStorage());
742  auto renderWindow2 = renderWindowWidget2->GetRenderWindow();
743  renderWindow2->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal);
744  renderWindowWidget2->SetDecorationColor(GetDecorationColor(1));
745  renderWindowWidget2->setStyleSheet("border: 0px");
746  renderWindowWidget2->SetCornerAnnotationText("Sagittal");
747  renderWindowWidget2->GetRenderWindow()->SetLayoutIndex(ViewDirection::SAGITTAL);
748  AddRenderWindowWidget(renderWindowWidgetName, renderWindowWidget2);
749 
750  // create coronal render window (widget)
751  renderWindowWidgetName = GetNameFromIndex(1, 0);
752  RenderWindowWidgetPointer renderWindowWidget3 = std::make_shared<QmitkRenderWindowWidget>(this, renderWindowWidgetName, GetDataStorage());
753  auto renderWindow3 = renderWindowWidget3->GetRenderWindow();
754  renderWindow3->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Frontal);
755  renderWindowWidget3->SetDecorationColor(GetDecorationColor(2));
756  renderWindowWidget3->SetCornerAnnotationText("Coronal");
757  renderWindowWidget3->GetRenderWindow()->SetLayoutIndex(ViewDirection::CORONAL);
758  AddRenderWindowWidget(renderWindowWidgetName, renderWindowWidget3);
759 
760  // create 3D render window (widget)
761  renderWindowWidgetName = GetNameFromIndex(1, 1);
762  RenderWindowWidgetPointer renderWindowWidget4 = std::make_shared<QmitkRenderWindowWidget>(this, renderWindowWidgetName, GetDataStorage());
763  auto renderWindow4 = renderWindowWidget4->GetRenderWindow();
764  renderWindow4->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Original);
765  renderWindowWidget4->SetDecorationColor(GetDecorationColor(3));
766  renderWindowWidget4->SetCornerAnnotationText("3D");
767  renderWindowWidget4->GetRenderWindow()->SetLayoutIndex(ViewDirection::THREE_D);
768  mitk::BaseRenderer::GetInstance(renderWindowWidget4->GetRenderWindow()->GetRenderWindow())->SetMapperID(mitk::BaseRenderer::Standard3D);
769  AddRenderWindowWidget(renderWindowWidgetName, renderWindowWidget4);
770 
771  SetActiveRenderWindowWidget(renderWindowWidget1);
772 
773  // connect to the "time navigation controller": send time via sliceNavigationControllers
774  m_TimeNavigationController->ConnectGeometryTimeEvent(renderWindow1->GetSliceNavigationController(), false);
775  m_TimeNavigationController->ConnectGeometryTimeEvent(renderWindow2->GetSliceNavigationController(), false);
776  m_TimeNavigationController->ConnectGeometryTimeEvent(renderWindow3->GetSliceNavigationController(), false);
777  m_TimeNavigationController->ConnectGeometryTimeEvent(renderWindow4->GetSliceNavigationController(), false);
778  renderWindow1->GetSliceNavigationController()->ConnectGeometrySendEvent(
779  mitk::BaseRenderer::GetInstance(renderWindow4->GetRenderWindow()));
780 
781  // reverse connection between sliceNavigationControllers and timeNavigationController
782  renderWindow1->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false);
783  renderWindow2->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false);
784  renderWindow3->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false);
785  //renderWindow4->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false);
786 
787  auto layoutManager = GetMultiWidgetLayoutManager();
788  connect(renderWindowWidget1.get(), &QmitkRenderWindowWidget::MouseEvent, this, &QmitkStdMultiWidget::mousePressEvent);
789  connect(renderWindow1, &QmitkRenderWindow::ResetView, this, &QmitkStdMultiWidget::ResetCrosshair);
793 
794  connect(renderWindowWidget2.get(), &QmitkRenderWindowWidget::MouseEvent, this, &QmitkStdMultiWidget::mousePressEvent);
795  connect(renderWindow2, &QmitkRenderWindow::ResetView, this, &QmitkStdMultiWidget::ResetCrosshair);
799 
800  connect(renderWindowWidget3.get(), &QmitkRenderWindowWidget::MouseEvent, this, &QmitkStdMultiWidget::mousePressEvent);
801  connect(renderWindow3, &QmitkRenderWindow::ResetView, this, &QmitkStdMultiWidget::ResetCrosshair);
805 
806  connect(renderWindowWidget4.get(), &QmitkRenderWindowWidget::MouseEvent, this, &QmitkStdMultiWidget::mousePressEvent);
807  connect(renderWindow4, &QmitkRenderWindow::ResetView, this, &QmitkStdMultiWidget::ResetCrosshair);
811 }
mitk::ScalarType FastSinglePixelAccess(mitk::PixelType, mitk::Image::Pointer im, ImageDataItem *item, itk::Index< 3 > idx, mitk::ScalarType &val, int component=0)
void LayoutDesignChanged(QmitkRenderWindowMenu::LayoutDesign)
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
QmitkRenderWindow * GetRenderWindow3() const
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
QmitkRenderWindow * GetRenderWindow(int row, int column) const
mitk::DataNode::Pointer GetWidgetPlane3() const
virtual DataNode * GetCurrentWorldPlaneGeometryNode()
Get a DataNode pointing to a data object containing the current 2D-worldgeometry. ...
void WheelMoved(QWheelEvent *)
Descibes a line.
Definition: mitkLine.h:28
static char * line
Definition: svm.cpp:2870
QmitkRenderWindow * GetRenderWindow2() const
virtual void AddRenderWindowWidget(const QString &widgetName, RenderWindowWidgetPointer renderWindowWidget)
virtual void mousePressEvent(QMouseEvent *) override
void SelectSliceByPoint(const mitk::Point3D &point)
Positions the SNC according to the specified point.
QmitkMultiWidgetLayoutManager * GetMultiWidgetLayoutManager() const
void SetVisibility(bool visible, const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="visible")
Convenience method for setting visibility properties (instances of BoolProperty)
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
mitk::DataNode::Pointer GetWidgetPlane1() const
vtkRenderer * GetVtkRenderer() const
virtual const mitk::Point3D GetSelectedPosition(const QString &widgetName) const override
RenderWindowWidgetPointer GetRenderWindowWidget(int row, int column) const
#define MITK_ERROR
Definition: mitkLogMacros.h:20
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of the input objects.
double ScalarType
virtual void ResetCrosshair() override
mitk::SliceNavigationController * GetTimeNavigationController()
Organizes the rendering process.
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
void SetDecorationColor(unsigned int widgetNumber, mitk::Color color)
SetDecorationColor Set the color of the decoration of the 4 widgets.
bool IntersectionPoint(const Line3D &line, Point3D &intersectionPoint) const
Calculate intersection point between the plane and a line.
void HandleCrosshairPositionEvent()
Listener to the CrosshairPositionEvent.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
Constants for most interaction classes, due to the generic StateMachines.
The &#39;QmitkRenderWindowWidget&#39; is a QFrame that holds a render window and some associates properties...
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
const SliceNavigationController * GetTimeNavigationController() const
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...
Controls the selection of the slice the associated BaseRenderer will display.
virtual void SetWidgetPlaneMode(int mode) override
void HandleCrosshairPositionEventDelayed()
Receives the signal from HandleCrosshairPositionEvent, executes the StatusBar update.
mitk::DataNode::Pointer GetWidgetPlane(unsigned int number) const
Convenience method to get a widget plane.
static Pointer New()
std::shared_ptr< QmitkRenderWindowWidget > RenderWindowWidgetPointer
mitk::Color GetDecorationColor(unsigned int widgetNumber)
GetDecorationColorForWidget Get the color for annotation, crosshair and rectangle.
The ColorProperty class RGB color property.
bool IntersectionLine(const PlaneGeometry *plane, Line3D &crossline) const
Calculate the intersecting line of two planes.
virtual void InitializeMultiWidget() override
void ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent=true)
QmitkRenderWindow * GetRenderWindow1() const
void SetWidgetPlaneVisibility(const char *widgetName, bool visible, mitk::BaseRenderer *renderer=nullptr)
void EnsureDisplayContainsPoint(mitk::BaseRenderer *renderer, const mitk::Point3D &p)
static Pointer New()
virtual void moveEvent(QMoveEvent *e) override
static RenderingManager * GetInstance()
void SetDisplayActionEventHandler(std::unique_ptr< mitk::DisplayActionEventHandler > displayActionEventHandler)
virtual unsigned int GetTimeStep() const
void SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer=nullptr)
virtual CameraController * GetCameraController()
virtual void SetLayout(int row, int column)
void CrosshairRotationModeChanged(int)
Image class for storing images.
Definition: mitkImage.h:72
const mitk::PlaneGeometry * GetCurrentPlaneGeometry()
Returns the currently selected Plane in the current BaseGeometry (if existent).
virtual QmitkRenderWindow * GetRenderWindow(const QString &widgetName) const override
MITK implementation of the QVTKWidget.
virtual int * GetViewportSize() const
void CrosshairVisibilityChanged(bool)
mitk::Image::Pointer image
Point< ScalarType, 3 > Point3D
Definition: mitkPoint.h:95
QmitkRenderWindow * GetRenderWindow4() const
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
mitk::DisplayActionEventHandler * GetDisplayActionEventHandler()
virtual void SetSelectedPosition(const mitk::Point3D &newPosition, const QString &widgetName) override
static StatusBar * GetInstance()
static method to get the GUI dependent StatusBar-instance so the methods DisplayText, etc. can be called No reference counting, cause of decentral static use!
virtual void wheelEvent(QWheelEvent *e) override
virtual void SetInteractionScheme(mitk::InteractionSchemeSwitcher::InteractionScheme scheme)
static Pointer New()
mitk::DataNode::Pointer GetWidgetPlane2() const
void DisplayGreyValueText(const char *t)
virtual bool GetCrosshairVisibility() const override
virtual QString GetNameFromIndex(int row, int column) const
virtual void SetActiveRenderWindowWidget(RenderWindowWidgetPointer activeRenderWindowWidget)
ViewDirection
Possible view directions for render windows.
virtual mitk::SliceNavigationController * GetSliceNavigationController()
#define mitkPixelTypeMultiplex5(function, ptype, param1, param2, param3, param4, param5)
Describes a two-dimensional, rectangular plane.
mitk::SliceNavigationController * m_TimeNavigationController
mitk::DataStorage * GetDataStorage() const
MITKCORE_EXPORT DataNode::Pointer FindTopmostVisibleNode(const DataStorage::SetOfObjects::ConstPointer nodes, const Point3D worldPosition, const TimePointType timePoint, const BaseRenderer *baseRender)
returns the topmost visible node of a given list of nodes. The function returns a node that is visibl...
BaseRenderer * GetRenderer() const
Gets the BaseRenderer associated with this SNC (if any). While the BaseRenderer is not directly used ...
void MoveCameraToPoint(const Point2D &planePoint)
MoveCameraToPoint Move camera so that the point on the plane is in the view center.
The &#39;QmitkAbstractMultiWidget&#39; is a &#39;QWidget&#39; that can be subclassed to display multiple render windo...
void Fit()
Fit Adjust the camera, so that the world bounding box is fully visible.
void MouseEvent(QMouseEvent *e)
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
void SetLayoutDesign(LayoutDesign layoutDesign)
This function is called by render window widgets. Given a specific layout design the layout of the mu...
static Pointer New()
QmitkStdMultiWidget(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr, const QString &name="stdmulti")
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
const char * GetName() const
get the name of the Renderer
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
virtual void SetCrosshairVisibility(bool) override