QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
LogScale.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_LOGSCALE_H
24#define QTRADINGVIEW_LOGSCALE_H
25
26#include <vector>
27#include "QTradingView/scale/IScale.h"
28#include "QTradingView/qtradingview_global.h"
29
30namespace QTradingView {
31
37class QTRADINGVIEW_EXPORT LogScale : public IScale
38{
39public:
43 LogScale();
51 LogScale(double minValue, double maxValue, double minPixel, double maxPixel);
55 ~LogScale() override = default;
56
62 double dataToPixel(double value) const override;
68 double pixelToData(double pixel) const override;
74 void setDomain(double minValue, double maxValue) override;
80 void setRange(double minPixel, double maxPixel) override;
86 std::vector<double> getTicks(int approxCount) const override;
93 void applyPadding(double &minValue, double &maxValue, double paddingRatio) const override;
101 void zoomDomain(double &minValue, double &maxValue, double zoomFactor, double anchorValue) const override;
106 void setLinearThreshold(double threshold);
111 double getLinearThreshold() const;
112
113private:
114 double m_minValue;
115 double m_maxValue;
116 double m_minPixel;
117 double m_maxPixel;
118 double m_linearThreshold; // Threshold for linear region around zero
119
120 double symlog(double value) const;
121 double invsymlog(double logValue) const;
122};
123
124} // namespace QTradingView
125
126#endif // QTRADINGVIEW_LOGSCALE_H
127
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
Logarithmic scale implementation for chart axes.
Definition LogScale.h:38
~LogScale() override=default
Destructor.