Eeschema: bug fix: when creating new connections, junctions were not always automatically added when needed.
Fix an other minor bug.
This commit is contained in:
parent
0459b4dafa
commit
7f16520498
|
@ -50,10 +50,10 @@
|
||||||
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
||||||
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos );
|
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos );
|
||||||
|
|
||||||
static DLIST< SCH_ITEM > s_wires;
|
static DLIST< SCH_ITEM > s_wires; // when creating a new set of wires,
|
||||||
static DLIST< SCH_ITEM > s_oldWires;
|
// stores here the new wires.
|
||||||
|
static DLIST< SCH_ITEM > s_oldWires; // when creating a new set of wires,
|
||||||
static wxPoint s_startPoint;
|
// stores here the old wires (for undo command)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,7 +125,6 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
|
||||||
|
|
||||||
if( !segment ) /* first point : Create first wire or bus */
|
if( !segment ) /* first point : Create first wire or bus */
|
||||||
{
|
{
|
||||||
s_startPoint = cursorpos;
|
|
||||||
GetScreen()->ExtractWires( s_oldWires, true );
|
GetScreen()->ExtractWires( s_oldWires, true );
|
||||||
GetScreen()->SchematicCleanUp( m_canvas );
|
GetScreen()->SchematicCleanUp( m_canvas );
|
||||||
|
|
||||||
|
@ -228,50 +227,40 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
|
||||||
wxCHECK_RET( item->Type() == SCH_LINE_T, wxT( "Unexpected object type in wire list." ) );
|
wxCHECK_RET( item->Type() == SCH_LINE_T, wxT( "Unexpected object type in wire list." ) );
|
||||||
|
|
||||||
segment = (SCH_LINE*) item;
|
segment = (SCH_LINE*) item;
|
||||||
|
item = item->Next();
|
||||||
|
|
||||||
if( segment->IsNull() )
|
if( segment->IsNull() )
|
||||||
{
|
delete s_wires.Remove( segment );
|
||||||
wxLogDebug( wxT( "Removing null segment: " ) + segment->GetSelectMenuText() );
|
|
||||||
|
|
||||||
SCH_ITEM* previousSegment = item->Back();
|
|
||||||
|
|
||||||
delete s_wires.Remove( item );
|
|
||||||
|
|
||||||
if( previousSegment == NULL )
|
|
||||||
item = s_wires.begin();
|
|
||||||
else
|
|
||||||
item = previousSegment;
|
|
||||||
wxLogDebug( wxT( "Segment count after removal: %d" ), s_wires.GetCount() );
|
|
||||||
}
|
|
||||||
|
|
||||||
item = item->Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( s_wires.GetCount() == 0 )
|
if( s_wires.GetCount() == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the last non-null wire.
|
// Get the last non-null wire (this is the last created segment).
|
||||||
m_itemToRepeat = segment = (SCH_LINE*) s_wires.GetLast();
|
m_itemToRepeat = segment = (SCH_LINE*) s_wires.GetLast();
|
||||||
screen->SetCurItem( NULL );
|
screen->SetCurItem( NULL );
|
||||||
m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );
|
m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );
|
||||||
|
|
||||||
|
// store the terminal point of this last segment: a junction could be needed
|
||||||
|
// (the last wire could be merged/deleted/modified, and lost)
|
||||||
|
wxPoint endpoint = segment->GetEndPoint();
|
||||||
|
|
||||||
|
// store the starting point of this first segment: a junction could be needed
|
||||||
|
SCH_LINE* firstsegment = (SCH_LINE*) s_wires.GetFirst();
|
||||||
|
wxPoint startPoint = firstsegment->GetStartPoint();
|
||||||
|
|
||||||
screen->Append( s_wires );
|
screen->Append( s_wires );
|
||||||
|
|
||||||
// Correct and remove segments that need merged.
|
// Correct and remove segments that need to be merged.
|
||||||
screen->SchematicCleanUp( NULL, DC );
|
screen->SchematicCleanUp( NULL, DC );
|
||||||
|
|
||||||
// A junction may be needed to connect the last segment. If the last segment was
|
// A junction could be needed to connect the end point of the last created segment.
|
||||||
// removed by a cleanup, a junction may be needed to connect the segment's end point
|
if( screen->IsJunctionNeeded( endpoint ) )
|
||||||
// which is also the same as the previous segment's start point.
|
screen->Append( AddJunction( DC, endpoint ) );
|
||||||
if( screen->IsJunctionNeeded( segment->GetEndPoint() ) )
|
|
||||||
screen->Append( AddJunction( DC, segment->GetEndPoint() ) );
|
|
||||||
else if( screen->IsJunctionNeeded( segment->GetStartPoint() ) )
|
|
||||||
screen->Append( AddJunction( DC, segment->GetStartPoint() ) );
|
|
||||||
|
|
||||||
// Automatically place a junction on the start point if necessary because the cleanup
|
// A junction could be needed to connect the start point of the set of new created wires
|
||||||
// can suppress intermediate points by merging wire segments.
|
if( screen->IsJunctionNeeded( startPoint ) )
|
||||||
if( screen->IsJunctionNeeded( s_startPoint ) )
|
screen->Append( AddJunction( DC, startPoint ) );
|
||||||
screen->Append( AddJunction( DC, s_startPoint ) );
|
|
||||||
|
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue