QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
CrosshairRenderer.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_CROSSHAIRRENDERER_H
24#define QTRADINGVIEW_CROSSHAIRRENDERER_H
25
26#include <QColor>
27#include <QPointF>
28#include <QFont>
29#include "QTradingView/qtradingview_global.h"
30
31class QPainter;
32class QRectF;
33
34namespace QTradingView {
35
36class ViewPort;
37class Pane;
38class Series;
39
48class QTRADINGVIEW_EXPORT CrosshairRenderer
49{
50public:
55
60 void setCrosshairColor(const QColor& color);
65 void setLabelBackgroundColor(const QColor& color);
70 void setLabelTextColor(const QColor& color);
75 void setFont(const QFont& font);
76
86 void render(QPainter* painter, const QPointF& position, const ViewPort& viewport,
87 const Pane* pane, const Series* series, double xAxisY = -1.0);
88
89private:
90 QColor m_crosshairColor;
91 QColor m_labelBackgroundColor;
92 QColor m_labelTextColor;
93 QFont m_font;
94
95 void drawPriceLabel(QPainter* painter, double y, double price, const QRectF& chartArea, bool onRight);
96 void drawTimeLabel(QPainter* painter, double x, const QString& timeStr, const QRectF& chartArea, double bottomY);
97 void drawCrosshairMarker(QPainter* painter, const QPointF& position);
98};
99
100} // namespace QTradingView
101
102#endif // QTRADINGVIEW_CROSSHAIRRENDERER_H
Renders crosshair lines and labels on the chart.
Definition CrosshairRenderer.h:49
Represents a chart pane that contains one or more data series.
Definition Pane.h:44
Abstract base class for data series in QTradingView charts.
Definition Series.h:49
Manages the visible range and pixel mapping for chart bars.
Definition ViewPort.h:39