Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmlMitkProperties.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 "QmlMitkProperties.h"
18 
19 #include <mitkImage.h>
20 #include <mitkDataNode.h>
23 
24 #include <QQmlEngine>
25 #include <QQmlContext>
26 
28 
30 {
31  instance = this;
32 }
33 
35 {
36 }
37 
39 {
40  this->m_rendering = state;
41  if(this->m_node)
42  {
43  this->m_node->SetBoolProperty("volumerendering", state);
45 
47  }
48 
49  emit this->renderingChanged();
50 }
51 
52 void QmlMitkProperties::setLod(bool state)
53 {
54  this->m_lod = state;
55  if(this->m_node)
56  {
57  this->m_node->SetBoolProperty("volumerendering.uselod", state);
59  }
60 
61  emit this->lodChanged();
62 }
63 
65 {
66  if (!this->m_node)
67  return;
68 
69  this->m_mode = mode;
70 
71  bool usegpu=mode==RM_GPU_COMPOSITE_SLICING;
72  // Only with VTK 5.6 or above
73 #if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) ))
74  bool useray=(mode==RM_GPU_COMPOSITE_RAYCAST)||(mode==RM_GPU_MIP_RAYCAST);
75 #endif
76  bool usemip=(mode==RM_GPU_MIP_RAYCAST)||(mode==RM_CPU_MIP_RAYCAST);
77 
78  this->m_node->SetBoolProperty("volumerendering.usegpu",usegpu);
79  // Only with VTK 5.6 or above
80 #if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) ))
81  this->m_node->SetBoolProperty("volumerendering.useray",useray);
82 #endif
83  this->m_node->SetBoolProperty("volumerendering.usemip",usemip);
84 
86 
87  emit this->modeChanged();
88 }
89 
91 {
92  return this->m_rendering;
93 }
94 
96 {
97  return this->m_lod;
98 }
99 
101 {
102  return this->m_mode;
103 }
104 
106 {
107  this->m_enabled = enabled;
108  emit this->enabledChanged();
109 }
110 
112 {
113  return this->m_enabled;
114 }
115 
117 {
118  this->m_node = node;
119 
120  if(!this->m_node)
121  {
122  this->setEnabled(false);
123  emit this->sync();
124  return;
125  }
126 
127  mitk::Image::Pointer image = static_cast<mitk::Image*>(this->m_node->GetData());
128 
129  if(image->GetDimension() == 2)
130  this->setEnabled(false);
131  else
132  this->setEnabled(true);
133 
134  bool use_volumerendering;
135  bool use_lod;
136  bool use_ray;
137  bool use_mip;
138  bool use_gpu;
139 
140  this->m_node->GetBoolProperty("volumerendering", use_volumerendering);
141  this->m_node->GetBoolProperty("volumerendering.uselod", use_lod);
142  this->m_node->GetBoolProperty("volumerendering.useray", use_ray);
143  this->m_node->GetBoolProperty("volumerendering.usemip", use_mip);
144  this->m_node->GetBoolProperty("volumerendering.usegpu", use_gpu);
145 
146  this->setRendering(use_volumerendering);
147  this->setLod(use_lod);
148 
149  int mode = 0;
150 
151  if(use_ray)
152  {
153  if(use_mip)
154  mode=RM_GPU_MIP_RAYCAST;
155  else
157  }
158  else if(use_gpu)
160  else
161  {
162  if(use_mip)
163  mode=RM_CPU_MIP_RAYCAST;
164  else
166  }
167 
168  this->setMode(mode);
169 
170  emit this->sync();
171 }
172 
173 void QmlMitkProperties::create(QQmlEngine &engine)
174 {
175  qmlRegisterType<QmlMitkProperties>("Mitk.Views", 1, 0, "Properties");
176 
177  QQmlComponent component(&engine, QUrl("qrc:/MitkProperties.qml"));
178 }
static QmlMitkTransferFunctionItem * instance
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
void setMode(int mode)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static void create(QQmlEngine &engine)
void notify(mitk::DataNode::Pointer node)
static RenderingManager * GetInstance()
Image class for storing images.
Definition: mitkImage.h:76
void setLod(bool state)
static QmlMitkProperties * instance
void SetBoolProperty(const char *propertyKey, bool boolValue, const mitk::BaseRenderer *renderer=nullptr)
Convenience method for setting boolean properties (instances of BoolProperty)
void setRendering(bool state)
void setEnabled(bool enabled)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)