pcbnew: Change track width should allow no changes

When doing a global edit of the tracks and vias, we need to allow for
the possibility that the track size doesn't change and that this is
explicitly allowed without DRC error.
This commit is contained in:
Seth Hillbrand 2019-02-08 07:21:48 -08:00
parent e1bce7dccd
commit c0008bc757
3 changed files with 35 additions and 25 deletions

View File

@ -280,7 +280,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
brdSettings.SetTrackWidthIndex( (unsigned) m_trackWidthSelectBox->GetSelection() );
brdSettings.SetViaSizeIndex( (unsigned) m_viaSizesSelectBox->GetSelection() );
if( !m_parent->SetTrackSegmentWidth( aItem, aUndoList, false ) )
if( m_parent->SetTrackSegmentWidth( aItem, aUndoList, false ) == TRACK_ACTION_DRC_ERROR )
m_failedDRC = true;
}
brdSettings.SetTrackWidthIndex( prevTrackWidthIndex );
@ -301,7 +301,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
}
else
{
if( !m_parent->SetTrackSegmentWidth( aItem, aUndoList, true ) )
if( m_parent->SetTrackSegmentWidth( aItem, aUndoList, true ) == TRACK_ACTION_DRC_ERROR )
m_failedDRC = true;
}
}

View File

@ -39,20 +39,15 @@
#include <drc.h>
bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
int PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
PICKED_ITEMS_LIST* aItemsListPicker,
bool aUseNetclassValue )
{
/* Modify one track segment width or one via diameter and drill (using DRC control).
* Basic function used by other routines when editing tracks or vias
* aTrackItem = the track segment or via to modify
* aItemsListPicker = the list picker to use for an undo command (can be NULL)
* aUseNetclassValue = true to use NetClass value, false to use BOARD::m_designSettings value
* return true if done, false if no not change (due to DRC error)
*/
int initial_width, new_width;
int initial_drill = -1,new_drill = -1;
bool change_ok = false;
int return_code = TRACK_ACTION_NONE;
int initial_width;
int new_width;
int initial_drill = -1;
int new_drill = -1;
NETINFO_ITEM* net = NULL;
if( aUseNetclassValue )
@ -118,25 +113,26 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
if( initial_width < new_width )
{
int diagdrc = OK_DRC;
return_code = TRACK_ACTION_SUCCESS;
if( Settings().m_legacyDrcOn )
diagdrc = m_drc->DrcOnCreatingTrack( aTrackItem, GetBoard()->m_Track );
if( diagdrc == OK_DRC )
change_ok = true;
if( diagdrc != OK_DRC )
return_code = TRACK_ACTION_DRC_ERROR;
}
else if( initial_width > new_width )
{
change_ok = true;
return_code = TRACK_ACTION_SUCCESS;
}
else if( (aTrackItem->Type() == PCB_VIA_T) )
{
// if a via has its drill value changed, force change
if( initial_drill != new_drill )
change_ok = true;
return_code = TRACK_ACTION_SUCCESS;
}
if( change_ok )
if( return_code == TRACK_ACTION_SUCCESS )
{
OnModify();
@ -164,7 +160,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
aTrackItem->SetWidth( initial_width );
}
return change_ok;
return return_code;
}
@ -177,9 +173,9 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
void PCB_EDIT_FRAME::Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem )
{
PICKED_ITEMS_LIST itemsListPicker;
bool change = SetTrackSegmentWidth( aTrackItem, &itemsListPicker, false );
bool changed = !SetTrackSegmentWidth( aTrackItem, &itemsListPicker, false );
if( change == 0 || aTrackItem->GetFlags() )
if( !changed || aTrackItem->GetFlags() )
return; // No change
// The segment has changed: redraw it and save it in undo list
@ -221,7 +217,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment )
{
pt_track->SetState( BUSY, false );
if( SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) )
if( !SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) )
change = true;
}

View File

@ -65,6 +65,16 @@ class FP_LIB_TABLE;
namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
/**
* Enum to signify the result of editing tracks and vias
*/
enum TRACK_ACTION_RESULT
{
TRACK_ACTION_DRC_ERROR = -1,//!< TRACK_ACTION_DRC_ERROR - Track not changed to to DRC
TRACK_ACTION_SUCCESS, //!< TRACK_ACTION_SUCCESS - Track changed successfully
TRACK_ACTION_NONE //!< TRACK_ACTION_NONE - Nothing to change
};
/**
* Class PCB_EDIT_FRAME
* is the main frame for Pcbnew.
@ -1351,15 +1361,19 @@ public:
/**
* Function SetTrackSegmentWidth
* Modify one track segment width or one via diameter (using DRC control).
* Basic routine used by other routines when editing tracks or vias
* Basic routine used by other routines when editing tracks or vias.
* Note that casting this to boolean will allow you to determine whether any action
* happened.
* @param aTrackItem = the track segment or via to modify
* @param aItemsListPicker = the list picker to use for an undo command
* (can be NULL)
* @param aUseNetclassValue = true to use NetClass value, false to use
* current designSettings value
* @return true if done, false if no not change (because DRC error)
* @return 0 if items successfully changed,
* -1 if there was a DRC error,
* 1 if items were changed successfully
*/
bool SetTrackSegmentWidth( TRACK* aTrackItem,
int SetTrackSegmentWidth( TRACK* aTrackItem,
PICKED_ITEMS_LIST* aItemsListPicker,
bool aUseNetclassValue );