As part of standardising the visual style of connectors, the standard KiCad
libraries now draw connectors with special art on each pin.

I have made a small patch which adds a 'Connector' pin visual style to the
available options, which removes the need for hand-drawn art and makes this
process easier.

gallery:

https://imgur.com/a/HIecX

Patch file attached. Is this something that will be appreciated?

Oliver
From 52210ca4c651fd20527261d931581b96effa2fdb Mon Sep 17 00:00:00 2001
From: Oliver <oliver.henry.walt...@gmail.com>
Date: Thu, 19 Oct 2017 00:12:53 +1100
Subject: [PATCH] Added 'connector' pin style

- Draws small rectangle with entry pin
- Save / load
- Icon
---
 bitmaps_png/CMakeLists.txt                 |  1 +
 bitmaps_png/cpp_16/pinshape_connector.cpp  | 22 +++++++++
 bitmaps_png/sources/pinshape_connector.svg | 75 ++++++++++++++++++++++++++++++
 eeschema/class_library.h                   |  3 +-
 eeschema/lib_pin.cpp                       | 49 +++++++++++++++++++
 eeschema/pin_shape.cpp                     |  6 +++
 eeschema/pin_shape.h                       |  1 +
 eeschema/sch_legacy_plugin.cpp             | 49 +++++++++++--------
 include/bitmaps.h                          |  1 +
 9 files changed, 186 insertions(+), 21 deletions(-)
 create mode 100644 bitmaps_png/cpp_16/pinshape_connector.cpp
 create mode 100644 bitmaps_png/sources/pinshape_connector.svg

diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt
index 7e88233..581ded2 100644
--- a/bitmaps_png/CMakeLists.txt
+++ b/bitmaps_png/CMakeLists.txt
@@ -86,6 +86,7 @@ set( BMAPS_SMALL
     pinshape_clock_active_low
     pinshape_active_low_output
     pinshape_clock_fall
+    pinshape_connector
     pinshape_nonlogic
     pintype_input
     pintype_output
diff --git a/bitmaps_png/cpp_16/pinshape_connector.cpp b/bitmaps_png/cpp_16/pinshape_connector.cpp
new file mode 100644
index 0000000..4efbe45
--- /dev/null
+++ b/bitmaps_png/cpp_16/pinshape_connector.cpp
@@ -0,0 +1,22 @@
+
+/* Do not modify this file, it was automatically generated by the
+ * PNG2cpp CMake script, using a *.png file as input.
+ */
+
+#include <bitmaps.h>
+
+static const unsigned char png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff,
+ 0x61, 0x00, 0x00, 0x00, 0x57, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0x63, 0x60, 0xc0, 0x03, 0xa4,
+ 0xa4, 0xa4, 0xb6, 0x03, 0xf1, 0x7f, 0x09, 0x09, 0x09, 0x4f, 0x06, 0x72, 0xc0, 0x10, 0x31, 0x40,
+ 0x5c, 0x5c, 0x5c, 0x11, 0x17, 0x96, 0x96, 0x96, 0x3e, 0x40, 0xd0, 0x00, 0x90, 0x02, 0x42, 0x98,
+ 0x18, 0x03, 0xd6, 0x03, 0x6d, 0x8b, 0xc7, 0x82, 0x2f, 0x11, 0x6b, 0x40, 0x03, 0x12, 0x3f, 0x17,
+ 0xe4, 0x74, 0x28, 0x7e, 0x0b, 0x92, 0x07, 0x19, 0x84, 0x24, 0x86, 0x82, 0xa9, 0x66, 0x00, 0xc5,
+ 0x5e, 0x20, 0x3f, 0x10, 0x29, 0x8e, 0xc6, 0xd1, 0xbc, 0xc0, 0x00, 0x00, 0x4a, 0x48, 0x6a, 0xa5,
+ 0x2e, 0x78, 0x5a, 0x63, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
+};
+
+const BITMAP_OPAQUE pinshape_connector_xpm[1] = {{ png, sizeof( png ), "pinshape_connector_xpm" }};
+
+//EOF
diff --git a/bitmaps_png/sources/pinshape_connector.svg b/bitmaps_png/sources/pinshape_connector.svg
new file mode 100644
index 0000000..3b8fc0d
--- /dev/null
+++ b/bitmaps_png/sources/pinshape_connector.svg
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   height="16"
+   width="16"
+   version="1.1"
+   id="svg2"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="pinshape_connector.svg">
+  <metadata
+     id="metadata22">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs20" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1855"
+     inkscape:window-height="1056"
+     id="namedview18"
+     showgrid="true"
+     inkscape:zoom="17.65625"
+     inkscape:cx="14.358419"
+     inkscape:cy="-1.1268556"
+     inkscape:window-x="65"
+     inkscape:window-y="24"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg2">
+    <inkscape:grid
+       type="xygrid"
+       id="grid2999"
+       empspacing="2"
+       visible="true"
+       enabled="true"
+       snapvisiblegridlinesonly="true" />
+  </sodipodi:namedview>
+  <path
+     d="m 8.2839791,0 0,16"
+     id="path12"
+     inkscape:connector-curvature="0"
+     style="fill:none;stroke:#1a1a1a;stroke-width:2;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none"
+     sodipodi:nodetypes="cc" />
+  <path
+     d="M 4.4286266,8 16,8"
+     id="path14"
+     inkscape:connector-curvature="0"
+     style="fill:none;stroke:#1a1a1a;stroke-width:1.5;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none"
+     sodipodi:nodetypes="cc" />
+  <path
+     style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#1a1a1a;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+     d="m 8.3392612,5.6192035 -7.5892612,0 0,4.7615935 8.2119976,0"
+     id="path4136"
+     inkscape:connector-curvature="0" />
+</svg>
diff --git a/eeschema/class_library.h b/eeschema/class_library.h
index 23bbe8f..cac4f40 100644
--- a/eeschema/class_library.h
+++ b/eeschema/class_library.h
@@ -53,7 +53,8 @@ class SCH_PLUGIN;
  * Part Library version and file header  macros.
  */
 #define LIB_VERSION_MAJOR 2
