gal: Draw grid from edge to edge
Fixes: lp:1677211 * https://bugs.launchpad.net/kicad/+bug/1677211
This commit is contained in:
parent
f4f0c09fe4
commit
7741b90c78
|
@ -269,6 +269,10 @@ void GAL::DrawGrid()
|
||||||
if( gridStartY > gridEndY )
|
if( gridStartY > gridEndY )
|
||||||
std::swap( gridStartY, gridEndY );
|
std::swap( gridStartY, gridEndY );
|
||||||
|
|
||||||
|
// Ensure the grid fills the screen
|
||||||
|
--gridStartX; ++gridEndX;
|
||||||
|
--gridStartY; ++gridEndY;
|
||||||
|
|
||||||
// Draw the grid behind all other layers
|
// Draw the grid behind all other layers
|
||||||
SetLayerDepth( depthRange.y * 0.75 );
|
SetLayerDepth( depthRange.y * 0.75 );
|
||||||
|
|
||||||
|
@ -281,7 +285,7 @@ void GAL::DrawGrid()
|
||||||
// Now draw the grid, every coarse grid line gets the double width
|
// Now draw the grid, every coarse grid line gets the double width
|
||||||
|
|
||||||
// Vertical lines
|
// Vertical lines
|
||||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||||
{
|
{
|
||||||
const double y = j * gridSize.y + gridOrigin.y;
|
const double y = j * gridSize.y + gridOrigin.y;
|
||||||
|
|
||||||
|
@ -302,7 +306,7 @@ void GAL::DrawGrid()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal lines
|
// Horizontal lines
|
||||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||||
{
|
{
|
||||||
const double x = i * gridSize.x + gridOrigin.x;
|
const double x = i * gridSize.x + gridOrigin.x;
|
||||||
|
|
||||||
|
@ -332,7 +336,7 @@ void GAL::DrawGrid()
|
||||||
double lineLen = GetLineWidth() * 2;
|
double lineLen = GetLineWidth() * 2;
|
||||||
|
|
||||||
// Vertical positions:
|
// Vertical positions:
|
||||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||||
{
|
{
|
||||||
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||||
|| gridScreenSizeDense > gridThreshold )
|
|| gridScreenSizeDense > gridThreshold )
|
||||||
|
@ -340,7 +344,7 @@ void GAL::DrawGrid()
|
||||||
int posY = j * gridSize.y + gridOrigin.y;
|
int posY = j * gridSize.y + gridOrigin.y;
|
||||||
|
|
||||||
// Horizontal positions:
|
// Horizontal positions:
|
||||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||||
{
|
{
|
||||||
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||||
|| gridScreenSizeDense > gridThreshold )
|
|| gridScreenSizeDense > gridThreshold )
|
||||||
|
@ -364,14 +368,14 @@ void GAL::DrawGrid()
|
||||||
SetIsStroke( false );
|
SetIsStroke( false );
|
||||||
SetFillColor( gridColor );
|
SetFillColor( gridColor );
|
||||||
|
|
||||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||||
{
|
{
|
||||||
if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
||||||
tickY = true;
|
tickY = true;
|
||||||
else
|
else
|
||||||
tickY = false;
|
tickY = false;
|
||||||
|
|
||||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||||
{
|
{
|
||||||
if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
||||||
tickX = true;
|
tickX = true;
|
||||||
|
|
|
@ -1032,6 +1032,10 @@ void OPENGL_GAL::DrawGrid()
|
||||||
if( gridStartY > gridEndY )
|
if( gridStartY > gridEndY )
|
||||||
std::swap( gridStartY, gridEndY );
|
std::swap( gridStartY, gridEndY );
|
||||||
|
|
||||||
|
// Ensure the grid fills the screen
|
||||||
|
--gridStartX; ++gridEndX;
|
||||||
|
--gridStartY; ++gridEndY;
|
||||||
|
|
||||||
glDisable( GL_DEPTH_TEST );
|
glDisable( GL_DEPTH_TEST );
|
||||||
glDisable( GL_TEXTURE_2D );
|
glDisable( GL_TEXTURE_2D );
|
||||||
|
|
||||||
|
@ -1056,7 +1060,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
int lineLen = KiROUND( minorLineWidth / worldScale * 2 );
|
int lineLen = KiROUND( minorLineWidth / worldScale * 2 );
|
||||||
|
|
||||||
// Vertical positions
|
// Vertical positions
|
||||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||||
{
|
{
|
||||||
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||||
|| gridScreenSizeDense > gridThreshold )
|
|| gridScreenSizeDense > gridThreshold )
|
||||||
|
@ -1064,7 +1068,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
int posY = j * gridSize.y + gridOrigin.y;
|
int posY = j * gridSize.y + gridOrigin.y;
|
||||||
|
|
||||||
// Horizontal positions
|
// Horizontal positions
|
||||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||||
{
|
{
|
||||||
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||||
|| gridScreenSizeDense > gridThreshold )
|
|| gridScreenSizeDense > gridThreshold )
|
||||||
|
@ -1085,7 +1089,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Vertical lines
|
// Vertical lines
|
||||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||||
{
|
{
|
||||||
const double y = j * gridSize.y + gridOrigin.y;
|
const double y = j * gridSize.y + gridOrigin.y;
|
||||||
|
|
||||||
|
@ -1115,7 +1119,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal lines
|
// Horizontal lines
|
||||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||||
{
|
{
|
||||||
const double x = i * gridSize.x + gridOrigin.x;
|
const double x = i * gridSize.x + gridOrigin.x;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue