diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp index 925d2c1538..b8183d6283 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp @@ -85,7 +85,8 @@ END_EVENT_TABLE() EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList, BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera, S3D_CACHE* a3DCachePointer ) : - HIDPI_GL_3D_CANVAS( aCamera, aParent, wxID_ANY, aAttribList, wxDefaultPosition, + HIDPI_GL_3D_CANVAS( EDA_DRAW_PANEL_GAL::GetVcSettings(), aCamera, aParent, wxID_ANY, + aAttribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ), m_eventDispatcher( nullptr ), m_parentStatusBar( nullptr ), diff --git a/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp b/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp index c0b5b98a3a..3e89bde576 100644 --- a/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp +++ b/3d-viewer/3d_model_viewer/eda_3d_model_viewer.cpp @@ -39,6 +39,7 @@ #include <settings/common_settings.h> #include <pgm_base.h> #include <gal/dpi_scaling.h> +#include <class_draw_panel_gal.h> #include <macros.h> /** @@ -86,7 +87,8 @@ END_EVENT_TABLE() EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList, S3D_CACHE* aCacheManager ) : - HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize, + HIDPI_GL_CANVAS( EDA_DRAW_PANEL_GAL::GetVcSettings(), aParent, wxID_ANY, aAttribList, + wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ), m_trackBallCamera( RANGE_SCALE_3D * 4.0f ), m_cacheManager( aCacheManager ) diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index acf048b2a5..5995fbb0cc 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -577,7 +577,9 @@ void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg ) m_canvas->SetAnimationEnabled( cfg->m_Camera.animation_enabled ); m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier ); m_canvas->SetProjectionMode( cfg->m_Camera.projection_mode ); - m_canvas->LoadSettings(); + + + m_canvas->SetVcSettings( EDA_DRAW_PANEL_GAL::GetVcSettings() ); if( cfg->m_CurrentPreset == LEGACY_PRESET_FLAG ) { diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 1ae85f69c5..4d120a305b 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -318,6 +318,7 @@ set( COMMON_SRCS config_params.cpp confirm.cpp dialog_shim.cpp + draw_panel_gal.cpp gr_text.cpp dsnlexer.cpp eda_base_frame.cpp diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index f6a5e5712b..e7701e0d1b 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -485,7 +485,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) if( errormsg.empty() ) { - new_gal = new KIGFX::OPENGL_GAL( m_options, this, this, this ); + new_gal = new KIGFX::OPENGL_GAL( GetVcSettings(), m_options, this, this, this ); } else { @@ -673,3 +673,28 @@ void EDA_DRAW_PANEL_GAL::ClearDebugOverlay() m_debugOverlay = nullptr; } } + + +KIGFX::VC_SETTINGS EDA_DRAW_PANEL_GAL::GetVcSettings() +{ + COMMON_SETTINGS* cfg = Pgm().GetCommonSettings(); + + KIGFX::VC_SETTINGS vcSettings; + vcSettings.m_warpCursor = cfg->m_Input.center_on_zoom; + vcSettings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb; + vcSettings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan; + vcSettings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration; + vcSettings.m_horizontalPan = cfg->m_Input.horizontal_pan; + vcSettings.m_zoomAcceleration = cfg->m_Input.zoom_acceleration; + vcSettings.m_zoomSpeed = cfg->m_Input.zoom_speed; + vcSettings.m_zoomSpeedAuto = cfg->m_Input.zoom_speed_auto; + vcSettings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom; + vcSettings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h; + vcSettings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v; + vcSettings.m_dragLeft = cfg->m_Input.drag_left; + vcSettings.m_dragMiddle = cfg->m_Input.drag_middle; + vcSettings.m_dragRight = cfg->m_Input.drag_right; + vcSettings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h; + + return vcSettings; +} \ No newline at end of file diff --git a/common/gal/CMakeLists.txt b/common/gal/CMakeLists.txt index b23190cecd..0c29473053 100644 --- a/common/gal/CMakeLists.txt +++ b/common/gal/CMakeLists.txt @@ -2,7 +2,6 @@ set( GAL_SRCS # Common part ../callback_gal.cpp - ../draw_panel_gal.cpp ../gl_context_mgr.cpp ../newstroke_font.cpp ../painter.cpp diff --git a/common/gal/hidpi_gl_3D_canvas.cpp b/common/gal/hidpi_gl_3D_canvas.cpp index d3884fde98..3bf8867a04 100644 --- a/common/gal/hidpi_gl_3D_canvas.cpp +++ b/common/gal/hidpi_gl_3D_canvas.cpp @@ -28,11 +28,12 @@ const float HIDPI_GL_3D_CANVAS::m_delta_move_step_factor = 0.7f; -HIDPI_GL_3D_CANVAS::HIDPI_GL_3D_CANVAS( CAMERA& aCamera, wxWindow* aParent, wxWindowID, +HIDPI_GL_3D_CANVAS::HIDPI_GL_3D_CANVAS( const KIGFX::VC_SETTINGS& aVcSettings, CAMERA& aCamera, + wxWindow* aParent, wxWindowID, const int* aAttribList, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aName, const wxPalette& aPalette ) : - HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, aPos, aSize, aStyle, aName, aPalette ), + HIDPI_GL_CANVAS( aVcSettings, aParent, wxID_ANY, aAttribList, aPos, aSize, aStyle, aName, aPalette ), m_mouse_is_moving( false ), m_mouse_was_moved( false ), m_camera_is_moving( false ), diff --git a/common/gal/hidpi_gl_canvas.cpp b/common/gal/hidpi_gl_canvas.cpp index 4c10ce1b50..22fc2c351a 100644 --- a/common/gal/hidpi_gl_canvas.cpp +++ b/common/gal/hidpi_gl_canvas.cpp @@ -29,35 +29,16 @@ #include <gal/dpi_scaling.h> -HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow* parent, wxWindowID id, const int* attribList, - const wxPoint& pos, const wxSize& size, long style, - const wxString& name, const wxPalette& palette ) : - wxGLCanvas( parent, id, attribList, pos, size, style, name, palette ), +HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( const KIGFX::VC_SETTINGS& aSettings, wxWindow* aParent, wxWindowID aId, + const int* aAttribList, + const wxPoint& aPos, const wxSize& aSize, long aStyle, + const wxString& aName, const wxPalette& aPalette ) : + wxGLCanvas( aParent, aId, aAttribList, aPos, aSize, aStyle, aName, aPalette ), + m_settings( aSettings ), m_scale_factor( DPI_SCALING::GetDefaultScaleFactor() ) { - this->LoadSettings(); } -void HIDPI_GL_CANVAS::LoadSettings() -{ - COMMON_SETTINGS* cfg = Pgm().GetCommonSettings(); - - m_settings.m_warpCursor = cfg->m_Input.center_on_zoom; - m_settings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb; - m_settings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan; - m_settings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration; - m_settings.m_horizontalPan = cfg->m_Input.horizontal_pan; - m_settings.m_zoomAcceleration = cfg->m_Input.zoom_acceleration; - m_settings.m_zoomSpeed = cfg->m_Input.zoom_speed; - m_settings.m_zoomSpeedAuto = cfg->m_Input.zoom_speed_auto; - m_settings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom; - m_settings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h; - m_settings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v; - m_settings.m_dragLeft = cfg->m_Input.drag_left; - m_settings.m_dragMiddle = cfg->m_Input.drag_middle; - m_settings.m_dragRight = cfg->m_Input.drag_right; - m_settings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h; -} wxSize HIDPI_GL_CANVAS::GetNativePixelSize() const { @@ -92,4 +73,4 @@ void HIDPI_GL_CANVAS::SetScaleFactor( double aNewScaleFactor ) double HIDPI_GL_CANVAS::GetScaleFactor() const { return m_scale_factor; -} +} \ No newline at end of file diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 37b653b2a7..d7e4622029 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -238,11 +238,13 @@ GLuint GL_BITMAP_CACHE::cacheBitmap( const BITMAP_BASE* aBitmap ) return textureID; } -OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, +OPENGL_GAL::OPENGL_GAL( const KIGFX::VC_SETTINGS& aVcSettings, GAL_DISPLAY_OPTIONS& aDisplayOptions, + wxWindow* aParent, wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener, const wxString& aName ) : GAL( aDisplayOptions ), - HIDPI_GL_CANVAS( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize, + HIDPI_GL_CANVAS( aVcSettings, aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, + wxDefaultSize, wxEXPAND, aName ), m_mouseListener( aMouseListener ), m_paintListener( aPaintListener ), @@ -400,7 +402,8 @@ wxString OPENGL_GAL::CheckFeatures( GAL_DISPLAY_OPTIONS& aOptions ) try { - opengl_gal = new KIGFX::OPENGL_GAL( aOptions, testFrame ); + KIGFX::VC_SETTINGS dummy; + opengl_gal = new KIGFX::OPENGL_GAL( dummy, aOptions, testFrame ); testFrame->Raise(); testFrame->Show(); diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index 0940ae32d5..618c295d3c 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -53,6 +53,7 @@ class VIEW_CONTROLS; class PAINTER; class GAL_DISPLAY_OPTIONS; class VIEW_OVERLAY; +struct VC_SETTINGS; } @@ -224,7 +225,7 @@ public: * Usually called by a OnPaint event. * * Because it does not use a wxPaintDC, it can be called outside a wxPaintEvent. - * + * * @return true if the repaint attempt was successful. */ bool DoRePaint(); @@ -240,6 +241,12 @@ public: */ void ClearDebugOverlay(); + + /** + * Gets a populated View Controls settings object dervived from our program settings + */ + static KIGFX::VC_SETTINGS GetVcSettings(); + /** * used on wxMSW: true after a wxEVT_MOUSE_CAPTURE_LOST was received * false after the mouse is recaptured. diff --git a/include/gal/hidpi_gl_3D_canvas.h b/include/gal/hidpi_gl_3D_canvas.h index 169723c15c..92f42a029c 100644 --- a/include/gal/hidpi_gl_3D_canvas.h +++ b/include/gal/hidpi_gl_3D_canvas.h @@ -39,14 +39,15 @@ class RENDER_3D_OPENGL; /** * Provides basic 3D controls ( zoom, rotate, translate, ... ) - * + * */ class HIDPI_GL_3D_CANVAS : public HIDPI_GL_CANVAS { public: // wxGLCanvas constructor - HIDPI_GL_3D_CANVAS( CAMERA& aCamera, wxWindow* parent, wxWindowID id = wxID_ANY, + HIDPI_GL_3D_CANVAS( const KIGFX::VC_SETTINGS& aVcSettings, CAMERA& aCamera, wxWindow* parent, + wxWindowID id = wxID_ANY, const int* attribList = nullptr, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxGLCanvasName, diff --git a/include/gal/hidpi_gl_canvas.h b/include/gal/hidpi_gl_canvas.h index 19fd7ae115..4b2ffc1372 100644 --- a/include/gal/hidpi_gl_canvas.h +++ b/include/gal/hidpi_gl_canvas.h @@ -42,10 +42,11 @@ class HIDPI_GL_CANVAS : public wxGLCanvas { public: // wxGLCanvas constructor - HIDPI_GL_CANVAS( wxWindow *parent, wxWindowID id = wxID_ANY, const int* attribList = nullptr, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = wxGLCanvasName, - const wxPalette& palette = wxNullPalette ); + HIDPI_GL_CANVAS( const KIGFX::VC_SETTINGS& aSettings, wxWindow* aParent, + wxWindowID aId = wxID_ANY, const int* aAttribList = nullptr, + const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize, + long aStyle = 0, const wxString& aName = wxGLCanvasName, + const wxPalette& aPalette = wxNullPalette ); virtual wxSize GetNativePixelSize() const; @@ -64,10 +65,7 @@ public: */ double GetScaleFactor() const; - /** - * Loads or updates the current settings - */ - void LoadSettings(); + void SetVcSettings( const KIGFX::VC_SETTINGS& aVcSettings ) { m_settings = aVcSettings; } protected: ///< Current VIEW_CONTROLS settings. diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index 59bba2414b..e3ceab22d4 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -82,7 +82,8 @@ public: * * @param aName is the name of this window for use by wxWindow::FindWindowByName() */ - OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, + OPENGL_GAL( const KIGFX::VC_SETTINGS& aVcSettings, GAL_DISPLAY_OPTIONS& aDisplayOptions, + wxWindow* aParent, wxEvtHandler* aMouseListener = nullptr, wxEvtHandler* aPaintListener = nullptr, const wxString& aName = wxT( "GLCanvas" ) );