From 4c9e2acb020f12f8b739c3f67a4d825492b7f90e Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 14 Feb 2014 14:16:08 +0100 Subject: [PATCH] GAL::GetGridPoint() returns point in world coordinates. --- common/gal/graphics_abstraction_layer.cpp | 8 ++++---- common/view/wx_view_controls.cpp | 2 +- include/gal/graphics_abstraction_layer.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 9bc79b5ab7..7f57d652c4 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -237,10 +237,10 @@ void GAL::DrawGrid() VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const { - VECTOR2D pointWorld = ToWorld( aPoint ); + VECTOR2D gridPoint; - pointWorld.x = round( pointWorld.x / gridSize.x ) * gridSize.x; - pointWorld.y = round( pointWorld.y / gridSize.y ) * gridSize.y; + gridPoint.x = round( aPoint.x / gridSize.x ) * gridSize.x; + gridPoint.y = round( aPoint.y / gridSize.y ) * gridSize.y; - return ToScreen( pointWorld ); + return gridPoint; } diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index df8b9849c3..4ecfa953fd 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -247,7 +247,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const VECTOR2D mousePosition = GetMousePosition(); if( m_snappingEnabled ) - return m_view->ToWorld( m_view->GetGAL()->GetGridPoint( mousePosition ) ); + return m_view->GetGAL()->GetGridPoint( m_view->ToWorld( mousePosition ) ); else return m_view->ToWorld( mousePosition ); } diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 5b6c656e32..d49e5e2fad 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -717,15 +717,15 @@ public: gridLineWidth = aGridLineWidth; } - /// @brief Draw the grid + ///> @brief Draw the grid void DrawGrid(); /** * Function GetGridPoint() - * For a given point it returns the nearest point belonging to the grid in screen coordinates. + * For a given point it returns the nearest point belonging to the grid in world coordinates. * * @param aPoint is the point for which the grid point is searched. - * @return The nearest grid point in screen coordinates. + * @return The nearest grid point in world coordinates. */ VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;