Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
qclickablelabel.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef qclickablelabelhincluded
14 #define qclickablelabelhincluded
15 
17 #include <QLabel>
18 
19 #include <map>
20 #include <vector>
21 
22 #include "mitkCommon.h"
23 
31 {
32  Q_OBJECT
33 
34 public:
35  QClickableLabel(QWidget *parent, Qt::WindowFlags f = nullptr);
36  QClickableLabel(const QString &text, QWidget *parent, Qt::WindowFlags f = nullptr);
37  ~QClickableLabel() override;
38 
39  void AddHotspot(const QString &name, const QRect position);
40 
41  void RemoveHotspot(const QString &name);
42  void RemoveHotspot(unsigned int hotspotIndex);
43  void RemoveAllHotspots();
44 
45 signals:
46 
47  void mousePressed(const QString &hotspotName);
48  void mousePressed(unsigned int hotspotIndex);
49  void mouseReleased(const QString &hotspotName);
50  void mouseReleased(unsigned int hotspotIndex);
51 
52 protected:
53  void mousePressEvent(QMouseEvent *e) override;
54  void mouseReleaseEvent(QMouseEvent *e) override;
55 
57  unsigned int matchingRect(const QPoint &p);
58 
59  typedef std::vector<QRect> RectVectorType;
60  RectVectorType m_Hotspots;
61 
62  typedef std::map<QString, unsigned int> NameToIndexMapType;
63  typedef std::map<unsigned int, QString> IndexToNameMapType;
64  NameToIndexMapType m_HotspotIndexForName;
65  IndexToNameMapType m_HotspotNameForIndex;
66 };
67 
68 #endif
std::vector< QRect > RectVectorType
std::map< unsigned int, QString > IndexToNameMapType
RectVectorType m_Hotspots
#define MITKQTWIDGETSEXT_EXPORT
A QLabel with multiple hotspots, that can be clicked.
IndexToNameMapType m_HotspotNameForIndex
NameToIndexMapType m_HotspotIndexForName
std::map< QString, unsigned int > NameToIndexMapType