Slicer 5.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
36// Qt includes
37#include <QStringList>
38
40class qMRMLSegmentsTableViewPrivate;
42class QContextMenuEvent;
43class QItemSelection;
44class QStandardItem;
45class QTableWidgetItem;
46class QTableView;
47class vtkMRMLNode;
48class vtkSegment;
49
50class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentsTableView : public qMRMLWidget
51{
52 Q_OBJECT
53 QVTK_OBJECT
54
55public:
56 Q_PROPERTY(int selectionMode READ selectionMode WRITE setSelectionMode)
57 Q_PROPERTY(bool headerVisible READ headerVisible WRITE setHeaderVisible)
63 Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
65 Q_PROPERTY(QString textFilter READ textFilter WRITE setTextFilter)
67 Q_PROPERTY(int segmentCount READ segmentCount)
72
75 explicit qMRMLSegmentsTableView(QWidget* parent = nullptr);
78
81
83 Q_INVOKABLE QTableView* tableWidget();
84
86 int segmentCount() const;
87
89 Q_INVOKABLE QStringList selectedSegmentIDs();
91 Q_INVOKABLE void setSelectedSegmentIDs(QStringList segmentIDs);
93 Q_INVOKABLE void clearSelection();
94
96 Q_INVOKABLE static QString terminologyTooltipForSegment(vtkSegment* segment);
97
105 bool readOnly();
107
110 Q_INVOKABLE void setHideSegments(const QStringList& segmentIDs);
111 Q_INVOKABLE QStringList hideSegments() const;
112
114 Q_INVOKABLE QStringList displayedSegmentIDs() const;
115
117 Q_INVOKABLE qMRMLSegmentsModel* model() const;
118
121 QString textFilter();
122
128
132
135
138
139 // If the specified status should be shown in the table
141 Q_INVOKABLE bool statusShown(int status);
142
144 Q_INVOKABLE int rowForSegmentID(QString segmentID);
146 Q_INVOKABLE QString segmentIDForRow(int row);
147
148public slots:
152 void setMRMLScene(vtkMRMLScene* newScene) override;
153
157 void setSelectionMode(int mode);
158
159 void setHeaderVisible(bool visible);
160 void setVisibilityColumnVisible(bool visible);
161 void setColorColumnVisible(bool visible);
162 void setOpacityColumnVisible(bool visible);
163 void setStatusColumnVisible(bool visible);
164 void setLayerColumnVisible(bool visible);
165 void setReadOnly(bool aReadOnly);
166 void setFilterBarVisible(bool visible);
167
170
173
177
180
182 void setSelectedSegmentsStatus(int status = -1);
183
186
191
197 void setUseTerminologySelectorSettingsKey(QString settingsKey);
203 void setTerminologySelectorAutoDisable(bool autoDisable);
204
207 void setStatusShown(int status, bool shown);
208
211
212signals:
214 void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
215
218 void segmentAboutToBeModified(const QString& segmentID);
219
220protected slots:
222 void onSegmentSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
223
225 void onVisibility3DActionToggled(bool visible);
228
233
235 void onSegmentsTableClicked(const QModelIndex& modelIndex);
237 void onSegmentsTableDoubleClicked(const QModelIndex& modelIndex);
238
241
243
247
250
254
256 void onUseTerminologyActionToggled(bool useTerminology);
257
258protected:
265 void setSegmentVisibility(QObject* senderObject, int visible, int visible3D, int visible2DFill, int visible2DOutline);
266 void setSegmentVisibility(QString segmentId, int visible, int visible3D, int visible2DFill, int visible2DOutline);
267
269 bool eventFilter(QObject* target, QEvent* event) override;
270
272 void contextMenuEvent(QContextMenuEvent* event) override;
273
275
276protected:
277 QScopedPointer<qMRMLSegmentsTableViewPrivate> d_ptr;
278
279private:
280 Q_DECLARE_PRIVATE(qMRMLSegmentsTableView);
281 Q_DISABLE_COPY(qMRMLSegmentsTableView);
282};
283
284#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