Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkLesionTreeItem.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 // semantic relations UI module
14 #include "QmitkLesionTreeItem.h"
15 
16 // qt
17 #include <QStringList>
18 
19 QmitkLesionTreeItem::QmitkLesionTreeItem(mitk::LesionData lesionData/* = mitk::LesionTreeItemData()*/)
20 {
21  m_ItemData = lesionData;
22 }
23 
25 {
26  m_ParentItem = parent;
27 }
28 
30 {
31  if (m_ParentItem.expired())
32  {
33  return 0;
34  }
35 
36  auto parentItem = m_ParentItem.lock();
37  return parentItem->GetRowOfChild(this->shared_from_this());
38 }
39 
41 {
42  auto it = std::find(m_Children.begin(), m_Children.end(), child);
43  if (it == m_Children.end())
44  {
45  return -1;
46  }
47  else
48  {
49  return std::distance(m_Children.begin(), it);
50  }
51 }
52 
54 {
55  auto it = std::find(m_Children.begin(), m_Children.end(), child);
56  if (it == m_Children.end())
57  {
58  // child does not already exist; add to vector of children
59  m_Children.push_back(child);
60  // add parent item
61  child->SetParent(this->shared_from_this());
62  }
63 }
64 
66 {
67  auto it = std::find(m_Children.begin(), m_Children.end(), child);
68  if (it != m_Children.end())
69  {
70  m_Children.erase(it);
71  }
72 }
73 
75 {
76  m_ItemData = lesionData;
77 }
std::shared_ptr< const QmitkLesionTreeItem > ChildConstPointer
int GetRow() const
Get the row of this item relative to its parent item using &#39;GetRowOfChild&#39;.
std::weak_ptr< QmitkLesionTreeItem > ParentPointer
void AddChild(ChildPointer child)
Add a new child to the list of children of this item if it is not already a child item...
void SetData(const mitk::LesionData &lesionData)
Set the item data of this item.
int GetRowOfChild(ChildConstPointer child) const
Get the row of the given child item relative to this item.
void RemoveChild(ChildPointer child)
Remove a child from the list of children of this item.
This class holds the data of each lesion in the lesion tree view. The data is the lesion itself with ...
QmitkLesionTreeItem(mitk::LesionData lesionData=mitk::LesionData())
void SetParent(ParentPointer parent)
Set the parent item of this item.
std::shared_ptr< QmitkLesionTreeItem > ChildPointer