mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Fix missing display of legends in Qt 6.9
Updates the Qwt subproject to the latest commit to incorporate necessary fixes and improvements for legend-related issues in Qt6.
This commit is contained in:
@@ -284,6 +284,54 @@ void RiuQwtPlotCurve::setColor( const QColor& color )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtGraphic RiuQwtPlotCurve::legendIcon( int index, const QSizeF& size ) const
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
|
||||
if ( size.isEmpty() ) return QwtGraphic();
|
||||
|
||||
// Qt 6.9 fix: For symbol-only curves (no line), we need explicit rendering
|
||||
// because the standard Qwt rendering has issues with NoCurve style
|
||||
bool hasLine = testLegendAttribute( QwtPlotCurve::LegendShowLine ) && ( pen().style() != Qt::NoPen );
|
||||
bool hasSymbol = symbol() && ( symbol()->style() != QwtSymbol::NoSymbol );
|
||||
bool isSymbolOnlyIcon = !hasLine && hasSymbol;
|
||||
|
||||
if ( isSymbolOnlyIcon )
|
||||
{
|
||||
// Qt 6.9 workaround: Bypass QwtGraphic rendering issues by drawing to QPixmap first
|
||||
QPixmap pixmap( size.toSize() );
|
||||
pixmap.fill( Qt::transparent );
|
||||
|
||||
{
|
||||
QPainter pixPainter( &pixmap );
|
||||
pixPainter.setRenderHint( QPainter::Antialiasing, testRenderHint( QwtPlotItem::RenderAntialiased ) );
|
||||
|
||||
// Draw symbol directly to pixmap
|
||||
QRectF symbolRect( 0, 0, size.width(), size.height() );
|
||||
symbol()->drawSymbol( &pixPainter, symbolRect );
|
||||
}
|
||||
|
||||
// Convert pixmap to QwtGraphic
|
||||
QwtGraphic graphic;
|
||||
graphic.setDefaultSize( size );
|
||||
|
||||
{
|
||||
QPainter graphicPainter( &graphic );
|
||||
|
||||
if ( m_blackAndWhiteLegendIcon )
|
||||
{
|
||||
QImage image = pixmap.toImage();
|
||||
RiaImageTools::makeGrayScale( image );
|
||||
graphicPainter.drawImage( QPoint( 0, 0 ), image );
|
||||
}
|
||||
else
|
||||
{
|
||||
graphicPainter.drawPixmap( QPoint( 0, 0 ), pixmap );
|
||||
}
|
||||
}
|
||||
|
||||
return graphic;
|
||||
}
|
||||
|
||||
// Use standard Qwt rendering for curves with lines
|
||||
QwtGraphic icon = QwtPlotCurve::legendIcon( index, size );
|
||||
if ( m_blackAndWhiteLegendIcon )
|
||||
{
|
||||
|
||||
Vendored
+1
-1
Submodule ThirdParty/qwt updated: eb4316bea1...2e1ab86284
Reference in New Issue
Block a user