Medical Imaging Interaction Toolkit  2016.11.0
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,
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 qclickablelabelhincluded
18 #define qclickablelabelhincluded
19 
21 #include <QLabel>
22 
23 #include <map>
24 #include <vector>
25 
26 #include "mitkCommon.h"
27 
35 {
36  Q_OBJECT
37 
38 public:
39  QClickableLabel(QWidget *parent, Qt::WindowFlags f = nullptr);
40  QClickableLabel(const QString &text, QWidget *parent, Qt::WindowFlags f = nullptr);
41  virtual ~QClickableLabel();
42 
43  void AddHotspot(const QString &name, const QRect position);
44 
45  void RemoveHotspot(const QString &name);
46  void RemoveHotspot(unsigned int hotspotIndex);
47  void RemoveAllHotspots();
48 
49 signals:
50 
51  void mousePressed(const QString &hotspotName);
52  void mousePressed(unsigned int hotspotIndex);
53  void mouseReleased(const QString &hotspotName);
54  void mouseReleased(unsigned int hotspotIndex);
55 
56 protected:
57  virtual void mousePressEvent(QMouseEvent *e) override;
58  virtual void mouseReleaseEvent(QMouseEvent *e) override;
59 
61  unsigned int matchingRect(const QPoint &p);
62 
63  typedef std::vector<QRect> RectVectorType;
64  RectVectorType m_Hotspots;
65 
66  typedef std::map<QString, unsigned int> NameToIndexMapType;
67  typedef std::map<unsigned int, QString> IndexToNameMapType;
68  NameToIndexMapType m_HotspotIndexForName;
69  IndexToNameMapType m_HotspotNameForIndex;
70 };
71 
72 #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