24 : QAbstractTableModel(parent),
25 m_showAbsoluteDose(false),
26 m_visibilityEditOnly(false),
27 m_referenceDose(
mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE),
39 emit beginResetModel();
57 return m_DoseSet->Size();
72 data(
const QModelIndex &index,
int role)
const
79 if (static_cast<unsigned int>(index.row()) < m_DoseSet->Size())
81 const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
83 switch(index.column())
86 if(role == Qt::EditRole || role == Qt::DecorationRole)
90 result = QVariant(color);
92 else if (role == Qt::ToolTipRole)
94 result = QVariant(
"Color of the iso dose level.");
98 if(role == Qt::DisplayRole)
100 if (this->m_showAbsoluteDose)
102 result = QVariant(QString::number(level.
GetDoseValue()*this->m_referenceDose)+QString(
" Gy"));
106 result = QVariant(QString::number(level.
GetDoseValue()*100)+QString(
" %"));
109 else if(role == Qt::EditRole)
111 if (this->m_showAbsoluteDose)
113 result = QVariant(level.
GetDoseValue()*this->m_referenceDose);
120 else if (role == Qt::ToolTipRole)
122 result = QVariant(
"Minimum dose value of this level / Value of the iso line.");
124 else if (role == Qt::UserRole+1)
126 result = QVariant(this->m_showAbsoluteDose);
130 if(role == Qt::DisplayRole || role == Qt::EditRole)
134 else if (role == Qt::ToolTipRole)
136 result = QVariant(
"Show isoline for this dose level.");
140 if(role == Qt::DisplayRole || role == Qt::EditRole)
144 else if (role == Qt::ToolTipRole)
146 result = QVariant(
"Show colorwash for this dose level.");
157 flags(
const QModelIndex &index)
const
159 Qt::ItemFlags
flags = QAbstractItemModel::flags(index);
161 if (static_cast<unsigned int>(index.row()) < m_DoseSet->Size())
163 if (index.column() < 4)
165 if ((index.column() > 1) || (index.column() >= 0 && !this->m_visibilityEditOnly))
167 flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
169 else if (index.column() >= 0 && this->m_visibilityEditOnly)
171 flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
181 headerData(
int section, Qt::Orientation orientation,
int role)
const
183 if( (Qt::DisplayRole == role) &&
184 (Qt::Horizontal == orientation))
188 return QVariant(
"Color");
192 if (m_showAbsoluteDose)
194 return QVariant(
"Dose [Gy]");
198 return QVariant(
"Dose [%]");
203 return QVariant(
"IsoLines");
207 return QVariant(
"ColorWash");
215 setData(
const QModelIndex &index,
const QVariant &value,
int role)
217 if(!index.isValid() || (m_DoseSet->Size() <=
static_cast<unsigned int>(index.row())) || (index.column()>3))
222 if(Qt::EditRole == role)
224 const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
226 switch(index.column())
230 QColor val = value.value<QColor>();
232 color.SetRed(val.redF());
233 color.SetGreen(val.greenF());
234 color.SetBlue(val.blueF());
236 emit dataChanged(index,index);
240 if (this->m_showAbsoluteDose)
242 pNewLevel->SetDoseValue(value.toDouble()/this->m_referenceDose);
246 pNewLevel->SetDoseValue(value.toDouble()/100.0);
248 emit dataChanged(index,index);
251 pNewLevel->SetVisibleIsoLine(value.toBool());
252 emit dataChanged(index,index);
255 pNewLevel->SetVisibleColorWash(value.toBool());
256 emit dataChanged(index,index);
260 emit beginResetModel();
262 m_DoseSet->DeleteIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
263 m_DoseSet->SetIsoDoseLevel(pNewLevel);
267 emit endResetModel();
278 if (newReferenceDose<= 0)
280 mitkThrow() <<
"Error. Passed prescribed dose is negative or equals 0.";
283 if (newReferenceDose != m_referenceDose)
285 this->m_referenceDose = newReferenceDose;
286 if(m_showAbsoluteDose)
288 emit beginResetModel();
289 emit endResetModel();
298 if (showAbsoluteDose != m_showAbsoluteDose)
300 emit beginResetModel();
301 this->m_showAbsoluteDose = showAbsoluteDose;
302 emit endResetModel();
308 if (onlyVisibility != m_visibilityEditOnly)
310 emit beginResetModel();
311 this->m_visibilityEditOnly = onlyVisibility;
312 emit endResetModel();
320 return this->m_showAbsoluteDose;
327 return this->m_referenceDose;
334 return this->m_visibilityEditOnly;
339 emit beginResetModel();
344 pNewLevel->SetVisibleIsoLine(activate);
345 m_DoseSet->SetIsoDoseLevel(pNewLevel);
350 emit endResetModel();
355 emit beginResetModel();
360 pNewLevel->SetVisibleColorWash(activate);
361 m_DoseSet->SetIsoDoseLevel(pNewLevel);
366 emit endResetModel();
371 emit beginResetModel();
376 pNewLevel->SetVisibleIsoLine(!pNewLevel->GetVisibleIsoLine());
377 m_DoseSet->SetIsoDoseLevel(pNewLevel);
382 emit endResetModel();
387 emit beginResetModel();
392 pNewLevel->SetVisibleColorWash(!pNewLevel->GetVisibleColorWash());
393 m_DoseSet->SetIsoDoseLevel(pNewLevel);
398 emit endResetModel();
403 emit beginResetModel();
408 bool colorWash = pNewLevel->GetVisibleColorWash();
409 pNewLevel->SetVisibleColorWash(pNewLevel->GetVisibleIsoLine());
410 pNewLevel->SetVisibleIsoLine(colorWash);
411 m_DoseSet->SetIsoDoseLevel(pNewLevel);
416 emit endResetModel();
423 if (m_DoseSet->Size()>0)
425 doseVal = m_DoseSet->GetIsoDoseLevel(m_DoseSet->Size()-1).GetDoseValue()+0.01;
430 emit beginResetModel();
431 m_DoseSet->SetIsoDoseLevel(pNewLevel);
433 emit endResetModel();
438 if(!index.isValid() || (m_DoseSet->Size() <=
static_cast<unsigned int>(index.row())) || (index.column()>3))
443 emit beginResetModel();
444 m_DoseSet->DeleteIsoDoseLevel(static_cast<mitk::IsoDoseLevelSet::IsoLevelIndexType>(index.row()));
446 emit endResetModel();
bool getVisibilityEditOnly() const
itk::SmartPointer< Self > Pointer
void invertVisibilityIsoLines()
Stores values needed for the representation/visualization of dose iso levels.
virtual QVariant data(const QModelIndex &index, int role) const
void deleteLevel(const QModelIndex &index)
virtual DoseValueType GetDoseValue() const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
size_type IsoLevelIndexType
virtual void SetColor(ColorType _arg)
void invertVisibilityColorWash()
virtual Qt::ItemFlags flags(const QModelIndex &index) 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...
bool getShowAbsoluteDose() const
void setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet)
Stores values needed for the representation/visualization of dose iso levels.
void setReferenceDose(double newReferenceDose)
Slot that can be used to set the prescribed dose.
void switchVisibilityIsoLines(bool activate)
void switchVisibilityColorWash(bool activate)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
::itk::RGBPixel< float > ColorType
DoseValueRel DoseValueType
virtual ColorType GetColor() const
mitk::DoseValueAbs getReferenceDose() const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
QmitkIsoDoseLevelSetModel(QObject *parent=NULL)
double DoseValueAbs
Represents absolute dose values (in Gy).
virtual bool GetVisibleIsoLine() const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
void setVisibilityEditOnly(bool onlyVisibility)
Slat that can be used to adjust wether the model allows to edit only visibilities (no dose value or c...
virtual bool GetVisibleColorWash() const