29 , m_LastSegmentation(nullptr)
40 if (!hasIndex(row, column, itemIndex))
45 auto childItem = GetItemByIndex(itemIndex)->
GetChildInRow(row);
46 if (
nullptr == childItem)
51 return createIndex(row, column, childItem.get());
56 if (!itemIndex.isValid())
61 auto parentItem = GetItemByIndex(itemIndex)->
GetParent();
62 if (parentItem.expired())
67 auto sharedParent = parentItem.lock();
68 if (sharedParent == m_RootItem)
73 return createIndex(sharedParent->GetRow(), 0, sharedParent.get());
78 return GetItemByIndex(itemIndex)->
ChildCount();
83 if (0 == m_RootItem->ChildCount())
89 return m_ControlPoints.size() + 1;
99 if (index.column() < 0 || index.column() >
static_cast<int>(m_ControlPoints.size()))
105 if (Qt::DisplayRole == role)
112 auto parentItem = currentItem->
GetParent().lock();
114 if (m_RootItem == parentItem)
117 if (0 == index.column())
120 if (itemString.empty())
124 return QString::fromStdString(itemString);
130 if (index.column() - 1 >
static_cast<int>(lesionPresence.size()))
135 if (lesionPresence.at(index.column() - 1))
137 return QString::fromStdString(
"present");
140 return QString::fromStdString(
"not present");
145 if (Qt::BackgroundColorRole == role)
148 if (it != m_DataNodePresence.end())
150 return it->second ? QVariant(QColor(Qt::darkGreen)) : QVariant(QColor(Qt::transparent));
153 return QVariant(QColor(Qt::transparent));
156 if (Qt::UserRole == role)
158 return QVariant::fromValue(currentItem);
166 if (0 == m_RootItem->ChildCount())
172 if (Qt::Horizontal == orientation && Qt::DisplayRole == role)
176 return QVariant(
"Lesion");
179 if (static_cast<int>(m_ControlPoints.size()) >= section)
182 return QVariant(QString::fromStdString(currentControlPoint.
ToString()));
191 return m_LastSegmentation;
198 m_LastSegmentation = dataNode;
209 std::sort(m_ControlPoints.begin(), m_ControlPoints.end());
212 SetSelectedDataNodesPresence();
215 void QmitkLesionTreeModel::SetLesionData()
218 for (
auto& lesion : m_CurrentLesions)
238 std::shared_ptr<QmitkLesionTreeItem> newLesionTreeItem = std::make_shared<QmitkLesionTreeItem>(lesionData);
239 m_RootItem->AddChild(newLesionTreeItem);
242 void QmitkLesionTreeModel::SetSelectedDataNodesPresence()
244 m_DataNodePresence.clear();
252 for (
const auto& lesion : m_CurrentLesions)
262 SetDataNodePresenceOfLesion(&lesion, dataNodePresence);
274 std::map<mitk::SemanticTypes::ID, bool>::iterator iter = m_DataNodePresence.find(lesion->
UID);
275 if (iter != m_DataNodePresence.end())
278 iter->second = dataNodePresence;
282 m_DataNodePresence.insert(std::make_pair(lesion->
UID, dataNodePresence));
297 return m_RootItem.get();
QmitkLesionTreeModel(QObject *parent=nullptr)
Initialize the root item of the model. The root item does not have a parent item. ...
int columnCount(const QModelIndex &itemIndex=QModelIndex()) const override
int rowCount(const QModelIndex &itemIndex=QModelIndex()) const override
MITKSEMANTICRELATIONS_EXPORT void ComputeLesionPresence(LesionData &lesionData, const SemanticTypes::CaseID &caseID)
Compute and store lesion presence for all available control points and information types...
MITKSEMANTICRELATIONS_EXPORT bool IsLesionPresent(const SemanticTypes::Lesion &lesion, const DataNode *dataNode)
Check if the given lesion is present on the given data node. The function receives the case- and the ...
itk::SmartPointer< T > Lock() const
std::string GetLesionName() const
mitk::LesionData & GetData()
Return the item data, which contains ...
QList< mitk::DataNode::Pointer > m_SelectedDataNodes
void NodeAdded(const mitk::DataNode *) override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
DataCollection - Class to facilitate loading/accessing structured data.
QModelIndex index(int row, int column, const QModelIndex &itemIndex=QModelIndex()) const override
SemanticTypes::Lesion GetLesion() const
MITKSEMANTICRELATIONS_EXPORT NodePredicateAnd::Pointer GetSegmentationPredicate()
ChildPointer GetChildInRow(int row) const
Return the child of this item at a specific position.
ParentPointer GetParent() const
Return the parent item.
bool IsExpired() const noexcept
void SetData() override
Overridden from 'QmitkAbstractSemanticRelationsStorageModel': This function retrieves all control poi...
This class holds the data of each lesion in the lesion tree view. The data is the lesion itself with ...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionVector GetAllLesionsOfCase(const SemanticTypes::CaseID &caseID)
SemanticTypes::ID GetLesionUID() const
std::string ToString() const
QModelIndex parent(const QModelIndex &itemIndex) const override
const mitk::DataNode * GetLastSegmentation() const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
const std::vector< bool > & GetLesionPresence() const
vcl_size_t ChildCount() const
Return the number of child items.
mitk::SemanticTypes::CaseID m_CaseID
Class for nodes of the DataTree.
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfCase(const SemanticTypes::CaseID &caseID)
MITKSEMANTICRELATIONS_EXPORT bool InstanceExists(const DataNode *dataNode)
Check if the given data node exists in the relation storage. The function receives the case- and the ...