Decouple 3D view dirty marking and refresh

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8154
This commit is contained in:
Jon Evans 2021-04-08 22:09:06 -04:00
parent d48adf9c77
commit 619a353c5e
15 changed files with 38 additions and 50 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -1064,7 +1064,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
Zoom_Automatique( false );
Update3DView( true );
Update3DView( true, true );
ClearUndoRedoList();
GetScreen()->ClrModify();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,6 +36,7 @@
#include <dialogs/dialog_constraints_reporter.h>
#include <kicad_string.h>
#include "board_inspection_tool.h"
#include <pcbnew_settings.h>
#include <widgets/appearance_controls.h>
@ -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;
}

View File

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

View File

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