diff --git a/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsTableModel.cpp b/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsTableModel.cpp index e4e0d20c45..435ff2869c 100644 --- a/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsTableModel.cpp +++ b/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsTableModel.cpp @@ -1,151 +1,155 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkImageStatisticsTableModel.h" QmitkImageStatisticsTableModel::QmitkImageStatisticsTableModel(QObject *parent) : QAbstractTableModel(parent) {} int QmitkImageStatisticsTableModel::rowCount(const QModelIndex &parent) const { if (parent.isValid()) { return 0; } if (!m_statistics.empty()){ return static_cast(m_statistics.front()->GetStatisticsAsOrderedVector().size()); } else { return 0; } } int QmitkImageStatisticsTableModel::columnCount(const QModelIndex &parent) const { if (parent.isValid()) return 0; return static_cast(m_statistics.size()); } QVariant QmitkImageStatisticsTableModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); QVariant result; if (m_viewMode == viewMode::imageXStatistic) { if (!m_statistics.empty() && index.row() < m_statistics.front()->GetStatisticsAsMap().size() && index.column() < m_statistics.size()) { if (Qt::DisplayRole == role) { result = QVariant(m_statistics.at(index.column())->GetStatisticsAsOrderedVector().at(index.row()).second); } else if (Qt::UserRole == role) { result = QVariant(index.row()); } } } return result; } Qt::ItemFlags QmitkImageStatisticsTableModel::flags(const QModelIndex &index) const { Qt::ItemFlags flags = QAbstractItemModel::flags(index); return flags; } QVariant QmitkImageStatisticsTableModel::headerData(int section, Qt::Orientation orientation, int role) const { if ((Qt::DisplayRole == role) && (Qt::Horizontal == orientation)) { if (!m_imageNodes.empty()) { if (m_viewMode == viewMode::imageXStatistic) { - return QVariant(m_imageNodes.at(section)->GetName().c_str()); + std::string maskName; + if (!m_maskNodes.empty() && m_maskNodes.size() == m_imageNodes.size()) { + maskName = " / " + m_maskNodes.at(section)->GetName(); + } + return QVariant((m_imageNodes.at(section)->GetName() + maskName).c_str()); } } } else if ((Qt::DisplayRole == role) && (Qt::Vertical == orientation)){ if (!m_statistics.empty()) { if (m_viewMode == viewMode::imageXStatistic) { return QVariant(m_statisticNames.at(section).c_str()); } } } return QVariant(); } void QmitkImageStatisticsTableModel::SetStatistics(const std::vector& statistics) { emit beginResetModel(); m_statistics = statistics; if (m_statisticNames.empty() && !statistics.empty()) { auto firstStatisticAsMap = statistics.front()->GetStatisticsAsOrderedVector(); for (const auto& keyValue : firstStatisticAsMap) { m_statisticNames.push_back(keyValue.first); } } emit endResetModel(); emit dataChanged(QModelIndex(), QModelIndex()); } void QmitkImageStatisticsTableModel::SetImageNodes(const std::vector& nodes) { m_imageNodes = nodes; } void QmitkImageStatisticsTableModel::SetMaskNodes(const std::vector& nodes) { m_maskNodes = nodes; } void QmitkImageStatisticsTableModel::SetViewMode(viewMode m) { m_viewMode = m; } void QmitkImageStatisticsTableModel::SetStatisticsToShow(const std::vector& statisticNames) { m_statisticNamesToShow = statisticNames; } void QmitkImageStatisticsTableModel::SetStatisticsToIgnore(const std::vector& statisticNames) { m_statisticNamesToIgnore = statisticNames; } void QmitkImageStatisticsTableModel::Clear() { emit beginResetModel(); m_statistics.clear(); m_imageNodes.clear(); m_maskNodes.clear(); m_statisticNamesToIgnore.clear(); m_statisticNamesToShow.clear(); m_statisticNames.clear(); emit endResetModel(); emit dataChanged(QModelIndex(), QModelIndex()); } diff --git a/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsWidget.cpp b/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsWidget.cpp index a47ae1185f..fccfc2a93b 100644 --- a/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsWidget.cpp +++ b/Modules/ImageStatisticsUI/Qmitk/QmitkImageStatisticsWidget.cpp @@ -1,84 +1,82 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkImageStatisticsWidget.h" #include QmitkImageStatisticsWidget::QmitkImageStatisticsWidget(QWidget* parent) : QWidget(parent) { m_Controls.setupUi(this); m_imageStatisticsModel = new QmitkImageStatisticsTableModel(parent); m_Controls.checkBox4dCompleteTable->setVisible(false); CreateConnections(); } void QmitkImageStatisticsWidget::SetStatistics(const std::vector& sc) { m_imageStatisticsModel->SetStatistics(sc); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(m_imageStatisticsModel); m_Controls.tableViewStatistics->setModel(proxyModel); m_Controls.tableViewStatistics->resizeColumnsToContents(); m_Controls.tableViewStatistics->resizeRowsToContents(); - m_Controls.tableViewStatistics->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); - m_Controls.tableViewStatistics->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); EnableAllGUIElements(); } void QmitkImageStatisticsWidget::SetImageNodes(const std::vector& nodes) { m_imageStatisticsModel->SetImageNodes(nodes); } void QmitkImageStatisticsWidget::SetMaskNodes(const std::vector& nodes) { m_imageStatisticsModel->SetMaskNodes(nodes); } void QmitkImageStatisticsWidget::Reset() { DisableAllGUIElements(); m_imageStatisticsModel->Clear(); } void QmitkImageStatisticsWidget::CreateConnections() { connect(m_Controls.buttonCopyImageStatisticsToClipboard, &QPushButton::clicked, this, &QmitkImageStatisticsWidget::OnClipboardButtonClicked); } void QmitkImageStatisticsWidget::EnableAllGUIElements() { this->setEnabled(true); //temporarily disabled because clipboard functionality is not implemented yet //m_Controls.buttonCopyImageStatisticsToClipboard->setEnabled(true); //m_Controls.checkBox4dCompleteTable->setEnabled(true); m_Controls.tableViewStatistics->setEnabled(true); m_Controls.groupBoxStatistics->setEnabled(true); } void QmitkImageStatisticsWidget::DisableAllGUIElements() { this->setEnabled(false); m_Controls.buttonCopyImageStatisticsToClipboard->setEnabled(false); m_Controls.checkBox4dCompleteTable->setEnabled(false); m_Controls.tableViewStatistics->setEnabled(false); m_Controls.groupBoxStatistics->setEnabled(false); } void QmitkImageStatisticsWidget::OnClipboardButtonClicked() { }