Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkSimpleBarrierModel Class Reference

Qt table model for viewing and editing the constraints of a SimpleBarrierConstraintChecker. More...

#include <QmitkSimpleBarrierModel.h>

Inheritance diagram for QmitkSimpleBarrierModel:
Collaboration diagram for QmitkSimpleBarrierModel:

Public Member Functions

 QmitkSimpleBarrierModel (QObject *parent=nullptr)
 Constructs a QmitkSimpleBarrierModel. More...
 
 ~QmitkSimpleBarrierModel () override
 Destructor. More...
 
void setChecker (mitk::SimpleBarrierConstraintChecker *pChecker, const mitk::ModelTraitsInterface::ParameterNamesType &names, const mitk::ModelTraitsInterface::ParamterUnitMapType units)
 Sets the constraint checker and parameter metadata managed by this model. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns item flags for the given model index. More...
 
QVariant data (const QModelIndex &index, int role) const override
 Returns data for the given index and role. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 Returns header data for the specified section. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of constraints (rows). More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns (always 5). More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 Sets data for a given index. More...
 
void addConstraint ()
 Adds a new default lower barrier constraint for parameter 0 with barrier value 0. More...
 
void deleteConstraint (const QModelIndex &index)
 Deletes the constraint at the specified model index. More...
 
bool isModified ()
 Indicates whether the model content has been modified since the last setChecker() call. More...
 

Detailed Description

Qt table model for viewing and editing the constraints of a SimpleBarrierConstraintChecker.

This model adapts a mitk::SimpleBarrierConstraintChecker for use with a Qt table view. Each row represents a single constraint, with columns for: affected parameters, constraint type (upper/lower), barrier threshold value, penalty zone width, and parameter units. All columns except the unit column are editable.

See also
QmitkSimpleBarrierManagerWidget
QmitkSimpleBarrierTypeDelegate
QmitkSimpleBarrierParametersDelegate
mitk::SimpleBarrierConstraintChecker

Definition at line 38 of file QmitkSimpleBarrierModel.h.

Constructor & Destructor Documentation

◆ QmitkSimpleBarrierModel()

QmitkSimpleBarrierModel::QmitkSimpleBarrierModel ( QObject *  parent = nullptr)

Constructs a QmitkSimpleBarrierModel.

Creates an empty internal SimpleBarrierConstraintChecker.

Parameters
[in]parentOptional parent QObject.

◆ ~QmitkSimpleBarrierModel()

QmitkSimpleBarrierModel::~QmitkSimpleBarrierModel ( )
inlineoverride

Destructor.

Definition at line 53 of file QmitkSimpleBarrierModel.h.

Member Function Documentation

◆ addConstraint()

void QmitkSimpleBarrierModel::addConstraint ( )

Adds a new default lower barrier constraint for parameter 0 with barrier value 0.

Triggers a full model reset and sets the modified flag.

◆ columnCount()

int QmitkSimpleBarrierModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of columns (always 5).

Parameters
[in]parentThe parent model index.
Returns
5 (parameters, type, value, width, unit). Returns 0 if parent is valid.

◆ data()

QVariant QmitkSimpleBarrierModel::data ( const QModelIndex &  index,
int  role 
) const
override

Returns data for the given index and role.

Column 0: affected parameter names (display: selected names; edit: all available names). Column 1: constraint type ("upper" or "lower"). Column 2: barrier threshold value. Column 3: penalty zone width. Column 4: units of the affected parameters.

Parameters
[in]indexThe model index to query.
[in]roleThe Qt item data role.
Returns
The requested data as QVariant.

◆ deleteConstraint()

void QmitkSimpleBarrierModel::deleteConstraint ( const QModelIndex &  index)

Deletes the constraint at the specified model index.

Does nothing if the index is invalid or out of range. Triggers a full model reset and sets the modified flag.

Parameters
[in]indexThe model index of the constraint to delete.

◆ flags()

Qt::ItemFlags QmitkSimpleBarrierModel::flags ( const QModelIndex &  index) const
override

Returns item flags for the given model index.

Columns 0 through 3 (parameters, type, value, width) are editable. Column 4 (unit) is read-only.

Parameters
[in]indexThe model index to query.
Returns
The item flags.

◆ headerData()

QVariant QmitkSimpleBarrierModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
override

Returns header data for the specified section.

Horizontal headers are: "Parameters", "Type", "Value", "Width", "Unit".

Parameters
[in]sectionThe column index.
[in]orientationThe header orientation.
[in]roleThe Qt item data role.
Returns
The header data as QVariant.

◆ isModified()

bool QmitkSimpleBarrierModel::isModified ( )

Indicates whether the model content has been modified since the last setChecker() call.

Returns
True if modified, false otherwise.

◆ rowCount()

int QmitkSimpleBarrierModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of constraints (rows).

Parameters
[in]parentThe parent model index.
Returns
The number of constraints. Returns 0 if parent is valid.

◆ setChecker()

void QmitkSimpleBarrierModel::setChecker ( mitk::SimpleBarrierConstraintChecker *  pChecker,
const mitk::ModelTraitsInterface::ParameterNamesType &  names,
const mitk::ModelTraitsInterface::ParamterUnitMapType  units 
)

Sets the constraint checker and parameter metadata managed by this model.

If the provided checker differs from the current one, the model is reset. The modified flag is cleared. If pChecker is nullptr, a new empty checker is created.

Parameters
[in]pCheckerPointer to the SimpleBarrierConstraintChecker to manage.
[in]namesList of parameter names. The index corresponds to the parameter index in the fitting model.
[in]unitsMap of parameter names to their unit strings.

◆ setData()

bool QmitkSimpleBarrierModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

Sets data for a given index.

Column 0: expects a QStringList of selected parameter names. Column 1: expects an integer (0 = lower, 1 = upper). Column 2: expects a double barrier value. Column 3: expects a double width value.

Parameters
[in]indexThe model index to modify.
[in]valueThe new value to set.
[in]roleThe Qt item data role (only Qt::EditRole is handled).
Returns
True if data was successfully modified, false otherwise.

The documentation for this class was generated from the following file: