From ff3bfaf82b494bfa6b6ab1b2e1b39b69b5903a2b Mon Sep 17 00:00:00 2001 From: John Beard Date: Thu, 16 Feb 2017 10:50:34 +0800 Subject: [PATCH] Make KIGFX::GRID_STYLE an enum class This provides stronger typing to these values. --- common/gal/gal_display_options.cpp | 4 ++-- common/gal/graphics_abstraction_layer.cpp | 4 ++-- common/gal/opengl/opengl_gal.cpp | 6 +++--- include/gal/gal_display_options.h | 8 ++++---- pcbnew/dialogs/dialog_display_options.cpp | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common/gal/gal_display_options.cpp b/common/gal/gal_display_options.cpp index 0b94ae819c..3befa9281d 100644 --- a/common/gal/gal_display_options.cpp +++ b/common/gal/gal_display_options.cpp @@ -35,7 +35,7 @@ static const wxString GalGridStyleConfig( "GridStyle" ); GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS() : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ), - m_gridStyle( GRID_STYLE_DOTS ) + m_gridStyle( GRID_STYLE::DOTS ) {} @@ -47,7 +47,7 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName ) aCfg->Read( aBaseName + GalGridStyleConfig, reinterpret_cast( &m_gridStyle ), - static_cast( KIGFX::GRID_STYLE::GRID_STYLE_DOTS ) ); + static_cast( KIGFX::GRID_STYLE::DOTS ) ); NotifyChanged(); } diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 9f33d68ef6..fe14af6eab 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -61,7 +61,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : SetGridDrawThreshold( 10 ); SetCoarseGrid( 10 ); SetGridLineWidth( 0.5 ); - gridStyle = GRID_STYLE_LINES; + gridStyle = GRID_STYLE::LINES; // Initialize the cursor shape SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); @@ -202,7 +202,7 @@ void GAL::DrawGrid() // Draw the grid behind all other layers SetLayerDepth( depthRange.y * 0.75 ); - if( gridStyle == GRID_STYLE_LINES ) + if( gridStyle == GRID_STYLE::LINES ) { SetIsFill( false ); SetIsStroke( true ); diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 7c18071ded..e6bcfcdbc1 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -888,7 +888,7 @@ void OPENGL_GAL::DrawGrid() glDisable( GL_DEPTH_TEST ); glDisable( GL_TEXTURE_2D ); - if( gridStyle == GRID_STYLE_DOTS ) + if( gridStyle == GRID_STYLE::DOTS ) { glEnable( GL_STENCIL_TEST ); glStencilFunc( GL_ALWAYS, 1, 1 ); @@ -918,7 +918,7 @@ void OPENGL_GAL::DrawGrid() } } - if( gridStyle == GRID_STYLE_DOTS ) + if( gridStyle == GRID_STYLE::DOTS ) { glStencilFunc( GL_NOTEQUAL, 0, 1 ); glColor4d( gridColor.r, gridColor.g, gridColor.b, 1.0 ); @@ -942,7 +942,7 @@ void OPENGL_GAL::DrawGrid() } } - if( gridStyle == GRID_STYLE_DOTS ) + if( gridStyle == GRID_STYLE::DOTS ) glDisable( GL_STENCIL_TEST ); glEnable( GL_DEPTH_TEST ); diff --git a/include/gal/gal_display_options.h b/include/gal/gal_display_options.h index 9c2c94c2d1..3694853e14 100644 --- a/include/gal/gal_display_options.h +++ b/include/gal/gal_display_options.h @@ -32,12 +32,12 @@ class wxString; namespace KIGFX { /** - * GridStyle: Type definition of the grid style + * GRID_STYLE: Type definition of the grid style */ - enum GRID_STYLE + enum class GRID_STYLE { - GRID_STYLE_LINES, ///< Use lines for the grid - GRID_STYLE_DOTS ///< Use dots for the grid + LINES, ///< Use lines for the grid + DOTS ///< Use dots for the grid }; enum class OPENGL_ANTIALIASING_MODE : long diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index 6df858cb44..72bdf48248 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -47,13 +47,13 @@ static void setRadioFromGridStyle( wxRadioBox& aRBox, KIGFX::GRID_STYLE aStyle ) { - aRBox.SetSelection( aStyle != KIGFX::GRID_STYLE_DOTS ); + aRBox.SetSelection( aStyle != KIGFX::GRID_STYLE::DOTS ); } static KIGFX::GRID_STYLE getGridStyleFromRadio( const wxRadioBox& aRBox ) { - return aRBox.GetSelection() == 0 ? KIGFX::GRID_STYLE_DOTS : KIGFX::GRID_STYLE_LINES; + return aRBox.GetSelection() == 0 ? KIGFX::GRID_STYLE::DOTS : KIGFX::GRID_STYLE::LINES; }