Slicer 5.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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:
83
84 typedef QStandardItemModel Superclass;
85 qMRMLSegmentsModel(QObject* parent = nullptr);
87
88 int nameColumn() const;
89 void setNameColumn(int column);
90 int visibilityColumn() const;
91 void setVisibilityColumn(int column);
92 int colorColumn() const;
93 void setColorColumn(int column);
94 int opacityColumn() const;
95 void setOpacityColumn(int column);
96 int statusColumn() const;
97 void setStatusColumn(int column);
98 int layerColumn() const;
99 void setLayerColumn(int layer);
100
102 QString segmentIDFromIndex(const QModelIndex& index) const;
104 QString segmentIDFromItem(QStandardItem* item) const;
106 QModelIndex indexFromSegmentID(QString segmentID, int column = 0) const;
108 QStandardItem* itemFromSegmentID(QString segmentID, int column = 0) const;
109
111 QModelIndexList indexes(QString segmentID) const;
112
115 virtual void setSegmentationNode(vtkMRMLSegmentationNode* segmentation);
116
118 Q_INVOKABLE static QString terminologyTooltipForSegment(vtkSegment* segment);
119
120signals:
123 void segmentAboutToBeModified(const QString& segmentID);
124
127
128protected slots:
130 virtual void onItemChanged(QStandardItem* item);
131
135
136protected:
137 qMRMLSegmentsModel(qMRMLSegmentsModelPrivate* pimpl, QObject* parent = nullptr);
138
140 virtual void rebuildFromSegments();
142 virtual void updateFromSegments();
143
144 virtual Qt::ItemFlags segmentFlags(QString segmentID, int column) const;
145
147 virtual void updateItemFromSegment(QStandardItem* item, QString segmentID, int column);
149 virtual void updateItemDataFromSegment(QStandardItem* item, QString segmentID, int column);
151 virtual void updateSegmentFromItem(QString segmentID, QStandardItem* item);
153 virtual void updateSegmentFromItemData(QString segmentID, QStandardItem* item);
157 void updateItemsFromSegmentID(QString segmentID);
158
161
167 static void onEvent(vtkObject* caller, unsigned long event, void* clientData, void* callData);
168
170 virtual int maxColumnId() const;
171
173 virtual void onSegmentAdded(QString segmentID);
175 virtual void onSegmentRemoved(QString segmentID);
177 virtual void onSegmentModified(QString segmentID);
181 virtual void onDisplayNodeModified();
182
183protected:
184 QScopedPointer<qMRMLSegmentsModelPrivate> d_ptr;
185
186private:
187 Q_DECLARE_PRIVATE(qMRMLSegmentsModel);
188 Q_DISABLE_COPY(qMRMLSegmentsModel);
189};
190
191#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
QVTK_OBJECTint nameColumn
Control in which column the segment name is displayed.
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).
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.
@ VisibilityIconRole
QIcon for the visibility button; stored here instead of DecorationRole so the delegate does not paint...
@ StatusIconRole
QIcon for the status button; stored here instead of DecorationRole so the delegate does not paint it.
@ ColorRole
QColor of the segment; stored here instead of DecorationRole so the delegate does not paint it.
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