##// END OF EJS Templates
Forced update of qmlapplicationviewer templates
Forced update of qmlapplicationviewer templates

File last commit:

r2356:c0053ad31507
r2405:92b9e13486f5 release-1.2.0
Show More
linechartitem.cpp
151 lines | 4.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
Fix naming convention for lineseries...
r144 #include "linechartitem_p.h"
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 #include "qlineseries.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "qlineseries_p.h"
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartpresenter_p.h"
Marek Rosa
Domains added
r2275 #include "abstractdomain_p.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QPainter>
Michal Klocek
Refactor xychartitem -> xychart
r1218 #include <QGraphicsSceneMouseEvent>
Michal Klocek
Fix naming convention for lineseries...
r144
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor current draft to fit int current design specs...
r21
Tero Ahola
Fixed area series paint bug caused by mouse event fix on line series
r1792 const qreal mouseEventMinWidth(12);
Michal Klocek
Adds cliping and proper zoom handling for line chart
r150
Michal Klocek
Refactors internals...
r2273 LineChartItem::LineChartItem(QLineSeries *series,QGraphicsItem* item)
: XYChart(series,item),
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_series(series),
m_pointsVisible(false)
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
Marek Rosa
Added hovered signal to QLineSeries. Updated callout example
r2255 setAcceptHoverEvents(true);
Michal Klocek
Adds ZOrder enum to presenter
r262 setZValue(ChartPresenter::LineChartZValue);
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 QObject::connect(series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated()));
Tero Ahola
Visible property to abstract series
r1342 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
Tero Ahola
Added opacity property to QAbstractSeries
r2067 QObject::connect(series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
Michal Klocek
Refactor domain model...
r439 handleUpdated();
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Michal Klocek
Fix naming convention for lineseries...
r144 QRectF LineChartItem::boundingRect() const
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 return m_rect;
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Fix naming convention for lineseries...
r144 QPainterPath LineChartItem::shape() const
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Fix line series graphic arefacts
r1819 return m_path;
Michal Klocek
Refactors qchart , adds line animation...
r131 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactors animation handling for xyseries
r1217 void LineChartItem::updateGeometry()
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Fix line series graphic arefacts
r1819 m_points = geometryPoints();
Michal Klocek
Refactors animation handling for xyseries
r1217
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (m_points.size() == 0) {
Michal Klocek
Fix last post remove in qlineseries
r1269 prepareGeometryChange();
Marek Rosa
XYSeries model support refactored
r1085 m_path = QPainterPath();
Michal Klocek
Fix last post remove in qlineseries
r1269 m_rect = QRect();
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 return;
}
Michal Klocek
Refactors linechart update calls
r464
Michal Klocek
Fix line series graphic arefacts
r1819 QPainterPath linePath(m_points.at(0));
Michal Klocek
Refactors linechart update calls
r464
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (m_pointsVisible) {
Michal Klocek
Fix line series graphic arefacts
r1819
int size = m_linePen.width();
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 linePath.addEllipse(m_points.at(0), size, size);
for (int i = 1; i < m_points.size(); i++) {
Michal Klocek
Fix line series graphic arefacts
r1819 linePath.lineTo(m_points.at(i));
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 linePath.addEllipse(m_points.at(i), size, size);
Marek Rosa
Linechartitem fix: drawing points
r2259 linePath.moveTo(m_points.at(i));
Michal Klocek
Fix line series graphic arefacts
r1819 }
} else {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 for (int i = 1; i < m_points.size(); i++)
Michal Klocek
Fix line series graphic arefacts
r1819 linePath.lineTo(m_points.at(i));
Michal Klocek
Refactor line spline to common xyline...
r465 }
Michal Klocek
Refactors linechart update calls
r464
Tero Ahola
Finetuning shape of line chart item to remove drawing artifacts
r1823 m_linePath = linePath;
Michal Klocek
Fix line series graphic arefacts
r1819 QPainterPathStroker stroker;
Tero Ahola
Finetuning shape of line chart item to remove drawing artifacts
r1823 // QPainter::drawLine does not respect join styles, for example BevelJoin becomes MiterJoin.
// This is why we are prepared for the "worst case" scenario, i.e. use always MiterJoin and
// multiply line width with square root of two when defining shape and bounding rectangle.
stroker.setWidth(m_linePen.width() * 1.42);
stroker.setJoinStyle(Qt::MiterJoin);
stroker.setCapStyle(Qt::SquareCap);
Michal Klocek
Adds magic number to fix some drawLine shape inaccuracy
r1821 stroker.setMiterLimit(m_linePen.miterLimit());
Tero Ahola
Fixed paint and mouse event issues with QLineSeries...
r1791
Michal Klocek
Fix line series graphic arefacts
r1819 prepareGeometryChange();
Tero Ahola
Fixed paint and mouse event issues with QLineSeries...
r1791
Michal Klocek
Fix line series graphic arefacts
r1819 m_path = stroker.createStroke(linePath);
m_rect = m_path.boundingRect();
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Michal Klocek
Adds updated handling for line series
r392 void LineChartItem::handleUpdated()
Michal Klocek
Rewrite animation hadnling in line series...
r389 {
Tero Ahola
Fixed isVisible implementation in XY series
r1346 setVisible(m_series->isVisible());
Tero Ahola
Added opacity property to QAbstractSeries
r2067 setOpacity(m_series->opacity());
Michal Klocek
Adds clicked(Point) to lineSeries, changes visible points handling
r544 m_pointsVisible = m_series->pointsVisible();
m_linePen = m_series->pen();
Michal Klocek
Refactored for MVP...
r139 update();
}
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(widget)
Q_UNUSED(option)
Tero Ahola
Fixed clip rect bug in QLineSeries
r1828 painter->save();
Tero Ahola
Fixed isVisible implementation in XY series
r1346 painter->setPen(m_linePen);
Michal Klocek
Fix line series graphic arefacts
r1819 painter->setBrush(m_linePen.color());
Michal Klocek
Refactors internals...
r2273 painter->setClipRect(QRectF(QPointF(0,0),domain()->size()));
Michal Klocek
Fix line series graphic arefacts
r1819
if (m_pointsVisible) {
painter->drawPath(m_linePath);
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 } else {
for (int i(1); i < m_points.size(); i++)
painter->drawLine(m_points.at(i - 1), m_points.at(i));
Michal Klocek
Adds clicked(Point) to lineSeries, changes visible points handling
r544 }
Tero Ahola
Fixed clip rect bug in QLineSeries
r1828 painter->restore();
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 }
Michal Klocek
Refactor xychartitem -> xychart
r1218 void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Michal Klocek
Refactors internals...
r2273 emit XYChart::clicked(domain()->calculateDomainPoint(event->pos()));
Michal Klocek
Fixes mouse handling in base class of chartseries
r1747 QGraphicsItem::mousePressEvent(event);
Michal Klocek
Refactor xychartitem -> xychart
r1218 }
Marek Rosa
Added hovered signal to QLineSeries. Updated callout example
r2255 void LineChartItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Michal Klocek
Refactors internals...
r2273 emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), true);
Marek Rosa
Negative values with log axis handled
r2356 // event->accept();
QGraphicsItem::hoverEnterEvent(event);
Marek Rosa
Added hovered signal to QLineSeries. Updated callout example
r2255 }
void LineChartItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Michal Klocek
Refactors internals...
r2273 emit XYChart::hovered(domain()->calculateDomainPoint(event->pos()), false);
Marek Rosa
Negative values with log axis handled
r2356 // event->accept();
QGraphicsItem::hoverEnterEvent(event);
Marek Rosa
Added hovered signal to QLineSeries. Updated callout example
r2255 }
Michal Klocek
Fix naming convention for lineseries...
r144 #include "moc_linechartitem_p.cpp"
Michal Klocek
Refactors qchart , adds line animation...
r131
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE