73class QTRADINGVIEW_EXPORT
Chart :
public QWidget
82 explicit Chart(QWidget *parent =
nullptr);
94 std::shared_ptr<Pane> addPane(
double heightRatio = 1.0);
100 void removePane(
Pane* pane);
112 std::vector<Pane*> panes()
const;
135 void calculateLayout();
141 void pan(
int indexDelta);
148 void zoom(
int indexDelta,
int anchorIndex);
159 void showLastNPoints(
int n);
170 void setCrosshairVisible(
bool visible);
176 bool isCrosshairVisible()
const;
182 void setCrosshairPosition(
const QPointF& position);
188 QPointF crosshairPosition()
const;
209 void paintEvent(QPaintEvent* event)
override;
210 void resizeEvent(QResizeEvent* event)
override;
211 void wheelEvent(QWheelEvent* event)
override;
212 void mousePressEvent(QMouseEvent* event)
override;
213 void mouseMoveEvent(QMouseEvent* event)
override;
214 void mouseReleaseEvent(QMouseEvent* event)
override;
215 void mouseDoubleClickEvent(QMouseEvent* event)
override;
216 void leaveEvent(QEvent* event)
override;
217 bool event(QEvent* event)
override;
218 void keyPressEvent(QKeyEvent *event)
override;
222 void handlePinchGesture(QPinchGesture* gesture);
223 void handlePanGesture(QPanGesture* gesture);
226 void render(QPainter* painter);
229 QRectF leftAxisRect()
const;
230 QRectF rightAxisRect()
const;
231 QRectF xAxisRect()
const;
234 Pane* paneAtPosition(
const QPointF& position)
const;
235 int paneBorderAtPosition(
const QPointF& position,
double threshold = 5.0)
const;
238 std::vector<std::shared_ptr<Pane>> m_panes;
244 QPoint m_lastMousePos;
245 int m_lastMouseIndex;
246 double m_initialVisibleCount;
247 double m_wheelDeltaAccumulator = 0;
249 static constexpr int WHEEL_THRESHOLD = 72;
251 static constexpr int WHEEL_THRESHOLD = 120;
254 enum class DragMode { None, ChartPan, YAxisZoom, XAxisZoom, PaneResize };
257 double m_dragStartValue;
258 int m_resizingBorderIndex;
259 double m_minPaneHeight;
267 int m_rightAxisWidth;
271 bool m_crosshairVisible;
272 QPointF m_crosshairPosition;
275 QTimer m_updateTimer;
276 bool m_pendingUpdate =
false;
277 static constexpr int UPDATE_INTERVAL_MS = 16;
278 void setupUpdateTimer();
279 void onUpdateTimerTick();
280 void scheduleUpdate();