Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmlMitkDatamanager.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 "QmlMitkDatamanager.h"
18 
19 #include <mitkImage.h>
20 #include <mitkNodePredicateNot.h>
22 
23 #include <QQmlEngine>
24 #include <QQmlContext>
25 
26 #include <QmlMitkProperties.h>
28 
30 QmitkDataStorageListModel* QmlMitkDatamanager::model = nullptr;
31 mitk::DataStorage::Pointer QmlMitkDatamanager::storage = nullptr;
32 
34 {
35  instance = this;
36 }
37 
39 {
40 }
41 
43 {
44  QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index);
45  mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex);
46  node->SetVisibility(checked);
47 
49 }
50 
52 {
53  this->m_index = index;
54 
55  if(index >= 0)
56  {
57  QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index);
58  mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex);
59 
60  if(dynamic_cast<mitk::Image*>(node->GetData()) && dynamic_cast<mitk::Image*>(node->GetData())->GetDimension()>=3 )
61  {
64  }
65  else
66  {
69  }
70  }
71  else
72  {
75  }
76 
77  emit this->indexChanged();
78 }
79 
81 {
82  return this->m_index;
83 }
84 
86 {
87  QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index);
88  mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex);
89 
90  mitk::BaseData::Pointer basedata = node->GetData();
91  if ( basedata.IsNotNull() &&
92  basedata->GetTimeGeometry()->IsValid() )
93  {
95  }
96 }
97 
99 {
101 }
102 
104 {
105  QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index);
106  mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex);
107 
108  QmlMitkDatamanager::storage->Remove(node);
109  this->globalReinit();
110 }
111 
113 {
114  qmlRegisterType<QmlMitkDatamanager>("Mitk.Views", 1, 0, "DataManager");
115 
117 
118  QmlMitkDatamanager::storage = storage;
119  QmlMitkDatamanager::model = new QmitkDataStorageListModel(storage, filter);
120 
121  QQmlContext* context = engine.rootContext();
122  context->setContextProperty("dataStorage", QmlMitkDatamanager::model);
123 
124  QQmlComponent component(&engine, QUrl("qrc:/views/MitkDataManager.qml"));
125 }
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
void toggleVisibility(bool checked)
static void create(QQmlEngine &engine, mitk::DataStorage::Pointer storage)
void setIndex(int index)
static QmlMitkTransferFunctionItem * instance
void notify(mitk::DataNode::Pointer node)
static QmlMitkDatamanager * instance
static Pointer New()
static RenderingManager * GetInstance()
static Pointer New(const mitk::NodePredicateBase *_arg)
static QmlMitkProperties * instance
static Pointer New(const char *_arg)
void setEnabled(bool enabled)
mitk::DataNode::Pointer getNode(const QModelIndex &index) const
Return the node for given model index.
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
void SetDataNode(mitk::DataNode *node, const mitk::BaseRenderer *renderer=nullptr)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)