#include "logger.h"
#include "signaldrawer.h"
-
+#include <QFontMetrics>
#include <QDebug>
const QString SignalDrawer::ME_SENDER_STR("SignalDrawer");
}
p.begin(target);
+ p.setFont(m_axisLabelFont);
switch (axis) {
case SignalController::Axis::TIME:
relMin = m_relXMin; relMax = m_relXMax;
void SignalDrawer::renderTimeScaleText(QPainter* const p, const double rel, const double value)
{
const int xPix = relToXPix(rel);
+ const QString text = m_locale.toString(value, 'f', 3);
+ /* Do not draw labels that would overflow */
+ QRect br = p->fontMetrics().boundingRect(text);
+ if (xPix + br.width() > m_gWidth)
+ return;
p->drawText(xPix + 2, m_gHeight + 15, m_locale.toString(value, 'f', 3));
}
void SignalDrawer::renderValueScaleText(QPainter* const p, const double rel, const double value)
{
const int yPix = relToYPix(rel);
+ const QString text = m_locale.toString(value, 'f', 2);
+
+ /* Do not draw labels that would overflow */
+ QRect br = p->fontMetrics().boundingRect(text);
+ if (yPix - br.height() < 0)
+ return;
p->drawText(1, yPix + 5, m_locale.toString(value, 'f', 2));
}