// // Created by Codex on 2025/12/10. // #pragma once #include "creeper-qt/utility/theme/theme.hh" #include "creeper-qt/utility/wrapper/common.hh" #include "creeper-qt/utility/wrapper/property.hh" #include "creeper-qt/utility/wrapper/widget.hh" #include "qcustomplot/qcustomplot.h" #include #include #include #include #include #include namespace creeper { class SumLinePlot; namespace line_widget::internal { class LinePlot: public QCustomPlot { public: LinePlot(); ~LinePlot() override; void load_theme_manager(ThemeManager& mgr); void set_data(const QVector& points); void set_max_points(int count); protected: void paintEvent(QPaintEvent* event) override; private: void initialize_plot(); void update_graph(); void apply_theme(); void reset_graph_range(); void trim_points(); QVector points_; bool initialized_ = false; std::optional scheme_; QCPGraph* graph_ = nullptr; int max_points_ = 240; double default_y_range_ = 100.0; }; } // namespace line_widget::internal namespace line_widget::pro { using Token = common::Token; struct MaxPoints: Token { int count; explicit MaxPoints(int c): count{ c } { } void apply(auto& self) const { self.set_max_points(count); } }; using PlotData = DerivedProp, [](auto& self, const auto& vec) { self.set_data(vec); }>; template concept trait = std::derived_from; CREEPER_DEFINE_CHECKER(trait); using namespace widget::pro; using namespace theme::pro; } // namespace line_widget::pro struct SumLinePlot : public Declarative> { using Declarative::Declarative; void paintEvent(QPaintEvent* event) override; }; } // namespace creeper