From 57c3d8e8d8f9cb265b39c00a37b7bae9696e0aad Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 15 Aug 2020 21:13:08 +0100 Subject: [PATCH] Make sure preview group gets added to view after a clear. --- common/view/view.cpp | 7 +++++++ eeschema/sch_view.cpp | 8 +++----- include/view/view.h | 2 ++ pcbnew/pcb_base_edit_frame.cpp | 1 + pcbnew/router/router_tool.cpp | 6 +++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index e513d63b39..b19fcdd8bc 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -1562,6 +1562,13 @@ void VIEW::ClearPreview() } +void VIEW::InitPreview() +{ + m_preview.reset( new KIGFX::VIEW_GROUP() ); + Add( m_preview.get() ); +} + + void VIEW::AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership ) { Hide( aItem, false ); diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 5057c80d47..1a526efda9 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -112,10 +112,9 @@ void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen ) ResizeSheetWorkingArea( aScreen ); - m_preview.reset( new KIGFX::VIEW_GROUP() ); - Add( m_worksheet.get() ); - Add( m_preview.get() ); + + InitPreview(); } @@ -171,8 +170,7 @@ void SCH_VIEW::DisplayComponent( LIB_PART* aPart ) Add( &item ); } - m_preview.reset( new KIGFX::VIEW_GROUP() ); - Add( m_preview.get() ); + InitPreview(); } diff --git a/include/view/view.h b/include/view/view.h index 4168e7fff4..1e11dd1745 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -663,6 +663,8 @@ public: std::shared_ptr MakeOverlay(); + void InitPreview(); + void ClearPreview(); void AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership = true ); diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index fc8d081f75..3d14606732 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -102,6 +102,7 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard ) m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); GetCanvas()->GetView()->Clear(); + GetCanvas()->GetView()->InitPreview(); } PCB_BASE_FRAME::SetBoard( aBoard ); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 8d9a5bcde8..ccbca68f26 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1422,6 +1422,9 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent ) controls()->SetAutoPan( true ); frame()->UndoRedoBlock( true ); + view()->ClearPreview(); + view()->InitPreview(); + while( TOOL_EVENT* evt = Wait() ) { frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); @@ -1456,20 +1459,17 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent ) previewItem->Move( offset ); } - view()->Add( previewItem ); view()->AddToPreview( previewItem ); view()->Hide( drawing, true ); } previewItem = static_cast( module->Reference().Clone() ); previewItem->Move( offset ); - view()->Add( previewItem ); view()->AddToPreview( previewItem ); view()->Hide( &module->Reference() ); previewItem = static_cast( module->Value().Clone() ); previewItem->Move( offset ); - view()->Add( previewItem ); view()->AddToPreview( previewItem ); view()->Hide( &module->Value() ); }