2009-11-14 22:15:22 +00:00
|
|
|
/******************************************/
|
|
|
|
/* Edit Track: Erase Routines */
|
|
|
|
/* Delete segments, tracks, and net areas */
|
|
|
|
/******************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "fctsys.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Removes 1 segment of track.
|
|
|
|
* 2 cases:
|
|
|
|
* If There is evidence of new track: delete new segment.
|
|
|
|
* Otherwise, delete segment under the cursor.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int current_net_code;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrack == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2008-03-04 21:39:46 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( aTrack->IsNew() ) // Trace in progress, erase the last segment
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( g_CurrentTrackList.GetCount() > 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-01-24 02:05:07 +00:00
|
|
|
int previous_layer = getActiveLayer();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); )
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Delete the current trace
|
2011-02-03 19:27:28 +00:00
|
|
|
ShowNewTrackWhenMovingCursor( DrawPanel, DC, wxDefaultPosition, FALSE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
// delete the most recently entered
|
|
|
|
delete g_CurrentTrackList.PopBack();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( g_TwoSegmentTrackBuild )
|
2008-03-04 21:39:46 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
// if in 2 track mode, and the next most recent is a segment
|
|
|
|
// not a via, and the one previous to that is a via, then
|
|
|
|
// delete up to the via.
|
2008-12-04 04:28:11 +00:00
|
|
|
if( g_CurrentTrackList.GetCount() >= 2
|
2009-11-14 22:15:22 +00:00
|
|
|
&& g_CurrentTrackSegment->Type() != TYPE_VIA
|
|
|
|
&& g_CurrentTrackSegment->Back()->Type() == TYPE_VIA )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete g_CurrentTrackList.PopBack();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() ==
|
|
|
|
TYPE_VIA )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete g_CurrentTrackList.PopBack();
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() !=
|
|
|
|
TYPE_VIA )
|
2007-08-23 04:28:46 +00:00
|
|
|
previous_layer = g_CurrentTrackSegment->GetLayer();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Correct active layer which could change if a via
|
|
|
|
// has been erased
|
2010-01-24 02:05:07 +00:00
|
|
|
setActiveLayer( previous_layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
UpdateStatusBar();
|
2009-11-14 22:15:22 +00:00
|
|
|
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more,
|
|
|
|
// or 0
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( g_CurrentTrackList.GetCount() == 1
|
|
|
|
&& g_CurrentTrackSegment->Type() != TYPE_VIA )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete g_CurrentTrackList.PopBack();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
if( g_CurrentTrackList.GetCount() == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2011-04-05 17:49:14 +00:00
|
|
|
if( GetBoard()->IsHightLightNetON() )
|
2010-01-24 13:46:01 +00:00
|
|
|
High_Light( DC );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return g_CurrentTrackSegment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2008-12-04 04:28:11 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
current_net_code = aTrack->GetNet();
|
2008-03-04 21:39:46 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
DLIST<TRACK>* container = (DLIST<TRACK>*)aTrack->GetList();
|
2009-07-29 13:10:36 +00:00
|
|
|
wxASSERT( container );
|
|
|
|
container->Remove( aTrack );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2008-03-06 01:46:13 +00:00
|
|
|
// redraw the area where the track was
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( aTrack->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
SaveCopyInUndoList( aTrack, UR_DELETED );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
test_1_net_connexion( DC, current_net_code );
|
2009-04-17 08:51:02 +00:00
|
|
|
GetBoard()->DisplayInfo( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Delete_Track( wxDC* DC, TRACK* aTrack )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrack != NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
int current_net_code = aTrack->GetNet();
|
|
|
|
Remove_One_Track( DC, aTrack );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
test_1_net_connexion( DC, current_net_code );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrack == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( !IsOK( this, _( "Delete NET?" ) ) )
|
2009-07-29 13:10:36 +00:00
|
|
|
return;
|
2008-03-10 15:51:44 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
PICKED_ITEMS_LIST itemsList;
|
|
|
|
ITEM_PICKER picker( NULL, UR_DELETED );
|
2009-07-29 13:10:36 +00:00
|
|
|
int net_code_delete = aTrack->GetNet();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
/* Search the first item for the given net code */
|
|
|
|
TRACK* trackList = GetBoard()->m_Track->GetStartNetCode( net_code_delete );
|
2008-03-10 15:51:44 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
/* Remove all segments having the given net code */
|
|
|
|
int ii = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
TRACK* next_track;
|
2009-07-29 13:10:36 +00:00
|
|
|
for( TRACK* segm = trackList; segm; segm = next_track, ++ii )
|
|
|
|
{
|
|
|
|
next_track = segm->Next();
|
|
|
|
if( segm->GetNet() != net_code_delete )
|
|
|
|
break;
|
|
|
|
|
|
|
|
GetBoard()->m_Track.Remove( segm );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
// redraw the area where the track was
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( segm->GetBoundingBox() );
|
2009-11-14 22:15:22 +00:00
|
|
|
picker.m_PickedItem = segm;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = segm->Type();
|
2009-11-14 22:15:22 +00:00
|
|
|
itemsList.PushItem( picker );
|
2009-07-29 13:10:36 +00:00
|
|
|
}
|
2008-03-10 15:51:44 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
SaveCopyInUndoList( itemsList, UR_DELETED );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-07-29 13:10:36 +00:00
|
|
|
test_1_net_connexion( DC, net_code_delete );
|
|
|
|
GetBoard()->DisplayInfo( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Remove 1 track:
|
|
|
|
* The leading segment is removed and all adjacent segments
|
|
|
|
* until a pad or a junction point of more than 2 segments is found
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int segments_to_delete_count;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( pt_segm == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
TRACK* trackList = Marque_Une_Piste( GetBoard(), pt_segm,
|
|
|
|
&segments_to_delete_count, NULL, true );
|
2009-07-29 13:10:36 +00:00
|
|
|
if( segments_to_delete_count == 0 )
|
|
|
|
return;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
int net_code = pt_segm->GetNet();
|
2009-11-14 22:15:22 +00:00
|
|
|
PICKED_ITEMS_LIST itemsList;
|
|
|
|
ITEM_PICKER picker( NULL, UR_DELETED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
int ii = 0;
|
|
|
|
TRACK* tracksegment = trackList;
|
|
|
|
TRACK* next_track;
|
2009-07-29 13:10:36 +00:00
|
|
|
for( ; ii < segments_to_delete_count; ii++, tracksegment = next_track )
|
|
|
|
{
|
|
|
|
next_track = tracksegment->Next();
|
|
|
|
tracksegment->SetState( BUSY, OFF );
|
|
|
|
|
2010-10-04 12:58:07 +00:00
|
|
|
//D( printf( "%s: track %p status=\"%s\"\n", __func__, tracksegment,
|
2011-02-28 18:36:19 +00:00
|
|
|
// TO_UTF8( TRACK::ShowState( tracksegment->GetState( -1 ) ) )
|
2010-10-04 12:58:07 +00:00
|
|
|
// ); )
|
|
|
|
D( std::cout<<__func__<<": track "<<tracksegment<<" status=" \
|
2011-02-28 18:36:19 +00:00
|
|
|
<<TO_UTF8( TRACK::ShowState( tracksegment->GetState( -1 ) ) ) \
|
2010-10-04 12:58:07 +00:00
|
|
|
<<std::endl;)
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
GetBoard()->m_Track.Remove( tracksegment );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
// redraw the area where the track was
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( tracksegment->GetBoundingBox() );
|
2009-11-14 22:15:22 +00:00
|
|
|
picker.m_PickedItem = tracksegment;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = tracksegment->Type();
|
2009-11-14 22:15:22 +00:00
|
|
|
itemsList.PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
SaveCopyInUndoList( itemsList, UR_DELETED );
|
2009-11-14 22:15:22 +00:00
|
|
|
if( net_code > 0 )
|
2009-07-29 13:10:36 +00:00
|
|
|
test_1_net_connexion( DC, net_code );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|