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
This commit is contained in:
Seth Hillbrand 2022-12-21 12:02:35 -08:00
parent e28f6ecc00
commit fcc4b202db
1 changed files with 34 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#endif
#include <widgets/mathplot.h>
#include <wx/graphics.h>
#include <wx/module.h>
#include <wx/image.h>
@ -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 );