From 9622918c314235dd02119cabc80087feceaee6dd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 19 Feb 2024 16:28:38 +0100 Subject: [PATCH] 3D view export to PNG/JPEG: ensure highlighted item under cursor is exoperted not highlighted. Fixes #14289 https://gitlab.com/kicad/code/kicad/-/issues/14289 --- 3d-viewer/3d_canvas/eda_3d_canvas.h | 10 ++++------ 3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.h b/3d-viewer/3d_canvas/eda_3d_canvas.h index 293855370d..ee4e44b7a1 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.h +++ b/3d-viewer/3d_canvas/eda_3d_canvas.h @@ -208,12 +208,6 @@ public: m_3dmousePivotPos = aPos; } -private: - /** - * Called by a wxPaintEvent event - */ - void OnPaint( wxPaintEvent& aEvent ); - /** * The actual function to repaint the canvas. * @@ -222,6 +216,10 @@ private: */ void DoRePaint(); +private: + // The wxPaintEvent event. mainly calls DoRePaint() + void OnPaint( wxPaintEvent& aEvent ); + void OnEraseBackground( wxEraseEvent& event ); void OnRefreshRequest( wxEvent& aEvent ); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index dfd35da6b3..1ddec77a13 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -757,8 +757,13 @@ void EDA_3D_VIEWER_FRAME::takeScreenshot( wxCommandEvent& event ) } // Be sure we have the latest 3D view (remember 3D view is buffered) - m_canvas->Request_refresh( true ); - wxYield(); + // Also ensure any highlighted item is not highlighted when creating screen shot + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + bool allow_highlight = cfg.highlight_on_rollover; + cfg.highlight_on_rollover = false; + + m_canvas->DoRePaint(); // init first buffer + m_canvas->DoRePaint(); // init second buffer // Build image from the 3D buffer wxWindowUpdateLocker noUpdates( this ); @@ -768,6 +773,8 @@ void EDA_3D_VIEWER_FRAME::takeScreenshot( wxCommandEvent& event ) if( m_canvas ) m_canvas->GetScreenshot( screenshotImage ); + cfg.highlight_on_rollover = allow_highlight; + if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { wxBitmap bitmap( screenshotImage );