Refresh item when its dangling state changes.

Fixes: lp:1797996
* https://bugs.launchpad.net/kicad/+bug/1797996
This commit is contained in:
Jeff Young 2018-10-16 14:11:33 +01:00
parent ecd893c4b1
commit 1114b5cfa9
9 changed files with 62 additions and 35 deletions

View File

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

View File

@ -268,6 +268,27 @@ void SCH_EDIT_FRAME::GetSchematicConnections( std::vector< wxPoint >& aConnectio
}
bool SCH_EDIT_FRAME::TestDanglingEnds()
{
std::vector<DANGLING_END_ITEM> 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 );
}

View File

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

View File

@ -534,7 +534,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow()
m_cmp->UpdatePinCache();
GetParent()->OnModify();
GetParent()->GetScreen()->TestDanglingEnds();
GetParent()->TestDanglingEnds();
return true;
}

View File

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

View File

@ -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,10 +1447,9 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen( bool aRedraw )
if( screen->IsJunctionNeeded( *i, true ) )
AddJunction( *i, true );
}
screen->TestDanglingEnds();
TestDanglingEnds();
}
if( aRedraw )
GetCanvas()->Refresh();
}

View File

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

View File

@ -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() )
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,7 +235,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_RESIZE_SHEET:
ReSizeSheet( (SCH_SHEET*) item, nullptr );
if( screen->TestDanglingEnds() )
TestDanglingEnds();
m_canvas->Refresh();
break;
@ -347,7 +347,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair();
screen->SetCurItem( AddJunction( GetCrossHairPosition() ) );
if( screen->TestDanglingEnds() )
TestDanglingEnds();
m_canvas->Refresh();
screen->SetCurItem( NULL );
@ -662,7 +662,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair()
DeleteItem( item );
if( itemHasConnections )
screen->TestDanglingEnds();
TestDanglingEnds();
GetCanvas()->Refresh();
OnModify();

View File

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