mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Set a sensible font size for Plot symbol labels (i.e. "P10", "P90" etc)
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "RiuQwtSymbol.h"
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QPainter>
|
||||
@@ -26,10 +28,11 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal class to support labels on symbols
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition )
|
||||
RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition, int labelFontSizePt )
|
||||
: QwtSymbol( QwtSymbol::NoSymbol )
|
||||
, m_globalLabel( label )
|
||||
, m_labelPosition( labelPosition )
|
||||
, m_labelFontSizePx( RiaFontCache::pointSizeToPixelSize( labelFontSizePt ) )
|
||||
{
|
||||
QwtSymbol::Style style = QwtSymbol::NoSymbol;
|
||||
|
||||
@@ -149,10 +152,16 @@ void RiuQwtSymbol::renderSymbols( QPainter* painter, const QPointF* points, int
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtSymbol::renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const
|
||||
{
|
||||
painter->save();
|
||||
QFont font = painter->font();
|
||||
font.setPixelSize( m_labelFontSizePx );
|
||||
painter->setFont( font );
|
||||
|
||||
QSize symbolSize = QwtSymbol::size();
|
||||
QRect symbolRect( position.x(), position.y(), symbolSize.width(), symbolSize.height() );
|
||||
QRect labelRect = labelBoundingRect( painter, symbolRect, label );
|
||||
painter->drawText( labelRect.topLeft(), label );
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -60,7 +60,10 @@ public:
|
||||
SYMBOL_RIGHT_TRIANGLE
|
||||
};
|
||||
|
||||
RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition = LabelAboveSymbol );
|
||||
RiuQwtSymbol( PointSymbolEnum riuStyle,
|
||||
const QString& label,
|
||||
LabelPosition labelPosition = LabelAboveSymbol,
|
||||
int labelFontSizePt = 8 );
|
||||
void renderSymbols( QPainter* painter, const QPointF* points, int numPoints ) const override;
|
||||
void renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const;
|
||||
QString globalLabel() const;
|
||||
@@ -79,5 +82,6 @@ private:
|
||||
|
||||
private:
|
||||
QString m_globalLabel;
|
||||
int m_labelFontSizePx;
|
||||
LabelPosition m_labelPosition;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user