Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSpinBoxSplineUnitConverter Class Reference

#include <KisSpinBoxSplineUnitConverter.h>

Public Member Functions

double io2sp (int x, int min, int max)
 
int sp2io (double x, int min, int max)
 

Detailed Description

KisSpinBoxSplineUnitConverter is a class that converts points from ranges(0, 1) to ranges (min, max). In case of reverted ranges (min > max), smaller values from range (0, 1) correspond to bigger values from range (min, max) and the other way around. Example: 3 from (0, 10) is 0.3 from (0, 1) 3 from (10, 0) is 0.7 from (0, 1)

Definition at line 25 of file KisSpinBoxSplineUnitConverter.h.

Member Function Documentation

◆ io2sp()

double KisSpinBoxSplineUnitConverter::io2sp ( int x,
int min,
int max )

Definition at line 13 of file KisSpinBoxSplineUnitConverter.cpp.

14{
15 int reversedRange = max - min > 0 ? 1 : -1; // tilt elevation has range (90; 0)
16 int rangeLen = qAbs(max - min);
17
18 double response = reversedRange * double(x - min) / rangeLen;
19 return response;
20}
T min(T a, T b, T c)
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()

◆ sp2io()

int KisSpinBoxSplineUnitConverter::sp2io ( double x,
int min,
int max )

Definition at line 22 of file KisSpinBoxSplineUnitConverter.cpp.

23{
24 int rangeLen = max - min; // tilt elevation has range (90; 0)
25 int response = qRound(x*rangeLen) + min;
26
27 return response;
28}

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