##// END OF EJS Templates
Fix color setting...
Fix color setting For some elements the brush and pen colors were set so that the default brush and pen style was used. This resulted wrong pattern for the colors. Change-Id: Ie67d954f1e6e91201a034921433e0bccf6745159 Task-number: QTRD-3736 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>

File last commit:

r2845:ae12522d475c
r2852:5f71da41b84f
Show More
chartlogvalueaxisx.cpp
150 lines | 5.2 KiB | text/x-c | CppLexer
/ src / charts / axis / logvalueaxis / chartlogvalueaxisx.cpp
Titta Heikkala
Updated license headers...
r2845 /******************************************************************************
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 **
Titta Heikkala
Updated license headers...
r2845 ** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 **
Titta Heikkala
Updated license headers...
r2740 ** This file is part of the Qt Charts module.
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 **
Titta Heikkala
Updated license headers...
r2845 ** $QT_BEGIN_LICENSE:COMM$
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 **
Titta Heikkala
Updated license headers...
r2845 ** 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 The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 **
Titta Heikkala
Updated license headers...
r2845 ** $QT_END_LICENSE$
**
******************************************************************************/
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
Titta Heikkala
Fix include syntax...
r2714 #include <private/chartlogvalueaxisx_p.h>
#include <private/chartpresenter_p.h>
#include <QtCharts/QLogValueAxis>
#include <private/abstractchartlayout_p.h>
#include <QtWidgets/QGraphicsLayout>
#include <QtCore/QtMath>
#include <QtCore/QDebug>
Titta Heikkala
Fix QNX build issue...
r2775 #include <cmath>
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_BEGIN_NAMESPACE
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
Miikka Heikkinen
Add Polar chart support...
r2483 ChartLogValueAxisX::ChartLogValueAxisX(QLogValueAxis *axis, QGraphicsItem *item)
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 : HorizontalAxis(axis, item),
m_axis(axis)
{
Miikka Heikkinen
Add Polar chart support...
r2483 QObject::connect(m_axis, SIGNAL(baseChanged(qreal)), this, SLOT(handleBaseChanged(qreal)));
QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString)));
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 }
ChartLogValueAxisX::~ChartLogValueAxisX()
{
}
QVector<qreal> ChartLogValueAxisX::calculateLayout() const
{
QVector<qreal> points;
Titta Heikkala
Fix QNX build issue...
r2775 qreal logMax = std::log10(m_axis->max()) / std::log10(m_axis->base());
qreal logMin = std::log10(m_axis->min()) / std::log10(m_axis->base());
Marek Rosa
Domains added
r2275 qreal leftEdge = logMin < logMax ? logMin : logMax;
Titta Heikkala
Fix QNX build issue...
r2775 qreal ceilEdge = qCeil(leftEdge);
int tickCount = qAbs(qCeil(logMax) - qCeil(logMin));
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
Miikka Heikkinen
Draw the tick and label on logaxis when tick is exactly at high edge...
r2837 // If the high edge sits exactly on the tick value, add a tick
qreal highValue = logMin < logMax ? logMax : logMin;
if (qFuzzyCompare(highValue, qreal(qCeil(highValue))))
tickCount++;
Titta Heikkala
Fix QLogValueAxis update...
r2759 points.resize(tickCount);
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 const QRectF &gridRect = gridGeometry();
const qreal deltaX = gridRect.width() / qAbs(logMax - logMin);
Titta Heikkala
Fix QLogValueAxis update...
r2759 for (int i = 0; i < tickCount; ++i)
Miikka Heikkinen
Add Polar chart support...
r2483 points[i] = (ceilEdge + qreal(i)) * deltaX - leftEdge * deltaX + gridRect.left();
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
return points;
}
void ChartLogValueAxisX::updateGeometry()
{
Miikka Heikkinen
Add Polar chart support...
r2483 const QVector<qreal>& layout = ChartAxisElement::layout();
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat()));
HorizontalAxis::updateGeometry();
}
Marek Rosa
Fixed: chart not redrawing when logaxis's logBase value changed
r2322 void ChartLogValueAxisX::handleBaseChanged(qreal base)
{
Q_UNUSED(base);
Michal Klocek
Fixes missing layout updated on ticks,base and format calls
r2333 QGraphicsLayoutItem::updateGeometry();
Marek Rosa
Fixed: chart not redrawing when logaxis's logBase value changed
r2322 if(presenter()) presenter()->layout()->invalidate();
}
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
Marek Rosa
Fixed: axis not redrawing when labelFormat changed
r2323 void ChartLogValueAxisX::handleLabelFormatChanged(const QString &format)
{
Q_UNUSED(format);
Michal Klocek
Fixes missing layout updated on ticks,base and format calls
r2333 QGraphicsLayoutItem::updateGeometry();
Marek Rosa
Fixed: axis not redrawing when labelFormat changed
r2323 if(presenter()) presenter()->layout()->invalidate();
}
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_UNUSED(constraint)
QSizeF sh;
QSizeF base = HorizontalAxis::sizeHint(which, constraint);
QStringList ticksList;
Titta Heikkala
Fix QNX build issue...
r2775 qreal logMax = std::log10(m_axis->max()) / std::log10(m_axis->base());
qreal logMin = std::log10(m_axis->min()) / std::log10(m_axis->base());
int tickCount = qAbs(qCeil(logMax) - qCeil(logMin));
Miikka Heikkinen
Draw the tick and label on logaxis when tick is exactly at high edge...
r2837
// If the high edge sits exactly on the tick value, add a tick
qreal highValue = logMin < logMax ? logMax : logMin;
if (qFuzzyCompare(highValue, qreal(qCeil(highValue))))
tickCount++;
Miikka Heikkinen
Fix sizeHint for logvalue axes that have only single tick...
r2460 if (m_axis->max() > m_axis->min() && tickCount > 0)
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat());
else
Titta Heikkala
Qt Charts project file structure change...
r2712 ticksList.append(QStringLiteral(" "));
Miikka Heikkinen
Fix vanishing labels for first and last ticks....
r2443 // Width of horizontal axis sizeHint indicates the maximum distance labels can extend past
// first and last ticks. Base width is irrelevant.
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 qreal width = 0;
qreal height = 0;
switch (which) {
case Qt::MinimumSize:{
Titta Heikkala
Qt Charts project file structure change...
r2712 QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(),
QStringLiteral("..."),
axis()->labelsAngle());
Miikka Heikkinen
Fix vanishing labels for first and last ticks....
r2443 width = boundingRect.width() / 2.0;
Miikka Heikkinen
Fix multiline axis label positioning....
r2534 height = boundingRect.height() + labelPadding() + base.height() + 1.0;
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 sh = QSizeF(width, height);
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 break;
}
case Qt::PreferredSize: {
Miikka Heikkinen
Fix multiline axis label positioning....
r2534 qreal labelHeight = 0.0;
qreal firstWidth = -1.0;
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 foreach (const QString& s, ticksList) {
Miikka Heikkinen
Added HTML support for various text items...
r2539 QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle());
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 labelHeight = qMax(rect.height(), labelHeight);
Miikka Heikkinen
Fix vanishing labels for first and last ticks....
r2443 width = rect.width();
Miikka Heikkinen
Fix multiline axis label positioning....
r2534 if (firstWidth < 0.0)
Miikka Heikkinen
Fix vanishing labels for first and last ticks....
r2443 firstWidth = width;
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 }
Miikka Heikkinen
Fix multiline axis label positioning....
r2534 height = labelHeight + labelPadding() + base.height() + 1.0;
width = qMax(width, firstWidth) / 2.0;
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 sh = QSizeF(width, height);
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 break;
}
default:
break;
}
return sh;
}
Marek Rosa
Fixed: chart not redrawing when logaxis's logBase value changed
r2322 #include "moc_chartlogvalueaxisx_p.cpp"
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_END_NAMESPACE