QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
LinearScale.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_LINEARSCALE_H
24#define QTRADINGVIEW_LINEARSCALE_H
25
26#include <vector>
27#include "QTradingView/scale/IScale.h"
28#include "QTradingView/qtradingview_global.h"
29
30namespace QTradingView {
31
38class QTRADINGVIEW_EXPORT LinearScale : public IScale
39{
40public:
52 LinearScale(double minValue, double maxValue, double minPixel, double maxPixel);
56 ~LinearScale() override = default;
57
63 double dataToPixel(double value) const override;
69 double pixelToData(double pixel) const override;
75 void setDomain(double minValue, double maxValue) override;
81 void setRange(double minPixel, double maxPixel) override;
87 std::vector<double> getTicks(int approxCount) const override;
94 void applyPadding(double &minValue, double &maxValue, double paddingRatio) const override;
102 void zoomDomain(double &minValue, double &maxValue, double zoomFactor, double anchorValue) const override;
103
104private:
105 double m_minValue;
106 double m_maxValue;
107 double m_minPixel;
108 double m_maxPixel;
109};
110
111} // namespace QTradingView
112
113#endif // QTRADINGVIEW_LINEARSCALE_H
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
Linear scale implementation for chart axes.
Definition LinearScale.h:39
~LinearScale() override=default
Destructor.