Eeschema: decouple SCH_SCREEN::TestDanglingEnds() from wxDC and EDA_DRAW_PANEL.

* Remove wxDC and EDA_DRAW_PANEL as parameters from function
  SCH_SCREEN::TestDanglingEnds().
* Change SCH_SCREEN::TestDanglingEnds() to return the connection change state
  rather than the dangling end status which wasn't used anywhere.
* Update all calls to SCH_SCREEN::TestDanglingEnds() to remove wxDC and
  EDA_DRAW_PANEL parameters and refresh connection indicators only if a
  connection state change occurred.
This commit is contained in:
Wayne Stambaugh 2016-02-19 10:41:32 -05:00
parent d1559b129d
commit 306b964b40
6 changed files with 54 additions and 37 deletions

View File

@ -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;

View File

@ -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();
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -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;
}

View File

@ -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;