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
 Gets the scale factor produced by a given mousewheel rotation. More...
 

Static Public Attributes

static constexpr double GTK3_SCALE = 0.002
 A suitable (magic) scale factor for GTK3 systems. More...
 
static constexpr double MAC_SCALE = 0.01
 A suitable (magic) scale factor for Mac systems. More...
 

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 129 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 110 of file zoom_controller.cpp.

110  : m_scale( aScale )
111 {
112 }
double m_scale
The scale factor set by the constructor.

Member Function Documentation

◆ GetScaleForRotation()

double CONSTANT_ZOOM_CONTROLLER::GetScaleForRotation ( int  aRotation)
overridevirtual

Gets the scale factor produced by a given mousewheel rotation.

Parameters
aRotationrotation of the mouse wheel (this comes from wxMouseEvent::GetWheelRotation())
Returns
the scale factor to scroll by

Implements KIGFX::ZOOM_CONTROLLER.

Definition at line 115 of file zoom_controller.cpp.

116 {
117  wxLogTrace( traceZoomScroll, wxString::Format( "Rot %d", aRotation ) );
118 
119  aRotation = ( aRotation > 0 ) ? std::min( aRotation, 100 ) : std::max( aRotation, -100 );
120 
121  double dscale = aRotation * m_scale;
122 
123  double zoom_scale = ( aRotation > 0 ) ? ( 1 + dscale ) : 1 / ( 1 - dscale );
124 
125  wxLogTrace( traceZoomScroll, wxString::Format( " Zoom factor: %f", zoom_scale ) );
126 
127  return zoom_scale;
128 }
const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
double m_scale
The scale factor set by the constructor.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define max(a, b)
Definition: auxiliary.h:86
#define min(a, b)
Definition: auxiliary.h:85

References Format(), m_scale, max, min, and traceZoomScroll.

Member Data Documentation

◆ GTK3_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::GTK3_SCALE = 0.002
static

A suitable (magic) scale factor for GTK3 systems.

Definition at line 141 of file zoom_controller.h.

Referenced by GetZoomControllerForPlatform().

◆ m_scale

double KIGFX::CONSTANT_ZOOM_CONTROLLER::m_scale
private

The scale factor set by the constructor.

Definition at line 148 of file zoom_controller.h.

Referenced by GetScaleForRotation().

◆ MAC_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::MAC_SCALE = 0.01
static

A suitable (magic) scale factor for Mac systems.

Definition at line 144 of file zoom_controller.h.

Referenced by GetZoomControllerForPlatform().


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