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 138 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

A suitable (magic) scale factor for GTK3 systems.

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, 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
static

A suitable (magic) scale factor for Mac systems.

Definition at line 150 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 163 of file zoom_controller.h.

Referenced by GetScaleForRotation().

◆ MAC_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::MAC_SCALE = 0.01
static

Definition at line 153 of file zoom_controller.h.

Referenced by GetZoomControllerForPlatform().

◆ MANUAL_SCALE_FACTOR

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

Definition at line 159 of file zoom_controller.h.

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

◆ MSW_SCALE

constexpr double CONSTANT_ZOOM_CONTROLLER::MSW_SCALE = 0.005
static

A suitable (magic) scale factor for Windows systems.

Multiplier for manual scale ssetting.

Definition at line 156 of file zoom_controller.h.

Referenced by GetZoomControllerForPlatform().


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