##// END OF EJS Templates
Fonts and background of the themes...
Fonts and background of the themes The theme demo app window color now matches the theme

File last commit:

r611:e622b3a8d8a0
r614:ac346143dd38
Show More
piechartitem.cpp
144 lines | 3.8 KiB | text/x-c | CppLexer
Jani Honkonen
Rename piepresenter -> piechartitem
r568 #include "piechartitem_p.h"
Jani Honkonen
Add _p to pie internal headers
r353 #include "pieslice_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
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
Pie chart refactoring
r142 #include <QDebug>
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 #include <QPainter>
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289
Jani Honkonen
Pie chart refactoring
r142
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Jani Honkonen
Rename piepresenter -> piechartitem
r568 PieChartItem::PieChartItem(QGraphicsItem *parent, QPieSeries *series)
Jani Honkonen
Refactoring piechart API (and internals)
r174 :ChartItem(parent),
m_series(series)
Jani Honkonen
Pie chart refactoring
r142 {
Q_ASSERT(series);
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 connect(series, SIGNAL(changed()), this, SLOT(handleSeriesChanged()));
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
Rename piepresenter -> piechartitem
r568 void PieChartItem::handleSeriesChanged()
Jani Honkonen
Refactoring piechart API (and internals)
r174 {
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 QVector<PieSliceLayout> sliceLayout = calculateLayout();
applyLayout(sliceLayout);
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 {
// TODO: optimize don't need to handle all slices
QVector<PieSliceLayout> sliceLayout = calculateLayout();
applyLayout(sliceLayout);
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;
QVector<PieSliceLayout> sliceLayout = calculateLayout();
applyLayout(sliceLayout);
update();
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157
Jani Honkonen
Rename piepresenter -> piechartitem
r568 QVector<PieSliceLayout> PieChartItem::calculateLayout()
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
QPointF center;
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 center.setX(m_rect.left() + (m_rect.width() * m_series->pieHorizontalPosition()));
center.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
qreal radius = m_rect.height() / 2;
if (m_rect.width() < m_rect.height())
radius = 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
Renamed the "factor" stuff from pie series API.
r498 radius *= m_series->pieSize();
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 QVector<PieSliceLayout> layout;
foreach (QPieSlice* s, m_series->slices()) {
PieSliceLayout sliceLayout;
sliceLayout.m_data = s;
sliceLayout.m_center = PieSlice::sliceCenter(center, radius, s);
sliceLayout.m_radius = radius;
sliceLayout.m_startAngle = s->startAngle();
sliceLayout.m_angleSpan = s->m_angleSpan;
layout << sliceLayout;
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 return layout;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Rename piepresenter -> piechartitem
r568 void PieChartItem::applyLayout(const QVector<PieSliceLayout> &layout)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 //if(m_animator)
// m_animator->applyLayout(this,points);
//else
setLayout(layout);
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Rename piepresenter -> piechartitem
r568 void PieChartItem::setLayout(const QVector<PieSliceLayout> &layout)
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 {
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 foreach (PieSliceLayout l, layout) {
// find slice
PieSlice *slice = m_slices.value(l.m_data);
if (!slice) {
// add a new slice
slice = new PieSlice(this);
m_slices.insert(l.m_data, slice);
// connect signals
connect(l.m_data, SIGNAL(changed()), this, SLOT(handleSliceChanged()));
connect(slice, SIGNAL(clicked()), l.m_data, SIGNAL(clicked()));
connect(slice, SIGNAL(hoverEnter()), l.m_data, SIGNAL(hoverEnter()));
connect(slice, SIGNAL(hoverLeave()), l.m_data, SIGNAL(hoverLeave()));
}
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 // update
slice->setLayout(l);
slice->updateGeometry();
slice->update();
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 }
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 // delete slices
foreach (QPieSlice *s, m_slices.keys()) {
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 bool found = false;
foreach (PieSliceLayout l, layout) {
if (l.m_data == s)
found = true;
}
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 if (!found)
delete m_slices.take(s);
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
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