File indexing completed on 2024-12-22 04:13:05

0001 /*
0002  *  SPDX-FileCopyrightText: 2019 Agata Cacko <cacko.azh@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "KisSpinBoxSplineUnitConverter.h"
0008 #include <QtMath>
0009 #include <kis_debug.h>
0010 
0011 
0012 
0013 double KisSpinBoxSplineUnitConverter::io2sp(int x, int min, int max)
0014 {
0015     int reversedRange = max - min > 0 ? 1 : -1; // tilt elevation has range (90; 0)
0016     int rangeLen = qAbs(max - min);
0017 
0018     double response = reversedRange * double(x - min) / rangeLen;
0019     return response;
0020 }
0021 
0022 int KisSpinBoxSplineUnitConverter::sp2io(double x, int min, int max)
0023 {
0024     int rangeLen = max - min; // tilt elevation has range (90; 0)
0025     int response = qRound(x*rangeLen) + min;
0026 
0027     return response;
0028 }
0029 
0030 
0031 
0032