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:
parent
e1bce7dccd
commit
c0008bc757
|
@ -280,7 +280,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
|
||||||
brdSettings.SetTrackWidthIndex( (unsigned) m_trackWidthSelectBox->GetSelection() );
|
brdSettings.SetTrackWidthIndex( (unsigned) m_trackWidthSelectBox->GetSelection() );
|
||||||
brdSettings.SetViaSizeIndex( (unsigned) m_viaSizesSelectBox->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;
|
m_failedDRC = true;
|
||||||
}
|
}
|
||||||
brdSettings.SetTrackWidthIndex( prevTrackWidthIndex );
|
brdSettings.SetTrackWidthIndex( prevTrackWidthIndex );
|
||||||
|
@ -301,7 +301,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !m_parent->SetTrackSegmentWidth( aItem, aUndoList, true ) )
|
if( m_parent->SetTrackSegmentWidth( aItem, aUndoList, true ) == TRACK_ACTION_DRC_ERROR )
|
||||||
m_failedDRC = true;
|
m_failedDRC = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,20 +39,15 @@
|
||||||
#include <drc.h>
|
#include <drc.h>
|
||||||
|
|
||||||
|
|
||||||
bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
|
int PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
|
||||||
PICKED_ITEMS_LIST* aItemsListPicker,
|
PICKED_ITEMS_LIST* aItemsListPicker,
|
||||||
bool aUseNetclassValue )
|
bool aUseNetclassValue )
|
||||||
{
|
{
|
||||||
/* Modify one track segment width or one via diameter and drill (using DRC control).
|
int return_code = TRACK_ACTION_NONE;
|
||||||
* Basic function used by other routines when editing tracks or vias
|
int initial_width;
|
||||||
* aTrackItem = the track segment or via to modify
|
int new_width;
|
||||||
* aItemsListPicker = the list picker to use for an undo command (can be NULL)
|
int initial_drill = -1;
|
||||||
* aUseNetclassValue = true to use NetClass value, false to use BOARD::m_designSettings value
|
int new_drill = -1;
|
||||||
* 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;
|
|
||||||
NETINFO_ITEM* net = NULL;
|
NETINFO_ITEM* net = NULL;
|
||||||
|
|
||||||
if( aUseNetclassValue )
|
if( aUseNetclassValue )
|
||||||
|
@ -118,25 +113,26 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
|
||||||
if( initial_width < new_width )
|
if( initial_width < new_width )
|
||||||
{
|
{
|
||||||
int diagdrc = OK_DRC;
|
int diagdrc = OK_DRC;
|
||||||
|
return_code = TRACK_ACTION_SUCCESS;
|
||||||
|
|
||||||
if( Settings().m_legacyDrcOn )
|
if( Settings().m_legacyDrcOn )
|
||||||
diagdrc = m_drc->DrcOnCreatingTrack( aTrackItem, GetBoard()->m_Track );
|
diagdrc = m_drc->DrcOnCreatingTrack( aTrackItem, GetBoard()->m_Track );
|
||||||
|
|
||||||
if( diagdrc == OK_DRC )
|
if( diagdrc != OK_DRC )
|
||||||
change_ok = true;
|
return_code = TRACK_ACTION_DRC_ERROR;
|
||||||
}
|
}
|
||||||
else if( initial_width > new_width )
|
else if( initial_width > new_width )
|
||||||
{
|
{
|
||||||
change_ok = true;
|
return_code = TRACK_ACTION_SUCCESS;
|
||||||
}
|
}
|
||||||
else if( (aTrackItem->Type() == PCB_VIA_T) )
|
else if( (aTrackItem->Type() == PCB_VIA_T) )
|
||||||
{
|
{
|
||||||
// if a via has its drill value changed, force change
|
// if a via has its drill value changed, force change
|
||||||
if( initial_drill != new_drill )
|
if( initial_drill != new_drill )
|
||||||
change_ok = true;
|
return_code = TRACK_ACTION_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( change_ok )
|
if( return_code == TRACK_ACTION_SUCCESS )
|
||||||
{
|
{
|
||||||
OnModify();
|
OnModify();
|
||||||
|
|
||||||
|
@ -164,7 +160,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
|
||||||
aTrackItem->SetWidth( initial_width );
|
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 )
|
void PCB_EDIT_FRAME::Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem )
|
||||||
{
|
{
|
||||||
PICKED_ITEMS_LIST itemsListPicker;
|
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
|
return; // No change
|
||||||
|
|
||||||
// The segment has changed: redraw it and save it in undo list
|
// 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 );
|
pt_track->SetState( BUSY, false );
|
||||||
|
|
||||||
if( SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) )
|
if( !SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) )
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,16 @@ class FP_LIB_TABLE;
|
||||||
|
|
||||||
namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
|
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
|
* Class PCB_EDIT_FRAME
|
||||||
* is the main frame for Pcbnew.
|
* is the main frame for Pcbnew.
|
||||||
|
@ -1351,15 +1361,19 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function SetTrackSegmentWidth
|
* Function SetTrackSegmentWidth
|
||||||
* Modify one track segment width or one via diameter (using DRC control).
|
* 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 aTrackItem = the track segment or via to modify
|
||||||
* @param aItemsListPicker = the list picker to use for an undo command
|
* @param aItemsListPicker = the list picker to use for an undo command
|
||||||
* (can be NULL)
|
* (can be NULL)
|
||||||
* @param aUseNetclassValue = true to use NetClass value, false to use
|
* @param aUseNetclassValue = true to use NetClass value, false to use
|
||||||
* current designSettings value
|
* 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,
|
PICKED_ITEMS_LIST* aItemsListPicker,
|
||||||
bool aUseNetclassValue );
|
bool aUseNetclassValue );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue