← Back to team overview

kicad-developers team mailing list archive

[PATCH 07/27] Replace DrawPinShape enum with PinShape

 

The bitmask requires a mapping to a different type used for the combobox,
and only few of the enumeration values actually make sense.

This removes the mapping, and uses a the same numbering throughout the
entire code.
---
 eeschema/dialogs/dialog_lib_edit_pin.cpp |   2 +-
 eeschema/dialogs/dialog_lib_edit_pin.h   |   4 +-
 eeschema/lib_pin.cpp                     | 219 ++++++++++++++++++-------------
 eeschema/lib_pin.h                       |  54 +++-----
 eeschema/pinedit.cpp                     |  20 +--
 5 files changed, 164 insertions(+), 135 deletions(-)

diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp
index 15954dd..85e5285 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp
@@ -129,7 +129,7 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
     int pinNumSize = ValueFromString( g_UserUnit, GetPadNameTextSize());
     int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
     int pinLength = ValueFromString( g_UserUnit, GetLength() );
-    int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
+    PinShape pinShape = GetStyle();
     int pinType = GetElectricalType();
 
     m_dummyPin->SetName( GetPinName() );
diff --git a/eeschema/dialogs/dialog_lib_edit_pin.h b/eeschema/dialogs/dialog_lib_edit_pin.h
index 948a32a..f292041 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin.h
@@ -68,8 +68,8 @@ public:
     }
 
     void SetStyleList( const wxArrayString& list, const BITMAP_DEF* aBitmaps );
-    void SetStyle( int style ) { m_choiceStyle->SetSelection( style ); }
-    int GetStyle( void ) { return m_choiceStyle->GetSelection(); }
+    void SetStyle( PinShape style ) { m_choiceStyle->SetSelection( style ); }
+    PinShape GetStyle( void ) { return static_cast<PinShape>( m_choiceStyle->GetSelection() ); }
 
     void SetPinName( const wxString& name ) { m_textPinName->SetValue( name ); }
     wxString GetPinName( void ) { return m_textPinName->GetValue(); }
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index 4ac66f2..813e912 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -86,22 +86,6 @@ static BITMAP_DEF iconsPinsShapes[] =
 };
 
 
-
-static const int pin_style_codes[] =
-{
-    NONE,
-    INVERT,
-    CLOCK,
-    CLOCK | INVERT,
-    LOWLEVEL_IN,
-    LOWLEVEL_IN | CLOCK,
-    LOWLEVEL_OUT,
-    CLOCK_FALL,
-    NONLOGIC
-};
-
-#define PIN_STYLE_CNT DIM( pin_style_codes )
-
 // bitmaps to show pins electrical type in dialog editor
 // must have same order than enum ElectricPinType (see lib_pin.h)
 static const BITMAP_DEF iconsPinsElectricalType[] =
@@ -200,7 +184,7 @@ const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType )
     return pin_electrical_type_names[ aPinsElectricalType ];
 }
 
-static const wxString getPinStyleName( unsigned aPinsStyle )
+static const wxString getPinStyleName( PinShape aPinsStyle )
 {
     const wxString pin_style_names[] =
     {   // Keep these translated strings not static
@@ -216,8 +200,8 @@ static const wxString getPinStyleName( unsigned aPinsStyle )
         wxT( "???" )
     };
 
-    if( aPinsStyle > PIN_STYLE_CNT )
-        aPinsStyle = PIN_STYLE_CNT;
+    if( aPinsStyle < 0 || aPinsStyle > int( PINSHAPE_COUNT ) )
+        aPinsStyle = static_cast<PinShape>( PINSHAPE_COUNT );
 
     return pin_style_names[ aPinsStyle ];
 }
@@ -241,11 +225,11 @@ static int ExternalPinDecoSize( const LIB_PIN &aPin )
 }
 
 LIB_PIN::LIB_PIN( LIB_PART*      aParent ) :
-    LIB_ITEM( LIB_PIN_T, aParent )
+    LIB_ITEM( LIB_PIN_T, aParent ),
+    m_shape( PINSHAPE_LINE )
 {
     m_length = LIB_EDIT_FRAME::GetDefaultPinLength();
     m_orientation = PIN_RIGHT;                  // Pin orient: Up, Down, Left, Right
-    m_shape = NONE;                             // Pin shape, bitwise.
     m_type = PIN_UNSPECIFIED;                   // electrical type of pin
     m_attributes = 0;                           // bit 0 != 0: pin invisible
     m_number = 0;                               // pin number (i.e. 4 ASCII chars)
@@ -378,8 +362,10 @@ void LIB_PIN::SetOrientation( int orientation )
 }
 
 
