File indexing completed on 2024-12-15 04:02:33
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCHART_STOCK_DIAGRAM_P_H 0010 #define KCHART_STOCK_DIAGRAM_P_H 0011 0012 #include "KChartStockDiagram.h" 0013 #include "KChartAbstractCartesianDiagram_p.h" 0014 #include "KChartCartesianDiagramDataCompressor_p.h" 0015 #include "KChartPaintContext.h" 0016 0017 namespace KChart { 0018 0019 class Q_DECL_HIDDEN StockDiagram::Private : public AbstractCartesianDiagram::Private 0020 { 0021 friend class StockDiagram; 0022 0023 public: 0024 Private(); 0025 Private( const Private& r ); 0026 ~Private() override; 0027 0028 Type type; 0029 StockDiagram* stockDiagram() { return static_cast< StockDiagram* >( diagram ); } 0030 0031 QBrush upTrendCandlestickBrush; 0032 QBrush downTrendCandlestickBrush; 0033 QPen upTrendCandlestickPen; 0034 QPen downTrendCandlestickPen; 0035 0036 QMap<int, QBrush> upTrendCandlestickBrushes; 0037 QMap<int, QBrush> downTrendCandlestickBrushes; 0038 QMap<int, QPen> upTrendCandlestickPens; 0039 QMap<int, QPen> downTrendCandlestickPens; 0040 0041 QPen lowHighLinePen; 0042 QMap<int, QPen> lowHighLinePens; 0043 0044 0045 void drawOHLCBar( int dataset, const CartesianDiagramDataCompressor::DataPoint &open, 0046 const CartesianDiagramDataCompressor::DataPoint &high, 0047 const CartesianDiagramDataCompressor::DataPoint &low, 0048 const CartesianDiagramDataCompressor::DataPoint &close, 0049 PaintContext *context ); 0050 void drawHLCBar( int dataset, const CartesianDiagramDataCompressor::DataPoint &high, 0051 const CartesianDiagramDataCompressor::DataPoint &low, 0052 const CartesianDiagramDataCompressor::DataPoint &close, 0053 PaintContext *context ); 0054 void drawCandlestick( int dataset, const CartesianDiagramDataCompressor::DataPoint &open, 0055 const CartesianDiagramDataCompressor::DataPoint &high, 0056 const CartesianDiagramDataCompressor::DataPoint &low, 0057 const CartesianDiagramDataCompressor::DataPoint &close, 0058 PaintContext *context ); 0059 0060 private: 0061 void drawLine( int dataset, int col, const QPointF &point1, const QPointF &p2, PaintContext *context ); 0062 QPointF projectPoint( PaintContext *context, const QPointF &point ) const; 0063 QRectF projectCandlestick( PaintContext *context, const QPointF &open, const QPointF &close, qreal width ) const; 0064 int openValueColumn() const; 0065 int highValueColumn() const; 0066 int lowValueColumn() const; 0067 int closeValueColumn() const; 0068 0069 class ThreeDPainter; 0070 }; 0071 0072 KCHART_IMPL_DERIVED_DIAGRAM( StockDiagram, AbstractCartesianDiagram, CartesianCoordinatePlane ) 0073 0074 } 0075 0076 #endif // KCHART_STOCK_DIAGRAM_P_H 0077