diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index bb58fa9716..0f8eb1bc61 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -87,10 +87,13 @@ public: /** * Update the 3D view, if the viewer is opened by this frame. * + * @param aMarkDirty alerts the 3D view that data is stale (it may not refresh instantly) + * @param aRefresh will tell the 3D view to refresh immediately * @param aTitle is the new title of the 3D frame, or nullptr to do not change the * frame title */ - virtual void Update3DView( bool aReloadRequest, const wxString* aTitle = nullptr ); + virtual void Update3DView( bool aMarkDirty, bool aRefresh, + const wxString* aTitle = nullptr ); /** * Attempt to load \a aFootprintId from the footprint library table. diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index d69dcf5ecd..2a04984b30 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -397,8 +397,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a if( aSetDirtyBit ) frame->OnModify(); - else if( frame->GetDisplayOptions().m_Live3DRefresh ) - frame->Update3DView( true ); + else + frame->Update3DView( true, frame->GetDisplayOptions().m_Live3DRefresh ); clear(); } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 80cfbba760..57aa5db813 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -736,7 +736,7 @@ void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage() void FOOTPRINT_EDIT_FRAME::OnModify() { PCB_BASE_FRAME::OnModify(); - Update3DView( true ); + Update3DView( true, true ); m_treePane->GetLibTree()->RefreshLibTree(); if( !GetTitle().StartsWith( "*" ) ) diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 2e51ac2003..f9dd8c9db0 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -84,7 +84,7 @@ void FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary( LIB_ID aFPID ) if( m_zoomSelectBox->GetSelection() == 0 ) Zoom_Automatique( false ); - Update3DView( true ); + Update3DView( true, true ); GetScreen()->ClrModify(); diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index da04d6d920..e9ad5e7556 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -1064,7 +1064,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint() Zoom_Automatique( false ); - Update3DView( true ); + Update3DView( true, true ); ClearUndoRedoList(); GetScreen()->ClrModify(); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 7559d5e365..c99a94153a 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -695,7 +695,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent ) updateView(); GetCanvas()->Refresh(); - Update3DView( true ); + Update3DView( true, true ); } // The m_fpList has now the focus, in order to be able to use arrow keys @@ -974,11 +974,11 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent } -void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aForceReload, const wxString* aTitle ) +void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle ) { wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ), getCurFootprintName() ); - PCB_BASE_FRAME::Update3DView( aForceReload, &title ); + PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title ); } @@ -1065,7 +1065,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) if( footprint ) GetBoard()->Add( footprint, ADD_MODE::APPEND ); - Update3DView( true ); + Update3DView( true, true ); updateView(); } diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 8e0d5c4ca2..123808bddf 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -154,14 +154,8 @@ private: */ void SelectAndViewFootprint( int aMode ); - /** - * Updates the 3D view and 3D frame title. - * - * Must be called after a footprint selection. - * - * @param aForceReload true to reload data immediately. - */ - void Update3DView( bool aForceReload, const wxString* aTitle = nullptr ) override; + /// @copydoc PCB_BASE_FRAME::Update3DView + void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override; void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {} void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {} diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 997a7708be..87a720b0c5 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -565,16 +565,11 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) } -/** - * Function Update3DView - * must be called after a footprint selection - * Updates the 3D view and 3D frame title. - */ -void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aForceReload, const wxString* aTitle ) +void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle ) { wxString frm3Dtitle; frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), m_wizardName ); - PCB_BASE_FRAME::Update3DView( aForceReload, &frm3Dtitle ); + PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &frm3Dtitle ); } diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index 431b50ece2..9e5d9e8e1d 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -194,15 +194,8 @@ private: */ void ParametersUpdated( wxGridEvent& event ); - /** - * Must be called after a footprint selection. - * - * Updates the 3D view and 3D frame title. - * - * @param aForceReload true to reload data immediately. - * @param aTitle (optional) the window title to set for the viewer. - */ - void Update3DView( bool aForceReload, const wxString* aTitle ) override; + /// @copydoc PCB_BASE_FRAME::Update3DView + void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override; /* * Not used here but needed by PCB_BASE_EDIT_FRAME. diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index f28c509dc5..3f56f61c53 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -170,7 +170,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint ) ToggleSearchTree(); } - Update3DView( true ); + Update3DView( true, true ); UpdateView(); GetCanvas()->Refresh(); m_treePane->GetLibTree()->RefreshLibTree(); // update any previously-highlighted items diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 355bee3d5d..efa952fe01 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -88,7 +88,7 @@ EDA_3D_VIEWER* PCB_BASE_FRAME::Get3DViewerFrame() } -void PCB_BASE_FRAME::Update3DView( bool aReloadRequest, const wxString* aTitle ) +void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle ) { EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); @@ -97,10 +97,11 @@ void PCB_BASE_FRAME::Update3DView( bool aReloadRequest, const wxString* aTitle ) if( aTitle ) draw3DFrame->SetTitle( *aTitle ); - if( aReloadRequest ) + if( aMarkDirty ) draw3DFrame->ReloadRequest(); - draw3DFrame->Redraw(); + if( aRefresh ) + draw3DFrame->Redraw(); } } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 6cd16689a1..c95c157e56 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1203,8 +1203,7 @@ void PCB_EDIT_FRAME::OnModify( ) { PCB_BASE_FRAME::OnModify(); - if( GetDisplayOptions().m_Live3DRefresh ) - Update3DView( true ); + Update3DView( true, GetDisplayOptions().m_Live3DRefresh ); if( !GetTitle().StartsWith( "*" ) ) UpdateTitle(); @@ -1215,7 +1214,7 @@ void PCB_EDIT_FRAME::OnModify( ) void PCB_EDIT_FRAME::HardRedraw() { - Update3DView( true ); + Update3DView( true, true ); } diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 1747fe5280..edd7f04f41 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -36,6 +36,7 @@ #include #include #include "board_inspection_tool.h" +#include #include @@ -713,7 +714,8 @@ int BOARD_INSPECTION_TOOL::CrossProbePcbToSch( const TOOL_EVENT& aEvent ) else m_frame->SendMessageToEESCHEMA( nullptr ); - m_frame->Update3DView( false ); + // Update 3D viewer highlighting + m_frame->Update3DView( false, frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh ); return 0; } @@ -732,13 +734,14 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) } m_probingSchToPcb = false; - bool request3DviewRedraw = true; + bool request3DviewRedraw = frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh; if( item && item->Type() != PCB_FOOTPRINT_T ) request3DviewRedraw = false; + // Update 3D viewer highlighting if( request3DviewRedraw ) - m_frame->Update3DView( false ); + m_frame->Update3DView( false, true ); return 0; } diff --git a/pcbnew/tools/footprint_editor_control.cpp b/pcbnew/tools/footprint_editor_control.cpp index ebcd4f63f4..ed4bebeb8a 100644 --- a/pcbnew/tools/footprint_editor_control.cpp +++ b/pcbnew/tools/footprint_editor_control.cpp @@ -171,7 +171,7 @@ int FOOTPRINT_EDITOR_CONTROL::NewFootprint( const TOOL_EVENT& aEvent ) } m_frame->UpdateView(); - m_frame->Update3DView( true ); + m_frame->Update3DView( true, true ); m_frame->SyncLibraryTree( false ); return 0; @@ -232,7 +232,7 @@ int FOOTPRINT_EDITOR_CONTROL::CreateFootprint( const TOOL_EVENT& aEvent ) m_frame->UpdateView(); canvas()->Refresh(); - m_frame->Update3DView( true ); + m_frame->Update3DView( true, true ); m_frame->SyncLibraryTree( false ); } diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index a284b0b58e..f821f329b4 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -68,7 +68,7 @@ int PCB_VIEWER_TOOLS::Show3DViewer( const TOOL_EVENT& aEvent ) || frame()->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) || frame()->IsType( FRAME_FOOTPRINT_WIZARD ) ) { - frame()->Update3DView( true ); + frame()->Update3DView( true, true ); // A stronger version of Raise() which promotes the window to its parent's level. KIPLATFORM::UI::ReparentQuasiModal( draw3DFrame ); @@ -222,10 +222,10 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) controls.ShowCursor( true ); controls.SetAutoPan( false ); controls.CaptureCursor( false ); - - auto setCursor = + + auto setCursor = [&]() - { + { frame()->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE ); };