-void LIB_PIN::SetShape( int aShape )
+void LIB_PIN::SetShape( PinShape aShape )
 {
+    assert( aShape >= 0 && aShape < int( PINSHAPE_COUNT ) );
+
     if( m_shape != aShape )
     {
         m_shape = aShape;
@@ -691,23 +677,55 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
     if( !IsVisible() && aFormatter.Print( 0, "N" ) < 0 )
         return false;
 
-    if( m_shape & INVERT && aFormatter.Print( 0, "I" ) < 0 )
-        return false;
+    switch( m_shape )
+    {
+    case PINSHAPE_LINE:
+        break;
 
-    if( m_shape & CLOCK && aFormatter.Print( 0, "C" ) < 0 )
-        return false;
+    case PINSHAPE_INVERTED:
+        if( aFormatter.Print( 0, "I" ) < 0 )
+            return false;
+        break;
 
-    if( m_shape & LOWLEVEL_IN && aFormatter.Print( 0, "L" ) < 0 )
-        return false;
+    case PINSHAPE_CLOCK:
+        if( aFormatter.Print( 0, "C" ) < 0 )
+            return false;
+        break;
 
-    if( m_shape & LOWLEVEL_OUT && aFormatter.Print( 0, "V" ) < 0 )
-        return false;
+    case PINSHAPE_INVERTED_CLOCK:
+        if( aFormatter.Print( 0, "IC" ) < 0 )
+            return false;
+        break;
 
-    if( m_shape & CLOCK_FALL && aFormatter.Print( 0, "F" ) < 0 )
-        return false;
+    case PINSHAPE_INPUT_LOW:
+        if( aFormatter.Print( 0, "L" ) < 0 )
+            return false;
+        break;
 
-    if( m_shape & NONLOGIC && aFormatter.Print( 0, "X" ) < 0 )
+    case PINSHAPE_CLOCK_LOW:
+        if( aFormatter.Print( 0, "CL" ) < 0 )
+            return false;
+        break;
+
+    case PINSHAPE_OUTPUT_LOW:
+        if( aFormatter.Print( 0, "V" ) < 0 )
+            return false;
+        break;
+
+    case PINSHAPE_FALLING_EDGE_CLOCK:
+        if( aFormatter.Print( 0, "F" ) < 0 )
+            return false;
+        break;
+
+    case PINSHAPE_NONLOGIC:
+        if( aFormatter.Print( 0, "X" ) < 0 )
+            return false;
+        break;
+
+    default:
+        assert( !"Invalid pin shape" );
         return false;
+    }
 
     if( aFormatter.Print( 0, "\n" ) < 0 )
         return false;
@@ -797,6 +815,18 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
 
     if( i == 12 )       /* Special Symbol defined */
     {
+        enum
+        {
+            INVERTED        = 1 << 0,
+            CLOCK           = 1 << 1,
+            LOWLEVEL_IN     = 1 << 2,
+            LOWLEVEL_OUT    = 1 << 3,
+            FALLING_EDGE    = 1 << 4,
+            NONLOGIC        = 1 << 5
+        };
+
+        int flags = 0;
+
         for( j = strlen( pinAttrs ); j > 0; )
         {
             switch( pinAttrs[--j] )
@@ -809,27 +839,27 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
                 break;
 
             case 'I':
-                m_shape |= INVERT;
+                flags |= INVERTED;
                 break;
 
             case 'C':
-                m_shape |= CLOCK;
+                flags |= CLOCK;
                 break;
 
             case 'L':
-                m_shape |= LOWLEVEL_IN;
+                flags |= LOWLEVEL_IN;
                 break;
 
             case 'V':
-                m_shape |= LOWLEVEL_OUT;
+                flags |= LOWLEVEL_OUT;
                 break;
 
             case 'F':
-                m_shape |= CLOCK_FALL;
+                flags |= FALLING_EDGE;
                 break;
 
             case 'X':
-                m_shape |= NONLOGIC;
+                flags |= NONLOGIC;
                 break;
 
             default:
@@ -837,6 +867,49 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
                 return false;
             }
         }
+
+        switch( flags )
+        {
+        case 0:
+            m_shape = PINSHAPE_LINE;
+            break;
+
+        case INVERTED:
+            m_shape = PINSHAPE_INVERTED;
+            break;
+
+        case CLOCK:
+            m_shape = PINSHAPE_CLOCK;
+            break;
+
+        case INVERTED | CLOCK:
+            m_shape = PINSHAPE_INVERTED_CLOCK;
+            break;
+
+        case LOWLEVEL_IN:
+            m_shape = PINSHAPE_INPUT_LOW;
+            break;
+
+        case LOWLEVEL_IN | CLOCK:
+            m_shape = PINSHAPE_CLOCK_LOW;
+            break;
+
+        case LOWLEVEL_OUT:
+            m_shape = PINSHAPE_OUTPUT_LOW;
+            break;
+
+        case FALLING_EDGE:
+            m_shape = PINSHAPE_FALLING_EDGE_CLOCK;
+            break;
+
+        case NONLOGIC:
+            m_shape = PINSHAPE_NONLOGIC;
+            break;
+
+        default:
+            aErrorMsg.Printf( wxT( "pin attributes do not give a valid pin shape [%s]" ), pinAttrs );
+            return false;
+        }
     }
 
     return true;
@@ -964,7 +1037,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
         break;
     }
 
