If you place a wire segment and then backtrack over it, you end up with a broken wire in the end:
http://misc.c4757p.com/backtrack.mp4 This is because the two segments are merged together, rather than the second *subtracting* from the first, even though the latter case is the way it's shown as you're drawing. This patch fixes that by adding a function to erase backtracks. -- Chris
commit d18fec08e34f7b509553fc72ee0616eeda6579a6 Author: Chris Pavlina <[email protected]> Date: Mon Jun 22 16:16:50 2015 -0400 Remove backtracking segments when drawing wires diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index a33f7b5..eb86ba5 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -43,6 +43,7 @@ #include <sch_text.h> #include <sch_component.h> #include <sch_sheet.h> +#include <trigo.h> static void AbortCreateNewLine( EDA_DRAW_PANEL* aPanel, wxDC* aDC ); @@ -53,6 +54,45 @@ static DLIST< SCH_ITEM > s_wires; // when creating a new set of wires, /** + * In a contiguous list of wires, remove wires that backtrack over the previous + * wire. Example: + * + * Wire is added: + * ----------------------------------------> + * + * A second wire backtracks over it: + * -------------------<====================> + * + * RemoveBacktracks is called: + * -------------------> + */ +static void RemoveBacktracks( DLIST<SCH_ITEM>& aWires ) +{ + SCH_LINE* last_line = NULL; + + EDA_ITEM* first = aWires.GetFirst(); + for( EDA_ITEM* p = first; p; p = p->Next() ) + { + SCH_LINE *line = dynamic_cast<SCH_LINE*>( p ); + + if( p != first ) + { + wxASSERT_MSG( last_line->GetEndPoint() == line->GetStartPoint(), + "RemoveBacktracks() requires contiguous lines" ); + if( IsPointOnSegment( last_line->GetStartPoint(), line->GetStartPoint(), + line->GetEndPoint() ) ) + { + last_line->SetEndPoint( line->GetEndPoint() ); + delete s_wires.Remove( line ); + p = line; + } + } + last_line = line; + } +} + + +/** * Mouse capture callback for drawing line segments. */ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, @@ -261,6 +301,9 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE ); + // Remove segments backtracking over others + RemoveBacktracks( s_wires ); + // Add the new wires screen->Append( s_wires );
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

