grid: Set grid to use integer pixels

Each dot is an integer number of pixels wide, so supporting 0.5 width
steps no longer makes sense.  We round up the existing settings to the
nearest integer and only allow integers in the dialog.

Fixes: lp:1816748
* https://bugs.launchpad.net/kicad/+bug/1816748
This commit is contained in:
Seth Hillbrand 2019-02-23 19:26:04 -08:00
parent 1be759c5c1
commit 30612ca62d
3 changed files with 7 additions and 7 deletions

View File

@ -51,7 +51,7 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
: gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ), : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ), cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
m_gridStyle( GRID_STYLE::DOTS ), m_gridStyle( GRID_STYLE::DOTS ),
m_gridLineWidth( 0.5 ), m_gridLineWidth( 1.0 ),
m_gridMinSpacing( 10.0 ), m_gridMinSpacing( 10.0 ),
m_axesEnabled( false ), m_axesEnabled( false ),
m_fullscreenCursor( false ), m_fullscreenCursor( false ),
@ -67,7 +67,7 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, const wxString& aBaseN
static_cast<long>( KIGFX::GRID_STYLE::DOTS ) ); static_cast<long>( KIGFX::GRID_STYLE::DOTS ) );
m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, readLong ); m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, readLong );
aCfg->Read( aBaseName + GalGridLineWidthConfig, &m_gridLineWidth, 0.5 ); aCfg->Read( aBaseName + GalGridLineWidthConfig, &m_gridLineWidth, 1.0 );
aCfg->Read( aBaseName + GalGridMaxDensityConfig, &m_gridMinSpacing, 10 ); aCfg->Read( aBaseName + GalGridMaxDensityConfig, &m_gridMinSpacing, 10 );
aCfg->Read( aBaseName + GalGridAxesEnabledConfig, &m_axesEnabled, false ); aCfg->Read( aBaseName + GalGridAxesEnabledConfig, &m_axesEnabled, false );
aCfg->Read( aBaseName + GalFullscreenCursorConfig, &m_fullscreenCursor, false ); aCfg->Read( aBaseName + GalFullscreenCursorConfig, &m_fullscreenCursor, false );

View File

@ -108,7 +108,7 @@ bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
if( options.m_gridLineWidth != gridLineWidth ) if( options.m_gridLineWidth != gridLineWidth )
{ {
gridLineWidth = options.m_gridLineWidth ; gridLineWidth = std::floor( options.m_gridLineWidth + 0.5 );
refresh = true; refresh = true;
} }

View File

@ -32,9 +32,9 @@
/* /*
* Spin control parameters * Spin control parameters
*/ */
static const double gridThicknessMin = 0.5; static const double gridThicknessMin = 1.0;
static const double gridThicknessMax = 10.0; static const double gridThicknessMax = 10.0;
static const double gridThicknessStep = 0.5; static const double gridThicknessStep = 1.0;
static const double gridMinSpacingMin = 5; static const double gridMinSpacingMin = 5;
static const double gridMinSpacingMax = 200; static const double gridMinSpacingMax = 200;
@ -134,7 +134,7 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI
m_gridSizeIncrementer->SetStep( gridThicknessMin, gridThicknessMax, m_gridSizeIncrementer->SetStep( gridThicknessMin, gridThicknessMax,
gridThicknessStep ); gridThicknessStep );
m_gridSizeIncrementer->SetPrecision( 1 ); m_gridSizeIncrementer->SetPrecision( 0 );
m_gridMinSpacingIncrementer = std::make_unique<SPIN_INCREMENTAL_TEXT_CTRL>( m_gridMinSpacingIncrementer = std::make_unique<SPIN_INCREMENTAL_TEXT_CTRL>(
*m_gridMinSpacingSpinBtn, *m_gridMinSpacing ); *m_gridMinSpacingSpinBtn, *m_gridMinSpacing );
@ -214,7 +214,7 @@ bool GAL_OPTIONS_PANEL::TransferDataFromWindow()
m_galOptions.m_gridStyle = UTIL::GetValFromConfig( m_galOptions.m_gridStyle = UTIL::GetValFromConfig(
gridStyleSelectMap, m_gridStyle->GetSelection() ); gridStyleSelectMap, m_gridStyle->GetSelection() );
m_galOptions.m_gridLineWidth = m_gridSizeIncrementer->GetValue(); m_galOptions.m_gridLineWidth = std::floor( m_gridSizeIncrementer->GetValue() + 0.5 );
m_galOptions.m_gridMinSpacing = m_gridMinSpacingIncrementer->GetValue(); m_galOptions.m_gridMinSpacing = m_gridMinSpacingIncrementer->GetValue();