Commit 0f366f84 authored by charras's avatar charras

OSX fixes.

Better code in fast draw grid algo (drawpanel.cpp):must be faster, and minor refresh problems removed under wxGTK
parent 96a9769f
...@@ -608,21 +608,21 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) ...@@ -608,21 +608,21 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y ); unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y );
wxImage image( viewport.x, viewport.y ); wxImage image( viewport.x, viewport.y );
glPixelStorei( GL_PACK_ALIGNMEN T, 1 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 );
glReadBuffer( GL_BACK_LEFT ); glReadBuffer( GL_BACK_LEFT );
glReadPixels( viewport.originx, glReadPixels( viewport.originx,
viewport.originy, viewport.originy,
viewport.x, viewport.x,
viewport.y, viewport.y,
GL_RGB, GL_RGB,
GL_UNSIGNED_ BYTE, GL_UNSIGNED_BYTE,
pixelbuffer ); pixelbuffer );
glReadPixels( viewport.originx, glReadPixels( viewport.originx,
viewport.originy, viewport.originy,
viewport.x, viewport.x,
viewport.y, viewport.y,
GL_ALPHA, GL_ALPHA,
GL_UNSIGNED_ BYTE, GL_UNSIGNED_BYTE,
alphabuffer ); alphabuffer );
......
...@@ -800,13 +800,13 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) ...@@ -800,13 +800,13 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
// so perhaps could be necessary to set this option at run time. // so perhaps could be necessary to set this option at run time.
#if defined( __WXMAC__ ) #if defined( __WXMAC__ )
wxWindowUpdateLocker( this ); // under macOSX: drawings are faster with this
#endif
#if defined( __WXMAC__ )
// 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
#if defined( __WXMAC__ )
wxWindowUpdateLocker( this ); // under macOSX: drawings are faster with this
#endif
for( ii = 0; ; ii++ ) for( ii = 0; ; ii++ )
{ {
xg = wxRound( ii * screen_grid_size.x ); xg = wxRound( ii * screen_grid_size.x );
...@@ -831,48 +831,38 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) ...@@ -831,48 +831,38 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
* a grid column is drawn; and then copied to others grid columns * a grid column is drawn; and then copied to others grid columns
* this is possible because the grid is drawn only after clearing the screen. * this is possible because the grid is drawn only after clearing the screen.
* *
* A first grid column is drawn, and after duplicated using the Blit function * A first grid column is drawn in a temporary bitmap,
* and after is duplicated using the Blit function
* (copy from a screen area to an other screen area) * (copy from a screen area to an other screen area)
* the screen area source is the first column drawn.
*/ */
wxSize screenSize = GetClientSize(); wxSize screenSize = GetClientSize();
int x0pos; wxMemoryDC tmpDC;
/* skip the grid columns outside the area to redraw wxBitmap tmpBM(1, screenSize.y);
* (it is not always the first pixel column when redraw a sub area of the screen) tmpDC.SelectObject( tmpBM );
* this is mandatory because we cannot write outside this sub area GRSetColorPen( &tmpDC, g_DrawBgColor );
* and therefore cannot use a column ouside this area as the column to duplicate tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background
* this ugly way to found the first suitable column is due to the fact GRSetColorPen( &tmpDC, g_GridColor );
* the function that reverses the GRMapX function does dot exist. for( jj = 0; ; jj++ ) // draw grid points
*/
for( ii = 1; ; ii++ ) // Do not draw the column 0 because it is not easily visible
{
xg = wxRound( ii * screen_grid_size.x );
if( xg > size.x )
return; // out of screen (should not occur)
x0pos = GRMapX( org.x + xg );
if( x0pos > m_ClipBox.GetOrigin().x) // First column in active screen area found.
break;
}
for( jj = 0; ; jj++ )
{ {
yg = wxRound( jj * screen_grid_size.y ); yg = wxRound( jj * screen_grid_size.y );
if( yg > size.y ) ypos = screen->Scale( yg );
if( ypos > screenSize.y )
break; break;
ypos = org.y + yg; tmpDC.DrawPoint( 0, ypos );
DC->DrawPoint( x0pos, GRMapY( ypos ) );
} }
ypos = GRMapY( org.y ); ypos = GRMapY( org.y );
for( ; ; ii++ ) for( ii = 0; ; ii++ )
{ {
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 = GRMapX( org.x + xg ); xpos = GRMapX( org.x + xg );
if( xpos < m_ClipBox.GetOrigin().x) // column not in active screen area.
if( xpos > m_ClipBox.GetEnd().x) // end of active area reached. if( xpos > m_ClipBox.GetEnd().x) // end of active area reached.
break; break;
DC->Blit( xpos, ypos, 1, screenSize.y, DC, x0pos, ypos ); DC->Blit( xpos, ypos, 1, screenSize.y, &tmpDC, 0, 0 );
} }
#endif #endif
......
...@@ -60,7 +60,13 @@ public: ...@@ -60,7 +60,13 @@ public:
bool OnPrintPage( int page ); bool OnPrintPage( int page );
bool HasPage( int page ) { return true; } // do not test page num bool HasPage( int page ) // do not test page num
{
if (page <= m_PrintParams.m_PageCount)
return true;
else return false;
}
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ); void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
void DrawPage(); void DrawPage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment