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:
parent
4829c5eba2
commit
993b98f977
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaCurveDataTools.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
@ -658,7 +659,10 @@ void RimPlotCurve::updateCurveAppearance()
|
||||
if ( m_pointSymbol() != RiuQwtSymbol::SYMBOL_NONE )
|
||||
{
|
||||
// QwtPlotCurve will take ownership of the symbol
|
||||
symbol = new RiuQwtSymbol( m_pointSymbol(), m_symbolLabel(), m_symbolLabelPosition() );
|
||||
symbol = new RiuQwtSymbol( m_pointSymbol(),
|
||||
m_symbolLabel(),
|
||||
m_symbolLabelPosition(),
|
||||
RiaApplication::instance()->preferences()->defaultPlotFontSize() );
|
||||
symbol->setSize( m_symbolSize, m_symbolSize );
|
||||
symbol->setColor( curveColor );
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user