3D viewer: use hi-DPI settings for canvases
The 3D viewer also uses OpenGL, so it also needs to adjust based on DPI scale factors. This patch moves the 3D viewer common config code solely within the 3D viewer, and adds handling of the DPI scale. This also avoids duplicated logic in PCB_BASE_FRAME::CommonSettingsChanged. For now, as EDA_3D_VIEWER is not included in the Kiway settings dispatch, still manually invoke the settings update from PCB_BASE_FRAME. The PANEL_3D_PREV gets a similar function to read the config, but it doesn't have a listener for the update, so it's set just once at dialog init, just like the existing pan settings. Fixes: lp:1823681 * https://bugs.launchpad.net/kicad/+bug/1823681
This commit is contained in:
parent
d361e68d0e
commit
124dd5e59a
|
@ -28,16 +28,20 @@
|
|||
* @file panel_prev_model.cpp
|
||||
*/
|
||||
|
||||
#include "panel_prev_model.h"
|
||||
|
||||
#include <3d_canvas/eda_3d_canvas.h>
|
||||
#include <common_ogl/cogl_att_list.h>
|
||||
#include <bitmaps.h>
|
||||
#include <base_units.h>
|
||||
|
||||
#include "project.h"
|
||||
#include "panel_prev_model.h"
|
||||
#include <class_board.h>
|
||||
|
||||
#include <base_units.h>
|
||||
#include <bitmaps.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <dpi_scaling.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
|
||||
|
||||
PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule,
|
||||
std::vector<MODULE_3D_SETTINGS> *aParentModelList ) :
|
||||
|
@ -58,15 +62,13 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE*
|
|||
// Set 3d viewer configuration for preview
|
||||
m_settings3Dviewer = new CINFO3D_VISU();
|
||||
|
||||
bool option;
|
||||
Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
|
||||
m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
|
||||
// Create the 3D canvas
|
||||
m_previewPane = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( true ),
|
||||
m_dummyBoard, *m_settings3Dviewer,
|
||||
aFrame->Prj().Get3DCacheManager() );
|
||||
|
||||
loadCommonSettings();
|
||||
|
||||
m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
|
||||
}
|
||||
|
||||
|
@ -111,6 +113,25 @@ void PANEL_PREV_3D::initPanel()
|
|||
}
|
||||
|
||||
|
||||
void PANEL_PREV_3D::loadCommonSettings()
|
||||
{
|
||||
wxCHECK_RET( m_previewPane, "Cannot load settings to null canvas" );
|
||||
|
||||
wxConfigBase& cmnCfg = *Pgm().CommonSettings();
|
||||
|
||||
{
|
||||
const DPI_SCALING dpi{ &cmnCfg, this };
|
||||
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
}
|
||||
|
||||
{
|
||||
bool option;
|
||||
cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
|
||||
m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief rotationFromString
|
||||
* Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION
|
||||
|
|
|
@ -93,6 +93,11 @@ private:
|
|||
private:
|
||||
void initPanel();
|
||||
|
||||
/**
|
||||
* Load 3D relevant settings from the user configuration
|
||||
*/
|
||||
void loadCommonSettings();
|
||||
|
||||
/**
|
||||
* @brief updateOrientation - it will receive the events from editing the fields
|
||||
* @param event
|
||||
|
|
|
@ -28,18 +28,22 @@
|
|||
*/
|
||||
|
||||
#include "eda_3d_viewer.h"
|
||||
|
||||
#include "../3d_viewer_id.h"
|
||||
#include <project.h>
|
||||
#include "../common_ogl/cogl_att_list.h"
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include <dpi_scaling.h>
|
||||
#include <gestfich.h>
|
||||
#include <lru_cache.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <hotkeys_basic.h>
|
||||
#include <wx/colordlg.h>
|
||||
#include <wx/colourdata.h>
|
||||
#include <lru_cache.h>
|
||||
#include "../common_ogl/cogl_att_list.h"
|
||||
#include <hotkeys_basic.h>
|
||||
#include <wx/toolbar.h>
|
||||
#include <bitmaps.h>
|
||||
#include <pgm_base.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -168,10 +172,6 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
|
|||
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
|
||||
SetIcon( icon );
|
||||
|
||||
bool option;
|
||||
Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
|
||||
m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
|
||||
LoadSettings( config() );
|
||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
|
@ -190,6 +190,9 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
|
|||
if( m_canvas )
|
||||
m_canvas->SetStatusBar( status_bar );
|
||||
|
||||
// Some settings need the canvas
|
||||
loadCommonSettings();
|
||||
|
||||
CreateMenuBar();
|
||||
ReCreateMainToolbar();
|
||||
|
||||
|
@ -869,6 +872,19 @@ void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg )
|
|||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::CommonSettingsChanged()
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CommonSettingsChanged" );
|
||||
|
||||
// Regen menu bars, etc
|
||||
EDA_BASE_FRAME::CommonSettingsChanged();
|
||||
|
||||
loadCommonSettings();
|
||||
|
||||
NewDisplay( true );
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::OnLeftClick( wxDC *DC, const wxPoint &MousePos )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnLeftClick" );
|
||||
|
@ -1225,3 +1241,22 @@ void EDA_3D_VIEWER::OnUpdateUIAxis( wxUpdateUIEvent& aEvent )
|
|||
{
|
||||
aEvent.Check( m_settings.GetFlag( FL_AXIS ) );
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_VIEWER::loadCommonSettings()
|
||||
{
|
||||
wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
|
||||
|
||||
wxConfigBase& cmnCfg = *Pgm().CommonSettings();
|
||||
|
||||
{
|
||||
const DPI_SCALING dpi{ &cmnCfg, this };
|
||||
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
}
|
||||
|
||||
{
|
||||
bool option;
|
||||
cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
|
||||
m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
}
|
||||
}
|
|
@ -154,6 +154,15 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
|
|||
*/
|
||||
bool Set3DSilkScreenColorFromUser();
|
||||
|
||||
/**
|
||||
* Notification that common settings are updated.
|
||||
*
|
||||
* This would be private (and only called by the Kiway), but we
|
||||
* need to do this manually from the PCB frame because the 3D viewer isn't
|
||||
* updated via the #KIWAY.
|
||||
*/
|
||||
void CommonSettingsChanged() override;
|
||||
|
||||
private:
|
||||
/// Called when user press the File->Exit
|
||||
void Exit3DFrame( wxCommandEvent &event );
|
||||
|
@ -217,6 +226,11 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
|
|||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Load configuration from common settings.
|
||||
*/
|
||||
void loadCommonSettings();
|
||||
|
||||
/**
|
||||
* Filename to propose for save a screenshot
|
||||
*/
|
||||
|
|
|
@ -992,9 +992,8 @@ void PCB_BASE_FRAME::CommonSettingsChanged()
|
|||
|
||||
if( viewer )
|
||||
{
|
||||
bool option;
|
||||
Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
|
||||
viewer->GetSettings().SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
// The 3D viewer isn't in the Kiway, so send its update manually
|
||||
viewer->CommonSettingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue