Fixed animation processing after selecting part of pie chart.
This commit is contained in:
parent
7ac9ab3a51
commit
6ffe555f6a
|
@ -447,6 +447,9 @@ void StackLinearChartView::paintZoomed(QPainter &p, const PaintContext &c) {
|
|||
selectedLineIndex = k;
|
||||
}
|
||||
}
|
||||
if (_piePartController.isFinished()) {
|
||||
_piePartAnimation.stop();
|
||||
}
|
||||
paintPieText(p, c);
|
||||
|
||||
if (selectedLineIndex >= 0) {
|
||||
|
@ -591,7 +594,7 @@ void StackLinearChartView::PiePartController::update(int id) {
|
|||
}
|
||||
}
|
||||
|
||||
float64 StackLinearChartView::PiePartController::progress(int id) {
|
||||
float64 StackLinearChartView::PiePartController::progress(int id) const {
|
||||
const auto it = _startedAt.find(id);
|
||||
if (it == end(_startedAt)) {
|
||||
return 0.;
|
||||
|
@ -607,7 +610,7 @@ float64 StackLinearChartView::PiePartController::progress(int id) {
|
|||
|
||||
QPointF StackLinearChartView::PiePartController::offset(
|
||||
LineId id,
|
||||
float64 angle) {
|
||||
float64 angle) const {
|
||||
const auto offset = st::statisticsPieChartPartOffset * progress(id);
|
||||
const auto radians = angle * M_PI / 180.;
|
||||
return { std::cos(radians) * offset, std::sin(radians) * offset };
|
||||
|
@ -617,6 +620,16 @@ auto StackLinearChartView::PiePartController::selected() const -> LineId {
|
|||
return _selected;
|
||||
}
|
||||
|
||||
bool StackLinearChartView::PiePartController::isFinished() const {
|
||||
for (const auto &[id, _] : _startedAt) {
|
||||
const auto p = progress(id);
|
||||
if (p > 0 && p < 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void StackLinearChartView::handleMouseMove(
|
||||
const Data::StatisticalChart &chartData,
|
||||
const QPoint ¢er,
|
||||
|
|
|
@ -105,9 +105,10 @@ private:
|
|||
public:
|
||||
using LineId = int;
|
||||
bool set(LineId id);
|
||||
[[nodiscard]] float64 progress(LineId id);
|
||||
[[nodiscard]] QPointF offset(LineId id, float64 angle);
|
||||
[[nodiscard]] float64 progress(LineId id) const;
|
||||
[[nodiscard]] QPointF offset(LineId id, float64 angle) const;
|
||||
[[nodiscard]] LineId selected() const;
|
||||
[[nodiscard]] bool isFinished() const;
|
||||
|
||||
private:
|
||||
void update(LineId id);
|
||||
|
|
Loading…
Reference in New Issue