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,
|
EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
|
||||||
BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera,
|
BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera,
|
||||||
S3D_CACHE* a3DCachePointer ) :
|
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 ),
|
wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ),
|
||||||
m_eventDispatcher( nullptr ),
|
m_eventDispatcher( nullptr ),
|
||||||
m_parentStatusBar( nullptr ),
|
m_parentStatusBar( nullptr ),
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <settings/common_settings.h>
|
#include <settings/common_settings.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <gal/dpi_scaling.h>
|
#include <gal/dpi_scaling.h>
|
||||||
|
#include <class_draw_panel_gal.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +87,8 @@ END_EVENT_TABLE()
|
||||||
|
|
||||||
EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList,
|
EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList,
|
||||||
S3D_CACHE* aCacheManager ) :
|
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 ),
|
wxFULL_REPAINT_ON_RESIZE ),
|
||||||
m_trackBallCamera( RANGE_SCALE_3D * 4.0f ),
|
m_trackBallCamera( RANGE_SCALE_3D * 4.0f ),
|
||||||
m_cacheManager( aCacheManager )
|
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->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
|
||||||
m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
|
m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
|
||||||
m_canvas->SetProjectionMode( cfg->m_Camera.projection_mode );
|
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 )
|
if( cfg->m_CurrentPreset == LEGACY_PRESET_FLAG )
|
||||||
{
|
{
|
||||||
|
|
|
@ -318,6 +318,7 @@ set( COMMON_SRCS
|
||||||
config_params.cpp
|
config_params.cpp
|
||||||
confirm.cpp
|
confirm.cpp
|
||||||
dialog_shim.cpp
|
dialog_shim.cpp
|
||||||
|
draw_panel_gal.cpp
|
||||||
gr_text.cpp
|
gr_text.cpp
|
||||||
dsnlexer.cpp
|
dsnlexer.cpp
|
||||||
eda_base_frame.cpp
|
eda_base_frame.cpp
|
||||||
|
|
|
@ -485,7 +485,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
||||||
|
|
||||||
if( errormsg.empty() )
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -673,3 +673,28 @@ void EDA_DRAW_PANEL_GAL::ClearDebugOverlay()
|
||||||
m_debugOverlay = nullptr;
|
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
|
set( GAL_SRCS
|
||||||
# Common part
|
# Common part
|
||||||
../callback_gal.cpp
|
../callback_gal.cpp
|
||||||
../draw_panel_gal.cpp
|
|
||||||
../gl_context_mgr.cpp
|
../gl_context_mgr.cpp
|
||||||
../newstroke_font.cpp
|
../newstroke_font.cpp
|
||||||
../painter.cpp
|
../painter.cpp
|
||||||
|
|
|
@ -28,11 +28,12 @@
|
||||||
|
|
||||||
const float HIDPI_GL_3D_CANVAS::m_delta_move_step_factor = 0.7f;
|
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 int* aAttribList, const wxPoint& aPos,
|
||||||
const wxSize& aSize, long aStyle, const wxString& aName,
|
const wxSize& aSize, long aStyle, const wxString& aName,
|
||||||
const wxPalette& aPalette ) :
|
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_is_moving( false ),
|
||||||
m_mouse_was_moved( false ),
|
m_mouse_was_moved( false ),
|
||||||
m_camera_is_moving( false ),
|
m_camera_is_moving( false ),
|
||||||
|
|
|
@ -29,35 +29,16 @@
|
||||||
#include <gal/dpi_scaling.h>
|
#include <gal/dpi_scaling.h>
|
||||||
|
|
||||||
|
|
||||||
HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow* parent, wxWindowID id, const int* attribList,
|
HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( const KIGFX::VC_SETTINGS& aSettings, wxWindow* aParent, wxWindowID aId,
|
||||||
const wxPoint& pos, const wxSize& size, long style,
|
const int* aAttribList,
|
||||||
const wxString& name, const wxPalette& palette ) :
|
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
||||||
wxGLCanvas( parent, id, attribList, pos, size, style, name, palette ),
|
const wxString& aName, const wxPalette& aPalette ) :
|
||||||
|
wxGLCanvas( aParent, aId, aAttribList, aPos, aSize, aStyle, aName, aPalette ),
|
||||||
|
m_settings( aSettings ),
|
||||||
m_scale_factor( DPI_SCALING::GetDefaultScaleFactor() )
|
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
|
wxSize HIDPI_GL_CANVAS::GetNativePixelSize() const
|
||||||
{
|
{
|
||||||
|
@ -92,4 +73,4 @@ void HIDPI_GL_CANVAS::SetScaleFactor( double aNewScaleFactor )
|
||||||
double HIDPI_GL_CANVAS::GetScaleFactor() const
|
double HIDPI_GL_CANVAS::GetScaleFactor() const
|
||||||
{
|
{
|
||||||
return m_scale_factor;
|
return m_scale_factor;
|
||||||
}
|
}
|
|
@ -238,11 +238,13 @@ GLuint GL_BITMAP_CACHE::cacheBitmap( const BITMAP_BASE* aBitmap )
|
||||||
return textureID;
|
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,
|
wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener,
|
||||||
const wxString& aName ) :
|
const wxString& aName ) :
|
||||||
GAL( aDisplayOptions ),
|
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 ),
|
wxEXPAND, aName ),
|
||||||
m_mouseListener( aMouseListener ),
|
m_mouseListener( aMouseListener ),
|
||||||
m_paintListener( aPaintListener ),
|
m_paintListener( aPaintListener ),
|
||||||
|
@ -400,7 +402,8 @@ wxString OPENGL_GAL::CheckFeatures( GAL_DISPLAY_OPTIONS& aOptions )
|
||||||
|
|
||||||
try
|
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->Raise();
|
||||||
testFrame->Show();
|
testFrame->Show();
|
||||||
|
|
|
@ -53,6 +53,7 @@ class VIEW_CONTROLS;
|
||||||
class PAINTER;
|
class PAINTER;
|
||||||
class GAL_DISPLAY_OPTIONS;
|
class GAL_DISPLAY_OPTIONS;
|
||||||
class VIEW_OVERLAY;
|
class VIEW_OVERLAY;
|
||||||
|
struct VC_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,7 +225,7 @@ public:
|
||||||
* Usually called by a OnPaint event.
|
* Usually called by a OnPaint event.
|
||||||
*
|
*
|
||||||
* Because it does not use a wxPaintDC, it can be called outside a wxPaintEvent.
|
* Because it does not use a wxPaintDC, it can be called outside a wxPaintEvent.
|
||||||
*
|
*
|
||||||
* @return true if the repaint attempt was successful.
|
* @return true if the repaint attempt was successful.
|
||||||
*/
|
*/
|
||||||
bool DoRePaint();
|
bool DoRePaint();
|
||||||
|
@ -240,6 +241,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void ClearDebugOverlay();
|
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
|
* used on wxMSW: true after a wxEVT_MOUSE_CAPTURE_LOST was received
|
||||||
* false after the mouse is recaptured.
|
* false after the mouse is recaptured.
|
||||||
|
|
|
@ -39,14 +39,15 @@ class RENDER_3D_OPENGL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides basic 3D controls ( zoom, rotate, translate, ... )
|
* Provides basic 3D controls ( zoom, rotate, translate, ... )
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class HIDPI_GL_3D_CANVAS : public HIDPI_GL_CANVAS
|
class HIDPI_GL_3D_CANVAS : public HIDPI_GL_CANVAS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// wxGLCanvas constructor
|
// 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 int* attribList = nullptr, const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize, long style = 0,
|
const wxSize& size = wxDefaultSize, long style = 0,
|
||||||
const wxString& name = wxGLCanvasName,
|
const wxString& name = wxGLCanvasName,
|
||||||
|
|
|
@ -42,10 +42,11 @@ class HIDPI_GL_CANVAS : public wxGLCanvas
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// wxGLCanvas constructor
|
// wxGLCanvas constructor
|
||||||
HIDPI_GL_CANVAS( wxWindow *parent, wxWindowID id = wxID_ANY, const int* attribList = nullptr,
|
HIDPI_GL_CANVAS( const KIGFX::VC_SETTINGS& aSettings, wxWindow* aParent,
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
wxWindowID aId = wxID_ANY, const int* aAttribList = nullptr,
|
||||||
long style = 0, const wxString& name = wxGLCanvasName,
|
const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize,
|
||||||
const wxPalette& palette = wxNullPalette );
|
long aStyle = 0, const wxString& aName = wxGLCanvasName,
|
||||||
|
const wxPalette& aPalette = wxNullPalette );
|
||||||
|
|
||||||
virtual wxSize GetNativePixelSize() const;
|
virtual wxSize GetNativePixelSize() const;
|
||||||
|
|
||||||
|
@ -64,10 +65,7 @@ public:
|
||||||
*/
|
*/
|
||||||
double GetScaleFactor() const;
|
double GetScaleFactor() const;
|
||||||
|
|
||||||
/**
|
void SetVcSettings( const KIGFX::VC_SETTINGS& aVcSettings ) { m_settings = aVcSettings; }
|
||||||
* Loads or updates the current settings
|
|
||||||
*/
|
|
||||||
void LoadSettings();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///< Current VIEW_CONTROLS settings.
|
///< Current VIEW_CONTROLS settings.
|
||||||
|
|
|
@ -82,7 +82,8 @@ public:
|
||||||
*
|
*
|
||||||
* @param aName is the name of this window for use by wxWindow::FindWindowByName()
|
* @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,
|
wxEvtHandler* aMouseListener = nullptr, wxEvtHandler* aPaintListener = nullptr,
|
||||||
const wxString& aName = wxT( "GLCanvas" ) );
|
const wxString& aName = wxT( "GLCanvas" ) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue