QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
IScale.h
1/*
2 * Copyright (c) 2025 Dhruvan Gnanadhandayuthapani
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#ifndef QTRADINGVIEW_ISCALE_H
24#define QTRADINGVIEW_ISCALE_H
25
26#include <vector>
27#include "QTradingView/qtradingview_global.h"
28
29namespace QTradingView {
30
36class QTRADINGVIEW_EXPORT IScale
37{
38public:
42 virtual ~IScale() = default;
43
49 [[nodiscard]] virtual double dataToPixel(double value) const = 0;
50
56 [[nodiscard]] virtual double pixelToData(double pixel) const = 0;
57
63 virtual void setDomain(double minValue, double maxValue) = 0;
64
70 virtual void setRange(double minPixel, double maxPixel) = 0;
71
77 [[nodiscard]] virtual std::vector<double> getTicks(int approxCount) const = 0;
78
83 [[nodiscard]] std::vector<double> getTicks() const {
84 return getTicks(5);
85 }
86
93 virtual void applyPadding(double &minValue, double &maxValue, double paddingRatio) const = 0;
94
102 virtual void zoomDomain(double &minValue, double &maxValue, double zoomFactor, double anchorValue) const = 0;
103};
104
105} // namespace QTradingView
106
107#endif // QTRADINGVIEW_ISCALE_H
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
virtual double pixelToData(double pixel) const =0
Converts a pixel position to its corresponding data value.
virtual void applyPadding(double &minValue, double &maxValue, double paddingRatio) const =0
Applies padding to the scale domain.
virtual std::vector< double > getTicks(int approxCount) const =0
Returns a vector of tick values for the axis.
std::vector< double > getTicks() const
Returns a default vector of tick values (approx. 5).
Definition IScale.h:83
virtual ~IScale()=default
Virtual destructor for IScale.
virtual void setDomain(double minValue, double maxValue)=0
Sets the domain (min and max data values) for the scale.
virtual void zoomDomain(double &minValue, double &maxValue, double zoomFactor, double anchorValue) const =0
Zooms the scale domain around an anchor value.
virtual void setRange(double minPixel, double maxPixel)=0
Sets the pixel range for the scale.
virtual double dataToPixel(double value) const =0
Converts a data value to its corresponding pixel position.