diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 9edd9d43fa..7a57f2443e 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -173,7 +173,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) GetScreen()->ClearDrawingState(); GetScreen()->ClearBlockCommand(); GetScreen()->SetCurItem( NULL ); - GetScreen()->TestDanglingEnds( m_canvas, DC ); + GetScreen()->TestDanglingEnds(); if( block->GetCount() ) { @@ -232,7 +232,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) } block->ClearItemsList(); - GetScreen()->TestDanglingEnds( m_canvas, aDC ); + GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); break; @@ -286,7 +286,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) OnModify(); } block->ClearItemsList(); - GetScreen()->TestDanglingEnds( m_canvas, aDC ); + GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); break; @@ -327,7 +327,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) OnModify(); } - GetScreen()->TestDanglingEnds( m_canvas, aDC ); + GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); break; @@ -346,7 +346,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) OnModify(); } - GetScreen()->TestDanglingEnds( m_canvas, aDC ); + GetScreen()->TestDanglingEnds(); m_canvas->Refresh(); break; diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 18e3bd1312..599f638fad 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -494,8 +494,17 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) ( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() ); GetScreen()->Append( my_clone ); - GetScreen()->TestDanglingEnds(); - my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); + + if( my_clone->IsConnectable() ) + { + if( GetScreen()->TestDanglingEnds() ) + m_canvas->Refresh(); + } + else + { + my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); + } + SaveCopyInUndoList( my_clone, UR_NEW ); my_clone->ClearFlags(); } diff --git a/eeschema/class_sch_screen.h b/eeschema/class_sch_screen.h index 67c6451b1c..f2c19c66f7 100644 --- a/eeschema/class_sch_screen.h +++ b/eeschema/class_sch_screen.h @@ -265,11 +265,9 @@ public: /** * Function TestDanglingEnds * tests all of the connectible objects in the schematic for unused connection points. - * @param aDC - The device context to draw the dangling status indicators. - * @param aCanvas - The window to draw on. - * @return True if any dangling ends were found. + * @return True if any connection state changes were made. */ - bool TestDanglingEnds( EDA_DRAW_PANEL* aCanvas = NULL, wxDC* aDC = NULL ); + bool TestDanglingEnds(); /** * Function ExtractWires diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 302a998e11..1fc44cd073 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -275,8 +275,10 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) component->SetOrientation( aOrientation ); m_canvas->CrossHairOn( &dc ); - GetScreen()->TestDanglingEnds( m_canvas, &dc ); - m_canvas->Refresh(); + + if( GetScreen()->TestDanglingEnds() ) + m_canvas->Refresh(); + OnModify(); } @@ -333,8 +335,9 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) if( m_autoplaceFields ) component->AutoAutoplaceFields( GetScreen() ); - screen->TestDanglingEnds( m_canvas, &dc ); - m_canvas->Refresh(); + if( screen->TestDanglingEnds() ) + m_canvas->Refresh(); + OnModify(); } } @@ -371,6 +374,9 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC ) if( DrawComponent->GetConvert() > 2 ) DrawComponent->SetConvert( 1 ); + // The alternate symbol may cause a change in the connection status so test the + // connections so the connection indicators are drawn correctly. + GetScreen()->TestDanglingEnds(); DrawComponent->ClearFlags(); DrawComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert()) @@ -380,7 +386,6 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC ) else DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - GetScreen()->TestDanglingEnds( m_canvas, DC ); OnModify(); } } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index c2f8201979..fdb491478e 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -457,7 +457,8 @@ 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 ) ) + else if ( ( ( item->Type() == SCH_JUNCTION_T ) + && ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) ) { if ( testItem->HitTest( item->GetPosition() ) ) { @@ -479,7 +480,7 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) } } - TestDanglingEnds( aCanvas, aDC ); + TestDanglingEnds(); if( aCanvas && modified ) aCanvas->Refresh(); @@ -931,28 +932,22 @@ int SCH_SCREEN::UpdatePickList() } -bool SCH_SCREEN::TestDanglingEnds( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) +bool SCH_SCREEN::TestDanglingEnds() { SCH_ITEM* item; std::vector< DANGLING_END_ITEM > endPoints; - bool hasDanglingEnds = false; + bool hasStateChanged = false; for( item = m_drawList.begin(); item; item = item->Next() ) item->GetEndPoints( endPoints ); for( item = m_drawList.begin(); item; item = item->Next() ) { - if( item->IsDanglingStateChanged( endPoints ) && ( aCanvas ) && ( aDC ) ) - { - item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode ); - item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - } - - if( item->IsDangling() ) - hasDanglingEnds = true; + if( item->IsDanglingStateChanged( endPoints ) ) + hasStateChanged = true; } - return hasDanglingEnds; + return hasStateChanged; } diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 864f8d5f61..e2a53dd458 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -187,8 +187,10 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ); screen->SetCurItem( NULL ); SetRepeatItem( NULL ); - screen->TestDanglingEnds( m_canvas, &dc ); - m_canvas->Refresh(); + + if( screen->TestDanglingEnds() ) + m_canvas->Refresh(); + break; case ID_POPUP_SCH_BREAK_WIRE: @@ -215,7 +217,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE ); } - screen->TestDanglingEnds( m_canvas, &dc ); + if( screen->TestDanglingEnds() ) + m_canvas->Refresh(); } break; @@ -227,8 +230,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) DeleteItem( item ); screen->SetCurItem( NULL ); SetRepeatItem( NULL ); - screen->TestDanglingEnds( m_canvas, &dc ); + screen->TestDanglingEnds(); SetSheetNumberAndCount(); + m_canvas->Refresh(); OnModify(); break; @@ -239,7 +243,10 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_RESIZE_SHEET: ReSizeSheet( (SCH_SHEET*) item, &dc ); - screen->TestDanglingEnds( m_canvas, &dc ); + + if( screen->TestDanglingEnds() ) + m_canvas->Refresh(); + break; case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN: @@ -375,7 +382,10 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ADD_JUNCTION: m_canvas->MoveCursorToCrossHair(); screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) ); - screen->TestDanglingEnds( m_canvas, &dc ); + + if( screen->TestDanglingEnds() ) + m_canvas->Refresh(); + screen->SetCurItem( NULL ); break; @@ -648,8 +658,8 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) SetRepeatItem( NULL ); DeleteItem( item ); - if( itemHasConnections ) - screen->TestDanglingEnds( m_canvas, DC ); + if( itemHasConnections && screen->TestDanglingEnds() ) + m_canvas->Refresh(); OnModify(); return true;