kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24723
[PATCH] Schematic Cleanup: Split lines at junctions
---
eeschema/bus-wire-junction.cpp | 3 +++
eeschema/sch_screen.cpp | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp
index 44dcdf3..36a416d 100644
--- a/eeschema/bus-wire-junction.cpp
+++ b/eeschema/bus-wire-junction.cpp
@@ -431,6 +431,9 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition,
OnModify();
}
+ // Split segments at junctions
+ GetScreen()->SchematicCleanUp();
+
return junction;
}
diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index bd60012..62577b3 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -522,6 +522,24 @@ bool SCH_SCREEN::SchematicCleanUp()
modified = true;
}
}
+ else if( lhs_isJunction && rhs_isLine )
+ {
+ auto lhs_pos = item->GetPosition();
+
+ SCH_LINE* rhs_line = (SCH_LINE*) testItem;
+
+ auto start_pos = rhs_line->GetStartPoint();
+ auto end_pos = rhs_line->GetEndPoint();
+
+ if( lhs_pos != start_pos && lhs_pos != end_pos && rhs_line->HitTest( lhs_pos, 0 ) )
+ {
+ // Split segment at junction
+ SCH_LINE* new_line = new SCH_LINE( *rhs_line );
+ rhs_line->SetEndPoint( lhs_pos );
+ new_line->SetStartPoint( lhs_pos );
+ Append( new_line );
+ }
+ }
}
}
Follow ups