KiCad PCB EDA Suite
HIDPI_GL_CANVAS Class Reference

wxGLCanvas wrapper for HiDPI/Retina support. More...

#include <hidpi_gl_canvas.h>

Inheritance diagram for HIDPI_GL_CANVAS:
C3D_MODEL_VIEWER EDA_3D_CANVAS KIGFX::OPENGL_GAL

Public Member Functions

 HIDPI_GL_CANVAS (wxWindow *parent, wxWindowID id=wxID_ANY, const int *attribList=NULL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxGLCanvasName, const wxPalette &palette=wxNullPalette)
 
virtual wxSize GetNativePixelSize () const
 
void SetScaleFactor (double aFactor)
 Set the canvas scale factor, probably for a hi-DPI display. More...
 
double GetScaleFactor () const
 Get the current scale factor. More...
 

Private Attributes

double m_scale_factor
 The current scale factor (e.g. More...
 

Detailed Description

wxGLCanvas wrapper for HiDPI/Retina support.

This is a small wrapper class to enable HiDPI/Retina support for wxGLCanvas.

Definition at line 38 of file hidpi_gl_canvas.h.

Constructor & Destructor Documentation

◆ HIDPI_GL_CANVAS()

HIDPI_GL_CANVAS::HIDPI_GL_CANVAS ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const int *  attribList = NULL,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = wxGLCanvasName,
const wxPalette &  palette = wxNullPalette 
)

Definition at line 32 of file hidpi_gl_canvas.cpp.

35  : wxGLCanvas( parent, id, attribList, pos, size, style, name, palette ),
37 {
38  // As of wxWidgets version 3.1.3, this is the default behavior of the wxGLCanvas on OSX
39  // so this piece of code can be removed once our minimum version is >3.1.3 for OSX.
40 #ifdef RETINA_OPENGL_PATCH
41  SetViewWantsBestResolution( true );
42 #endif
43 }
static double GetDefaultScaleFactor()
Get the "default" scaling factor to use if not other config is available.
double m_scale_factor
The current scale factor (e.g.
const char * name
Definition: DXF_plotter.cpp:59

Member Function Documentation

◆ GetNativePixelSize()

wxSize HIDPI_GL_CANVAS::GetNativePixelSize ( ) const
virtual

Definition at line 46 of file hidpi_gl_canvas.cpp.

47 {
48  wxSize size = wxGLCanvas::GetClientSize();
49 
50  const double scaleFactor = GetScaleFactor();
51  size.x *= scaleFactor;
52  size.y *= scaleFactor;
53 
54  return size;
55 }
double GetScaleFactor() const
Get the current scale factor.

References GetScaleFactor().

Referenced by EDA_3D_CANVAS::DoRePaint(), EDA_3D_CANVAS::OnMouseMove(), and KIGFX::OPENGL_GAL::OPENGL_GAL().

◆ GetScaleFactor()

double HIDPI_GL_CANVAS::GetScaleFactor ( ) const

◆ SetScaleFactor()

void HIDPI_GL_CANVAS::SetScaleFactor ( double  aFactor)

Set the canvas scale factor, probably for a hi-DPI display.

Definition at line 58 of file hidpi_gl_canvas.cpp.

59 {
60  m_scale_factor = aNewScaleFactor;
61 }
double m_scale_factor
The current scale factor (e.g.

References m_scale_factor.

Referenced by PANEL_PREV_3D::loadCommonSettings(), EDA_3D_VIEWER::loadCommonSettings(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().

Member Data Documentation

◆ m_scale_factor

double HIDPI_GL_CANVAS::m_scale_factor
private

The current scale factor (e.g.

for hi-DPI displays)

Definition at line 68 of file hidpi_gl_canvas.h.

Referenced by GetScaleFactor(), and SetScaleFactor().


The documentation for this class was generated from the following files: