Fixed a minor artefact when redraw the grid after a scrool.
This commit is contained in:
commit
bff752e7bf
|
@ -34,7 +34,6 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
|
||||||
m_Zoom = 32 * m_ZoomScalar;
|
m_Zoom = 32 * m_ZoomScalar;
|
||||||
m_Grid.m_Size = wxRealPoint( 50, 50 ); /* Default grid size */
|
m_Grid.m_Size = wxRealPoint( 50, 50 ); /* Default grid size */
|
||||||
m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50;
|
m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50;
|
||||||
m_UserGridIsON = FALSE;
|
|
||||||
m_Center = true;
|
m_Center = true;
|
||||||
m_CurrentSheetDesc = &g_Sheet_A4;
|
m_CurrentSheetDesc = &g_Sheet_A4;
|
||||||
m_IsPrinting = false;
|
m_IsPrinting = false;
|
||||||
|
|
|
@ -758,11 +758,13 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
|
||||||
*/
|
*/
|
||||||
void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
{
|
{
|
||||||
|
#define MIN_GRID_SIZE 10 // min grid size in pixels to allow drawing
|
||||||
BASE_SCREEN* screen = GetScreen();
|
BASE_SCREEN* screen = GetScreen();
|
||||||
int ii, jj, xg, yg;
|
int ii, jj, xg, yg;
|
||||||
wxRealPoint screen_grid_size;
|
wxRealPoint screen_grid_size;
|
||||||
wxSize size;
|
wxSize size;
|
||||||
wxPoint org;
|
wxPoint org;
|
||||||
|
wxRealPoint dgrid;
|
||||||
|
|
||||||
/* The grid must be visible. this is possible only is grid value
|
/* The grid must be visible. this is possible only is grid value
|
||||||
* and zoom value are sufficient
|
* and zoom value are sufficient
|
||||||
|
@ -773,43 +775,50 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
size = GetClientSize();
|
size = GetClientSize();
|
||||||
|
|
||||||
#ifdef USE_WX_ZOOM
|
#ifdef USE_WX_ZOOM
|
||||||
if( DC->LogicalToDeviceXRel( wxRound( screen_grid_size.x ) ) < 5
|
dgrid.x = DC->LogicalToDeviceXRel( wxRound( screen_grid_size.x ) );
|
||||||
|| DC->LogicalToDeviceXRel( wxRound( screen_grid_size.y ) ) < 5 )
|
dgrid.y = DC->LogicalToDeviceXRel( wxRound( screen_grid_size.y ) );
|
||||||
return;
|
|
||||||
|
|
||||||
org = m_ClipBox.m_Pos;
|
org = m_ClipBox.m_Pos;
|
||||||
size = m_ClipBox.m_Size;
|
size = m_ClipBox.m_Size;
|
||||||
#else
|
#else
|
||||||
wxRealPoint dgrid = screen_grid_size;
|
dgrid = screen_grid_size;
|
||||||
screen->Scale( dgrid ); // dgrid = grid size in pixels
|
screen->Scale( dgrid ); // dgrid = grid size in pixels
|
||||||
|
|
||||||
// if the grid size is small ( < 5 pixels) do not display all points
|
|
||||||
if( dgrid.x < 5 )
|
|
||||||
{
|
|
||||||
screen_grid_size.x *= 2;
|
|
||||||
dgrid.x *= 2;
|
|
||||||
}
|
|
||||||
if( dgrid.x < 5 )
|
|
||||||
return; // The grid is too small: do not show it
|
|
||||||
|
|
||||||
if( dgrid.y < 5 )
|
|
||||||
{
|
|
||||||
screen_grid_size.y *= 2;
|
|
||||||
dgrid.y *= 2;
|
|
||||||
}
|
|
||||||
if( dgrid.y < 5 )
|
|
||||||
return; // The grid is too small
|
|
||||||
|
|
||||||
|
|
||||||
screen->Unscale( size );
|
screen->Unscale( size );
|
||||||
screen->Unscale( org );
|
screen->Unscale( org );
|
||||||
org += screen->m_DrawOrg;
|
org += screen->m_DrawOrg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// if the grid size is small ( < MIN_GRID_SIZE pixels ) do not display all points
|
||||||
|
bool double_size = false;
|
||||||
|
if( dgrid.x < MIN_GRID_SIZE )
|
||||||
|
{
|
||||||
|
double_size = true;
|
||||||
|
dgrid.x *= 2;
|
||||||
|
}
|
||||||
|
if( dgrid.x < MIN_GRID_SIZE )
|
||||||
|
return; // The X grid is too small: do not show it
|
||||||
|
|
||||||
|
if( dgrid.y < MIN_GRID_SIZE )
|
||||||
|
{
|
||||||
|
double_size = true;
|
||||||
|
dgrid.y *= 2;
|
||||||
|
}
|
||||||
|
if( dgrid.y < MIN_GRID_SIZE )
|
||||||
|
return; // The Y grid is too small: do not show it
|
||||||
|
|
||||||
|
|
||||||
m_Parent->PutOnGrid( &org );
|
m_Parent->PutOnGrid( &org );
|
||||||
GRSetColorPen( DC, m_Parent->GetGridColor() );
|
GRSetColorPen( DC, m_Parent->GetGridColor() );
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
|
|
||||||
|
/* When we use an double_size grid, we must align grid ord on double grid
|
||||||
|
*/
|
||||||
|
int increment = double_size ? 2 : 1;
|
||||||
|
if( double_size )
|
||||||
|
{
|
||||||
|
wxRealPoint dblgrid = screen_grid_size * 2;
|
||||||
|
m_Parent->PutOnGrid(&org, &dblgrid);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw grid: the best algorithm depend on the platform.
|
// Draw grid: the best algorithm depend on the platform.
|
||||||
// under macOSX, the first method is better
|
// under macOSX, the first method is better
|
||||||
|
@ -824,14 +833,14 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
#if defined( __WXMAC__ ) && !defined( USE_WX_ZOOM )
|
#if defined( __WXMAC__ ) && !defined( USE_WX_ZOOM )
|
||||||
// Use a pixel based draw to display grid
|
// Use a pixel based draw to display grid
|
||||||
// When is not used USE_WX_ZOOM
|
// When is not used USE_WX_ZOOM
|
||||||
for( ii = 0; ; ii++ )
|
for( ii = 0; ; ii += increment )
|
||||||
{
|
{
|
||||||
xg = wxRound( ii * screen_grid_size.x );
|
xg = wxRound( ii * screen_grid_size.x );
|
||||||
if( xg > size.x )
|
if( xg > size.x )
|
||||||
break;
|
break;
|
||||||
xpos = org.x + xg;
|
xpos = org.x + xg;
|
||||||
xpos = GRMapX( xpos );
|
xpos = GRMapX( xpos );
|
||||||
for( jj = 0; ; jj++ )
|
for( jj = 0; ; jj += increment )
|
||||||
{
|
{
|
||||||
yg = wxRound( jj * screen_grid_size.y );
|
yg = wxRound( jj * screen_grid_size.y );
|
||||||
if( yg > size.y )
|
if( yg > size.y )
|
||||||
|
@ -846,7 +855,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
// Use a pixel based draw to display grid
|
// Use a pixel based draw to display grid
|
||||||
// There is a lot of calls, so the cost is hight
|
// There is a lot of calls, so the cost is hight
|
||||||
// and grid is slowly drawn on some platforms
|
// and grid is slowly drawn on some platforms
|
||||||
for( ii = 0; ; ii++ )
|
for( ii = 0; ; ii += increment )
|
||||||
{
|
{
|
||||||
xg = wxRound( ii * screen_grid_size.x );
|
xg = wxRound( ii * screen_grid_size.x );
|
||||||
if( xg > size.x )
|
if( xg > size.x )
|
||||||
|
@ -857,7 +866,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
continue;
|
continue;
|
||||||
if( xpos > m_ClipBox.GetEnd().x) // end of active area reached.
|
if( xpos > m_ClipBox.GetEnd().x) // end of active area reached.
|
||||||
break;
|
break;
|
||||||
for( jj = 0; ; jj++ )
|
for( jj = 0; ; jj += increment )
|
||||||
{
|
{
|
||||||
yg = wxRound( jj * screen_grid_size.y );
|
yg = wxRound( jj * screen_grid_size.y );
|
||||||
if( yg > size.y )
|
if( yg > size.y )
|
||||||
|
@ -890,7 +899,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
GRSetColorPen( &tmpDC, g_DrawBgColor );
|
GRSetColorPen( &tmpDC, g_DrawBgColor );
|
||||||
tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background
|
tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background
|
||||||
GRSetColorPen( &tmpDC, m_Parent->GetGridColor() );
|
GRSetColorPen( &tmpDC, m_Parent->GetGridColor() );
|
||||||
for( jj = 0; ; jj++ ) // draw grid points
|
for( jj = 0; ; jj += increment ) // draw grid points
|
||||||
{
|
{
|
||||||
yg = wxRound( jj * screen_grid_size.y );
|
yg = wxRound( jj * screen_grid_size.y );
|
||||||
ypos = screen->Scale( yg );
|
ypos = screen->Scale( yg );
|
||||||
|
@ -900,7 +909,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
|
||||||
}
|
}
|
||||||
|
|
||||||
ypos = GRMapY( org.y );
|
ypos = GRMapY( org.y );
|
||||||
for( ii = 0; ; ii++ )
|
for( ii = 0; ; ii += increment )
|
||||||
{
|
{
|
||||||
xg = wxRound( ii * screen_grid_size.x );
|
xg = wxRound( ii * screen_grid_size.x );
|
||||||
if( xg > size.x )
|
if( xg > size.x )
|
||||||
|
@ -1107,7 +1116,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
|
||||||
* in order to avoid spurious block commands.
|
* in order to avoid spurious block commands.
|
||||||
*/
|
*/
|
||||||
static int MinDragEventCount;
|
static int MinDragEventCount;
|
||||||
if( event.Leaving() /*|| event.Entering()*/ )
|
if( event.Leaving() )
|
||||||
{
|
{
|
||||||
m_CanStartBlock = -1;
|
m_CanStartBlock = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,23 +46,25 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
|
||||||
|
|
||||||
|
|
||||||
/** Adjust the coordinate to the nearest grid value
|
/** Adjust the coordinate to the nearest grid value
|
||||||
* @param coord = coordinate to adjust
|
* @param aCoord = coordinate to adjust
|
||||||
|
* @param aGridSize = pointer to a grid value. if NULL uses the current grid size
|
||||||
*/
|
*/
|
||||||
void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
|
void WinEDA_DrawFrame::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize )
|
||||||
{
|
{
|
||||||
wxRealPoint grid_size = GetBaseScreen()->GetGridSize();
|
wxRealPoint grid_size;
|
||||||
|
if( aGridSize )
|
||||||
|
grid_size = *aGridSize;
|
||||||
|
else
|
||||||
|
grid_size = GetBaseScreen()->GetGridSize();
|
||||||
|
|
||||||
if( !GetBaseScreen()->m_UserGridIsON ) // XXX UNUSED VARIABLE???
|
|
||||||
{
|
|
||||||
const wxPoint& grid_origin = GetBaseScreen()->GetGridOrigin();
|
const wxPoint& grid_origin = GetBaseScreen()->GetGridOrigin();
|
||||||
double offset = fmod(grid_origin.x, grid_size.x);
|
double offset = fmod(grid_origin.x, grid_size.x);
|
||||||
int tmp = wxRound( (coord->x - offset) / grid_size.x );
|
int tmp = wxRound( (aCoord->x - offset) / grid_size.x );
|
||||||
coord->x = wxRound( tmp * grid_size.x + offset );
|
aCoord->x = wxRound( tmp * grid_size.x + offset );
|
||||||
|
|
||||||
offset = fmod(grid_origin.y, grid_size.y);
|
offset = fmod(grid_origin.y, grid_size.y);
|
||||||
tmp = wxRound( (coord->y - offset) / grid_size.y );
|
tmp = wxRound( (aCoord->y - offset) / grid_size.y );
|
||||||
coord->y = wxRound ( tmp * grid_size.y + offset );
|
aCoord->y = wxRound ( tmp * grid_size.y + offset );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,6 @@ private:
|
||||||
public:
|
public:
|
||||||
wxPoint m_GridOrigin;
|
wxPoint m_GridOrigin;
|
||||||
GridArray m_GridList;
|
GridArray m_GridList;
|
||||||
bool m_UserGridIsON;
|
|
||||||
|
|
||||||
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
|
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
|
||||||
int m_Zoom; /* Current zoom coefficient. */
|
int m_Zoom; /* Current zoom coefficient. */
|
||||||
|
|
|
@ -361,9 +361,13 @@ public:
|
||||||
virtual void OnZoom( wxCommandEvent& event );
|
virtual void OnZoom( wxCommandEvent& event );
|
||||||
void OnGrid( int grid_type );
|
void OnGrid( int grid_type );
|
||||||
void Recadre_Trace( bool ToMouse );
|
void Recadre_Trace( bool ToMouse );
|
||||||
void PutOnGrid( wxPoint* coord ); /* set the coordinate to
|
|
||||||
* the nearest grid
|
/** Adjust the coordinate to the nearest grid value
|
||||||
* coordinate */
|
* @param aCoord = coordinate to adjust
|
||||||
|
* @param aGridSize = pointer to a grid value. if NULL uses the current grid size
|
||||||
|
*/
|
||||||
|
void PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize = NULL );
|
||||||
|
|
||||||
void Zoom_Automatique( bool move_mouse_cursor );
|
void Zoom_Automatique( bool move_mouse_cursor );
|
||||||
|
|
||||||
/* Set the zoom level to show the area Rect */
|
/* Set the zoom level to show the area Rect */
|
||||||
|
|
Loading…
Reference in New Issue