Slicer  4.10
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 vtkMRMLNode;
37 class vtkSegment;
38 class qMRMLSegmentsTableViewPrivate;
39 class QStringList;
40 class QTableWidget;
41 class QTableWidgetItem;
42 class QItemSelection;
43 class QContextMenuEvent;
44 
46 class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentsTableView : public qMRMLWidget
47 {
48  Q_OBJECT
49  QVTK_OBJECT
50 
51  enum SegmentTableItemDataRole
52  {
54  IDRole = Qt::UserRole + 1,
57  VisibilityRole
58  };
59 
60 public:
61  Q_PROPERTY(int selectionMode READ selectionMode WRITE setSelectionMode)
62  Q_PROPERTY(bool headerVisible READ headerVisible WRITE setHeaderVisible)
63  Q_PROPERTY(bool visibilityColumnVisible READ visibilityColumnVisible WRITE setVisibilityColumnVisible)
64  Q_PROPERTY(bool colorColumnVisible READ colorColumnVisible WRITE setColorColumnVisible)
65  Q_PROPERTY(bool opacityColumnVisible READ opacityColumnVisible WRITE setOpacityColumnVisible)
66  Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
67 
70  explicit qMRMLSegmentsTableView(QWidget* parent = 0);
72  virtual ~qMRMLSegmentsTableView();
73 
75  Q_INVOKABLE vtkMRMLNode* segmentationNode();
76 
78  Q_INVOKABLE QTableWidget* tableWidget();
79 
81  int segmentCount() const;
82 
84  Q_INVOKABLE QStringList selectedSegmentIDs();
86  Q_INVOKABLE void setSelectedSegmentIDs(QStringList segmentIDs);
88  Q_INVOKABLE void clearSelection();
89 
91  Q_INVOKABLE static QString terminologyTooltipForSegment(vtkSegment* segment);
92 
93  int selectionMode();
94  bool headerVisible();
95  bool visibilityColumnVisible();
96  bool colorColumnVisible();
97  bool opacityColumnVisible();
98  bool readOnly();
99 
102  Q_INVOKABLE void setHideSegments(const QStringList& segmentIDs);
103  Q_INVOKABLE QStringList hideSegments()const;
104 
106  Q_INVOKABLE QStringList displayedSegmentIDs()const;
107 
108 public slots:
110  void setSegmentationNode(vtkMRMLNode* node);
111 
112  virtual void setMRMLScene(vtkMRMLScene* newScene);
113 
117  void setSelectionMode(int mode);
118 
119  void setHeaderVisible(bool visible);
120  void setVisibilityColumnVisible(bool visible);
121  void setColorColumnVisible(bool visible);
122  void setOpacityColumnVisible(bool visible);
123  void setReadOnly(bool aReadOnly);
124 
126  void showOnlySelectedSegments();
127 
130  void jumpSlices();
131 
133  void moveSelectedSegmentsUp();
135  void moveSelectedSegmentsDown();
136 
137 signals:
139  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
140 
143  void segmentAboutToBeModified(const QString &segmentID);
144 
145 protected slots:
147  void onSegmentTableItemChanged(QTableWidgetItem* changedItem);
148 
150  void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
151 
153  void onVisibilityButtonClicked();
154  void onVisibility3DActionToggled(bool visible);
155  void onVisibility2DFillActionToggled(bool visible);
156  void onVisibility2DOutlineActionToggled(bool visible);
157 
159  void populateSegmentTable();
160 
162  void updateWidgetFromMRML();
163 
165  void endProcessing();
166 
167 protected:
174  void setSegmentVisibility(QObject* senderObject, int visible, int visible3D, int visible2DFill, int visible2DOutline);
175 
177  virtual bool eventFilter(QObject* target, QEvent* event);
178 
180  virtual void contextMenuEvent(QContextMenuEvent* event);
181 
182 protected:
183  QScopedPointer<qMRMLSegmentsTableViewPrivate> d_ptr;
184 
185 private:
186  Q_DECLARE_PRIVATE(qMRMLSegmentsTableView);
187  Q_DISABLE_COPY(qMRMLSegmentsTableView);
188 };
189 
190 #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:54
Base class for any widget that requires a MRML Scene.
Definition: qMRMLWidget.h:35
QWidget Superclass
Definition: qMRMLWidget.h:40
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138