Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkImageStatisticsTreeItem.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 
14 
16  ImageStatisticsObject statisticsData,
17  StatisticNameVector statisticNames,
18  QVariant label,
20  : m_statistics(statisticsData) , m_statisticNames(statisticNames), m_label(label), m_parentItem(parent)
21 {
22 }
23 
25  QVariant label,
27  : QmitkImageStatisticsTreeItem(ImageStatisticsObject(), statisticNames, label, parentItem )
28 {
29 }
30 
32 
34 {
35  qDeleteAll(m_childItems);
36 }
37 
39 {
40  m_childItems.append(item);
41 }
42 
44 {
45  return m_childItems.value(row);
46 }
47 
49 {
50  return m_childItems.count();
51 }
52 
54 {
55  return m_statisticNames.size() + 1;
56 }
57 
58 QVariant QmitkImageStatisticsTreeItem::data(int column) const
59 {
60  QVariant result;
61  if (column > 0 && !m_statisticNames.empty())
62  {
63  if (column - 1 < static_cast<int>(m_statisticNames.size()))
64  {
65  auto statisticKey = m_statisticNames.at(column - 1);
66  std::stringstream ss;
67  if (m_statistics.HasStatistic(statisticKey))
68  {
69  ss << m_statistics.GetValueNonConverted(statisticKey);
70  }
71  else
72  {
73  return QVariant();
74  }
75  result = QVariant(QString::fromStdString(ss.str()));
76  }
77  else
78  {
79  return QVariant();
80  }
81  }
82  else if (column == 0)
83  {
84  result = m_label;
85  }
86  return result;
87 }
88 
90 {
91  return m_parentItem;
92 }
93 
95 {
96  if (m_parentItem)
97  return m_parentItem->m_childItems.indexOf(const_cast<QmitkImageStatisticsTreeItem *>(this));
98 
99  return 0;
100 }
QmitkImageStatisticsTreeItem * parentItem()
QmitkImageStatisticsTreeItem * child(int row)
void appendChild(QmitkImageStatisticsTreeItem *child)
mitk::ImageStatisticsContainer::ImageStatisticsObject::StatisticNameVector StatisticNameVector
Container class for storing the computed image statistics.
StatisticsVariantType GetValueNonConverted(const std::string &name) const
Returns the requested value.