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:
EDA_3D_CANVAS EDA_3D_MODEL_VIEWER KIGFX::OPENGL_GAL

Public Member Functions

 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)
 
virtual wxSize GetNativePixelSize () const
 
wxPoint GetNativePosition (const wxPoint &aPoint) const
 Convert the given point from client coordinates to native pixel coordinates. More...
 
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 = nullptr,
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.

34  :
35  wxGLCanvas( parent, id, attribList, pos, size, style, name, palette ),
37 {
38 }
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:56

Member Function Documentation

◆ GetNativePixelSize()

wxSize HIDPI_GL_CANVAS::GetNativePixelSize ( ) const
virtual

Definition at line 41 of file hidpi_gl_canvas.cpp.

42 {
43  wxSize size = wxGLCanvas::GetClientSize();
44 
45  const double scaleFactor = GetScaleFactor();
46  size.x *= scaleFactor;
47  size.y *= scaleFactor;
48 
49  return size;
50 }
double GetScaleFactor() const
Get the current scale factor.

References GetScaleFactor().

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

◆ GetNativePosition()

wxPoint HIDPI_GL_CANVAS::GetNativePosition ( const wxPoint &  aPoint) const

Convert the given point from client coordinates to native pixel coordinates.

Definition at line 53 of file hidpi_gl_canvas.cpp.

54 {
55  wxPoint nativePoint = aPoint;
56 
57  const double scaleFactor = GetScaleFactor();
58  nativePoint.x *= scaleFactor;
59  nativePoint.y *= scaleFactor;
60 
61  return nativePoint;
62 }
double GetScaleFactor() const
Get the current scale factor.

References GetScaleFactor().

Referenced by EDA_3D_MODEL_VIEWER::OnMouseMove(), EDA_3D_CANVAS::OnMouseMove(), and EDA_3D_CANVAS::OnMouseWheel().

◆ 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 65 of file hidpi_gl_canvas.cpp.

66 {
67  m_scale_factor = aNewScaleFactor;
68 }
double m_scale_factor
The current scale factor (e.g.

References m_scale_factor.

Referenced by EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER(), EDA_3D_VIEWER_FRAME::loadCommonSettings(), PANEL_PREVIEW_3D_MODEL::loadSettings(), 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: