Medical Imaging Interaction Toolkit  2023.12.99-63768887
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 = {});
36  QClickableLabel(const QString &text, QWidget *parent, Qt::WindowFlags f = {});
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;
61 
62  typedef std::map<QString, unsigned int> NameToIndexMapType;
63  typedef std::map<unsigned int, QString> IndexToNameMapType;
66 };
67 
68 #endif
MITKQTWIDGETSEXT_EXPORT
#define MITKQTWIDGETSEXT_EXPORT
Definition: MitkQtWidgetsExtExports.h:15
QClickableLabel::m_HotspotNameForIndex
IndexToNameMapType m_HotspotNameForIndex
Definition: qclickablelabel.h:65
QClickableLabel
A QLabel with multiple hotspots, that can be clicked.
Definition: qclickablelabel.h:30
QClickableLabel::m_HotspotIndexForName
NameToIndexMapType m_HotspotIndexForName
Definition: qclickablelabel.h:64
QClickableLabel::IndexToNameMapType
std::map< unsigned int, QString > IndexToNameMapType
Definition: qclickablelabel.h:63
QClickableLabel::NameToIndexMapType
std::map< QString, unsigned int > NameToIndexMapType
Definition: qclickablelabel.h:62
QClickableLabel::m_Hotspots
RectVectorType m_Hotspots
Definition: qclickablelabel.h:60
mitkCommon.h
QClickableLabel::RectVectorType
std::vector< QRect > RectVectorType
Definition: qclickablelabel.h:59
MitkQtWidgetsExtExports.h