diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 9f6788912f..cde33e2bcb 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -168,13 +168,13 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) CheckListConnections( block->GetItems(), true ); block->ClearItemsList(); SchematicCleanUp( true ); + TestDanglingEnds(); OnModify(); // clear dome flags and pointers GetScreen()->ClearDrawingState(); GetScreen()->ClearBlockCommand(); GetScreen()->SetCurItem( NULL ); - GetScreen()->TestDanglingEnds(); if( block->GetCount() ) { @@ -294,7 +294,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) append = true; } - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); break; case BLOCK_COPY: // Save a copy of items in paste buffer diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 67182879cc..45fc83911e 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -268,6 +268,27 @@ void SCH_EDIT_FRAME::GetSchematicConnections( std::vector< wxPoint >& aConnectio } +bool SCH_EDIT_FRAME::TestDanglingEnds() +{ + std::vector endPoints; + bool hasStateChanged = false; + + for( SCH_ITEM* item = GetScreen()->GetDrawList().begin(); item; item = item->Next() ) + item->GetEndPoints( endPoints ); + + for( SCH_ITEM* item = GetScreen()->GetDrawList().begin(); item; item = item->Next() ) + { + if( item->IsDanglingStateChanged( endPoints ) ) + { + GetCanvas()->GetView()->Update( item, KIGFX::REPAINT ); + hasStateChanged = true; + } + } + + return hasStateChanged; +} + + void SCH_EDIT_FRAME::EndSegment() { SCH_SCREEN* screen = GetScreen(); @@ -349,10 +370,11 @@ void SCH_EDIT_FRAME::EndSegment() AddJunction( i, true ); } - screen->TestDanglingEnds(); + TestDanglingEnds(); screen->ClearDrawingState(); screen->SetCurItem( NULL ); m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false ); + m_canvas->Refresh(); OnModify(); } @@ -634,7 +656,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend ) SaveCopyInUndoList( itemList, UR_CHANGED, aAppend ); - return !!( itemList.GetCount() ); + return itemList.GetCount() > 0; } @@ -778,7 +800,7 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( const wxPoint& aPosition, bool aAppen AddToScreen( junction ); broken_segments = BreakSegments( aPosition, aAppend ); - screen->TestDanglingEnds(); + TestDanglingEnds(); OnModify(); SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend ); @@ -798,7 +820,7 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( const wxPoint& aPosition ) SetRepeatItem( no_connect ); AddToScreen( no_connect ); SchematicCleanUp(); - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); OnModify(); auto view = GetCanvas()->GetView(); @@ -870,7 +892,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem() AddToScreen( my_clone ); if( my_clone->IsConnectable() ) - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); SaveCopyInUndoList( my_clone, UR_NEW ); my_clone->ClearFlags(); @@ -879,3 +901,5 @@ void SCH_EDIT_FRAME::RepeatDrawItem() // clone my_clone, now that it has been moved, thus saving new position. SetRepeatItem( my_clone ); } + + diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index 1f4f00c939..a5d82742a9 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -75,7 +75,7 @@ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, c s_LastShape = entry_shape == '/' ? '/' : '\\'; BusEntry->SetBusEntryShape( s_LastShape ); - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); OnModify( ); } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 93b219390d..bba0577446 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -534,7 +534,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() m_cmp->UpdatePinCache(); GetParent()->OnModify(); - GetParent()->GetScreen()->TestDanglingEnds(); + GetParent()->TestDanglingEnds(); return true; } diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index e93cd70ca0..43c3bab116 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -317,7 +317,7 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) SchematicCleanUp( true ); } - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); RefreshItem( item ); OnModify(); @@ -361,7 +361,7 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) if( m_autoplaceFields ) component->AutoAutoplaceFields( GetScreen() ); - screen->TestDanglingEnds(); + TestDanglingEnds(); RefreshItem( component ); OnModify(); @@ -403,7 +403,7 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent ) // The alternate symbol may cause a change in the connection status so test the // connections so the connection indicators are drawn correctly. - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); aComponent->ClearFlags(); aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert()) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index ba1f8076dd..d0da4c0d5a 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1332,7 +1332,7 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const } -void SCH_EDIT_FRAME::addCurrentItemToScreen( bool aRedraw ) +void SCH_EDIT_FRAME::addCurrentItemToScreen() { SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); @@ -1447,11 +1447,10 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen( bool aRedraw ) if( screen->IsJunctionNeeded( *i, true ) ) AddJunction( *i, true ); } - screen->TestDanglingEnds(); + TestDanglingEnds(); } - if( aRedraw ) - GetCanvas()->Refresh(); + GetCanvas()->Refresh(); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index f2439045cd..2b02391e32 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -191,10 +191,8 @@ protected: /** * Add the item currently being edited to the schematic and adds the changes to * the undo/redo container. - * - * @param aRedraw = true (default) to redrw -the screen after adding the item. */ - void addCurrentItemToScreen( bool aRedraw = true ); + void addCurrentItemToScreen(); void updateFindReplaceView( wxFindDialogEvent& aEvent ); @@ -473,6 +471,12 @@ public: */ bool BreakSegmentsOnJunctions( bool aApped = false ); + /** + * Test all of the connectable objects in the schematic for unused connection points. + * @return True if any connection state changes were made. + */ + bool TestDanglingEnds(); + /** * Send a message to Pcbnew via a socket connection. * diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 1e7e00166a..7ee27d687f 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -197,19 +197,19 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) screen->SetCurItem( NULL ); SetRepeatItem( NULL ); - screen->TestDanglingEnds(); + TestDanglingEnds(); m_canvas->Refresh(); break; case ID_POPUP_SCH_BREAK_WIRE: - { - SaveWireImage(); - m_canvas->MoveCursorToCrossHair(); - BreakSegments( GetCrossHairPosition() ); - if( screen->TestDanglingEnds() ) - m_canvas->Refresh(); - } + SaveWireImage(); + m_canvas->MoveCursorToCrossHair(); + BreakSegments( GetCrossHairPosition() ); + + TestDanglingEnds(); + m_canvas->Refresh(); + break; case ID_POPUP_SCH_DELETE_CMP: @@ -221,7 +221,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) SchematicCleanUp( true ); screen->SetCurItem( NULL ); SetRepeatItem( NULL ); - screen->TestDanglingEnds(); + TestDanglingEnds(); SetSheetNumberAndCount(); m_canvas->Refresh(); OnModify(); @@ -235,8 +235,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_RESIZE_SHEET: ReSizeSheet( (SCH_SHEET*) item, nullptr ); - if( screen->TestDanglingEnds() ) - m_canvas->Refresh(); + TestDanglingEnds(); + m_canvas->Refresh(); break; @@ -347,8 +347,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->MoveCursorToCrossHair(); screen->SetCurItem( AddJunction( GetCrossHairPosition() ) ); - if( screen->TestDanglingEnds() ) - m_canvas->Refresh(); + TestDanglingEnds(); + m_canvas->Refresh(); screen->SetCurItem( NULL ); break; @@ -662,7 +662,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair() DeleteItem( item ); if( itemHasConnections ) - screen->TestDanglingEnds(); + TestDanglingEnds(); GetCanvas()->Refresh(); OnModify(); diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 88aa574705..a0fda29ad6 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -407,7 +407,7 @@ void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event ) OnModify(); SetSheetNumberAndCount(); - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); m_canvas->Refresh(); } @@ -430,6 +430,6 @@ void SCH_EDIT_FRAME::GetSchematicFromRedoList( wxCommandEvent& event ) OnModify(); SetSheetNumberAndCount(); - GetScreen()->TestDanglingEnds(); + TestDanglingEnds(); m_canvas->Refresh(); }