diff --git a/ApplicationCode/UserInterface/RiuQwtSymbol.cpp b/ApplicationCode/UserInterface/RiuQwtSymbol.cpp index 092f8df2eb..e46f3d6cff 100644 --- a/ApplicationCode/UserInterface/RiuQwtSymbol.cpp +++ b/ApplicationCode/UserInterface/RiuQwtSymbol.cpp @@ -19,6 +19,8 @@ #include "RiuQwtSymbol.h" +#include "cvfAssert.h" + #include //-------------------------------------------------------------------------------------------------- @@ -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) diff --git a/ApplicationCode/UserInterface/RiuQwtSymbol.h b/ApplicationCode/UserInterface/RiuQwtSymbol.h index d9e813a927..c3f7986645 100644 --- a/ApplicationCode/UserInterface/RiuQwtSymbol.h +++ b/ApplicationCode/UserInterface/RiuQwtSymbol.h @@ -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;