Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 class qMRMLSegmentsModel;
37 class qMRMLSegmentsTableViewPrivate;
39 class QContextMenuEvent;
40 class QItemSelection;
41 class QStandardItem;
42 class QStringList;
43 class QTableWidgetItem;
44 class QTableView;
45 class vtkMRMLNode;
46 class vtkSegment;
47 
49 class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentsTableView : public qMRMLWidget
50 {
51  Q_OBJECT
52  QVTK_OBJECT
53 
54 public:
55  Q_PROPERTY(int selectionMode READ selectionMode WRITE setSelectionMode)
56  Q_PROPERTY(bool headerVisible READ headerVisible WRITE setHeaderVisible)
57  Q_PROPERTY(bool visibilityColumnVisible READ visibilityColumnVisible WRITE setVisibilityColumnVisible)
58  Q_PROPERTY(bool colorColumnVisible READ colorColumnVisible WRITE setColorColumnVisible)
59  Q_PROPERTY(bool opacityColumnVisible READ opacityColumnVisible WRITE setOpacityColumnVisible)
60  Q_PROPERTY(bool statusColumnVisible READ statusColumnVisible WRITE setStatusColumnVisible)
61  Q_PROPERTY(bool layerColumnVisible READ layerColumnVisible WRITE setLayerColumnVisible)
62  Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
63  Q_PROPERTY(bool filterBarVisible READ filterBarVisible WRITE setFilterBarVisible)
64  Q_PROPERTY(QString textFilter READ textFilter WRITE setTextFilter)
65  Q_PROPERTY(bool jumpToSelectedSegmentEnabled READ jumpToSelectedSegmentEnabled WRITE setJumpToSelectedSegmentEnabled)
66 
69  explicit qMRMLSegmentsTableView(QWidget* parent = nullptr);
71  ~qMRMLSegmentsTableView() override;
72 
74  Q_INVOKABLE vtkMRMLNode* segmentationNode();
75 
77  Q_INVOKABLE QTableView* tableWidget();
78 
80  int segmentCount() const;
81 
83  Q_INVOKABLE QStringList selectedSegmentIDs();
85  Q_INVOKABLE void setSelectedSegmentIDs(QStringList segmentIDs);
87  Q_INVOKABLE void clearSelection();
88 
90  Q_INVOKABLE static QString terminologyTooltipForSegment(vtkSegment* segment);
91 
92  int selectionMode();
93  bool headerVisible();
94  bool visibilityColumnVisible();
95  bool colorColumnVisible();
96  bool opacityColumnVisible();
97  bool statusColumnVisible();
98  bool layerColumnVisible();
99  bool readOnly();
100  bool filterBarVisible();
101 
104  Q_INVOKABLE void setHideSegments(const QStringList& segmentIDs);
105  Q_INVOKABLE QStringList hideSegments()const;
106 
108  Q_INVOKABLE QStringList displayedSegmentIDs()const;
109 
110  Q_INVOKABLE qMRMLSortFilterSegmentsProxyModel* sortFilterProxyModel()const;
111  Q_INVOKABLE qMRMLSegmentsModel* model()const;
112 
115  QString textFilter();
116  // If the specified status should be shown in the table
118  Q_INVOKABLE bool statusShown(int status);
119 
121  int rowForSegmentID(QString segmentID);
123  QString segmentIDForRow(int row);
124 
125 public slots:
127  void setSegmentationNode(vtkMRMLNode* node);
129  void setMRMLScene(vtkMRMLScene* newScene) override;
130 
134  void setSelectionMode(int mode);
135 
136  void setHeaderVisible(bool visible);
137  void setVisibilityColumnVisible(bool visible);
138  void setColorColumnVisible(bool visible);
139  void setOpacityColumnVisible(bool visible);
140  void setStatusColumnVisible(bool visible);
141  void setLayerColumnVisible(bool visible);
142  void setReadOnly(bool aReadOnly);
143  void setFilterBarVisible(bool visible);
144 
146  void showOnlySelectedSegments();
147 
150  void jumpSlices();
151 
153  void setJumpToSelectedSegmentEnabled(bool enable);
154 
156  void setSelectedSegmentsStatus(int status=-1);
157 
159  void clearSelectedSegments();
160 
162  void moveSelectedSegmentsUp();
164  void moveSelectedSegmentsDown();
165 
168  void setTextFilter(QString textFilter);
171  void setStatusShown(int status, bool shown);
172 
174  bool jumpToSelectedSegmentEnabled()const;
175 
176 signals:
178  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
179 
182  void segmentAboutToBeModified(const QString &segmentID);
183 
184 protected slots:
186  void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
187 
189  void onVisibility3DActionToggled(bool visible);
190  void onVisibility2DFillActionToggled(bool visible);
191  void onVisibility2DOutlineActionToggled(bool visible);
192 
194  void onSegmentsFilterModified();
196  void onShowStatusButtonClicked();
197 
199  void onSegmentsTableClicked(const QModelIndex& modelIndex);
200 
202  void endProcessing();
203 
204  void onSegmentAddedOrRemoved();
205 
208  void updateWidgetFromMRML();
209 
211  void updateMRMLFromFilterParameters();
212 
214  void modelAboutToBeReset();
215  void modelReset();
216 
217 protected:
224  void setSegmentVisibility(QObject* senderObject, int visible, int visible3D, int visible2DFill, int visible2DOutline);
225  void setSegmentVisibility(QString segmentId, int visible, int visible3D, int visible2DFill, int visible2DOutline);
226 
228  bool eventFilter(QObject* target, QEvent* event) override;
229 
231  void contextMenuEvent(QContextMenuEvent* event) override;
232 
233 protected:
234  QScopedPointer<qMRMLSegmentsTableViewPrivate> d_ptr;
235 
236 private:
237  Q_DECLARE_PRIVATE(qMRMLSegmentsTableView);
238  Q_DISABLE_COPY(qMRMLSegmentsTableView);
239 };
240 
241 #endif
This class encapsulates a segment that is part of a segmentation.
Definition: vtkSegment.h:45
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
Base class for any widget that requires a MRML Scene.
Definition: qMRMLWidget.h:35
QWidget Superclass
Definition: qMRMLWidget.h:40
Item model for segments.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167