← Back to team overview

kicad-developers team mailing list archive

[PATCH] Add junction to 3-component (fixes lp:1737014)

 

​Patch 0001 fixes the bug reported at
https://bugs.launchpad.net/kicad/+bug/1737014

Patch 0002 fixes a separate issue I encountered while looking at this bug.
Two components that are directly connected ​still show the NC circle if
they are the same symbol but not if they are different symbols (see
screenshot).  The fix adds a "parent" tag to the connections allowing us to
distinguish which connections below to which symbol.

-Seth

Attachment: Screenshot_2017-12-07_12-29-04.png
Description: PNG image

From f2451b0523691d570e708be4e270148303b55470 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Thu, 7 Dec 2017 12:19:53 -0800
Subject: [PATCH 1/2] Eeschema: add junction to 3-component/wire connection

Fixes: lp:1737014
* https://bugs.launchpad.net/kicad/+bug/1737014
---
 eeschema/sch_screen.cpp | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index dc52d8d2f..d0c444a88 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -352,24 +352,25 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
     bool has_line = false;
     bool has_nonparallel = false;
     int end_count = 0;
-
+    int pin_count = 0;
     std::vector< SCH_LINE* > lines;
 
     for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
     {
         if( item->GetFlags() & STRUCT_DELETED )
             continue;
+
         if( aNew && ( item->Type() == SCH_JUNCTION_T ) && ( item->HitTest( aPosition ) ) )
             return false;
 
-        if( item->Type() != SCH_LINE_T )
-            continue;
-
-        if( item->GetLayer() != LAYER_WIRE )
-            continue;
-
-        if( item->HitTest( aPosition, 0 ) )
+        if( ( item->Type() == SCH_LINE_T )
+                && ( item->GetLayer() == LAYER_WIRE )
+                && ( item->HitTest( aPosition, 0 ) ) )
             lines.push_back( (SCH_LINE*) item );
+
+        if( ( item->Type() == SCH_COMPONENT_T )
+                && ( item->IsConnected( aPosition ) ) )
+            pin_count++;
     }
 
     BOOST_FOREACH( SCH_LINE* line, lines)
@@ -390,10 +391,12 @@ bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition, bool aNew )
         }
     }
 
-    int has_pin = !!( GetPin( aPosition, NULL, true ) );
+    // If there is line intersecting a pin
+    if( pin_count && has_line )
+        return true;
 
-    // If there is line intersecting a pin or non-parallel end
-    if( has_pin && ( has_line || end_count > 1 ) )
+    // If there are three or more endpoints
+    if( pin_count + end_count > 2 )
         return true;
 
     // If there is at least one segment that ends on a non-parallel line or
-- 
2.11.0

From 19df3c3ccd9b1292279df77d939f8df0e323c7d0 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Thu, 7 Dec 2017 12:23:02 -0800
Subject: [PATCH 2/2] Eeschema: calculate not-connected pins correctly

Show the NC box only on pins connected via the same component,
indicating a stacked pin group.  Do not show NC box on pins for
different components with the same symbol.
---
 eeschema/sch_component.cpp | 11 ++---------
 eeschema/sch_item_struct.h | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp
index c20f382c1..51b146486 100644
--- a/eeschema/sch_component.cpp
+++ b/eeschema/sch_component.cpp
@@ -1476,7 +1476,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
             if( pin->GetConvert() && m_convert && ( m_convert != pin->GetConvert() ) )
                 continue;
 
-            DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ) );
+            DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ), this );
             aItemList.push_back( item );
         }
     }
@@ -1507,14 +1507,7 @@ bool SCH_COMPONENT::IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM> &a
         // internal connection. While technically connected, it is not particularly useful
         // to display them that way, so skip any pins that are in the same symbol as this
         // one.
-        //
-        // Do not make this exception for hidden pins, because those actually make internal
-        // connections to a power net.
-        const LIB_PIN* item_pin = dynamic_cast<const LIB_PIN*>( each_item.GetItem() );
-
-        if( item_pin
-          && ( !item_pin->IsPowerConnection() || !IsInNetlist() )
-          && std::find( aLibPins.begin(), aLibPins.end(), item_pin) != aLibPins.end() )
+        if( each_item.GetParent() == this )
             continue;
 
         switch( each_item.GetType() )
diff --git a/eeschema/sch_item_struct.h b/eeschema/sch_item_struct.h
index 7daadb14a..8acd20c91 100644
--- a/eeschema/sch_item_struct.h
+++ b/eeschema/sch_item_struct.h
@@ -87,16 +87,30 @@ private:
     /// The type of connection of #m_item.
     DANGLING_END_T m_type;
 
+    /// A pointer to the parent object (in the case of pins)
+    const EDA_ITEM* m_parent;
+
 public:
     DANGLING_END_ITEM( DANGLING_END_T aType, const EDA_ITEM* aItem, const wxPoint& aPosition )
     {
         m_item = aItem;
         m_type = aType;
         m_pos = aPosition;
+        m_parent = aItem;
+    }
+
+    DANGLING_END_ITEM( DANGLING_END_T aType, const EDA_ITEM* aItem,
+            const wxPoint& aPosition, const EDA_ITEM* aParent )
+    {
+        m_item = aItem;
+        m_type = aType;
+        m_pos = aPosition;
+        m_parent = aParent;
     }
 
     wxPoint GetPosition() const { return m_pos; }
     const EDA_ITEM* GetItem() const { return m_item; }
+    const EDA_ITEM* GetParent() const { return m_parent; }
     DANGLING_END_T GetType() const { return m_type; }
 };
 
-- 
2.11.0


Follow ups