-    if( m_shape & INVERT )
+    if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK )
     {
         const int radius = ExternalPinDecoSize( *this );
         GRCircle( clipbox, aDC, MapX1 * radius + x1,
@@ -975,7 +1048,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
                   MapY1 * radius * 2 + y1 );
         GRLineTo( clipbox, aDC, posX, posY, width, color );
     }
-    else if( m_shape & CLOCK_FALL ) /* an alternative for Inverted Clock */
+    else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK ) /* an alternative for Inverted Clock */
     {
         const int clock_size = InternalPinDecoSize( *this );
         if( MapY1 == 0 ) /* MapX1 = +- 1 */
@@ -1020,7 +1093,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
         GRLineTo( clipbox, aDC, posX, posY, width, color );
     }
 
-    if( m_shape & CLOCK )
+    if( m_shape == PINSHAPE_CLOCK || m_shape == PINSHAPE_INVERTED_CLOCK || m_shape == PINSHAPE_CLOCK_LOW )
     {
         const int clock_size = InternalPinDecoSize( *this );
         if( MapY1 == 0 ) /* MapX1 = +- 1 */
@@ -1057,7 +1130,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
         }
     }
 
-    if( m_shape & LOWLEVEL_IN )     /* IEEE symbol "Active Low Input" */
+    if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW )
     {
         const int symbol_size = ExternalPinDecoSize( *this );
         if( MapY1 == 0 )            /* MapX1 = +- 1 */
@@ -1081,7 +1154,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
     }
 
 
-    if( m_shape & LOWLEVEL_OUT )    /* IEEE symbol "Active Low Output" */
+    if( m_shape == PINSHAPE_OUTPUT_LOW )    /* IEEE symbol "Active Low Output" */
     {
         const int symbol_size = ExternalPinDecoSize( *this );
         if( MapY1 == 0 )            /* MapX1 = +- 1 */
@@ -1105,7 +1178,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
                       color );
         }
     }
-    else if( m_shape & NONLOGIC ) /* NonLogic pin symbol */
+    else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
     {
         const int symbol_size = ExternalPinDecoSize( *this );
         GRMoveTo( x1 - (MapX1 + MapY1) * symbol_size,
@@ -1391,7 +1464,7 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
         break;
     }
 
-    if( m_shape & INVERT )
+    if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK )
     {
         const int radius = ExternalPinDecoSize( *this );
         aPlotter->Circle( wxPoint( MapX1 * radius + x1,
@@ -1404,7 +1477,7 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
                                     MapY1 * radius * 2 + y1 ) );
         aPlotter->FinishTo( aPosition );
     }
-    else if( m_shape & CLOCK_FALL )
+    else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK )
     {
         const int clock_size = InternalPinDecoSize( *this );
         if( MapY1 == 0 ) /* MapX1 = +- 1 */
@@ -1430,7 +1503,8 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
         aPlotter->FinishTo( aPosition );
     }
 
-    if( m_shape & CLOCK )
+    if( m_shape == PINSHAPE_CLOCK || m_shape == PINSHAPE_INVERTED_CLOCK ||
+        m_shape == PINSHAPE_CLOCK_LOW )
     {
         const int clock_size = InternalPinDecoSize( *this );
         if( MapY1 == 0 ) /* MapX1 = +- 1 */
@@ -1447,7 +1521,7 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
         }
     }
 
