1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the QtDataVisualization API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | |
14 | #ifndef BARRENDERITEM_P_H |
15 | #define BARRENDERITEM_P_H |
16 | |
17 | #include "abstractrenderitem_p.h" |
18 | |
19 | QT_BEGIN_NAMESPACE |
20 | |
21 | class BarRenderItem : public AbstractRenderItem |
22 | { |
23 | public: |
24 | BarRenderItem(); |
25 | BarRenderItem(const BarRenderItem &other); |
26 | BarRenderItem &operator=(const BarRenderItem &) = default; |
27 | virtual ~BarRenderItem(); |
28 | |
29 | // Position relative to data window (for bar label generation) |
30 | inline void setPosition(const QPoint &pos) { m_position = pos; } |
31 | inline const QPoint &position() const { return m_position; } |
32 | |
33 | // Actual cached data value of the bar (needed to trigger label reformats) |
34 | inline void setValue(float value) { m_value = value; } |
35 | inline float value() const { return m_value; } |
36 | |
37 | // Normalized bar height |
38 | inline void setHeight(GLfloat height) { m_height = height; } |
39 | inline GLfloat height() const { return m_height; } |
40 | |
41 | protected: |
42 | float m_value; |
43 | QPoint m_position; // x = row, y = column |
44 | GLfloat m_height; |
45 | |
46 | friend class QBarDataItem; |
47 | }; |
48 | |
49 | class BarRenderSliceItem : public BarRenderItem |
50 | { |
51 | public: |
52 | BarRenderSliceItem(); |
53 | BarRenderSliceItem(const BarRenderSliceItem &other); |
54 | BarRenderSliceItem &operator=(const BarRenderSliceItem &other) = default; |
55 | virtual ~BarRenderSliceItem(); |
56 | |
57 | void setItem(const BarRenderItem &renderItem); |
58 | |
59 | // Label item for formatted label |
60 | LabelItem &sliceLabelItem(); |
61 | |
62 | // Formatted label for item. |
63 | void setSliceLabel(const QString &label); |
64 | const QString &sliceLabel() const; // Formats label if not previously formatted |
65 | |
66 | protected: |
67 | QString m_sliceLabel; |
68 | LabelItem *m_sliceLabelItem; |
69 | bool m_isNull; |
70 | }; |
71 | |
72 | typedef QList<BarRenderItem> BarRenderItemRow; |
73 | typedef QList<BarRenderItemRow> BarRenderItemArray; |
74 | |
75 | QT_END_NAMESPACE |
76 | |
77 | #endif |
78 | |