kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #30995
[PATCH] Clean up unused junctions
Hi All-
Currently, when laying wire in eeschema, junctions are automatically added
where needed. This patch provides the reverse. When deleting segments in
eeschema, it automatically removes the junction if it is no longer needed.
This should save extra clicks when re-wiring and hopefully help new Kicad
users keep their schematics cleaner.
Best-
Seth
From 5092561b2d879df2156f1798055bec48fa1e94b6 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Tue, 26 Sep 2017 16:17:14 -0700
Subject: [PATCH 1/1] Eeschema: Automatically remove dangling junctions
---
eeschema/operations_on_items_lists.cpp | 23 ++++++++++++++++++++++-
eeschema/sch_screen.cpp | 3 ---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp
index 6f0b790c2..5e7502854 100644
--- a/eeschema/operations_on_items_lists.cpp
+++ b/eeschema/operations_on_items_lists.cpp
@@ -175,8 +175,29 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
}
else
{
+ PICKED_ITEMS_LIST delete_list;
+
screen->Remove( aItem );
- SaveCopyInUndoList( aItem, UR_DELETED );
+ delete_list.PushItem(aItem);
+
+ if ( aItem->Type() == SCH_LINE_T ) {
+
+ SCH_LINE* segment = (SCH_LINE*) aItem;
+ SCH_ITEM* item;
+ // Clean out junctions that are no longer needed
+ if( !screen->IsJunctionNeeded( segment->GetEndPoint() ) &&
+ ( item = screen->GetItem( segment->GetEndPoint(), 0, SCH_JUNCTION_T ) ) ) {
+ delete_list.PushItem( item );
+ screen->Remove( item );
+ }
+
+ if( !screen->IsJunctionNeeded( segment->GetStartPoint() ) &&
+ ( item = screen->GetItem( segment->GetStartPoint(), 0, SCH_JUNCTION_T ) ) ) {
+ delete_list.PushItem( item );
+ screen->Remove( item );
+ }
+ }
+ SaveCopyInUndoList( delete_list, UR_DELETED );
m_canvas->RefreshDrawingRect( aItem->GetBoundingBox() );
}
}
diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index 02f2030d1..b2d6e6c1d 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -336,9 +336,6 @@ void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition )
{
- if( GetItem( aPosition, 0, SCH_JUNCTION_T ) )
- return false;
-
if( GetWire( aPosition, 0, EXCLUDE_END_POINTS_T ) )
{
if( GetWire( aPosition, 0, END_POINTS_ONLY_T ) )
--
2.11.0
Follow ups