USE_WX_ZOOM fixes.

* Corrected over zealous clipping fix in last commit.
* Tweaked clip box rectangle size.
* Fixed cross hair cursor drawing bug.
This commit is contained in:
stambaughw 2010-02-10 21:39:32 +00:00
parent 8be7f467e8
commit 5591ccd443
2 changed files with 22 additions and 25 deletions

View File

@ -138,19 +138,25 @@ void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor )
wxPoint Cursor = GetScreen()->m_Curseur; wxPoint Cursor = GetScreen()->m_Curseur;
GRSetDrawMode( aDC, GR_XOR ); GRSetDrawMode( aDC, GR_XOR );
if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */ if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */
{ {
#ifdef USE_WX_ZOOM #ifdef USE_WX_ZOOM
int dx = m_ClipBox.GetWidth(); wxSize clientSize = GetClientSize();
int dy = m_ClipBox.GetHeight(); wxPoint lineStart = wxPoint( Cursor.x, aDC->DeviceToLogicalY( 0 ) );
wxPoint lineEnd = wxPoint( Cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // Y azis
lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), Cursor.y );
lineEnd = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), Cursor.y );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // X azis
#else #else
int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() ); int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() ); int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
#endif
GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y, GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y,
Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis
GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx, GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx,
Cursor.x, Cursor.y + dy, 0, aColor ); // X axis Cursor.x, Cursor.y + dy, 0, aColor ); // X axis
#endif
} }
else else
{ {
@ -504,6 +510,7 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
{ {
Scroll( -1, y + value ); Scroll( -1, y + value );
} }
event.Skip(); event.Skip();
} }
@ -554,6 +561,7 @@ void WinEDA_DrawPanel::SetBoundaryBox( wxDC* dc )
m_ClipBox.m_Pos.y = dc->DeviceToLogicalY( 0 ); m_ClipBox.m_Pos.y = dc->DeviceToLogicalY( 0 );
m_ClipBox.m_Size.x = dc->DeviceToLogicalXRel( m_ClipBox.m_Size.x ); m_ClipBox.m_Size.x = dc->DeviceToLogicalXRel( m_ClipBox.m_Size.x );
m_ClipBox.m_Size.y = dc->DeviceToLogicalYRel( m_ClipBox.m_Size.y ); m_ClipBox.m_Size.y = dc->DeviceToLogicalYRel( m_ClipBox.m_Size.y );
m_ClipBox.Inflate( dc->DeviceToLogicalXRel( 2 ) );
#endif #endif
Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL ); Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
@ -610,15 +618,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
* implemented. * implemented.
*/ */
EDA_Rect tmp; EDA_Rect tmp = m_ClipBox;
wxRect PaintClipBox;
tmp = m_ClipBox; // Get the union of all rectangles in the update region.
wxRect PaintClipBox = GetUpdateRegion().GetBox();
wxRegion upd = GetUpdateRegion(); // get the update rect list
// get the union of all rectangles in the update region, 'upd'
PaintClipBox = upd.GetBox();
#if 0 #if 0
wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ), wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
@ -634,6 +637,8 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( PaintClipBox.y ); m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( PaintClipBox.y );
m_ClipBox.m_Size.x = paintDC.DeviceToLogicalXRel( PaintClipBox.width ); m_ClipBox.m_Size.x = paintDC.DeviceToLogicalXRel( PaintClipBox.width );
m_ClipBox.m_Size.y = paintDC.DeviceToLogicalYRel( PaintClipBox.height ); m_ClipBox.m_Size.y = paintDC.DeviceToLogicalYRel( PaintClipBox.height );
m_ClipBox.Inflate( paintDC.DeviceToLogicalXRel( 2 ) );
PaintClipBox = m_ClipBox;
#else #else
/* When using Kicads scaling the clipping region coordinates are in screen /* When using Kicads scaling the clipping region coordinates are in screen
* (device) units. * (device) units.
@ -642,10 +647,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
m_ClipBox.SetY( PaintClipBox.GetY() ); m_ClipBox.SetY( PaintClipBox.GetY() );
m_ClipBox.SetWidth( PaintClipBox.GetWidth() ); m_ClipBox.SetWidth( PaintClipBox.GetWidth() );
m_ClipBox.SetHeight( PaintClipBox.GetHeight() ); m_ClipBox.SetHeight( PaintClipBox.GetHeight() );
#endif
// Be sure the drawpanel clipbox is bigger than the region to repair: // Be sure the drawpanel clipbox is bigger than the region to repair:
m_ClipBox.Inflate( 1 ); // Give it one pixel more in each direction m_ClipBox.Inflate( 1 ); // Give it one pixel more in each direction
#endif
#if 0 #if 0
wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ), wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
@ -653,9 +658,6 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y ); m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#endif #endif
#if defined( USE_WX_ZOOM ) && defined( KICAD_USE_BUFFERED_PAINTDC )
PaintClipBox = m_ClipBox;
#endif
// call ~wxDCClipper() before ~wxPaintDC() // call ~wxDCClipper() before ~wxPaintDC()
{ {
wxDCClipper dcclip( paintDC, PaintClipBox ); wxDCClipper dcclip( paintDC, PaintClipBox );

View File

@ -47,8 +47,7 @@ int g_DrawBgColor = WHITE;
#define USE_CLIP_FILLED_POLYGONS #define USE_CLIP_FILLED_POLYGONS
#ifdef USE_CLIP_FILLED_POLYGONS #ifdef USE_CLIP_FILLED_POLYGONS
void ClipAndDrawFilledPoly( EDA_Rect * ClipBox, wxDC * DC, wxPoint Points[], void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n );
int n );
#endif #endif
@ -262,11 +261,7 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
xcliphi += width; xcliphi += width;
ycliphi += width; ycliphi += width;
#ifdef USE_WX_ZOOM
if( !ClipBox->Inside( wxPoint( x1, y1 ) ) && !ClipBox->Inside( wxPoint( x2, y2 ) ) )
#else
if( clip_line( x1, y1, x2, y2 ) ) if( clip_line( x1, y1, x2, y2 ) )
#endif
return; return;
} }
@ -1641,11 +1636,11 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox,
clippedPolygon.clear(); clippedPolygon.clear();
for( int ii = 0; ii < n; ii++ ) for( int ii = 0; ii < n; ii++ )
inputPolygon.push_back( PointF( (REAL) aPoints[ii].x, inputPolygon.push_back( PointF( (REAL) aPoints[ii].x,
(REAL) aPoints[ii].y ) ); (REAL) aPoints[ii].y ) );
RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(), RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
(REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetWidth(),
(REAL) aClipBox->GetHeight() ); (REAL) aClipBox->GetHeight() );
SutherlandHodgman sh( window ); SutherlandHodgman sh( window );
sh.Clip( inputPolygon, outputPolygon ); sh.Clip( inputPolygon, outputPolygon );
@ -1655,7 +1650,7 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox,
++cit ) ++cit )
{ {
clippedPolygon.push_back( wxPoint( wxRound( cit->X ), clippedPolygon.push_back( wxPoint( wxRound( cit->X ),
wxRound( cit->Y ) ) ); wxRound( cit->Y ) ) );
} }
if( clippedPolygon.size() ) if( clippedPolygon.size() )