37 , m_SelectedNodeType(
"Image")
39 m_HeaderModel =
new QStandardItemModel(
this);
49 if (hasIndex(row, column, parent))
51 return createIndex(row, column);
69 return m_InformationTypes.size();
79 return m_ExaminationPeriods.size();
87 return QVariant::fromValue<QStandardItemModel*>(m_HeaderModel);
95 if (index.row() < 0 || index.row() >=
static_cast<int>(m_InformationTypes.size())
96 || index.column() < 0 || index.column() >=
static_cast<int>(m_ExaminationPeriods.size()))
103 if (Qt::DecorationRole == role)
105 auto it = m_PixmapMap.find(dataNode);
106 if (it != m_PixmapMap.end())
108 return QVariant(it->second);
111 auto emptyPixmap = QPixmap(120, 120);
112 emptyPixmap.fill(Qt::transparent);
116 if (Qt::BackgroundColorRole == role)
118 auto it = m_LesionPresence.find(dataNode);
119 if (it != m_LesionPresence.end())
121 return it->second ? QVariant(QColor(Qt::darkGreen)) : QVariant(QColor(Qt::transparent));
124 return QVariant(QColor(Qt::transparent));
134 return QVariant::fromValue<mitk::DataNode*>(dataNode);
142 if (Qt::Vertical == orientation && Qt::DisplayRole == role)
144 if (static_cast<int>(m_InformationTypes.size()) > section)
147 return QVariant(QString::fromStdString(currentInformationType));
158 if (
nullptr != dataNode)
160 flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
168 m_SelectedNodeType = nodeType;
186 std::string examinationPeriodName =
"Baseline";
187 for (
size_t i = 0; i < m_ExaminationPeriods.size(); ++i)
189 auto& examinationPeriod = m_ExaminationPeriods.at(i);
190 examinationPeriod.name = examinationPeriodName;
192 examinationPeriodName =
"Follow-up " + std::to_string(i);
198 if (
"Image" == m_SelectedNodeType)
202 else if (
"Segmentation" == m_SelectedNodeType)
209 SetLesionPresences();
212 void QmitkPatientTableModel::SetHeaderModel()
214 m_HeaderModel->clear();
215 QStandardItem* rootItem =
new QStandardItem(
"Timeline");
216 QList<QStandardItem*> standardItems;
218 for (
const auto& examinationPeriod : m_ExaminationPeriods)
220 QStandardItem* examinationPeriodItem =
new QStandardItem(QString::fromStdString(examinationPeriod.name));
221 standardItems.push_back(examinationPeriodItem);
222 rootItem->appendColumn(standardItems);
223 standardItems.clear();
226 m_HeaderModel->setItem(0, 0, rootItem);
229 void QmitkPatientTableModel::SetPixmaps()
232 for (
const auto& dataNode : m_CurrentDataNodes)
236 SetPixmapOfNode(dataNode, &pixmapFromImage);
240 void QmitkPatientTableModel::SetPixmapOfNode(
const mitk::DataNode* dataNode, QPixmap* pixmapFromImage)
242 if (
nullptr == dataNode)
247 std::map<mitk::DataNode::ConstPointer, QPixmap>::iterator iter = m_PixmapMap.find(dataNode);
248 if (iter != m_PixmapMap.end())
251 if (
nullptr != pixmapFromImage)
254 iter->second = pixmapFromImage->scaled(120, 120, Qt::IgnoreAspectRatio);
259 m_PixmapMap.erase(iter);
264 m_PixmapMap.insert(std::make_pair(dataNode, pixmapFromImage->scaled(120, 120, Qt::IgnoreAspectRatio)));
268 void QmitkPatientTableModel::SetLesionPresences()
270 m_LesionPresence.clear();
276 for (
const auto& dataNode : m_CurrentDataNodes)
285 SetLesionPresenceOfNode(dataNode, lesionPresence);
289 void QmitkPatientTableModel::SetLesionPresenceOfNode(
const mitk::DataNode* dataNode,
bool lesionPresence)
291 std::map<mitk::DataNode::ConstPointer, bool>::iterator iter = m_LesionPresence.find(dataNode);
292 if (iter != m_LesionPresence.end())
295 iter->second = lesionPresence;
299 m_LesionPresence.insert(std::make_pair(dataNode, lesionPresence));
305 if (!index.isValid())
310 auto examinationPeriod = m_ExaminationPeriods.at(index.column());
311 auto currentInformationType = m_InformationTypes.at(index.row());
312 auto controlPointsOfExaminationPeriod = examinationPeriod.controlPointUIDs;
313 for (
const auto& controlPointUID : controlPointsOfExaminationPeriod)
318 std::vector<mitk::DataNode::Pointer> filteredDataNodes;
319 if (
"Image" == m_SelectedNodeType)
323 else if (
"Segmentation" == m_SelectedNodeType)
328 if (filteredDataNodes.empty())
336 return filteredDataNodes.front();
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 ...
void NodePredicateChanged() override
QmitkPatientTableModel(QObject *parent=nullptr)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::InformationTypeVector GetAllInformationTypesOfCase(const SemanticTypes::CaseID &caseID)
void SetNodeType(const std::string &nodeType)
end override
itk::SmartPointer< Self > Pointer
MITKSEMANTICRELATIONS_EXPORT void RenameExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ExaminationPeriod &examinationPeriod)
std::unique_ptr< mitk::SemanticRelationsDataStorageAccess > m_SemanticRelationsDataStorageAccess
void SetData() override
Overridden from 'QmitkAbstractSemanticRelationsStorageModel': This function retrieves all control poi...
mitk::SemanticTypes::Lesion m_Lesion
QModelIndex parent(const QModelIndex &child) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
MITKSEMANTICRELATIONSUI_EXPORT QPixmap GetPixmapFromImageNode(const mitk::DataNode *dataNode)
~QmitkPatientTableModel() override
std::string InformationType
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ExaminationPeriodVector GetAllExaminationPeriodsOfCase(const SemanticTypes::CaseID &caseID)
Qt::ItemFlags flags(const QModelIndex &index) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPoint GetControlPointByUID(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &controlPointUID)
Find and return a whole control point including its date given a specific control point UID...
mitk::SemanticTypes::CaseID m_CaseID
Class for nodes of the DataTree.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
MITKSEMANTICRELATIONS_EXPORT void SortAllExaminationPeriods(const SemanticTypes::CaseID &caseID, SemanticTypes::ExaminationPeriodVector &allExaminationPeriods)
Sort the given vector of examination periods. Each examination period has a vector of control point U...
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 ...