KiCad PCB EDA Suite
KIGFX::CONSTANT_ZOOM_CONTROLLER Class Reference

A #ZOOM_CONTROLLER that zooms by a fixed factor based only on the magnitude of the scroll wheel rotation. More...

#include <zoom_controller.h>

Inheritance diagram for KIGFX::CONSTANT_ZOOM_CONTROLLER:
KIGFX::ZOOM_CONTROLLER

Public Member Functions

 CONSTANT_ZOOM_CONTROLLER (double aScale)
 
double GetScaleForRotation (int aRotation) override
 A suitable (magic) scale factor for GTK3 systems. More...
 

Static Public Attributes

static constexpr double GTK3_SCALE = 0.002
 A suitable (magic) scale factor for Mac systems. More...
 
static constexpr double MAC_SCALE = 0.01
 
static constexpr double MSW_SCALE = 0.005
 A suitable (magic) scale factor for Windows systems. More...
 
static constexpr double MANUAL_SCALE_FACTOR = 0.001
 

Private Attributes

double m_scale
 < The scale factor set by the constructor. More...
 

Detailed Description

A #ZOOM_CONTROLLER that zooms by a fixed factor based only on the magnitude of the scroll wheel rotation.

Definition at line 141 of file zoom_controller.h.

Constructor & Destructor Documentation

◆ CONSTANT_ZOOM_CONTROLLER()

CONSTANT_ZOOM_CONTROLLER::CONSTANT_ZOOM_CONTROLLER ( double  aScale)
Parameters
aScalea scaling parameter that adjusts the magnitude of the scroll. This factor might be dependent on the platform for comfort.

Definition at line 112 of file zoom_controller.cpp.

112 : m_scale( aScale )
113{
114}
double m_scale
< The scale factor set by the constructor.

Member Function Documentation

◆ GetScaleForRotation()

double CONSTANT_ZOOM_CONTROLLER::GetScaleForRotation ( int  aRotation)
overridevirtual

A suitable (magic) scale factor for GTK3 systems.

Implements KIGFX::ZOOM_CONTROLLER.

Definition at line 117 of file zoom_controller.cpp.

118{
119 wxLogTrace( traceZoomScroll, wxString::Format( "Rot %d", aRotation ) );
120
121 aRotation = ( aRotation > 0 ) ? std::min( aRotation, 100 ) : std::max( aRotation, -100 );
122
123 double dscale = aRotation * m_scale;
124
125 double zoom_scale = ( aRotation > 0 ) ? ( 1 + dscale ) : 1 / ( 1 - dscale );
126
127 wxLogTrace( traceZoomScroll, wxString::Format( " Zoom factor: %f", zoom_scale ) );
128
129 return zoom_scale;
130}
const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format(), m_scale, and traceZoomScroll.

Referenced by BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ GTK3_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::GTK3_SCALE = 0.002
staticconstexpr

A suitable (magic) scale factor for Mac systems.

Definition at line 153 of file zoom_controller.h.

◆ m_scale

double KIGFX::CONSTANT_ZOOM_CONTROLLER::m_scale
private

< The scale factor set by the constructor.

Definition at line 166 of file zoom_controller.h.

Referenced by GetScaleForRotation().

◆ MAC_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::MAC_SCALE = 0.01
staticconstexpr

Definition at line 156 of file zoom_controller.h.

◆ MANUAL_SCALE_FACTOR

constexpr double KIGFX::CONSTANT_ZOOM_CONTROLLER::MANUAL_SCALE_FACTOR = 0.001
staticconstexpr

Definition at line 162 of file zoom_controller.h.

Referenced by KIGFX::WX_VIEW_CONTROLS::LoadSettings().

◆ MSW_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::MSW_SCALE = 0.005
staticconstexpr

A suitable (magic) scale factor for Windows systems.

Multiplier for manual scale ssetting.

Definition at line 159 of file zoom_controller.h.


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