##// END OF EJS Templates
Values and Intervals axes ranges are now initialized only if they haven't been preset earlier
Values and Intervals axes ranges are now initialized only if they haven't been preset earlier

File last commit:

r1698:da7242791c36
r1703:d83729eb88d8
Show More
areachartitem.cpp
150 lines | 4.0 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
Adds area chart...
r421 #include "areachartitem_p.h"
#include "qareaseries.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "qareaseries_p.h"
Michal Klocek
Adds area chart...
r421 #include "qlineseries.h"
Michal Klocek
Fixes missing chart area z value intialization
r564 #include "chartpresenter_p.h"
Michal Klocek
Refactors Domain and Axis...
r1698 #include "domain_p.h"
Michal Klocek
Adds area chart...
r421 #include <QPainter>
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 #include <QGraphicsSceneMouseEvent>
Michal Klocek
Refactors axis animation, line animations
r1241 #include <QDebug>
Michal Klocek
Adds area chart...
r421
QTCOMMERCIALCHART_BEGIN_NAMESPACE
//TODO: optimize : remove points which are not visible
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter)
: ChartItem(presenter),
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 m_series(areaSeries),
m_upper(0),
m_lower(0),
m_pointsVisible(false)
Michal Klocek
Adds area chart...
r421 {
Michal Klocek
Fixes missing chart area z value intialization
r564 setZValue(ChartPresenter::LineChartZValue);
Michal Klocek
Refactors axis animation, line animations
r1241 m_upper = new AreaBoundItem(this,m_series->upperSeries(),presenter);
Michal Klocek
Refactors Domain and Axis...
r1698 if (m_series->lowerSeries()){
Michal Klocek
Refactors axis animation, line animations
r1241 m_lower = new AreaBoundItem(this,m_series->lowerSeries(),presenter);
Michal Klocek
Refactors Domain and Axis...
r1698 }
Michal Klocek
Adds area chart...
r421
Michal Klocek
Refactors animation handling for xyseries
r1217 QObject::connect(m_series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated()));
Tero Ahola
Visible property to abstract series
r1342 QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
Michal Klocek
Refactors animation handling for xyseries
r1217 QObject::connect(this,SIGNAL(clicked(QPointF)),areaSeries,SIGNAL(clicked(QPointF)));
Michal Klocek
Adds area chart...
r421
handleUpdated();
}
AreaChartItem::~AreaChartItem()
{
delete m_upper;
delete m_lower;
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761 }
Michal Klocek
Adds area chart...
r421
QRectF AreaChartItem::boundingRect() const
{
return m_rect;
}
QPainterPath AreaChartItem::shape() const
{
return m_path;
}
void AreaChartItem::updatePath()
{
QPainterPath path;
Michal Klocek
Bugfix : black line drawn during areachart paint
r690 path = m_upper->shape();
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 if (m_lower) {
path.connectPath(m_lower->shape().toReversed());
} else {
Michal Klocek
Adds area chart...
r421 QPointF first = path.pointAtPercent(0);
QPointF last = path.pointAtPercent(1);
path.lineTo(last.x(),m_clipRect.bottom());
path.lineTo(first.x(),m_clipRect.bottom());
}
path.closeSubpath();
prepareGeometryChange();
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761 m_path = path;
m_rect = path.boundingRect();
Michal Klocek
Adds area chart...
r421 update();
}
void AreaChartItem::handleUpdated()
{
Tero Ahola
Fixed isVisible implementation in XY series
r1346 setVisible(m_series->isVisible());
Michal Klocek
Adds visiblePoints handling to area chart
r563 m_pointsVisible = m_series->pointsVisible();
m_linePen = m_series->pen();
Michal Klocek
Unify naming setGeometry -> setLayout
r557 m_brush = m_series->brush();
Michal Klocek
Adds visiblePoints handling to area chart
r563 m_pointPen = m_series->pen();
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761 m_pointPen.setWidthF(2 * m_pointPen.width());
Michal Klocek
Adds visiblePoints handling to area chart
r563
Michal Klocek
Adds area chart...
r421 update();
}
Michal Klocek
Refactors Domain and Axis...
r1698 void AreaChartItem::handleDomainUpdated()
Michal Klocek
Adds area chart...
r421 {
Michal Klocek
Refactors Domain and Axis...
r1698 m_upper->setDomain(domain());
m_upper->handleDomainUpdated();
if (m_lower){
m_lower->setDomain(domain());
m_lower->handleDomainUpdated();
}
Michal Klocek
Adds area chart...
r421 }
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 void AreaChartItem::handleGeometryChanged(const QRectF &rect)
Michal Klocek
Adds area chart...
r421 {
m_clipRect=rect.translated(-rect.topLeft());
setPos(rect.topLeft());
m_upper->handleGeometryChanged(rect);
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 if (m_lower)
m_lower->handleGeometryChanged(rect);
Michal Klocek
Adds area chart...
r421 }
void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(widget)
Q_UNUSED(option)
Tero Ahola
Fixed isVisible implementation in XY series
r1346 painter->save();
painter->setPen(m_linePen);
painter->setBrush(m_brush);
painter->setClipRect(m_clipRect);
painter->drawPath(m_path);
if (m_pointsVisible) {
painter->setPen(m_pointPen);
painter->drawPoints(m_upper->geometryPoints());
if (m_lower)
painter->drawPoints(m_lower->geometryPoints());
Michal Klocek
Adds visiblePoints handling to area chart
r563 }
Tero Ahola
Fixed isVisible implementation in XY series
r1346 painter->restore();
Michal Klocek
Adds area chart...
r421 }
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 {
emit clicked(m_upper->calculateDomainPoint(event->pos()));
}
Michal Klocek
Adds area chart...
r421 #include "moc_areachartitem_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE