##// END OF EJS Templates
Bugfix : black line drawn during areachart paint
Bugfix : black line drawn during areachart paint

File last commit:

r679:2f2494d0880e
r690:847ff650439d
Show More
piechartitem.cpp
192 lines | 5.3 KiB | text/x-c | CppLexer
Jani Honkonen
Rename piepresenter -> piechartitem
r568 #include "piechartitem_p.h"
Jani Honkonen
rename PieSlice -> PieSliceItem
r673 #include "piesliceitem_p.h"
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 #include "qpieslice.h"
Jani Honkonen
Adding PIMPL to pie
r669 #include "qpiesliceprivate_p.h"
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 #include "qpieseries.h"
Tero Ahola
Z order for pie
r490 #include "chartpresenter_p.h"
Jani Honkonen
Fix add/remove animation for pie and apply colors from theme when adding/removing
r659 #include "chartdataset_p.h"
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 #include "chartanimator_p.h"
Jani Honkonen
Pie chart refactoring
r142 #include <QDebug>
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 #include <QPainter>
Jani Honkonen
Refactoring pie series and animations.
r621 #include <QTimer>
Jani Honkonen
Pie chart refactoring
r142
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactors chartitem...
r677 PieChartItem::PieChartItem(QPieSeries *series, ChartPresenter* presenter)
:ChartItem(presenter),
m_series(series)
Jani Honkonen
Pie chart refactoring
r142 {
Q_ASSERT(series);
Jani Honkonen
Refactoring pie series and animations.
r621 connect(series, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleSlicesAdded(QList<QPieSlice*>)));
connect(series, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleSlicesRemoved(QList<QPieSlice*>)));
connect(series, SIGNAL(piePositionChanged()), this, SLOT(handlePieLayoutChanged()));
connect(series, SIGNAL(pieSizeChanged()), this, SLOT(handlePieLayoutChanged()));
QTimer::singleShot(0, this, SLOT(initialize()));
Tero Ahola
Z order for pie
r490
// Note: the following does not affect as long as the item does not have anything to paint
setZValue(ChartPresenter::PieSeriesZValue);
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Rename piepresenter -> piechartitem
r568 PieChartItem::~PieChartItem()
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Refactoring piechart API (and internals)
r174 // slices deleted automatically through QGraphicsItem
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Rename piepresenter -> piechartitem
r568 void PieChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
Jani Honkonen
Pie chart refactoring
r142 {
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(painter)
Jani Honkonen
Refactoring piechart API (and internals)
r174 // TODO: paint shadows for all components
// - get paths from items & merge & offset and draw with shadow color?
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 //painter->setBrush(QBrush(Qt::red));
//painter->drawRect(m_debugRect);
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Refactoring pie series and animations.
r621 void PieChartItem::initialize()
{
Jani Honkonen
Adding PIMPL to pie
r669 handleSlicesAdded(m_series->slices());
Jani Honkonen
Refactoring pie series and animations.
r621 }
void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices)
{
Jani Honkonen
Nicer animation for adding a pie initially.
r634 bool isEmpty = m_slices.isEmpty();
Michal Klocek
Refactors chartitem...
r677 presenter()->theme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series));
Jani Honkonen
Fix add/remove animation for pie and apply colors from theme when adding/removing
r659
Jani Honkonen
Refactoring pie series and animations.
r621 foreach (QPieSlice *s, slices) {
Jani Honkonen
rename PieSlice -> PieSliceItem
r673 PieSliceItem* item = new PieSliceItem(this);
m_slices.insert(s, item);
Jani Honkonen
Refactoring pie series and animations.
r621 connect(s, SIGNAL(changed()), this, SLOT(handleSliceChanged()));
Jani Honkonen
rename PieSlice -> PieSliceItem
r673 connect(item, SIGNAL(clicked()), s, SIGNAL(clicked()));
connect(item, SIGNAL(hoverEnter()), s, SIGNAL(hoverEnter()));
connect(item, SIGNAL(hoverLeave()), s, SIGNAL(hoverLeave()));
Jani Honkonen
Refactoring pie series and animations.
r621
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 PieSliceData data = sliceData(s);
Jani Honkonen
Refactoring pie series and animations.
r621
Michal Klocek
Refactors barchart axis hadnling...
r679 if (animator())
animator()->addAnimation(this, s, data, isEmpty);
Jani Honkonen
Refactoring pie series and animations.
r621 else
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 setLayout(s, data);
Jani Honkonen
Refactoring pie series and animations.
r621 }
}
void PieChartItem::handleSlicesRemoved(QList<QPieSlice*> slices)
{
Michal Klocek
Refactors chartitem...
r677 presenter()->theme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series));
Jani Honkonen
Fix add/remove animation for pie and apply colors from theme when adding/removing
r659
Jani Honkonen
Refactoring pie series and animations.
r621 foreach (QPieSlice *s, slices) {
Michal Klocek
Refactors chartitem...
r677 if (animator())
animator()->removeAnimation(this, s);
Jani Honkonen
Refactoring pie series and animations.
r621 else
destroySlice(s);
}
}
void PieChartItem::handlePieLayoutChanged()
Jani Honkonen
Refactoring piechart API (and internals)
r174 {
Jani Honkonen
Getting rid of slice pointer in PieSliceLayout.
r629 PieLayout layout = calculateLayout();
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 applyLayout(layout);
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 update();
}
Jani Honkonen
Pie chart refactoring
r142
Jani Honkonen
Rename piepresenter -> piechartitem
r568 void PieChartItem::handleSliceChanged()
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 {
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 PieSliceData data = sliceData(slice);
updateLayout(slice, data);
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 update();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Rename piepresenter -> piechartitem
r568 void PieChartItem::handleDomainChanged(qreal, qreal, qreal, qreal)
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 {
// TODO
}
Jani Honkonen
Rename piepresenter -> piechartitem
r568 void PieChartItem::handleGeometryChanged(const QRectF& rect)
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 {
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 prepareGeometryChange();
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 m_rect = rect;
Jani Honkonen
Refactoring pie series and animations.
r621 handlePieLayoutChanged();
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Refactoring pie series and animations.
r621 void PieChartItem::calculatePieLayout()
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 {
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 // find pie center coordinates
Jani Honkonen
Refactoring pie series and animations.
r621 m_pieCenter.setX(m_rect.left() + (m_rect.width() * m_series->pieHorizontalPosition()));
m_pieCenter.setY(m_rect.top() + (m_rect.height() * m_series->pieVerticalPosition()));
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 // find maximum radius for pie
Jani Honkonen
Refactoring pie series and animations.
r621 m_pieRadius = m_rect.height() / 2;
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 if (m_rect.width() < m_rect.height())
Jani Honkonen
Refactoring pie series and animations.
r621 m_pieRadius = m_rect.width() / 2;
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 // apply size factor
Jani Honkonen
Refactoring pie series and animations.
r621 m_pieRadius *= m_series->pieSize();
}
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 PieSliceData PieChartItem::sliceData(QPieSlice *slice)
Jani Honkonen
Refactoring pie series and animations.
r621 {
Jani Honkonen
Getting rid of friend classes in pie API
r676 PieSliceData sliceData = slice->data_ptr()->m_data;
Jani Honkonen
rename PieSlice -> PieSliceItem
r673 sliceData.m_center = PieSliceItem::sliceCenter(m_pieCenter, m_pieRadius, slice);
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 sliceData.m_radius = m_pieRadius;
Jani Honkonen
Adding PIMPL to pie
r669 sliceData.m_angleSpan = slice->endAngle() - slice->startAngle();
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 return sliceData;
Jani Honkonen
Refactoring pie series and animations.
r621 }
Jani Honkonen
Getting rid of slice pointer in PieSliceLayout.
r629 PieLayout PieChartItem::calculateLayout()
Jani Honkonen
Refactoring pie series and animations.
r621 {
calculatePieLayout();
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 PieLayout layout;
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 foreach (QPieSlice* s, m_series->slices()) {
Jani Honkonen
Refactoring pie series and animations.
r621 if (m_slices.contains(s)) // calculate layout only for those slices that are already visible
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 layout.insert(s, sliceData(s));
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 return layout;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Getting rid of slice pointer in PieSliceLayout.
r629 void PieChartItem::applyLayout(const PieLayout &layout)
Jani Honkonen
Pie chart refactoring
r142 {
Michal Klocek
Refactors chartitem...
r677 if (animator())
animator()->updateLayout(this, layout);
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 else
setLayout(layout);
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 void PieChartItem::updateLayout(QPieSlice *slice, const PieSliceData &sliceData)
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 {
Michal Klocek
Refactors barchart axis hadnling...
r679 if (animator())
animator()->updateLayout(this, slice, sliceData);
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 else
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 setLayout(slice, sliceData);
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 }
Jani Honkonen
Getting rid of slice pointer in PieSliceLayout.
r629 void PieChartItem::setLayout(const PieLayout &layout)
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 {
Jani Honkonen
Getting rid of slice pointer in PieSliceLayout.
r629 foreach (QPieSlice *slice, layout.keys()) {
Jani Honkonen
rename PieSlice -> PieSliceItem
r673 PieSliceItem *item = m_slices.value(slice);
Q_ASSERT(item);
item->setSliceData(layout.value(slice));
item->updateGeometry();
item->update();
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 }
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 }
Jani Honkonen
Rename PieSliceLayout -> PieSliceData. A "layout" is a bad name for this.
r668 void PieChartItem::setLayout(QPieSlice *slice, const PieSliceData &sliceData)
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 {
// find slice
Jani Honkonen
rename PieSlice -> PieSliceItem
r673 PieSliceItem *item = m_slices.value(slice);
Q_ASSERT(item);
item->setSliceData(sliceData);
item->updateGeometry();
item->update();
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 }
void PieChartItem::destroySlice(QPieSlice *slice)
{
delete m_slices.take(slice);
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Rename piepresenter -> piechartitem
r568 #include "moc_piechartitem_p.cpp"
Jani Honkonen
Pie chart refactoring
r142
QTCOMMERCIALCHART_END_NAMESPACE