Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkLesionTreeItem.h
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 #ifndef QMITKLESIONTREEITEM_H
14 #define QMITKLESIONTREEITEM_H
15 
16 // mitk semantic relations UI
17 #include "mitkLesionData.h"
18 
19 // mitk semantic relations
20 #include <mitkSemanticTypes.h>
21 
22 // qt
23 #include <QVariant>
24 
25 // c++
26 #include <memory>
27 #include <vector>
28 
29 /*
30 * @brief This class is used by custom tree models to create their tree items.
31 * It provides functions to traverse and modify the tree.
32 * Additionally it holds some 'LesionData' that is used to display lesion properties inside a tree view.
33 */
34 class QmitkLesionTreeItem : public std::enable_shared_from_this<QmitkLesionTreeItem>
35 {
36 public:
37 
38  using ChildPointer = std::shared_ptr<QmitkLesionTreeItem>;
39  using ChildConstPointer = std::shared_ptr<const QmitkLesionTreeItem>;
40  using ParentPointer = std::weak_ptr<QmitkLesionTreeItem>;
41 
43 
51  ChildPointer GetChildInRow(int row) const { return m_Children.at(row); };
57  ParentPointer GetParent() const { return m_ParentItem; };
63  void SetParent(ParentPointer parent);
69  mitk::LesionData& GetData() { return m_ItemData; };
75  int GetRow() const;
83  int GetRowOfChild(ChildConstPointer child) const;
89  size_t ChildCount() const { return m_Children.size(); };
95  void AddChild(ChildPointer child);
101  void RemoveChild(ChildPointer child);
107  void SetData(const mitk::LesionData& lesionData);
108 
109 private:
110 
111  ParentPointer m_ParentItem;
112  std::vector<ChildPointer> m_Children;
113  mitk::LesionData m_ItemData;
114 
115 };
116 
117 Q_DECLARE_METATYPE(QmitkLesionTreeItem)
118 Q_DECLARE_METATYPE(QmitkLesionTreeItem*)
119 
120 #endif // QMITKLESIONTREEITEM_H
std::shared_ptr< const QmitkLesionTreeItem > ChildConstPointer
int GetRow() const
Get the row of this item relative to its parent item using &#39;GetRowOfChild&#39;.
mitk::LesionData & GetData()
Return the item data, which contains ...
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.
ChildPointer GetChildInRow(int row) const
Return the child of this item at a specific position.
int GetRowOfChild(ChildConstPointer child) const
Get the row of the given child item relative to this item.
ParentPointer GetParent() const
Return the parent 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.
vcl_size_t ChildCount() const
Return the number of child items.
std::shared_ptr< QmitkLesionTreeItem > ChildPointer