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

Commit patches from Moses McKnight, to avoid duplicate junctions.

parent 52ee7c6e
Loading
Loading
Loading
Loading
+4 −23
Original line number Diff line number Diff line
@@ -255,14 +255,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
    screen->SetCurItem( NULL );
    m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );

    DLIST< SCH_ITEM > tmp;

    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 );
    screen->Append( s_wires );

    // Correct and remove segments that need merged.
    screen->SchematicCleanUp( NULL, 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
    // which is also the same as the previous segment's start point.
    if( screen->IsJunctionNeeded( segment->GetEndPoint() ) )
        s_wires.Append( AddJunction( DC, segment->GetEndPoint() ) );
        screen->Append( AddJunction( DC, segment->GetEndPoint() ) );
    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
    // can suppress intermediate points by merging wire segments.
    if( screen->IsJunctionNeeded( s_startPoint ) )
        s_wires.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() );
        screen->Append( AddJunction( DC, s_startPoint ) );

    // 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();

    // Put the snap shot of the previous wire, buses, and junctions in the undo/redo list.
+13 −6
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
                wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick error.  Item type <" ) +
                            item->GetClass() + wxT( "> is already being edited." ) );
                item->ClearFlags();
                break;
            }
        }
        else
@@ -123,11 +124,14 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )

    case ID_NOCONN_BUTT:
        if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
        {
            if( false == GetScreen()->GetItem( gridPosition, 0, SCH_NO_CONNECT_T ) )
            {
                m_itemToRepeat = AddNoConnect( aDC, gridPosition );
                GetScreen()->SetCurItem( m_itemToRepeat );
                m_canvas->SetAutoPanRequest( true );
            }
        }
        else
        {
            addCurrentItemToList( aDC );
@@ -137,11 +141,14 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )

    case ID_JUNCTION_BUTT:
        if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
        {
            if( false == GetScreen()->GetItem( gridPosition, 0, SCH_JUNCTION_T ) )
            {
                m_itemToRepeat = AddJunction( aDC, gridPosition, true );
                GetScreen()->SetCurItem( m_itemToRepeat );
                m_canvas->SetAutoPanRequest( true );
            }
        }
        else
        {
            addCurrentItemToList( aDC );
+17 −2
Original line number Diff line number Diff line
@@ -434,14 +434,14 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )

    for( ; item != NULL; item = item->Next() )
    {
        if( item->Type() != SCH_LINE_T )
        if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
            continue;

        testItem = item->Next();

        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;

@@ -458,6 +458,21 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
                    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
            {
                testItem = testItem->Next();