fw4spl
WindowLevel.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "uiImageQt/config.hpp"
10 
11 #include <fwData/Integer.hpp>
12 
13 #include <fwDataTools/helper/MedicalImageAdaptor.hpp>
14 
15 #include <fwGui/editor/IEditor.hpp>
16 
17 #include <fwTools/Failed.hpp>
18 
19 #include <QObject>
20 #include <QPointer>
21 
22 class QAction;
23 class QComboBox;
24 class QLabel;
25 class QLineEdit;
26 class QMenu;
27 class QSlider;
28 class QToolButton;
29 class QSignalMapper;
30 
31 fwCorePredeclare( (fwGuiQt)(widget)(QRangeSlider) );
32 namespace fwGuiQt
33 {
34 namespace widget
35 {
36 class QRangeSlider;
37 }
38 }
39 
40 namespace uiImageQt
41 {
42 
74 class UIIMAGEQT_CLASS_API WindowLevel : public QObject,
77 {
78 Q_OBJECT
79 
80 public:
81 
83 
84 
85  UIIMAGEQT_API WindowLevel() noexcept;
86 
88  UIIMAGEQT_API virtual ~WindowLevel() noexcept;
89 
90 protected:
91 
95  virtual void starting() override;
96 
100  virtual void stopping() override;
101 
103  virtual void updating() override;
104 
106  virtual void swapping(const KeyType& key) override;
107 
109  virtual void configuring() override;
110 
118  UIIMAGEQT_API virtual KeyConnectionsMap getAutoConnections() const override;
119 
121  UIIMAGEQT_API virtual void info( std::ostream& _sstream ) override;
122 
124  UIIMAGEQT_API virtual void updateTFPoints() override;
125 
127  UIIMAGEQT_API virtual void updateTFWindowing(double window, double level) override;
128 
129 protected Q_SLOTS:
130 
131  void onTextEditingFinished();
132  void onToggleTF(bool squareTF);
133  void onToggleAutoWL(bool autoWL);
134 
135  void onWindowLevelWidgetChanged(double _min, double _max);
136  void onDynamicRangeSelectionChanged(QAction* action);
137 
138 protected:
139  typedef ::fwData::TransferFunction::TFValuePairType WindowLevelMinMaxType;
140 
141  double toWindowLevel(double _val);
142  double fromWindowLevel(double _val);
143 
144  WindowLevelMinMaxType getImageWindowMinMax();
145 
146  void onImageWindowLevelChanged(double _imageMin, double _imageMax);
147 
148  void updateWidgetMinMax(double _imageMin, double _imageMax);
149  void updateImageWindowLevel(double _imageMin, double _imageMax);
150  void updateTextWindowLevel(double _imageMin, double _imageMax);
151 
152  void setWidgetDynamicRange(double min, double max);
153  bool getWidgetDoubleValue(QLineEdit* widget, double& val);
154 
155 private:
156 
157  QPointer< QLineEdit > m_valueTextMin;
158  QPointer< QLineEdit > m_valueTextMax;
159  QPointer< QToolButton > m_toggleTFButton;
160  QPointer< QToolButton > m_toggleAutoButton;
161  QPointer< QToolButton > m_dynamicRangeSelection;
162  QPointer< QMenu > m_dynamicRangeMenu;
163  QPointer< QSignalMapper > m_dynamicRangeSignalMapper;
164 
165  QPointer< ::fwGuiQt::widget::QRangeSlider > m_rangeSlider;
166 
167  double m_widgetDynamicRangeMin;
168  double m_widgetDynamicRangeWidth;
169  bool m_autoWindowing;
170  bool m_enableSquareTF;
171 
173  ::fwData::TransferFunction::sptr m_previousTF;
174 };
175 
176 } // uiImageQt
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
Defines the service interface managing the editor service for object.
Definition: IEditor.hpp:25
STL namespace.
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
Definition: WindowLevel.hpp:32
The namespace uiImageQt contains several editors on image written with Qt. This namespace is included...
Definition: ImageInfo.hpp:23
#define fwCorePredeclare(_cls_)
Generate predeclarations.
WindowLevel service allows to change the min / max value of windowing.
Definition: WindowLevel.hpp:74
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
Contains the representation of the data objects used in the framework.