Evict the Pgm() dependency in GAL
This commit is contained in:
parent
cef0f176d3
commit
a6a20bf8dc
|
@ -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 ),
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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 ),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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" ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue