← Back to team overview

kicad-developers team mailing list archive

[PATCH] Show bus entry joining two wires as dangling

 

Another improvement to the pin/entry targets: if a bus entry is drawn between
two WIRES (not a wire and a bus, or two buses), it looks like it's connecting
the wires together, but doesn't actually represent a connection. This patch
makes it display as dangling in that case, to make it clear to the user that
a connection has not actually been made.

--
Chris
commit 04217c50d45ce0ed4e291c24e559da133aa4e181
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
Date:   Mon Jun 15 11:05:25 2015 -0400

    Show bus entry joining two wires as dangling

diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp
index c655750..1819cae 100644
--- a/eeschema/sch_bus_entry.cpp
+++ b/eeschema/sch_bus_entry.cpp
@@ -258,6 +258,12 @@ bool SCH_BUS_ENTRY_BASE::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>&
     // when the end position is found.
     wxPoint seg_start;
 
+    // Special case: if both items are wires, show as dangling. This is because
+    // a bus entry between two wires will look like a connection, but does NOT
+    // actually represent one. We need to clarify this for the user.
+    bool start_is_wire = false;
+    bool end_is_wire = false;
+
     BOOST_FOREACH( DANGLING_END_ITEM& each_item, aItemList )
     {
         if( each_item.GetItem() == this )
@@ -269,17 +275,29 @@ bool SCH_BUS_ENTRY_BASE::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>&
         case BUS_START_END:
             seg_start = each_item.GetPosition();
             break;
+
         case WIRE_END_END:
+            if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) )
+                start_is_wire = true;
+            if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_End() ) )
+                end_is_wire = true;
+            // Fall through
+
         case BUS_END_END:
             if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) )
                 m_isDanglingStart = false;
             if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_End() ) )
                 m_isDanglingEnd = false;
+            break;
         default:
             break;
         }
     }
 
+    // See above: show as dangling if joining two wires
+    if( start_is_wire && end_is_wire )
+        m_isDanglingStart = m_isDanglingEnd = true;
+
     return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
 }
 

Follow ups