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()->ClearDrawingState();
GetScreen()->ClearBlockCommand(); GetScreen()->ClearBlockCommand();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds( m_canvas, DC ); GetScreen()->TestDanglingEnds();
if( block->GetCount() ) if( block->GetCount() )
{ {
@ -232,7 +232,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
} }
block->ClearItemsList(); block->ClearItemsList();
GetScreen()->TestDanglingEnds( m_canvas, aDC ); GetScreen()->TestDanglingEnds();
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
@ -286,7 +286,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
OnModify(); OnModify();
} }
block->ClearItemsList(); block->ClearItemsList();
GetScreen()->TestDanglingEnds( m_canvas, aDC ); GetScreen()->TestDanglingEnds();
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
@ -327,7 +327,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
OnModify(); OnModify();
} }
GetScreen()->TestDanglingEnds( m_canvas, aDC ); GetScreen()->TestDanglingEnds();
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
@ -346,7 +346,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
OnModify(); OnModify();
} }
GetScreen()->TestDanglingEnds( m_canvas, aDC ); GetScreen()->TestDanglingEnds();
m_canvas->Refresh(); m_canvas->Refresh();
break; break;

View File

@ -494,8 +494,17 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() ); ( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() );
GetScreen()->Append( my_clone ); 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 ); SaveCopyInUndoList( my_clone, UR_NEW );
my_clone->ClearFlags(); my_clone->ClearFlags();
} }

View File

@ -265,11 +265,9 @@ public:
/** /**
* Function TestDanglingEnds * Function TestDanglingEnds
* tests all of the connectible objects in the schematic for unused connection points. * tests all of the connectible objects in the schematic for unused connection points.
* @param aDC - The device context to draw the dangling status indicators. * @return True if any connection state changes were made.
* @param aCanvas - The window to draw on.
* @return True if any dangling ends were found.
*/ */
bool TestDanglingEnds( EDA_DRAW_PANEL* aCanvas = NULL, wxDC* aDC = NULL ); bool TestDanglingEnds();
/** /**
* Function ExtractWires * Function ExtractWires

View File

@ -275,8 +275,10 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
component->SetOrientation( aOrientation ); component->SetOrientation( aOrientation );
m_canvas->CrossHairOn( &dc ); m_canvas->CrossHairOn( &dc );
GetScreen()->TestDanglingEnds( m_canvas, &dc );
m_canvas->Refresh(); if( GetScreen()->TestDanglingEnds() )
m_canvas->Refresh();
OnModify(); OnModify();
} }
@ -333,8 +335,9 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
if( m_autoplaceFields ) if( m_autoplaceFields )
component->AutoAutoplaceFields( GetScreen() ); component->AutoAutoplaceFields( GetScreen() );
screen->TestDanglingEnds( m_canvas, &dc ); if( screen->TestDanglingEnds() )
m_canvas->Refresh(); m_canvas->Refresh();
OnModify(); OnModify();
} }
} }
@ -371,6 +374,9 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC )
if( DrawComponent->GetConvert() > 2 ) if( DrawComponent->GetConvert() > 2 )
DrawComponent->SetConvert( 1 ); 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->ClearFlags();
DrawComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert()) DrawComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
@ -380,7 +386,6 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC )
else else
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
GetScreen()->TestDanglingEnds( m_canvas, DC );
OnModify(); OnModify();
} }
} }

View File

@ -457,7 +457,8 @@ 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 ) ) else if ( ( ( item->Type() == SCH_JUNCTION_T )
&& ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) )
{ {
if ( testItem->HitTest( item->GetPosition() ) ) 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 ) if( aCanvas && modified )
aCanvas->Refresh(); 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; SCH_ITEM* item;
std::vector< DANGLING_END_ITEM > endPoints; std::vector< DANGLING_END_ITEM > endPoints;
bool hasDanglingEnds = false; bool hasStateChanged = false;
for( item = m_drawList.begin(); item; item = item->Next() ) for( item = m_drawList.begin(); item; item = item->Next() )
item->GetEndPoints( endPoints ); item->GetEndPoints( endPoints );
for( item = m_drawList.begin(); item; item = item->Next() ) for( item = m_drawList.begin(); item; item = item->Next() )
{ {
if( item->IsDanglingStateChanged( endPoints ) && ( aCanvas ) && ( aDC ) ) if( item->IsDanglingStateChanged( endPoints ) )
{ hasStateChanged = true;
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode );
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
}
if( item->IsDangling() )
hasDanglingEnds = 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 ); DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
SetRepeatItem( NULL ); SetRepeatItem( NULL );
screen->TestDanglingEnds( m_canvas, &dc );
m_canvas->Refresh(); if( screen->TestDanglingEnds() )
m_canvas->Refresh();
break; break;
case ID_POPUP_SCH_BREAK_WIRE: case ID_POPUP_SCH_BREAK_WIRE:
@ -215,7 +217,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE ); SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
} }
screen->TestDanglingEnds( m_canvas, &dc ); if( screen->TestDanglingEnds() )
m_canvas->Refresh();
} }
break; break;
@ -227,8 +230,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DeleteItem( item ); DeleteItem( item );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
SetRepeatItem( NULL ); SetRepeatItem( NULL );
screen->TestDanglingEnds( m_canvas, &dc ); screen->TestDanglingEnds();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
m_canvas->Refresh();
OnModify(); OnModify();
break; break;
@ -239,7 +243,10 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_RESIZE_SHEET: case ID_POPUP_SCH_RESIZE_SHEET:
ReSizeSheet( (SCH_SHEET*) item, &dc ); ReSizeSheet( (SCH_SHEET*) item, &dc );
screen->TestDanglingEnds( m_canvas, &dc );
if( screen->TestDanglingEnds() )
m_canvas->Refresh();
break; break;
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN: 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: case ID_POPUP_SCH_ADD_JUNCTION:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) ); screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) );
screen->TestDanglingEnds( m_canvas, &dc );
if( screen->TestDanglingEnds() )
m_canvas->Refresh();
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
break; break;
@ -648,8 +658,8 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC )
SetRepeatItem( NULL ); SetRepeatItem( NULL );
DeleteItem( item ); DeleteItem( item );
if( itemHasConnections ) if( itemHasConnections && screen->TestDanglingEnds() )
screen->TestDanglingEnds( m_canvas, DC ); m_canvas->Refresh();
OnModify(); OnModify();
return true; return true;