diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-08 12:46:49 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-05-08 13:30:48 +0300 |
commit | ee7f5d387934c46442ece1ea17566305ada94cef (patch) | |
tree | 90dd4d95ae2f83f66e2ee42608122a393f5be46c /src/engine/qdataitem.cpp | |
parent | 161232582e7f7e7e6e991def2fe87d78e668d08f (diff) |
Directory structure reorganized
Unnecessary subdirectory levels deleted from examples and src
Change-Id: I88892b4fc92784e706be2264eeb7d6208250a50f
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/engine/qdataitem.cpp')
-rw-r--r-- | src/engine/qdataitem.cpp | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/src/engine/qdataitem.cpp b/src/engine/qdataitem.cpp new file mode 100644 index 00000000..14d6c85f --- /dev/null +++ b/src/engine/qdataitem.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtDataVis3D module. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdataitem.h" +#include "qdataitem_p.h" + +#include <QPoint> +#include <QString> + +QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE + +QDataItem::QDataItem(float value, const QString &label) + : d_ptr(new QDataItemPrivate(this, value, label)) +{ + //qDebug("QDataItem"); +} + +QDataItem::~QDataItem() +{ + //qDebug("~QDataItem"); +} + +void QDataItem::setLabel(const QString &label, bool prepend) +{ + d_ptr->m_labelString = label; + d_ptr->m_prependLabel = prepend; +} + +void QDataItem::setValue(float value) +{ + d_ptr->m_value = value; +} + +void QDataItem::setValue(int value) +{ + d_ptr->m_value = (float)value; +} + +void QDataItem::setPosition(const QPointF &position) +{ + d_ptr->m_position = position; +} + +void QDataItem::setPosition(const QPoint &position) +{ + d_ptr->m_position = (QPointF)position; +} + +QDataItemPrivate::QDataItemPrivate(QDataItem *q, float value, const QString &label) + : q_ptr(q), + m_value(value), + m_labelString(label), + m_prependLabel(false), + m_translation(QVector3D(0, 0, 0)), + m_label(LabelItem()), + m_selectionLabel(LabelItem()) +{ +} + +QDataItemPrivate::~QDataItemPrivate() +{ +} + +void QDataItemPrivate::setTranslation(const QVector3D &translation) +{ + m_translation = translation; +} + +QVector3D QDataItemPrivate::translation() +{ + return m_translation; +} + +float QDataItemPrivate::value() +{ + return m_value; +} + +QString QDataItemPrivate::valueStr() +{ + QString strVal; + QString numStr; + numStr.setNum(m_value); + if (m_prependLabel) { + strVal.append(m_labelString); + strVal.append(QStringLiteral(" ")); + strVal.append(numStr); + } else { + strVal.append(numStr); + strVal.append(m_labelString); + } + return strVal; +} + +void QDataItemPrivate::setLabel(const LabelItem &label) +{ + m_label = label; +} + +LabelItem QDataItemPrivate::label() +{ + return m_label; +} + +void QDataItemPrivate::setSelectionLabel(const LabelItem &label) +{ + m_selectionLabel = label; +} + +LabelItem QDataItemPrivate::selectionLabel() +{ + return m_selectionLabel; +} + +QPointF QDataItemPrivate::position() +{ + return m_position; +} + +QTCOMMERCIALDATAVIS3D_END_NAMESPACE |