From c5d3376c261726b1f70227e48b2d46e33f5ded87 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 11 Sep 2013 11:34:10 +0200 Subject: [PATCH] Changed some 'magic numbers' into constants. Added const modifier in appropriate spots. --- common/gal/graphics_abstraction_layer.cpp | 5 ++--- common/worksheet.cpp | 2 +- eeschema/schframe.cpp | 2 +- include/gal/graphics_abstraction_layer.h | 6 ++++++ include/painter.h | 2 +- include/wxEeschemaStruct.h | 2 +- include/wxstruct.h | 2 +- pcbnew/tools/selection_area.h | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 0a4c9a4dd9..0282e69327 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -29,7 +29,6 @@ #include #include - using namespace KiGfx; GAL::GAL() : @@ -41,7 +40,7 @@ GAL::GAL() : SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) ); SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetZoomFactor( 1.0 ); - SetDepthRange( VECTOR2D( -2048, 2047 ) ); + SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) ); SetFlip( false, false ); SetLineWidth( 1.0 ); @@ -114,7 +113,7 @@ void GAL::DrawGrid() // Draw the origin marker double origSize = static_cast( gridOriginMarkerSize ) / worldScale; - SetLayerDepth( 0.0 ); + SetLayerDepth( GAL::GRID_DEPTH ); SetIsFill( false ); SetIsStroke( true ); SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 4e2b1d116c..75f65b25cc 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -101,7 +101,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi } -wxString EDA_DRAW_FRAME::GetScreenDesc() +wxString EDA_DRAW_FRAME::GetScreenDesc() const { // Virtual function. In basic class, returns // an empty string. diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 653709f516..b295d8ec04 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -324,7 +324,7 @@ SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const } -wxString SCH_EDIT_FRAME::GetScreenDesc() +wxString SCH_EDIT_FRAME::GetScreenDesc() const { wxString s = m_CurrentSheet->PathHumanReadable(); diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 2b87606de0..77cb3c48a8 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -818,6 +818,9 @@ public: depthStack.pop(); } + /// Depth level on which the grid is drawn + static const int GRID_DEPTH = 1024; + protected: std::stack depthStack; ///< Stored depth values VECTOR2D screenSize; ///< Screen size in screen coordinates @@ -884,6 +887,9 @@ protected: * @param aCursorSize is the size of the cursor. */ virtual void initCursor( int aCursorSize ) = 0; + + static const int MIN_DEPTH = -2048; + static const int MAX_DEPTH = 2047; }; } // namespace KiGfx diff --git a/include/painter.h b/include/painter.h index d546981369..3a8a7c392f 100644 --- a/include/painter.h +++ b/include/painter.h @@ -195,7 +195,7 @@ public: * Returns pointer to current settings that are going to be used when drawing items. * @return Current rendering settings. */ - virtual RENDER_SETTINGS* GetSettings() + virtual RENDER_SETTINGS* GetSettings() const { return m_settings; } diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 8607c835f7..bcd4194409 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -356,7 +356,7 @@ public: */ void OnModify(); - virtual wxString GetScreenDesc(); + virtual wxString GetScreenDesc() const; void InstallConfigFrame( wxCommandEvent& event ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 6cdd0fec65..d5dfd47842 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -499,7 +499,7 @@ public: EDA_DRAW_PANEL* GetCanvas() { return m_canvas; } - virtual wxString GetScreenDesc(); + virtual wxString GetScreenDesc() const; /** * Function GetScreen diff --git a/pcbnew/tools/selection_area.h b/pcbnew/tools/selection_area.h index 8cc380b4ab..28bf0f8b63 100644 --- a/pcbnew/tools/selection_area.h +++ b/pcbnew/tools/selection_area.h @@ -63,7 +63,7 @@ public: m_end = aEnd; } - void Show( int x, std::ostream& st) const + void Show( int x, std::ostream& st ) const { }