Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkScalarBar.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 QmitkScalarBar_h
14 #define QmitkScalarBar_h
15 
16 #include <MitkQtOverlaysExports.h>
17 #include <mitkCommon.h>
18 
19 #include <QPen>
20 #include <QWidget>
21 
32 class MITKQTOVERLAYS_EXPORT QmitkScalarBar : public QWidget
33 {
34  Q_OBJECT
35 public:
39  enum alignment
40  {
41  vertical = 0,
42  horizontal = 1
43  };
44 
49  QmitkScalarBar(QWidget *parent = nullptr);
50 
52  ~QmitkScalarBar() override;
53 
62  virtual void SetScaleFactor(double scale);
63 
68  virtual void SetAlignment(alignment align);
69 
74  void SetPen(const QPen &pen);
75 
80  void SetNumberOfSubdivisions(unsigned int subs);
81 
86  unsigned int GetNumberOfSubdivisions();
87 
88 protected:
89  void paintEvent(QPaintEvent *event) override;
90 
91  void SetupGeometry(alignment align);
92 
93  void CleanUpLines();
94  // void moveEvent(QMoveEvent*);
95 
97 
98  double m_ScaleFactor;
99 
100  QLine *m_MainLine;
101 
102  std::vector<QLine *> m_SubDivisionLines;
103 
104  QPen m_Pen;
105 
107 };
108 
109 #endif
#define MITKQTOVERLAYS_EXPORT
A widget that draws a scale bar with subdivision lines for spatial reference.
~QmitkScalarBar() override
Destructor.
virtual void SetScaleFactor(double scale)
Sets the scale factor (mm per pixel) and resizes the bar accordingly.
void CleanUpLines()
void SetPen(const QPen &pen)
Sets the pen used to draw the scalar bar lines.
unsigned int m_NumberOfSubDivisions
void SetNumberOfSubdivisions(unsigned int subs)
Sets the number of subdivision tick marks.
alignment m_Alignment
virtual void SetAlignment(alignment align)
Sets the orientation of the scalar bar.
unsigned int GetNumberOfSubdivisions()
Returns the current number of subdivision tick marks.
std::vector< QLine * > m_SubDivisionLines
void paintEvent(QPaintEvent *event) override
alignment
Orientation of the scalar bar.
double m_ScaleFactor
void SetupGeometry(alignment align)
QmitkScalarBar(QWidget *parent=nullptr)
Constructor.