diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index b8ae5d59e7..9d5321a07d 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -119,11 +119,49 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) current_net_code = Track->GetNet(); -#if 0 && !defined(DEBUG) +#if 0 + Track->Draw( DrawPanel, DC, GR_XOR ); + #else - // just redraw the whole drawing so there are no XOR remnants at track intersections. + + // redraw the area where the track was + + // this rectangle is corrrect + EDA_Rect dirty = Track->GetBoundingBox(); + + D(printf( "dirty m_Pos=(%d, %d) m_Size=(%d, %d)\n", + dirty.m_Pos.x, dirty.m_Pos.y, dirty.m_Size.x, dirty.m_Size.y );) + + int zoom = GetZoom(); + + wxPoint drwOrig = GetScreen()->m_DrawOrg; + + dirty.m_Pos.x = (dirty.m_Pos.x - drwOrig.x) / zoom; + dirty.m_Pos.y = (dirty.m_Pos.y - drwOrig.y) / zoom; + + dirty.m_Size.x = (dirty.m_Size.x - drwOrig.x) / zoom; + dirty.m_Size.y = (dirty.m_Size.y - drwOrig.y) / zoom; + + D(printf( "dirty scaled zoom=%d m_Pos=(%d, %d) m_Size=(%d, %d) drwOrig=(%d, %d)\n", + zoom, + dirty.m_Pos.x, dirty.m_Pos.y, dirty.m_Size.x, dirty.m_Size.y, + drwOrig.x, drwOrig.y );) + + // pass wxRect() via EDA_Rect::operator wxRect() overload + wxRect dirtyR = dirty; + + D(printf( "dirtyR m_Pos=(%d, %d) m_Size=(%d, %d)\n", + dirtyR.x, dirtyR.y, dirtyR.width, dirtyR.height );) + +/* The calculation for dirtyR is either wrong or the handling of the clipping + rect in OnPaint() is wrong. Enable this line instead of the Refresh() below, + then try deleting a track segment. + DrawPanel->RefreshRect( dirtyR, TRUE ); +*/ + DrawPanel->Refresh( TRUE ); + #endif SaveItemEfface( Track, 1 );