Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qMRMLUnitWidget.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Johan Andruejol, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __qMRMLUnitWidget_h
22 #define __qMRMLUnitWidget_h
23 
24 // CTK includes
25 #include <ctkVTKObject.h>
26 
27 // MRML includes
28 class vtkMRMLNode;
29 
30 // qMRML includes
31 #include <qMRMLWidget.h>
32 class qMRMLNodeComboBox;
33 
34 // Qt includes
35 class QWidget;
36 
37 // Unit includes
38 #include "qSlicerUnitsModuleWidgetsExport.h"
39 class qMRMLUnitWidgetPrivate;
41 
42 class Q_SLICER_MODULE_UNITS_WIDGETS_EXPORT qMRMLUnitWidget : public qMRMLWidget
43 {
44  Q_OBJECT
45  QVTK_OBJECT
48  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
51  Q_PROPERTY(QString quantity READ quantity WRITE setQuantity NOTIFY quantityChanged)
54  Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
57  Q_PROPERTY(QString suffix READ suffix WRITE setSuffix NOTIFY suffixChanged)
60  Q_PROPERTY(int precision READ precision WRITE setPrecision NOTIFY precisionChanged)
63  Q_PROPERTY(double minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
66  Q_PROPERTY(double maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
69  Q_PROPERTY(double coefficient READ coefficient WRITE setCoefficient NOTIFY coefficientChanged)
72  Q_PROPERTY(double offset READ offset WRITE setOffset NOTIFY offsetChanged)
73 
78  Q_PROPERTY(UnitProperties displayedProperties READ displayedProperties WRITE setDisplayedProperties)
82  Q_PROPERTY(UnitProperties editableProperties READ editableProperties WRITE setEditableProperties)
83 
84  Q_FLAGS(UnitProperty UnitProperties)
85 
86 public:
88  qMRMLUnitWidget(QWidget *parent=nullptr);
89  ~qMRMLUnitWidget() override;
90 
93  QString name() const;
96  QString quantity() const;
99  QString prefix() const;
102  QString suffix() const;
105  int precision() const;
108  double minimum() const;
111  double maximum() const;
114  double coefficient() const;
117  double offset() const;
118 
120  {
121  None = 0x000,
122  Preset = 0x001,
123  Name = 0x002,
124  Quantity = 0x004,
125  Precision = 0x008,
126  Prefix = 0x010,
127  Suffix = 0x020,
128  Minimum = 0x040,
129  Maximum = 0x080,
130  Coefficient = 0x100,
131  Offset = 0x200,
132  All = 0xfff,
133  };
134  Q_DECLARE_FLAGS(UnitProperties, UnitProperty)
135 
136 
137  UnitProperties displayedProperties() const;
141  UnitProperties editableProperties() const;
142 
144  void setMRMLScene(vtkMRMLScene* unitsLogicScene) override;
145 
146  Q_INVOKABLE vtkMRMLNode* currentNode() const;
147 
148 public slots:
149  void setCurrentNode(vtkMRMLNode* unitNode);
150 
153  void setName(const QString &);
156  void setQuantity(const QString &);
159  void setPrefix(const QString &);
162  void setSuffix(const QString &);
165  void setPrecision(int);
168  void setMinimum(double);
171  void setMaximum(double);
174  void setCoefficient(double);
177  void setOffset(double);
178 
180  void setUnitFromPreset(vtkMRMLNode* presetNode);
181 
184  void setDisplayedProperties(UnitProperties properties);
187  void setEditableProperties(UnitProperties properties);
188 
189 protected slots:
190  void updateWidgetFromNode();
191 
192 signals:
193  void nameChanged(QString);
194  void quantityChanged(QString);
195  void prefixChanged(QString);
196  void suffixChanged(QString);
197  void precisionChanged(int);
198  void minimumChanged(double);
199  void maximumChanged(double);
200  void coefficientChanged(double);
201  void offsetChanged(double);
202 
203 protected:
204  QScopedPointer<qMRMLUnitWidgetPrivate> d_ptr;
205 
206 private:
207  Q_DECLARE_PRIVATE(qMRMLUnitWidget);
208  Q_DISABLE_COPY(qMRMLUnitWidget);
209 };
210 
211 Q_DECLARE_OPERATORS_FOR_FLAGS(qMRMLUnitWidget::UnitProperties)
212 
213 #endif
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
Combobox that automatically displays all the nodes of the scene that match filtering criteria...
Slicer logic for unit manipulation.
QScopedPointer< qMRMLUnitWidgetPrivate > d_ptr
virtual void setMRMLScene(vtkMRMLScene *newScene)
Set the MRML scene associated with the widget.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167