Modify Synchronize Pins behavior

Consider a pin synchronized iff the names and electrical types match in
addition to the position, orientation and demorgan variant.

Also, only modify one matching pin per unit.  This prevents
moving/editing a full stack of pins on the same unit when synchonized.

Fixes https://gitlab.com/kicad/code/kicad/issues/2590
This commit is contained in:
Seth Hillbrand 2020-12-18 15:16:30 -08:00
parent 2226e0b7aa
commit 0fd920a94c
3 changed files with 43 additions and 5 deletions

View File

@ -257,10 +257,17 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
toDelete.insert( pin );
// when pin editing is synchronized, all pins of the same body style are removed:
// when pin editing is synchronized, pins in the same position, with the same name
// in different units are also removed. But only one pin per unit (matching)
if( m_frame->SynchronizePins() )
{
std::vector<bool> got_unit( part->GetUnitCount() );
got_unit[pin->GetUnit()] = true;
int curr_convert = pin->GetConvert();
ELECTRICAL_PINTYPE etype = pin->GetType();
wxString name = pin->GetName();
LIB_PIN* next_pin = part->GetNextPin();
while( next_pin != NULL )
@ -268,13 +275,23 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
pin = next_pin;
next_pin = part->GetNextPin( pin );
if( got_unit[pin->GetUnit()] )
continue;
if( pin->GetPosition() != pos )
continue;
if( pin->GetConvert() != curr_convert )
continue;
if( pin->GetType() != etype )
continue;
if( pin->GetName() != name )
continue;
toDelete.insert( pin );
got_unit[pin->GetUnit()] = true;
}
}
}

View File

@ -123,14 +123,21 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
{
LIB_PIN* cur_pin = (LIB_PIN*) lib_item;
LIB_PART* part = m_frame->GetCurPart();
std::vector<bool> got_unit( part->GetUnitCount() );
got_unit[cur_pin->GetUnit()] = true;
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
{
if( pin->GetPosition() == cur_pin->GetPosition()
if( !got_unit[pin->GetUnit()]
&& pin->GetPosition() == cur_pin->GetPosition()
&& pin->GetOrientation() == cur_pin->GetOrientation()
&& pin->GetConvert() == cur_pin->GetConvert() )
&& pin->GetConvert() == cur_pin->GetConvert()
&& pin->GetType() == cur_pin->GetType()
&& pin->GetName() == cur_pin->GetName() )
{
m_selectionTool->AddItemToSel( pin, true /*quiet mode*/ );
got_unit[pin->GetUnit()] = true;
}
}
}

View File

@ -108,6 +108,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::Init()
bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
{
LIB_PIN original_pin( *aPin );
DIALOG_PIN_PROPERTIES dlg( m_frame, aPin );
if( aPin->GetEditFlags() == 0 )
@ -127,14 +128,26 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
{
LIB_PINS pinList;
aPin->GetParent()->GetPins( pinList );
std::vector<bool> got_unit( aPin->GetParent()->GetUnitCount() );
got_unit[aPin->GetUnit()] = true;
for( LIB_PIN* other : pinList )
{
if( other == aPin )
continue;
if( other->GetPosition() == aPin->GetPosition()
&& other->GetOrientation() == aPin->GetOrientation() )
/// Only change one pin per unit to allow stacking pins
/// If you change all units on the position, then pins are not
/// uniquely editable
if( got_unit[other->GetUnit()] )
continue;
if( other->GetPosition() == original_pin.GetPosition()
&& other->GetOrientation() == original_pin.GetOrientation()
&& other->GetType() == original_pin.GetType()
&& other->IsVisible() == original_pin.IsVisible()
&& other->GetName() == original_pin.GetName() )
{
if( aPin->GetConvert() == 0 )
{
@ -162,6 +175,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
other->SetNumberTextSize( aPin->GetNumberTextSize() );
other->SetModified();
got_unit[other->GetUnit()] = true;
}
}
}