← Back to team overview

kicad-developers team mailing list archive

[PATCH] Drag components with line in Eeschema

 

​The attached patch fixes
https://bugs.launchpad.net/kicad/+bug/1167714

This happens when you drag a full line that is connected to a component.
Previously, the component would disconnect from any other lines as it was
dragged.  Images documenting this are in the linked bug report

Best-
Seth
​​
From 1a8dc3434febc9d892c4f5551a3f407cbb2a92a1 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Wed, 15 Nov 2017 14:51:18 -0800
Subject: [PATCH] Eeschema: Select component connections in drag

Dragging a full line that is connected to a component
now drags the component as part of the block, maintaining
connections.

Fixes: lp:1167714
* https://bugs.launchpad.net/kicad/+bug/1167714
---
 eeschema/sch_screen.cpp | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index a6c138930..86fdefa73 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -767,6 +767,14 @@ void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems )
 
 void SCH_SCREEN::SelectBlockItems()
 {
+    auto addConnections = [ this ]( SCH_ITEM* item ) -> void
+    {
+        std::vector< wxPoint > connections;
+        item->GetConnectionPoints( connections );
+        for( auto conn : connections )
+            addConnectedItemsToBlock( conn );
+    };
+
     PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
 
     if( pickedlist->GetCount() == 0 )
@@ -804,23 +812,27 @@ void SCH_SCREEN::SelectBlockItems()
                 // so we must keep it selected and select items connected to it
                 // Note: an other option could be: remove it from drag list
                 item->SetFlags( SELECTED | SKIP_STRUCT );
-                std::vector< wxPoint > connections;
-                item->GetConnectionPoints( connections );
-
-                for( size_t i = 0; i < connections.size(); i++ )
-                    addConnectedItemsToBlock( connections[i] );
+                addConnections( item );
             }
 
             pickedlist->SetPickerFlags( item->GetFlags(), ii );
         }
         else if( item->IsConnectable() )
         {
-            std::vector< wxPoint > connections;
+            addConnections( item );
+        }
+    }
 
-            item->GetConnectionPoints( connections );
+    // Select the items that are connected to a component that was added
+    // to our selection list in the last step.
+    for( unsigned ii = last_select_id; ii < pickedlist->GetCount(); ii++ )
+    {
+        SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
 
-            for( size_t jj = 0; jj < connections.size(); jj++ )
-                addConnectedItemsToBlock( connections[jj] );
+        if( item->Type() == SCH_COMPONENT_T )
+        {
+            item->SetFlags( IS_DRAGGED );
+            addConnections( item );
         }
     }
 
-- 
2.11.0


Follow ups