From 268565ee4100f6d2d354bc77fbcc919c2b5127dc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 9 Sep 2018 20:34:09 +0100 Subject: [PATCH] Refresh component when children change. --- eeschema/sch_edit_frame.cpp | 12 ++++++++++++ eeschema/sch_edit_frame.h | 5 +++++ eeschema/sch_line.cpp | 5 +---- eeschema/schedit.cpp | 17 ++++++++++------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 4be91d4029..90133537b5 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -752,6 +752,18 @@ void SCH_EDIT_FRAME::OnModify() } +void SCH_EDIT_FRAME::RefreshItem( SCH_ITEM* aItem ) +{ + GetCanvas()->GetView()->Update( aItem ); + + // Component children are drawn from their parents so we must also dirty the parent. + if( aItem->GetParent() && aItem->GetParent()->Type() == SCH_COMPONENT_T ) + GetCanvas()->GetView()->Update( aItem->GetParent(), KIGFX::REPAINT ); + + GetCanvas()->Refresh(); +} + + void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event ) { event.Enable( m_blockItems.GetCount() > 0 ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index eaec93c27f..eb4470c0d0 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -347,6 +347,11 @@ public: */ void OnModify(); + /** + * Mark an item for refresh. + */ + void RefreshItem( SCH_ITEM* aItem ); + virtual wxString GetScreenDesc() const override; /** diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 39b32df05e..8689241771 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -796,10 +796,7 @@ int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw ) return wxID_CANCEL; if( aRedraw ) - { - GetCanvas()->GetView()->Update( aLine ); - GetCanvas()->Refresh(); - } + RefreshItem( aLine ); return wxID_OK; } diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 7f7efb89a3..a397bc0ca3 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -764,7 +764,11 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ) SetRepeatItem( NULL ); - if( !aItem->IsNew() ) + if( aItem->IsNew() ) + { + GetCanvas()->GetView()->Add( aItem ); + } + else { if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) ) SetUndoItem( (SCH_ITEM*) aItem->GetParent() ); @@ -952,8 +956,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent ) GetChars( item->GetClass() ) ) ); } - GetCanvas()->GetView()->Update( item ); - GetCanvas()->Refresh(); + RefreshItem( item ); if( item->GetFlags() == 0 ) screen->SetCurItem( NULL ); @@ -1115,8 +1118,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent ) GetChars( item->GetClass() ) ) ); } - GetCanvas()->GetView()->Update( item ); - GetCanvas()->Refresh(); + RefreshItem( item ); if( item->GetFlags() == 0 ) screen->SetCurItem( NULL ); @@ -1157,7 +1159,9 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent ) // When a junction or a node is found, a BLOCK_DRAG is better if( m_collectedItems.IsCorner() || m_collectedItems.IsNode( false ) || m_collectedItems.IsDraggableJunction() ) + { dragType = BLOCK_DRAG; + } } switch( item->Type() ) @@ -1310,8 +1314,7 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent ) ; } - GetCanvas()->GetView()->Update( item ); - GetCanvas()->Refresh(); + RefreshItem( item ); if( item->GetFlags() == 0 ) screen->SetCurItem( NULL );