##// END OF EJS Templates
Fixed a Qt5 build issue in presenterchart test app
Fixed a Qt5 build issue in presenterchart test app

File last commit:

r2345:25ac4815295c
r2368:6a035c04dc6b
Show More
chartaxis.cpp
531 lines | 16.4 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** 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$
**
****************************************************************************/
Michal Klocek
Changes QChartAxis -> QAxis
r1006 #include "chartaxis_p.h"
Michal Klocek
Refactors QAxis to QAbstractAxis...
r1541 #include "qabstractaxis.h"
#include "qabstractaxis_p.h"
Michal Klocek
Adds ZOrder enum to presenter
r262 #include "chartpresenter_p.h"
Michal Klocek
Refactors layout:...
r2105 #include "chartlayout_p.h"
Marek Rosa
Domains added
r2275 #include "abstractdomain_p.h"
Michal Klocek
Refactor QChart API...
r1577 #include <qmath.h>
Marek Rosa
Added QDateTimeAxis
r1717 #include <QDateTime>
Marek Rosa
QValueAxis: added posibility to specify label format
r1854 #include <QValueAxis>
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 #include <QLogValueAxis>
Michal Klocek
Adds checkLayout call, when geometry of axis updated
r1890 #include <QGraphicsLayout>
Michal Klocek
Refactors layout...
r1965 #include <QFontMetrics>
Michal Klocek
Add zoom support...
r67
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactors internals...
r2273 ChartAxis::ChartAxis(QAbstractAxis *axis, QGraphicsItem* item , bool intervalAxis)
: ChartElement(item),
m_axis(axis),
Jani Honkonen
src folder: another massive victory for coding style police
r2131 m_labelsAngle(0),
Michal Klocek
Refactors internals...
r2273 m_grid(new QGraphicsItemGroup(item)),
m_arrow(new QGraphicsItemGroup(item)),
m_shades(new QGraphicsItemGroup(item)),
m_labels(new QGraphicsItemGroup(item)),
m_title(new QGraphicsSimpleTextItem(item)),
Jani Honkonen
src folder: another massive victory for coding style police
r2131 m_animation(0),
m_labelPadding(5),
m_intervalAxis(intervalAxis)
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Refactors internals...
r2273 Q_ASSERT(item);
Marek Rosa
Fixed visibility initialization on axis
r2345 //initial initialization
Michal Klocek
Refactor Visibly methods of axis...
r1729 m_arrow->setHandlesChildEvents(false);
Michal Klocek
Refactors internals...
r2273 m_arrow->setZValue(ChartPresenter::AxisZValue);
Michal Klocek
Add missing zvalue setting in axis
r1745 m_labels->setZValue(ChartPresenter::AxisZValue);
Jani Honkonen
make QGraphicsItemGroup a pointer in axis
r784 m_shades->setZValue(ChartPresenter::ShadesZValue);
m_grid->setZValue(ChartPresenter::GridZValue);
Michal Klocek
Bug fix axis artefacts when title set
r2142 m_title->setZValue(ChartPresenter::GridZValue);
Marek Rosa
Fixed visibility initialization on axis
r2345 handleVisibleChanged(m_axis->isVisible());
Michal Klocek
Refactors internals...
r2273 connectSlots();
Michal Klocek
Refactor domain model...
r439
Michal Klocek
Refactors internals...
r2273 setFlag(QGraphicsItem::ItemHasNoContents,true);
}
Michal Klocek
Bugfixes for layout...
r1837
Michal Klocek
Refactors internals...
r2273 void ChartAxis::connectSlots()
{
QObject::connect(m_axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleVisibleChanged(bool)));
QObject::connect(m_axis,SIGNAL(lineVisibleChanged(bool)),this,SLOT(handleArrowVisibleChanged(bool)));
Jani Honkonen
BC fix: change gridLineVisibleChanged() back to gridVisibleChanged()
r2282 QObject::connect(m_axis,SIGNAL(gridVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool)));
Michal Klocek
Refactors internals...
r2273 QObject::connect(m_axis,SIGNAL(labelsVisibleChanged(bool)),this,SLOT(handleLabelsVisibleChanged(bool)));
QObject::connect(m_axis,SIGNAL(shadesVisibleChanged(bool)),this,SLOT(handleShadesVisibleChanged(bool)));
QObject::connect(m_axis,SIGNAL(labelsAngleChanged(int)),this,SLOT(handleLabelsAngleChanged(int)));
QObject::connect(m_axis,SIGNAL(linePenChanged(const QPen&)),this,SLOT(handleArrowPenChanged(const QPen&)));
QObject::connect(m_axis,SIGNAL(labelsPenChanged(const QPen&)),this,SLOT(handleLabelsPenChanged(const QPen&)));
QObject::connect(m_axis,SIGNAL(labelsBrushChanged(const QBrush&)),this,SLOT(handleLabelsBrushChanged(const QBrush&)));
QObject::connect(m_axis,SIGNAL(labelsFontChanged(const QFont&)),this,SLOT(handleLabelsFontChanged(const QFont&)));
QObject::connect(m_axis,SIGNAL(gridLinePenChanged(const QPen&)),this,SLOT(handleGridPenChanged(const QPen&)));
QObject::connect(m_axis,SIGNAL(shadesPenChanged(const QPen&)),this,SLOT(handleShadesPenChanged(const QPen&)));
QObject::connect(m_axis,SIGNAL(shadesBrushChanged(const QBrush&)),this,SLOT(handleShadesBrushChanged(const QBrush&)));
QObject::connect(m_axis,SIGNAL(titleTextChanged(const QString&)),this,SLOT(handleTitleTextChanged(const QString&)));
QObject::connect(m_axis,SIGNAL(titleFontChanged(const QFont&)),this,SLOT(handleTitleFontChanged(const QFont&)));
QObject::connect(m_axis,SIGNAL(titlePenChanged(const QPen&)),this,SLOT(handleTitlePenChanged(const QPen&)));
QObject::connect(m_axis,SIGNAL(titleBrushChanged(const QBrush&)),this,SLOT(handleTitleBrushChanged(const QBrush&)));
Michal Klocek
Bugfix: axis visibily issues...
r2297 QObject::connect(m_axis,SIGNAL(titleVisibleChanged(bool)),this,SLOT(handleTitleVisibleChanged(bool)));
Michal Klocek
Refactors internals...
r2273 QObject::connect(m_axis->d_ptr.data(),SIGNAL(rangeChanged(qreal,qreal)),this,SLOT(handleRangeChanged(qreal,qreal)));
Michal Klocek
Add zoom support...
r67 }
Michal Klocek
Changes QChartAxis -> QAxis
r1006 ChartAxis::~ChartAxis()
Michal Klocek
Add zoom support...
r67 {
}
Jani Honkonen
src folder: another massive victory for coding style police
r2131 void ChartAxis::setAnimation(AxisAnimation *animation)
Michal Klocek
Adds more axis handling...
r176 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 m_animation = animation;
Michal Klocek
Refactors axis animation, line animations
r1241 }
Michal Klocek
Animation refactor...
r530
Michal Klocek
Refactors axis animation, line animations
r1241 void ChartAxis::setLayout(QVector<qreal> &layout)
{
Jani Honkonen
src folder: another massive victory for coding style police
r2131 m_layoutVector = layout;
Michal Klocek
Refactors axis animation, line animations
r1241 }
void ChartAxis::createItems(int count)
{
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 if (m_arrow->childItems().size() == 0){
Michal Klocek
Refactors internals...
r2273 QGraphicsLineItem* arrow = new ArrowItem(this, this);
arrow->setPen(m_axis->linePen());
m_arrow->addToGroup(arrow);
}
Jani Honkonen
src folder: another massive victory for coding style police
r2131
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 if (m_intervalAxis && m_grid->childItems().size() == 0) {
Michal Klocek
Refactors internals...
r2273 for (int i = 0 ; i < 2 ; i ++){
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 QGraphicsLineItem* item = new QGraphicsLineItem(this);
item->setPen(m_axis->gridLinePen());
Michal Klocek
Refactors internals...
r2273 m_grid->addToGroup(item);
}
Michal Klocek
Refactors axis updateGeometry handling...
r2111 }
Jani Honkonen
src folder: another massive victory for coding style police
r2131
Michal Klocek
Refactors axis handling...
r223 for (int i = 0; i < count; ++i) {
Michal Klocek
Refactors internals...
r2273 QGraphicsLineItem* arrow = new QGraphicsLineItem(this);
arrow->setPen(m_axis->linePen());
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 QGraphicsLineItem* grid = new QGraphicsLineItem(this);
grid->setPen(m_axis->gridLinePen());
QGraphicsSimpleTextItem* label = new QGraphicsSimpleTextItem(this);
label->setFont(m_axis->labelsFont());
label->setPen(m_axis->labelsPen());
label->setBrush(m_axis->labelsBrush());
m_arrow->addToGroup(arrow);
Michal Klocek
Refactors internals...
r2273 m_grid->addToGroup(grid);
Marek Rosa
Font is now correctly set when new tick label is created
r2221 m_labels->addToGroup(label);
Michal Klocek
Refactors internals...
r2273
if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2){
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 QGraphicsRectItem* shades = new QGraphicsRectItem(this);
shades->setPen(m_axis->shadesPen());
shades->setBrush(m_axis->shadesBrush());
Michal Klocek
Refactors internals...
r2273 m_shades->addToGroup(shades);
}
Michal Klocek
Refactors axis animation, line animations
r1241 }
Michal Klocek
Refactors internals...
r2273
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartAxis::deleteItems(int count)
Michal Klocek
Adds more axis handling...
r176 {
Jani Honkonen
make QGraphicsItemGroup a pointer in axis
r784 QList<QGraphicsItem *> lines = m_grid->childItems();
QList<QGraphicsItem *> labels = m_labels->childItems();
QList<QGraphicsItem *> shades = m_shades->childItems();
Michal Klocek
Refactor Visibly methods of axis...
r1729 QList<QGraphicsItem *> axis = m_arrow->childItems();
Michal Klocek
Adds more axis handling...
r176
Michal Klocek
Refactors axis layout managment...
r291 for (int i = 0; i < count; ++i) {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 if (lines.size() % 2 && lines.size() > 1)
delete(shades.takeLast());
Michal Klocek
Refactors axis layout managment...
r291 delete(lines.takeLast());
delete(labels.takeLast());
delete(axis.takeLast());
Michal Klocek
Fix zorder of axis, and ticks
r272 }
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartAxis::updateLayout(QVector<qreal> &layout)
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors axis animation, line animations
r1241 int diff = m_layoutVector.size() - layout.size();
Jani Honkonen
src folder: another massive victory for coding style police
r2131 if (diff > 0)
Michal Klocek
Refactors axis animation, line animations
r1241 deleteItems(diff);
Jani Honkonen
src folder: another massive victory for coding style police
r2131 else if (diff < 0)
Michal Klocek
Refactors axis animation, line animations
r1241 createItems(-diff);
if (m_animation) {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 switch (presenter()->state()) {
case ChartPresenter::ZoomInState:
m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
m_animation->setAnimationPoint(presenter()->statePoint());
break;
case ChartPresenter::ZoomOutState:
m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
m_animation->setAnimationPoint(presenter()->statePoint());
break;
case ChartPresenter::ScrollUpState:
case ChartPresenter::ScrollLeftState:
m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
break;
case ChartPresenter::ScrollDownState:
case ChartPresenter::ScrollRightState:
m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
break;
case ChartPresenter::ShowState:
m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
break;
}
m_animation->setValues(m_layoutVector, layout);
presenter()->startAnimation(m_animation);
} else {
sauimone
more minor code review fixes
r745 setLayout(layout);
Michal Klocek
Refactors axis animation, line animations
r1241 updateGeometry();
Michal Klocek
Animation refactor...
r530 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
Michal Klocek
Adds more axis handling...
r176
Michal Klocek
Refactors internals...
r2273 void ChartAxis::setLabelPadding(int padding)
{
m_labelPadding = padding;
}
bool ChartAxis::isEmpty()
{
return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(min(),max());
}
void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid)
{
m_gridRect = grid;
m_axisRect = axis;
if (isEmpty())
return;
QVector<qreal> layout = calculateLayout();
updateLayout(layout);
}
qreal ChartAxis::min() const
Michal Klocek
Fixes wrong shades zvalues
r184 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 return m_axis->d_ptr->min();
Michal Klocek
Fixes wrong shades zvalues
r184 }
Michal Klocek
Refactors internals...
r2273 qreal ChartAxis::max() const
Michal Klocek
Fixes wrong shades zvalues
r184 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 return m_axis->d_ptr->max();
Michal Klocek
Refactor Visibly methods of axis...
r1729 }
Michal Klocek
Refactors internals...
r2273 QFont ChartAxis::font() const
Michal Klocek
Refactor Visibly methods of axis...
r1729 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 return m_axis->labelsFont();
Michal Klocek
Fixes wrong shades zvalues
r184 }
Michal Klocek
Refactors internals...
r2273 QFont ChartAxis::titleFont() const
Michal Klocek
Adds more axis handling...
r176 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 return m_axis->titleFont();
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactors internals...
r2273 QString ChartAxis::titleText() const
Michal Klocek
Adds more axis handling...
r176 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 return m_axis->titleText();
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactors internals...
r2273 void ChartAxis::axisSelected()
Michal Klocek
Refactor Visibly methods of axis...
r1729 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 emit clicked();
Michal Klocek
Refactor Visibly methods of axis...
r1729 }
Michal Klocek
Refactors internals...
r2273 Qt::Orientation ChartAxis::orientation() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors internals...
r2273 return m_axis->orientation();
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactors internals...
r2273 Qt::Alignment ChartAxis::alignment() const
{
return m_axis->alignment();
}
void ChartAxis::setLabels(const QStringList &labels)
{
m_labelsList = labels;
}
QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors internals...
r2273 Q_UNUSED(which);
Q_UNUSED(constraint);
return QSizeF();
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactors internals...
r2273 //handlers
void ChartAxis::handleArrowVisibleChanged(bool visible)
Michal Klocek
Refactor Visibly methods of axis...
r1729 {
Michal Klocek
Refactors internals...
r2273 m_arrow->setVisible(visible);
Michal Klocek
Refactor Visibly methods of axis...
r1729 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleGridVisibleChanged(bool visible)
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors internals...
r2273 m_grid->setVisible(visible);
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleLabelsVisibleChanged(bool visible)
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors internals...
r2273 m_labels->setVisible(visible);
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Add zoom support...
r67
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleShadesVisibleChanged(bool visible)
Michal Klocek
Refactor Visibly methods of axis...
r1729 {
m_shades->setVisible(visible);
}
Michal Klocek
Bugfix: axis visibily issues...
r2297 void ChartAxis::handleTitleVisibleChanged(bool visible)
{
m_title->setVisible(visible);
presenter()->layout()->invalidate();
}
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleLabelsAngleChanged(int angle)
Michal Klocek
Adds more axis handling...
r176 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item, m_labels->childItems())
item->setRotation(angle);
Michal Klocek
Adds more axis handling...
r176
Jani Honkonen
src folder: another massive victory for coding style police
r2131 m_labelsAngle = angle;
Michal Klocek
Add zoom support...
r67 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleLabelsPenChanged(const QPen &pen)
Michal Klocek
Adds refactored axis to presenter
r140 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item , m_labels->childItems())
static_cast<QGraphicsSimpleTextItem *>(item)->setPen(pen);
Michal Klocek
Adds refactored axis to presenter
r140 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleLabelsBrushChanged(const QBrush &brush)
Michal Klocek
Adds refactored axis to presenter
r140 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item , m_labels->childItems())
static_cast<QGraphicsSimpleTextItem *>(item)->setBrush(brush);
Michal Klocek
Adds refactored axis to presenter
r140 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleLabelsFontChanged(const QFont &font)
Michal Klocek
Adds refactored axis to presenter
r140 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 foreach (QGraphicsItem *item , m_labels->childItems())
static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font);
QGraphicsLayoutItem::updateGeometry();
presenter()->layout()->invalidate();
Michal Klocek
Adds refactored axis to presenter
r140 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleShadesBrushChanged(const QBrush &brush)
Michal Klocek
Adds refactored axis to presenter
r140 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item , m_shades->childItems())
static_cast<QGraphicsRectItem *>(item)->setBrush(brush);
Michal Klocek
Adds refactored axis to presenter
r140 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleShadesPenChanged(const QPen &pen)
Michal Klocek
Adds refactored axis to presenter
r140 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item , m_shades->childItems())
static_cast<QGraphicsRectItem *>(item)->setPen(pen);
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleArrowPenChanged(const QPen &pen)
Michal Klocek
Fixes wrong shades zvalues
r184 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item , m_arrow->childItems())
static_cast<QGraphicsLineItem *>(item)->setPen(pen);
Michal Klocek
Fixes wrong shades zvalues
r184 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleGridPenChanged(const QPen &pen)
Michal Klocek
Adds more axis handling...
r176 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 foreach (QGraphicsItem *item , m_grid->childItems())
static_cast<QGraphicsLineItem *>(item)->setPen(pen);
Michal Klocek
Refactors layout:...
r2105 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleTitleTextChanged(const QString &title)
Michal Klocek
Adds draft of axis bar label support
r497 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 Q_UNUSED(title)
QGraphicsLayoutItem::updateGeometry();
presenter()->layout()->invalidate();
Michal Klocek
Adds draft of axis bar label support
r497 }
Michal Klocek
Refactor domain model...
r439
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleTitlePenChanged(const QPen &pen)
Michal Klocek
Makes theming axis title aware
r2153 {
m_title->setPen(pen);
}
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleTitleBrushChanged(const QBrush &brush)
Michal Klocek
Makes theming axis title aware
r2153 {
m_title->setBrush(brush);
}
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleTitleFontChanged(const QFont &font)
Michal Klocek
Makes theming axis title aware
r2153 {
if(m_title->font() != font){
m_title->setFont(font);
QGraphicsLayoutItem::updateGeometry();
presenter()->layout()->invalidate();
}
}
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleVisibleChanged(bool visible)
Michal Klocek
Refactor Visibly methods of axis...
r1729 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 setVisible(visible);
Michal Klocek
Bugfix: axis visibily issues...
r2297 if(!visible) {
m_grid->setVisible(visible);
m_arrow->setVisible(visible);
m_shades->setVisible(visible);
m_labels->setVisible(visible);
m_title->setVisible(visible);
}else {
m_grid->setVisible(m_axis->isGridLineVisible());
m_arrow->setVisible(m_axis->isLineVisible());
m_shades->setVisible(m_axis->shadesVisible());
m_labels->setVisible(m_axis->labelsVisible());
m_title->setVisible(m_axis->isTitleVisible());
}
Marek Rosa
Fixed visibility initialization on axis
r2345 if(presenter()) presenter()->layout()->invalidate();
Michal Klocek
Refactor Visibly methods of axis...
r1729 }
Michal Klocek
Refactors internals...
r2273 void ChartAxis::handleRangeChanged(qreal min, qreal max)
Michal Klocek
Refactor domain model...
r439 {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 Q_UNUSED(min);
Q_UNUSED(max);
Michal Klocek
Refactors layout managment...
r1534
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 if (!isEmpty()) {
Marek Rosa
Multiaxis support...
r2093
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 QVector<qreal> layout = calculateLayout();
updateLayout(layout);
QSizeF before = effectiveSizeHint(Qt::PreferredSize);
QSizeF after = sizeHint(Qt::PreferredSize);
Michal Klocek
Refactor domain model...
r439
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 if (before != after) {
QGraphicsLayoutItem::updateGeometry();
//we don't want to call invalidate on layout, since it will change minimum size of component,
//which we would like to avoid since it causes nasty flips when scrolling or zooming,
//instead recalculate layout and use plotArea for extra space.
presenter()->layout()->setGeometry(presenter()->layout()->geometry());
}
}
Michal Klocek
Adds checkLayout call, when geometry of axis updated
r1890
Michal Klocek
Refactors layout...
r1965 }
Michal Klocek
Refactors internals...
r2273 //helpers
Michal Klocek
Refactors axis updateGeometry handling...
r2111
Michal Klocek
Refactors internals...
r2273 QStringList ChartAxis::createValueLabels(qreal min, qreal max, int ticks,const QString& format)
Michal Klocek
Refactors axis updateGeometry handling...
r2111 {
Michal Klocek
Refactors internals...
r2273 //TODO: Q_ASSERT(m_max > m_min);
//TODO: Q_ASSERT(ticks > 1);
Michal Klocek
Refactors axis updateGeometry handling...
r2111
QStringList labels;
Michal Klocek
Refactors internals...
r2273 if(max <= min || ticks < 1){
return labels;
}
Michal Klocek
Refactors axis updateGeometry handling...
r2111
Michal Klocek
Refactors internals...
r2273 int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
n++;
Michal Klocek
Refactors axis updateGeometry handling...
r2111
Jani Honkonen
src folder: another massive victory for coding style police
r2131 if (format.isNull()) {
for (int i = 0; i < ticks; i++) {
Michal Klocek
Refactors internals...
r2273 qreal value = min + (i * (max - min) / (ticks - 1));
Jani Honkonen
src folder: another massive victory for coding style police
r2131 labels << QString::number(value, 'f', n);
Michal Klocek
Refactors axis updateGeometry handling...
r2111 }
Jani Honkonen
src folder: another massive victory for coding style police
r2131 } else {
Jani Honkonen
Fix deprecation errors from Qt5
r2241 QByteArray array = format.toLatin1();
Jani Honkonen
src folder: another massive victory for coding style police
r2131 for (int i = 0; i < ticks; i++) {
Michal Klocek
Refactors internals...
r2273 qreal value = min + (i * (max - min) / (ticks - 1));
Marek Rosa
setLabelFormat bug fixed in QValueAxis
r2268 if (format.contains("d")
|| format.contains("i")
|| format.contains("c"))
labels << QString().sprintf(array, (qint64)value);
else if (format.contains("u")
|| format.contains("o")
|| format.contains("x", Qt::CaseInsensitive))
labels << QString().sprintf(array, (quint64)value);
Marek Rosa
fix: forgot to restage previous commit
r2269 else if (format.contains("f", Qt::CaseInsensitive)
|| format.contains("e", Qt::CaseInsensitive)
|| format.contains("g", Qt::CaseInsensitive))
Marek Rosa
setLabelFormat bug fixed in QValueAxis
r2268 labels << QString().sprintf(array, value);
Marek Rosa
Fixed: axis not redrawing when labelFormat changed
r2323 else
labels << QString();
Michal Klocek
Refactors axis updateGeometry handling...
r2111 }
}
return labels;
}
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 QStringList ChartAxis::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format)
{
// Q_ASSERT(m_max > m_min);
// Q_ASSERT(ticks > 1);
QStringList labels;
int n = 0;
if (ticks > 1)
n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
n++;
int firstTick;
if (base > 1)
Marek Rosa
Domains added
r2275 firstTick = ceil(log10(min) / log10(base));
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 else
Marek Rosa
Domains added
r2275 firstTick = ceil(log10(max) / log10(base));
Marek Rosa
QLogValueAxis added. Log domain missing
r2274
if (format.isNull()) {
for (int i = firstTick; i < ticks + firstTick; i++) {
qreal value = qPow(base, i);
labels << QString::number(value, 'f', n);
}
} else {
Jani Honkonen
Some fixes for Qt5, vs2010 build and qml
r2277 QByteArray array = format.toLatin1();
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 for (int i = firstTick; i < ticks + firstTick; i++) {
qreal value = qPow(base, i);
Marek Rosa
Log domains update when axis base changes. LogAxis fix for labelFormat
r2293 if (format.contains("d")
|| format.contains("i")
|| format.contains("c"))
labels << QString().sprintf(array, (qint64)value);
else if (format.contains("u")
|| format.contains("o")
|| format.contains("x", Qt::CaseInsensitive))
labels << QString().sprintf(array, (quint64)value);
else if (format.contains("f", Qt::CaseInsensitive)
|| format.contains("e", Qt::CaseInsensitive)
|| format.contains("g", Qt::CaseInsensitive))
labels << QString().sprintf(array, value);
Marek Rosa
Fixed: axis not redrawing when labelFormat changed
r2323 else
labels << QString();
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 }
}
return labels;
}
Michal Klocek
Refactors internals...
r2273 QStringList ChartAxis::createDateTimeLabels(qreal min, qreal max,int ticks,const QString& format)
Michal Klocek
Refactors axis updateGeometry handling...
r2111 {
Michal Klocek
Refactors internals...
r2273 //TODO: Q_ASSERT(m_max > m_min);
//TODO: Q_ASSERT(ticks > 1);
Michal Klocek
Refactors axis updateGeometry handling...
r2111 QStringList labels;
Michal Klocek
Refactors internals...
r2273
if(max <= min || ticks < 1) {
return labels;
}
int n = qMax(int(-floor(log10((max - min) / (ticks - 1)))), 0);
Michal Klocek
Refactors axis updateGeometry handling...
r2111 n++;
Jani Honkonen
src folder: another massive victory for coding style police
r2131 for (int i = 0; i < ticks; i++) {
Michal Klocek
Refactors internals...
r2273 qreal value = min + (i * (max - min) / (ticks - 1));
Michal Klocek
Refactors axis updateGeometry handling...
r2111 labels << QDateTime::fromMSecsSinceEpoch(value).toString(format);
}
return labels;
}
Michal Klocek
Changes QChartAxis -> QAxis
r1006 #include "moc_chartaxis_p.cpp"
Michal Klocek
Add zoom support...
r67
QTCOMMERCIALCHART_END_NAMESPACE