From 0f0d9afa66c9048bba0f32860e3e55c400d8f5ad Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 28 Mar 2018 18:06:03 +0200 Subject: [PATCH] Pcbnew, legacy mode: fix ratsnest display artifacts when finishing or removing a track --- pcbnew/connect.cpp | 1 + pcbnew/deltrack.cpp | 36 +++++++++++++++++++++++++++++------- pcbnew/editrack.cpp | 25 ++++++++++--------------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index 0c11dce309..a75b5d522c 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -39,5 +39,6 @@ void PCB_BASE_FRAME::TestNetConnection( wxDC* aDC, int aNetCode ) { + // Build and display new ratsnest Compile_Ratsnest( aDC, false ); } diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 3a394900c2..84b6ec368e 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -120,19 +120,25 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) int netcode = aTrack->GetNetCode(); - // Remove the segment from list, but do not delete it (it will be stored i n undo list) + // Remove the segment from list, but do not delete it (it will be stored in undo list) GetBoard()->Remove( aTrack ); - GetBoard()->GetConnectivity()->Remove( aTrack ); - // redraw the area where the track was - m_canvas->RefreshDrawingRect( aTrack->GetBoundingBox() ); - SaveCopyInUndoList( aTrack, UR_DELETED ); OnModify(); + + if( GetBoard()->IsElementVisible( LAYER_RATSNEST ) && DC ) + { + GRSetDrawMode( DC, GR_XOR ); + DrawGeneralRatsnest( DC, 0 ); + } + // compute and display the new ratsnest TestNetConnection( DC, netcode ); SetMsgPanel( GetBoard() ); + // redraw the area where the track was + m_canvas->RefreshDrawingRect( aTrack->GetBoundingBox() ); + return NULL; } @@ -141,10 +147,8 @@ void PCB_EDIT_FRAME::Delete_Track( wxDC* DC, TRACK* aTrack ) { if( aTrack != NULL ) { - int netcode = aTrack->GetNetCode(); Remove_One_Track( DC, aTrack ); OnModify(); - TestNetConnection( DC, netcode ); } } @@ -184,6 +188,14 @@ void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack ) SaveCopyInUndoList( itemsList, UR_DELETED ); OnModify(); + + // Erase old ratsnest + if( GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) + { + GRSetDrawMode( DC, GR_XOR ); + DrawGeneralRatsnest( DC, 0 ); + } + TestNetConnection( DC, netcode ); SetMsgPanel( GetBoard() ); } @@ -231,5 +243,15 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) SaveCopyInUndoList( itemsList, UR_DELETED ); if( net_code > 0 ) + { + // Erase old ratsnest + if( GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) + { + GRSetDrawMode( DC, GR_XOR ); + DrawGeneralRatsnest( DC, 0 ); + } + + // Build and draw the new ratsnest TestNetConnection( DC, net_code ); + } } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 3d16841d49..5f6e83450a 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -425,21 +425,13 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) if( Begin_Route( aTrack, aDC ) == NULL ) return false; + // Update last track position ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, true ); + // Erase the last drawings ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false ); - TraceAirWiresToTargets( aDC ); - - /* cleanup - * if( g_CurrentTrackSegment->Next() != NULL ) - * { - * delete g_CurrentTrackSegment->Next(); - * g_CurrentTrackSegment->SetNext( NULL ); - * } - */ DBG( g_CurrentTrackList.VerifyListIntegrity(); ); - /* The track here is now chained to the list of track segments. * It must be seen in the area of net * As close as possible to the segment base (or end), because @@ -487,8 +479,6 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) GetBoard()->GetConnectivity()->Add( track ); } - TraceAirWiresToTargets( aDC ); - int i = 0; for( track = firstTrack; track && i < newCount; ++i, track = track->Next() ) @@ -506,7 +496,14 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items - // compute the new ratsnest + // Erase old ratsnest + if( GetBoard()->IsElementVisible( LAYER_RATSNEST ) && aDC ) + { + GRSetDrawMode( aDC, GR_XOR ); + DrawGeneralRatsnest( aDC, 0 ); + } + + // compute and display the new ratsnest TestNetConnection( aDC, netcode ); OnModify(); SetMsgPanel( GetBoard() ); @@ -530,8 +527,6 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) m_canvas->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); - GetBoard()->GetConnectivity()->RecalculateRatsnest(); - return true; }