13#include "ui_QmitkUSZoneManagementWidget.h"
19#include "usModuleRegistry.h"
22#include "mitkSurface.h"
28m_Interactor(
mitk::USZonesInteractor::New()),
29m_StateMachineFileName(
"USZoneInteractions.xml"),
37 connect(ui->CurrentZonesTable->selectionModel(), SIGNAL(selectionChanged(
const QItemSelection&,
const QItemSelection&)),
39 connect(
m_ZonesDataModel, SIGNAL(rowsInserted(
const QModelIndex&,
int,
int)),
41 connect(
m_ZonesDataModel, SIGNAL(dataChanged(
const QModelIndex&,
const QModelIndex&)),
42 this, SLOT(
OnDataChanged(
const QModelIndex&,
const QModelIndex&)));
59 m_Interactor->LoadStateMachine(filename, us::ModuleRegistry::GetModule(
"MitkUS"));
64 if (dataStorage.IsNull())
66 MITK_ERROR(
"QWidget")(
"QmitkUSZoneManagementWidget")
67 <<
"DataStorage must not be null.";
68 mitkThrow() <<
"DataStorage must not be null.";
71 mitk::DataNode::Pointer baseNode = dataStorage->GetNamedNode(baseNodeName);
72 if (baseNode.IsNull())
74 baseNode = mitk::DataNode::New();
75 baseNode->SetName(baseNodeName);
76 dataStorage->Add(baseNode);
79 baseNode->SetData(mitk::Surface::New());
89 if (dataStorage.IsNull() || baseNode.IsNull())
91 MITK_ERROR(
"QWidget")(
"QmitkUSZoneManagementWidget")
92 <<
"DataStorage and BaseNode must not be null.";
93 mitkThrow() <<
"DataStorage and BaseNode must not be null.";
96 if (!baseNode->GetData()) { baseNode->SetData(mitk::Surface::New()); }
112 MITK_WARN(
"QWidget")(
"QmitkUSZoneManagementWidget")
113 <<
"Data storage or base node is null. Returning empty zone nodes set.";
114 return mitk::DataStorage::SetOfObjects::New().GetPointer();
120 QItemSelectionModel* selectionModel = ui->CurrentZonesTable->selectionModel();
121 if (!selectionModel->hasSelection())
123 MITK_WARN(
"QWidget")(
"QmitkUSZoneManagementWidget")
124 <<
"RemoveSelectedRows() called without any row being selected.";
128 QModelIndexList selectedRows = selectionModel->selectedRows();
131 QListIterator<QModelIndex> i(selectedRows);
133 while (i.hasPrevious())
145 MITK_ERROR(
"QWidget")(
"QmitkUSZoneManagementWidget")
146 <<
"DataStorage must be set before adding the first zone.";
147 mitkThrow() <<
"DataStorage must be set before adding the first zone.";
155 mitk::DataNode::Pointer dataNode = mitk::DataNode::New();
157 dataNode->SetName((QString(
"Zone ") + QString(
"%1").arg(m_CurMaxNumOfZones + 1, 2, 10, QLatin1Char(
'0'))).toStdString());
158 dataNode->SetColor(0.9, 0.9, 0);
167 MITK_ERROR(
"QWidget")(
"QmitkUSZoneManagementWidget")
168 <<
"DataStorage must be set before aborting adding a zone.";
169 mitkThrow() <<
"DataStorage must be set before aborting adding a zone.";
183 m_CurMaxNumOfZones = 0;
189 ui->ZoneSizeLabel->setEnabled(somethingSelected);
190 ui->ZoneSizeSlider->setEnabled(somethingSelected);
191 ui->DeleteZoneButton->setEnabled(somethingSelected);
193 if (somethingSelected)
195 ui->ZoneSizeSlider->setValue(
202 QItemSelectionModel* selection = ui->CurrentZonesTable->selectionModel();
203 if (!selection->hasSelection()) {
return; }
211 m_CurMaxNumOfZones++;
213 ui->CurrentZonesTable->selectRow(end);
219 QItemSelectionModel* selection = ui->CurrentZonesTable->selectionModel();
220 if (!selection->hasSelection() || selection->selectedRows().size() < 1) {
return; }
222 if (selection->selectedRows().at(0) == topLeft)
224 ui->ZoneSizeSlider->setValue(
QStyledItemDelegate that provides a QColorDialog as editor.
Implementation of the QAbstractTableModel for ultrasound risk zones. This class manages the data mode...
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Return model data of the selected cell.
void SetDataStorage(mitk::DataStorage::Pointer dataStorage, mitk::DataNode::Pointer baseNode)
Set data storage and base node for the zone nodes of this model. The node event listeners will only r...
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Set model data for the selected cell.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Return number of rows of the model.