Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qMRMLSegmentsModel.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4 Queen's University, Kingston, ON, Canada. All Rights Reserved.
5
6 See COPYRIGHT.txt
7 or http://www.slicer.org/copyright/copyright.txt for details.
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 This file was originally developed by Kyle Sunderland, PerkLab, Queen's University
16 and was supported through CANARIE's Research Software Program, and Cancer
17 Care Ontario.
18
19==============================================================================*/
20
21#ifndef __qMRMLSegmentsModel_h
22#define __qMRMLSegmentsModel_h
23
24// Qt includes
25#include <QStandardItemModel>
26
27// CTK includes
28#include <ctkPimpl.h>
29#include <ctkVTKObject.h>
30
31// Segments includes
32#include "qSlicerSegmentationsModuleWidgetsExport.h"
33
34class qMRMLSegmentsModelPrivate;
36class vtkMRMLNode;
37class vtkMRMLScene;
38class vtkSegment;
39
46class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentsModel : public QStandardItemModel
47{
48 Q_OBJECT
49 QVTK_OBJECT
50
52 Q_PROPERTY (int nameColumn READ nameColumn WRITE setNameColumn)
58 Q_PROPERTY(int colorColumn READ colorColumn WRITE setColorColumn)
60 Q_PROPERTY (int opacityColumn READ opacityColumn WRITE setOpacityColumn)
62 Q_PROPERTY(int statusColumn READ statusColumn WRITE setStatusColumn)
64 Q_PROPERTY(int layerColumn READ layerColumn WRITE setLayerColumn)
65
66public:
67
75
76 typedef QStandardItemModel Superclass;
77 qMRMLSegmentsModel(QObject *parent=nullptr);
79
80 int nameColumn()const;
81 void setNameColumn(int column);
82 int visibilityColumn()const;
83 void setVisibilityColumn(int column);
84 int colorColumn()const;
85 void setColorColumn(int column);
86 int opacityColumn()const;
87 void setOpacityColumn(int column);
88 int statusColumn()const;
89 void setStatusColumn(int column);
90 int layerColumn()const;
91 void setLayerColumn(int layer);
92
94 QString segmentIDFromIndex(const QModelIndex &index)const;
96 QString segmentIDFromItem(QStandardItem* item)const;
98 QModelIndex indexFromSegmentID(QString segmentID, int column=0)const;
100 QStandardItem* itemFromSegmentID(QString segmentID, int column=0)const;
101
103 QModelIndexList indexes(QString segmentID)const;
104
107 virtual void setSegmentationNode(vtkMRMLSegmentationNode* segmentation);
108
110 Q_INVOKABLE static QString terminologyTooltipForSegment(vtkSegment* segment);
111
112signals:
115 void segmentAboutToBeModified(const QString& segmentID);
116
119
120protected slots:
122 virtual void onItemChanged(QStandardItem* item);
123
127
128protected:
129 qMRMLSegmentsModel(qMRMLSegmentsModelPrivate* pimpl, QObject *parent=nullptr);
130
132 virtual void rebuildFromSegments();
134 virtual void updateFromSegments();
135
136 virtual Qt::ItemFlags segmentFlags(QString segmentID, int column)const;
137
139 virtual void updateItemFromSegment(QStandardItem* item, QString segmentID, int column );
141 virtual void updateItemDataFromSegment(QStandardItem* item, QString segmentID, int column );
143 virtual void updateSegmentFromItem(QString segmentID, QStandardItem* item );
145 virtual void updateSegmentFromItemData(QString segmentID, QStandardItem* item );
149 void updateItemsFromSegmentID(QString segmentID);
150
153
159 static void onEvent(vtkObject* caller, unsigned long event, void* clientData, void* callData);
160
162 virtual int maxColumnId()const;
163
165 virtual void onSegmentAdded(QString segmentID);
167 virtual void onSegmentRemoved(QString segmentID);
169 virtual void onSegmentModified(QString segmentID);
173 virtual void onDisplayNodeModified();
174
175protected:
176 QScopedPointer<qMRMLSegmentsModelPrivate> d_ptr;
177
178private:
179 Q_DECLARE_PRIVATE(qMRMLSegmentsModel);
180 Q_DISABLE_COPY(qMRMLSegmentsModel);
181};
182
183#endif
void setColorColumn(int column)
int opacityColumn() const
int visibilityColumn() const
virtual void updateFromSegments()
Updates all items from the segments in the segmentation model.
void setStatusColumn(int column)
virtual void onSegmentAdded(QString segmentID)
Called when a segment is added to the segmentation node.
virtual void onSegmentRemoved(QString segmentID)
Called when a segment is removed from the segmentation node.
virtual void rebuildFromSegments()
Removes all items and regenerates the model from the segments in the segmentation node.
QModelIndex indexFromSegmentID(QString segmentID, int column=0) const
Returns the index for the given segment ID.
QScopedPointer< qMRMLSegmentsModelPrivate > d_ptr
int layerColumn
Control in which column the segment layer is displayed (qMRMLSegmentsModel::LayerRole).
vtkMRMLSegmentationNode * segmentationNode() const
The segmentation node that is used to populate the model.
virtual void updateItemDataFromSegment(QStandardItem *item, QString segmentID, int column)
Update QStandardItem data associated using segmentID and column.
QModelIndexList indexes(QString segmentID) const
Return all the QModelIndexes (all the columns) for a given segment ID.
QString segmentIDFromIndex(const QModelIndex &index) const
Returns the segment ID for the given index.
void setVisibilityColumn(int column)
QStandardItemModel Superclass
virtual void onItemChanged(QStandardItem *item)
Invoked when an item in the model is changed.
void updateItemsFromSegmentID(QString segmentID)
Update all of the the QStandardItem associated with a segment ID.
static Q_INVOKABLE QString terminologyTooltipForSegment(vtkSegment *segment)
Assemble terminology info string (for tooltips) from a segment's terminology tags.
virtual void updateItemFromSegment(QStandardItem *item, QString segmentID, int column)
Update QStandardItem associated using segmentID and column.
void updateItemsFromColumnIndex(int column)
Update all of the the QStandardItem associated with a column.
QString segmentIDFromItem(QStandardItem *item) const
Returns the segment ID for the given item.
void requestSelectItems(QList< vtkIdType > itemIDs)
Signal requesting selecting items in the tree.
void setOpacityColumn(int column)
void reorderItems()
Rearrange the order of the rows to match the indices of the segments in the MRML node.
virtual void updateSegmentFromItem(QString segmentID, QStandardItem *item)
Update a segment in the MRML node using the associated QStandardItem.
~qMRMLSegmentsModel() override
QStandardItem * itemFromSegmentID(QString segmentID, int column=0) const
Returns the item for the given segment ID.
qMRMLSegmentsModel(QObject *parent=nullptr)
int opacityColumn
Control in which column the segment opacity is displayed (Qt::EditRole).
QVTK_OBJECT int nameColumn
Control in which column the segment name is displayed.
int layerColumn() const
qMRMLSegmentsModel(qMRMLSegmentsModelPrivate *pimpl, QObject *parent=nullptr)
void segmentAboutToBeModified(const QString &segmentID)
static void onEvent(vtkObject *caller, unsigned long event, void *clientData, void *callData)
void setNameColumn(int column)
virtual int maxColumnId() const
Must be reimplemented in subclasses that add new column types.
void setLayerColumn(int layer)
int statusColumn
Control in which column the segment status is displayed (qMRMLSegmentsModel::StatusRole).
virtual void onSegmentOrderModified()
Called when a the order of segment in the segmentation node is modified.
int colorColumn() const
virtual void setSegmentationNode(vtkMRMLSegmentationNode *segmentation)
virtual void onSegmentModified(QString segmentID)
Called when a segment is modified in the segmentation node.
virtual Qt::ItemFlags segmentFlags(QString segmentID, int column) const
int nameColumn() const
int statusColumn() const
virtual void onDisplayNodeModified()
Called when the vtkMRMLSegmentationDisplayNode is modified.
virtual void updateSegmentFromItemData(QString segmentID, QStandardItem *item)
Update a segment in the MRML node using the associated QStandardItem data.
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node containing segmentations.
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:45