19 #include <QPaintEvent>
23 : QWidget(parent, Qt::Tool | Qt::FramelessWindowHint), m_Alignment(vertical), m_MainLine(nullptr)
27 this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
29 this->setBackgroundRole(QPalette::Base);
30 this->setAttribute(Qt::WA_TranslucentBackground,
true);
31 this->setAutoFillBackground(
false);
34 this->setAttribute(Qt::WA_X11NetWmWindowTypeUtility,
true);
38 this->setAttribute(Qt::WA_MacAlwaysShowToolWindow,
true);
40 this->setAttribute(Qt::WA_MacShowFocusRect,
false);
43 this->setFixedWidth(10);
44 this->setFixedHeight(61);
46 m_Pen = QPen(Qt::red, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
65 int y = this->height() / (m_NumberOfSubDivisions - 1) * i;
71 else if (i == m_NumberOfSubDivisions - 1)
74 y = this->height() - 1;
82 m_MainLine =
new QLine(QPoint(width() - 1, 0), QPoint(width() - 1, height()));
86 m_MainLine =
new QLine(QPoint(0, 0), QPoint(0, 0));
96 int x = this->width() / (m_NumberOfSubDivisions - 1) * i;
101 else if (i == m_NumberOfSubDivisions - 1)
103 x = this->width() - 1;
111 m_MainLine =
new QLine(QPoint(0, height() / 2), QPoint(width(), height() / 2));
115 m_MainLine =
new QLine(QPoint(0, 0), QPoint(0, 0));
145 if (this->parentWidget() !=
nullptr && this->parentWidget()->parentWidget() !=
nullptr)
153 else if (this->height() < this->parentWidget()->parentWidget()->height() * 0.4 &&
154 (m_NumberOfSubDivisions < 7 && m_NumberOfSubDivisions > 0))
162 this->setFixedWidth(0);
163 this->setFixedHeight(0);
168 this->setFixedWidth(10);
205 QPainter painter(
this);
206 painter.setPen(
m_Pen);
207 painter.setBrush(Qt::SolidPattern);
208 painter.setRenderHint(QPainter::Antialiasing,
true);
214 painter.drawLine(line->p1(), line->p2());
void SetPen(const QPen &pen)
QmitkScalarBar(QWidget *parent=nullptr)
Default Constructor.
void paintEvent(QPaintEvent *event) override
std::vector< QLine * > m_SubDivisionLines
unsigned int m_NumberOfSubDivisions
void SetupGeometry(alignment align)
virtual ~QmitkScalarBar()
Default Destructor.
void SetNumberOfSubdivisions(unsigned int subs)
virtual void SetScaleFactor(double scale)
virtual void SetAlignment(alignment align)
unsigned int GetNumberOfSubdivisions()