##// END OF EJS Templates
pie: finetuning donut animations...
Jani Honkonen -
r1758:ef94aea95359
parent child
Show More
@@ -115,6 +115,14 MainWidget::MainWidget(QWidget* parent)
115 m_endAngle->setValue(m_series->pieEndAngle());
115 m_endAngle->setValue(m_series->pieEndAngle());
116 m_endAngle->setSingleStep(1);
116 m_endAngle->setSingleStep(1);
117
117
118 m_isDonut = new QCheckBox();
119
120 m_donutInnerSize = new QDoubleSpinBox();
121 m_donutInnerSize->setMinimum(0.0);
122 m_donutInnerSize->setMaximum(1.0);
123 m_donutInnerSize->setSingleStep(0.1);
124 m_donutInnerSize->setValue(m_series->donutInnerSize());
125
118 QPushButton *appendSlice = new QPushButton("Append slice");
126 QPushButton *appendSlice = new QPushButton("Append slice");
119 QPushButton *insertSlice = new QPushButton("Insert slice");
127 QPushButton *insertSlice = new QPushButton("Insert slice");
120 QPushButton *removeSlice = new QPushButton("Remove selected slice");
128 QPushButton *removeSlice = new QPushButton("Remove selected slice");
@@ -125,6 +133,8 MainWidget::MainWidget(QWidget* parent)
125 seriesSettingsLayout->addRow("Size factor", m_sizeFactor);
133 seriesSettingsLayout->addRow("Size factor", m_sizeFactor);
126 seriesSettingsLayout->addRow("Start angle", m_startAngle);
134 seriesSettingsLayout->addRow("Start angle", m_startAngle);
127 seriesSettingsLayout->addRow("End angle", m_endAngle);
135 seriesSettingsLayout->addRow("End angle", m_endAngle);
136 seriesSettingsLayout->addRow("Is donut", m_isDonut);
137 seriesSettingsLayout->addRow("Donut inner size", m_donutInnerSize);
128 seriesSettingsLayout->addRow(appendSlice);
138 seriesSettingsLayout->addRow(appendSlice);
129 seriesSettingsLayout->addRow(insertSlice);
139 seriesSettingsLayout->addRow(insertSlice);
130 seriesSettingsLayout->addRow(removeSlice);
140 seriesSettingsLayout->addRow(removeSlice);
@@ -136,6 +146,8 MainWidget::MainWidget(QWidget* parent)
136 connect(m_sizeFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
146 connect(m_sizeFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
137 connect(m_startAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
147 connect(m_startAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
138 connect(m_endAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
148 connect(m_endAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
149 connect(m_isDonut, SIGNAL(toggled(bool)), this, SLOT(updateSerieSettings()));
150 connect(m_donutInnerSize, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
139 connect(appendSlice, SIGNAL(clicked()), this, SLOT(appendSlice()));
151 connect(appendSlice, SIGNAL(clicked()), this, SLOT(appendSlice()));
140 connect(insertSlice, SIGNAL(clicked()), this, SLOT(insertSlice()));
152 connect(insertSlice, SIGNAL(clicked()), this, SLOT(insertSlice()));
141 connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice()));
153 connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice()));
@@ -239,6 +251,8 void MainWidget::updateSerieSettings()
239 m_series->setPieSize(m_sizeFactor->value());
251 m_series->setPieSize(m_sizeFactor->value());
240 m_series->setPieStartAngle(m_startAngle->value());
252 m_series->setPieStartAngle(m_startAngle->value());
241 m_series->setPieEndAngle(m_endAngle->value());
253 m_series->setPieEndAngle(m_endAngle->value());
254 m_series->setDonut(m_isDonut->isChecked());
255 m_series->setDonutInnerSize(m_donutInnerSize->value());
242 }
256 }
243
257
244 void MainWidget::updateSliceSettings()
258 void MainWidget::updateSliceSettings()
@@ -72,6 +72,8 private:
72 QDoubleSpinBox* m_sizeFactor;
72 QDoubleSpinBox* m_sizeFactor;
73 QDoubleSpinBox* m_startAngle;
73 QDoubleSpinBox* m_startAngle;
74 QDoubleSpinBox* m_endAngle;
74 QDoubleSpinBox* m_endAngle;
75 QCheckBox* m_isDonut;
76 QDoubleSpinBox* m_donutInnerSize;
75
77
76 QLineEdit* m_sliceName;
78 QLineEdit* m_sliceName;
77 QDoubleSpinBox* m_sliceValue;
79 QDoubleSpinBox* m_sliceValue;
@@ -60,8 +60,11 ChartAnimation* PieAnimation::addSlice(PieSliceItem *sliceItem, const PieSliceDa
60 else
60 else
61 startValue.m_startAngle = sliceData.m_startAngle + (sliceData.m_angleSpan / 2);
61 startValue.m_startAngle = sliceData.m_startAngle + (sliceData.m_angleSpan / 2);
62 startValue.m_angleSpan = 0;
62 startValue.m_angleSpan = 0;
63 animation->setValue(startValue, sliceData);
64
63
64 if (sliceData.m_donut)
65 startValue.m_radius = sliceData.m_innerRadius;
66
67 animation->setValue(startValue, sliceData);
65 animation->setDuration(ChartAnimationDuration);
68 animation->setDuration(ChartAnimationDuration);
66 animation->setEasingCurve(QEasingCurve::OutQuart);
69 animation->setEasingCurve(QEasingCurve::OutQuart);
67
70
@@ -75,6 +78,9 ChartAnimation* PieAnimation::removeSlice(PieSliceItem *sliceItem)
75 animation->stop();
78 animation->stop();
76
79
77 PieSliceData endValue = animation->currentSliceValue();
80 PieSliceData endValue = animation->currentSliceValue();
81 if (endValue.m_donut)
82 endValue.m_radius = endValue.m_innerRadius;
83 else
78 endValue.m_radius = 0;
84 endValue.m_radius = 0;
79 endValue.m_startAngle = endValue.m_startAngle + endValue.m_angleSpan;
85 endValue.m_startAngle = endValue.m_startAngle + endValue.m_angleSpan;
80 endValue.m_angleSpan = 0;
86 endValue.m_angleSpan = 0;
@@ -110,6 +110,7 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &
110 result.m_angleSpan = linearPos(startValue.m_angleSpan, endValue.m_angleSpan, progress);
110 result.m_angleSpan = linearPos(startValue.m_angleSpan, endValue.m_angleSpan, progress);
111 result.m_slicePen = linearPos(startValue.m_slicePen, endValue.m_slicePen, progress);
111 result.m_slicePen = linearPos(startValue.m_slicePen, endValue.m_slicePen, progress);
112 result.m_sliceBrush = linearPos(startValue.m_sliceBrush, endValue.m_sliceBrush, progress);
112 result.m_sliceBrush = linearPos(startValue.m_sliceBrush, endValue.m_sliceBrush, progress);
113 result.m_innerRadius = linearPos(startValue.m_innerRadius, endValue.m_innerRadius, progress);
113
114
114 return qVariantFromValue(result);
115 return qVariantFromValue(result);
115 }
116 }
General Comments 0
You need to be logged in to leave comments. Login now