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
qMRMLSegmentsTableView.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6 Queen's University, Kingston, ON, Canada. All Rights Reserved.
7
8 See COPYRIGHT.txt
9 or http://www.slicer.org/copyright/copyright.txt for details.
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18 and was supported through the Applied Cancer Research Unit program of Cancer Care
19 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20
21==============================================================================*/
22
23#ifndef __qMRMLSegmentsTableView_h
24#define __qMRMLSegmentsTableView_h
25
26// Segmentations includes
27#include "qSlicerSegmentationsModuleWidgetsExport.h"
28
29// MRMLWidgets includes
30#include "qMRMLWidget.h"
31
32// CTK includes
33#include <ctkPimpl.h>
34#include <ctkVTKObject.h>
35
37class qMRMLSegmentsTableViewPrivate;
39class QContextMenuEvent;
40class QItemSelection;
41class QStandardItem;
42class QStringList;
43class QTableWidgetItem;
44class QTableView;
45class vtkMRMLNode;
46class vtkSegment;
47
48class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentsTableView : public qMRMLWidget
49{
50 Q_OBJECT
51 QVTK_OBJECT
52
53public:
54 Q_PROPERTY(int selectionMode READ selectionMode WRITE setSelectionMode)
55 Q_PROPERTY(bool headerVisible READ headerVisible WRITE setHeaderVisible)
61 Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
63 Q_PROPERTY(QString textFilter READ textFilter WRITE setTextFilter)
65 Q_PROPERTY(int segmentCount READ segmentCount)
70
73 explicit qMRMLSegmentsTableView(QWidget* parent = nullptr);
76
79
81 Q_INVOKABLE QTableView* tableWidget();
82
84 int segmentCount() const;
85
87 Q_INVOKABLE QStringList selectedSegmentIDs();
89 Q_INVOKABLE void setSelectedSegmentIDs(QStringList segmentIDs);
91 Q_INVOKABLE void clearSelection();
92
94 Q_INVOKABLE static QString terminologyTooltipForSegment(vtkSegment* segment);
95
103 bool readOnly();
105
108 Q_INVOKABLE void setHideSegments(const QStringList& segmentIDs);
109 Q_INVOKABLE QStringList hideSegments()const;
110
112 Q_INVOKABLE QStringList displayedSegmentIDs()const;
113
115 Q_INVOKABLE qMRMLSegmentsModel* model()const;
116
119 QString textFilter();
120
126
130
133
136
137 // If the specified status should be shown in the table
139 Q_INVOKABLE bool statusShown(int status);
140
142 Q_INVOKABLE int rowForSegmentID(QString segmentID);
144 Q_INVOKABLE QString segmentIDForRow(int row);
145
146public slots:
150 void setMRMLScene(vtkMRMLScene* newScene) override;
151
155 void setSelectionMode(int mode);
156
157 void setHeaderVisible(bool visible);
158 void setVisibilityColumnVisible(bool visible);
159 void setColorColumnVisible(bool visible);
160 void setOpacityColumnVisible(bool visible);
161 void setStatusColumnVisible(bool visible);
162 void setLayerColumnVisible(bool visible);
163 void setReadOnly(bool aReadOnly);
164 void setFilterBarVisible(bool visible);
165
168
171
175
178
180 void setSelectedSegmentsStatus(int status=-1);
181
184
189
195 void setUseTerminologySelectorSettingsKey(QString settingsKey);
201 void setTerminologySelectorAutoDisable(bool autoDisable);
202
205 void setStatusShown(int status, bool shown);
206
209
210signals:
212 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
213
216 void segmentAboutToBeModified(const QString &segmentID);
217
218protected slots:
220 void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
221
223 void onVisibility3DActionToggled(bool visible);
226
231
233 void onSegmentsTableClicked(const QModelIndex& modelIndex);
235 void onSegmentsTableDoubleClicked(const QModelIndex& modelIndex);
236
239
241
245
248
252
254 void onUseTerminologyActionToggled(bool useTerminology);
255
256protected:
263 void setSegmentVisibility(QObject* senderObject, int visible, int visible3D, int visible2DFill, int visible2DOutline);
264 void setSegmentVisibility(QString segmentId, int visible, int visible3D, int visible2DFill, int visible2DOutline);
265
267 bool eventFilter(QObject* target, QEvent* event) override;
268
270 void contextMenuEvent(QContextMenuEvent* event) override;
271
273
274protected:
275 QScopedPointer<qMRMLSegmentsTableViewPrivate> d_ptr;
276
277private:
278 Q_DECLARE_PRIVATE(qMRMLSegmentsTableView);
279 Q_DISABLE_COPY(qMRMLSegmentsTableView);
280};
281
282#endif
Item model for segments.
void setJumpToSelectedSegmentEnabled(bool enable)
Enables automatic jumping to current segment when selection is changed.
Q_INVOKABLE bool statusShown(int status)
Q_INVOKABLE QStringList selectedSegmentIDs()
Get the segment IDs of selected segments.
void toggleSelectedSegmentsVisibility()
Toggle visibility for the selected segments.
void showOnlySelectedSegments()
Show only selected segments.
void onVisibility2DFillActionToggled(bool visible)
void setUseTerminologySelector(bool useTerminologySelector)
Set if standard terminologies are used for choosing segment name and color.
void onShowStatusButtonClicked()
Handles clicks on the show status buttons.
void contextMenuEvent(QContextMenuEvent *event) override
Handle context menu events.
void moveSelectedSegmentsUp()
Move selected segments up in the list.
void setMRMLScene(vtkMRMLScene *newScene) override
Set MRML scene.
Q_INVOKABLE vtkMRMLNode * segmentationNode()
Get segmentation MRML node.
void setTextFilter(QString textFilter)
Q_INVOKABLE void setSelectedSegmentIDs(QStringList segmentIDs)
Select segments with specified IDs.
Q_INVOKABLE qMRMLSegmentsModel * model() const
void setSelectionMode(int mode)
void onSegmentsFilterModified()
Handles when the filters on underlying sort model are modified.
Q_INVOKABLE QStringList displayedSegmentIDs() const
Return list of visible segment IDs.
void setSelectedSegmentsStatus(int status=-1)
Set the status of the selected segments.
void moveSelectedSegmentsDown()
Move selected segments down in the list.
Q_INVOKABLE qMRMLSortFilterSegmentsProxyModel * sortFilterProxyModel() const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Emitted if selection changes.
static Q_INVOKABLE QString terminologyTooltipForSegment(vtkSegment *segment)
Assemble terminology info string (for tooltips) from a segment's terminology tags.
void setVisibilityColumnVisible(bool visible)
void onSegmentsTableClicked(const QModelIndex &modelIndex)
Handles clicks on a table cell (visibility + state)
void setTerminologySelectorOptionVisible(bool visible)
Set if the user can choose between the standard terminologies selector or the simple selectors for se...
Q_INVOKABLE QTableView * tableWidget()
Get access to the table widget to allow low-level customization.
void onVisibility2DOutlineActionToggled(bool visible)
void onUseTerminologyActionToggled(bool useTerminology)
Toggle using standard terminology for this segments table.
Q_INVOKABLE void clearSelection()
Clear segment selection.
void setUseTerminologySelectorSettingsKey(QString settingsKey)
Q_INVOKABLE void setHideSegments(const QStringList &segmentIDs)
void segmentAboutToBeModified(const QString &segmentID)
Q_INVOKABLE QStringList hideSegments() const
void updateMRMLFromFilterParameters()
Update the filter parameters in the vtkMRMLSegmentationNode.
void setFilterBarVisible(bool visible)
void modelAboutToBeReset()
Signals to save/restore segment ID selection when the model is reset.
bool eventFilter(QObject *target, QEvent *event) override
To prevent accidentally moving out of the widget when pressing up/down arrows.
void setStatusColumnVisible(bool visible)
void onSegmentsTableDoubleClicked(const QModelIndex &modelIndex)
Handles clicks on a table cell (name + color change / terminology change)
void clearSelectedSegments()
Erase the contents of the selected segments and set the status to "Not started".
void setHeaderVisible(bool visible)
void setTerminologySelectorAutoDisable(bool autoDisable)
Offer automatic disable of using standard terminologies selector if custom segment names or colors ar...
qMRMLSegmentsTableView(QWidget *parent=nullptr)
Constructor.
void endProcessing()
Handle MRML scene event.
Q_INVOKABLE QString segmentIDForRow(int row)
Get the segment ID for the specified row.
void setReadOnly(bool aReadOnly)
void setOpacityColumnVisible(bool visible)
void setSegmentVisibility(QObject *senderObject, int visible, int visible3D, int visible2DFill, int visible2DOutline)
void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Forwards selection changed events. In case of batch update of items, selected and deselected are empt...
void setLayerColumnVisible(bool visible)
void onVisibility3DActionToggled(bool visible)
Handles actions on table cell (visibility)
Q_INVOKABLE int rowForSegmentID(QString segmentID)
Get the row for the specified segment ID.
QScopedPointer< qMRMLSegmentsTableViewPrivate > d_ptr
void setStatusShown(int status, bool shown)
void setSegmentationNode(vtkMRMLNode *node)
Set segmentation MRML node.
void setColorColumnVisible(bool visible)
qMRMLWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:45