#3780 Get rid of debug output from painter

* don't really need the boundingRect override for RiuQwtSymbol
* And it needs a painter
* Just get rid of it and pass in the painter for the labelBoundingRect
This commit is contained in:
Gaute Lindkvist 2018-11-30 14:01:29 +01:00 committed by Magne Sjaastad
parent 1ffcca8f20
commit 2e8c2e28a8
2 changed files with 10 additions and 18 deletions

View File

@ -19,6 +19,8 @@
#include "RiuQwtSymbol.h"
#include "cvfAssert.h"
#include <QPainter>
//--------------------------------------------------------------------------------------------------
@ -130,7 +132,7 @@ void RiuQwtSymbol::renderSymbolLabel(QPainter *painter, const QPointF& position)
{
QSize symbolSize = QwtSymbol::size();
QRect symbolRect (position.x(), position.y(), symbolSize.width(), symbolSize.height());
QRect labelRect = labelBoundingRect(symbolRect);
QRect labelRect = labelBoundingRect(painter, symbolRect);
painter->drawText(labelRect.topLeft(), m_label);
}
@ -145,24 +147,16 @@ void RiuQwtSymbol::setLabelPosition(LabelPosition labelPosition)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QRect RiuQwtSymbol::boundingRect() const
QRect RiuQwtSymbol::labelBoundingRect(const QPainter* painter, const QRect& symbolRect) const
{
QRect symbolRect = QwtSymbol::boundingRect();
QRect labelRect = labelBoundingRect(symbolRect);
return symbolRect.united(labelRect);
}
CVF_ASSERT(painter);
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QRect RiuQwtSymbol::labelBoundingRect(const QRect& symbolRect) const
{
QPoint symbolPosition = symbolRect.topLeft();
int symbolWidth = symbolRect.width();
int labelWidth = QPainter().fontMetrics().width(m_label);
int labelHeight = QPainter().fontMetrics().height();
int labelWidth = painter->fontMetrics().width(m_label);
int labelHeight = painter->fontMetrics().height();
QPoint labelPosition;
if (m_labelPosition == LabelAboveSymbol)

View File

@ -55,15 +55,13 @@ public:
RiuQwtSymbol(PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition = LabelAboveSymbol);
void renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const override;
void renderSymbolLabel(QPainter *painter, const QPointF& position) const;
void renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const override;
void renderSymbolLabel(QPainter *painter, const QPointF& position) const;
QString label() const { return m_label; }
void setLabelPosition(LabelPosition labelPosition);
QRect boundingRect() const override;
private:
QRect labelBoundingRect(const QRect& symbolRect) const;
QRect labelBoundingRect(const QPainter* painter, const QRect& symbolRect) const;
private:
QString m_label;