-    if( m_shape & LOWLEVEL_IN )   /* IEEE symbol "Active Low Input" */
+    if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW )    /* IEEE symbol "Active Low Input" */
     {
         const int symbol_size = ExternalPinDecoSize( *this );
         if( MapY1 == 0 )        /* MapX1 = +- 1 */
@@ -1467,7 +1541,7 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
     }
 
 
-    if( m_shape & LOWLEVEL_OUT )  /* IEEE symbol "Active Low Output" */
+    if( m_shape == PINSHAPE_OUTPUT_LOW )    /* IEEE symbol "Active Low Output" */
     {
         const int symbol_size = ExternalPinDecoSize( *this );
         if( MapY1 == 0 )        /* MapX1 = +- 1 */
@@ -1481,7 +1555,7 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
             aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
         }
     }
-    else if( m_shape & NONLOGIC ) /* NonLogic pin symbol */
+    else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
     {
         const int symbol_size = ExternalPinDecoSize( *this );
         aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * symbol_size,
@@ -1978,12 +2052,7 @@ void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
                                      LIB_PIN::GetElectricalTypeName( m_type ),
                                      RED ) );
 
-    int styleCodeIndex = GetStyleCodeIndex( m_shape );
-
-    if( styleCodeIndex >= 0 )
-        text = getPinStyleName( styleCodeIndex );
-    else
-        text = wxT( "?" );
+    text = getPinStyleName( m_shape );
 
     aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) );
 
@@ -2031,7 +2100,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox() const
     // Actual text height is bigger than text size
     int numberTextHeight  = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
 
-    if( m_shape & INVERT )
+    if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK )
         minsizeV = std::max( TARGET_PIN_RADIUS, ExternalPinDecoSize( *this ) );
 
     // calculate top left corner position
@@ -2182,36 +2251,13 @@ wxArrayString LIB_PIN::GetStyleNames( void )
 {
     wxArrayString tmp;
 
-    for( unsigned ii = 0; ii < PIN_STYLE_CNT; ii++ )
-        tmp.Add( getPinStyleName( ii ) );
+    for( unsigned ii = 0; ii < PINSHAPE_COUNT; ii++ )
+        tmp.Add( getPinStyleName( static_cast<PinShape>( ii ) ) );
 
     return tmp;
 }
 
 