-#define LIB_VERSION_MINOR 4
+//#define LIB_VERSION_MINOR 4
+#define LIB_VERSION_MINOR 5  // Added 'connector' pin graphical style Oct 2017
 
 /* Must be the first line of part library (.lib) files. */
 #define LIBFILE_IDENT     "EESchema-LIBRARY Version"
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index 1f99840..7c898a3 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -658,6 +658,11 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
             return false;
         break;
 
+    case PINSHAPE_CONNECTOR:
+        if( aFormatter.Print( 0, "P" ) < 0 )
+            return false;
+        break;
+
     case PINSHAPE_NONLOGIC:
         if( aFormatter.Print( 0, "X" ) < 0 )
             return false;
@@ -1099,6 +1104,50 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
         }
     }
 
+    if( m_shape == PINSHAPE_CONNECTOR )
+    {
+        const int conn_size = InternalPinDecoSize( *this );
+
+        // Dimensions of internal U shape
+        const int L = conn_size * 1.5;
+        const int W = conn_size * 0.75;
+
+        if( MapY1 == 0 ) /* MapX1 = +- 1 */
+        {
+            // Draw the small line inside the 'U' shape
+            GRMoveTo( x1, y1 );
+            GRLineTo( clipbox, aDC, x1 - MapX1 * conn_size * 0.75, y1,
+                      width, color );
+
+            // Draw the 'U' shape
+            GRMoveTo( x1, y1 - W );
+            GRLineTo( clipbox, aDC, x1 - MapX1 * L, y1 - W,
+                      width, color );
+
+            GRLineTo( clipbox, aDC, x1 - MapX1 * L, y1 + W,
+                      width, color );
+
+            GRLineTo( clipbox, aDC, x1, y1 + W,
+                      width, color );
+        }
+        else    /* MapX1 = 0 */
+        {
+            // Draw the small line inside the 'U' shape
+            GRMoveTo( x1, y1 );
+            GRLineTo( clipbox, aDC, x1, y1 - MapY1 * conn_size * 0.75,
+                      width, color );
+
+            // Draw the 'U' shape
+            GRMoveTo( x1 - W, y1 );
+            GRLineTo( clipbox, aDC, x1 - W, y1 - MapY1 * L,
+                      width, color );
+            GRLineTo( clipbox, aDC, x1 + W, y1 - MapY1 * L,
+                      width, color );
+            GRLineTo( clipbox, aDC, x1 + W, y1,
+                      width, color );
+        }
+    }
+
     if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW )
     {
         const int symbol_size = ExternalPinDecoSize( *this );
diff --git a/eeschema/pin_shape.cpp b/eeschema/pin_shape.cpp
index f59dbb4..570d895 100644
--- a/eeschema/pin_shape.cpp
+++ b/eeschema/pin_shape.cpp
@@ -58,6 +58,9 @@ wxString GetText( GRAPHIC_PINSHAPE shape )
     case PINSHAPE_FALLING_EDGE_CLOCK:
         return _( "Falling edge clock" );
 
+    case PINSHAPE_CONNECTOR:
+        return _( "Connector" );
+
     case PINSHAPE_NONLOGIC:
         return _( "NonLogic" );
     }
@@ -95,6 +98,9 @@ BITMAP_DEF GetBitmap( GRAPHIC_PINSHAPE shape )
     case PINSHAPE_FALLING_EDGE_CLOCK:
         return pinshape_clock_fall_xpm;
 
+    case PINSHAPE_CONNECTOR:
+        return pinshape_connector_xpm;
+
     case PINSHAPE_NONLOGIC:
         return pinshape_nonlogic_xpm;
     }
diff --git a/eeschema/pin_shape.h b/eeschema/pin_shape.h
index 25f11b9..9bb2a5c 100644
--- a/eeschema/pin_shape.h
+++ b/eeschema/pin_shape.h
@@ -42,6 +42,7 @@ enum GRAPHIC_PINSHAPE
     PINSHAPE_CLOCK_LOW,
     PINSHAPE_OUTPUT_LOW,
     PINSHAPE_FALLING_EDGE_CLOCK,
