From daf103d7e4356c8fb565f0217f6070f116154d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Thu, 8 Dec 2016 22:55:06 +0100 Subject: [PATCH] GAL: fix grid origin and grid rendering in flipped view mode --- common/gal/graphics_abstraction_layer.cpp | 13 ++++++++++--- common/gal/opengl/opengl_gal.cpp | 11 +++++++++-- common/origin_viewitem.cpp | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index a4432f66c7..e13792436e 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -122,7 +122,6 @@ void GAL::ComputeWorldScreenMatrix() screenWorldMatrix = worldScreenMatrix.Inverse(); } - void GAL::DrawGrid() { if( !gridVisibility ) @@ -153,11 +152,19 @@ void GAL::DrawGrid() int gridEndY = KiROUND( worldEndPoint.y / gridSize.y ); // Correct the index, else some lines are not correctly painted - gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + gridStartY -= std::abs( gridOrigin.y / gridSize.y ) + 1; - gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; gridEndY += std::abs( gridOrigin.y / gridSize.y ) + 1; + if ( gridStartX <= gridEndX ) + { + gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; + } else { + gridStartX += std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + } + int dirX = gridEndX >= gridStartX ? 1 : -1; int dirY = gridEndY >= gridStartY ? 1 : -1; diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 515050101c..8a2e881d22 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -880,11 +880,18 @@ void OPENGL_GAL::DrawGrid() int gridEndY = KiROUND( worldEndPoint.y / gridSize.y ); // Correct the index, else some lines are not correctly painted - gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; gridStartY -= std::abs( gridOrigin.y / gridSize.y ) + 1; - gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; gridEndY += std::abs( gridOrigin.y / gridSize.y ) + 1; + if ( gridStartX <= gridEndX ) + { + gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; + } else { + gridStartX += std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + } + int dirX = gridStartX >= gridEndX ? -1 : 1; int dirY = gridStartY >= gridEndY ? -1 : 1; diff --git a/common/origin_viewitem.cpp b/common/origin_viewitem.cpp index 3195c74564..08e5e66633 100644 --- a/common/origin_viewitem.cpp +++ b/common/origin_viewitem.cpp @@ -59,7 +59,7 @@ void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const // Draw a circle around the marker's centre point if the style demands it if( ( m_style == CIRCLE_CROSS ) || ( m_style == CIRCLE_DOT ) || ( m_style == CIRCLE_X ) ) - gal->DrawCircle( m_position, scaledSize.x ); + gal->DrawCircle( m_position, fabs( scaledSize.x ) ); switch( m_style ) {