From fcc4b202db7b01ca32ee7d23c7ebd7cc75b5c76e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 21 Dec 2022 12:02:35 -0800 Subject: [PATCH] Set interpolation/anti-alias in plots This doesn't do much for Linux, but the interpolation modes for MSW and Mac should clean up lines a bit in plotting Fixes https://gitlab.com/kicad/code/kicad/issues/10239 --- common/widgets/mathplot.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index bccb00c483..8e9cd46fdd 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -31,6 +31,7 @@ #endif #include +#include #include #include @@ -1633,6 +1634,16 @@ mpWindow::mpWindow() : wxWindow(), m_movingInfoLayer( nullptr ), m_zooming( false ) { + if( wxGraphicsContext *ctx = m_buff_dc.GetGraphicsContext() ) + { + if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST ) + || !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) ) + { + ctx->SetInterpolationQuality( wxINTERPOLATION_FAST ); + } + + ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT ); + } } mpWindow::mpWindow( wxWindow* parent, @@ -1680,6 +1691,17 @@ mpWindow::mpWindow( wxWindow* parent, // J.L.Blanco: Eliminates the "flick" with the double buffer. SetBackgroundStyle( wxBG_STYLE_CUSTOM ); + if( wxGraphicsContext* ctx = m_buff_dc.GetGraphicsContext() ) + { + if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST ) + || !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) ) + { + ctx->SetInterpolationQuality( wxINTERPOLATION_FAST ); + } + + ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT ); + } + UpdateAll(); } @@ -2345,6 +2367,18 @@ void mpWindow::OnPaint( wxPaintEvent& WXUNUSED( event ) ) // Draw background: // trgDc->SetDeviceOrigin(0,0); + + if( wxGraphicsContext* ctx = trgDc->GetGraphicsContext() ) + { + if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST ) + || !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) ) + { + ctx->SetInterpolationQuality( wxINTERPOLATION_FAST ); + } + + ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT ); + } + trgDc->SetPen( *wxTRANSPARENT_PEN ); wxBrush brush( GetBackgroundColour() ); trgDc->SetBrush( brush );