qintervalaxis.cpp
149 lines
| 3.4 KiB
| text/x-c
|
CppLexer
|
r1540 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
|
r1615 | #include "qintervalaxis.h" | ||
#include "qintervalaxis_p.h" | ||||
|
r1561 | #include "chartcategoriesaxisx_p.h" | ||
#include "chartcategoriesaxisy_p.h" | ||||
|
r1572 | #include <qmath.h> | ||
|
r1611 | #include <QDebug> | ||
|
r1540 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r1614 | QIntervalAxis::QIntervalAxis(QObject *parent): | ||
QValuesAxis(*new QIntervalAxisPrivate(this),parent) | ||||
|
r1540 | { | ||
} | ||||
|
r1614 | QIntervalAxis::~QIntervalAxis() | ||
|
r1540 | { | ||
} | ||||
|
r1614 | QIntervalAxis::QIntervalAxis(QIntervalAxisPrivate &d,QObject *parent):QValuesAxis(d,parent) | ||
|
r1540 | { | ||
} | ||||
/*! | ||||
Appends \a categories to axis | ||||
*/ | ||||
|
r1614 | void QIntervalAxis::append(const QString& category, qreal x) | ||
|
r1613 | { | ||
|
r1614 | Q_D(QIntervalAxis); | ||
|
r1613 | if (!d->m_categories.contains(category)) | ||
{ | ||||
if(d->m_categories.isEmpty()){ | ||||
Range range(d->m_categoryMinimum,x); | ||||
d->m_categoriesMap.insert(category,range); | ||||
d->m_categories.append(category); | ||||
}else{ | ||||
Range range = d->m_categoriesMap.value(d->m_categories.last()); | ||||
d->m_categoriesMap.insert(category,Range(range.first,x)); | ||||
d->m_categories.append(category); | ||||
} | ||||
setRange(d->m_min,x); | ||||
|
r1605 | } | ||
|
r1540 | } | ||
|
r1614 | void QIntervalAxis::setFisrtCategoryMinimum(qreal x) | ||
|
r1540 | { | ||
|
r1614 | Q_D(QIntervalAxis); | ||
|
r1613 | if(d->m_categories.isEmpty()){ | ||
d->m_categoryMinimum=x; | ||||
}else{ | ||||
Range range = d->m_categoriesMap.value(d->m_categories.first()); | ||||
d->m_categoriesMap.insert(d->m_categories.first(),Range(x,range.second)); | ||||
setRange(x,d->m_min); | ||||
} | ||||
|
r1540 | } | ||
/*! | ||||
Removes \a category from axis | ||||
*/ | ||||
|
r1614 | void QIntervalAxis::remove(const QString &category) | ||
|
r1540 | { | ||
|
r1613 | Q_UNUSED(category); | ||
//TODO | ||||
|
r1540 | } | ||
|
r1614 | QStringList QIntervalAxis::categories() | ||
|
r1550 | { | ||
|
r1614 | Q_D(QIntervalAxis); | ||
|
r1550 | return d->m_categories; | ||
} | ||||
|
r1540 | /*! | ||
Returns number of categories. | ||||
*/ | ||||
|
r1614 | int QIntervalAxis::count() const | ||
|
r1540 | { | ||
|
r1614 | Q_D(const QIntervalAxis); | ||
|
r1540 | return d->m_categories.count(); | ||
} | ||||
/*! | ||||
Returns the type of axis. | ||||
*/ | ||||
|
r1614 | QAbstractAxis::AxisType QIntervalAxis::type() const | ||
|
r1540 | { | ||
return AxisTypeCategories; | ||||
} | ||||
|
r1544 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
r1614 | QIntervalAxisPrivate::QIntervalAxisPrivate(QIntervalAxis* q): | ||
|
r1613 | QValuesAxisPrivate(q), | ||
m_categoryMinimum(0) | ||||
|
r1541 | { | ||
|
r1544 | |||
|
r1541 | } | ||
|
r1614 | QIntervalAxisPrivate::~QIntervalAxisPrivate() | ||
|
r1541 | { | ||
|
r1544 | |||
|
r1541 | } | ||
|
r1614 | int QIntervalAxisPrivate::ticksCount() const | ||
|
r1540 | { | ||
|
r1544 | return m_categories.count()+1; | ||
|
r1540 | } | ||
|
r1614 | void QIntervalAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | ||
|
r1566 | { | ||
m_min = min; | ||||
m_max = max; | ||||
m_ticksCount = count; | ||||
} | ||||
|
r1614 | ChartAxis* QIntervalAxisPrivate::createGraphics(ChartPresenter* presenter) | ||
|
r1556 | { | ||
|
r1613 | Q_UNUSED(presenter); | ||
// Q_Q( QCategoriesAxis); | ||||
|
r1556 | if(m_orientation == Qt::Vertical){ | ||
|
r1613 | return 0; | ||
|
r1556 | }else{ | ||
|
r1613 | return 0; | ||
|
r1556 | } | ||
} | ||||
|
r1615 | #include "moc_qintervalaxis.cpp" | ||
#include "moc_qintervalaxis_p.cpp" | ||||
|
r1540 | |||
QTCOMMERCIALCHART_END_NAMESPACE | ||||