20 : QAbstractTableModel(parent),
21 m_showAbsoluteDose(false),
22 m_visibilityEditOnly(false),
23 m_referenceDose(
mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE),
35 emit beginResetModel();
53 return m_DoseSet->Size();
68 data(
const QModelIndex &index,
int role)
const 75 if (static_cast<unsigned int>(index.row()) < m_DoseSet->Size())
77 const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
79 switch(index.column())
82 if(role == Qt::EditRole || role == Qt::DecorationRole)
86 result = QVariant(color);
88 else if (role == Qt::ToolTipRole)
90 result = QVariant(
"Color of the iso dose level.");
94 if(role == Qt::DisplayRole)
96 if (this->m_showAbsoluteDose)
98 result = QVariant(QString::number(level.
GetDoseValue()*this->m_referenceDose)+QString(
" Gy"));
102 result = QVariant(QString::number(level.
GetDoseValue()*100)+QString(
" %"));
105 else if(role == Qt::EditRole)
107 if (this->m_showAbsoluteDose)
109 result = QVariant(level.
GetDoseValue()*this->m_referenceDose);
116 else if (role == Qt::ToolTipRole)
118 result = QVariant(
"Minimum dose value of this level / Value of the iso line.");
120 else if (role == Qt::UserRole+1)
122 result = QVariant(this->m_showAbsoluteDose);
126 if(role == Qt::DisplayRole || role == Qt::EditRole)
130 else if (role == Qt::ToolTipRole)
132 result = QVariant(
"Show isoline for this dose level.");
136 if(role == Qt::DisplayRole || role == Qt::EditRole)
140 else if (role == Qt::ToolTipRole)
142 result = QVariant(
"Show colorwash for this dose level.");
153 flags(
const QModelIndex &index)
const 155 Qt::ItemFlags
flags = QAbstractItemModel::flags(index);
157 if (static_cast<unsigned int>(index.row()) < m_DoseSet->Size())
159 if (index.column() < 4)
161 if ((index.column() > 1) || (index.column() >= 0 && !this->m_visibilityEditOnly))
163 flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
165 else if (index.column() >= 0 && this->m_visibilityEditOnly)
167 flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
177 headerData(
int section, Qt::Orientation orientation,
int role)
const 179 if( (Qt::DisplayRole == role) &&
180 (Qt::Horizontal == orientation))
184 return QVariant(
"Color");
188 if (m_showAbsoluteDose)
190 return QVariant(
"Dose [Gy]");
194 return QVariant(
"Dose [%]");
199 return QVariant(
"IsoLines");
203 return QVariant(
"ColorWash");
211 setData(
const QModelIndex &index,
const QVariant &value,
int role)
213 if(!index.isValid() || (m_DoseSet->Size() <=
static_cast<unsigned int>(index.row())) || (index.column()>3))
218 if(Qt::EditRole == role)
220 const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
221 mitk::IsoDoseLevel::Pointer pNewLevel = level.Clone();
222 switch(index.column())
226 QColor val = value.value<QColor>();
228 color.SetRed(val.redF());
229 color.SetGreen(val.greenF());
230 color.SetBlue(val.blueF());
232 emit dataChanged(index,index);
236 if (this->m_showAbsoluteDose)
238 pNewLevel->SetDoseValue(value.toDouble()/this->m_referenceDose);
242 pNewLevel->SetDoseValue(value.toDouble()/100.0);
244 emit dataChanged(index,index);
247 pNewLevel->SetVisibleIsoLine(value.toBool());
248 emit dataChanged(index,index);
251 pNewLevel->SetVisibleColorWash(value.toBool());
252 emit dataChanged(index,index);
256 emit beginResetModel();
258 m_DoseSet->DeleteIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
259 m_DoseSet->SetIsoDoseLevel(pNewLevel);
263 emit endResetModel();
274 if (newReferenceDose<= 0)
276 mitkThrow() <<
"Error. Passed prescribed dose is negative or equals 0.";
279 if (newReferenceDose != m_referenceDose)
281 this->m_referenceDose = newReferenceDose;
282 if(m_showAbsoluteDose)
284 emit beginResetModel();
285 emit endResetModel();
294 if (showAbsoluteDose != m_showAbsoluteDose)
296 emit beginResetModel();
297 this->m_showAbsoluteDose = showAbsoluteDose;
298 emit endResetModel();
304 if (onlyVisibility != m_visibilityEditOnly)
306 emit beginResetModel();
307 this->m_visibilityEditOnly = onlyVisibility;
308 emit endResetModel();
316 return this->m_showAbsoluteDose;
323 return this->m_referenceDose;
330 return this->m_visibilityEditOnly;
335 emit beginResetModel();
339 mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone();
340 pNewLevel->SetVisibleIsoLine(activate);
341 m_DoseSet->SetIsoDoseLevel(pNewLevel);
346 emit endResetModel();
351 emit beginResetModel();
355 mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone();
356 pNewLevel->SetVisibleColorWash(activate);
357 m_DoseSet->SetIsoDoseLevel(pNewLevel);
362 emit endResetModel();
367 emit beginResetModel();
371 mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone();
372 pNewLevel->SetVisibleIsoLine(!pNewLevel->GetVisibleIsoLine());
373 m_DoseSet->SetIsoDoseLevel(pNewLevel);
378 emit endResetModel();
383 emit beginResetModel();
387 mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone();
388 pNewLevel->SetVisibleColorWash(!pNewLevel->GetVisibleColorWash());
389 m_DoseSet->SetIsoDoseLevel(pNewLevel);
394 emit endResetModel();
399 emit beginResetModel();
403 mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone();
404 bool colorWash = pNewLevel->GetVisibleColorWash();
405 pNewLevel->SetVisibleColorWash(pNewLevel->GetVisibleIsoLine());
406 pNewLevel->SetVisibleIsoLine(colorWash);
407 m_DoseSet->SetIsoDoseLevel(pNewLevel);
412 emit endResetModel();
419 if (m_DoseSet->Size()>0)
421 doseVal = m_DoseSet->GetIsoDoseLevel(m_DoseSet->Size()-1).GetDoseValue()+0.01;
426 emit beginResetModel();
427 m_DoseSet->SetIsoDoseLevel(pNewLevel);
429 emit endResetModel();
434 if(!index.isValid() || (m_DoseSet->Size() <=
static_cast<unsigned int>(index.row())) || (index.column()>3))
439 emit beginResetModel();
440 m_DoseSet->DeleteIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
442 emit endResetModel();
QVariant data(const QModelIndex &index, int role) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
void invertVisibilityIsoLines()
Stores values needed for the representation/visualization of dose iso levels.
virtual ColorType GetColor() const
bool getShowAbsoluteDose() const
void deleteLevel(const QModelIndex &index)
size_type IsoLevelIndexType
virtual void SetColor(ColorType _arg)
void invertVisibilityColorWash()
mitk::DoseValueAbs getReferenceDose() const
virtual DoseValueType GetDoseValue() const
DataCollection - Class to facilitate loading/accessing structured data.
void setShowAbsoluteDose(bool showAbsoluteDose)
Slot that can be used to adjust whether the dose should be displayed in absolute or relative units...
Qt::ItemFlags flags(const QModelIndex &index) const override
virtual bool GetVisibleIsoLine() const
void setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet)
Stores values needed for the representation/visualization of dose iso levels.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setReferenceDose(double newReferenceDose)
Slot that can be used to set the prescribed dose.
virtual bool GetVisibleColorWash() const
bool getVisibilityEditOnly() const
void switchVisibilityIsoLines(bool activate)
void switchVisibilityColorWash(bool activate)
::itk::RGBPixel< float > ColorType
DoseValueRel DoseValueType
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
double DoseValueAbs
Represents absolute dose values (in Gy).
void setVisibilityEditOnly(bool onlyVisibility)
Slat that can be used to adjust wether the model allows to edit only visibilities (no dose value or c...
QmitkIsoDoseLevelSetModel(QObject *parent=nullptr)