Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerTerminologyNavigatorWidget.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 __qSlicerTerminologyNavigatorWidget_h
24 #define __qSlicerTerminologyNavigatorWidget_h
25 
26 // MRMLWidgets includes
27 #include "qMRMLWidget.h"
28 
29 // Terminologies includes
30 #include "qSlicerTerminologiesModuleWidgetsExport.h"
31 
33 
34 // CTK includes
35 #include <ctkPimpl.h>
36 #include <ctkVTKObject.h>
37 
38 class qSlicerTerminologyNavigatorWidgetPrivate;
39 
40 class QColor;
41 class QTableWidgetItem;
42 class QItemSelection;
45 
49 class Q_SLICER_MODULE_TERMINOLOGIES_WIDGETS_EXPORT qSlicerTerminologyNavigatorWidget : public qMRMLWidget
50 {
51  Q_OBJECT
52  QVTK_OBJECT
53 
54  Q_PROPERTY(bool anatomicRegionSectionVisible READ anatomicRegionSectionVisible WRITE setAnatomicRegionSectionVisible)
55  Q_PROPERTY(bool overrideSectionVisible READ overrideSectionVisible WRITE setOverrideSectionVisible)
56 
58  enum TerminologyItemDataRole
59  {
60  CodingSchemeDesignatorRole = Qt::UserRole + 100,
61  CodeValueRole,
62  // Roles for type items referencing category
63  CategoryCodingSchemeDesignatorRole,
64  CategoryCodeValueRole,
65  CategoryCodeMeaningRole,
66  // Last role (always keep last)
67  LastTerminologyRole
68  };
69 
70 public:
72  explicit qSlicerTerminologyNavigatorWidget(QWidget* parent = nullptr);
75 
76 #ifndef __VTK_WRAP__
77  class Q_SLICER_MODULE_TERMINOLOGIES_WIDGETS_EXPORT TerminologyInfoBundle
78  {
79  public:
81  TerminologyInfoBundle(vtkSlicerTerminologyEntry* entry, QString name, bool nameAutoGenerated, QColor color, bool colorAutoGenerated, QColor generatedColor);
83  const TerminologyInfoBundle& operator=(const TerminologyInfoBundle& other);
84  vtkSlicerTerminologyEntry* GetTerminologyEntry();
85 
86  QString Name;
88  QColor Color;
91  private:
92  vtkSlicerTerminologyEntry* TerminologyEntry;
93  };
94 
97  void terminologyInfo(TerminologyInfoBundle &terminologyInfo);
99  void setTerminologyInfo(TerminologyInfoBundle &terminologyInfo);
100 #endif // __VTK_WRAP__
101 
104  Q_INVOKABLE bool terminologyEntry(vtkSlicerTerminologyEntry* entry);
107  Q_INVOKABLE bool setTerminologyEntry(vtkSlicerTerminologyEntry* entry);
108 
110  bool anatomicRegionSectionVisible() const;
111 
113  bool overrideSectionVisible() const;
114 
116  Q_INVOKABLE static QString nameFromTerminology(vtkSlicerTerminologyEntry* entry);
118  QString nameFromCurrentTerminology();
120  Q_INVOKABLE static QColor recommendedColorFromTerminology(vtkSlicerTerminologyEntry* entry);
122  QColor recommendedColorFromCurrentTerminology();
123 
124 public slots:
126  void setAnatomicRegionSectionVisible(bool);
127 
129  void setOverrideSectionVisible(bool);
130 
131 protected:
133  void setCurrentTerminology(QString terminologyName);
137  bool setCurrentCategory(vtkSlicerTerminologyCategory* category);
139  void updateWidgetFromCurrentCategory();
142  bool setCurrentType(vtkSlicerTerminologyType* type);
145  bool setCurrentTypeModifier(vtkSlicerTerminologyType* modifier);
147  void setCurrentAnatomicContext(QString contextName);
150  bool setCurrentRegion(vtkSlicerTerminologyType* region);
153  bool setCurrentRegionModifier(vtkSlicerTerminologyType* modifier);
154 
155 protected:
157  void populateTerminologyComboBox();
159  void populateCategoryTable();
161  void populateTypeTable();
163  void populateTypeModifierComboBox();
164 
166  void populateAnatomicContextComboBox();
168  void populateRegionTable();
170  void populateRegionModifierComboBox();
171 
173  void copyContextToUserDirectory(QString filePath);
174 
175 protected slots:
176  void onTerminologySelectionChanged(int);
177  void onCategorySelectionChanged();
178  void onTypeSelected(QTableWidgetItem*, QTableWidgetItem*);
179  void onTypeCellDoubleClicked(int, int);
180  void onTypeModifierSelectionChanged(int);
181  void onCategorySearchTextChanged(QString);
182  void onTypeSearchTextChanged(QString);
183 
184  void onAnatomicContextSelectionChanged(int);
185  void onRegionSelected(QTableWidgetItem*,QTableWidgetItem*);
186  void onRegionModifierSelectionChanged(int);
187  void onRegionSearchTextChanged(QString);
188 
189  void onNameChanged(QString);
190  void onResetNameClicked();
191  void onColorChanged(QColor);
192  void onResetColorClicked();
193 
194  void onLoadTerminologyClicked();
195  void onLoadAnatomicContextClicked();
196 
197  void anatomicalRegionExpandButtonUp();
198  void anatomicalRegionExpandButtonDown();
199 
200  void onLogicModified();
201 
202 signals:
204  void selectionValidityChanged(bool);
206  void typeDoubleClicked();
207 
208 protected:
209  QScopedPointer<qSlicerTerminologyNavigatorWidgetPrivate> d_ptr;
210 
211 private:
212  Q_DECLARE_PRIVATE(qSlicerTerminologyNavigatorWidget);
213  Q_DISABLE_COPY(qSlicerTerminologyNavigatorWidget);
214 };
215 
216 #endif
QScopedPointer< qSlicerTerminologyNavigatorWidgetPrivate > d_ptr
Terminology property type object.
Base class for any widget that requires a MRML Scene.
Definition: qMRMLWidget.h:35
Qt widget for browsing a terminology dictionary. DICOM properties of the selected entry can also be s...
Terminology property category object.