Commit 70c30bce authored by Moses McKnight's avatar Moses McKnight Committed by jean-pierre charras

Commit patches from Moses McKnight, to avoid duplicate junctions.

parent 52ee7c6e
...@@ -255,14 +255,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) ...@@ -255,14 +255,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false ); m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );
DLIST< SCH_ITEM > tmp; screen->Append( s_wires );
for( item = s_wires.begin(); item != NULL; item = item->Next() )
tmp.PushBack( (SCH_ITEM*) item->Clone() );
// Temporarily add the new segments to the schematic item list to test if any
// junctions are required.
screen->Append( tmp );
// Correct and remove segments that need merged. // Correct and remove segments that need merged.
screen->SchematicCleanUp( NULL, DC ); screen->SchematicCleanUp( NULL, DC );
...@@ -271,27 +264,15 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) ...@@ -271,27 +264,15 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
// removed by a cleanup, a junction may be needed to connect the segment's end point // removed by a cleanup, a junction may be needed to connect the segment's end point
// which is also the same as the previous segment's start point. // which is also the same as the previous segment's start point.
if( screen->IsJunctionNeeded( segment->GetEndPoint() ) ) if( screen->IsJunctionNeeded( segment->GetEndPoint() ) )
s_wires.Append( AddJunction( DC, segment->GetEndPoint() ) ); screen->Append( AddJunction( DC, segment->GetEndPoint() ) );
else if( screen->IsJunctionNeeded( segment->GetStartPoint() ) ) else if( screen->IsJunctionNeeded( segment->GetStartPoint() ) )
s_wires.Append( AddJunction( DC, segment->GetStartPoint() ) ); screen->Append( AddJunction( DC, segment->GetStartPoint() ) );
// Automatically place a junction on the start point if necessary because the cleanup // Automatically place a junction on the start point if necessary because the cleanup
// can suppress intermediate points by merging wire segments. // can suppress intermediate points by merging wire segments.
if( screen->IsJunctionNeeded( s_startPoint ) ) if( screen->IsJunctionNeeded( s_startPoint ) )
s_wires.Append( AddJunction( DC, s_startPoint ) ); screen->Append( AddJunction( DC, s_startPoint ) );
// Make a copy of the original wires, buses, and junctions.
for( item = s_oldWires.begin(); item != NULL; item = item->Next() )
tmp.PushBack( (SCH_ITEM*) item->Clone() );
// Restore the old wires.
if( tmp.GetCount() != 0 )
screen->ReplaceWires( tmp );
// Now add the new wires and any required junctions to the schematic item list.
screen->Append( s_wires );
screen->SchematicCleanUp( NULL, DC );
m_canvas->Refresh(); m_canvas->Refresh();
// Put the snap shot of the previous wire, buses, and junctions in the undo/redo list. // Put the snap shot of the previous wire, buses, and junctions in the undo/redo list.
......
...@@ -86,6 +86,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -86,6 +86,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick error. Item type <" ) + wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick error. Item type <" ) +
item->GetClass() + wxT( "> is already being edited." ) ); item->GetClass() + wxT( "> is already being edited." ) );
item->ClearFlags(); item->ClearFlags();
break;
} }
} }
else else
...@@ -124,9 +125,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -124,9 +125,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_NOCONN_BUTT: case ID_NOCONN_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
m_itemToRepeat = AddNoConnect( aDC, gridPosition ); if( false == GetScreen()->GetItem( gridPosition, 0, SCH_NO_CONNECT_T ) )
GetScreen()->SetCurItem( m_itemToRepeat ); {
m_canvas->SetAutoPanRequest( true ); m_itemToRepeat = AddNoConnect( aDC, gridPosition );
GetScreen()->SetCurItem( m_itemToRepeat );
m_canvas->SetAutoPanRequest( true );
}
} }
else else
{ {
...@@ -138,9 +142,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -138,9 +142,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_JUNCTION_BUTT: case ID_JUNCTION_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
m_itemToRepeat = AddJunction( aDC, gridPosition, true ); if( false == GetScreen()->GetItem( gridPosition, 0, SCH_JUNCTION_T ) )
GetScreen()->SetCurItem( m_itemToRepeat ); {
m_canvas->SetAutoPanRequest( true ); m_itemToRepeat = AddJunction( aDC, gridPosition, true );
GetScreen()->SetCurItem( m_itemToRepeat );
m_canvas->SetAutoPanRequest( true );
}
} }
else else
{ {
......
...@@ -434,14 +434,14 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) ...@@ -434,14 +434,14 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() )
{ {
if( item->Type() != SCH_LINE_T ) if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
continue; continue;
testItem = item->Next(); testItem = item->Next();
while( testItem ) while( testItem )
{ {
if( testItem->Type() == SCH_LINE_T ) if( ( item->Type() == SCH_LINE_T ) && ( testItem->Type() == SCH_LINE_T ) )
{ {
SCH_LINE* line = (SCH_LINE*) item; SCH_LINE* line = (SCH_LINE*) item;
...@@ -458,6 +458,21 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) ...@@ -458,6 +458,21 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
testItem = testItem->Next(); testItem = testItem->Next();
} }
} }
else if ( ( ( item->Type() == SCH_JUNCTION_T ) && ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) )
{
if ( testItem->HitTest( item->GetPosition() ) )
{
// Keep the current flags, because the deleted segment can be flagged.
item->SetFlags( testItem->GetFlags() );
DeleteItem( testItem );
testItem = m_drawList.begin();
modified = true;
}
else
{
testItem = testItem->Next();
}
}
else else
{ {
testItem = testItem->Next(); testItem = testItem->Next();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment