2023-08-27 21:44:50 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-08-27 22:17:30 +00:00
|
|
|
#include "statistics/segment_tree.h"
|
2023-08-27 21:44:50 +00:00
|
|
|
#include "statistics/statistics_common.h"
|
|
|
|
#include "statistics/view/abstract_chart_view.h"
|
2023-09-08 09:15:35 +00:00
|
|
|
#include "ui/effects/animation_value.h"
|
2023-08-27 21:44:50 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
struct StatisticalChart;
|
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
namespace Statistic {
|
|
|
|
|
|
|
|
struct Limits;
|
|
|
|
|
2023-11-16 23:41:36 +00:00
|
|
|
class BarChartView final : public AbstractChartView {
|
2023-08-27 21:44:50 +00:00
|
|
|
public:
|
2023-11-17 00:28:33 +00:00
|
|
|
BarChartView(bool isStack);
|
2023-11-16 23:41:36 +00:00
|
|
|
~BarChartView() override final;
|
2023-08-27 21:44:50 +00:00
|
|
|
|
2023-09-19 10:02:50 +00:00
|
|
|
void paint(QPainter &p, const PaintContext &c) override;
|
2023-08-27 21:44:50 +00:00
|
|
|
|
|
|
|
void paintSelectedXIndex(
|
|
|
|
QPainter &p,
|
2023-09-19 10:02:50 +00:00
|
|
|
const PaintContext &c,
|
2023-09-05 14:03:08 +00:00
|
|
|
int selectedXIndex,
|
|
|
|
float64 progress) override;
|
2023-08-27 21:44:50 +00:00
|
|
|
|
2023-09-05 17:04:37 +00:00
|
|
|
int findXIndexByPosition(
|
|
|
|
const Data::StatisticalChart &chartData,
|
|
|
|
const Limits &xPercentageLimits,
|
|
|
|
const QRect &rect,
|
|
|
|
float64 x) override;
|
|
|
|
|
2023-08-27 21:44:50 +00:00
|
|
|
[[nodiscard]] HeightLimits heightLimits(
|
|
|
|
Data::StatisticalChart &chartData,
|
|
|
|
Limits xIndices) override;
|
|
|
|
|
2023-08-27 22:17:30 +00:00
|
|
|
private:
|
2023-09-19 10:02:50 +00:00
|
|
|
void paintChartAndSelected(QPainter &p, const PaintContext &c);
|
2023-09-08 09:15:35 +00:00
|
|
|
|
2023-08-27 22:17:30 +00:00
|
|
|
struct {
|
|
|
|
Limits full;
|
|
|
|
std::vector<int> ySum;
|
|
|
|
SegmentTree ySumSegmentTree;
|
|
|
|
} _cachedHeightLimits;
|
|
|
|
|
2023-11-17 00:28:33 +00:00
|
|
|
const bool _isStack;
|
|
|
|
DoubleLineRatios _cachedLineRatios; // Non-stack.
|
2023-09-08 09:15:35 +00:00
|
|
|
Limits _lastPaintedXIndices;
|
|
|
|
int _lastSelectedXIndex = -1;
|
|
|
|
float64 _lastSelectedXProgress = 0;
|
|
|
|
|
2023-11-17 00:28:33 +00:00
|
|
|
CachedSelectedPoints _selectedPoints; // Non-stack.
|
|
|
|
|
2023-08-27 21:44:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Statistic
|