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
|
@ -257,10 +257,10 @@ void GAL::DrawGrid()
|
|||
// Compute grid staring and ending indexes to draw grid points on the
|
||||
// visible screen area
|
||||
// Note: later any point coordinate will be offsetted by gridOrigin
|
||||
int gridStartX = KiROUND( (worldStartPoint.x-gridOrigin.x) / gridSize.x );
|
||||
int gridEndX = KiROUND( (worldEndPoint.x-gridOrigin.x) / gridSize.x );
|
||||
int gridStartY = KiROUND( (worldStartPoint.y-gridOrigin.y) / gridSize.y );
|
||||
int gridEndY = KiROUND( (worldEndPoint.y-gridOrigin.y) / gridSize.y );
|
||||
int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridSize.x );
|
||||
int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridSize.x );
|
||||
int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridSize.y );
|
||||
int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridSize.y );
|
||||
|
||||
// Ensure start coordinate > end coordinate
|
||||
if( gridStartX > gridEndX )
|
||||
|
@ -269,6 +269,10 @@ void GAL::DrawGrid()
|
|||
if( gridStartY > gridEndY )
|
||||
std::swap( gridStartY, gridEndY );
|
||||
|
||||
// Ensure the grid fills the screen
|
||||
--gridStartX; ++gridEndX;
|
||||
--gridStartY; ++gridEndY;
|
||||
|
||||
// Draw the grid behind all other layers
|
||||
SetLayerDepth( depthRange.y * 0.75 );
|
||||
|
||||
|
@ -281,7 +285,7 @@ void GAL::DrawGrid()
|
|||
// Now draw the grid, every coarse grid line gets the double width
|
||||
|
||||
// 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;
|
||||
|
||||
|
@ -302,7 +306,7 @@ void GAL::DrawGrid()
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
@ -332,7 +336,7 @@ void GAL::DrawGrid()
|
|||
double lineLen = GetLineWidth() * 2;
|
||||
|
||||
// Vertical positions:
|
||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
||||
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||
{
|
||||
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||
|| gridScreenSizeDense > gridThreshold )
|
||||
|
@ -340,7 +344,7 @@ void GAL::DrawGrid()
|
|||
int posY = j * gridSize.y + gridOrigin.y;
|
||||
|
||||
// Horizontal positions:
|
||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
||||
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||
{
|
||||
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||
|| gridScreenSizeDense > gridThreshold )
|
||||
|
@ -364,14 +368,14 @@ void GAL::DrawGrid()
|
|||
SetIsStroke( false );
|
||||
SetFillColor( gridColor );
|
||||
|
||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
||||
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||
{
|
||||
if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
||||
tickY = true;
|
||||
else
|
||||
tickY = false;
|
||||
|
||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
||||
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||
{
|
||||
if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
||||
tickX = true;
|
||||
|
|
|
@ -1020,10 +1020,10 @@ void OPENGL_GAL::DrawGrid()
|
|||
// Compute grid staring and ending indexes to draw grid points on the
|
||||
// visible screen area
|
||||
// Note: later any point coordinate will be offsetted by gridOrigin
|
||||
int gridStartX = KiROUND( (worldStartPoint.x-gridOrigin.x) / gridSize.x );
|
||||
int gridEndX = KiROUND( (worldEndPoint.x-gridOrigin.x) / gridSize.x );
|
||||
int gridStartY = KiROUND( (worldStartPoint.y-gridOrigin.y) / gridSize.y );
|
||||
int gridEndY = KiROUND( (worldEndPoint.y-gridOrigin.y) / gridSize.y );
|
||||
int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridSize.x );
|
||||
int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridSize.x );
|
||||
int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridSize.y );
|
||||
int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridSize.y );
|
||||
|
||||
// Ensure start coordinate > end coordinate
|
||||
if( gridStartX > gridEndX )
|
||||
|
@ -1032,6 +1032,10 @@ void OPENGL_GAL::DrawGrid()
|
|||
if( gridStartY > gridEndY )
|
||||
std::swap( gridStartY, gridEndY );
|
||||
|
||||
// Ensure the grid fills the screen
|
||||
--gridStartX; ++gridEndX;
|
||||
--gridStartY; ++gridEndY;
|
||||
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
|
||||
|
@ -1053,10 +1057,10 @@ void OPENGL_GAL::DrawGrid()
|
|||
|
||||
// calculate a line len = 2 minorLineWidth, in internal unit value
|
||||
// (in fact the size of cross is lineLen*2)
|
||||
int lineLen = KiROUND( minorLineWidth / worldScale *2 );
|
||||
int lineLen = KiROUND( minorLineWidth / worldScale * 2 );
|
||||
|
||||
// Vertical positions
|
||||
for( int j = gridStartY-1; j <= gridEndY; j++ )
|
||||
for( int j = gridStartY; j <= gridEndY; j++ )
|
||||
{
|
||||
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||
|| gridScreenSizeDense > gridThreshold )
|
||||
|
@ -1064,7 +1068,7 @@ void OPENGL_GAL::DrawGrid()
|
|||
int posY = j * gridSize.y + gridOrigin.y;
|
||||
|
||||
// Horizontal positions
|
||||
for( int i = gridStartX-1; i <= gridEndX; i++ )
|
||||
for( int i = gridStartX; i <= gridEndX; i++ )
|
||||
{
|
||||
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
||||
|| gridScreenSizeDense > gridThreshold )
|
||||
|
@ -1085,7 +1089,7 @@ void OPENGL_GAL::DrawGrid()
|
|||
else
|
||||
{
|
||||
// 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;
|
||||
|
||||
|
@ -1115,7 +1119,7 @@ void OPENGL_GAL::DrawGrid()
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue