Browse Source

Eeschema: Changing pin length adjusts offset according to orientation

ADDED: When pin length is changed now, the pin position is adjusted
according to its orientation such that the connection point for wires
moves instead of the other side of the stem base. For pins coming out of
component boxes, etc. this keeps them attached to the box while the
length is changed.
7.0
Mike Williams 3 years ago
parent
commit
e454595348
  1. 2
      eeschema/dialogs/dialog_lib_edit_pin_table.cpp
  2. 2
      eeschema/dialogs/dialog_pin_properties.cpp
  3. 27
      eeschema/lib_pin.cpp
  4. 7
      eeschema/lib_pin.h
  5. 4
      eeschema/tools/symbol_editor_pin_tool.cpp

2
eeschema/dialogs/dialog_lib_edit_pin_table.cpp

@ -355,7 +355,7 @@ public:
break;
case COL_LENGTH:
pin->SetLength( ValueFromString( m_frame->GetUserUnits(), aValue ) );
pin->ChangeLength( ValueFromString( m_frame->GetUserUnits(), aValue ) );
break;
case COL_POSX:

2
eeschema/dialogs/dialog_pin_properties.cpp

@ -345,8 +345,8 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
m_pin->SetNameTextSize( m_nameSize.GetValue() );
m_pin->SetNumberTextSize( m_numberSize.GetValue() );
m_pin->SetOrientation( PinOrientationCode( m_choiceOrientation->GetSelection() ) );
m_pin->SetLength( m_pinLength.GetValue() );
m_pin->SetPosition( newPos );
m_pin->ChangeLength( m_pinLength.GetValue() );
m_pin->SetType( m_choiceElectricalType->GetPinTypeSelection() );
m_pin->SetShape( m_choiceStyle->GetPinShapeSelection() );
m_pin->SetConvert( m_checkApplyToAllConversions->GetValue() ? 0 : m_frame->GetConvert() );

27
eeschema/lib_pin.cpp

@ -963,6 +963,33 @@ int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
return 0;
}
void LIB_PIN::ChangeLength( int aLength )
{
int lengthChange = m_length - aLength;
int offsetX = 0;
int offsetY = 0;
switch( m_orientation )
{
case PIN_RIGHT:
offsetX = lengthChange;
break;
case PIN_LEFT:
offsetX = -1 * lengthChange;
break;
case PIN_UP:
offsetY = lengthChange;
break;
case PIN_DOWN:
offsetY = -1 * lengthChange;
break;
}
wxPoint offset = wxPoint( offsetX, offsetY );
Offset( offset );
m_length = aLength;
}
void LIB_PIN::Offset( const VECTOR2I& aOffset )
{

7
eeschema/lib_pin.h

@ -81,6 +81,13 @@ public:
int GetLength() const { return m_length; }
void SetLength( int aLength ) { m_length = aLength; }
/**
* Change the length of a pin and adjust its position based on orientation.
*
* @param aLength New length of pin
*/
void ChangeLength( int aLength );
ELECTRICAL_PINTYPE GetType() const { return m_type; }
void SetType( ELECTRICAL_PINTYPE aType ) { m_type = aType; }

4
eeschema/tools/symbol_editor_pin_tool.cpp

@ -171,7 +171,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
else if( other->GetConvert() == aPin->GetConvert() )
{
other->SetPosition( aPin->GetPosition() );
other->SetLength( aPin->GetLength() );
other->ChangeLength( aPin->GetLength() );
other->SetShape( aPin->GetShape() );
}
@ -392,7 +392,7 @@ int SYMBOL_EDITOR_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
if( aEvent.IsAction( &EE_ACTIONS::pushPinLength ) )
{
if( !pin->GetConvert() || pin->GetConvert() == m_frame->GetConvert() )
pin->SetLength( sourcePin->GetLength() );
pin->ChangeLength( sourcePin->GetLength() );
}
else if( aEvent.IsAction( &EE_ACTIONS::pushPinNameSize ) )
{

Loading…
Cancel
Save