-int LIB_PIN::GetStyleCode( int index )
-{
-    if( index >= 0 && index < (int) PIN_STYLE_CNT )
-        return pin_style_codes[ index ];
-
-    return NONE;
-}
-
-
-int LIB_PIN::GetStyleCodeIndex( int code )
-{
-    size_t i;
-
-    for( i = 0; i < PIN_STYLE_CNT; i++ )
-    {
-        if( pin_style_codes[i] == code )
-            return (int) i;
-    }
-
-    return wxNOT_FOUND;
-}
-
-
 wxArrayString LIB_PIN::GetElectricalTypeNames( void )
 {
     wxArrayString tmp;
@@ -2252,12 +2298,7 @@ wxString LIB_PIN::GetSelectMenuText() const
     wxString tmp;
     wxString style;
 
-    int styleCode = GetStyleCodeIndex( m_shape );
-
-    if( styleCode >= 0 )
-        style = getPinStyleName( styleCode );
-    else
-        style = wxT( "?" );
+    style = getPinStyleName( m_shape );
 
     tmp.Printf( _( "Pin %s, %s, %s" ),
                 GetChars( GetNumberString() ),
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index 430cec9..912b517 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -58,17 +58,23 @@ enum ElectricPinType {
 #define PIN_INVISIBLE 1    /* Set makes pin invisible */
 
 
-/**
- * The component library pin object drawing shapes.
- */
-enum DrawPinShape {
-    NONE         = 0,
-    INVERT       = 1,
-    CLOCK        = 2,
-    LOWLEVEL_IN  = 4,
-    LOWLEVEL_OUT = 8,
-    CLOCK_FALL   = 0x10, /* this is common form for inverted clock in Eastern Block */
-    NONLOGIC     = 0x20
+enum PinShape
+{
+    PINSHAPE_LINE,
+    PINSHAPE_INVERTED,
+    PINSHAPE_CLOCK,
+    PINSHAPE_INVERTED_CLOCK,
+    PINSHAPE_INPUT_LOW,
+    PINSHAPE_CLOCK_LOW,
+    PINSHAPE_OUTPUT_LOW,
+    PINSHAPE_FALLING_EDGE_CLOCK,
+    PINSHAPE_NONLOGIC
+};
+
+
+enum
+{
+    PINSHAPE_COUNT = PINSHAPE_NONLOGIC + 1
 };
 
 
@@ -88,7 +94,7 @@ class LIB_PIN : public LIB_ITEM
     wxPoint  m_position;     ///< Position of the pin.
     int      m_length;       ///< Length of the pin.
     int      m_orientation;  ///< Pin orientation (Up, Down, Left, Right)
-    int      m_shape;        ///< Bitwise ORed of pin shapes (see enum DrawPinShape)
+    PinShape m_shape;        ///< Shape drawn around pin
     int      m_width;        ///< Line width of the pin.
     int      m_type;         ///< Electrical type of the pin.  See enum ElectricPinType.
     int      m_attributes;   ///< Set bit 0 to indicate pin is invisible.
@@ -248,16 +254,16 @@ public:
 
     void Rotate();
 
-    int GetShape() const { return m_shape; }
+    PinShape GetShape() const { return m_shape; }
 
     /**
      * Set the shape of the pin to \a aShape.
      *
      * This will also update the draw style of the pins marked by EnableEditMode().
      *
-     * @param aShape - The draw shape of the pin.  See enum DrawPinShape.
+     * @param aShape - The draw shape of the pin.  See enum PinShape.
      */
-    void SetShape( int aShape );
+    void SetShape( PinShape aShape );
 
     /**
      * Get the electrical type of the pin.
@@ -470,24 +476,6 @@ public:
     static const BITMAP_DEF* GetStyleSymbols();
 
     /**
-     * Get the pin draw style code by index used to set the pin draw style.
-     *
-     * @param aIndex - The index of the pin draw style code to look up.
-     * @return  Pin draw style code if index is valid.  Returns NONE
-     *          style on index error.
-     */
-    static int GetStyleCode( int aIndex );
-
-    /**
-     * Get the index of the pin draw style code.
-     *
-     * @param aCode - The pin draw style code to look up.
-     * @return The index of the pin draw style code if found.  Otherwise,
-     *         return wxNOT_FOUND.
-     */
-    static int GetStyleCodeIndex( int aCode );
-
-    /**
      * Get a list of pin electrical type names.
      *
      * @return  List of valid pin electrical type names.
diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp
index 58c706a..9802599 100644
--- a/eeschema/pinedit.cpp
+++ b/eeschema/pinedit.cpp
@@ -53,14 +53,14 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC );
 static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase );
 
 
-static wxPoint OldPos;
-static wxPoint PinPreviousPos;
-static int     LastPinType          = PIN_INPUT;
-static int     LastPinOrient        = PIN_RIGHT;
-static int     LastPinShape         = NONE;
-static bool    LastPinCommonConvert = false;
-static bool    LastPinCommonUnit    = false;
-static bool    LastPinVisible       = true;
+static wxPoint  OldPos;
+static wxPoint  PinPreviousPos;
+static int      LastPinType = PIN_INPUT;
+static int      LastPinOrient = PIN_RIGHT;
+static PinShape LastPinShape = PINSHAPE_LINE;
+static bool     LastPinCommonConvert = false;
+static bool     LastPinCommonUnit = false;
+static bool     LastPinVisible = true;
 
 // The -1 is a non-valid value to trigger delayed initialization
 static int     LastPinLength        = -1;
@@ -105,7 +105,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
     dlg.SetOrientationList( LIB_PIN::GetOrientationNames(), LIB_PIN::GetOrientationSymbols() );
     dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->GetOrientation() ) );
     dlg.SetStyleList( LIB_PIN::GetStyleNames(), LIB_PIN::GetStyleSymbols() );
-    dlg.SetStyle( LIB_PIN::GetStyleCodeIndex( pin->GetShape() ) );
+    dlg.SetStyle( pin->GetShape() );
     dlg.SetElectricalTypeList( LIB_PIN::GetElectricalTypeNames(),
                                LIB_PIN::GetElectricalTypeSymbols() );
     dlg.SetElectricalType( pin->GetType() );
@@ -147,7 +147,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
     LastPinNumSize = ValueFromString( g_UserUnit, dlg.GetPadNameTextSize() );
     LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
     LastPinLength = ValueFromString( g_UserUnit, dlg.GetLength() );
-    LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
+    LastPinShape = dlg.GetStyle();
     LastPinType = dlg.GetElectricalType();
     LastPinCommonConvert = dlg.GetAddToAllBodyStyles();
     LastPinCommonUnit = dlg.GetAddToAllParts();

Follow ups

References