KChart

KChartStockDiagram.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KCHART_STOCK_DIAGRAM_H
10#define KCHART_STOCK_DIAGRAM_H
11
12#include "KChartAbstractCartesianDiagram.h"
13#include "KChartCartesianCoordinatePlane.h"
14#include "KChartStockBarAttributes.h"
15#include "KChartThreeDBarAttributes.h"
16
17namespace KChart {
18 class PaintContext;
19
20class KCHART_EXPORT StockDiagram : public AbstractCartesianDiagram
21{
22 Q_OBJECT
23
24 Q_DISABLE_COPY( StockDiagram )
25
26 KCHART_DECLARE_DERIVED_DIAGRAM( StockDiagram, CartesianCoordinatePlane )
27
28public:
29 enum Type {
30 HighLowClose,
31 OpenHighLowClose,
32 Candlestick
33 };
34
35 explicit StockDiagram( QWidget *parent = nullptr, CartesianCoordinatePlane *plane = nullptr );
36 ~StockDiagram() override;
37
38
39 /**
40 * Switches between the supported types of stock charts,
41 * depending on \a type
42 */
43 void setType( Type type );
44
45 /**
46 * @return the type of this diagram
47 */
48 Type type() const;
49
50 void setStockBarAttributes( const StockBarAttributes &attr );
51 StockBarAttributes stockBarAttributes() const;
52
53 void setStockBarAttributes( int column, const StockBarAttributes &attr );
54 StockBarAttributes stockBarAttributes( int column ) const;
55
56
57 /**
58 * Sets the 3D attributes for all bars (i.e. candlesticks)
59 *
60 * @param attr The 3D attributes to set
61 */
62
63 /**
64 * Sets the 3D attributes for the bar (i.e. candlestick) in certain column
65 * of the diagram
66 *
67 * Note: Every column in a StockDiagram is represented by a row in the model
68 *
69 * @param column The column to set the 3D bar attributes for
70 * @param attr The 3D attributes to set
71 */
72 void setThreeDBarAttributes( const ThreeDBarAttributes &attr );
73
74 /**
75 * Returns the 3D attributes for all bars (i.e. candlesticks)
76 *
77 * @return the 3D bar attributes
78 */
79 ThreeDBarAttributes threeDBarAttributes() const;
80
81 /**
82 * Returns the 3D attributes for a bars (i.e. candlestick) in a certain column
83 * of the diagram
84 *
85 * Note: Every column in a StockDiagram is represented by a row in the model
86 *
87 * @param column The column to get the 3D bar attributes for
88 * @return The 3D attributes for the specified column
89 */
90 ThreeDBarAttributes threeDBarAttributes( int column ) const;
91
92 void setThreeDBarAttributes( int column, const ThreeDBarAttributes &attr );
93
94 void setLowHighLinePen( const QPen &pen );
95 QPen lowHighLinePen() const;
96
97 void setLowHighLinePen( int column, const QPen &pen );
98 QPen lowHighLinePen( int column ) const;
99
100 void setUpTrendCandlestickBrush( const QBrush &brush );
101 QBrush upTrendCandlestickBrush() const;
102
103 void setDownTrendCandlestickBrush( const QBrush &brush );
104 QBrush downTrendCandlestickBrush() const;
105
106 void setUpTrendCandlestickBrush( int column, const QBrush &brush );
107 QBrush upTrendCandlestickBrush( int column ) const;
108
109 void setDownTrendCandlestickBrush( int column, const QBrush &brush );
110 QBrush downTrendCandlestickBrush( int column ) const;
111
112 void setUpTrendCandlestickPen( const QPen &pen );
113 QPen upTrendCandlestickPen() const;
114
115 void setDownTrendCandlestickPen( const QPen &pen );
116 QPen downTrendCandlestickPen() const;
117
118 void setUpTrendCandlestickPen( int column, const QPen &pen );
119 QPen upTrendCandlestickPen( int column ) const;
120
121 void setDownTrendCandlestickPen( int column, const QPen &pen );
122 QPen downTrendCandlestickPen( int column ) const;
123
124#if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
125 virtual const int numberOfAbscissaSegments() const;
126 virtual const int numberOfOrdinateSegments() const;
127#else
128 int numberOfAbscissaSegments() const override;
129 int numberOfOrdinateSegments() const override;
130#endif
131
132 void paint( PaintContext *paintContext ) override;
133
134 void resize( const QSizeF &size ) override;
135
136 qreal threeDItemDepth( int column ) const override;
137 qreal threeDItemDepth( const QModelIndex &index ) const override;
138
139protected:
140 const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
141};
142
143} // namespace KChart
144
145#endif // KCHART_STOCK_DIAGRAM_H
146
Type type(const QSqlDatabase &db)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.