##// END OF EJS Templates
Default theme with OS specific colors on Windows
Default theme with OS specific colors on Windows

File last commit:

r513:c1d8fdd92b71
r537:f223805ee598
Show More
linechartitem.cpp
122 lines | 2.7 KiB | text/x-c | CppLexer
Michal Klocek
Fix naming convention for lineseries...
r144 #include "linechartitem_p.h"
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 #include "qlineseries.h"
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartpresenter_p.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QPainter>
Michal Klocek
Fix naming convention for lineseries...
r144
Michal Klocek
Refactor current draft to fit int current design specs...
r21
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor current draft to fit int current design specs...
r21
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 //TODO: optimize : remove points which are not visible
Michal Klocek
Adds cliping and proper zoom handling for line chart
r150
Michal Klocek
Refactor line spline to common xyline...
r465 LineChartItem::LineChartItem(QLineSeries* series,QGraphicsItem *parent):XYChartItem(series,parent),
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 m_series(series),
m_items(this)
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 //m_items.setZValue(ChartPresenter::LineChartZValue);
Michal Klocek
Adds ZOrder enum to presenter
r262 setZValue(ChartPresenter::LineChartZValue);
Michal Klocek
Adds area chart...
r421 QObject::connect(series,SIGNAL(updated()),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 {
Michal Klocek
Refactors qchart , adds line animation...
r131 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
Refactors qchart , adds line animation...
r131 return m_path;
}
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Rewrite animation hadnling in line series...
r389 void LineChartItem::createPoints(int count)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Rewrite animation hadnling in line series...
r389 for (int i = 0; i < count; ++i) {
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 QGraphicsRectItem* item = new QGraphicsRectItem(0,0,3,3);
Michal Klocek
Rewrite animation hadnling in line series...
r389 m_items.addToGroup(item);
Michal Klocek
Refactors qchart , adds line animation...
r131 }
}
Michal Klocek
Refactor line spline to common xyline...
r465 void LineChartItem::deletePoints(int count)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Rewrite animation hadnling in line series...
r389 QList<QGraphicsItem *> items = m_items.childItems();
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Rewrite animation hadnling in line series...
r389 for (int i = 0; i < count; ++i) {
delete(items.takeLast());
Michal Klocek
Refactors qchart , adds line animation...
r131 }
}
Michal Klocek
Refactor line spline to common xyline...
r465 void LineChartItem::setGeometry(QVector<QPointF>& points)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Refactor line spline to common xyline...
r465 if(points.size()==0) return;
Michal Klocek
Refactors linechart update calls
r464
Michal Klocek
Refactor line spline to common xyline...
r465 int diff = XYChartItem::points().size() - points.size();
Michal Klocek
Refactors linechart update calls
r464
if(diff>0) {
Michal Klocek
Refactor line spline to common xyline...
r465 deletePoints(diff);
Michal Klocek
Refactors linechart update calls
r464 }
else if(diff<0) {
createPoints(-diff);
}
Michal Klocek
Refactor line spline to common xyline...
r465 QList<QGraphicsItem*> items = m_items.childItems();
Michal Klocek
Refactors linechart update calls
r464
Michal Klocek
Refactor line spline to common xyline...
r465 QPainterPath path;
const QPointF& point = points.at(0);
path.moveTo(point);
QGraphicsItem* item = items.at(0);
item->setPos(point.x()-1,point.y()-1);
if(!clipRect().contains(point)) {
item->setVisible(false);
}
else {
item->setVisible(true);
}
Michal Klocek
Refactors linechart update calls
r464
Michal Klocek
Refactor line spline to common xyline...
r465 for(int i=1; i< points.size();i++) {
QGraphicsItem* item = items.at(i);
const QPointF& point = points.at(i);
item->setPos(point.x()-1,point.y()-1);
if(!clipRect().contains(point)) {
item->setVisible(false);
}
else {
item->setVisible(true);
}
path.lineTo(point);
}
Michal Klocek
Refactors linechart update calls
r464
Michal Klocek
Refactor line spline to common xyline...
r465 prepareGeometryChange();
m_path = path;
m_rect = path.boundingRect();
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Refactor line spline to common xyline...
r465 XYChartItem::setGeometry(points);
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 void LineChartItem::setLinePen(const QPen& pen)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Refactored for MVP...
r139 m_pen = pen;
}
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Adds updated handling for line series
r392 void LineChartItem::handleUpdated()
Michal Klocek
Rewrite animation hadnling in line series...
r389 {
m_items.setVisible(m_series->pointsVisible());
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 setLinePen(m_series->pen());
Michal Klocek
Refactored for MVP...
r139 update();
}
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 //painter
void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(option);
painter->save();
painter->setPen(m_pen);
Michal Klocek
Refactor line spline to common xyline...
r465 painter->setClipRect(clipRect());
Michal Klocek
Fix commit 7b90ec69ce9a3353820d295c222ef3f79537484d
r391 painter->drawPath(m_path);
painter->restore();
}
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