1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#include "qbardataitem_p.h"
31
32QT_BEGIN_NAMESPACE_DATAVISUALIZATION
33
34/*!
35 * \class QBarDataItem
36 * \inmodule QtDataVisualization
37 * \brief The QBarDataItem class provides a container for resolved data to be added to bar graphs.
38 * \since QtDataVisualization 1.0
39 *
40 * A bar data item holds the data for a single rendered bar in a graph.
41 * Bar data proxies parse data into QBarDataItem instances for visualization.
42 *
43 * \sa QBarDataProxy, {Qt Data Visualization C++ Classes}
44 */
45
46/*!
47 * Constructs a bar data item.
48 */
49QBarDataItem::QBarDataItem()
50 : d_ptr(0), // private data doesn't exist by default (optimization)
51 m_value(0.0f),
52 m_angle(0.0f)
53{
54}
55
56/*!
57 * Constructs a bar data item with the value \a value.
58 */
59QBarDataItem::QBarDataItem(float value)
60 : d_ptr(0),
61 m_value(value),
62 m_angle(0.0f)
63{
64}
65
66/*!
67 * Constructs a bar data item with the value \a value and angle \a angle.
68 */
69QBarDataItem::QBarDataItem(float value, float angle)
70 : d_ptr(0),
71 m_value(value),
72 m_angle(angle)
73{
74}
75
76/*!
77 * Constructs a copy of \a other.
78 */
79QBarDataItem::QBarDataItem(const QBarDataItem &other)
80{
81 operator=(other);
82}
83
84/*!
85 * Deletes a bar data item.
86 */
87QBarDataItem::~QBarDataItem()
88{
89 delete d_ptr;
90}
91
92/*!
93 * Assigns a copy of \a other to this object.
94 */
95QBarDataItem &QBarDataItem::operator=(const QBarDataItem &other)
96{
97 m_value = other.m_value;
98 m_angle = other.m_angle;
99 if (other.d_ptr)
100 createExtraData();
101 else
102 d_ptr = 0;
103 return *this;
104}
105
106/*!
107 * \fn void QBarDataItem::setValue(float val)
108 * Sets the value \a val to this data item.
109 */
110
111/*!
112 * \fn float QBarDataItem::value() const
113 * Returns the value of this data item.
114 */
115
116/*!
117 * \fn void QBarDataItem::setRotation(float angle)
118 * Sets the rotation angle \a angle in degrees for this data item.
119 */
120
121/*!
122 * \fn float QBarDataItem::rotation() const
123 * Returns the rotation angle in degrees for this data item.
124 */
125
126/*!
127 * \internal
128 */
129void QBarDataItem::createExtraData()
130{
131 if (!d_ptr)
132 d_ptr = new QBarDataItemPrivate;
133}
134
135QBarDataItemPrivate::QBarDataItemPrivate()
136{
137}
138
139QBarDataItemPrivate::~QBarDataItemPrivate()
140{
141}
142
143QT_END_NAMESPACE_DATAVISUALIZATION
144

source code of qtdatavis3d/src/datavisualization/data/qbardataitem.cpp