Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmlMitkSliderLevelWindowItem.h
Go to the documentation of this file.
1 /*===================================================================
2 
3  The Medical Imaging Interaction Toolkit (MITK)
4 
5  Copyright (c) German Cancer Research Center,
6  Division of Medical and Biological Informatics.
7  All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without
10  even the implied warranty of MERCHANTABILITY or FITNESS FOR
11  A PARTICULAR PURPOSE.
12 
13  See LICENSE.txt or http://www.mitk.org for details.
14 
15  ===================================================================*/
16 
17 #ifndef __qmlMitkSliderLevelWindowItem_h
18 #define __qmlMitkSliderLevelWindowItem_h
19 
20 #include <MitkQmlItemsExports.h>
21 
22 #include <mitkLevelWindowManager.h>
23 #include <mitkDataStorage.h>
24 
25 #include <QQuickPaintedItem>
26 #include <QQmlEngine>
27 
28 class MITKQMLITEMS_EXPORT QmlMitkSliderLevelWindowItem : public QQuickPaintedItem
29 {
30  Q_OBJECT
31  Q_PROPERTY(QColor color READ color WRITE setColor)
32  Q_PROPERTY(QColor fontColor READ fontColor WRITE setFontColor)
33  Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
34  Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize)
35  Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
36  Q_PROPERTY(int level READ getLevel WRITE setLevel NOTIFY levelChanged)
37  Q_PROPERTY(int window READ getWindow WRITE setWindow NOTIFY windowChanged)
38 
39 private:
40  static mitk::DataStorage::Pointer storage;
41 
43  void OnPropertyModified(const itk::EventObject& e);
44 
45  QColor m_Color;
46  QColor m_BorderColor;
47  QColor m_FontColor;
48  QFont m_Font;
49 
50  bool m_Enabled;
51 
52  int m_Level;
53  int m_Window;
54 
55  mitk::LevelWindow m_LevelWindow;
56  mitk::LevelWindowManager::Pointer m_Manager;
57 
58 public:
59  static QmlMitkSliderLevelWindowItem* instance;
60 
61  QmlMitkSliderLevelWindowItem(QQuickPaintedItem * parent = nullptr);
63 
64  void setLevelWindowManager(mitk::LevelWindowManager* levelWindowManager);
65  void setDataStorage(mitk::DataStorage* ds);
66 
67  mitk::LevelWindowManager* GetManager();
68 
69  QColor color() const;
70  void setColor(const QColor &color);
71 
72  QColor fontColor() const;
73  void setFontColor(const QColor &color);
74 
75  QColor borderColor() const;
76  void setBorderColor(const QColor &color);
77 
78  int getLevel();
79  void setLevel(int level);
80 
81  int getWindow();
82  void setWindow(int window);
83 
84  int fontSize() const;
85  void setFontSize(const int &fontSize);
86 
87  bool isEnabled();
88  void setEnabled(bool enable);
89 
90  static void create(QQmlEngine &engine, mitk::DataStorage::Pointer storage);
91 
92 protected:
93  QRect m_Rect;
94  QPoint m_StartPos;
95 
96  QRect m_LowerBound;
97  QRect m_UpperBound;
98 
99  bool m_Resize;
100  bool m_Bottom;
101  bool m_MouseDown;
102  bool m_Leftbutton;
103  bool m_CtrlPressed;
104  bool m_ScaleVisible;
105 
106  int m_FontSize;
107  int m_MoveHeight;
108 
109  unsigned long m_ObserverTag;
110  bool m_IsObserverTagSet;
111 
112  void paint(QPainter* painter) override;
113 
114  void mouseMoveEvent(QMouseEvent* mouseEvent ) override;
115  void mousePressEvent(QMouseEvent* mouseEvent ) override;
116  void mouseReleaseEvent(QMouseEvent* mouseEvent ) override;
117 
118  void hoverMoveEvent(QHoverEvent* event) override;
119  void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) override;
120 
121  virtual void update( );
122 
123 protected slots:
124  void hideScale();
125  void showScale();
126 
127 signals:
128  void enabledChanged();
129  void levelChanged();
130  void windowChanged();
131  void sync();
132 };
133 
134 #endif
itk::SmartPointer< Self > Pointer
#define MITKQMLITEMS_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.