Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmlMitkStdMultiItem.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,
6  Division of Medical and Biological Informatics.
7  All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without
10  even the implied warranty of MERCHANTABILITY or FITNESS FOR
11  A PARTICULAR PURPOSE.
12 
13  See LICENSE.txt or http://www.mitk.org for details.
14 
15  ===================================================================*/
16 
17 #include "QmlMitkStdMultiItem.h"
19 
20 #include <mitkImage.h>
21 #include <mitkDataNode.h>
22 #include <mitkIOUtil.h>
24 #include <mitkLine.h>
25 
27 mitk::DataStorage::Pointer QmlMitkStdMultiItem::storage = nullptr;
28 
30 {
31  instance = this;
32 }
33 
35 {
36 }
37 
39 {
40  viewerItem->setupView();
41  viewerItem->createPlaneNode();
42 
43  switch (viewerItem->GetRenderer()->GetSliceNavigationController()->GetDefaultViewDirection())
44  {
46  this->m_viewerAxial = viewerItem;
47  break;
49  this->m_viewerFrontal = viewerItem;
50  break;
52  this->m_viewerSagittal = viewerItem;
53  break;
54  default:
55  this->m_viewerOriginal = viewerItem;
56  }
57 }
58 
60 {
61  if(QmlMitkStdMultiItem::storage.IsNull())
62  QmlMitkStdMultiItem::storage = mitk::StandaloneDataStorage::New();
63 
64  this->m_mouseMode = mitk::MouseModeSwitcher::New();
65  this->m_mouseMode->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::MITK);
66 
67  this->m_viewerAxial->SetDataStorage(QmlMitkStdMultiItem::storage);
68  this->m_viewerFrontal->SetDataStorage(QmlMitkStdMultiItem::storage);
69  this->m_viewerSagittal->SetDataStorage(QmlMitkStdMultiItem::storage);
70  this->m_viewerOriginal->SetDataStorage(QmlMitkStdMultiItem::storage);
71 
72  this->addPlanes();
73 
75 }
76 
78 {
79  bool toggle;
80  this->m_planeAxial->GetBoolProperty("visible", toggle);
81 
82  this->m_planeAxial->SetVisibility(!toggle);
83  this->m_planeFrontal->SetVisibility(!toggle);
84  this->m_planeSagittal->SetVisibility(!toggle);
85 
87 }
88 
90 {
91  this->m_planeAxial = this->m_viewerAxial->GetRenderer()->GetCurrentWorldPlaneGeometryNode();
92  this->m_planeFrontal = this->m_viewerFrontal->GetRenderer()->GetCurrentWorldPlaneGeometryNode();
93  this->m_planeSagittal = this->m_viewerSagittal->GetRenderer()->GetCurrentWorldPlaneGeometryNode();
94 
95  QmlMitkStdMultiItem::storage->Add(this->m_planeAxial);
96  QmlMitkStdMultiItem::storage->Add(this->m_planeFrontal);
97  QmlMitkStdMultiItem::storage->Add(this->m_planeSagittal);
98 }
99 
101 {
102  this->m_viewerAxial->GetSliceNavigationController()->SelectSliceByPoint(newPosition);
103  this->m_viewerFrontal->GetSliceNavigationController()->SelectSliceByPoint(newPosition);
104  this->m_viewerSagittal->GetSliceNavigationController()->SelectSliceByPoint(newPosition);
105 
107 }
108 
110 {
111  const mitk::PlaneGeometry *plane1 = this->m_viewerAxial->GetSliceNavigationController()->GetCurrentPlaneGeometry();
112  const mitk::PlaneGeometry *plane2 = this->m_viewerFrontal->GetSliceNavigationController()->GetCurrentPlaneGeometry();
113  const mitk::PlaneGeometry *plane3 = this->m_viewerSagittal->GetSliceNavigationController()->GetCurrentPlaneGeometry();
114 
116  if ( (plane1 != NULL) && (plane2 != NULL)
117  && (plane1->IntersectionLine( plane2, line )) )
118  {
119  mitk::Point3D point;
120  if ( (plane3 != NULL)
121  && (plane3->IntersectionPoint( line, point )) )
122  {
123  return point;
124  }
125  }
126  // TODO BUG POSITIONTRACKER;
127  mitk::Point3D p;
128  return p;
129  //return m_LastLeftClickPositionSupplier->GetCurrentPoint();
130 }
131 
132 
134 {
135  return this->m_viewerAxial;
136 }
137 
139 {
140  return this->m_viewerFrontal;
141 }
142 
144 {
145  return this->m_viewerSagittal;
146 }
147 
149 {
150  return this->m_viewerOriginal;
151 }
152 
154 {
155  QmlMitkStdMultiItem::storage = storage;
156 
157  qmlRegisterType<QmlMitkStdMultiItem>("Mitk.Views", 1, 0, "MultiItem");
158  qmlRegisterType<QmlMitkRenderWindowItem>("Mitk.Views", 1, 0, "ViewItem");
159  QQmlComponent component(&engine, QUrl("qrc:/views/MitkStdMultiItem.qml"));
160 }
QmlMitkRenderWindowItem * getViewerAxial()
virtual DataNode * GetCurrentWorldPlaneGeometryNode()
Get a DataNode pointing to a data object containing the current 2D-worldgeometry. ...
Descibes a line.
Definition: mitkLine.h:32
static char * line
Definition: svm.cpp:2884
QmlMitkRenderWindowItem * getViewerOriginal()
void SelectSliceByPoint(const mitk::Point3D &point)
Positions the SNC according to the specified point.
bool IntersectionPoint(const Line3D &line, Point3D &intersectionPoint) const
Calculate intersection point between the plane and a line.
QmlMitkRenderWindowItem * getViewerSagittal()
static Pointer New()
void SetDataStorage(mitk::DataStorage::Pointer storage)
void moveCrossToPosition(const mitk::Point3D &newPosition)
static void create(QQmlEngine &engine, mitk::DataStorage::Pointer storage)
const mitk::Point3D getCrossPosition() const
QmlMitkRenderWindowItem * getViewerCoronal()
static RenderingManager * GetInstance()
const mitk::PlaneGeometry * GetCurrentPlaneGeometry()
Returns the currently selected Plane in the current BaseGeometry (if existent).
virtual mitk::VtkPropRenderer * GetRenderer()
static QmlMitkStdMultiItem * instance
bool IntersectionLine(const PlaneGeometry *plane, Line3D &crossline) const
Calculate the intersecting line of two planes.
void registerViewerItem(QmlMitkRenderWindowItem *viewerItem)
virtual SliceNavigationController * GetSliceNavigationController()
virtual mitk::SliceNavigationController * GetSliceNavigationController()
Describes a two-dimensional, rectangular plane.
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)