##// END OF EJS Templates
Remove PlotDomain , use Domain insted...
Remove PlotDomain , use Domain insted * clean old setSize SetPlotDomain iterface * remove all PlotDomain references

File last commit:

r149:23a271e217e1
r149:23a271e217e1
Show More
qscatterseries.cpp
140 lines | 4.0 KiB | text/x-c | CppLexer
/ src / qscatterseries.cpp
Tero Ahola
Integrated scatter type series...
r42 #include "qscatterseries.h"
#include "qscatterseries_p.h"
#include "qchart.h"
#include <QPainter>
#include <QGraphicsScene>
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 #include <QDebug>
Tero Ahola
Integrated scatter type series...
r42
QTCOMMERCIALCHART_BEGIN_NAMESPACE
//#define QSeriesData QList<qreal>
Tero Ahola
Refactored series creation with QChart
r61 QScatterSeriesPrivate::QScatterSeriesPrivate(QGraphicsItem *parent) :
Tero Ahola
Refactoring continued: restored ChartItem class
r104 ChartItem(parent),
Tero Ahola
Cleanup; removed left over .h file and squashed warnings
r121 m_boundingRect(),
Tero Ahola
One more alternative for changing themes
r108 m_markerColor(QColor()),
Tero Ahola
Cleanup; removed left over .h file and squashed warnings
r121 m_visibleChartArea()
Tero Ahola
Integrated scatter type series...
r42 {
Tero Ahola
Scaling for scatter series
r111 if (parent)
m_boundingRect = parent->boundingRect();
Tero Ahola
Integrated scatter type series...
r42 }
Tero Ahola
Scaling for scatter series
r111 void QScatterSeriesPrivate::changeGeometry()
Tero Ahola
Integrated scatter type series...
r42 {
Tero Ahola
Scaling for scatter series
r111 if (m_boundingRect.isValid()) {
prepareGeometryChange();
qreal scalex = m_boundingRect.width() / m_visibleChartArea.spanX();
qreal scaley = m_boundingRect.height() / m_visibleChartArea.spanY();
m_scenex.clear();
m_sceney.clear();
// Convert relative coordinates to absolute pixel coordinates that can be used for drawing
foreach(qreal x, m_x)
m_scenex.append(m_boundingRect.left() + x * scalex - m_visibleChartArea.m_minX * scalex);
foreach(qreal y, m_y)
m_sceney.append(m_boundingRect.bottom() - y * scaley + m_visibleChartArea.m_minY * scaley);
}
Tero Ahola
Integrated scatter type series...
r42 }
Michal Klocek
Adds layout support for charts....
r115 void QScatterSeriesPrivate::setSize(const QSizeF &size)
Tero Ahola
Refactoring continued: restored ChartItem class
r104 {
Tero Ahola
Scaling for scatter series
r111 // m_boundingRect = QRectF(pos().x(), pos().y(), size.width(), size.height());
m_boundingRect = QRectF(0, 0, size.width(), size.height());
changeGeometry();
Tero Ahola
Refactoring continued: restored ChartItem class
r104 }
Tero Ahola
One more alternative for changing themes
r108 void QScatterSeriesPrivate::themeChanged(ChartTheme *theme)
Tero Ahola
Refactoring continued: restored ChartItem class
r104 {
Michal Klocek
Refactor themes...
r143 //m_theme = theme->themeForSeries();
Tero Ahola
Refactoring continued: restored ChartItem class
r104 }
Michal Klocek
Remove PlotDomain , use Domain insted...
r149 void QScatterSeriesPrivate::setPlotDomain(const Domain& plotDomain)
Tero Ahola
Refactoring continued: restored ChartItem class
r104 {
Michal Klocek
Remove PlotDomain , use Domain insted...
r149 //m_visibleChartArea = plotDomain;
Tero Ahola
Scaling for scatter series
r111 changeGeometry();
Tero Ahola
Refactoring continued: restored ChartItem class
r104 }
Tero Ahola
Removed scale from chart's sizeChanged signals
r54
Tero Ahola
Integrated scatter type series...
r42 QRectF QScatterSeriesPrivate::boundingRect() const
{
Tero Ahola
Scaling for scatter series
r111 return m_boundingRect;
Tero Ahola
Integrated scatter type series...
r42 }
Tero Ahola
Refactored the test app
r110 void QScatterSeriesPrivate::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
Tero Ahola
Integrated scatter type series...
r42 {
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 // TODO: The opacity should be user definable?
Tero Ahola
Draft implementation for setting color themes for a chart
r64 //brush.setColor(QColor(255, 82, 0, 100));
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 if (m_markerColor.isValid()) {
QPen pen = painter->pen();
QBrush brush = pen.brush();
brush.setColor(m_markerColor);
pen.setBrush(brush);
pen.setWidth(4);
painter->setPen(pen);
}
else
Michal Klocek
Refactor themes...
r143 //painter->setPen(m_theme.markerPen);
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 // brush.setColor(m_theme..lineColor);
Tero Ahola
Integrated scatter type series...
r42
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 // TODO: m_scenex and m_sceny are left empty during construction -> we would need a resize
// event right after construction or maybe given a size during initialization
for (int i(0); i < m_scenex.count() && i < m_sceney.count(); i++) {
if (scene()->width() > m_scenex.at(i) && scene()->height() > m_sceney.at(i))
//painter->drawArc(m_scenex.at(i), m_sceney.at(i), 2, 2, 0, 5760);
painter->drawPoint(m_scenex.at(i), m_sceney.at(i));
Tero Ahola
Integrated scatter type series...
r42 }
}
Tero Ahola
Refactored series creation with QChart
r61 QScatterSeries::QScatterSeries(QObject *parent) :
Tero Ahola
Integrated scatter type series...
r42 QChartSeries(parent),
Tero Ahola
Refactored series creation with QChart
r61 d(new QScatterSeriesPrivate(qobject_cast<QGraphicsItem *> (parent)))
Tero Ahola
Integrated scatter type series...
r42 {
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 }
Tero Ahola
Scaling for scatter series
r111 bool QScatterSeries::setData(QList<qreal> xlist, QList<qreal> ylist)
Tero Ahola
Refactored series creation with QChart
r61 {
// TODO: validate data
Tero Ahola
Scaling for scatter series
r111 d->m_x = xlist;
d->m_y = ylist;
// TODO: the following updates the visible chart area setting of the series, we would instead
// need to update the _chart's_ visible area... this would require a callback or
// similar to the parenting QChart object...
foreach (qreal x, d->m_x) {
d->m_visibleChartArea.m_minX = qMin(d->m_visibleChartArea.m_minX, x);
d->m_visibleChartArea.m_maxX = qMax(d->m_visibleChartArea.m_maxX, x);
}
foreach (qreal y, d->m_y) {
d->m_visibleChartArea.m_minY = qMin(d->m_visibleChartArea.m_minY, y);
d->m_visibleChartArea.m_maxY = qMax(d->m_visibleChartArea.m_maxY, y);
}
d->changeGeometry();
Tero Ahola
Refactored series creation with QChart
r61 return true;
}
Tero Ahola
Draft implementation for setting color themes for a chart
r64 void QScatterSeries::setMarkerColor(QColor color)
{
d->m_markerColor = color;
}
Tero Ahola
Color themes now enabled for scatter, pie and line series.
r75 QColor QScatterSeries::markerColor()
{
return d->m_markerColor;
}
Tero Ahola
Removed scale from chart's sizeChanged signals
r54 // TODO:
//void QScatterSeries::chartScaleChanged(qreal xscale, qreal yscale)
//{
// d->rescale(xscale, yscale);
//}
Tero Ahola
Integrated scatter type series...
r42 QScatterSeries::~QScatterSeries()
{
delete d;
}
#include "moc_qscatterseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE