QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
Pane.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_PANE_H
24#define QTRADINGVIEW_PANE_H
25
26#include <QRectF>
27#include <vector>
28#include <memory>
29#include "series/Series.h"
30#include "scale/IScale.h"
31#include "QTradingView/ViewPort.h"
32#include "QTradingView/qtradingview_global.h"
33
34namespace QTradingView {
35
36enum class ScaleType;
37
43class QTRADINGVIEW_EXPORT Pane
44{
45public:
49 Pane();
50
55 void addSeries(std::shared_ptr<Series> series);
56
61 void removeSeries(std::shared_ptr<Series> series);
62
66 const std::vector<std::shared_ptr<Series>>& series() const;
67
72 void setScale(ScaleType type);
73
77 IScale* scale() const;
78
83 void setHeightRatio(double ratio);
84
88 double heightRatio() const;
89
94 void setRect(const QRectF &rect);
95
99 QRectF rect() const;
100
106 void calculateRange(int start, int end);
107
111 double minValue() const;
112
116 double maxValue() const;
117
123 void setManualRange(double minValue, double maxValue);
124
130 void zoomYAxis(double zoomFactor, double anchorValue);
131
135 void resetAutoRange();
136
140 bool isAutoRange() const;
141
147 void render(QPainter *painter, const ViewPort &viewport);
148
149private:
150 std::vector<std::shared_ptr<Series>> m_series;
151 std::shared_ptr<IScale> m_scale;
152 double m_heightRatio;
153 QRectF m_rect;
154 double m_minValue;
155 double m_maxValue;
156 bool m_autoRange;
157};
158
159} // namespace QTradingView
160
161#endif // QTRADINGVIEW_PANE_H
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
Represents a chart pane that contains one or more data series.
Definition Pane.h:44
Manages the visible range and pixel mapping for chart bars.
Definition ViewPort.h:39