+    PINSHAPE_CONNECTOR,
     PINSHAPE_NONLOGIC
 };
 
diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp
index c73dad3..1537333 100644
--- a/eeschema/sch_legacy_plugin.cpp
+++ b/eeschema/sch_legacy_plugin.cpp
@@ -3102,12 +3102,13 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr< LIB_PART >& aPart,
     {
         enum
         {
-            INVERTED        = 1 << 0,
-            CLOCK           = 1 << 1,
-            LOWLEVEL_IN     = 1 << 2,
-            LOWLEVEL_OUT    = 1 << 3,
-            FALLING_EDGE    = 1 << 4,
-            NONLOGIC        = 1 << 5
+            PIN_ATTR_INVERTED        = 1 << 0,
+            PIN_ATTR_CLOCK           = 1 << 1,
+            PIN_ATTR_LOWLEVEL_IN     = 1 << 2,
+            PIN_ATTR_LOWLEVEL_OUT    = 1 << 3,
+            PIN_ATTR_FALLING_EDGE    = 1 << 4,
+            PIN_ATTR_CONNECTOR       = 1 << 5,
+            PIN_ATTR_NONLOGIC        = 1 << 6
         };
 
         int flags = 0;
@@ -3124,27 +3125,31 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr< LIB_PART >& aPart,
                 break;
 
             case 'I':
-                flags |= INVERTED;
+                flags |= PIN_ATTR_INVERTED;
                 break;
 
             case 'C':
-                flags |= CLOCK;
+                flags |= PIN_ATTR_CLOCK;
                 break;
 
             case 'L':
-                flags |= LOWLEVEL_IN;
+                flags |= PIN_ATTR_LOWLEVEL_IN;
                 break;
 
             case 'V':
-                flags |= LOWLEVEL_OUT;
+                flags |= PIN_ATTR_LOWLEVEL_OUT;
                 break;
 
             case 'F':
-                flags |= FALLING_EDGE;
+                flags |= PIN_ATTR_FALLING_EDGE;
                 break;
 
             case 'X':
-                flags |= NONLOGIC;
+                flags |= PIN_ATTR_NONLOGIC;
+                break;
+
+            case 'P':
+                flags |= PIN_ATTR_CONNECTOR;
                 break;
 
             default:
@@ -3158,35 +3163,39 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr< LIB_PART >& aPart,
             pin->SetShape( PINSHAPE_LINE );
             break;
 
-        case INVERTED:
+        case PIN_ATTR_INVERTED:
             pin->SetShape( PINSHAPE_INVERTED );
             break;
 
-        case CLOCK:
+        case PIN_ATTR_CLOCK:
             pin->SetShape( PINSHAPE_CLOCK );
             break;
 
-        case INVERTED | CLOCK:
+        case PIN_ATTR_INVERTED | PIN_ATTR_CLOCK:
             pin->SetShape( PINSHAPE_INVERTED_CLOCK );
             break;
 
-        case LOWLEVEL_IN:
+        case PIN_ATTR_LOWLEVEL_IN:
             pin->SetShape( PINSHAPE_INPUT_LOW );
             break;
 
-        case LOWLEVEL_IN | CLOCK:
+        case PIN_ATTR_LOWLEVEL_IN | PIN_ATTR_CLOCK:
             pin->SetShape( PINSHAPE_CLOCK_LOW );
             break;
 
-        case LOWLEVEL_OUT:
+        case PIN_ATTR_LOWLEVEL_OUT:
             pin->SetShape( PINSHAPE_OUTPUT_LOW );
             break;
 
-        case FALLING_EDGE:
+        case PIN_ATTR_FALLING_EDGE:
             pin->SetShape( PINSHAPE_FALLING_EDGE_CLOCK );
             break;
 
-        case NONLOGIC:
+        case PIN_ATTR_CONNECTOR:
+            pin->SetShape( PINSHAPE_CONNECTOR );
+            break;
+
+        case PIN_ATTR_NONLOGIC:
             pin->SetShape( PINSHAPE_NONLOGIC );
             break;
 
diff --git a/include/bitmaps.h b/include/bitmaps.h
index 800ec2d..0c81548 100644
--- a/include/bitmaps.h
+++ b/include/bitmaps.h
@@ -368,6 +368,7 @@ EXTERN_BITMAP( pinshape_invert_xpm )
 EXTERN_BITMAP( pinshape_clock_fall_xpm )
 EXTERN_BITMAP( pinshape_clock_normal_xpm )
 EXTERN_BITMAP( pinshape_clock_invert_xpm )
+EXTERN_BITMAP( pinshape_connector_xpm )
 EXTERN_BITMAP( pinshape_active_low_input_xpm )
 EXTERN_BITMAP( pinshape_clock_active_low_xpm )
 EXTERN_BITMAP( pinshape_active_low_output_xpm )
-- 
2.7.4

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to